Commit graph

458 commits

Author SHA1 Message Date
novenary
f1762f428b xwm: ensure stack list only contains mapped managed surfaces 2023-11-23 10:41:41 +00:00
novenary
720e8ac26b xwm: avoid restacking managed surfaces above OR surfaces
This is consistent with other X11 window managers (checked against i3
and mutter).
2023-11-23 10:41:41 +00:00
mfk530
92dabc3a01 xwayland: fix user_event_handler
Don't break and free event as the commont says:
wlr-xwayland will free the event.
2023-11-17 02:33:18 +00:00
John Lindgren
af165acb42 xwayland: add wlr_xwayland_set_workareas()
This function allows compositors to set the _NET_WORKAREA property on
the root window. XWayland clients use _NET_WORKAREA to determine how
much of the screen is not covered by panels/docks. The property is used
for example by Qt to determine areas of the screen that popup menus
should not overlap (see QScreen::availableVirtualGeometry).
2023-10-26 15:05:08 -04:00
John Lindgren
6114dd6a83 xwayland: stop translating _NET_WM_STRUT_PARTIAL coordinates
Translating the right/bottom coordinates from offsets to absolute
coordinates in wlroots (rather than in the compositor) was supposed to
be more reliable, since wlroots had access to the X11 screen size.

It ended up being less reliable, because the screen size values
(xwm->screen->width_in_pixels/height_in_pixels) are not updated when the
output layout changes.

So let's remove the translation from wlroots, and let the compositor
figure it out. From what I can understand of the current XWayland code,
the X11 screen size should generally match the overall wlr_output_layout
bounding box, which the compositor has access to.
2023-10-14 21:27:34 -04:00
Simon Ser
e519635cc2 xwayland: add wlr_xwayland_create_with_server()
Allows compositors to set up the server (and shell) on their own.
2023-10-10 17:05:04 +02:00
Simon Ser
bdcf997a89 xwayland/server: add ready flag
Allows one to check whether the server is currently ready.
2023-10-10 17:05:04 +02:00
Christopher Snowhill
285645b8d7 xwayland: fix memory leak
Fixes: f5797be8a8

Thanks to tesselslate on IRC for reporting.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2023-10-09 20:50:11 -07:00
Simon Ser
36e7a672c7 xwayland: batch client ID request with other property requests 2023-10-06 08:35:33 +00:00
Simon Ser
f5797be8a8 xwayland: batch property requests when handling new window
Instead of sending one request, waiting for the reply, and
repeating for all properties we're interested in, we can send all
property requests in one go and then wait for the server to reply.
2023-10-06 08:35:33 +00:00
JiDe Zhang
ca19014af0 xwayland: fix double free wlr_xwayland_shell_v1 2023-10-06 10:04:11 +02:00
Alexander Orzechowski
1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Simon Ser
77dc1c28aa xwayland: drop wlr_xwayland_surface.events.set_pid
The PID of an X11 window cannot change.

This is a remnant from the days when we queried the PID with a
window property, instead of using XRes.
2023-08-03 03:19:35 +00:00
Simon Ser
d40bcfe2c1 xwayland: avoid calling xwm_get_atom_name() when debug logs are off
xwm_get_atom_name() performs a roundtrip to the X11 server. Avoid
calling this blocking function if debug logs are turned off.
2023-07-28 14:21:37 +02:00
Kirill Primak
529f1b82ee xwayland/shell: don't listen to wlr_surface.events.destroy
The wlr_xwayland_surface_v1 will be destroyed automatically
from xwl_surface_role_destroy().
2023-07-26 20:31:03 +00:00
Simon Ser
fe06e5f49a Use wl_container_of() instead of casts
This slightly improves type safety.

The culprits were found with:

    git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
2023-07-11 20:16:17 +02:00
Kirill Primak
fce7cb249f xwayland-shell: don't remove inert role resource 2023-07-10 10:03:24 +02:00
Simon Ser
27edd024f8 xwayland: pass NULL as event data
This is more extensible: in the future we can introduce event
structs if we need to.
2023-07-09 12:18:49 +02:00
Simon Ser
76e2a74282 xwayland: use initializer for struct wlr_xwayland_resize_event
Ensures there are no fields with uninitialized memory.

