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

X.H.ManageHelpers: isNotification predicate #877

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

ilya-bobyr
Copy link
Contributor

Description

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

Checklist

  • I've read CONTRIBUTING.md

  • I've considered how to best test these changes (property, unit,
    manually, ...) and concluded:
    It is a rather trivial predicate. I do not see any examples of how to test those.
    isDialog has no tests either.
    So no tests :(

  • I updated the CHANGES.md file

Very similar to `isDialog`, `isNotification` checks for the
`_NET_WM_WINDOW_TYPE_NOTIFICATION` value in the `_NET_WM_WINDOW_TYPE`
property.
@geekosaur
Copy link
Contributor

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

@ilya-bobyr
Copy link
Contributor Author

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 liskin merged commit de5ef6c into xmonad:master Mar 4, 2024
18 checks passed
@liskin
Copy link
Member

liskin commented Mar 4, 2024

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
Copy link
Contributor Author

ilya-bobyr commented Mar 4, 2024

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
Copy link
Contributor

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

@liskin
Copy link
Member

liskin commented Mar 4, 2024

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
Copy link
Contributor

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

@ilya-bobyr
Copy link
Contributor Author

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
Copy link
Contributor

Override Redirect State: no

Report that to the Firefox devs.

@ilya-bobyr
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@ilya-bobyr
Copy link
Contributor Author

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

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.

3 participants