Commit Graph

114 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult 4cd73b26c0 (!1688) os: unexport internal logging functions
Lots of logging functions, especially init and teardown aren't called
by any drivers/modules, so no need to keep them exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-09-18 17:23:12 +02:00
Enrico Weigelt, metux IT consult 31c8867db4 (submit/drop-obsolete-have-dix-config.h) drop obsolete HAVE_DIX_CONFIG_H
The symbol controls whether to include dix-config.h, and it's always set,
thus we don't need it (and dozens of ifdef's) anymore.

This commit only removes them from our own source files, where we can
guarantee that dix-config.h is present - leaving the (potentially exported)
headers untouched.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-09-18 17:23:11 +02:00
Enrico Weigelt, metux IT consult fb697dd644 dix: unexport dixLookupProperty()
It's not used by any drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1340>
2024-09-02 17:50:47 +00:00
Enrico Weigelt, metux IT consult f446235b71 treewide: replace xnfcalloc() calls by XNFcallocarray()
This has been nothing but an alias for two decades now (somewhere in R6.6),
so there doesn't seem to be any practical need for this indirection.

The macro still needs to remain, as long as (external) drivers still using it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1529>
2024-07-26 23:41:33 +00:00
Olivier Fourdan 66f5e7e96a xwayland: Make sure output is suitable for fullscreen
Since commit d370f1e58, Xwayland can optionally be started rootful and
fullscreen.

To do so, it will setup a viewport to scale the root window to match the
size of the output.

However, if the rootful Xwayland window receives an xdg-surface configure
event before the output definition is complete, as with e.g. the labwc
Wayland compositor, we might end up trying to setup a viewport with a
destination size of 0x0 which is a protocol violation, and that kills
Xwayland.

To avoid that issue, only setup the viewport if the output size is
meaningful.

Also, please note that once the output definition is complete, i.e. when
the "done" event is eventually received, we shall recompute the size for
fullscreen again, hence achieving the desired fullscreen state.

Fixes: d370f1e58 - xwayland: add fullscreen mode for rootful
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1717
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1621>
2024-07-24 15:42:19 +02:00
Olivier Fourdan a5e863963e xwayland: Force disposal of windows buffers for root on destroy
With explicit buffer synchronization in use, the window buffers use a
file descriptor for event notification to keep the buffer alive for
synchronization purpose.

When running rootful, the root window (which is visible) is destroyed
directly from the resource manager on server reset, and the window
buffer's eventfd will trigger after the window is destroyed, leading to
a use after free and a crash of the xserver.

To avoid the issue, check whether the window being destroyed is the root
window in rootless mode, and make sure to force the disposal of the
window buffers in that case.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1699
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1589>
2024-07-04 08:26:23 +00:00
Olivier Fourdan fa04e15afc xwayland/window-buffers: optionally force disposal
For cases (to come) where we would want to force the disposal of the
window buffers, add a parameter to force the disposal by calling
dispose() directly instead of maybe_dispose().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1589>
2024-07-04 08:26:23 +00:00
Olivier Fourdan 0e1a98f52f xwayland: Make sure we do not leak xwl_window on destroy
Right now, we would dispose the xwl_window and all the data associated
with it on unrealize.

But not all window destruction go through the unrealize code path, for
example when the root window (running rootful) is destroyed from the
resource manager on server reset, we do not get to the unrealize window
step, but straight to destroy window.

As a result, we are leaking the xwl_window and all the data associated
with it, for example:

