Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dirty hack to make keepassxc work. #68

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sidequestboy
Copy link

@sidequestboy sidequestboy commented May 19, 2020

So, I did some debugging about #66 and isolated the problem.

It seems that inside create_win_return_wid, we spawn the program which seems to create two visible windows in succession, and we grab the first one while it's actually the second window we want to store.

Here's the output of my patch which gets the dropdown working, though we definitely need a better approach than this! I wanted to touch base before I try to fix it for real. Maybe you have an idea of what the best approach would be.

spawned program keepassxc with pid 1544112
found some wids:
52428815 52428806
52428815 is visible
52428806 is visible
deciding on wid: 52428815

p.s. I wasn't sure the best way to share my troubleshooting, so I made this "draft pull request". Obviously I don't actually want this merged as is.

@noctuid
Copy link
Owner

noctuid commented May 19, 2020

I only ever get one wid. Do you actually see two windows? Ideally there would be some way to distinguish between them and ignore one. Could you give me the output of xprop -id <wid> and xwininfo -id <wid> for both window ids?

@sidequestboy
Copy link
Author

OH, I figured out what the window is - it's the system tray icon. Disabling the system tray icon in my preferences makes tdrop work. Maybe we can add a check for "redirect override" windows:

./tdrop keepassxc
spawned program keepassxc with pid 1606759
found some wids:
77594639 77594630
77594639 is visible
77594630 is visible
deciding on wid: 77594639

So the one that makes the dropdown work (77594639):

$ xprop -id 77594639
_NET_WM_USER_TIME(CARDINAL) = 186403759
_NET_WM_DESKTOP(CARDINAL) = 3
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
...
XdndAware(ATOM) = BITMAP
WM_NAME(STRING) = "pass.kdbx [Locked] - KeePassXC"
_NET_WM_NAME(UTF8_STRING) = "pass.kdbx [Locked] - KeePassXC"
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x3, 0x3e, 0x7e, 0x0, 0x0
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_XEMBED_INFO(_XEMBED_INFO) = 0x0, 0x1
WM_CLIENT_LEADER(WINDOW): window id # 0x4a00008
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                window id # of group leader: 0x4a00008
WM_CLIENT_MACHINE(STRING) = "viper"
_NET_WM_PID(CARDINAL) = 1606759
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 77594640
WM_CLASS(STRING) = "keepassxc", "KeePassXC"
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                user specified location: 996, 55
                user specified size: 924 by 1002
                program specified minimum size: 724 by 440
                window gravity: Static

$ xwininfo -id 77594639

xwininfo: Window id: 0x4a0000f "pass.kdbx [Locked] - KeePassXC"

  Absolute upper-left X:  970
  Absolute upper-left Y:  52
  Relative upper-left X:  970
  Relative upper-left Y:  52
  Width: 924
  Height: 1002
  Depth: 24
  Visual: 0x152
  Visual Class: TrueColor
  Border width: 3
  Class: InputOutput
  Colormap: 0x4a0000e (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +970+52  -20+52  -20-20  +970-20
  -geometry 924x1002-20-20

and the one which doesn't work (the systray window):

$ xprop -id 77594630
_NET_WM_ICON_NAME(UTF8_STRING) =
XdndAware(ATOM) = BITMAP
WM_NAME(STRING) =
_NET_WM_NAME(UTF8_STRING) = "KeePassXC"
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x1, 0x0, 0x0, 0x0
_NET_WM_WINDOW_TYPE(ATOM) = _KDE_NET_WM_WINDOW_TYPE_OVERRIDE, _NET_WM_WINDOW_TYPE_NORMAL
_XEMBED_INFO(_XEMBED_INFO) = 0x0, 0x1
WM_CLIENT_LEADER(WINDOW): window id # 0x4a00008
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                window id # of group leader: 0x4a00008
WM_CLIENT_MACHINE(STRING) = "viper"
_NET_WM_PID(CARDINAL) = 1606759
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 77594631
WM_CLASS(STRING) = "keepassxc", "KeePassXC"
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                user specified location: 0, 0
                user specified size: 22 by 22
                program specified minimum size: 22 by 22
                window gravity: Static

$ xwininfo -id 77594630

xwininfo: Window id: 0x4a00006 "KeePassXC"

  Absolute upper-left X:  1848
  Absolute upper-left Y:  8
  Relative upper-left X:  8
  Relative upper-left Y:  8
  Width: 16
  Height: 16
  Depth: 24
  Visual: 0x20
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x4a00005 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: yes
  Corners:  +1848+8  -56+8  -56-1056  +1848-1056
  -geometry 16x16-56+8

@noctuid
Copy link
Owner

noctuid commented May 22, 2020

Maybe we can add a check for "redirect override" windows

That may be good enough, but I don't think it's perfect (hypothetically you could want to disable decorations for a some program you wanted to make a dropdown for). Probably I will do it for now if I can't think of anything better. It seems strange to me that the system tray icon gets the same class name as the actual program.

Handling all these special cases in tdrop is incredibly ugly. What I'm thinking of doing at some point is adding support for a config file (with all the current defaults moved into it). You could do something like this:

[keepassxc]
validate_wid_cmd = "xwininfo -id $wid | grep --quiet 'Override Redirect State: no'"

Parsing a config file every invocation would probably be too slow, so either this could only be used for configuration program creation or I would need to rewrite tdrop in another language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants