Commit Graph

9288 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult e5c8b664d3 os: unexport ddx callbacks
The DDX callbacks (where core/DIX calls into DDX) aren't supposed to be
called by drivers directly, so unexport them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1332>
2024-05-08 09:37:35 +02:00
Olivier Fourdan a7ba1e9fe4 xquartz: Remove invalid Unicode sequence
This is flagged by the automatic scanning tools.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1673
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1524>
2024-05-07 22:26:34 +00:00
Vlad Zahorodnii 8c2b9f4e71 xwayland: Use correct xwl_window lookup function in xwl_set_shape
In xwl_set_shape(), xwl_window_set_input_region() should be called only
when the input shape of the toplevel window changes.

However, given that xwl_window_from_window() is going to walk the
ancestor tree until it finds an xwl_window, that lookup function cannot
be used. Instead, xwl_window_get() should be used. It's going to return
a valid xwl_window object iff the specified window has one associated
with it.

Fixes: a4ed100c0 - xwayland: Set wl_surface input region
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1672
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1516>
2024-05-06 14:47:39 +00:00
Michel Dänzer 069ad69efe xwayland/present: Drop vblank->flip_ready assignment
Xwayland hasn't used the flip_ready field's value for anything since
e1f16fb1ac ("xwayland: don't scrap pending present requests").

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1511>
2024-05-02 08:17:35 +00:00
Michel Dänzer 0d9a54aa97 xwayland/present: Skip queued flip when a new one becomes ready
If multiple flips become ready for the same MSC, we would previously
execute them all sequentially, one per MSC for sync flips. This could
result in an unbounded flip queue and corresponding memory consumption.

With implicit sync, leave the mailbox handling to the compositor for
async flips though.

v2:
* Use present_vblank_rec::sync_flip.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1664
Fixes: e1f16fb1ac ("xwayland: don't scrap pending present requests")
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1511>
2024-05-02 08:17:35 +00:00
Erik Kurzinger d5192ba8eb xwayland: use write fence in xwl_glamor_dmabuf_import_sync_file
The functions xwl_glamor_dmabuf_import_sync_file and
xwl_glamor_dmabuf_export_sync_file are used to ensure proper
synchronization between clients using PresentPixmapSynced and
compositors that do not support the wp_linux_drm_syncobj_v1 protocol
when presenting by flipping. The acquire point's fence will be imported
as the DMA-BUF's implicit fence before handing it off to the compositor,
and then, after the DMA-BUF has been released, its new implicit fence
will be exported and become the release point's fence which the client
is expected to wait for before re-using the buffer.

Both functions currently set the flags arguments of their respective
ioctls to DMA_BUF_SYNC_READ. When importing a sync file, this means that
any subsequent implicitly synchronized reads from the buffer will not
wait for the fence, and when exporting a sync file it means that the
returned fence may be signaled before preceeding reads from the buffer
have completed.

While this is correct for xwl_glamor_dmabuf_export_sync_file since the
compositor will never write to the buffer, it is incorrect for
xwl_glamor_dmabuf_import_sync_file. To avoid corruption, we need any
reads from the buffer by the compositor to wait on the acquire point's
fence.

As a fix, instead of setting the DMA_BUF_SYNC_READ flag in
xwl_glamor_dmabuf_import_sync_file, we set the DMA_BUF_SYNC_WRITE flag.
This *does* provide the necessary guarantees.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1509>
2024-04-30 13:18:30 +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 4053782443 xwayland: Do not remove output on withdraw if leased
On DRM lease connector withdrawn event, Xwayland would free the
corresponding xwl_output offered for lease.

However, the pointer is still referenced from the rrLease->outputs[],
meaning that trying to clean up the RANDR DRM leases as done with commit
ef181265 (xwayland: Clean up drm lease when terminating) would cause a
use after free and random crashes.

To avoid that issue, on the connector withdraw event, set the connector
withdrawn flag but do not to remove (i.e. free) the xwayland output if
its is offered for lease.

Then, once the lease is terminated, check for the xwl_outputs with a
withdrawn connector and remove them (once we have no use for them
anymore.

Note that we cannot do that cleanup from xwl_randr_terminate_lease() as
removing the xwl_output will free the RRcrtc resources, which checks for
leases in XRANDR, and calls RRTerminateLease(), which chains back to
xwl_randr_terminate_lease().

v2: Use a "withdrawn_connector" flag to mark outputs to remove (Xaver)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Xaver Hugl <xaver.hugl@kde.org>
fixes: ef181265 - xwayland: Clean up drm lease when terminating

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/946
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1130
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1482>
2024-04-30 09:13:34 +02:00
Olivier Fourdan 21916ae148 xwayland: Check for outputs before lease devices
In xwl_randr_request_lease(), the code checks first for leased device,
and then checks for existing output for lease.

The former assumes there are outputs for lease whereas the latter checks
for the output, connector and lease.

So if there is any existing rrLease->outputs[]->devPrivate unset, the
code would crash on a NULL pointer dereference on the first sanity check
before having a chance to reach the second check that would have caught
the problem.

Invert the sanity checks so that we would catch this first and return a
BadValue instead of possibly segfaulting.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Xaver Hugl <xaver.hugl@kde.org>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1482>
2024-04-30 09:13:34 +02:00
Enrico Weigelt, metux IT consult eff7ccc11c include: move private definitions out of exevents.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to private header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-30 00:47:38 +00:00
Enrico Weigelt, metux IT consult 33350ef8ff include: move private definitions out of extinit.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to extinit_priv.h.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-30 00:47:38 +00:00
Enrico Weigelt, metux IT consult bae6cbc8ca include: move private defs to dixstruct_priv.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to dixstruct_priv.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-30 00:47:38 +00:00
Enrico Weigelt, metux IT consult f17bc7e24d include: split out non-exported prototypes to dix_priv.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to dix-intern.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-30 00:47:38 +00:00
Michel Dänzer 08113b8923 xwayland/glamor: Handle depth 15 in gbm_format_for_depth
Prevents Xwayland with glamor from logging

 unexpected depth: 15

to stderr many times when running

 rendercheck -t blend -o clear

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1507>
2024-04-25 17:17:55 +02:00
Olivier Fourdan 49b8f131f7 xwayland: Use the connector name for XRANDR leases
Use the connector name as basis for the Xwayland output name in XRANDR,
similar to what we do for regular outputs, instead of the generic
"XWAYLAND<n>" name which changes every time the output is leased.

Prefix the actual name with "lease-" to distinguish from duplicate names
from the regular outputs.

v2: avoid duplicate names (Simon)
v3: Move the check for duplicates to xwl_output_set_name() (Simon)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>
2024-04-23 11:14:31 +02:00
Olivier Fourdan d36f66f15d xwayland: Check for duplicate output names
Even though the name provided by either xdg-output or wl_output are
guaranteed to be unique, that might not be the case with output names
between different protocols, such as the one offered for DRM lease.

To avoid running into name conflicts, check that no other existing
output of the same name exists prior to changing the output name.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>
2024-04-23 11:14:31 +02:00
Olivier Fourdan 0cb4ec4dbd xwayland: Make xwl_output_set_name() public
No functional change, this is preparation work for the next commit.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>
2024-04-23 11:14:31 +02:00
Olivier Fourdan 12265aaa1c xwayland: Define MAX_OUTPUT_NAME in the header
So that other parts of the Xwayland code can use it.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>
2024-04-23 11:14:31 +02:00
Enrico Weigelt, metux IT consult 75cf29fe6c dbe: unexport dbestruct.h
This include isn't used by any (known) driver nor included by any other
public header, so no need to keep it in the public module API.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1422>
2024-04-23 02:18:02 +00:00
Enrico Weigelt, metux IT consult 8982344e53 include: move dbus-core.h to config
This header is internal (not installed) and holds definitions for sources
in config/, thus it fells more clean moving it to config/, too.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1357>
2024-04-23 01:46:24 +00:00
Enrico Weigelt, metux IT consult 140b75298a include: colormap.h: move internal typedef to dix/colormap_priv.h
Moving the internal EntryType typedef from "colormap.h" into newly added
internal-only header "dix/colormap_priv.h"

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1283>
2024-04-23 01:05:06 +00:00
Enrico Weigelt, metux IT consult 94451181c2 xnest: fix segfault in miCreateScreenResources()
With aa3f5023e3, pScreen->devPrivate now is
initialized only once, which uncovered a silent bug in xnestOpenScreen:
It's NULL'ing the pScreen->devPrivate pointer which already had been
initialized by previous miScreenDevPrivateInit() call.

Fixes: aa3f5023e3
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1495>
2024-04-23 00:52:52 +00:00
Enrico Weigelt, metux IT consult 17db4ba3de xfree86: sdksyms: drop errornous check for mifillarc.h
This file had been dropped from public API a decade ago, but sdksyms.sh
yet had been forgotten to be fixed.

Fixes: 707965407a
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1497>
2024-04-22 20:43:38 +02:00
Enrico Weigelt, metux IT consult 43f47e8e65 xfree86: x86emu: fix warning on unneccessary abs()
fix warning:

> In file included from ../hw/xfree86/int10/x86emu.c:11:
> ../hw/xfree86/x86emu/prim_ops.c:2478:9: warning: taking the absolute value of unsigned type 'x86emuu32' (aka 'unsigned int') has no effect [-Wabsolute-value]
>     if (abs(div) > 0xff) {
>         ^
> ../hw/xfree86/x86emu/prim_ops.c:2478:9: note: remove the call to 'abs' since unsigned values cannot be negative
>     if (abs(div) > 0xff) {
>         ^~~
> ../hw/xfree86/x86emu/prim_ops.c:2502:9: warning: taking the absolute value of unsigned type 'x86emuu32' (aka 'unsigned int') has no effect [-Wabsolute-value]
>     if (abs(div) > 0xffff) {
>         ^
> ../hw/xfree86/x86emu/prim_ops.c:2502:9: note: remove the call to 'abs' since unsigned values cannot be negative
>     if (abs(div) > 0xffff) {
>         ^~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1428>
2024-04-18 01:03:11 +00:00
Enrico Weigelt, metux IT consult a0daa6f1fe xfree86: x86emu: drop unused stq_u()
fix warning on unused function:

> ../hw/xfree86/x86emu/sys.c:87:1: warning: unused function 'stq_u' [-Wunused-function]
> stq_u(u64 val, u64 * p)
> ^

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1428>
2024-04-18 01:03:11 +00:00
Enrico Weigelt, metux IT consult 8081fe1206 xfree86: x86emu: drop unused ldq_u()
fix warning on unused function:

> ../hw/xfree86/x86emu/sys.c:69:1: warning: unused function 'ldq_u' [-Wunused-function]
> ldq_u(u64 * p)
> ^
> ../hw/xfree86/x86emu/sys.c:95:1: warning: unused function 'stq_u' [-Wunused-function]
> stq_u(u64 val, u64 * p)
> ^

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1428>
2024-04-18 01:03:11 +00:00
Enrico Weigelt, metux IT consult 1e7085d143 xfree86: os-support: bsd: fix missing prototypes
Fix warnings on missing prototypes:

> ../hw/xfree86/os-support/bsd/bsd_VTsw.c:56:20: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86VTSwitchPending()
>                    ^
>                     void
> ../hw/xfree86/os-support/bsd/bsd_VTsw.c:67:17: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86VTSwitchAway()
>                 ^
>                  void
> ../hw/xfree86/os-support/bsd/bsd_VTsw.c:82:15: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86VTSwitchTo()
>               ^
>                void

> ../hw/xfree86/os-support/bsd/bsd_init.c:155:16: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86OpenConsole()
>                ^
>                 void
> ../hw/xfree86/os-support/bsd/bsd_init.c:322:15: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86OpenPccons()
>               ^
>                void
> ../hw/xfree86/os-support/bsd/bsd_init.c:347:16: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86OpenSyscons()
>                ^
>                 void
> ../hw/xfree86/os-support/bsd/bsd_init.c:453:13: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86OpenPcvt()
>             ^
>              void
> ../hw/xfree86/os-support/bsd/bsd_init.c:596:17: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86CloseConsole()
>                 ^
>                  void
> ../hw/xfree86/os-support/bsd/bsd_init.c:673:11: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
> xf86UseMsg()
>           ^
>            void

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1428>
2024-04-18 01:03:11 +00:00
Enrico Weigelt, metux IT consult 20d0545f0d xfree86: modes: drop unused xf86_driver_has_show_cursor()
Fix warning on unused function:

> ../hw/xfree86/modes/xf86Cursors.c:212:1: warning: unused function 'xf86_driver_has_show_cursor' [-Wunused-function]
> xf86_driver_has_show_cursor(xf86CrtcPtr crtc)
> ^

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1428>
2024-04-18 01:03:11 +00:00
Enrico Weigelt, metux IT consult 0f715b4ca4 xfree86: os-support: move hidden Solaris-specific symbols out of public header
These aren't exported at all, so no need to have it in public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult 7429f8ee8f xfree86: os-support: move xf86FatalError macro out of public header
This macro is only used inside xfree86's os-support layer, not by any
(known) drivers. Thus no need to have it exported in the public API.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult 16a3790d60 xfree86: os-support: move unexported stuff out of xf86_OSproc.h
It's cleaner to have public headers only holding public stuff and
xf86_os_support seems to be much more appropriate place for this.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult 5b23578f93 xfree86: os-support: move VidMemInfo xf86_os_support.h
This type is only used inside the os-support layer of xfree86, so it fits
better into xf86_os_support.h, whose purpose is being the primary entry
point into os-support layer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult 533c45e595 xfree86: os-support: move xf86OSInitVidMem() to xf86_os_support.h
This function isn't exported at all, so it better fits into xf86_os_support.h,
whose purpose is being the primary entry point into os-support layer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult a5cfe020f5 xfree86: os-support: unexport xf86RemoveSIGIOHandler
It's not used by any driver, so no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult 3e4fc3e588 xfree86: os-support: unexport xf86DeallocateGARTMemory
It's not used in any drivers, so no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult 38030fce53 xfree86: os-support: unexport xf86OSInputThreadInit()
This is just called by xfree86 core, not by any drivers, thus no need
to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult b9569f1eb3 xfree86: os-support: unexport xf86OSRingBell()
This function is only internal to xfree86 DDX, not used by any drivers,
thus no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult 7aa3fa54d4 xfree86: unexport os-support functions
These aren't called by drivers/modules, so no need to export them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1456>
2024-04-18 00:40:39 +00:00
Enrico Weigelt, metux IT consult e2fa0d2ae0 fix including <sys/mman.h>
Make sure everybody who needs stuff from <sys/mman.h> actually includes it,
and dropped the include from xf86_OSlib.h.

Check for all symbols defined by Open Group spec.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1412>
2024-04-18 00:12:02 +00:00
Enrico Weigelt, metux IT consult 8ce76acddf xfree86: os-support: bsd fix warning on unused label on NetBSD
The label is only used on FreeBSD, so compiling on NetBSD gives a
warning on unused label.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1447>
2024-04-18 00:01:27 +00:00
Enrico Weigelt, metux IT consult 6eea4f0b8c xfree86: os-support: bsd: fix warning on discarded const
Fix warnings:

../hw/xfree86/os-support/bsd/bsd_init.c
../hw/xfree86/os-support/bsd/bsd_init.c:91:5: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   91 |     "pccons (with X support)",
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
../hw/xfree86/os-support/bsd/bsd_init.c:97:5: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   97 |     "pcvt",
      |     ^~~~~~
../hw/xfree86/os-support/bsd/bsd_init.c💯5: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  100 |     "wscons",
      |     ^~~~~~~~

../hw/xfree86/os-support/bsd/bsd_init.c:462:14: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  462 |     vtprefix = "/dev/ttyv";
      |              ^
../hw/xfree86/os-support/bsd/bsd_init.c:471:18: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  471 |         vtprefix = "/dev/ttyE";
      |                  ^

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1446>
2024-04-17 23:50:09 +00:00
Olivier Fourdan 41c3155fdf xwayland: Use exec name instead of hardcoding '/Xwayland'
Use the target name instead of hardcoding the 'Xwayland' executable
name, along with the / operator.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1490>
2024-04-17 15:20:05 +00:00
Olivier Fourdan 8ff88ffec9 xwayland: Use the path to Xwayland as installed
Otherwise the executable cannot be found where specified.

v2: Use 'xwayland_path' (Simon)

Fixes: fbf5e26b5 - xwayland: Use full path for Xwayland exec
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1490>
2024-04-17 15:20:05 +00:00
Simon Ser d1fe52933e xwayland: use array for protocol XML files
Saves us the repetition.

Signed-off-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1491>
2024-04-17 15:25:34 +02:00
Enrico Weigelt, metux IT consult 5057c716eb Fix missing include of sys/stat.h
Instead of relying on very indirect includes, it's more more clean when
everybody explicitly includes what he really needs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1417>
2024-04-17 10:55:10 +02:00
Enrico Weigelt, metux IT consult 97e26532d5 xfree86: os-support: drop ununsed POSIX_TTY
Found no evidence that this define is practically used anywhere, aymore.
Web research just showed up a single ancient .c file (looks like an
Wacom driver) from 1998. Xserver's git history doesn't tell when it
actually had been introduced.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1408>
2024-04-17 02:16:12 +00:00
Enrico Weigelt, metux IT consult a1c1f8b9d8 xfree86: drop unused xf86EnableAGP()
This function doesn't seem to be used anymore, neither inside the xserver,
nor by any drivers - so it can be dropped.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1404>
2024-04-17 02:05:36 +00:00
Enrico Weigelt, metux IT consult ba870af892 xfree86: drop unused xf86SetReallySlowBcopy()
This had been introduced almost two decades ago, by Dave Airlie (*1) along
with some major IO speed improvement, just in case some driver still needed
the old behaviour - in that case it would call xf86SetReallySlowBcopy(),
so xf86SlowBcopy() would fall back to the old approach emitting an extra
outb() on debug port, in order to slow things down more.

Now aeons have passed and there doesn't seem to be any actual user for this,
so it's time to drop that ancient relic.

*1) commit e717eb82dc

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1402>
2024-04-17 01:54:28 +00:00
Enrico Weigelt, metux IT consult e37bcac1dc xfree86: linux: int10: drop dead code
The code pieces inside `ifdef DoSubModule` aren't used anymore since very
long time. There's no evidence of this symbol ever been set in the whole
git history, so it must be an really ancient relic, that nobody used for
decades.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1400>
2024-04-17 01:43:30 +00:00
Enrico Weigelt, metux IT consult be4c8444eb os: unexport Os*() functions
These aren't called (and suited for being called) by drivers,
thus drop them from the public module API.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1381>
2024-04-16 14:20:30 +02:00
Enrico Weigelt, metux IT consult 85d4bd0dba rename remaining RT_* defines to X11_RESTYPE_*
Since we already had to rename some of them, in order to fix name clashes
on win32, it's now time to rename all the remaining ones.

The old ones are still present as define's to the new ones, just for
backwards compatibility.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355>
2024-04-15 19:00:47 -07:00
Enrico Weigelt, metux IT consult 232cad9ec3 prevent name clash on Windows w/ RT_* defines
Windows' native headers using some our RT_* define's names for other things.
Since the naming isn't very nice anyways, introducing some new ones
(X11_RESTYPE_NONE, X11_RESTYPE_FONT, X11_RESTYPE_CURSOR) and define the old
ones as an alias to them, in case some out-of-tree code still uses them.

With thins change, we don't need to be so extremely careful about include
ordering and have explicit #undef's in order to prevent name clashes on
Win32 targets.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355>
2024-04-15 18:59:23 -07:00
Enrico Weigelt, metux IT consult d444cd4237 dix: unexport some lookup functions
These aren't used by any drivers, so no need to export them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1380>
2024-04-15 18:11:57 -07:00
Enrico Weigelt, metux IT consult 76d01e9bf6 os: unexport OsVendorVErrorFProc pointer
This pointer allows a DDX to install it's own error print handler. It's really
only intended for DDXes, thus no need to have it exported to modules.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1369>
2024-04-15 23:59:38 +00:00
Enrico Weigelt, metux IT consult 1205f5b6f9 dix: unexport GetCurrentClient()
Not used by any driver, so no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1377>
2024-04-15 23:47:47 +00:00
Enrico Weigelt, metux IT consult 3b7a63e6ae os: unexport xthread_sigmask
This function isn't used by drivers and there's currently no need to do so,
thus keep it out of the public module API.

Fixes: 30ac756798
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1368>
2024-04-15 22:49:02 +00:00
Enrico Weigelt, metux IT consult 5a9b885118 os: unexport authorization management functions
Those aren't used by modules, thus no need to export them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1344>
2024-04-15 14:55:22 -07:00
Enrico Weigelt, metux IT consult bed778ee60 os: unexport LocalAccessScopeUser()
this function is only used by wayland ddx, so no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1344>
2024-04-15 14:55:22 -07:00
Enrico Weigelt, metux IT consult 389b528203 os: unexport command line args handling functions
These functions shouldn't be called by drivers or extensions, thus
shouldn't be exported. Also moving it to separate header, so the
already huge ones aren't cluttered with even more things.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1334>
2024-04-15 21:21:40 +00:00
Enrico Weigelt, metux IT consult 84407af615 xfree86: x86emu: fix missing Xfuncproto.h include in debug.h
The header uses macros from Xfuncproto.h - right now it just works by pure
accident since consumers of this header indirectly include Xfuncproto.h
by totally different roads. This is a fragile programming style that deserved
to be cleand up.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1331>
2024-04-15 20:11:18 +00:00
Enrico Weigelt, metux IT consult 045c9185f8 xfree86: x86emu: drop unnecessary extern C from debug.h
Since we're not using C++ code, thus no trouble w/ name mangling, we don't
need explicit extern "C" { ... } sections in the code. (If we would, we
have to have it in many other places, too)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1331>
2024-04-15 20:11:18 +00:00
Enrico Weigelt, metux IT consult 8516bbe422 Xnest: print event ID on warning about unhandled upstream event
When getting an unhandled event from upstream Xserver, a warning
is printed, but it doesn't tell which one yet. Just printing it's
ID should be good enough for now - it's already a good help
for debugging.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1398>
2024-04-15 19:33:57 +00:00
Enrico Weigelt, metux IT consult 2cc5c57238 Xnest: cleanup X.h includes
It's cleaner to include explicitly instead of relying on indirect includes,
thus adding a few more on X.h.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1394>
2024-04-15 19:20:39 +00:00
Enrico Weigelt, metux IT consult 737c316a99 Xnest: canonicalize includes: <X11/Xdefs.h>
For cleaner code, make sure every source needing something from Xdefs.h
does explicitly include it (not relying on indirect including)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1394>
2024-04-15 19:20:39 +00:00
Enrico Weigelt, metux IT consult b15f0204b2 Xnest: ignore NoExpose event
Sometimes getting NoExpose event from upstream xserver, where
we've got nothing actually to do.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1399>
2024-04-15 19:06:59 +00:00
Enrico Weigelt, metux IT consult 57254ca23c xnest: Display: fix xallocarray() compiler warning
Compiler warning:

[7/29] Compiling C object hw/xnest/Xnest.p/Display.c.o
In file included from ../include/misc.h:119,
                 from ../include/screenint.h:50,
                 from ../hw/xnest/Display.c:24:
../hw/xnest/Display.c: In function ‘xnestOpenDisplay’:
../include/os.h:81:32: warning: argument 2 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
   81 | #define xallocarray(num, size) reallocarray(NULL, (num), (size))
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../hw/xnest/Display.c:124:29: note: in expansion of macro ‘xallocarray’
  124 |     xnestDefaultColormaps = xallocarray(xnestNumDefaultColormaps,
      |                             ^~~~~~~~~~~
In file included from ../include/os.h:54:
/usr/include/stdlib.h:582:14: note: in a call to allocation function ‘reallocarray’ declared here
  582 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
      |              ^~~~~~~~~~~~

Since we really don't need more than 2^16 colormaps, using uint16_t here
to silence this warning.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1392>
2024-04-15 18:52:13 +00:00
Tom Yan aa3f5023e3 xnest/mi: remove redundant call of miScreenDevPrivateInit()
miScreenDevPrivateInit() is also made static in this commit.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/854>
2024-04-14 17:20:09 +00:00
Enrico Weigelt, metux IT consult 786f7ceb61 xfree86: vgahw: drop obsolete _NEED_SYSI86
This doesn't seem to be needed anymore, probably a left over from migration
to libpciaccess. So it can be removed now.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1415>
2024-04-13 19:43:59 +00:00
Enrico Weigelt, metux IT consult dee16edd2e xfree86: os-support: move _NEED_SYSI86 guarded block to sun_vid.c
The sun_vid.c driver seems to be the only actual consumer left, so it
can be dropped from public headers and moved to sun_vid.c instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1414>
2024-04-13 12:13:50 -07:00
Enrico Weigelt, metux IT consult 1073ca2b8a xfree86: os-support: drop Solaris pre-7 remains
Since meson transition, we can't build on Solaris older than v7
(which came out 1998), so no need for extra quirks.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1414>
2024-04-13 12:13:42 -07:00
Enrico Weigelt, metux IT consult bfcc7726a8 xfree86: os-support: clean out remains of SVR3/sysv support
SVR3/sysv support had been removed 13 years ago, but there still was
some fallout left. The symbol HAS_SVR3_MMAPDRV never had been set by
autoconf, let alone meson, so this piece of code is really dead.

Fixes: 6ce1908ba4
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1414>
2024-04-13 12:13:42 -07: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 4dc7e99840 xwayland: Use drmDevicesEqual in xwl_dmabuf_feedback_tranche_done
xwl_dmabuf_feedback_tranche_target_device always allocates a new
drmDevice for xwl_feedback->tmp_tranche.drm_dev, so the pointers are
never equal here.

Fixes: 6f0b9deed6 ("xwayland: use drmDevice to compare DRM devices")

v2:
* Flip order of checks, so drmDevicesEqual is called only if the
  supports_scanout flags match.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1484>
2024-04-12 07:25:55 +00:00
Michel Dänzer 82d3b8ff05 xwayland: Call drmFreeDevice for dma-buf default feedback
Fixes leaks:

==13712== 144 bytes in 1 blocks are definitely lost in loss record 4,827 of 7,462
==13712==    at 0x48459F3: calloc (vg_replace_malloc.c:1340)
==13712==    by 0x49BE94D: drmDeviceAlloc (xf86drm.c:4072)
==13712==    by 0x49BFAC9: drmProcessPciDevice (xf86drm.c:4104)
==13712==    by 0x49BFAC9: process_device (xf86drm.c:4508)
==13712==    by 0x49C35FB: drmGetDeviceFromDevId (xf86drm.c:4670)
==13712==    by 0x1AD370: xwl_dmabuf_feedback_main_device (xwayland-dmabuf.c:477)
==13712==    by 0x53C03FD: ffi_call_unix64 (unix64.S:104)
==13712==    by 0x53BF70C: ffi_call_int (ffi64.c:673)
==13712==    by 0x53BFEE2: ffi_call (ffi64.c:710)
==13712==    by 0x49AC920: wl_closure_invoke (connection.c:1025)
==13712==    by 0x49A8C08: dispatch_event.isra.0 (wayland-client.c:1631)
==13712==    by 0x49AA5AB: dispatch_queue (wayland-client.c:1777)
==13712==    by 0x49AA5AB: wl_display_dispatch_queue_pending (wayland-client.c:2019)
==13712==    by 0x49AAB5E: wl_display_roundtrip_queue (wayland-client.c:1403)

==13712== 576 bytes in 4 blocks are definitely lost in loss record 6,289 of 7,462
==13712==    at 0x48459F3: calloc (vg_replace_malloc.c:1340)
==13712==    by 0x49BE94D: drmDeviceAlloc (xf86drm.c:4072)
==13712==    by 0x49BFAC9: drmProcessPciDevice (xf86drm.c:4104)
==13712==    by 0x49BFAC9: process_device (xf86drm.c:4508)
==13712==    by 0x49C35FB: drmGetDeviceFromDevId (xf86drm.c:4670)
==13712==    by 0x1AD583: xwl_dmabuf_feedback_main_device (xwayland-dmabuf.c:477)
==13712==    by 0x1AD583: xwl_window_dmabuf_feedback_main_device (xwayland-dmabuf.c:691)
==13712==    by 0x53C03FD: ffi_call_unix64 (unix64.S:104)
==13712==    by 0x53BF70C: ffi_call_int (ffi64.c:673)
==13712==    by 0x53BFEE2: ffi_call (ffi64.c:710)
==13712==    by 0x49AC920: wl_closure_invoke (connection.c:1025)
==13712==    by 0x49A8C08: dispatch_event.isra.0 (wayland-client.c:1631)
==13712==    by 0x49AA5AB: dispatch_queue (wayland-client.c:1777)
==13712==    by 0x49AA5AB: wl_display_dispatch_queue_pending (wayland-client.c:2019)
==13712==    by 0x1A1842: xwl_read_events (xwayland-screen.c:566)
==13712==    by 0x1A1842: xwl_read_events (xwayland-screen.c:553)

Fixes: 6f0b9deed6 ("xwayland: use drmDevice to compare DRM devices")
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1484>
2024-04-12 07:25:55 +00:00
Olivier Fourdan a65bb8480a Revert "xwayland/glamor: Avoid implicit redirection with depth 32 parent windows"
There are a number of regressions and hard to reproduce issues that find
their roots in this change, so revert it until those can be ironed out
some more.

This reverts commit 4bb1f976d5.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1655
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1656
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1457>
2024-04-11 07:33:19 +00:00
Jan Beich f0748b05dc xwayland: avoid Linux-only headers on non-Linux
hw/xwayland/xwayland-glamor-gbm.c:38:10: fatal error: 'linux/dma-buf.h' file not found
   38 | #include <linux/dma-buf.h>
      |          ^~~~~~~~~~~~~~~~~

Fixes: 3df236a3d5 ("xwayland: add functions to import and export dma-buf implicit fences")
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1481>
2024-04-11 06:30:11 +00:00
Michel Dänzer c7d56b0e29 xwayland/present: Redirect surface window as needed for page flips
It's needed when the surface window is a depth 24 descendant of a depth
32 toplevel window.

xwl_source_validate ensures the toplevel window pixmap has valid
contents when a client reads from it, or when the window hierarchy /
geometry changes. It's never called in the normal fullscreen application
case, so there's no GPU copy overhead with that.

v2:
* Don't try to redirect a depth 32 descendant of different-depth
  ancestors, the alpha channel wouldn't be handled correctly.
  (Olivier Fourdan)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer 4495c696b5 xwayland/present: Check window & source pixmap depth match last
Preparation for next commit, 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 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 db248682b3 xwayland: Pass xwl_window to xwl_glamor_dri3_syncobj_passthrough
Preparation for later changes, 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 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
Enrico Weigelt, metux IT consult 0db309467d xfree86: os-support: bsd: fix warning on old-style function definition
Fix compiler warnings:

../hw/xfree86/os-support/bsd/bsd_VTsw.c: In function ‘xf86VTSwitchPending’:
../hw/xfree86/os-support/bsd/bsd_VTsw.c:56:1: warning: old-style function definition [-Wold-style-definition]
   56 | xf86VTSwitchPending()
      | ^~~~~~~~~~~~~~~~~~~
./hw/xfree86/os-support/bsd/bsd_VTsw.c: In function ‘xf86VTSwitchAway’:
./hw/xfree86/os-support/bsd/bsd_VTsw.c:67:1: warning: old-style function definition [-Wold-style-definition]
   67 | xf86VTSwitchAway()
      | ^~~~~~~~~~~~~~~~
../hw/xfree86/os-support/bsd/bsd_VTsw.c: In function ‘xf86VTSwitchTo’:
../hw/xfree86/os-support/bsd/bsd_VTsw.c:82:1: warning: old-style function definition [-Wold-style-definition]
   82 | xf86VTSwitchTo()
      | ^~~~~~~~~~~~~~

../hw/xfree86/os-support/bsd/bsd_init.c: In function ‘xf86OpenConsole’:
../hw/xfree86/os-support/bsd/bsd_init.c:153:1: warning: old-style function definition [-Wold-style-definition]
  153 | xf86OpenConsole()
      | ^~~~~~~~~~~~~~~

../hw/xfree86/os-support/bsd/bsd_init.c: In function ‘xf86OpenPccons’:
../hw/xfree86/os-support/bsd/bsd_init.c:320:1: warning: old-style function definition [-Wold-style-definition]
  320 | xf86OpenPccons()
      | ^~~~~~~~~~~~~~
../hw/xfree86/os-support/bsd/bsd_init.c: In function ‘xf86OpenPcvt’:
../hw/xfree86/os-support/bsd/bsd_init.c:451:1: warning: old-style function definition [-Wold-style-definition]
  451 | xf86OpenPcvt()
      | ^~~~~~~~~~~~

../hw/xfree86/os-support/bsd/bsd_init.c: In function ‘xf86OpenWScons’:
../hw/xfree86/os-support/bsd/bsd_init.c:563:1: warning: old-style function definition [-Wold-style-definition]
  563 | xf86OpenWScons()
      | ^~~~~~~~~~~~~~
../hw/xfree86/os-support/bsd/bsd_init.c: In function ‘xf86CloseConsole’:
../hw/xfree86/os-support/bsd/bsd_init.c:594:1: warning: old-style function definition [-Wold-style-definition]
  594 | xf86CloseConsole()
      | ^~~~~~~~~~~~~~~~
../hw/xfree86/os-support/bsd/bsd_init.c: In function ‘xf86UseMsg’:
../hw/xfree86/os-support/bsd/bsd_init.c:671:1: warning: old-style function definition [-Wold-style-definition]
  671 | xf86UseMsg()
      | ^~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1445>
2024-04-10 03:24:08 +00:00
Erik Kurzinger e1f16fb1ac xwayland: don't scrap pending present requests
When a present request is received, Xwayland will check if there is an
existing request targeting the same window and msc and scrap the older
request if so. Alas, this does not interact well the older fence-based
or newer syncobj-based synchronization features of the Present
extension.

Since execution of a request may be delayed for an unknown length of
time while waiting for a fence to be signaled, the target msc computed
upon receiving a request may not match the actual msc at which the
request is executed. Therefore, we cannot determine in advance whether a
more recently received request will make an older request redundant.

This change removes the code to scrap pending present requests.

We must also ensure requests are executed in the correct order even if
their fences are signaled out of order. To achieve this, whenever
execution of a request needs to wait for a fence, execution of any
later-received requests will be blocked until the earlier request is
ready. The blocked requests will be added to a list tracked in the
xwl_present_window struct. Once the earlier request's fence is signaled,
any blocked requests will be re-executed.

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
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
Erik Kurzinger 6f85ce4d4e xwayland: support DRI3 1.4 and Present 1.4
Together, DRI3 1.4 and Present 1.4 allow clients to explicitly
synchronize GPU rendering with presentation using DRM syncobjs. Here we
add the necessary support to Xwayland's glamor and Present
infrastructure to enable this functionality.

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
Erik Kurzinger ac0bc0b3b6 Present: add PresentCapabilitySyncobj and PresentPixmapSynced
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
Erik Kurzinger 0a7b09a041 xwayland: re-compute target msc during xwl_present_re_execute
If a presentation request is delayed while waiting for a fence, the
original target msc may no longer be correct. Instead, we should compute
a new target msc in xwl_present_re_execute.

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
Erik Kurzinger 3df236a3d5 xwayland: add functions to import and export dma-buf implicit fences
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
Xaver Hugl d411a8b611 xwayland: add workaround for drivers that don't support impicit sync
Without either implicit or explicit synchronization, the result of rendering is
pretty much undefined, and many glitches can appear. This still doesn't synchronize
buffer release, but it works around most glitches until explicit sync is supported.

Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/967>
2024-04-09 06:11:03 +00:00
Erik Kurzinger 89c327f263 xwayland: add detection for drivers that don't support implicit sync
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
Alan Coopersmith 6c684d035c Xquartz: ProcAppleDRICreatePixmap needs to use unswapped length to send reply
CVE-2024-31082

Fixes: 14205ade0 ("XQuartz: appledri: Fix byte swapping in replies")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1463>
2024-04-02 19:19:40 -07:00
Enrico Weigelt, metux IT consult 0663bb119a xfree86: modesetting: fix warning on unused variable
Fix warning:

../hw/xfree86/drivers/modesetting/driver.c:1612:19: warning: unused variable ‘pEnt’ [-Wunused-variable]
 1612 |     EntityInfoPtr pEnt = ms->pEnt;
      |                   ^~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1443>
2024-04-01 23:36:14 +00:00
Alan Coopersmith bb2e2eba42 xorg.conf.man: Add missing new paragraph mark before AllowByteSwappedClients
Was previously being shown as part of previous entry.

Fixes: 412777664 ("Disallow byte-swapped clients by default")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1439>
2024-03-23 14:30:43 -07:00
Enrico Weigelt, metux IT consult f361931035 xfree86: int10: fix missing include of <errno.h>
It's much cleaner to always include directly what one needs,
instead of relying on very indirect including.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1435>
2024-03-21 17:32:30 +01:00
Enrico Weigelt, metux IT consult cd84b3eaf3 xfree86: modesettig: fix missing include of <errno.h>
It's much cleaner to always include directly what one needs,
instead of relying on very indirect including.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1435>
2024-03-21 17:32:30 +01:00
Enrico Weigelt, metux IT consult 9fc6e0d304 xfree86: os-support: fix missing include of <errno.h>
It's much cleaner to always include directly what one needs,
instead of relying on very indirect including.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1435>
2024-03-21 17:32:30 +01:00
Enrico Weigelt, metux IT consult d91098ef48 xfree86: common: fix missing include of <errno.h>
It's much cleaner to always include directly what one needs,
instead of relying on very indirect including.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1435>
2024-03-21 17:32:30 +01:00
Enrico Weigelt, metux IT consult b2fd743288 xwayland: fix missing include of <errno.h>
It's much cleaner to always include directly what one needs,
instead of relying on very indirect including.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1435>
2024-03-21 17:32:30 +01:00
Enrico Weigelt, metux IT consult 94e5252365 xquartz: fix missing include of <errno.h>
It's much cleaner to always include directly what one needs,
instead of relying on very indirect including.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1435>
2024-03-21 17:32:30 +01: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 3e77c1699a xwayland: Add helper function for fractional scaling
Fractional scaling may not be available, or not suitable for the current
configuration (e.g. if running rootless).

Add a helper function to tell whether fractional scaling should be used.

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 7a78756d0a xwayland: Add support for fractional scale protocol
Add support for wp_fractional_scale_v1 protocol.

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 d7f31fe887 xwayland: Apply the viewport's scale_x/y to all input
The viewport's scale_x/y is currently applied to the motion event only.

Apply the same viewport_scale_x/y to all relevant input coordinates.

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 b678297c53 xwayland: Add scale factor to the Xwayland screen
For now, the global surface scale is always 1, 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 2bdf594cea xwayland: Track output scales
Keep track of the output scales as advertised by the wl_output protocol.

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 5b05a29912 xwayland: Use CRTC transforms
Advertise the scaling factor applied to the Xwayland output using the
mechanism of CRTC transforms.

That allows for X11 clients to query the scale factor using XRandR.

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 6a09cd2d20 xwayland: Introduce output scale
Add a scale factor to the Xwayland output and take the scale into
account when computing the screen size.

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 8c54f90673 xwayland: Store the mode width/height
The mode size can be different from the actual output size when a
transformation is at play.

Store the actual mode width/height as well in preparation for adding
support for transforms.

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 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
Alan Coopersmith e1c5be126b bsd_init.c: fix build on FreeBSD
Commit 0d4a7ed6 put the definition of pcvt_version inside #ifdef __NetBSD__
but left one use of it outside of the ifdefs, resulting in a build failure
on FreeBSD 14.0 in the gitlab CI for xf86-input-keyboard.

../hw/xfree86/os-support/bsd/bsd_init.c:540:21:
  error: use of undeclared identifier 'pcvt_version'
                    pcvt_version.rmajor, pcvt_version.rminor);
                    ^
../hw/xfree86/os-support/bsd/bsd_init.c:540:42:
  error: use of undeclared identifier 'pcvt_version'
                    pcvt_version.rmajor, pcvt_version.rminor);
                                         ^

Fixes: 0d4a7ed68 ("bsd_init.c: fix build on OpenBSD")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1424>
2024-03-20 03:32:23 +00:00
Enrico Weigelt, metux IT consult 2003adfd33 xwin: consolidate debugging symbols
We've got three #define's that are all set at once, on enable_debugging.

A comment in meson.build already asks for consolidating them into one,
so just do it now.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1409>
2024-03-19 02:05:35 +00:00
Enrico Weigelt, metux IT consult d8758cdd20 xfree86: os-support: ppc_video: drop unused DEV_MEM define
This #define is local within a .c file, but became unused about a
decade ago (commit 8686463de7).

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1410>
2024-03-19 01:59:38 +00:00
Enrico Weigelt, metux IT consult 0cb8a76a9f xfree86: os-support: drop obsolete Solaris specific LED defines
Historical legacy: the LED ID defines have/had different naming across various
platforms - for better portability of the keyboard driver, those have been
aliased to BSD's naming scheme. Meanwhile, lots of ancient platforms have
been died or moved to other drivers (eg. Linux went to either evdev or libinput
and not supported by the xf86-input-keyboard driver anymore).

The only remaining possible consumer is Solaris. But it has it's own dedicated
code (sun_kbd.c in xf86-input-keyboard), which already using the Solaris' naming.

Therefore, there's no actual consumer of them left, so we can drop them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1418>
2024-03-19 00:54:38 +00:00
Peter Hutterer 924939c886 Revert "Fix missing includes of <errno.h>"
Removing errno from xf86_OSlib.h breaks the xf86-input-mouse driver
build. And xf86_OSlib.h itself relies on errno anyway in the SYSCALL
macro provided by this header.

This reverts commit f6a367102c.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1423>
2024-03-19 00:33:26 +00: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 122ad8a0de xwayland: Introduce xwl_screen_lost_focus()
xwl_screen_lost_focus() calls the keyboard and pointer leave functions
for each seat.

No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
2024-03-18 23:34:29 +00:00
Olivier Fourdan 654c354da9 xwayland: Move the leave kbd/ptr code
Move part of the code that deals with pointer or keyboard leave
notifications to their own function.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
2024-03-18 23:34:29 +00:00
Olivier Fourdan 9a7fb3a153 xwayland: Use "-decorate" if available
That allows to open new Xwayland decorated windows as needed (e.g. using
the "New window" entry from the launcher)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1421>
2024-03-18 23:19:59 +00:00
Olivier Fourdan fbf5e26b5c xwayland: Use full path for Xwayland exec
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1421>
2024-03-18 23:19:59 +00:00
Olivier Fourdan 66b371f306 xwayland: Add the Exec key to the desktop file
This was intentionally left out, but it's against the spec.

Add an Exec key to be conformant.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1654
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1421>
2024-03-18 23:19:59 +00:00
Enrico Weigelt, metux IT consult ccfa7e9f2e Fix missing include of <sys/wait.h>
Instead of relying on indirect includes, it's much cleaner if everybody
includes directly what he needs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1419>
2024-03-18 23:02:45 +00:00
Enrico Weigelt, metux IT consult f6a367102c Fix missing includes of <errno.h>
It's much cleaner to always include directly what one needs,
instead of relying on very indirect including.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1416>
2024-03-18 22:58:32 +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 656d2efd4b xwayland/glamor: Drop xwl_glamor_needs_n_buffering()
This function always return TRUE now that EGLSTream is gone, so 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 d422b40926 xwayland/glamor: Drop xwl_glamor_needs_buffer_flush()
GLAMOR needs that, and the function returns TRUE unless GLAMOR is not
used.

Drop the function xwl_glamor_needs_buffer_flush() and call
glamor_block_handler() when glamor is used.

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 6466c1ee81 xwayland/glamor: Drop xwl_screen_get_main_dev()
This is made redundant with xwl_gbm_get_main_device(), and this is not
really an xwl_screen function either.

Let's 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 ef29e05200 xwayland/glamor: Drop the backend_flags definition
Nobody uses that anymore.

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 888e3e7a94 xwayland/glamor: Remove the xwl_egl_backend structure
No more backend structure, one GBM backend to rule them all!

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 8c0267b60f xwayland/glamor: Drop init_backend() and select_backend()
Now that we have only one backend, there is no need to initialize or
select between different backends.

Drop the corresponding functions.

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 bceaca28d3 xwayland/glamor: Remove the backend pointers
We have only one backend now.

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 863ee2da4d xwayland/glamor: Make xwl_glamor_has_wl_interfaces() private
It's not used outside of Xwayland GLAMOR code itself, no need to keep it
public.

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 4eb8684f52 xwayland/glamor: Drop the allow_commit() hook
That was used only by 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 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 5fd0c92b0e xwayland/glamor: Remove the flag "is_available"
Now that we have only one GBM backend, either it is available and
usable, or we cannot use GLAMOR.

Therefore we can drop the flag "is_available".

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 5df6a1e969 xwayland/glamor: Make xwl_glamor_init_gbm() return its status
This is a preliminary step to remove the backend's field "is_available".

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan 63e2f98f0a xwayland/glamor: Drop the backend_flags
We do not need these anymore, since we only have the GBM backend left.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan 925a218b4b xwayland/glamor: Drop the create_pixmap_for_window() hook
And rename the function xwl_glamor_gbm_create_pixmap_for_window() as
xwl_glamor_create_pixmap_for_window().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan 439c0ee5e4 xwayland/glamor: Drop the get_main_device() hook
Call xwl_gbm_get_main_device() directly from xwl_screen_get_main_dev().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan e8d974a8d3 xwayland/glamor: Drop the check_flip() hook
The GBM backend never had a use for 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:17 +00:00
Olivier Fourdan 76ae669327 xwayland/glamor: Drop the get_wl_buffer_for_pixmap() hook
And rename the GLAMOR GBM xwl_glamor_gbm_get_wl_buffer_for_pixmap()
function as xwl_glamor_pixmap_get_wl_buffer().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan e60e00ff40 xwayland/glamor: Drop the init_screen() hook
And call xwl_glamor_gbm_init_screen() directly instead.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan e1bec429bb xwayland/glamor: Drop the init_egl() hook.
And call xwl_glamor_gbm_init_egl() directly instead.

Yet, keep the function separate rather than merging it back into
xwl_glamor_init() for clarity of the code.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan ca73cd8a9d xwayland/glamor: Drop xwl_glamor_gbm_has_wl_interfaces()
And merge it back into xwl_glamor_has_wl_interfaces()

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan 2ccabf5aa8 xwayland/glamor: Drop xwl_glamor_gbm_init_wl_registry()
And merge it back into xwl_glamor_init_wl_registry().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan 673ed3cd6d xwayland/glamor: Add a GLAMOR GBM header
That will be used between the generic Xwayland GLAMOR functions and the
GBM implementation.

Move the definition of xwl_glamor_init_gbm() to that new header rather
than in the generic Xwayland GLAMOR header.

This is preparation work to eventually replace the xwl_egl_backend now
that we have only one backend left.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Olivier Fourdan 701284f057 xwayland/glamor: Drop the EGLStream backend
Now that the NVIDIA proprietary driver has grown support for GBM, the
EGLStream backend for NVIDIA GPUs is now superseded by the standard
GBM backend in Xwayland.

This code path is therefore not used and hardly ever tested.

Remove support for EGLStream in Xwayland.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1386>
2024-03-18 15:41:17 +00:00
Simon Ser 005912d82f xwayland/glamor/gbm: simplify render node check
No need to call is_device_path_render_node() on each node, the
index is the node type. Saves a couple of open()/close()/IOCTLs.

Signed-off-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1237>
2024-03-15 10:53:01 +00:00
Enrico Weigelt, metux IT consult 5b43fd8393 xfree86: os-support: drop unused xf86SerialSendBreak()
Since no evidency of anybody actually using it (nor it ever been used within
recorded git history), it's time to drop this old relic from times before
the great flood.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1403>
2024-03-15 04:33:43 +00:00
Enrico Weigelt, metux IT consult 9bc7d96a45 xfree86: os-support: drop unused NO_OSLIB_PROTOTYPES guard
The last user was removed a decade ago by commit
a6fcb15472.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1407>
2024-03-15 04:29:17 +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
Erik Kurzinger a0717e5f03 xwayland: correctly report PresentCompleteModeCopy
After executing a PresentPixmap request using the copy path, Xwayland
will clear the vblank's pixmap field and re-queue it for the next msc so
that on the next frame a PresentCompleteNotify event will be delivered
to the client by present_execute_post.

While this does work, since the pixmap field of the vblank will be NULL
when present_execute_post is called, the mode reported in the event will
always be PresentCompleteModeSkip, even if the request *was* actually
executed with a copy.

To fix this, we introduce a new "copy_executed" flag in the
xwl_present_event struct. If xwl_present_execute sees that this flag is
set, it will fall straight through to present_execute_post like it does
if the window or pixmap is NULL. So, after executing a request with
present_execute_copy, instead of clearing the pixmap field we will set
the copy_executed flag to true. This will cause present_execute_post to
report the correct completion mode to the client when the
PresentCompleteNotify event is delivered on the next frame.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1254>
2024-03-14 10:37:28 +00:00
Enrico Weigelt, metux IT consult 6557286084 xfree86: use own dev-privates key for per-screen cursor
Since it's storing an locally defined (ddx-internal) data, it's better
not to abuse some globally defined key for this.

It just happened to work before, since CursorScreenKey is only used by DDX
(and there's only one DDX per executable) and they currently (!) have the
same size (pointer) - but that's a fragile programming style, so clean it up.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1342>
2024-03-12 15:24:35 +00:00
Enrico Weigelt, metux IT consult 49d139344d xnest: use own dev-privates key for per-screen cursor
Since it's storing an locally defined (ddx-internal) struct, it's better
not to abuse some globally defined key for this.

It just happened to work before, since CursorScreenKey is only used by DDX
(and there's only one DDX per executable) and they currently (!) have the
same size (pointer) - but that's a fragile programming style, so clean it up.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1342>
2024-03-12 15:24:35 +00:00
Enrico Weigelt, metux IT consult 7e22c033d0 xnest: fix naming of xnestCursorScreenKeyRec
It's naming is a bit unprecise: it actually is used for storing
xnestCursorFuncPtr inside a Screen. Thus rename it to
xnestScreenCursorFuncKeyRec to make it bit more clear.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1342>
2024-03-12 15:24:35 +00:00
Enrico Weigelt, metux IT consult 22306f16b6 xnest: drop superfluous xnestCursorScreenKey define
We can just write &xnestCursorScreenKeyRec instead, which makes the code
a bit more clear.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1342>
2024-03-12 15:24:35 +00:00
Enrico Weigelt, metux IT consult 738edd3501 dix: unexport eventconvert.h functions
This header isn't installed, so no external modules could use the
functions declared there. Thus we can unexport it all.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1358>
2024-03-11 12:26:44 +01:00
Enrico Weigelt, metux IT consult b598727f1c dix: unexport InitTrackers()
Not used by any modules, thus no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1347>
2024-03-09 18:01:52 +00:00
Enrico Weigelt, metux IT consult 040e41c7e9 dix: unexport global variables
Those aren't used by drivers, so no need to export them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1375>
2024-03-09 17:23:43 +00:00
Enrico Weigelt, metux IT consult 15d3c1a6f1 os: move os_move_fd() out of public API
This function isn't used by any driver and doesn't seem to be useful for them,
thus move it out of the public module API, in order to tidy it up a bit.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1366>
2024-03-09 17:12:46 +00: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 0e29cccf36 xwayland: Re-use xwl_window_realloc_pixmap in xwl_window_swap_pixmap
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 17:09:22 +01:00
Michel Dänzer 44527c2549 xwayland: Refactor xwl_window_swap_pixmap out of _buffers_get_pixmap
There will be another caller in a later commit.

v2:
* Bump xwl_window_buffer->refcnt in xwl_window_swap_pixmap, to prevent
  xwl_window_set_pixmap from disposing of it.
v3:
* Go back to bumping xwl_window_buffer->refcnt in
  xwl_window_buffers_get_pixmap. xwl_window_set_pixmap should no longer
  dispose of it now that xwl_glamor_gbm_create_pixmap_for_window is
  fixed, and xwl_window_swap_pixmap forgot to bump it if
  xwl_window_buffer_get_available returned NULL.
v4:
* Unlink xwl_window_buffer from xwl_window->window_buffers_available
  before calling xwl_window_set_pixmap in xwl_window_swap_pixmap, or
  that might dispose of it.
v5:
* xwl_window_swap_pixmap does everything xwl_window_buffer_get_available
  did before, except for just using the window pixmap if
  !xwl_glamor_needs_n_buffering.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 16:58:17 +01:00
Michel Dänzer af4b64d227 xwayland: Rename xwl_window_recycle_pixmap to xwl_window_realloc_pixmap
It doesn't recycle anything but allocates a new pixmap from scratch.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 16:55:13 +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 913631071e xwayland: Use border width in xwl_glamor_gbm_create_pixmap_for_window
Otherwise the pixmap is too small for a window with non-0 border width.

Fixes: 9730fb64ea ("xwayland: Add create_pixmap_for_window() to GBM backend")
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1314>
2024-03-06 16:55:13 +01:00
Enrico Weigelt, metux IT consult 71b81a7473 dix: unexport AttachUnboundGPU() and DetachUnboundGPU()
These aren't externally used, thus no need to export them.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1349>
2024-03-03 23:24:28 +00:00
Enrico Weigelt, metux IT consult 27b83c4cd0 dix: unexport AddScreen() and AddGPUScreen()
These aren't used by any drivers/modules, just DDX'es, so no need to export.

Note: tigervnc does use it, but it has it's own DDX, therefore directly
linked in, just like the in-tree DDX'es which doesn't need exporting.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1349>
2024-03-03 23:24:28 +00:00
Enrico Weigelt, metux IT consult 17ad53c803 include: unexport registry.h
This file isn't included by any known modules, so no need to keep it
around in the public api.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1348>
2024-03-03 23:20:06 +00:00
Enrico Weigelt, metux IT consult c3255fbc1c os: drop unneeded DDXOSVERRORF conditional
This conditional practically only controls whether we have an pointer,
where DDX can plug in it's own VErrorF() handler (currently only xwin
doing that). The cost of having it even when DDX doesn't use it, is
really negligible: it's just one pointer and an extra non-null check
on it per VErrorF() call - a very cold path. Strangely, xwin has extra

Getting rid of this unnecessary complexity that really hasn't any
practical gain.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1329>
2024-03-03 23:15:14 +00:00
Enrico Weigelt, metux IT consult ebabca56a4 consolidate MITSHM and HAS_SHM symbols
Both symbols are set on exactly the same condition (build_mitshm),
so can be consolidated into one: MITSHM

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1296>
2024-03-03 23:07:18 +00:00
Enrico Weigelt, metux IT consult 02b5696e2b xwin: winsock.h needs to be included earlier
[374/383] Compiling C object hw/xwin/Xming.exe.p/winmultiwindowicons.c.obj
791In file included from /usr/i686-w64-mingw32/include/X11/Xwinsock.h:57,
792                 from /usr/i686-w64-mingw32/include/xcb/xcb_windefs.h:34,
793                 from /usr/i686-w64-mingw32/include/xcb/xcb.h:41,
794                 from ../hw/xwin/winmultiwindowicons.c:43:
795/usr/share/mingw-w64/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
796   15 | #warning Please include winsock2.h before windows.h
797      |  ^~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
2024-03-03 23:02:54 +00:00
Enrico Weigelt, metux IT consult 7bd19a9580 xwin: replace ZeroMemory()
replace Windows specific ZeroMemory (macro just calling memset())
by static initialization, calloc() and memset().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
2024-03-03 23:02:54 +00:00
Enrico Weigelt, metux IT consult c444223da3 xwin: fix missing prototype for winValidateArgs()
[378/383] Compiling C object hw/xwin/Xming.exe.p/winvalargs.c.obj
811../hw/xwin/winvalargs.c:57:1: warning: no previous prototype for ‘winValidateArgs’ [-Wmissing-prototypes]
812   57 | winValidateArgs(void)
813      | ^~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
2024-03-03 23:02:54 +00:00
Enrico Weigelt, metux IT consult 123a473e33 xwin: fix possibly missing string termination
../hw/xwin/InitOutput.c: In function ‘winFixupPaths’:
747../hw/xwin/InitOutput.c:578:9: warning: ‘strncpy’ output truncated before terminating nul copying 5 bytes from a string of the same length [-Wstringop-truncation]
748  578 |         strncpy(buffer, "HOME=", 5);
749      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
2024-03-03 23:02:54 +00:00
Enrico Weigelt, metux IT consult f855e35df2 xwin: winclipboard: fix missing prototypes / missing include
[324/383] Compiling C object hw/xwin/winclipboard/xwinclip.exe.p/debug.c.obj
666../hw/xwin/winclipboard/debug.c:31:1: warning: no previous prototype for ‘winDebug’ [-Wmissing-prototypes]
667   31 | winDebug(const char *format, ...)
668      | ^~~~~~~~
669../hw/xwin/winclipboard/debug.c: In function ‘winDebug’:
670../hw/xwin/winclipboard/debug.c:37:3: warning: function ‘winDebug’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
671   37 |   count += vfprintf(stderr, format, ap);
672      |   ^~~~~
673../hw/xwin/winclipboard/debug.c: At top level:
674../hw/xwin/winclipboard/debug.c:44:1: warning: no previous prototype for ‘ErrorF’ [-Wmissing-prototypes]
675   44 | ErrorF(const char *format, ...)
676      | ^~~~~~
677../hw/xwin/winclipboard/debug.c: In function ‘ErrorF’:
678../hw/xwin/winclipboard/debug.c:49:3: warning: function ‘ErrorF’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
679   49 |   count = vfprintf(stderr, format, ap);
680      |   ^~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
2024-03-03 23:02:54 +00:00
Enrico Weigelt, metux IT consult b93c614176 xwin: fix unused variables
../hw/xwin/winmultiwindowwndproc.c:418:17: warning: unused variable ‘ps’ [-Wunused-variable]
744  418 |     PAINTSTRUCT ps;
745      |                 ^~

../hw/xwin/InitOutput.c:114:13: warning: ‘noDriExtension’ defined but not used [-Wunused-variable]
752  114 | static Bool noDriExtension;
753      |             ^~~~~~~~~~~~~~

375/383] Compiling C object hw/xwin/Xming.exe.p/winprefs.c.obj
799../hw/xwin/winprefs.c: In function ‘LoadImageComma’:
800../hw/xwin/winprefs.c:545:14: warning: unused variable ‘convert’ [-Wunused-variable]
801  545 |         Bool convert = FALSE;
802      |              ^~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1295>
2024-03-03 23:02:54 +00:00
Enrico Weigelt, metux IT consult 10a8031865 render: drop obsolete macros pict_f_transform and pict_f_vector
Over 1.5 decades ago, pixmap handling was moved to using pixman library,
but there's still a bit fallout from that left. Cleaning it up now.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1287>
2024-03-03 22:54:16 +00:00
Enrico Weigelt, metux IT consult 06685cabde composite: move out unexported CompositeIsImplicitRedirectException()
Move out non-exported stuff from public module header compositeext.h,
into compositeext_priv.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1284>
2024-03-03 22:50:07 +00:00
Enrico Weigelt, metux IT consult 5b2c00d38a include: drop closestr.h from public module API
None of the public module API functions use the types defined in here,
this file isn't even included anywhere (in the public headers). Thus it
doesn't seem to be needed in the public API at all - so make it private.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1281>
2024-03-03 22:46:34 +00:00
Enrico Weigelt, metux IT consult ff6b196d1d xfree86: parser: drop HAS_NO_UIDS
It's only locally defined when WIN32 is defined, so we can use this directly.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1278>
2024-03-03 22:38:52 +00:00
Enrico Weigelt, metux IT consult e439c9c8d7 xwayland: drop duplicate _X_EXPORT
These are already defined in glamor.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1274>
2024-03-03 22:34:26 +00:00
Enrico Weigelt, metux IT consult ee011ea82b xfree86: common: move non-exported funcs from dgaproc.h to separate header
The typdef and defines from dgaproc.h are used by drivers, so it needs to
remain part of the public API. But no need to clutter the public header
with non-exported function declarations.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1323>
2024-02-29 10:27:08 +00:00
Enrico Weigelt, metux IT consult 4705fa933a xfree86: drop unneeded wrapper xf86PrivsElevated()
It's just a dumb wrapper around PrivsElevated(), and also just called in few
places, while others call PrivsElevated() directly - thus not needed and
can be dropped.

Note that it's also not called by drivers, so the export was unnecessary.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1324>
2024-02-29 10:04:34 +00:00
Enrico Weigelt, metux IT consult eed0697ec9 os: consolidate busfault handling
The symbols HAVE_SIGACTION and BUSFAULT are set under the same conditions,
so can be consolidated into one. Also define dummies when HAVE_SIGACTION
is not set, so a few #ifdef's less clutterig the code.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1297>
2024-02-23 23:15:12 +00:00
Peter Hutterer eaa92ea422 Revert "include: move BUG_*() macros to separate header"
This breaks the xf86-input-synaptics driver:

  synaptics.c: In function 'clickpad_guess_clickfingers':
  synaptics.c:2638:5: error: implicit declaration of function 'BUG_RETURN_VAL' [-Werror=implicit-function-declaration]
   2638 |     BUG_RETURN_VAL(hw->num_mt_mask > sizeof(close_point) * 8, 0);

This reverts commit 442aec2219.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1316>
2024-02-23 23:11:01 +00:00
Enrico Weigelt, metux IT consult 7a37e5df12 xwayland: fix int size mismatch
GCC reports:

[1/2] Compiling C object hw/xwayland/Xwayland.p/xwayland.c.o
../hw/xwayland/xwayland.c: In function ‘try_raising_nofile_limit’:
../hw/xwayland/xwayland.c:161:72: warning: format ‘%li’ expects argument of type ‘long int’, but argument 4 has type ‘rlim_t’ {aka ‘long long unsigned int’} [-Wformat=]
  161 |     LogMessageVerb(X_INFO, 3, "Raising the file descriptors limit to %li\n",
      |                                                                      ~~^
      |                                                                        |
      |                                                                        long int
      |                                                                      %lli
  162 |                    rlim.rlim_max);
      |                    ~~~~~~~~~~~~~
      |                        |
      |                        rlim_t {aka long long unsigned int}

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1257>
2024-02-22 23:56:37 +00:00
Enrico Weigelt, metux IT consult 37b9b9a854 modesetting: fix int size mismatch
GCC repors:

../hw/xfree86/drivers/modesetting/drmmode_display.c:4135:49: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
 4135 |                            "Gamma ramp set to %ld entries on CRTC %d\n",
      |                                               ~~^
      |                                                 |
      |                                                 long int
      |                                               %lld
 4136 |                            size, num);
      |                            ~~~~
      |                            |
      |                            uint64_t {aka long long unsigned int}
../hw/xfree86/drivers/modesetting/drmmode_display.c:4139:57: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
 4139 |                        "Failed to allocate memory for %ld gamma ramp entries "
      |                                                       ~~^
      |                                                         |
      |                                                         long int
      |                                                       %lld
 4140 |                        "on CRTC %d.\n",
 4141 |                        size, num);
      |                        ~~~~
      |                        |
      |                        uint64_t {aka long long unsigned int}

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1257>
2024-02-22 23:56:37 +00:00
Enrico Weigelt, metux IT consult eda769f34c randr: move private definitons from randrstr.h to randrstr_priv.h
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1291>
2024-02-22 23:47:49 +00:00
Enrico Weigelt, metux IT consult 5620102dfe os: move mitauth prototypes to separate header
The MIT authentication handling isn't really OS specific, and only few sites
actually need to call it, so at least it's prototypes are better off in some
separate header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1311>
2024-02-22 23:42:52 +00:00
Enrico Weigelt, metux IT consult 27b5530107 xfree86: drop remains of old USL compiler
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1286>
2024-02-19 09:21:36 +00:00
Enrico Weigelt, metux IT consult 6dafe3dbe6 drop remains of support for old Sun compilers
With transition from autoconf to meson, these aren't actually supported
anymore, and re-adding it isn't planned. Thus the now dead code pathes
can be completely removed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1286>
2024-02-19 09:21:36 +00:00
Yusuf Khan db3aa4e03b hw/xfree86: fix NULL pointer refrence to mode name
Potentially, the pointer to the mode name could be unset, this can
occur with the xf86-video-nv DDX, in that case there isnt much we can do
except check if the next mode is any better.

Signed-off-by: Yusuf Khan <yusisamerican@gmail.com>
2024-02-19 03:51:25 +00:00
Enrico Weigelt, metux IT consult a2e7904b1d fix: unused readIntVec()
[585/699] Compiling C object hw/xfree86/int10/libint10.so.p/generic.c.o
../hw/xfree86/int10/generic.c:103:1: warning: ‘readIntVec’ defined but not used [-Wunused-function]
  103 | readIntVec(struct pci_device *dev, unsigned char *buf, int len)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 01:02:32 +00:00
Enrico Weigelt, metux IT consult 8d2117abeb hw: xwayland: fix build if neither gbm nor eglstream available
glamor needs to be disabled if neither gbm nor eglstream is available,
otherwise build breaks.

Closes: xorg/xserver#1631
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 00:53:30 +00:00
Enrico Weigelt, metux IT consult 374ee7acd7 xkb: drop defining XKBSRV_NEED_FILE_FUNCS
No need to define XKBSRV_NEED_FILE_FUNCS, for about 15 years now
(since XKBsrv.h isn't used anymore), so drop it.

Fixes: e5f002edde
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-19 00:44:15 +00:00
Matthieu Herrb 0d4a7ed684 bsd_init.c: fix build on OpenBSD
isolate NetBSD specific VGAPCVTID ioctl(2) call.

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2024-02-19 00:40:04 +00:00
Matthieu Herrb 238f8edcaf xfree86/bsd: fix build on NetBSD/amd64.
The IOPL function for 64 bit systems is x86_64_iopl() there
2024-02-18 00:03:45 +00:00
Matthieu Herrb 59dac6af45 Add full prototypes in hw/xfree86/os-support/bsd/bsd-video.c
Trivial functions without parameters -> (void)
2024-02-17 23:50:59 +00:00
Enrico Weigelt 442aec2219 include: move BUG_*() macros to separate header
Yet another step of uncluttering includes: move out the BUG_* macros
into a separate header, which then is included as-needed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-15 23:33:46 +00:00
Alan Coopersmith a8bb924af1 os: Assume all supported non-WIN32 platforms have seteuid & saved_ids
Removes fallback code to fork and exec a "cat" command to read files.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-10 00:05:54 +00:00
Florian Weimer f0a187f55d xwayland: Use correct pointer types on i386
And other 32-bit architectures, where uint32_t and CARD32 are
not the same type.  Otherwise the build will fail with GCC 14
with errors like:

../hw/xwayland/xwayland-glamor.c: In function ‘xwl_glamor_get_formats’:
../hw/xwayland/xwayland-glamor.c:291:43: error: passing argument 3 of ‘xwl_get_formats_for_device’ from incompatible pointer type [-Wincompatible-pointer-types]
  291 |                                           num_formats, formats);
      |                                           ^~~~~~~~~~~
      |                                           |
      |                                           CARD32 * {aka long unsigned int *}
../hw/xwayland/xwayland-glamor.c:238:38: note: expected ‘uint32_t *’ {aka ‘unsigned int *’} but argument is of type ‘CARD32 *’ {aka ‘long unsigned int *’}
  238 |                            uint32_t *num_formats, uint32_t **formats)
      |                            ~~~~~~~~~~^~~~~~~~~~~
../hw/xwayland/xwayland-glamor.c:291:56: error: passing argument 4 of ‘xwl_get_formats_for_device’ from incompatible pointer type [-Wincompatible-pointer-types]
  291 |                                           num_formats, formats);
      |                                                        ^~~~~~~
      |                                                        |
      |                                                        CARD32 ** {aka long unsigned int **}
../hw/xwayland/xwayland-glamor.c:238:62: note: expected ‘uint32_t **’ {aka ‘unsigned int **’} but argument is of type ‘CARD32 **’ {aka ‘long unsigned int **’}
  238 |                            uint32_t *num_formats, uint32_t **formats)
      |                                                   ~~~~~~~~~~~^~~~~~~
../hw/xwayland/xwayland-glamor.c:295:28: error: passing argument 3 of ‘xwl_get_formats’ from incompatible pointer type [-Wincompatible-pointer-types]
  295 |                            num_formats, formats);
      |                            ^~~~~~~~~~~
      |                            |
      |                            CARD32 * {aka long unsigned int *}
../hw/xwayland/xwayland-glamor.c:217:26: note: expected ‘uint32_t *’ {aka ‘unsigned int *’} but argument is of type ‘CARD32 *’ {aka ‘long unsigned int *’}
  217 |                uint32_t *num_formats, uint32_t **formats)
      |                ~~~~~~~~~~^~~~~~~~~~~
