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

Notification role window is not treated properly #4662

Closed
2 tasks done
nazar-pc opened this issue Jan 24, 2024 · 17 comments
Closed
2 tasks done

Notification role window is not treated properly #4662

nazar-pc opened this issue Jan 24, 2024 · 17 comments

Comments

@nazar-pc
Copy link
Contributor

Issue description

Firefox recently changes role of notifications from "utility" to "notification" and Qtile fails to treat it properly, more specifically notification window only shows up on the same group as Firefox itself and steals focus from currently active window.

My Qtile version is a bit old, so feel free to tell me if this was fixed already upstream.

Version

0.21.0

Backend

X11 (default)

Config

No response

Logs

No response

Required

  • I have searched past issues to see if this bug has already been reported, and it hasn't been.
  • I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.
@elParaguayo
Copy link
Member

Can you post an xprop of the notification window.

Please also confirm what the desired behaviour should be.

@nazar-pc
Copy link
Contributor Author

xprop:

_NET_WM_STATE(ATOM) = 
_NET_FRAME_EXTENTS(CARDINAL) = 1, 1, 1, 1
_NET_WM_DESKTOP(CARDINAL) = 1
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: 0x3600001
_GTK_THEME_VARIANT(UTF8_STRING) = 
_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) = 56623286, 56623287
_NET_WM_USER_TIME(CARDINAL) = 62597
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x36000b5
WM_CLIENT_LEADER(WINDOW): window id # 0x3600001
_NET_WM_PID(CARDINAL) = 9767
WM_LOCALE_NAME(STRING) = "uk_UA.UTF-8"
WM_CLIENT_MACHINE(STRING) = "nazar-pc"
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-nightly"
WM_ICON_NAME(STRING) = 
_NET_WM_ICON_NAME(UTF8_STRING) = 
WM_NAME(STRING) = 
_NET_WM_NAME(UTF8_STRING) = 

I expect that this notification will be sticky (remaining in top right corner when I switch groups) and to not steal focus when it opens.

@elParaguayo
Copy link
Member

The way we handle notification windows is to make them floating but they shouldn't steal focus. That code was in place back in 0.21.0 too.

When I create a notification window it doesn't steal focus so I'm not sure why this one is.

Our code doesn't make the notification "sticky".

@nazar-pc
Copy link
Contributor Author

nazar-pc commented Feb 1, 2024

Here is xprop of the older version of Firefox where notifications are working correctly (do not steal focus, sticky and shown on any group):

WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		Initial state is Normal State.
		window id # of group leader: 0x6600001
_NET_WM_BYPASS_COMPOSITOR(CARDINAL) = 2
WM_WINDOW_ROLE(STRING) = "alert"
XdndAware(ATOM) = BITMAP
_NET_WM_OPAQUE_REGION(CARDINAL) = 
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_UTILITY
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 106954891, 106954892
_NET_WM_USER_TIME(CARDINAL) = 624485161
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x660008a
WM_CLIENT_LEADER(WINDOW): window id # 0x6600001
_NET_WM_PID(CARDINAL) = 2002550
WM_LOCALE_NAME(STRING) = "uk_UA.UTF-8"
WM_CLIENT_MACHINE(STRING) = "nazar-pc"
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-nightly"
WM_ICON_NAME(STRING) = 
_NET_WM_ICON_NAME(UTF8_STRING) = 
WM_NAME(STRING) = 
_NET_WM_NAME(UTF8_STRING) = 

@nazar-pc
Copy link
Contributor Author

Any other information I can provide? I'd really like to fix this somehow.

@tych0
Copy link
Member

tych0 commented Feb 22, 2024

The only place I can really tell that we treat them differently is below,

diff --git a/libqtile/backend/x11/window.py b/libqtile/backend/x11/window.py
index 2f7fef90..342ee6a1 100644
--- a/libqtile/backend/x11/window.py
+++ b/libqtile/backend/x11/window.py
@@ -1240,7 +1240,7 @@ class _Window:

     @property
     def can_steal_focus(self):
