xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
579 stars 271 forks source link

X.H.ManageHelpers: `isNotification` predicate #877

Closed ilya-bobyr closed 4 months ago

ilya-bobyr commented 4 months ago

Description

Very similar to isDialog, isNotification checks for the _NET_WM_WINDOW_TYPE_NOTIFICATION value in the _NET_WM_WINDOW_TYPE property.

Checklist

geekosaur commented 4 months ago

Those have to be tested manually, because there's no way to create a window in CI.

ilya-bobyr commented 4 months ago

Those have to be tested manually, because there's no way to create a window in CI.

I did test it manually. I am using it in my config. Sorry, I should have stated it in the PR check list, I guess.

liskin commented 4 months ago

Thanks, and another thanks for fixing the typos in CHANGES!

Out of curiosity, https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm46485863906176 says that "This property is typically used on override-redirect windows" and these are normally unmanaged by xmonad, so I'm wondering what your use case is for this. Can you enlighten me pls? :-)

ilya-bobyr commented 4 months ago

Both Firefox and Chrome set it on notification windows, created on behalf of web sites ("Web Notifications"). You can test them here: https://www.bennish.net/web-notifications.html

For Chrome xprop shows this:

_NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE, _NET_WM_STATE_SKIP_TASKBAR
_NET_WM_USER_TIME(CARDINAL) = 0
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified location: 2301, 993
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x0, 0x0, 0x0
XdndAware(ATOM) = BITMAP
_NET_WM_ICON(CARDINAL) =        Icon (128 x 128):
[...icon...]
_NET_WM_BYPASS_COMPOSITOR(CARDINAL) = 2
WM_NAME(UTF8_STRING) =
_NET_WM_NAME(UTF8_STRING) =
WM_WINDOW_ROLE(STRING) = "popup"
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NOTIFICATION
_NET_WM_PID(CARDINAL) = 98907
WM_CLIENT_MACHINE(STRING) = "[cut]"
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, _NET_WM_PING, _NET_WM_SYNC_REQUEST

For Firefox xprop shows this:

_NET_WM_OPAQUE_REGION(CARDINAL) =
_NET_WM_DESKTOP(CARDINAL) = 6
_NET_WM_STATE(ATOM) =
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                Initial state is Normal State.
                window id # of group leader: 0x2800001
_GTK_THEME_VARIANT(UTF8_STRING) = "dark"
_NET_WM_BYPASS_COMPOSITOR(CARDINAL) = 2
WM_WINDOW_ROLE(STRING) = "alert"
XdndAware(ATOM) = BITMAP
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x0, 0x0, 0x0
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NOTIFICATION
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 41943423, 41943424
_NET_WM_USER_TIME(CARDINAL) = 1427931
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x280017e
WM_CLIENT_LEADER(WINDOW): window id # 0x2800001
_NET_WM_PID(CARDINAL) = 75017
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "[cut]"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified location: 0, 0
                program specified minimum size: 0 by 0
                program specified maximum size: 16384 by 16384
                program specified base size: 0 by 0
                window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Alert", "firefox"
WM_ICON_NAME(STRING) =
_NET_WM_ICON_NAME(UTF8_STRING) =
WM_NAME(STRING) =
_NET_WM_NAME(UTF8_STRING) =

Chrome provides a position via WM_NORMAL_HINTS(WM_SIZE_HINTS), but Firefox does not. And _NET_WM_STATE for Firefox is empty, while for Chrome it is not:

_NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE, _NET_WM_STATE_SKIP_TASKBAR

I wonder if it is the _NET_WM_STATE that makes XMonad position Chrome notifications as a notification window out of the box. Notifications from Firefox, in my rather basic config, would be mapped as a normal window.

This started happening rather recently, maybe a couple of weeks ago. Currently, I am running Firefox 123.0, but I am not sure when did it start.

geekosaur commented 4 months ago

What does xwininfo show? override_redirect is not a window property, it is a window attribute.

liskin commented 4 months ago

I wonder if it is the _NET_WM_STATE that makes XMonad position Chrome notifications as a notification window out of the box. Notifications from Firefox, in my rather basic config, would be mapped as a normal window.

This started happening rather recently, maybe a couple of weeks ago. Currently, I am running Firefox 123.0, but I am not sure when did it start.

Chrome definitely sets override_redirect, and so did Firefox most likely. This is probably worth reporting as a bug to them, although it's quite a marginal usecase – most Firefox users run a notification daemon, either as part of their desktop environment (GNOME, KDE, XFCE, Mate all have one I think) or as a separate thing (I use https://github.com/dunst-project/dunst). The browser's ability to display notifications itself is just a fallback. I'm almost surprised they haven't dropped it by now :-)

geekosaur commented 4 months ago

Actually they still recommend not going through a notification daemon, because they can't control drawing etc. if you do.

ilya-bobyr commented 4 months ago

Chrome:

xwininfo: Window id: 0x740001b (has no name)
  [...position properties...]
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: yes
  [...size-properties...]

Firefox:

xwininfo: Window id: 0x2800209 (has no name)
  [...position properties...]
  Depth: 32
  Visual: 0x82
  Visual Class: TrueColor
  Border width: 3
  Class: InputOutput
  Colormap: 0x280002c (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
  [...size-properties...]
geekosaur commented 4 months ago

Override Redirect State: no

Report that to the Firefox devs.

ilya-bobyr commented 4 months ago

Override Redirect State: no

Report that to the Firefox devs.

It seems reasonable to search for an existing bug(s) and/or discussions. But searching for "Override Redirect" (or "override_redirect") in the Mozilla bug list shows no results: https://bugzilla.mozilla.org/buglist.cgi?quicksearch=Override+Redirect

Any suggestions?

I'm not particularly familiar with XWindow. Would you be interested in providing a bit more reasoning as to why Firefox should set the override redirect flag? Reading the "The Xlib Manual: 3.2.8 Override Redirect Flag" and "The Xlib Manual: 10.11.3 MapRequest Events" it seems that the controlling process needs to position the window on their own when the flag is set.

geekosaur commented 4 months ago

The primary purpose of override_redirect is to prevent a window from being managed by the window manager. That a program must subsequently position the window itself is a side effect of this, but without override_redirect xmonad (and indeed any other wm) will treat it as a normal application window. I expect this is usually not noticed because the window is floated (which is true of any non-tiling window manager).

ilya-bobyr commented 4 months ago

Thank you.

I've filed "X11: Firefox does not set Override Redirect flag on notification windows": https://bugzilla.mozilla.org/show_bug.cgi?id=1883532

geekosaur commented 4 months ago

I should also mention that the EWMH specification was quoted earlier and said that notification windows should be override_redirect.

ilya-bobyr commented 4 months ago

Added a note about the EWMH spec suggestion to the bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1883532#c1