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

Respect _NET_WM_WINDOW_TYPE_DESKTOP atom #1472

Closed
wants to merge 0 commits into from

Conversation

grisha128
Copy link

Hi, I'd like to improve condition of desktop file managers (like pcmanfm --desktop) in Labwc and Wayland in general.

Back in X11, they indicated that they are desktops with _NET_WM_WINDOW_TYPE_DESKTOP atom.

In Wayland, there's a layer-shell obviously, but it doesn't come with Qt suit. Folks over KDE developed some 3rd-party component, but I doubt it will ever be stable enough for use by regular people/in enterprise: I encountered pretty flimsy bug 480240 immediately after integrating this component into my Qt project. This is by no means a stone thrown in the garden of layer-shell-qt developers - Qt is too big and fast moving to be able to keep up with it for basically anyone.

There's a not very clean solution of writing window rules for these desktops, like:

<windowRule identifier="...">
	<skipTaskbar>yes</skipTaskbar>
	<skipWindowSwitcher>yes</skipWindowSwitcher>
	<fixedPosition>yes</fixedPosition>
	<action name="Maximize"/>
	<action name="ToggleDecorations"/>
	<action name="ToggleAlwaysOnBottom"/>
</windowRule>

But these rules are not in every project's goals. For example, hyprland seems to be reluctant of it (#2093).

So my proposal for solution is adding support for _NET_WM_WINDOW_TYPE_DESKTOP in wlroots and asking compositor developers to check for this atom in their xwayland code. Since I'm a user of labwc, I already made the patch for this. Now we are waiting for wlroots folks. As far as I could test, the only change required for wlroots is:

diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h
index da3515d..66108e2 100644
--- a/include/xwayland/xwm.h
    b/include/xwayland/xwm.h
@@ -72,6  72,7 @@ enum atom_name {
 	NET_WM_WINDOW_TYPE_MENU,
 	NET_WM_WINDOW_TYPE_NOTIFICATION,
 	NET_WM_WINDOW_TYPE_SPLASH,
 	NET_WM_WINDOW_TYPE_DESKTOP,
 	DND_SELECTION,
 	DND_AWARE,
 	DND_STATUS,
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 2c437e8..97c805b 100644
--- a/xwayland/xwm.c
    b/xwayland/xwm.c
@@ -74,6  74,7 @@ static const char *const atom_map[ATOM_LAST] = {
 	[NET_WM_WINDOW_TYPE_MENU] = "_NET_WM_WINDOW_TYPE_MENU",
 	[NET_WM_WINDOW_TYPE_NOTIFICATION] = "_NET_WM_WINDOW_TYPE_NOTIFICATION",
 	[NET_WM_WINDOW_TYPE_SPLASH] = "_NET_WM_WINDOW_TYPE_SPLASH",
 	[NET_WM_WINDOW_TYPE_DESKTOP] = "_NET_WM_WINDOW_TYPE_DESKTOP",
 	[DND_SELECTION] = "XdndSelection",
 	[DND_AWARE] = "XdndAware",
 	[DND_STATUS] = "XdndStatus",
@@ -2297,6  2298,7 @@ bool wlr_xwayland_or_surface_wants_focus(
 		NET_WM_WINDOW_TYPE_NOTIFICATION,
 		NET_WM_WINDOW_TYPE_POPUP_MENU,
 		NET_WM_WINDOW_TYPE_SPLASH,
 		NET_WM_WINDOW_TYPE_DESKTOP,
 		NET_WM_WINDOW_TYPE_TOOLTIP,
 		NET_WM_WINDOW_TYPE_UTILITY,
 	};

I would like to ask you to review this patch so that I could correct it to comply with labwc guidelines by the time wlroots adds _NET_WM_WINDOW_TYPE_DESKTOP to their atoms.

@grisha128
Copy link
Author

@Consolatis
Copy link
Member

Consolatis commented Jan 24, 2024

Alternative labwc internal implementation:

That PR might need a rebase though as it was written for wlroots 0.16.x AFAIR.

@grisha128
Copy link
Author

Alternative labwc internal implementation:

* [[wip] xwayland: support querying more window types #1185](https://github.com/labwc/labwc/pull/1185)

That PR might need a rebase though as it was written for wlroots 0.16.x AFAIR.

Cool, good to know! If your PR goes first I'll be sure to adjust the patch ;)

@Consolatis
Copy link
Member

Consolatis commented Jan 24, 2024

Alternative labwc internal implementation:

* [[wip] xwayland: support querying more window types #1185](https://github.com/labwc/labwc/pull/1185)

That PR might need a rebase though as it was written for wlroots 0.16.x AFAIR.

Cool, good to know! If your PR goes first I'll be sure to adjust the patch ;)

I don't really have time for finishing that one currently. I'll try to rebase it later but no promises.

I would prefer the approach taken in #1185 over this one as it encapsulated the needed changes a bit more to the actual xwayland parts rather than sprinkle #if HAVE_XWAYLAND all around. So if you have time / motivation feel free to use parts / all of that PR as a base for your changes.

CC @jlindgren90 as it might be relevant for his use-cases as well.

@jlindgren90
Copy link
Contributor

It would be great to be able to query _NET_WM_WINDOW_TYPE in labwc. Unfortunately there is no public wlroots function to do that - one needs to be added (in addition to the new enum value that you've defined).

@Consolatis
Copy link
Member

Consolatis commented Jan 24, 2024

It would be great to be able to query _NET_WM_WINDOW_TYPE in labwc. Unfortunately there is no public wlroots function to do that - one needs to be added (in addition to the new enum value that you've defined).

Why is that? We do have all the raw atoms in xsurface->window_type. There should be no changes required for wlroots.

Edit:
https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/0.17/xwayland/xwm.c?ref_type=heads#L626 (it is a memcpy() from xcb reply)

@jlindgren90
Copy link
Contributor

I guess the approach taken in #1185 works without additional changes to wlroots. But it duplicates work that wlroots is already doing (opening up a new X server connection and performing a bunch of xcb_intern_atom calls that wlroots already did using its own connection).

@Consolatis
Copy link
Member

Consolatis commented Jan 24, 2024

I guess the approach taken in #1185 works without additional changes to wlroots. But it duplicates work that wlroots is already doing (opening up a new X server connection and performing a bunch of xcb_intern_atom calls that wlroots already did using its own connection).

Right. However it has the benefit of not requiring wlroots changes and thus us having to wait a year until we can use it :)
We also only have to make a single short-lived connection whenever xwayland restarts.

Edit:
Rebased #1185 on top of master and split off the useless example into its own commit. With that PR applied something like this should work on an unmodified wlroots:

bool is_desktop_surface = xwayland_surface_contains_window_type(
	xwayland_view->xwayland_surface, NET_WM_WINDOW_TYPE_DESKTOP);

Edit 2:
Note the timestamps (with #1185 applied on a slow ARM SBC):

00:00:05.192 [xwayland/server.c:108] Starting Xwayland on :1
00:00:05.597 [types/wlr_compositor.c:692] New wlr_surface 0xaaaaabd46850 (res 0xaaaaabd46c00)
00:00:05.599 [xwayland/server.c:273] Xserver is ready
00:00:05.603 [xwayland/xwm.c:1935] xfixes version: 6.0
00:00:05.604 [xwayland/xwm.c:1956] xres version: 1.2
00:00:05.624 [../src/xwayland.c:951] Connected to xwayland
00:00:05.624 [../src/xwayland.c:910] Syncing X11 atoms
00:00:05.627 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_DESKTOP: 318
00:00:05.627 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_DOCK: 319
00:00:05.627 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_TOOLBAR: 320
00:00:05.627 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_MENU: 298
00:00:05.627 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_UTILITY: 292
00:00:05.627 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_SPLASH: 300
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_DIALOG: 321
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_DROPDOWN_MENU: 295
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_POPUP_MENU: 296
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_TOOLTIP: 293
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_NOTIFICATION: 299
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_COMBO: 297
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_DND: 294
00:00:05.628 [../src/xwayland.c:925] Got X11 atom for _NET_WM_WINDOW_TYPE_NORMAL: 291
00:00:05.628 [../src/xwayland.c:953] Disconnecting from xwayland

So I don't think that the initial atom sync is an issue when restarting xwayland.

@johanmalm
Copy link
Collaborator

johanmalm commented Jan 24, 2024

I guess the approach taken in #1185 works without additional changes to wlroots. But it duplicates work that wlroots is already doing (opening up a new X server connection and performing a bunch of xcb_intern_atom calls that wlroots already did using its own connection).

In the interest of moving forward on net-wm-window-type atom support, I'm comfortable with doing a separate connection in the interim until wlroots exposes a get_xcb_connection() function (i.e. merging #1185)

Do say though @jlindgren90 if you think we're making a mistake.

--EDIT-- In the more generic sense - whether or not we implement things "not yet" in wlroots and wait for them to be available is probably best handled on a case-by-case basis taking into account time to next wlroots release and the perceived benefits as well as disbenefits of increased maintenance.

@jlindgren90
Copy link
Contributor

It should be fine as an interim solution. It would still be nice to have more proper wlroots support eventually.

@grisha128
Copy link
Author

@Consolatis I synced my PR with yours and it works on my side, although I could test only _NET_WM_WINDOW_TYPE_DESKTOP atom functionality.

@grisha128
Copy link
Author

Couldn't find here in GitHub how to change source branch, sorry. Going to make another PR...

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.

4 participants