Also remove an outdated TODO: Xwayland only supports a single seat.
2023-07-09 12:18:49 +02:00
Simon Ser
19ba3f0c2a xwayland: drop struct wlr_xwayland_move_event
This only contains the xsurface, which isn't particularly useful.
2023-07-09 11:48:16 +02:00
Simon Ser
7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Simon Ser
8a5b5e6f28 compositor: listen to role_resource destroy signal
Call wlr_surface_destroy_role_object() when the role_resource is
destroyed.
2023-06-23 14:33:26 +02:00
Simon Ser
89cb484220 compositor: replace role_data with role_resource
This increases type safety, makes it more obvious that role_data
must represent the role object, and will allow for automatic
cleanup when the resource is destroyed.
2023-06-23 14:23:27 +02:00
Kirill Primak
0f67580aab compositor: introduce wlr_surface_set_role_object() 2023-06-23 11:54:05 +00:00
Simon Ser
8714657d7b xwayland: unset wlr_xwayland.server on destroy
This fixes a use-after-free in the Sway patch to filter the Xwayland
shell [1].

The server is destroyed first, then the shell. The Xwayland process
might still be using the shell while running.

When the shell is destroyed, libwayland will invoke the global
filter (to figure out whether to send a wl_registry.global_remove
to clients). Then Sway will compare the client with
wlr_xwayland_server.client. However, at that point, the server is
gone.

Reset the server to NULL so that Sway can check whether the server
is still running.

[1]: https://github.com/swaywm/sway/pull/7647
2023-06-22 16:28:43 +02:00
Kirill Primak
3dc646ea88 Add some missing includes/declarations 2023-06-05 21:06:19 +00:00
Kirill Primak
17230d33c1 xwm: check for a buffer before mapping 2023-06-02 22:44:21 +03:00
Kirill Primak
26676c8c07 xwm: use unified map logic 2023-06-02 17:26:18 +00:00
Kirill Primak
75d03f2b68 xwm: introduce associate/dissociate events
We'll soon introduce a unified wlr_surface map event. Up until now, compositors
have been using wlr_xwayland_surface's map event to setup various wlr_surface
related listeners (e.g. commit). This will no longer be possible when that
event is moved over to wlr_surface. Introduce new events where the compositor
can add/remove wlr_surface event listeners.
2023-06-02 15:54:25 +00:00
Kirill Primak
2d6a09d9f0 Revert "xwm: emit new_surface/destroy on associate/dissociate"
Firing new_surface when a wlr_surface is associated to the X11 window is too
late: the X11 client might've sent configure events before that.

This reverts commit 039cca8a51.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3606
2023-06-02 15:54:25 +00:00
novenary
d7917d2076 xwayland: allow compositor to set withdrawn state 2023-05-04 18:05:00 +00:00
Simon Ser
2827ec6b7b xwayland: enable use of a xserver subproject
Makes it easier to work on Xwayland and wlroots features in
parallel.

References: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1048
2023-05-04 18:02:32 +00:00
Kirill Primak
039cca8a51 xwm: emit new_surface/destroy on associate/dissociate 2023-03-09 18:51:47 +00:00
Kirill Primak
ad51983b23 xwm: make atom_map static 2023-03-09 18:51:47 +00:00
Kirill Primak
774d2c82f0 xwm: remove misleading comment
The surfaces are stored in the bottom-to-top order, as specified
in include/xwayland/xwm.h and expected by
wlr_xwayland_surface_restack().
2023-03-07 17:51:27 +00:00
John Lindgren
7d90cd055d xwayland: Send synthetic ConfigureNotify per ICCCM 4.1.5
X11 clients expect a ConfigureNotify after a ConfigureRequest. If
the compositor/window manager chooses not to honor the request
(e.g. due to the window being maximized), XWayland will not send a
"real" ConfigureNotify event and the window manager is expected to
send a synthetic event instead. Otherwise, the X11 client is left
waiting and may not repaint its window properly.