../hw/xwayland/xwayland-glamor.c:295:41: error: passing argument 4 of ‘xwl_get_formats’ from incompatible pointer type [-Wincompatible-pointer-types]
  295 |                            num_formats, formats);
      |                                         ^~~~~~~
      |                                         |
      |                                         CARD32 ** {aka long unsigned int **}
../hw/xwayland/xwayland-glamor.c:217:50: note: expected ‘uint32_t **’ {aka ‘unsigned int **’} but argument is of type ‘CARD32 **’ {aka ‘long unsigned int **’}
  217 |                uint32_t *num_formats, uint32_t **formats)
      |                                       ~~~~~~~~~~~^~~~~~~
2024-02-02 09:36:52 +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
Michel Dänzer 613e4466b4 xwayland: Handle NULL xwl_pixmap in xwl_shm_pixmap_get_wl_buffer 2024-01-22 14:14:05 +00:00
Michel Dänzer f50ed265cf xwayland: Initialize Present extension support also with rootful
Multiple benefits, in particular:

* Fullscreen windows can hit the page flip path
* X client presentation is properly synchronized to the Wayland
  compositor refresh cycle via frame events
2024-01-22 14:14:05 +00:00
Michel Dänzer e391d53076 xwayland/present: Update screen pixmap in xwl_present_execute
If the screen pixmap was also the toplevel window pixmap.

This can't happen yet, it will with the next commit though.
2024-01-22 14:14:05 +00:00
Olivier Fourdan 0cbf6d9326 xwayland: Add a -nokeymap option
By default, Xwayland (as any Wayland client) uses the keymap set by the
Wayland compositor using the standard Wayland protocol.

There are some specific uses cases where a user would want to let the
X11 clients control the keymap. However, the Wayland compositor may
(re)send the keymap at any time, overriding whatever change was made
using the X11 mechanisms.

Add a new "-nokeymap" option to Xwayland to instruct Xwayland to simply
ignore the standard Wayland mechanism to set the keymap, hence leaving
the control entirely to the X11 clients.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2024-01-22 13:01:18 +00:00
José Expósito e89edec497 ephyr: Fix incompatible pointer type build error
Fix a compilation error on 32 bits architectures with gcc 14:

  ephyr_glamor_xv.c: In function ‘ephyr_glamor_xv_init’:
  ephyr_glamor_xv.c:154:31: error: assignment to ‘SetPortAttributeFuncPtr’ {aka ‘int (*)(struct _KdScreenInfo *, long unsigned int,  int,  void *)’} from incompatible pointer type ‘int (*)(KdScreenInfo *, Atom,  INT32,  void *)’ {aka ‘int (*)(struct _KdScreenInfo *, long unsigned int,  long int,  void *)’} [-Wincompatible-pointer-types]
    154 |     adaptor->SetPortAttribute = ephyr_glamor_xv_set_port_attribute;
        |                               ^
  ephyr_glamor_xv.c:155:31: error: assignment to ‘GetPortAttributeFuncPtr’ {aka ‘int (*)(struct _KdScreenInfo *, long unsigned int,  int *, void *)’} from incompatible pointer type ‘int (*)(KdScreenInfo *, Atom,  INT32 *, void *)’ {aka ‘int (*)(struct _KdScreenInfo *, long unsigned int,  long int *, void *)’} [-Wincompatible-pointer-types]
    155 |     adaptor->GetPortAttribute = ephyr_glamor_xv_get_port_attribute;
        |                               ^