| 65,536 bytes in 1 blocks are possibly lost in loss record 12,462 of 12,488
|    at 0x484A0FC: calloc (vg_replace_malloc.c:1675)
|    by 0x48B661C: UnknownInlinedFun (pixman-bits-image.c:1273)
|    by 0x48B661C: _pixman_bits_image_init (pixman-bits-image.c:1296)
|    by 0x48B6754: create_bits_image_internal (pixman-bits-image.c:1349)
|    by 0x64180DE: UnknownInlinedFun (cairo-image-surface.c:380)
|    by 0x64180DE: UnknownInlinedFun (cairo-image-surface.c:366)
|    by 0x64180DE: cairo_image_surface_create (cairo-image-surface.c:432)
|    by 0x6346B44: UnknownInlinedFun (libdecor-gtk.c:467)
|    by 0x6346B44: libdecor_plugin_gtk_frame_new (libdecor-gtk.c:546)
|    by 0x4B7F297: libdecor_decorate (libdecor.c:559)
|    by 0x42C6F3: xwl_create_root_surface (xwayland-window.c:1266)
|    by 0x42CD97: ensure_surface_for_window (xwayland-window.c:1466)
|    by 0x42D0D1: xwl_realize_window (xwayland-window.c:1560)
|    by 0x50858F: compRealizeWindow (compwindow.c:279)
|    by 0x4FF2A2: MapWindow (window.c:2706)
|    by 0x4F9E7F: InitRootWindow (window.c:697)

To avoid that issue, check whether there is still an xwl_window
associated with the X11 window on destroy, and if that's the case,
dispose the xwl_window.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1589>
2024-07-04 08:26:23 +00:00
Olivier Fourdan 74be7a7f36 xwayland: Move xwl_window disposal to its own function
No functional change intended, this is just preparation work for the
next commit.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1589>
2024-07-04 08:26:23 +00:00
Olivier Fourdan aab01c7391 xwayland/window-buffers: Do not always set syncpnts
The function xwl_window_swap_pixmap() can be called from two places,
either from xwl_window_attach_buffer() or from damage_report().

When called from xwl_window_attach_buffer(), the new buffer is attached
and the surface committed.

However, when called from damage_report(), a new buffer might not be
attached before the surface is committed.

That's fine with implicit synchronization, but if we use explicit
synchronization, committing a surface without a new buffer attached but
with a release timeline point set is a protocol error:

| If at surface commit time there is a pending release timeline point
| set but no pending buffer attached, a no_buffer error is raised.

To avoid such an issue, add a new parameter to xwl_window_swap_pixmap()
to hint whether it should set the synchronization points, and have the
synchronization points set only from xwl_window_attach_buffer().

v2: Rename param to handle_sync (Michel)

Suggested-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1571>
2024-07-04 08:13:36 +00:00
Michel Dänzer e1b8a12194 xwayland: Only ignore manual redirection by clients for surface window
If the manual redirection was done by xwl_present_maybe_redirect_window,
we are in control.

This allows xwl_present_maybe_redirect_window to work as intended again.
Previously, xwl_window_update_surface_window would ignore the window
redirected by xwl_present_maybe_redirect_window, which would result in
xwl_present_maybe_redirect_window undoing the redirection and bailing.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1570>
2024-06-24 08:26:46 +00:00
Enrico Weigelt, metux IT consult 06b599edb6 dix: unexport fields from opaque.h not used by modules/drivers
Lots of fields from opaque.h aren't used by any drivers/modules and thus
don't need to be exported at all.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1351>
2024-06-23 21:19:27 +00:00
Olivier Fourdan 32e16082c5 xwayland: Stop on first unmapped child
If a child window of the same size is unmapped, we should stop walking
the tree looking for the surface window to use.

Whatever lies beneath is not visible anyway.

This also fixes an issue with the Damage list becoming corrupted when
destroying a window, because the first thing that DeleteWindow() does
is to unmap the window and crush the window tree underneath it.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Fixes: 3a0fc268 - xwayland: Add xwl_window::surface_window
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1680
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1564>
2024-06-17 07:06:38 +00:00
Olivier Fourdan 0509b13fa2 xwayland: Do not use manual redirect windows as surface window
While walking the window tree looking for the surface window to use, we
should ignore windows using manual redirection.

If a client manually redirects a window, it has control over how the
contents of that window are presented. It's not safe to present them
directly to the Wayland compositor.

v2: break instead of continue, reword commit message (Michel)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Fixes: 3a0fc268 - xwayland: Add xwl_window::surface_window
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1677
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1679
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1564>
2024-06-17 07:06:38 +00:00
Olivier Fourdan 702a419c39 xwayland: Move XRandR emulation to the ResizeWindow hook
This restores the handling of the XRandR emulation for Xwayland rootless
where it was before commit fa7b1c20.

