summaryrefslogtreecommitdiff
path: root/hw/xwayland/xwayland-window.c
Commit message (Collapse)AuthorAgeFilesLines
* xwayland/window: Queue damage after commits are allowedJonas Ådahl2023-04-261-0/+12
| | | | | | | | | | | | | | | Compositors may use XWAYLAND_ALLOW_COMMITS to communicate when Xwayland may or may not commit new buffers to a wl_surface. If commits are denied, then later allowed, we'll only get a buffer attached if there is actual damage posted, which might be long after. This fixes an issue where the window manager would reparent a window while denying commits, then after reparenting, allow commits. The window in question belonged to a game and took several seconds produce the next frame, resulting in an empty window appearing as if it had just disappeared. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* xwayland/window: Move set-allow functions lower downJonas Ådahl2023-04-261-35/+35
| | | | | | | This will make some helper functions in the same file usable without extra declarations. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* xwayland: Prevent nested xwl_present_for_each_frame_callback callsMichel Dänzer2023-03-271-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It could happen with the following call path: frame_callback xwl_present_frame_callback xwl_present_msc_bump xwl_present_execute xwl_present_flip xwl_window_create_frame_callback The nested loop called xwl_present_reset_timer, which may end up calling xorg_list_del for the entry after the one frame_callback started the chain for. This resulted in the outer loop never terminating, because its next element wasn't hooked up to the list anymore. We avoid this by calling xwl_present_reset_timer as needed in frame_callback, and bailing from xwl_window_create_frame_callback if it was called from the former. We also catch nested calls and FatalError if they ever happen again due to another bug. v2: * Leave xwl_present_reset_timer call in xwl_present_frame_callback, needed if xwl_present_msc_bump didn't hook up the window to the frame callback list again. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1442
* xwayland: Refactor xwl_present_for_each_frame_callback helperMichel Dänzer2023-03-271-27/+6
| | | | Preparation for following changes, no functional change intended.
* xwayland: use drmDevice to compare DRM devicesSimon Ser2023-03-031-0/+1
| | | | | | | | | The linux_dmabuf_v1 protocol doesn't guarantee any DRM node type: the compositor may send a primary node or a render node. Use drmDevice so that device comparisons are node-type-insensitive. Signed-off-by: Simon Ser <contact@emersion.fr> Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1447
* xwayland: Spell XWAYLAND consistently in debug messagesMichel Dänzer2023-02-131-1/+1
|
* xwayland/window: Do not double add window to damage listMinh Phan2023-02-101-1/+2
| | | | | | | | | | The window might be retained in the damage list after `xwl_screen_post_damage` in certain conditions. This means we need to check if the window is already in the list to avoid adding the same window twice which will lead to list corruption resulting in server freeze in `xwl_screen_post_damage`. Signed-off-by: Minh Phan <phanquangminh217@gmail.com>
* xwayland: Commit surface changes with libdecor configureOlivier Fourdan2023-02-031-0/+7
| | | | | | | | | | | With libdecor, when the state changes (in the configure handler), we need to commit the libdecor frame but also the wl_surface, otherwise the surface is left in a uncommitted state until a wl_surface commit eventually occurs later. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Fixes: c74c6add3e - xwayland: add optional support for libdecor Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
* xwayland: Implement linux_dmabuf_feedback event handlersAustin Shafer2023-01-201-0/+48
| | | | | | | | | Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> [ Michel Dänzer: * Sort protocol #includes lexically. * memcpy to &xwl_feedback->main_dev directly in xwl_dmabuf_feedback_main_device. ]
* xwayland: Implement xwayland_shell_v1Joshua Ashton2022-12-211-12/+86
| | | | | | | | | | | | | | | | Implements the xwayland_shell protocol which makes the surface association happen via a shared serial, rather than sharing a wl_surface resource ID across an X atom. This solves a race that can happen if the wl_surface associated with a WL_SURFACE_ID for a window was destroyed before the update of the atom was processed by the compositor and another surface (or other object) had taken its id due to recycling. Closes: #1157 Signed-off-by: Joshua Ashton <joshua@froggi.es> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
* xwayland: Clear the "xwl-window" tag on unrealizeOlivier Fourdan2022-10-191-3/+13
| | | | | | | | | | | | | | Now that we keep the Wayland surface around for longer than the xwl_window, we might get events for that surface after the X11 window is unrealized. Make sure we untag the Wayland surface when the Wayland surface is delayed, to break the wl_surface/xwl_window relationship, so that events for that surface are discarded by Xwayland. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Fixes: e37f18ee9 - xwayland: Delay wl_surface destruction
* xwayland: Delay wl_surface destructionOlivier Fourdan2022-09-281-1/+55
| | | | | | | | | | | | | | | | | | | | | | | X11 and Wayland requests are unordered, causing a race in the X11 window and wl_surface association. To mitigate that race, delay the wl_surface destruction by 1 second, so that the compositor has time to establish the association before the wl_surface is destroyed: to see both the wl_surface created and the WL_SURFACE_ID X11 property set. This is only a mitigation though, a more robust solution requires a future dedicated Wayland protocol. v2: Clean up pending wl_surface destroy on exit as well. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1157 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Tested-by: Joshua Ashton <joshua@froggi.es> Tested-by: Sterophonick <sterophonick@gmail.com> See-also: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/163
* xwayland: add optional support for libdecorOlivier Fourdan2022-06-301-20/+113
| | | | | | | | | | | | | | | When running rootful, the Xwayland window is not decorated (as all Wayland surfaces), which makes it quite inconvenient to move on screen. libdecor is "a client-side decorations library for Wayland clients" which can be used precisely for adding decorations to Wayland surfaces. Add optional support for libdecor in Xwayland to gain decorations when running rootful and a new command line option "-decorate". Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1332
* xwayland: set tag on our surfacesOlivier Fourdan2022-06-301-0/+14
| | | | | | | | | | | That allows to differentiate Xwayland's own surfaces from others. This is preparation work for optional libdecor support. v2: Check for surface not being NULL (Jonas Ådahl <jadahl@gmail.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: set the app_id and install a desktop launcherOlivier Fourdan2022-06-301-0/+10
| | | | | | | | | | | The app_id is used to identify applications (and group windows), some desktops (such as GNOME Shell) use it in their top bar. Set the XDG toplevel "app_id" to "org.freedesktop.Xwayland" and install a desktop file for Xwayland rootful. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: add xdg-toplevel listenerOlivier Fourdan2022-06-301-0/+26
| | | | | | | | So that when running rootful, the compositor can close the Xwayland window using the xdg-toplevel protocol. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: set the surface title when running rootfulOlivier Fourdan2022-06-301-0/+22
| | | | | | | | Set a meaningful title for the xdg_surface, it's nicer when running rootful. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: move the root window surface to its own functionOlivier Fourdan2022-06-301-41/+54
| | | | | | | | | | Currently, when running rootful, the toplevel root surface is created in the same function as the rest of the Wayland surfaces. Move it to its own function to improve readability - No function change. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: add fullscreen mode for rootfulOlivier Fourdan2022-06-301-3/+83
| | | | | | | | | | | Add a new command line option "-fullscreen" to make the rootful Xwayland window appear fullscreen. This requires viewport support in the compositor and when used with "-geometry" can emulate the full range of XRandR resolutions. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: pass the emulated mode by referenceOlivier Fourdan2022-06-301-5/+5
| | | | | | | | | | | | | | | When using xrandr emulation, the emulated mode is passed as a pointer to the XRandR mode from the xwl_output associated with the X11 client. In preparation for fullscreen mode, we want to be able to reuse that code but use a separate emulated mode. Simply change the internal API to pass a reference to the emulated mode. This introduces no functional change. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: keep the xdg_toplevel aroundOlivier Fourdan2022-06-301-2/+9
| | | | | | | | | | | | The xdg_toplevel object was used solely when creating the window surface, and the value of the object discarded. To be able to make the surface fullscreen using the xdg_toplevel protocol, we need to have access that object, so keep it around along with the xwl_window. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: keep track of the wl_output enter/leaveOlivier Fourdan2022-06-301-0/+30
| | | | | | | | | | | | | Keep track of the output the surface enters/leaves. This is fairly basic tracking though, we do not keep a full list of outputs a surface may be covering partially, we just keep the output the surface entered last. This is sufficient as a preparation work for fullscreen though. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: Always hook up frame_callback_list in xwl_present_queue_vblankMichel Dänzer2022-03-171-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | Even if there's no pending frame callback yet. Without this, if there was no pending frame callback yet in xwl_present_queue_vblank, xwl_present_msc_bump would only get called from xwl_present_timer_callback, resulting in the MSC ticking at ~58 Hertz. Doing this requires some adjustments elsewhere: 1. xwl_present_reset_timer needs to check for a pending frame callback as well. 2. xwl_window_create_frame_callback needs to call xwl_present_reset_timer for all child windows hooked up to frame_callback_list, to make sure the timer length takes the pending frame callback into account. 3. xwl_present_flip needs to hook up the window to frame_callback_list before calling xwl_window_create_frame_callback, for 2. to work. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1309 Fixes: 9b31358c52e9 ("xwayland: Use frame callbacks for Present vblank events") Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
* xwayland/present: Fix use-after-free in xwl_unrealize_window()Olivier Fourdan2022-03-151-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a window is unrealized, Xwayland would destroy the Wayland surface prior to unrealizing the present window. xwl_present_flip() will then do a wl_surface_commit() of that surface, hence causing a use-after-free: Invalid read of size 8 at 0x49F7FD4: wl_proxy_marshal_array_flags (wayland-client.c:852) by 0x49F823A: wl_proxy_marshal_flags (wayland-client.c:784) by 0x42B877: wl_surface_commit (wayland-client-protocol.h:3914) by 0x42CAA7: xwl_present_flip (xwayland-present.c:717) by 0x42CD0E: xwl_present_execute (xwayland-present.c:783) by 0x42C26D: xwl_present_msc_bump (xwayland-present.c:416) by 0x42C2D1: xwl_present_timer_callback (xwayland-present.c:433) by 0x42BAC4: xwl_present_reset_timer (xwayland-present.c:149) by 0x42D1F8: xwl_present_unrealize_window (xwayland-present.c:945) by 0x4230E2: xwl_unrealize_window (xwayland-window.c:616) by 0x4FCDD8: compUnrealizeWindow (compwindow.c:292) by 0x4F3F5C: UnrealizeTree (window.c:2805) Address 0x1390b8d8 is 24 bytes inside a block of size 80 free'd at 0x48470E4: free (vg_replace_malloc.c:872) by 0x49F8029: wl_proxy_destroy_caller_locks (wayland-client.c:523) by 0x49F8029: wl_proxy_marshal_array_flags (wayland-client.c:861) by 0x49F823A: wl_proxy_marshal_flags (wayland-client.c:784) by 0x421984: wl_surface_destroy (wayland-client-protocol.h:3672) by 0x423052: xwl_unrealize_window (xwayland-window.c:599) by 0x4FCDD8: compUnrealizeWindow (compwindow.c:292) by 0x4F3F5C: UnrealizeTree (window.c:2805) by 0x4F424B: UnmapWindow (window.c:2863) by 0x4EF58C: DeleteWindow (window.c:1075) by 0x4E24B3: doFreeResource (resource.c:885) by 0x4E2ED7: FreeClientResources (resource.c:1151) by 0x4ACBA4: CloseDownClient (dispatch.c:3546) Block was alloc'd at at 0x4849464: calloc (vg_replace_malloc.c:1328) by 0x49F7F29: zalloc (wayland-private.h:233) by 0x49F7F29: proxy_create (wayland-client.c:422) by 0x49F7F29: create_outgoing_proxy (wayland-client.c:664) by 0x49F7F29: wl_proxy_marshal_array_flags (wayland-client.c:831) by 0x49F823A: wl_proxy_marshal_flags (wayland-client.c:784) by 0x4218CA: wl_compositor_create_surface (wayland-client-protocol.h:1291) by 0x422A0D: ensure_surface_for_window (xwayland-window.c:445) by 0x4231E8: xwl_window_set_window_pixmap (xwayland-window.c:647) by 0x5232D6: damageSetWindowPixmap (damage.c:1565) by 0x4FC7BC: compSetPixmapVisitWindow (compwindow.c:129) by 0x4EDB3F: TraverseTree (window.c:441) by 0x4FC851: compSetPixmap (compwindow.c:151) by 0x4F8C1A: compAllocPixmap (compalloc.c:616) by 0x4FC938: compCheckRedirect (compwindow.c:174) To avoid that, call xwl_present_unrealize_window() before destroying the Wayland surface. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
* Xwayland: Do not map the COW by default when rootlessOlivier Fourdan2022-03-081-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | The composite overlay window (COW) can be queried from any X11 client, not just the X11 compositing manager. If a client tries to get the composite overlay window, the Xserver will map the window and block all pointer events (the window being mapped and on top of the stack). To avoid that issue, unset the "mapped" state of the composite overlay window once realized when Xwayland is running rootless. Note: All Xservers are actually affected by this issue, but with most regular X servers, the compositing manager will take care of dealing with the composite overlay window, and an X11 client using GetOverlayWindow() won't break pointer events for all X11 clients. Wayland compositors however usually run Xwayland rootless and have no use for the COW. v2: Avoid registering damage for the COW (Michel) v3: Remove the "mapped" test to avoid calling register_damage() if the COW is not mapped (Michel) Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1314 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
* xwayland/glamor: Add return status to post_damageOlivier Fourdan2021-05-111-2/+6
| | | | | | | | | | | | | If the glamor backend failed to post damage, the caller should do the same to avoid a failure to attach the buffer to the Wayland surface. Change the API of Xwayland's glamor backend post_damage() to return a status so that xwl_window_post_damage() can tell whether the callee failed. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
* xwayland: Check buffer prior to attaching itOlivier Fourdan2021-05-111-0/+5
| | | | | | | | | | If the buffer is NULL, do not even try to attach it, and risk a Wayland protocol error which would be fatal to us. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Martin Peres <martin.peres@mupuf.org> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
* xwayland: remove unused parameter of xwl_glamor_pixmap_get_wl_bufferErik Kurzinger2021-01-081-2/+1
| | | | | | There are currently no callers that make use of the "created" output parameter of xwl_glamor_pixmap_get_wl_buffer. Remove it, along with the corresponding argument of the associated EGL backend entrypoint.
* xwayland: Replace LogMessage with LogMessageVerbMariusz Ceier2020-12-081-2/+2
| | | | | | | | LogMessage logs only when the XLOG_VERBOSITY is >= 1, but by default XLOG_VERBOSITY is 0, so for example warning about deprected -listen parameter is never shown when running "Xwayland -listen 32 -help". Signed-off-by: Mariusz Ceier <mceier+freedesktop@gmail.com>
* xwayland: Make window_get_client_toplevel non-recursiveMichel Dänzer2020-11-091-4/+4
| | | | | | Noticed while reading the code. Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
* xwayland: Create an xwl_window for toplevel onlyOlivier Fourdan2020-11-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One general assumption in Xwayland is that the xwl_window remains the same for all the child windows of the toplevel window. When mapping a new X11 window, ensure_surface_for_window() checks for an existing xwl_window by using xwl_window_get() which will just check for the registered xwl_window for the window. That means that a client mapping a child window of an existing window with a xwl_window will get another different xwl_window. If an X11 client issues a Present request on the parent window, hence placed underneath its child window of the same size, the Wayland compositor may not send the frame callback event for the parent's Wayland surface which is reckoned to be not visible, obscured behind the other Wayland surface for the child X11 window. That bug affects some games running in wine which may get 1 fps because the repaint occurs only on timeout with a long interval (as with, e.g. https://bugs.winehq.org/show_bug.cgi?id=47066) Fix ensure_surface_for_window() by using xwl_window_from_window() which will walk the window tree, so that a child window won't get another xwl_window than its parent. https://gitlab.freedesktop.org/xorg/xserver/-/issues/1099 See-also: https://bugs.winehq.org/show_bug.cgi?id=47066 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
* xwayland: Move xwl_surface_damage definition to xwayland-screen.cMichel Dänzer2020-07-071-10/+0
| | | | | | | It was already declared in xwayland-screen.h, and only takes a screen parameter, no window ones. Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
* xwayland: Delete all frame_callback_list nodes in xwl_unrealize_windowMichel Dänzer2020-03-171-2/+9
| | | | | | | | | | | | We were only calling xwl_present_unrealize_window for the toplevel window, but the list can contain entries from child windows as well, in which case we were leaving dangling pointers to freed memory. Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/1000 Fixes: c5067feaeea1 "xwayland: Use single frame callback for Present flips and normal updates" Reviewed-by: Olivier Fourdan <ofourdan@redhat.com> Tested-by: Olivier Fourdan <ofourdan@redhat.com>
* xwayland: port rooted xwayland from wl_shell to xdg-shell protocolmntmn2020-02-281-28/+18
| | | | | | | | | | | Recently, rooted Xwayland crashes on wlroots-based compositors, because wlroots removed the deprecated wl_shell protocol. This MR fixes this by changing the code in question to the xdg-shell protocol. My motivation do this: on etnaviv-based embedded platforms, rooted Xwayland is much faster and doesn't cause UI rendering bugs compared to rootless Xwayland. Signed-off-by: Lukas F. Hartmann <lukas@mntre.com>
* xwayland: Fix setting of _XWAYLAND_RANDR_EMU_MONITOR_RECTS prop on new windowsHans de Goede2020-02-231-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | For window-manager managed windows, xwl_realize_window is only called for the window-manager's decoration window and not for the actual client window on which we should set the _XWAYLAND_RANDR_EMU_MONITOR_RECTS prop. Usualy this is not a problem since we walk all client windows to update the property when the resolution is changed through a randr call. But for apps which first do the randr change and only then create their window this does not work, and our xwl_output_set_window_randr_emu_props call in xwl_realize_window is a no-op as that is only called for the wm decoration window and not for the actual client's window. This commit fixes this by making ensure_surface_for_window() call xwl_output_set_window_randr_emu_props on the first and only child of window-manager managed windows. Note this also removes the non-functional xwl_output_set_window_randr_emu_props call from xwl_realize_window, which was intended to do this, but does not work. This fixes apps using the ogre3d library always running at the monitors native resolution. Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Call xwl_window_check_resolution_change_emulation() on newly ↵Hans de Goede2020-02-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | created O-R windows Some clients, which use vidmode to change the resolution when going fullscreen, create an override-redirect window and never trigger the screen->ResizeWindow callback we rely on to do the xwl_window_check_resolution_change_emulation(). This causes us to not apply a viewport to them, causing the fullscreen window to not fill the entire monitor. This commit adds a call to xwl_window_check_resolution_change_emulation() at the end of ensure_surface_for_window() to fix this. Note that ensure_surface_for_window() exits early without creating an xwl_window for new windows which will not be backed by a wayland surface and which thus will not have an xwl_window. This fixes ClanLib-0.6.x and alleggl-4.4.x using apps not properly fullscreening. Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Also hook screen's MoveWindow methodHans de Goede2020-02-231-0/+22
| | | | | | | | | | | | | | | | | Not only hook the ResizeWindow method of the screen (which really is MoveAndResize) but also hook the MoveWindow method for checking if we need to setup a viewport for resolution change emulation. Our resolution change emulation check if the windows origin matches the monitors origin and the windows origin can also be changed by just a move without being resized. Also checking on a move becomes esp. important when we move to checking on changes to the top-level non-window-manager client (X11)Window instead of on changes to the xwl_window later on in this patch series. Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Also check resolution-change-emulation when the xwl_window itself ↵Hans de Goede2020-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | moves The recent change to use the top-level non-window-manager Window drawable coordinates from xwl_window_check_resolution_change_emulation() in combination with only calling it on a resize when the top-level window is moved breaks things with mutter/gnome-shell. When fullscreening a X11 window, mutter moves its window-decoration Window wrapping the top-level Window to the monitor's origin coordinates (e.g. 0x0) last. This updates the top-level's drawable coordinates, but as the actual MoveWindow is called on the wrapper Window and not on the toplevel we do not call xwl_window_check_resolution_change_emulation() and we never enable the viewport. This commit fixes this by also calling xwl_window_check_resolution_change_emulation() if the Window being moved is an xwl_window itself. Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Check emulation on client toplevel resizeRoman Gilg2020-02-231-16/+11
| | | | | | | | | | | | | | | | | When a reparented window is resized directly check the emulation instead of doing this only when the window manager parent window is resized, what might never happen. For that to work we need to make sure that we compare the current size of the client toplevel when looking for an emulated mode. Changes by Hans de Goede: - Remove xwl_window x, y, width and height members as those are no longer used. - Add check for xwl_window_from_window() returning NULL. Signed-off-by: Roman Gilg <subdiff@gmail.com> Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Make window_get_none_wm_owner return a Window instead of a ClientRoman Gilg2020-02-231-7/+10
| | | | | | | | | | | | | | | | | | Make window_get_none_wm_owner return the first non-wm-window instead of the owner (client) of the first non-wm-window and rename it to window_get_client_toplevel to match its new behavior. This is a preparation patch for switching to using the drawable coordinates in xwl_window_should_enable_viewport() Changes by Hans de Goede: - Split this change out into a separate patch for easier reviewing - Rename window_get_none_wm_owner to window_get_client_toplevel to match its new behavior Signed-off-by: Roman Gilg <subdiff@gmail.com> Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Recurse on finding the none-wm ownerRoman Gilg2020-02-231-9/+8
| | | | | | | | | | | | | | | | | | | | | | An X11 window manager might add a chain of parent windows when reparenting to a decoration window. That is for example the case for KWin, which reparents client windows to one decoration and another wrapper parent window. Account for that by a recursion into the tree. For now assume as before that all X11 window managers reparent with one child only for these parent windows. Changes by Hans de Goede: - Move the xwl_window_is_toplevel() from a later patch in this series here as it really belongs together with these changes - Drop no longer necessary xwl_window argument from window_get_none_wm_owner parameters Signed-off-by: Roman Gilg <subdiff@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Reuse viewport instead of recreatingRoman Gilg2020-02-231-11/+7
| | | | | | | | | | | When a viewport is already created we can reuse this object instead of destroying it and getting a new one for updating the source rectangle and destination size. Signed-off-by: Roman Gilg <subdiff@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Cache client-id for the window-manager clientHans de Goede2020-02-231-16/+29
| | | | | | | | | | | | | | | | Instead of iterating over all clients which are listening for events on the root window and checking if the client we are dealing with is the one listening for SubstructureRedirectMask | ResizeRedirectMask events and thus is the window-manager, cache the client-id of the window-manager in xwl_screen and use that when checking if a client is the window-manager. Note that we cache and compare the client-id rather then the ClienPtr, this saves reading the ClientPtr from the global clients array when doing the comparison. Suggested-by: Olivier Fourdan <ofourdan@redhat.com> Acked-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* xwayland: Split up xwl_screen_post_damage into two phasesMichel Dänzer2020-02-111-3/+0
| | | | | | | | | | | The first phase sets the new surface properties for all damaged windows, then the second phase commits all surface updates. This is preparatory for the next change, there should be no observable change in behaviour (other than the order of Wayland protocol requests). Reviewed-by: Adam Jackson <ajax@redhat.com>
* xwayland: Cleanup and remove `xwayland.h`Olivier Fourdan2019-12-201-1/+0
| | | | | | | | | Now that each source and header should be in order, we can safely cleaup the last remaining bits from the main `xwayland.h` which is not needed anymore and can be removed. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
* xwayland: Separate Xwayland screen codeOlivier Fourdan2019-12-201-0/+1
| | | | | | | Move Xwayland screen related code to a separate source file and header. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
* xwayland: Move Xwayland input declarationsOlivier Fourdan2019-12-201-0/+1
| | | | | | | Move the Xwayland input declarations to their own header file. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
* xwayland: Move Xwayland present declarationsOlivier Fourdan2019-12-201-0/+1
| | | | | | | Move the Xwayland Present declarations to their own header file. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
* xwayland: Move Xwayland windows to its own sourcesOlivier Fourdan2019-12-201-0/+825
Over time, Xwayland main source file `xwayland.c` has grown in size which makes it look cluttered and harder to read. Move the code dealing with Xwayland window to its own source and header files. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>