Build error logs:
https://koji.fedoraproject.org/koji/taskinfo?taskID=111964273

Signed-off-by: José Expósito <jexposit@redhat.com>
2024-01-19 14:42:48 +01:00
Simon Ser d7f1909e7c xwayland/glamor/gbm: make wl_drm optional
Build on top of [1] to use linux-dmabuf to grab the main device
when wl_drm is unavailable. Fixes Xwayland glamor on top of latest
wlroots commit which has dropped wl_drm support [2].

[1]: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/818
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4397

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 10:59:53 +00:00
Simon Ser 4beb4f26ef xwayland/glamor/gbm: use Bool for true/false fields
This makes it more obvious what the values mean.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-01-19 10:59:53 +00:00
Michel Dänzer 3ddb81b15e xwayland: Update screen pixmap for root window in xwl_window_set_pixmap
If the old window pixmap was the screen pixmap.

Fixes screen->GetScreenPixmap() returning a stale pointer to a destroyed
pixmap with rootful Xwayland. It would result in a crash after resizing
the Xwayland window, or at the latest when shutting down.

Fixes: 6779ec5bf6 ("xwayland: Use window pixmap as a window buffer")
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1621
2024-01-17 18:12:37 +01:00
Olivier Fourdan 2ef0f1116c ephyr,xwayland: Use the proper private key for cursor
The cursor in DIX is actually split in two parts, the cursor itself and
the cursor bits, each with their own devPrivates.

