aboutsummaryrefslogtreecommitdiff
path: root/xwayland/xwm.c
AgeCommit message (Collapse)Author
2024-02-23xwayland: add map_request signalJohn Lindgren
For XWayland surfaces that start maximized, it's best to send an initial Configure event to set the size of the surface before mapping it. This reduces visual glitches since the application sees the correct maximized size when performing its initial layout and drawing. wlroots surfaces emit their first "map" event after the XWayland window has already been mapped and the first frame has been drawn & committed. This is too late to send the initial Configure event. So, add a new "map_request" event which is emitted immediately before telling XWayland to map the window. Compositors can connect to this event to send the initial Configure event to an XWayland app based on its requested maximized (or fullscreen) state. Compositors should not place anything visually on the screen at this point but rather wait until the "map" event as before.
2024-02-22xwayland/xwm: Initialize client_id_cookieKenny Levinsen
scan-build is a little confused, thinking xwm->xres value could change during the execution of xwayland_surface_create so client_id_cookie could end up used uninitialized. The struct is just an unsigned int, so no harm in initializing it to get it off the list.
2024-02-22xwayland/xwm: Allocate to the right variableKenny Levinsen
837060f894a4 made a change to only allocate the xcb_window_t array if it was not going to be zero-sized. It accidentally shadowed the variable so the output of the allocation would never be used. Regressed-by: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4563
2024-02-22xwayland/xwm: Avoid zero-size allocaitonKenny Levinsen
Zero-sized allocations have glibc-specific behavior, so avoid those.
2024-02-15Define _POSIX_C_SOURCE globallySimon Ser
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead, require POSIX.1-2008 globally. A lot of core source files depend on that already. Some care must be taken on a few select files where we need a bit more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and some files need BSD extensions (_DEFAULT_SOURCE). In both cases, these feature test macros imply _POSIX_C_SOURCE. Make sure to not define both these macros and _POSIX_C_SOURCE explicitly to avoid POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001 but _XOPEN_SOURCE says POSIX.1-2008). Additionally, there is one special case in render/vulkan/vulkan.c. That file needs major()/minor(), and these are system-specific. On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need to make sure it's not defined for this file. On Linux, we can explicitly include <sys/sysmacros.h> and ensure that apart from symbols defined there the file only uses POSIX toys.
2024-01-25xwayland: add support for _NET_WM_WINDOW_TYPE_DESKTOP atomGrigory Kirillov
2024-01-25Fix disappearing menus in QT appsSarunas Valaskevicius
A motivating example of such problem - Zoom's popups that open on button presses. Before this fix the popup would flicker and immediately disappear - because the PID is not yet available for the verification (as the surface has not been associated yet), wlroots would refuse to focus the popup and instead focus the previous window. This leads QT to interpret this as a sign to close the popup. This change moves the PID aqcuisition to an earlier phase - just where the window is created.
2024-01-24xwayland/xwm: associate even on xcb_get_property() failureKirill Primak
This matches the behavior before f5797be8a8d410e22fa6397b2217a6a81858d05c.
2023-11-27xwm: don't do anything except mapping on MapRequestKirill Primak
Instead, move the wlr_xwayland_surface_set_withdrawn() and wlr_xwayland_surface_restack() calls to the MapNotify handler with an override_redirect check, as they are done too early. This mirrors the logic in the UnmapNotify handler and fixes a bug where wlr_xwayland_surface_restack() would be called on an o-r window after the following sequence of requests: - CreateWindow with override_redirect=True - ChangeWindowAttributes with override_redirect=False - MapWindow Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3770
2023-11-23xwm: ensure stack list only contains mapped managed surfacesnovenary
2023-11-23xwm: avoid restacking managed surfaces above OR surfacesnovenary
This is consistent with other X11 window managers (checked against i3 and mutter).
2023-11-17xwayland: fix user_event_handler mfk530
Don't break and free event as the commont says: wlr-xwayland will free the event.
2023-10-26xwayland: add wlr_xwayland_set_workareas()John Lindgren
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-14xwayland: stop translating _NET_WM_STRUT_PARTIAL coordinatesJohn Lindgren
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-09xwayland: fix memory leakChristopher Snowhill
Fixes: f5797be8a8d410e22fa6397b2217a6a81858d05c Thanks to tesselslate on IRC for reporting. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2023-10-06xwayland: batch client ID request with other property requestsSimon Ser
2023-10-06xwayland: batch property requests when handling new windowSimon Ser
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-03treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practicalAlexander Orzechowski
2023-08-03xwayland: drop wlr_xwayland_surface.events.set_pidSimon Ser
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-07-28xwayland: avoid calling xwm_get_atom_name() when debug logs are offSimon Ser
xwm_get_atom_name() performs a roundtrip to the X11 server. Avoid calling this blocking function if debug logs are turned off.
2023-07-09xwayland: pass NULL as event dataSimon Ser
This is more extensible: in the future we can introduce event structs if we need to.
2023-07-09xwayland: use initializer for struct wlr_xwayland_resize_eventSimon Ser
Ensures there are no fields with uninitialized memory. Also remove an outdated TODO: Xwayland only supports a single seat.
2023-07-09xwayland: drop struct wlr_xwayland_move_eventSimon Ser
This only contains the xsurface, which isn't particularly useful.
2023-06-02xwm: check for a buffer before mappingKirill Primak
2023-06-02xwm: use unified map logicKirill Primak
2023-06-02xwm: introduce associate/dissociate eventsKirill Primak
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-02Revert "xwm: emit new_surface/destroy on associate/dissociate"Kirill Primak
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 039cca8a51ed0783d45fb7a5215e9ae83e4e02e2. Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3606
2023-05-04xwayland: allow compositor to set withdrawn statenovenary
2023-03-09xwm: emit new_surface/destroy on associate/dissociateKirill Primak
2023-03-09xwm: make atom_map staticKirill Primak
2023-03-07xwm: remove misleading commentKirill Primak
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-02-21xwayland: Send synthetic ConfigureNotify per ICCCM 4.1.5John Lindgren
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-13xwayland: Read and publish _NET_WM_STRUT_PARTIAL propertyJohn Lindgren
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-01xwayland/xwm: reset serial in xwayland_surface_dissociate()Simon Ser
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-01xwayland/xwm: introduce wlr_xwayland_surface_try_from_wlr_surface()Kirill Primak
This new function replaces wlr_surface_is_xwayland_surface() and wlr_xwayland_surface_from_wlr_surface().
2022-12-22xwayland/xwm: remove unnecessary surface_id resetSimon Ser
xwayland_surface_associate() already does this.
2022-12-22xwayland/xwm: assert that we're not overwriting when associatingSimon Ser
Make sure xwayland_surface_associate() is not called twice in a row without a xwayland_surface_dissociate() call in-between.
2022-12-22xwayland/xwm: dissociate even if surface is NULLKirill Primak
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-18xwayland/xwm: constify needlesKirill Primak
2022-12-08xwayland: use HAVE_ prefix for xcb_xfixes_set_client_disconnect_modeSimon Ser
86fc2199f85a ("build: unify naming for HAVE_* defines") has switched over all other feature defines from HAS_* to HAVE_*, but missed this one.
2022-12-06build: unify naming for HAVE_* definesSimon Ser
We sometimes used HAS_, sometimes polluted the LIBINPUT_ namespace, etc.
2022-12-05xwayland/xwm: replace role with addonSimon Ser
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3545
2022-12-05xwayland/xwm: rename xwm_map_shell_surface()Simon Ser
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-11-18xwayland/xwm: add support for xwayland-shell-v1Simon Ser
2022-11-06compositor: drop role object NULL checks in handlersKirill Primak
Instead, move the check to the caller.
2022-11-06xwayland/xwm: use role object destroy handlerKirill Primak
2022-10-19xwyland/xwm: simplify unpaired_link handlingSimon Ser
Always keep it initialized, so that we don't have to check for xsurface->surface_id. Will help with WL_SURFACE_SERIAL support, which adds a new way for a surface to be unpaired.
2022-10-18xwayland: Simplify net_wm_edges_to_wlrAlexander Orzechowski
2022-08-18Use wl_signal_emit_mutableAlexander Orzechowski
2022-08-06Set mapped before firing map/unmap eventsKenny Levinsen
This allows whatever the user calls from the signal handlers to react to observe the new state rather than the old, e.g. that a surface is no longer mapped in the unmap handler.