-        return self.window.get_wm_type() != "notification"
+        return self.window.get_wm_type() not in ["notification", "utility"]

     def _do_focus(self):
         """

I don't know that we'd want to apply that patch (it may make e.g. gimp windows a bit wonky), but can you confirm whether that matches the behavior you expect?

@elParaguayo
Copy link
Member

I was reluctant to change that too.

The broader question seems to be whether we make notification windows static so they appear on every group.

@tych0
Copy link
Member

tych0 commented Feb 22, 2024

The broader question seems to be whether we make notification windows static so they appear on every group.

Yep, and IMO we don't. Stuff from libnotify is type notification, which means those will show up on every desktop. Perhaps an option to do so but off by default is the best we'd do. (But users can already do this right? they can hook client_new and make it static there?

@nazar-pc
Copy link
Contributor Author

I'm not sure if there is a standard for this, but are you saying that Firefox basically switched to incorrect (not appropriate) window type for their notification and they should fix it? I can workaround it on my end, but I am also interested in knowing what is the root cause here and where it should, ideally, be fixed.

@tych0
Copy link
Member

tych0 commented Feb 22, 2024

They definitely changed it. Whether it's incorrect is a matter of opinion. I believe they've made a correct decision here. If you read https://specifications.freedesktop.org/wm-spec/1.5/ar01s05.html#idm44882398096864 it says of "utility" (i.e. the old style):

_NET_WM_WINDOW_TYPE_UTILITY indicates a small persistent utility window, such as a palette or toolbox. It is distinct from type TOOLBAR because it does not correspond to a toolbar torn off from the main application. It's distinct from type DIALOG because it isn't a transient dialog, the user will probably keep it open while they're working. Windows of this type may set the WM_TRANSIENT_FOR hint indicating the main application window.

and of notification

_NET_WM_WINDOW_TYPE_NOTIFICATION indicates a notification. An example of a notification would be a bubble appearing with informative text such as "Your laptop is running out of power" etc. This property is typically used on override-redirect windows.

IMO, we only want notifications to be displayed on the current desktop, vs. all of them (although, is that the old behavior of utility windows? I don't think so right?).

@elParaguayo
Copy link
Member

Should Firefox be setting the override-redirect attribute here? Would that solve the issue?

@elParaguayo
Copy link
Member

Ok. I've tested this a bit:

  • If I create a window with type _NET_WM_WINDOW_TYPE_NOTIFICATION then the window stays on the current group
  • If do the same and set the override redirect flag then the window is sticky and is visible on every group.

So, it looks like firefox should set that flag (which would be in line with the spec that Tych0 posted above).

@nazar-pc
Copy link
Contributor Author

Will it still capture focus in that case though?

@elParaguayo
Copy link
Member

I don't think so. Once I've done those steps, clicking on the window does not focus the window.

If you want to try it, this is the script I used:

#!/usr/bin/bash
xprop -f _NET_WM_WINDOW_TYPE 32a -set _NET_WM_WINDOW_TYPE _NET_WM_WINDOW_TYPE_NOTIFICATION -id $1
xdotool set_window --overrideredirect 1 $1
xdotool windowunmap $1
xdotool windowmap $1

I run it with the ID of an existing window.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 28, 2024
…erts. r=stransky

This prevents some WMs from stealing focus, see
qtile/qtile#4662

Differential Revision: https://phabricator.services.mozilla.com/D202701
ErichDonGubler pushed a commit to ErichDonGubler/firefox that referenced this issue Feb 28, 2024
…erts. r=stransky

This prevents some WMs from stealing focus, see
qtile/qtile#4662

Differential Revision: https://phabricator.services.mozilla.com/D202701
@nazar-pc
Copy link
Contributor Author

nazar-pc commented Apr 6, 2024

Firefox Nightly (at least) landed a change (can be seen in links above) that changes redirect property, now it looks like this:

_NET_FRAME_EXTENTS(CARDINAL) = 1, 1, 1, 1
_NET_WM_DESKTOP(CARDINAL) = 1
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
_NET_WM_STATE(ATOM) = _NET_WM_STATE_SKIP_TASKBAR, _NET_WM_STATE_ABOVE
WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		Initial state is Normal State.
		window id # of group leader: 0x3800001
_GTK_THEME_VARIANT(UTF8_STRING) = 
_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) = 58722054, 58722055
_NET_WM_USER_TIME(CARDINAL) = 19361677
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x3800705
WM_CLIENT_LEADER(WINDOW): window id # 0x3800001
_NET_WM_PID(CARDINAL) = 255177
WM_LOCALE_NAME(STRING) = "uk_UA.UTF-8"
WM_CLIENT_MACHINE(STRING) = "nazar-pc"
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-nightly"
WM_ICON_NAME(STRING) = 
_NET_WM_ICON_NAME(UTF8_STRING) = 
WM_NAME(STRING) = 
_NET_WM_NAME(UTF8_STRING) = 

However all of the issues still remain unfortunately.

I also tried patch from #4662 (comment) and it doesn't seem to make any difference.

I'm really looking forward to solution here. Upgraded to 0.25.0 already.

@nazar-pc
Copy link
Contributor Author

nazar-pc commented Apr 8, 2024

Actually #4662 (comment) breaks pop-up windows of various kinds, while they do still seem to steal focus, they are invisible behind other apps for some reason 👀

@nazar-pc
Copy link
Contributor Author

nazar-pc commented May 4, 2024

I was using notify-osd and it didn't play nicely with Firefox (I guess didn't support proper features) and after upgrading to Ubuntu 24.04 other apps stopped cooperating with it too, so I switched to https://github.com/Toqozz/wired-notify and now notifications are rendered properly.

@nazar-pc nazar-pc closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants