joewing / jwm

Joe's Window Manager
http://joewing.net/projects/jwm
MIT License
501 stars 83 forks source link

jwm's sloppy focus breaks around _NET_WM_WINDOW_TYPE_DESKTOP #613

Open achadwick opened 1 week ago

achadwick commented 1 week ago

Version: v2.4.4 (current Debian stable). It'll affect main as of 84f2adce63f5fbefbb62eafa7947d1473786085d too, I think.

Background: Debian stable's stock configuration of pcmanfm-qt deploys a desktop window via autostart (I use <StartupCommand>dex -a &amp;</StartupCommand>, and that's why I see this). The specifics of the file manger don't matter so much: it's just a fairly well behaved client with a desktop window that sets _NET_WM_WINDOW_TYPE_DESKTOP to let the wm know what it is. I'm also using <FocusModel>sloppy</FocusModel>.

What I expected: the new desktop window should behave like jwm's own root window, and not accept the sloppy focus. It should instead be click-to-focus regardless of the sloppy settings.

What I see: pcmanfm-qt's new desktop window takes sloppy focus as if it was any other window. jwm's own root window behaves differently, and does not accept the sloppily assigned focus (because it doesn't need it).

Analysis: I think that HandleEnterNotify() should make an exception for client-provided desktop windows, and not give the focus to them. That leaves focus assignment to be granted in HandleButtonEvent() instead, by my reading.

Window properties: jwm could use the presence of _NET_WM_WINDOW_TYPE_DESKTOP, either alone or along with _NET_WM_STATE_SKIP_TASKBAR, as a way of detecting such client-provided desktop windows.

Potential stumbling blocks: client desktop windows like this do accept focus, and it is in fact useful. It allows cursor keyboard navigation to work amongst the desktop icons.

Potential future stuff: perhaps it would be nice to provide jwm's own root menu popup with one type of click, and pass through other clicks to such desktop windows provided by clients. I guess that'd be a whole new of C and A for <Mouse context="C">A</>, however.

$ xprop
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x600011
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_STICK, _NET_WM_ACTION_BELOW, _NET_WM_ACTION_ABOVE
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 0, 0
_NET_WM_STATE(ATOM) = _NET_WM_STATE_STICKY, _NET_WM_STATE_SKIP_TASKBAR
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 4294967295
_NET_WM_ICON_NAME(UTF8_STRING) = 
XdndAware(ATOM) = BITMAP
WM_NAME(STRING) = 
_NET_WM_NAME(UTF8_STRING) = "pcmanfm-qt"
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x1, 0x0, 0x0, 0x0
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP
_XEMBED_INFO(_XEMBED_INFO) = 0x0, 0x1
WM_CLIENT_LEADER(WINDOW): window id # 0x600008
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                window id # of group leader: 0x600008
WM_CLIENT_MACHINE(STRING) = "bookworm"
_NET_WM_PID(CARDINAL) = 14156
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 6291463
WM_CLASS(STRING) = "pcmanfm-qt", "pcmanfm-qt"
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: 1796 by 1112
                program specified minimum size: 68 by 68
                window gravity: Static

The file manager package runs /etc/xdg/autostart/lxqt-desktop.desktop runs pcmanfm-qt --desktop --profile=lxqt, in case you want to replicate this with the specific dfm.

achadwick commented 3 days ago

I think I have a fix for this. I'll submit a PR.

JWM should probably not draw the desktop window's rectangle in the pager either. I'll put that in a separate commit, as it's a separate concern.