The cursor itself includes the cursor bits, meaning that the cursor bits
devPrivates in within structure of the cursor.

Both Xephyr and Xwayland were using the private key for the cursor bits
to store the data for the cursor, and when using XSELINUX which comes
with its own special devPrivates, the data stored in that cursor bits'
devPrivates would interfere with the XSELINUX devPrivates data and the
SELINUX security ID would point to some other unrelated data, causing a
crash in the XSELINUX code when trying to (re)use the security ID.

CVE-2024-0409

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2024-01-16 09:26:01 +01:00
Michel Dänzer cad42fcb08 xwayland: Destroy old window pixmap in xwl_window_recycle_pixmap
We were leaking it.

Fixes: 6779ec5bf6 ("xwayland: Use window pixmap as a window buffer")
2024-01-12 17:06:39 +00:00
Michel Dänzer 8f66c15694 glamor: Make glamor_set_alu take a DrawablePtr
Preparation for the following commit, no functional change intended.
2024-01-11 10:03:10 +00:00
Olivier Fourdan 4805d901c3 xwayland: Add the output name for fullscreen rootful
This adds a new command line option "-output" to specify on which output
Xwayland should be starting fullscreen when rootful.

That allows to run multiple instances of Xwayland rootful fullscreen on
multiple outputs.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +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
Olivier Fourdan 2e317e0242 xwayland: Check for fullscreen on output name change
At startup, the names of the Wayland outputs are not yet known,
therefore we cannot rely on those when running fullscreen rootful.