For comparison, see Openbox's client_configure() or Weston's
weston_wm_window_send_configure_notify().

v2: Move logic to wlr_xwayland_surface_configure()
2023-02-21 09:32:06 +00:00
John Lindgren
068280201a xwayland: Read and publish _NET_WM_STRUT_PARTIAL property
This is needed for compositors that want to reserve space for
XWayland panels.  Such a feature can be useful in a "transitional"
setup, where only the X11 window manager and compositor is replaced
but other components of an X11 desktop environment are still used.

This change simply reads the X11 property; the compositor is free
to ignore it.  Thus, compositors that don't want to support such a
"transitional" feature are not impacted.

v2: Update xwayland_surface_associate()
2023-02-13 12:57:20 -05:00
Kirill Primak
b355a12751 xwayland/shell: actually use wlr_xwayland_surface_v1.link
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3575
2023-02-03 16:38:12 +03:00
Simon Ser
03412e9aab xwayland/xwm: reset serial in xwayland_surface_dissociate()
The same X11 window can be used multiple times with a different
wl_surface.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3570
2023-02-01 16:33:15 +00:00
Kirill Primak
fbf5982e38 xwayland/xwm: introduce wlr_xwayland_surface_try_from_wlr_surface()
This new function replaces wlr_surface_is_xwayland_surface() and
wlr_xwayland_surface_from_wlr_surface().
2023-02-01 16:13:21 +00:00
Simon Ser
cef1811547 xwayland/xwm: remove unnecessary surface_id reset
xwayland_surface_associate() already does this.
2022-12-22 15:45:18 +01:00
Simon Ser
445ce7eac6 xwayland/xwm: assert that we're not overwriting when associating
Make sure xwayland_surface_associate() is not called twice in a
row without a xwayland_surface_dissociate() call in-between.
2022-12-22 15:44:15 +01:00
Kirill Primak
a922428c41 xwayland/xwm: dissociate even if surface is NULL
If a window is unmapped too quickly, we might receive UnmapNotify before
we get the corresponding wl_surface, which will later lead to
associating the same window twice. To fix this, move the NULL surface
check to xwayland_surface_dissociate(), which makes resetting the
unpaired link and the wl_surface object ID unconditional.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3552
2022-12-22 14:40:58 +00:00
Kirill Primak
1cd53f54b7 xwayland/xwm: constify needles 2022-12-18 13:55:39 +03:00
Simon Ser
9b7ee63774 xwayland: use HAVE_ prefix for xcb_xfixes_set_client_disconnect_mode
86fc2199f8 ("build: unify naming for HAVE_* defines") has
switched over all other feature defines from HAS_* to HAVE_*, but
missed this one.
2022-12-08 02:06:40 +01:00
Simon Ser
1ed5137720 xwayland: remove find_program() fallback when dep is not found
The dep allows us to check dep variables to discover supported
features. With the binary we assume none of the features are
supported. If a user forgets to install the pkg-config file (e.g.
because it's in a split package) we end up incorrectly disabling
all features. Instead let's error out.
2022-12-08 01:58:34 +01:00
Simon Ser
86fc2199f8 build: unify naming for HAVE_* defines
We sometimes used HAS_, sometimes polluted the LIBINPUT_ namespace,
etc.
2022-12-06 22:39:45 +00:00
Simon Ser
4da9b32a15 xwayland: use internal_config
Avoids the need to have a separate config.h, and removes C compiler
arguments.
2022-12-06 22:39:45 +00:00
Simon Ser
532f3d3c20 xwayland/xwm: replace role with addon
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3545
2022-12-05 18:48:15 +01:00
Simon Ser
d962918128 xwayland/xwm: rename xwm_map_shell_surface()
Rename xwm_map_shell_surface() to xwayland_surface_associate().
This function doesn't actually "map" the surface in Wayland
parlance, the wl_surface may not have a buffer attached yet.
2022-12-05 10:51:46 +01:00