Some compositors may trigger a protocol error if the viewport source is
larger than the actual window size, having that handled in the window
resize hook makes sure we do not regress.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1521>
2024-05-13 08:52:32 +00:00
Olivier Fourdan 31d6f9998d xwayland: Handle rootful resize in ResizeWindow
Commit fa7b1c20 ("xwayland: Use ConfigNotify screen hook instead of
ResizeWindow") replaced the WindowResize hook with ConfigNotify.

However, that's breaking rootful Xwayland with libdecor because the root
window size is already set so the libdecor size is not updated, and the
root size will be reverted back as soon as the focus changes.

Reinstate the rootful size change in ResizeWindow to avoid that issue.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1669
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1671
Fixes: fa7b1c20 - xwayland: Use ConfigNotify screen hook instead of ResizeWindow
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1521>
2024-05-13 08:52:32 +00:00
Olivier Fourdan 539859bde0 xwayland: Restore the ResizeWindow handler
For now it just chains to ResizeWindow hook.

This is preparation work for the next commit, no functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1521>
2024-05-13 08:52:32 +00:00
Vlad Zahorodnii a4ed100c0c xwayland: Set wl_surface input region
Some applications that use client side decorations usually set custom
input shape in order to prevent drop shadows stealing pointer events
from windows below. Currently, the only way to get it is to use some
XFixes APIs.

On the other hand, plenty of wayland compositors use solely the
wl_surface input region to decide what view can receive pointer input,
which results in some pointer input issues around client side drop
shadows because Xwayland doesn't set wl_surface.input_region.

See-also: https://bugs.kde.org/show_bug.cgi?id=448119
Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1510>
2024-04-30 12:46:49 +00:00
Olivier Fourdan 385226bdaf xwayland: Walk the regions' boxes
In xwl_source_validate(), the actual box wasn't updated, so we would
possibly copy several times the same first box.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Fixes: aa05f38f3 - xwayland: Add SourceValidate hook
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1485>
2024-04-12 07:38:26 +00:00
Michel Dänzer aa05f38f3d xwayland: Add SourceValidate hook
A later commit will use it to ensure the toplevel window pixmap has
valid contents.

It's hooked up only while any xwl_window->surface_window_damage points
to a non-empty region. So far it's always NULL, so no functional change
intended.

v2:
* Fix trailing whitespace. (Olivier Fourdan)
v3:
* Use toplevel local variable more in xwl_window_update_surface_window.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer fca63f8fb8 xwayland/present: Add xwl_present_maybe_(un)redirect_window
A later commit will use these to (un)redirect the surface window on
demand.

Not used yet, so no functional change intended.

v2:
* Use "surface_window_damage" instead of "surf_win_damage".
  (Olivier Fourdan)
* Slightly simplify logic in xwl_unrealize_window.
v3:
* Add comment in xwl_present_maybe_unredirect_window explaining why we
  use a timer. (Olivier Fourdan)
v4:
* Rename unredir_timer field to unredirect_timer.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer fa7b1c20c4 xwayland: Use ConfigNotify screen hook instead of ResizeWindow
Preparation for later commits, no functional change intended.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer 3a0fc2684a xwayland: Add xwl_window::surface_window
It may track a non-toplevel window which fully covers the area of the
window pixmap / Wayland surface. It is now used instead of
xwl_window::toplevel for updating the Wayland surface contents.

The surface_window can now hit the Present page flip path while it's
automatically redirected.

v2:
* Use "surface_window" instead of "surf_win". (Olivier Fourdan)
* Add comment describing surface_window, and describe what
  surface_window/toplevel are useful for respectively. (Olivier Fourdan)
* Use surface_window in xwl_realize_window.
v3:
* Backtrack up to the closest opaque ancestor in
  xwl_window_update_surface_window. (Olivier Fourdan)
v4:
* Clean up logic for determining the surface window in
  xwl_window_update_surface_window, and document it better.
* Handle window_get_damage(xwl_window->surface_window) returning NULL
  in xwl_window_update_surface_window.
* Call xwl_window_update_surface_window after xwl_window_buffers_init
  in ensure_surface_for_window, since the former may call
  xwl_window_buffers_dispose.
* Rename surf/win_pix to surface/window_pixmap in
  xwl_window_update_surface_window.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer d3448f7aad xwayland: Use xwl_window for damage closure
Preparation for later commits, no functional change intended.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer 07f6032627 xwayland: Call register_damage depending on ensure_surface_for_window
Preparation for next commit.

This might change behaviour for non-InputOutput top-level windows.
ensure_surface_for_window getting called and returning non-NULL for
those would seem like a pre-existing bug though.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer a562d01a18 xwayland: Return struct xwl_window * from ensure_surface_for_window
Preparation for later commits, no functional change intended.

v2:
* Leave register_damage call unchanged in this commit. (Olivier Fourdan)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer 972d5af537 xwayland: Rename xwl_window::window to ::toplevel
It's always the toplevel window, i.e. either the root window or a child
of it.

Preparation for later commits, no functional change.

v2: (Olivier Fourdan)
* Fix debug build.
* Add comment describing ::toplevel.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer 59a0259152 xwayland: Use xwl_window for tracking focus/touch
Slightly simpler, and might work better in some cases when X windows
get reparented.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Erik Kurzinger 87bf2cafcc xwayland: add support for wp_linux_drm_syncobj_v1
This protocol allows for explicit synchronization of GPU operations by
Wayland clients and the compositor. Xwayland can make use of this to
ensure any rendering it initiates has completed before the target image
is accessed by the compositor, without having to rely on kernel-level
implicit synchronization.

Furthermore, for X11 clients that also support explicit synchronization
using the mechanisms exposed in the DRI3 and Present extensions, this
Wayland protocol allows us to simply forward the timeline, acquire, and
release points directly to the compositor, ideally avoiding any
premature stalls in the presentation pipeline.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/967>
2024-04-09 06:11:03 +00:00
Olivier Fourdan 821d3d5789 xwayland: Use fractional scale with rootful
Implement fractional scale with Xwayland rootful by scaling the content
to the desired fractional scale using a viewport.

For now this applies to Xwayland rootful only.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan da84b470cb xwayland: Rename xwl_window_enable_viewport()
To support the fractional scale protocol, we need a viewport.

Rename the existing function xwl_window_enable_viewport() to avoid
confusion with the viewport we use for fullscreen XRandR emulation in
rootless mode.

No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 4003b1f9a2 xwayland: Update the global screen scale
Recompute and update the global screen scale based on the different
outputs the root window is placed on.

For backward compatibility, this functionality is however disabled by
default and can be enabled using a new command line option "-hidpi".

That option has no effect if Xwayland is running rootless.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 290ae87c02 xwayland: Update the scale based on enter/leave events
Recompute the window scale each time the window enters or leaves an
output.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 4248bfb0da xwayland: Keep track of outputs per window
Add a list of outputs a window is placed on, adding an output whenever
the surface enters the output and removing it once it leaves the output.

Note that not all Wayland compositors actually send a leave surface
event on output removal, so we need to make sure to remove the output
from the list for each window, otherwise we might end up pointing to
freed memory.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan cd0c43df13 xwayland: Make has_viewport_enabled private
By using a sensible scale factor for input even when there is no
viewport enabled, no need to have xwl_window_has_viewport_enabled()
public anymore.

Small cleanup, no functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 3ea36e5214 xwayland: Always set the viewport scale factor
When the viewport is disabled, set the scale x/y back to 1.0 so that we
can apply the scale factor regardless of the viewport being enabled.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 96fd7cc8c9 xwayland: Rename scale_x/y to viewport_scale_x/y
The scale_x/y factor applies when a viewport is in use, rename the
fields to reflect that and distinguish these from the other scale
factors such as the core protocol surface scale and the fractional
scaling.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 54f8fc4090 xwayland: Account for the scale factor
Apply the scale factor to the root window and adjust the coordinates and
hotspot location for cursors.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 32dad24083 xwayland: Use double for screen size
Use double precision floating point for the screen size to reduce the
rounding issues when using fractional scaling.

Introduce a couple of simple convenient functions that round the
floating point value into an integer and use it in place of directly
accessing the xwl_screen width/height for integer computation.

This is preparation work for the introduction of fractional scaling,
there should be no functional change at this point.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 792758faa5 xwayland: Update lost focus on deactivation
Use the "activated" state from xdg-shell to call the pointer and
keyboard leave events when running rootful.

The regular pointer and keyboard leave notifications are now ignored
when running rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1604
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
2024-03-18 23:34:29 +00:00
Olivier Fourdan 54a2dfc229 xwayland: Drop xwl_window_buffers_get_pixmap()
This just calls into xwl_window_swap_pixmap() so we can just use that
instead (Michel).

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:18 +00:00
Olivier Fourdan 6fd77acd91 xwayland/glamor: Drop the post_damage() hook
That was used only with the EGLStream backend, we can remove it.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:18 +00:00
Olivier Fourdan 722ea5d000 xwayland: Move dmabuf code to its own source file
The dmabuf support code is scattered across different source files,
making it hard to follow and bloating unrelated sources.

Move the dmabuf related source code to its own source files.

This is just a cleanup aimed at helping with code readability, no
functional change intended.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1111>
2024-03-14 15:00:46 +01:00
Michel Dänzer 64341c479c xwayland/present: Handle clearing damage after flip in xwl_present_execute
Due to DamageReportNonEmpty, damage_report doesn't get called if the
damage region was already non-empty before the flip. In which case it
didn't get called before the first draw after the flip either.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1627
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 17:33:54 +01:00
Michel Dänzer 6b290fa5d9 xwayland: Replace window pixmap as needed for drawing operation
We must not modify the contents of a client pixmap.

If there's an available window buffer, we re-use that for the window
pixmap. Otherwise we just allocate a new one.

This also avoids Present client hangs due to xwl_present_buffer_release
not getting called for the buffer release event.

v2:
* Use xwl_pixmap_get_buffer_release_cb instead of keeping track of the
  flip pixmap in xwl_window.
* Dispose of xwl_window_buffer in xwl_window_swap_pixmap called from
  damage_report.
v3:
* Use xwl_window->surface_pixmap in damage_report.
v4:
* Don't re-use client pixmaps as window buffers.
* Clear xwl_window_buffer->pixmap before calling
  xwl_window_buffer_maybe_dispose in xwl_window_swap_pixmap, to prevent
  it from clearing the buffer release callback.
v5:
* Keep using xwl_window_buffers_get_pixmap in xwl_window_attach_buffer.
* Always keep a reference to the old window pixmap in _swap_pixmap,
  drop it in damage_report.

Fixes: 6779ec5bf6 ("xwayland: Use window pixmap as a window buffer")
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1633
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1644
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 17:12:54 +01:00
Michel Dänzer 716805e3ad xwayland: Call xwl_window_buffer_add_damage_region from damage_report
Before clearing the damage region. Otherwise the damage region from a
Present flip may be ignored when replacing the window pixmap.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 16:55:13 +01:00
Michel Dänzer c1c5bf382e xwayland: Do not plumb damage region through function parameters
Each function can get the damage region from the xwl_window instead.
Add xwl_window_get_damage_region helper for this.

v2:
* Use xwl_window_get_damage_region in xwl_window_attach_buffer as well
  (Olivier Fourdan)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 16:55:13 +01:00
Michel Dänzer abe3a08245 xwayland: Enable Present extension support also without glamor
This allows e.g.

 xfwm4 --vblank=xpresent

to hit the page flip path instead of copies.

In the future, Mesa might also use the Present extension with software
rendering.
2024-01-22 14:14:05 +00:00
Michel Dänzer 17986658bf xwayland: Add xwl_pixmap_get_wl_buffer helper
Preparation for the next commit.
2024-01-22 14:14:05 +00:00
Olivier Fourdan 87ca6dcb43 xwayland: Check for the screen output name for fullscreen
When putting the (root) window fullscreen, first search for an output
with the specified name, if any.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00