Make sure to check the fullscreen state once the Wayland output name
changes.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan 01e31f5d95 xwayland: Add an output name for fullscreen
Add a output name to the xwl_screen.

This is preparation work for fullscreen rootful on a specific output,
no functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan d99e98ad68 xwayland: Add a function to search for xwl_output by name
Add a convenient function to search for an xwl_output based on its
XRandR name.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan 0fede76cc3 xwayland: Do not update the outputs when rootful
When running rootful, we do not need to apply the output changes, these
are there just to track the names and show up as disconnected in XRandR.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan 060f1f1154 xwayland: Always create the XrandR CRTCs
When running rootful, Xwayland would simply skip the creation of the CRTC
for the "real" outputs.

Instead, create the CRTC regardless of all outputs in rootful mode, but
mark them as disconnected when running rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan f0124485e1 xwayland: Use the output serial for the fixed output
The fixed output is called "XWAYLAND0", yet if the compositor does not
support Wayland output names, the "real" output names may collide with
the fixed output name.

Use the same output serial as with the (default) real output names to
avoid reusing the same names.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan a6bbc9663d xwayland: Use simpler initialization syntax
Use the simpler form `{ 0 }` instead of `{ '\0', }` for the
initialization of the output name buffer.

No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan e1e3bef7f8 xwayland: Use a helper function for fullscreen update
Move the code which may update the fullscreen state of the rootful
window to a dedicated helper function.

No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Michel Dänzer 777c3e0000 xwayland: Return NULL from xwl_window_buffer_get_available
If there's no available window buffer.

This allows keeping xwl_window_buffer->damage_region empty for a newly
allocated xwl_window_buffer in xwl_window_buffers_get_pixmap, instead
of first populating it in xwl_window_buffer_add_damage_region and then
emptying it again.
2024-01-10 17:31:42 +00:00
Michel Dänzer 6779ec5bf6 xwayland: Use window pixmap as a window buffer
Assuming the same number of window buffers, this results in one less
pixmap per toplevel window, saving pixmap storage.

v2:
* Preserve xwl_window_buffer_get_available behaviour (Olivier Fourdan)
v3:
* Leave RegionEmpty call where it was in xwl_window_buffers_get_pixmap,
  so it takes effect for a newly allocated struct xwl_window_buffer.
* Consolidate xwl_window_buffer->pixmap assignment in the same place.
2024-01-10 17:31:42 +00:00
Michel Dänzer 2b577c2e3b xwayland: Drop xwl_window_buffers_recycle
Use xwl_window_buffers_dispose instead. The pixmaps will need to be
re-created anyway, so keeping around the xwl_window_buffers doesn't
buy much. And dropping this makes the next commit simpler.

Also fold xwl_window_buffer_destroy_pixmap into its only remaining
caller,  xwl_window_buffer_maybe_dispose.

v2: (Olivier Fourdan)
* Fix up indentation in xwl_window_set_window_pixmap
* Leave xwl_window_buffer_destroy_pixmap helper
2024-01-10 17:31:42 +00:00
Michel Dänzer 2879032ecc xwayland: Rename helper to xwl_window_buffer_maybe_dispose
To make it clearer that it doesn't always dispose of the
xwl_window_buffer, only if the reference count drops to 0.
2024-01-10 17:31:42 +00:00
Michel Dänzer 114f060de5 xwayland: Make copy_pixmap_area return void
GetScratchGC can't really fail without a bug elsewhere. Just FatalError
in that case, so we'd get a bug report if it ever happens, instead of
trying to limp along.
2024-01-10 17:31:42 +00:00
Peter Hutterer 7f7adfdef8 xwayland: override the XTest sendEventsProc for all devices
Otherwise only XTest events on the XTest device get handled, XTest
requests on real devices are still processed as normal events.
2024-01-09 00:45:31 +00:00
Luke Dashjr 5f48efa2bd Xvfb: Support up to 13 mouse buttons
Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
2024-01-08 11:16:11 +00:00
Olivier Fourdan 7fdef970c4 build: Switch to meson 0.56
And replace the deprecated meson API accordingly.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2024-01-08 10:38:05 +00:00
Dongwon Kim 995e60a919 modesetting: Correct coordinate info of dirty clips for front-buffer flushing
A clip should represent the area that is covering the current FB associated
with the CRTC. So making sure each input rect covers any area in the FB is
the first thing to do. If that is the case, the size and coordinates should
be adjusted based on the partial area in the FB the each rect covers. The size
elements need to be truncated if the rect's size exceeds FB's for the CRTC.
Then offsets should be applied to coordinates if the CRTC's offsets aren't 0.
And coordinate transposing and inversion are needed in case the rotated image
is assigned to the FB.

Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
2024-01-04 17:51:30 +00:00