Commit Graph

8544 Commits

Author SHA1 Message Date
Olivier Fourdan c7730cfe55 xwayland: Translate keyboard grabs on the root window
When an X11 client issues an active grab on the keyboard, Xwayland
forward this to the Wayland compositor using the Xwayland specific
protocol "xwayland-keyboard-grab" if it can find the corresponding
Xwayland window.

Some X11 clients (typically older games) however try to issue the
keyboard grab on the X11 root window, which has obviously no matching
Xwayland window. In such a case, the grab is simply ignored and the game
will not work as expected.

To workaround that issue, if an X11 client issues a keyboard grab on the
root window, Xwayland will search for a toplevel window belonging to the
same X11 client that it can use as the grab window instead.

This way, the grab can be forwarded to the Wayland compositor that can
either grant or deny the request based on the window and its internal
policies.

The heuristic picks the first realized toplevel window belonging to the
client so that the Wayland compositor will send it the keyboard events,
and the Xserver grab mechanism will then take care of routing the events
to the expected X11 window by itself.

v2: Make the test more clear (Dor Askayo <dor.askayo@gmail.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Jonas Ådahl <jadahl@gmail.com>
See-also: https://gitlab.gnome.org/GNOME/mutter/-/issues/1249
2021-02-02 09:49:35 +00:00
Jeremy Huddleston Sequoia 520e7a1310 xquartz: Ensure that NSRunAlertPanel() is run on the main thread
Fixes: https://github.com/XQuartz/XQuartz/issues/30
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-02 00:46:26 +00:00
Jeremy Huddleston Sequoia 7d0bb7ed06 xquartz: Remove support for older versions of libXplugin
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia 5e7c0762e6 xquartz: Remove unused include of AvailabilityMacros.h from various sources
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia 59f22341a8 xquartz: Remove support for building for i386
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia aea15a7659 xquartz: Remove support for Mountain Lion and earlier versions of macOS
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia c0b2d3e099 xquartz: Remove support for Lion and earlier versions of macOS
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia cc9cf6f085 xquartz: Remove support for SnowLeopard and earlier versions of macOS
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia f699aac2ea xquartz: Remove check for libdispatch now that we don't support pre-SnowLeopard
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia 5ad4910272 xquartz: Remove support for Leopard and earlier versions of macOS
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia 6e6db055f8 xquartz: Remove support for Tiger and earlier versions of macOS
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jeremy Huddleston Sequoia 74aef85bd8 xquartz: Remove support for Panther and earlier versions of macOS
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2021-02-01 16:21:39 -08:00
Jim DeLaHunt 0e272ac458 Fix typo "XQaurtz" in Xquartz.man 2021-02-01 16:21:39 -08:00
Olivier Fourdan 3cdac5ba07 mi: List extensions in usage message
Not all extensions can be enabled or disabled at runtime, list the
extensions which can from the help message rather than on error only.

v2:
 * Print the header message in the ListStaticExtensions() (Peter
   Hutterer)
 * Do not export ListStaticExtensions() as Xserver API

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-01-29 12:52:09 +00:00
Misha Gusarov 4341f1da72 xwayland: Add -verbose option as in xfree86
Makes it easier to debug Xwayland problems.

Signed-off-by: Misha Gusarov <dottedmag@dottedmag.net>
2021-01-29 10:02:14 +00:00
Julien Cristau 0148a15da1 compiler.h: don't define inb/outb and friends on mips
The definition relies on IOPortBase, which is only ever set in
hw/xfree86/os-support/bsd/arm_video.c

This caused build failures on linux/mips with GCC 10, due to this
change (from https://gcc.gnu.org/gcc-10/changes.html#c):

"GCC now defaults to -fno-common. As a result, global variable accesses
are more efficient on various targets. In C, global variables with
multiple tentative definitions now result in linker errors. With
-fcommon such definitions are silently merged during linking."

As a result anything including compiler.h would get its own definition
of IOPortBase and the linker would error out.
2021-01-27 19:29:35 +00:00
Olivier Fourdan 9716c4193f xwayland: Add new pkg-config variable for listenfd
Since commit b3f3d65e, xwayland now supports the command line option
"-listenfd" for passing file descriptors and marked "-listen" as
deprecated for this specific purpose.

Add a new pkg-config variable "have_listenfd" to the xwayland.pc so that
compositors can know this is available and use listenfd in place of the
deprecated option.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2021-01-22 11:23:29 +01:00
Erik Kurzinger a9269808f3 xwayland: remove unused parameter of xwl_glamor_pixmap_get_wl_buffer
There are currently no callers that make use of the "created" output parameter
of xwl_glamor_pixmap_get_wl_buffer. Remove it, along with the corresponding
argument of the associated EGL backend entrypoint.
2021-01-08 06:17:51 -08:00
Povilas Kanapickas 5322457980 xfree86/inputtest: Drop extraneous linux-specific include
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-01-06 01:48:02 +00:00
Povilas Kanapickas 5e3900904d xfree86: Use different scroll increment than libinput in inputtest drv
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-18 04:39:07 +02:00
Povilas Kanapickas 58465a3dd9 xfree86: Add scroll axes to touch devices in inputtest driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-17 03:11:16 +02:00
Povilas Kanapickas 91a8013990 xfree86: Add support for pressure valuator axis in inputtest driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-17 03:11:08 +02:00
Povilas Kanapickas 742b87f7ee xfree86: Fix axis labels for PointerAbsolute input of inputtest driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-17 03:10:58 +02:00
Olivier Fourdan e4a9f0bb4e xwayland: Remove unneeded variable
Just a small code cleanup, there is no need to allocate a variable only
to check the return value of eglInitialize().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
2020-12-15 15:03:47 +01:00
Olivier Fourdan 95be87db98 xwayland: Refactor glamor EGL init
Glamor requires at least big GL 2.1 or GLES2, therefore Xwayland tries
to initialize first GL and then GLES2 if that fails.

It does that all in one single function which makes the code slightly
complicated, move the initialization of big-GL and GLES2 to separate
functions to help with readability of the code.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
2020-12-15 15:03:47 +01:00
Tony Lindgren 65673b02ef xwayland: fix GL version check for GLES only devices
We currently bail out early for GLES only devices, and call
epoxy_gl_version() too early for GLES only that will make GLES only
devices return NULL for glGetString(GL_RENDERER).

Let's also add a check to see if we need to recreate the context to
avoid pointless warnings for GLES only devices as suggested by
Olivier Fourdan <ofourdan@redhat.com>.

Fixes: a506b4ec - xwayland: make context current to check GL version
Signed-off-by: Tony Lindgren <tony@atomide.com>
2020-12-14 15:57:35 +01:00
Povilas Kanapickas 8c0afc9eb2 xfree86: Implement a test input driver
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-12-14 01:12:10 +00:00
Olivier Fourdan f95d81e88b xwayland: Hold window buffer until released
The window buffer mechanism would free the pixmap and its corresponding
Wayland buffer as soon as window buffers are disposed.

Typically when the X11 window is unrealized, the current window buffer
is still used by the Wayland compositor and yet Xwayland will destroy
the buffer.

As a matter of fact, Xwayland should not destroy the Wayland buffer
before the wl_buffer.release event is received.

Add a reference counter to the window buffer similar to the to pixmap
reference counter to keep the buffer around until the release callback
is received.

Increase that reference counter on the buffer which will be attached to
the surface, and drop that reference when receiving the release callback
notification.

v2: Use a specific reference counter on the buffer rather than relying
    on the pixmap refcnt (Michel Dänzer <mdaenzer@redhat.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Acked-by: Martin Peres <martin.peres@mupuf.org>
2020-12-10 13:49:42 +01:00
Olivier Fourdan 85d8eac4bc xwayland: Hold cursor buffer until released
The cursor code would destroy the buffer as soon as the cursor is
unrealized on X11 side.

Yet, the Wayland compositor may still be using the buffer as long as a
released callback has not been received.

Increase the reference counter on the pixmap to hold a reference on the
pixmap when attaching it to the surface and use the new pixmap release
callback mechanism to release that reference when the buffer is
released.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Martin Peres <martin.peres@mupuf.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-12-10 13:49:42 +01:00
Olivier Fourdan 79afbd608b xwayland: Factorize common cursor code
The seat and tablet cursor functions are very similar, factorize the
commonalities to simplify the code and reduce the copy/paste.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-12-10 13:49:42 +01:00
Prabhu Sundararaj 36e353bcf4 Remove check for useSIGIO option
Commit 6a5a4e6037 removed the option to
configure useSIGIO option. Indeed, the xfree86 SIGIO support was
reworked to use internal versions of OsBlockSIGIO and OsReleaseSIGIO.

As a result, useSIGIO is no longer needed and can dropped

Fixes: 6a5a4e60 - Remove SIGIO support for input [v5]
Closes: xorg/xserver#1107
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@nxp.com>
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-12-08 11:23:31 -05:00
Mariusz Ceier 95539ab37b xwayland: Replace LogMessage with LogMessageVerb
LogMessage logs only when the XLOG_VERBOSITY is >= 1, but by default
XLOG_VERBOSITY is 0, so for example warning about deprected -listen
parameter is never shown when running "Xwayland -listen 32 -help".

Signed-off-by: Mariusz Ceier <mceier+freedesktop@gmail.com>
2020-12-08 09:16:52 +00:00
Olivier Fourdan 3ce05a44f3 modesetting: Fix build with DebugPresent() enabled
By default, the macro DebugPresent() is a no-op but it can be enabled
at build time for debugging purpose.

However, doing so prevents the code to build because one debug statement
tries to make use of a non-existent variable:

  present.c: In function ‘ms_present_queue_vblank’:
  present.c:147:18: error: ‘vbl’ undeclared (first use in this function)
    147 |                  vbl.request.sequence));
        |                  ^~~
  present.c:49:32: note: in definition of macro ‘DebugPresent’
    49 | #define DebugPresent(x) ErrorF x
       |                                ^

Fix the build with DebugPresent() by removing the vbl variable from the
debug message.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-26 22:06:56 +00:00
Böszörményi Zoltán 682167475c Introduce and use BUS_USB
With !155, the device bus ID received via udev is constructed
properly with the "usb:" prefix. But, it is not enough to
make the following line to work in Section "Device":

    BusID  "usb:0:1.2:1.0"

Introduce BUS_USB, so the prefix can be distinguished from BUS_PCI
and check the supplied BusID value against device->attribs->busid
in xf86PlatformDeviceCheckBusID().

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2020-11-25 04:39:14 +00:00
Aaron Plattner af4622d3f9 modesetting: Add missing copyright notices
I forgot to add these in commits 4fefe73fe, b6985d6b3, 245b9db03, and 4e670f128.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2020-11-25 04:28:42 +00:00
Jon Turney bb7aab6afe hw/xwin: Fix building with -fno-common
Provide an actual definition of noDriExtension where used, rather than a
tentative definition in a header, to fix compilation with -fno-common
(the default with gcc 10).
2020-11-24 14:55:28 +00:00
Olivier Fourdan d18dcecbe0 xwayland: Clean up pending eglstream on pixmap destroy
EGLStream implementation in Xwayland keeps a list of pending streams for
a window.

If the windows's pixmap is destroyed while there is a pending stream,
the pending stream will point to freed memory once the callback is
triggered.

Make sure to cancel the pending stream if there's one when the pixmap is
destroyed.

v2:
 * Use xorg_list_for_each_entry() instead of the safe variant (Michel
   Dänzer <mdaenzer@redhat.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Karol Szuster <karolsz9898@gmail.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Closes https://gitlab.freedesktop.org/xorg/xserver/-/issues/1096
2020-11-23 15:11:47 +01:00
Olivier Fourdan 662b2bcb84 xwayland: Use the pixmap release callback with EGLStream
Commit 77658741 - "xwayland: Add buffer release callback" added an API
to deal with Wayland buffer release callbacks.

The EGLstream implementation has its own wl_buffer callback, move that
to the buffer release API instead so we don't have to deal with Wayland
buffers directly and match the other Xwayland pixmap backend
implementations.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Tested-by: Erik Kurzinger <ekurzinger@nvidia.com>
2020-11-19 09:33:01 +00:00
Alan Coopersmith e538601128 int10: wrap entire V_ADDR_R* macros in parens for safer expansion
Resolves warnings from Oracle Parfait static analyser:

Error: Misleading macro
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '|' operator has higher precedence than ternary '?:' operator inside macro body at line 431
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 431
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 431
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 431
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 442
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 442
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 443
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 443
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '|' operator has higher precedence than ternary '?:' operator inside macro body at line 443
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 441
   Misleading macro [misleading-macro]:
      misleading evaluation of ternary '?:' operator in expansion of macro V_ADDR_RB due to missing parentheses
        at line 392 of hw/xfree86/int10/generic.c.
        '<<' operator has higher precedence than ternary '?:' operator inside macro body at line 443
        low precedence ternary '?:' operator is hidden by expansion of macro V_ADDR_RB at line 443

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-11-17 18:43:39 -08:00
Alan Coopersmith 034e792662 dmx: example code should set a good example
Resolves warning from Oracle Parfait static analyser:

Error: Unchecked result
   Unchecked result [unchecked-result-call-X]:
      Unchecked return value from call to XOpenDisplay. Value display must be ch
ecked to ensure this function was successful.
        at line 73 of hw/dmx/examples/xbell.c in function 'main'.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-11-17 18:43:39 -08:00
Michel Dänzer 250db8708a xwayland: Add and hook up test script
It runs XTS via piglit on (non-rootless) Xwayland on weston using the
headless backend.

Xwayland might use glamor if enabled in the build, but we're making sure
it uses software rendering.

v2:
* Use weston-info to wait for weston to be ready, instead of just a
  fixed sleep. (Martin Peres)
v3:
* Build wayland 1.18 & weston 9.0 locally, since the packages in Debian
  buster are too old for current Xwayland.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-17 18:21:37 +01:00
Olivier Fourdan 28ed4b95e9 xwayland: Add a man page
Xwayland was missing a man page, add one.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
2020-11-10 14:09:42 +01:00
Olivier Fourdan d14cef853a xwayland: Do not list option "-eglstream" if not supported
As Xwayland is usually spawned by the Wayland server/compositor, its
command line options are not always adjustable.

Yet, if EGLStream is not supported in a given Xwayland build, the option
will do nothing (yet we must still accept it otherwise Xwayland would
refuse to run if the Wayland compositor uses it).

If Xwayland was built without support for EGLStream, there is not point
in showing the option in the help message though.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
2020-11-10 14:09:41 +01:00
Olivier Fourdan d163f938a0 xwayland: Add help entry for -shm
The command line options "-shm" is used to instruct Xwayland to prefer
shared-memory for passing buffers to the Wayland server, rather than
using glamor and DRI3.

The option was there from the beginning, yet not documented in the
"-help" message.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
2020-11-10 14:09:41 +01:00
Michel Dänzer df3aa4922f xwayland: Make window_get_client_toplevel non-recursive
Noticed while reading the code.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-09 09:54:09 +00:00
Olivier Fourdan 606ba7fc51 xwayland: Create an xwl_window for toplevel only
One general assumption in Xwayland is that the xwl_window remains the
same for all the child windows of the toplevel window.

When mapping a new X11 window, ensure_surface_for_window() checks for an
existing xwl_window by using xwl_window_get() which will just check for
the registered xwl_window for the window.

That means that a client mapping a child window of an existing window
with a xwl_window will get another different xwl_window.

If an X11 client issues a Present request on the parent window, hence
placed underneath its child window of the same size, the Wayland
compositor may not send the frame callback event for the parent's
Wayland surface which is reckoned to be not visible, obscured behind
the other Wayland surface for the child X11 window.

That bug affects some games running in wine which may get 1 fps because
the repaint occurs only on timeout with a long interval (as with, e.g.
https://bugs.winehq.org/show_bug.cgi?id=47066)

Fix ensure_surface_for_window() by using xwl_window_from_window() which
will walk the window tree, so that a child window won't get another
xwl_window than its parent.

https://gitlab.freedesktop.org/xorg/xserver/-/issues/1099
See-also: https://bugs.winehq.org/show_bug.cgi?id=47066
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-11-09 09:03:47 +00:00
Olivier Fourdan ffd02d9b26 xwayland: non-rootless requires the XDG-WM-Base protocol
When running non-rootless, Xwayland requires that the Wayland compositor
supports the XDG-WM-Base protocol.

Check for XDG-WM-Base protocol support at startup and exit cleanly if
missing rather than segfaulting later in ensure_surface_for_window()
while trying to use xdg_wm_base_get_xdg_surface().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
2020-11-09 08:48:16 +00:00
Adam Jackson affc474525 xwayland: Drop the separate refcount for the xwl_pixmap
Instead, bump the pixmap's refcount at the bottom of post_damage to
reflect the compositor's hold on the buffer, and "destroy" the pixmap in
the buffer release callback (which will dec the pixmap's refcount and
free if necessary).

Signed-off-by: Adam Jackson <ajax@redhat.com>
2020-10-30 11:09:45 -04:00
Aaron Plattner 4e670f1281 modesetting: Add CTM RandR property
When the "CTM" (color transform matrix) modesetting property is available,
create a corresponding RandR property.

To match the format of the property available in the amdgpu driver, expose it as
an array of 18 32-bit XA_INTEGERs representing a 3x3 matrix in row-major order,
where each entry is a S31.32 sign-magnitude fixed-point number with the
fractional part listed first.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: James Jones <jajones@nvidia.com>
2020-10-29 15:25:00 -07:00
Aaron Plattner 245b9db03a modesetting: Use GAMMA_LUT when available
If the kernel exposes GAMMA_LUT and GAMMA_LUT_SIZE properties and the size is
not what the server has pre-configured for the crtc, free the old gamma ramp
memory allocated by the server and replace it with new allocations of the
appropriate size.

In addition, when GAMMA_LUT is available, use drmModeCreatePropertyBlob() and
drmModeObjectSetProperty() to set the gamma ramp rather than using the legacy
drmModeCrtcSetGamma() function.

Add a new option "UseGammaLUT" to allow disabling this new behavior and falling
back to drmModeCrtcSetGamma() unconditionally.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2020-10-29 15:13:17 -07:00
Aaron Plattner b6985d6b3f modesetting: Query properties even in non-atomic mode
Modeset properties can be set even when ms->atomic_modeset is disabled by using
the drmModeObjectSetProperty() function.

This will be necessary in a later change in order to set the GAMMA_LUT and CTM
properties.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2020-10-29 15:10:16 -07:00
Aaron Plattner 4fefe73fea modesetting: Store property values in drmmode_prop_info_rec
A later change will need to read the value of the GAMMA_LUT_SIZE property.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2020-10-29 15:10:16 -07:00
Kishore Kadiyala efb3abddd4 modesetting: keep going if a modeset fails on EnterVT
There was a time when setting a mode on a CRTC would not depend on the
associated connector's state. If a mode had been set successfully once,
it would mean it would work later on.

This changed with the introduction of new connectors type that now
require a link training sequence (DP, HDMI 2.0), and that means that
some events may have happened while the X server was not master that
would then prevent the mode from successfully be restored to its
previous state.

This patch relaxes the requirement that all modes should be restored on
EnterVT, or the entire X-Server would go down by allowing modesets to
fail (with some warnings). If a modeset fails, the CRTC will be
disabled, and a RandR event will be sent for the desktop environment to
fix the situation as well as possible.

Additional patches might be needed to make sure that the user would
never be left with all screens black in some scenarios.

v2 (Martin Peres):
 - whitespace fixes
 - remove the uevent handling (it is done in a previous patch)
 - improve the commit message
 - reduce the size of the patch by not changing lines needlessly
 - return FALSE if one modeset fails in ignore mode
 - add comments/todos to explain why we do things
 - disable the CRTCs that failed the modeset

Signed-off-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
Closes: #1010
2020-09-25 16:13:56 +03:00
Martin Peres 293cf660c9 modesetting: check the kms state on EnterVT
Normally, we would receive a uevent coming from Linux's DRM subsystem,
which would trigger the check for disappearing/appearing resources.
However, this event is not received when X is not master (another VT
is selected), and so the userspace / desktop environment would not be
notified about the changes that happened while X wasn't master.

To fix the issue, this patch forces a refresh on EnterVT by splitting
the kms-checking code from the uevent handling into its own (exported)
function called drmmode_update_kms_state. This function is then called
from both the uevent-handling function, and on EnterVT right before
restoring the modes.

Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
Tested-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
2020-09-25 16:13:56 +03:00
Povilas Kanapickas 4c00369024 Bump input minor ABI due to addition of input event drain callback
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-09-24 17:33:22 +00:00
Povilas Kanapickas 5eb985e353 mi: Add a callback to notify driver about input event submission
This is useful for mock input drivers that control the server in
integration tests. Given that input submission happens on a different
thread than processing, it's otherwise impossible for the driver to
synchronize with the completion of the processing of submitted events.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2020-09-24 17:33:22 +00:00
Olivier Fourdan a5f439dcd2 xwayland: Remove pending stream reference when freeing
The EGLStream backend keeps a queue of pending streams for each Xwayland
window.

However, when this pending queue is freed, the corresponding private
data may not be cleared (typically if the pixmap for this window has
changed before the compositor finished attaching the consumer for the
window's pixmap's original eglstream), leading to a use-after-free and a
crash when trying to use that data as the window pixmap.

Make sure to clear the private data when the pending stream is freed.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1055
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Karol Szuster <karolsz9898@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-09-22 19:23:52 +00:00
Olivier Fourdan 0b86c0c362 xwayland: Add a flag for n-buffers in EGL backend
Using multiple window buffers crashes with EGLStream, which does not
need it anyway as this is handled through EGL directly.

Add a flag to the EGL backend to indicate whether it would benefit from
multiple buffers and use this in the get_buffer() function.

Thanks to Adam Jackson <ajax@redhat.com> for pointing out that issue
with EGLStream.

v2: Fix logical test (Adam Jackson <ajax@redhat.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-09-22 17:59:42 +02:00
Olivier Fourdan ae84f14fb5 xwayland: Add a flag to expose EGL backend features
The present flip does not work with the EGLStream backend. Similarly,
the EGLStream backend does not require the buffer to be flushed as
eglSwapBuffers() should take care of this.

Instead of actually checking the backend in use in the present code,
add a flag in the form of a bitfield to the EGL backend to indicate
its features and requirements.

This should not introduce any functional change.

v2: Fix logical test (Adam Jackson <ajax@redhat.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-09-22 17:59:42 +02:00
Greg V 239ebdc9e4 xwayland: use drmGetNodeTypeFromFd for checking if a node is a render one
Major/minor numbers are a.. major (ha) source of pain in FreeBSD porting.
In this case, Xwayland was thinking that /dev/dri/card0 is already a render node,
because the st_rdev on FreeBSD was passing the Linux-style check,
and because of the assumption, acceleration would fail because
various ioctls like AMDGPU_INFO would be denied on the non-render node.

Switch to libdrm's function that already works correctly on all platforms.

Signed-off-by: Greg V <greg@unrelenting.technology>
Reviewed-by: Emmanuel Vadot <manu@FreeBSD.org>
2020-09-21 07:01:54 +00:00
Michel Dänzer add3df2001 Consolidate fourcc.h
Move the copy in hw/xfree86/common to include/, and remove the one in
hw/kdrive/src/.

Fixes DIX glamor code including an xfree86 DDX header.
2020-09-15 11:43:16 +02:00
Uday Kiran Pichika 97f858d336 modesetting: Allow users to opt-in VRR support
Fetch VariableRefresh option value from X conf file for
modesetting backend DDX driver. This option defaults to false,
and must be set to "true" in conf file for variable refresh
support in the DDX driver.

Signed-off-by: Uday Kiran Pichika <pichika.uday.kiran@intel.com>
2020-09-08 08:00:20 +00:00
Uday Kiran Pichika ede2c32ce1 modesetting: Detect changes to the _VARIABLE_REFRESH window properties
Window wrappers gets the notification when the window
properties changes. These wrappers are mainly used to
keep track of per-window _VARIABLE_REFRESH property values.

These changes have been ported from AMDGPU

Signed-off-by: Uday Kiran Pichika <pichika.uday.kiran@intel.com>
2020-09-08 08:00:20 +00:00
Uday Kiran Pichika 9823ea4ed2 modesetting: Lay the foundation for enabling VRR
These changes have been ported from AMD GPU DDX driver.

This patch adds support for setting the CRTC variable refresh property
for suitable windows flipping via the Present extension.

In order for a window to be suitable for variable refresh it must have
the _VARIABLE_REFRESH property set by the MESA and inform Modesetting
DDX driver with window property updates.

Then the window must pass the checks required to be suitable for
Present extension flips - it must cover the entire X screen and no
other window may already be flipping. And also DRM connector should
be VRR capable.

With these conditions met every CRTC for the X screen will have their
variable refresh property set to true.

Kernel Changes to support this feature in I915 driver is under development.

Tested with DOTA2, Xonotic and custom GLX apps.

Signed-off-by: Uday Kiran Pichika <pichika.uday.kiran@intel.com>
2020-09-08 08:00:20 +00:00
Michel Dänzer 4c25356d6c xwayland: Check window pixmap in xwl_present_check_flip2
We can only flip if the window pixmap matches that of the toplevel
window. Doing so regardless could cause the toplevel window pixmap to
get destroyed while it was still referenced by the window, resulting in
use-after-free and likely a crash.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1033
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Roman Gilg <subdiff@gmail.com>
2020-09-07 17:55:12 +02:00
Roman Gilg 727df0a74e xwayland: Replace need_rotate boolean with simple check on xdg-output
The need_rotate variable is only used once anymore and had semantics which lead
to errors in the past. In particular when negated we are dealing with a double
negation.

The variable gets replaced with a simple check on the xdg-output directly.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-09-01 13:13:57 +00:00
Roman Gilg da791ed9fd Revert "xserver: Fix a typo"
This reverts commit 427f8bc009.

When receiving an output update for the mode size we need to rotate the stored
width and height values if and only if we have an xdg-output for this output
since in this case the stored values describe the output's size in logical
space, i.e. rotated.

The here reverted commit made a code change with which we would not rotate though
when an xdg-output was available since in this case the need_rotate variable was
set to False what caused in the check afterwards the first branch to execute.
2020-09-01 13:13:57 +00:00
Roman Gilg 92f4a9ade3 xwayland: Switch width and height argument order
That is just a small style-change to the output_get_new_size function. The
function before did take first the height and then the width argument, what
is unusual since resolutions are normally named the other way around, for
example 1920x1080. Also compare the update_screen_size function.

Therefore change the order of arguments for output_get_new_size.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-09-01 13:13:57 +00:00
Roman Gilg 1805383d9e xwayland: simplify output_get_new_size function
We can just read out the xdg_output field of the provided xwl_output to check
if a rotation is necessary or not.

This makes the function easier to understand. Additionally some documentation
is added.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-09-01 13:13:57 +00:00
Michel Dänzer 919f1f46fc xfree86: Take second reference for SavedCursor in xf86CursorSetCursor
The same pointer is kept in CurrentCursor as well, therefore two
RefCursor calls are needed.

Fixes use-after-free after switching VTs.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1067
2020-08-31 12:10:43 +02:00
Olivier Fourdan 5c20e4b834 xwayland: Disable the MIT-SCREEN-SAVER extension when rootless
Xwayland is just a Wayland client, no X11 screensaver should be
expected to work reliably on Xwayland when running rootless because
Xwayland cannot grab the input devices so it has no way to actually
lock the screen managed by the Wayland compositor.

Turn off the screensaver on Xwayland when running rootless by setting
the screensaver timeout and interval and their default values to zero
and disable the MIT-SCREEN-SAVER extension.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1051
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-04 09:33:15 +02:00
Ignacio Casal Quinteiro 9d8e7c4828 XKB: Add debug key actions for grabs & window tree
Replicate 7d2543a3cb but for
all types of X servers
2020-07-31 05:25:50 +00:00
Roman Gilg c24eb7e31e xwayland: Simplify Present event handling code
Instead of optionally return early when an event is aborted and potentially
clean it up in there we can only optionally inform Present if not aborted and
afterwards clean it up if required.

Saves some lines of code and conditional branches.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-30 09:28:20 +00:00
Jon Turney 4c2d1fe045 hw/xwin: Update for renames in xserver/output API
Update commit ea47af87 renaming master_pixmap to primary_pixmap in
struct PixmapRec.
2020-07-29 20:36:35 +01:00
Roman Gilg ab880b8b9e present: Idle vblanks any time in window mode
With the newly introduced separate API method for idling a presented Pixmap in
window mode we can simplify the logic by allowing calls to it at any point in
time.

This is done by setting the flip_idler flag if the Pixmap was idled before
being presented.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22 11:10:17 +02:00
Roman Gilg 932c6baca2 present: Notify via distinct API functions in window mode
Notifying Present about events' states was done prior with the single function
present_wnmd_event_notify just like in screen mode. But it is more intelligible
if at least in window mode we make use of three different functions with names
that directly indicate what their purpose is:

* present_wnmd_event_notify only for queued events feedback.
* present_wnmd_flip_notify for when a presentation occured (flip).
* present_wnmd_idle_notify for when the Pixmap of the event can be reused.

This is an API-breaking change in regards to window mode. DDX written against
the previous version won't work anymore. It is assumed that there only exists
the XWayland DDX at the moment using the window mode such that this is not an
issue for the overall ecosystem.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22 11:09:50 +02:00
Roman Gilg f8211095c3 xwayland: Rename present event lists
Rename the lists release_queue to release_list and event_list to
wait_list.

The prior names release_queue and event_list were ambiguous: in both are event-
like vblanks which can be removed from the lists in random order. In the
release_queue can be flips that are already released but still wait for the
sync or frame callback but normally the release comes later. In the event_list
are queued events waiting for a later msc.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22 11:01:42 +02:00
Roman Gilg 0db326e5ca xwayland: Remove unused xwl_screen entry
In xwl_present_window an xwl_screen entry was declared but never actually used.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22 10:53:20 +02:00
Alex Goins 495bf63a7d randr: Re-add removed NULL checks to xf86RandR12.c
Commit 1e3f9ea1 removed some NULL checks from xf86RandR12.c, on the premise that
they can't be reached unless RandR has already been initialized. For threesuch
calls, that's not true:

xf86Crtc.c::xf86CrtcScreenInit():

    if (c == config->num_crtc) {
        xf86RandR12SetRotations(screen, RR_Rotate_0 | RR_Rotate_90 |
                                RR_Rotate_180 | RR_Rotate_270 |
                                RR_Reflect_X | RR_Reflect_Y);
        xf86RandR12SetTransformSupport(screen, TRUE);
    }
    else {
        xf86RandR12SetRotations(screen, RR_Rotate_0);
        xf86RandR12SetTransformSupport(screen, FALSE);
    }

xf86Crtc.c::xf86CrtcCloseScreen():

    xf86RandR12CloseScreen(screen);

This change adds checks back to xf86RandR12Set{Rotations,TransformSupport}() and
xf86RandR12CloseScreen(), checking that xf86RandR12KeyRec has been registered.
Without this, X will hit an assert that causes it to abort.

Signed-off-by: Alex Goins <agoins@nvidia.com>
2020-07-21 15:53:53 +00:00
Michel Dänzer e33453f911 xwayland: Handle NULL xwl_seat in xwl_seat_can_emulate_pointer_warp
This can happen e.g. with weston's headless backend.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-07-21 15:58:42 +02:00
Emmanuel Gil Peyrot ddb86e94c0 xwayland: Remove harmless duplicated #include 2020-07-20 00:19:22 +00:00
Emmanuel Gil Peyrot a137dd5f79 xwayland: Use memfd_create() when available
This (so-far) Linux-only API lets users create file descriptors purely
in memory, without any backing file on the filesystem and the race
condition which could ensue when unlink()ing it.

It also allows seals to be placed on the file, ensuring to every other
process that we won’t be allowed to shrink the contents, potentially
causing a SIGBUS when they try reading it.

This patch is best viewed with the -w option of git log -p.

This is a port of this commit from Weston:
deae98ef45

Fixes #848.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2020-07-20 00:19:22 +00:00
Lyude Paul ba0e789b91 xwayland: Store xwl_tablet_pad in its own private key
When a slave device causes the master virtual pointer device to change
device types, the device's private data pointer
(device->public.devicePrivate) is also changed to match the type of the
slave device. This can be a problem though, as tablet pad devices will
set the device's private data pointer to their own xwl_tablet_pad
struct. This can cause us to dereference the pointer as the wrong type,
and result in a segfault:

Thread 1 "Xwayland" received signal SIGSEGV, Segmentation fault.
wl_proxy_marshal (proxy=0x51, opcode=opcode@entry=0) at src/wayland-client.c:792
792             va_start(ap, opcode);
(gdb) bt
0  wl_proxy_marshal (proxy=0x51, opcode=opcode@entry=0) at
  src/wayland-client.c:792
1  0x00005610b27b6c55 in wl_pointer_set_cursor (hotspot_y=0,
  hotspot_x=0, surface=0x0, serial=<optimized out>, wl_pointer=<optimized
  out>) at /usr/include/wayland-client-protocol.h:4610
2  xwl_seat_set_cursor (xwl_seat=xwl_seat@entry=0x5610b46d5d10) at
  xwayland-cursor.c:137
3  0x00005610b27b6ecd in xwl_set_cursor (device=<optimized out>,
  screen=<optimized out>, cursor=<optimized out>, x=<optimized out>,
  y=<optimized out>) at xwayland-cursor.c:249
4  0x00005610b2800b46 in miPointerUpdateSprite (pDev=0x5610b4501a30) at
  mipointer.c:468
5  miPointerUpdateSprite (pDev=0x5610b4501a30) at mipointer.c:410
6  0x00005610b2800e56 in miPointerDisplayCursor (pCursor=0x5610b4b35740,
  pScreen=0x5610b3d54410, pDev=0x5610b4501a30) at mipointer.c:206
7  miPointerDisplayCursor (pDev=0x5610b4501a30, pScreen=0x5610b3d54410,
  pCursor=0x5610b4b35740) at mipointer.c:194
8  0x00005610b27ed62b in CursorDisplayCursor (pDev=<optimized out>,
  pScreen=0x5610b3d54410, pCursor=0x5610b4b35740) at cursor.c:168
9  0x00005610b28773ee in AnimCurDisplayCursor (pDev=0x5610b4501a30,
  pScreen=0x5610b3d54410, pCursor=0x5610b4b35740) at animcur.c:197
10 0x00005610b28eb4ca in ChangeToCursor (pDev=0x5610b4501a30,
  cursor=0x5610b4b35740) at events.c:938
11 0x00005610b28ec99f in WindowHasNewCursor
  (pWin=pWin@entry=0x5610b4b2e0c0) at events.c:3362
12 0x00005610b291102d in ChangeWindowAttributes (pWin=0x5610b4b2e0c0,
  vmask=<optimized out>, vlist=vlist@entry=0x5610b4c41dcc,
  client=client@entry=0x5610b4b2c900) at window.c:1561
13 0x00005610b28db8e3 in ProcChangeWindowAttributes (client=0x5610b4b2c900)
  at dispatch.c:746
14 0x00005610b28e1e5b in Dispatch () at dispatch.c:497
15 0x00005610b28e5f34 in dix_main (argc=16, argv=0x7ffc7a601b68,
  envp=<optimized out>) at main.c:276
16 0x00007f8828cde042 in __libc_start_main (main=0x5610b27ae930 <main>,
  argc=16, argv=0x7ffc7a601b68, init=<optimized out>, fini=<optimized
  out>, rtld_fini=<optimized out>, stack_end=0x7ffc7a601b58) at
  ../csu/libc-start.c:308
17 0x00005610b27ae96e in _start () at cursor.c:1064

Simple reproducer in gnome-shell: open up an Xwayland window, press some
tablet buttons, lock and unlock the screen. Repeat if it doesn't crash
the first time.

So, let's fix this by registering our own device-specific private key
for storing a backpointer to xwl_tablet_pad, so that all input devices
have their private data pointers set to their respective xwl_seat.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <lyude@redhat.com>
2020-07-16 21:00:48 +00:00
Roman Gilg 85a6fd11c7 xwayland: Damage surface in surface-relative coordinates
In 9141196d positional coordinates were added to the damage call of pixmap
flips. The damage box coordinates are in screen space though and we need
to convert them first to surface-relative ones by substracting the origin
of the window.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-14 08:21:03 +00:00
Michel Dänzer ed624544d4 xfree86: Bump ABI_VIDEODRV_VERSION to 25.2
This gives out of tree drivers a fighting chance to build against both
sides of
https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/468 .

Reviewed-by: Dave Airlie <airlied@redhat.com>
2020-07-13 07:06:07 +10:00
Dave Airlie ea47af87f6 xserver/output: rename some badly named variables/APIs.
This is an API and ABI break

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-10 06:17:44 +10:00
Olivier Fourdan 5188603ff7 xwayland: Add a pkg-config file for Xwayland
Xwayland is usually spawned by the Wayland compositor which sets the
command line options.

If a command line option is not supported, Xwayland will fail to start.

That somehow makes the Xwayland command line option sort of ABI, the
Wayland compositor need to know if a particular option is supported by
Xwayland at build time.

Also, currently, Xwayland is being installed along with the rest of the
common executable programs that users may run, which is sub-optimal
because, well, Xwayland is not a common executable program, it's meant
to be a proxy between the Wayland compositor and the legacy X11 clients
which wouldn't be able to run on Wayland otherwise.

Xwayland would be better installed in `libexec` but that directory is
(purposedly) not in the user `PATH` and therefore the Wayland compositor
may not be able to find Xwayland in that case.

To solve both problems (which options are supported by Xwayland and
where to look for it), add a `pkg-config` file specifically for Xwayland
which gives the full path to Xwayland (`xwayland`) and which options it
supports (using `pkg-config` variables).

The `pkg-config` file also provides the `Version` so the build scripts
can check for a particular version if necessary.

Obviously, Wayland compositors are not required to use the `pkg-config`
file and can continue to use whatever mechanism they deem preferable.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-07-08 08:56:32 +00:00
Michel Dänzer 2beefda5a8 xwayland: Move xwl_surface_damage definition to xwayland-screen.c
It was already declared in xwayland-screen.h, and only takes a screen
parameter, no window ones.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-07-07 13:47:11 +00:00
Michel Dänzer 12af425acd xwayland: Rename xwl_pixmap_cb → xwl_buffer_release_cb
Seems clearer.

While we're at it, also drop the unused pixmap parameter.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-07-07 13:47:11 +00:00
Michel Dänzer 9eb0b4f731 xwayland: Remove xwl_present_event::buffer_released in favor of ::pixmap
No need for the separate boolean.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-07-07 13:47:11 +00:00
Michel Dänzer 9141196d31 xwayland: Propagate damage x1/y1 coordinates in xwl_present_flip
This couldn't have worked correctly for non-0 x1/y1.

Noticed by inspection.

Reviewed-by: Simon Ser <contact@emersion.fr>
2020-07-07 15:37:23 +02:00
Alan Coopersmith 23e83724df Fix spelling/wording issues
Most (but not all) of these were found by using
  codespell --builtin clear,rare,usage,informal,code,names
but not everything reported by that was fixed.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-07-05 13:07:33 -07:00
Olivier Fourdan b0413b6e99 xwayland: Use a fixed DPI value for core protocol
The way Xwayland works (like all Wayland clients), it first queries the
Wayland registry, set up all relevant protocols and then initializes its
own structures.

That means Xwayland will get the Wayland outputs from the Wayland
compositor, compute the physical size of the combined outputs and set
the corresponding Xwayland screen properties accordingly.

Then it creates the X11 screen using fbScreenInit() but does so by using
a default DPI value of 96. That value is used to set the physical size
of the X11 screen, hence overriding the value computed from the actual
physical size provided by the Wayland compositor.

As a result, the DPI computed by tools such as xdpyinfo will always be
96 regardless of the actual screen size and resolution.

However, if the Wayland outputs get reconfigured, or new outputs added,
or existing outputs removed, Xwayland will recompute and update the
physical size of the screen, leading to an unexpected change of DPI.

To avoid that discrepancy, use a fixed size DPI (defaults to 96, and can
be set using the standard command lime option "-dpi") and compute a
physical screen size to match that DPI setting.

Note that only affects legacy core protocols, X11 clients can still get
the actual physical output size as reported by the Wayland compositor
using the RandR protocol, which also allows for the size to be 0 if the
size is unknown or meaningless.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/731
2020-07-03 12:59:23 +00:00
SimonP 6748a40941 xwayland: Initialise values in xwlVidModeGetGamma()
ProcVidModeGetGamma() relies on GetGamma() to initialise values if it
returns TRUE. Without this, we're sending uninitialised values to
clients.

Fixes: xorg/xserver#1040
2020-07-03 10:56:43 +00:00
Sjoerd Simons d35f68336b xwayland: Fix crashes when there is no pointer
When running with a weston session without a pointer device (thus with
the wl_seat not having a pointer) xwayland pointer warping and pointer
confining should simply be ignored to avoid crashes.

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2020-07-02 04:42:29 +00:00
Jose Maria Casanova Crespo 73480f172a modesetting: Fix front_bo leak at drmmode_xf86crtc_resize on XRandR rotation
Since the introduction of "modesetting: Remove unnecessary fb addition from
drmmode_xf86crtc_resize" the fb_id isn't initialited at
drmmode_xf86crtc_resize.

Rotate operation of XRandR uses rotate_bo. So in this case the fb_id
associated to the front_bo is not initialized at drmmode_set_mode_major.
So fd_id remains 0.

As every call to drmmode_xf86crtc_resize allocates a new front_bo we should
destroy unconditionally the old_front_bo if operation success. So we free
the allocated GBM handles.

This avoids crashing xserver with a OOM in the RPI4 1Gb at 4k resolution
after 3 series xrandr rotations from normal to left and vice versa reported at
https://github.com/raspberrypi/firmware/issues/1345

Signed-off-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1024
Fixes: 8774532121 "modesetting: Remove unnecessary fb addition from
       drmmode_xf86crtc_resize"
2020-06-27 08:29:45 +00:00
Michel Dänzer b670527429 xwayland: Free all remaining events in xwl_present_cleanup
These events aren't reachable after xwl_present_cleanup, so they're
leaked if we don't free them first.

This requires storing the pixmap pointer in struct xwl_present_window.
Luckily, the buffer pointer isn't used for anything, so just replace
that.

v2:
* Bump pixmap reference count in xwl_present_flip and drop it in
  xwl_present_free_event, fixes use-after-free in the latter due to the
  pixmap already being destroyed.

Reviewed-by: Dave Airlie <airlied@redhat.com>
2020-06-25 17:32:19 +02:00
Michel Dänzer 1beffba699 xwayland: Always use xwl_present_free_event for freeing Present events
Minor cleanup, and will make the next change simpler. No functional
change intended.

Reviewed-by: Dave Airlie <airlied@redhat.com>
2020-06-25 17:31:06 +02:00
Martin Weber 7ae221ad57 hw/xfree86: Avoid cursor use after free
During a VT-Switch a raw pointer to the shared cursor object
is saved which is then freed (in case of low refcount) by a call to
xf86CursorSetCursor with argument pCurs = NullCursor.
This leads to a dangling pointer which can follow in a use after free.

This fix ensures that there is a shared handle saved for the VT-Switch cycle.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-06-24 08:02:59 +00:00
Aaron Ma 6a79a737e2 xfree86: add drm modes on non-GTF panels
EDID1.4 replaced GTF Bit with Continuous or Non-Continuous Frequency Display.

Check the "Display Range Limits Descriptor" for GTF support.
If panel doesn't support GTF, then add gtf modes.

Otherwise X will only show the modes in "Detailed Timing Descriptor".

V2: Coding style changes.
V3: Coding style changes, remove unused variate.
V4: remove unused variate.

BugLink: https://gitlab.freedesktop.org/drm/intel/issues/313
Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-06-23 13:09:20 +08:00
Simon Ser d6558477d7 xwayland: allow using linux-dmabuf with DRM_FORMAT_MOD_INVALID
When the linux-dmabuf protocol is available, prefer it over the old
wl_drm protocol. Previously wl_drm was used when modifiers aren't
supported, however linux-dmabuf supports formats without modifiers too.
In this case, linux-dmabuf will send a DRM_FORMAT_MOD_INVALID modifier
for each supported format [1].

This allows compositors to better handle these buffers, getting a
DMA-BUF and implementing features like direct scan-out.

A similar logic has been implemented for EGL [2].

DRM_FORMAT_MOD_INVALID is now stored in the xwl_screen->formats list.
glamor_get_modifiers still returns FALSE with zero modifiers if the
only advertised modifier is DRM_FORMAT_MOD_INVALID.

[1]: fb9b2a8731
[2]: c376865f5e

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-06-19 10:10:47 +00:00
Simon Ser c0e13cbf5a xwayland: only use linux-dmabuf if format/modifier was advertised
Previously, linux-dmabuf was used unconditionally if the buffer had a
modifier. However creating a linux-dmabuf buffer with a format/modifier
which hasn't been advertised will fail.

Change xwl_glamor_gbm_get_wl_buffer_for_pixmap to use linux-dmabuf when
the format/modifier has been advertised only.

Signed-off-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1035
Tested-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-06-19 10:10:47 +00:00
Simon Ser 9c8d274458
xwayland: don't use GBM_BO_USE_SCANOUT
This flag should only be used when the caller intends to display the
buffer on a hardware plane. Xwayland isn't a DRM client, so it doesn't
make sense to use this flag.

This change will allow the driver to potentially use buffer parameters
that are more optimized.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-06-19 11:26:10 +02:00
Adam Jackson fc4f248544 xwayland: Set the vendor name for GLX_EXT_libglvnd
Without this the client library will flail around looking for a default
provider, probably one named "indirect", and that defeats the point of
having the EGL provider for direct context support in the first place.

This assumes that "mesa" will work, of course, and in general it should.
Mesa drivers will DTRT through the DRI3 setup path, and if our glamor is
atop something non-Mesa then you should fall back to llvmpipe like 1.20.
In the future it might be useful to differentiate the vendor here based
on whether glamor is using gbm or streams.

Fixes: xorg/xserver#1032
2020-06-05 14:50:55 -04:00
Matthieu Herrb 5dc16f6fec Remove BSD APM support.
None of the current BSD is actually using this code.
(checked DragonFly 5.8.1, FreeBSD 11.2, NetBSD 9.0 and OpenBSD 6.7)

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2020-06-03 17:33:10 +02:00
Jan Beich be731e0bdc glx: unbreak on Unix without /usr/include/drm
In file included from ../glx/glxdri2.c:35:
/usr/local/include/GL/internal/dri_interface.h:43:10: fatal error: 'drm.h' file not found
 #include <drm.h>
          ^~~~~~~
In file included from ../glx/glxdriswrast.c:39:
/usr/local/include/GL/internal/dri_interface.h:43:10: fatal error: 'drm.h' file not found
 #include <drm.h>
          ^~~~~~~
2020-05-27 07:15:07 +00:00
Olivier Fourdan 4195e80356 xwayland: Clear private on device removal
Xwayland uses the device private to point to the `xwl_seat`.

Device may be removed at any time, including on suspend.

On resume, if the DIX code ends up calling a function that requires the
`xwl_seat` such as `xwl_set_cursor()` we may end up pointing at random
data.

Make sure the clear the device private data on removal so that we don't
try to use it and crash later.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
https://gitlab.freedesktop.org/xorg/xserver/issues/709
2020-05-20 07:13:28 +00:00
Simon Ser 421ce458f1
xwayland: import DMA-BUFs with GBM_BO_USE_RENDERING only
Drop GBM_BO_USE_SCANOUT from the GBM_BO_IMPORT_FD import, add
GBM_BO_USE_RENDERING to the GBM_BO_IMPORT_FD_MODIFIER import.

If the DMA-BUF cannot be scanned out, gbm_bo_import with
GBM_BO_USE_SCANOUT will fail. However Xwayland doesn't need to scan-out
the buffer and can work fine without scanout. Glamor only needs
GBM_BO_USE_RENDERING.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2020-05-18 19:08:02 +02:00
Carlos Garnacho 0777cf46d7 xwayland: Improve checks for confined_to on InputOnly windows
In this pretty Wine/Proton specific kludge, we try to handle confining grabs
on InputOnly windows by trying to find the InputOutput window that the pointer
would get visually confined to.

The grabbing window and the visible window come from different clients, so
we used to simply resort to the pointer focus. This is troublesome though, as
the call may happen very soon at a time that the toplevel wasn't yet mapped by
the Wayland compositor, so the pointer focus may well be out of date soon.

In these situations, it does seem that even though the confining grab happens
too early to have the wayland surface mapped, the xserver view of the WindowPtr
does already reflect the size. Use this to find out the better window to
assign the confining grab to, one whose geometry fully contains the InputOnly
window's.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-05-13 09:19:48 +00:00
Olivier Fourdan f486e2fdaa xwayland: Remove undeeded test
xwl_seat_maybe_lock_on_hidden_cursor() checks that the value of
cursor_confinement_window is not NULL, yet there is no code path
that could lead to this.

Remove the test for cursor_confinement_window being set, it's useless.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-12 16:37:28 +02:00
Olivier Fourdan baa8d12e46 xwayland: Lock on entering surface if needed
When an X11 client issues a ConfinePointer wit ha hidden cursor,
Xwayland may translate that as a pointer lock.

However, if the pointer is located on another window at the time,
the request may be ignored, even if the pointer later enters the window.

To avoid that issue, check again if locking the pointer with a hidden
cursor is needed when pointer enters a surface.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-12 16:37:28 +02:00
Olivier Fourdan 1345f804a8 xwayland: confine motion events to the confined window
When an X11 client has an active grab on the pointer, all events are
reported relative to the window with the grab.

For Xwayland, if an X11 client has a grab with a pointer confinement
active, while pointer focus is on another window, motion events should
not be reported to the client with the grab, because that sets the X11
client appart, the events would be reported when the pointer is on any
X11 window but not on Wayland native surfaces.

Therefore, if the pointer is confined on a window and that window
differs from the actual pointer focus window, just pretend we lost
pointer focus to another window.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/962
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-12 16:37:28 +02:00
Olivier Fourdan 5929b789f9 xwayland: Do not lock the pointer on the wrong window
If a client issues a grab on the pointer while the cursor is on another
X11 window, and then hides the cursor, we may end up locking the pointer
onto that other window.

Then a button click might end up moving the focus away from the window
which issued the grab, leaving the whole setup in a mixed up state.

Typically, if the pointer is on another X11 window, we should not try to
lock the pointer, so that it can be moved back to the window which
actually issues the grab (and hence the pointer confinement). Typically,
this is the same as an X11 client issuing a pointer grab while the
cursor is on another Wayland native window.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/962
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-12 16:37:28 +02:00
Alan Coopersmith a5151f58cf Update URL's in man pages
Mostly http->https conversions, but also replaces gitweb.fd.o
with gitlab.fd.o, and xquartz.macosforge.org with xquartz.org.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-05-10 17:46:33 -07:00
Christopher Chavez 462beb5338 XQuartz: recognize F16-F20 and Menu keys
Signed-off-by: Christopher Chavez <chrischavez@gmx.us>
2020-05-07 22:19:50 +00:00
Alexander Volkov 9937183e4b Fix build with gcc 9.3.0's -Werror=alloc-size-larger-than= 2020-05-01 20:02:29 +00:00
Tobias Stoeckmann 9890e91265 hw/xfree86: Support ACPI without APM.
On systems with ACPI but disabled APM (e.g. --disable-linux-apm)
the code does not compile due to preprocessor directives.

If APM is disabled, the final return statement is considered to
be part of ACPI's last if-statement, leading to a function which
has no final return statement at all.

I have refactored the code so ACPI and APM are independent of each
other.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2020-04-30 18:45:35 +00:00
Olivier Fourdan 785e59060c xwayland: Fix infinite loop at startup
Mutter recently added headless tests, and when running those tests the
Wayland compositor runs for a very short time.

Xwayland is spawned by the Wayland compositor and upon startup will
query the various Wayland protocol supported by the compositor.

To do so, it will do a roundtrip to the Wayland server waiting for
events it expects.

If the Wayland compositor terminates before Xwayland has got the replies
it expects, it will loop indefinitely calling `wl_display_roundtrip()`
continuously.

To avoid that issue, add a new `xwl_screen_roundtrip()` that checks for
the returned value from `wl_display_roundtrip()` and fails if it is
negative.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2020-04-27 11:42:13 +02:00
Jon Turney 2fe13a1f44 hw/xwin: Drop call to setlocale()
Since we now only work with UTF-8 (or ISO8859-1) text in the clipboard,
we don't need to setlocale().
2020-04-15 14:13:58 +00:00
Jon Turney f269e01e1a hw/xwin: Consistently use BOOL type from Xmd.h
This avoids including Xdefs.h, which means we avoid all the issues with
_XSERVER64 effecting how types are defined by that.
2020-04-15 14:13:58 +00:00
Jon Turney 4055fed1e7 hw/xwin: Remove XSetAuthorization() for helper clients
All helper client code now uses xcb, so calling XSetAuthorization() is
no longer needed.

This is the last reference to libX11 from helper clients, so linking
with x11-xcb and libX11 is no longer required.

Also drop (unneeded?) linking with libXau.

Also drop installing these prerequistes on AppvVeyor.

Also move prototypes for functions in winauth.c from win.h into a new
header, winauth.h, and include that where needed.
2020-04-15 14:13:58 +00:00
Jon Turney 9e02e023b0 hw/xwin: xcbify clipboard integration
Convert clipboard integration code from libX11 to xcb

This drops support for COMPOUND_TEXT.  Presumably some ancient
(pre-2000) clients exist which support that, but not UTF8_STRING, but we
don't have an example to test with. (Given the nature of the thing, the
users of those clients probably work in CJK languages)

Supporting COMPOUND_TEXT would also involve writing (or extracting from
Xlib) support for the ISO 2022 encoding.

v2:
Fix the length of text property set by a SelectionRequest

The length of the text property is not neccessarily the same as the
length of the clipboard text before it is d2u converted (specifically,
if that contains any '\r\n' sequences, it will be shorter as they are
now just '\n')
2020-04-15 14:13:58 +00:00
Jon Turney f4936de73c hw/xwin: Remove nounicodeclipboard option
Always use CF_UNICODETEXT clipboard format.  Windows will automatically
down-convert to CF_TEXT for clients which request that.

This is subtly different in one way: if CF_TEXT is requested, we now
post CF_UNICODETEXT and it is converted to CF_TEXT *in the locale of the
requesting process*.  Previously, we would convert to CF_TEXT *in our
locale* and post that.

It looks like the code in the !X_HAVE_UTF8_STRING case didn't actually
work correctly, but fortunately that has never been true...
2020-04-15 14:13:58 +00:00
Jon Turney 9f51dfdec3 hw/xwin: Remove support for pre-Vista Win32 clipboard API
The original Win32 clipboard API is widely regarded as terrible, since
it relies on clients co-operatively managing the clipboard viewer chain,
and a single buggy client can break it for all other clients.

The last Windows version only supporting that API was Windows XP (5.1),
EOLed in 2014.

(This requires MinGW-w64 w32api 6.0.0 or later for
Add/RemoveClipboardListener correctly exported by the x86_64 user32
implib)
2020-04-15 14:13:58 +00:00
Jon Turney 9a4b62798b hw/xwin: Fix lingering uses of libX11 types and values 2020-04-15 14:13:58 +00:00
Jon Turney d7010cd93a hw/xwin: Warn about too large Windows -> X clipboard pastes
XChangeProperty() requests larger than the ~16MB permitted even with
BigReq will fail BadLength
2020-04-15 14:13:58 +00:00
Jon Turney 56a91f2067 hw/xwin: Implement INCR protocol for X clipboard -> Windows clipboard
Also, relax the timeout mechanism so it allows 1 second between events,
rather than 1 second for the entire transfer, as transfers of large
pastes can take more than 1 second.

Also, prefer UTF8_STRING encoding to COMPOUND_TEXT encoding
2020-04-15 14:13:58 +00:00
Michael Stapelberg 4f95d87d66 Xorg: honor AutoRepeat option
This option was implemented before the drivers were split in ≈2006,
and e.g. XWin still supports it.

With this commit, Xorg regains support, so that the following configuration can
be used to set the repeat rate for all keyboard devices without having to modify
Xorg command-line flags or having to automate xset(1):

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "de"
        Option "XkbVariant" "neo"
	Option "AutoRepeat" "250 30"
EndSection

Signed-off-by: Michael Stapelberg <stapelberg@google.com>
2020-04-10 16:38:17 +02:00
Michel Dänzer 5e91587302 xwayland: Delete all frame_callback_list nodes in xwl_unrealize_window
We were only calling xwl_present_unrealize_window for the toplevel
window, but the list can contain entries from child windows as well,
in which case we were leaving dangling pointers to freed memory.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/1000
Fixes: c5067feaee "xwayland: Use single frame callback for Present
                     flips and normal updates"
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
2020-03-17 11:45:22 +01:00
Yuriy Vasilev 5b9010fa6b modesetting: add support for GBM_FORMAT_ARGB1555
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Yuriy Vasilev <uuvasiliev@yandex.ru>
2020-03-13 16:42:30 -04:00
Yuriy Vasilev 8315fc4ea2 modesetting: add support for GBM_FORMAT_RGB565
This allow x-server to run with -depth 16.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Yuriy Vasilev <uuvasiliev@yandex.ru>
2020-03-13 16:42:06 -04:00
mntmn 3d6efc4aaf xwayland: port rooted xwayland from wl_shell to xdg-shell protocol
Recently, rooted Xwayland crashes on wlroots-based compositors, because
wlroots removed the deprecated wl_shell protocol.
This MR fixes this by changing the code in question to the xdg-shell
protocol. My motivation do this: on etnaviv-based embedded platforms,
rooted Xwayland is much faster and doesn't cause UI rendering bugs
compared to rootless Xwayland.

Signed-off-by: Lukas F. Hartmann <lukas@mntre.com>
2020-02-28 16:23:58 +00:00
Hans de Goede d4faab8708 xwayland: Remove unnecessary xwl_window_is_toplevel() check from xwl_output_set_window_randr_emu_props()
Since the recent fix to call xwl_output_set_window_randr_emu_props() from
ensure_surface_for_window(), it is now only called on a toplevel window,
so the is-toplevel check is not necessary for the
xwl_output_set_window_randr_emu_props() case.

This commit moves the check to xwl_output_set_randr_emu_prop_callback()
so that we only do it when we are walking over all Windows of a client
to update the property on a change of the emulated resolution.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:05:18 +01:00
Hans de Goede 148f428dfc xwayland: Fix setting of _XWAYLAND_RANDR_EMU_MONITOR_RECTS prop on new windows
For window-manager managed windows, xwl_realize_window is only called for
the window-manager's decoration window and not for the actual client window
on which we should set the _XWAYLAND_RANDR_EMU_MONITOR_RECTS prop.

Usualy this is not a problem since we walk all client windows to update
the property when the resolution is changed through a randr call.

But for apps which first do the randr change and only then create their
window this does not work, and our xwl_output_set_window_randr_emu_props
call in xwl_realize_window is a no-op as that is only called for the wm
decoration window and not for the actual client's window.

This commit fixes this by making ensure_surface_for_window() call
xwl_output_set_window_randr_emu_props on the first and only child of
window-manager managed windows.

Note this also removes the non-functional xwl_output_set_window_randr_emu_props
call from xwl_realize_window, which was intended to do this, but does not
work.

This fixes apps using the ogre3d library always running at the
monitors native resolution.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:05:15 +01:00
Hans de Goede 4cfc2677f5 xwayland: Call xwl_window_check_resolution_change_emulation() on newly created O-R windows
Some clients, which use vidmode to change the resolution when going fullscreen,
create an override-redirect window and never trigger the screen->ResizeWindow
callback we rely on to do the xwl_window_check_resolution_change_emulation().

This causes us to not apply a viewport to them, causing the fullscreen window
to not fill the entire monitor.

This commit adds a call to xwl_window_check_resolution_change_emulation()
at the end of ensure_surface_for_window() to fix this. Note that
ensure_surface_for_window() exits early without creating an xwl_window
for new windows which will not be backed by a wayland surface and which
thus will not have an xwl_window.

This fixes ClanLib-0.6.x and alleggl-4.4.x using apps not properly
fullscreening.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:05:11 +01:00
Hans de Goede 88342353de xwayland: Fix emulated modes not being removed when screen rotation is used
The code building the mode-list does the following to deal with screen
rotation:

    if (need_rotate || xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180)) {
        mode_width = xwl_output->width;
        mode_height = xwl_output->height;
    } else {
        mode_width = xwl_output->height;
        mode_height = xwl_output->width;
    }

This means we need to do something similar in xwl_output_set_emulated_mode()
to determine if the mode being set is the actual (not-emulated) output mode
and we this should remove any emulated modes set by the client.

All callers of xwl_output_set_emulated_mode always pass a mode pointer
to a member of xwl_output->randr_output->modes, so we do not need to
duplicate this code, instead we can simply check that the passed in mode
is modes[0] which always is the actual output mode.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:05:08 +01:00
Hans de Goede 10df0437a2 xwayland: Also hook screen's MoveWindow method
Not only hook the ResizeWindow method of the screen (which really is
MoveAndResize) but also hook the MoveWindow method for checking if we
need to setup a viewport for resolution change emulation.

Our resolution change emulation check if the windows origin matches
the monitors origin and the windows origin can also be changed by just
a move without being resized.

Also checking on a move becomes esp. important when we move to checking
on changes to the top-level non-window-manager client (X11)Window instead
of on changes to the xwl_window later on in this patch series.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:05:05 +01:00
Hans de Goede 4fc107460a xwayland: Also check resolution-change-emulation when the xwl_window itself moves
The recent change to use the top-level non-window-manager Window drawable
coordinates from xwl_window_check_resolution_change_emulation() in
combination with only calling it on a resize when the top-level window
is moved breaks things with mutter/gnome-shell.

When fullscreening a X11 window, mutter moves its window-decoration Window
wrapping the top-level Window to the monitor's origin coordinates (e.g. 0x0)
last. This updates the top-level's drawable coordinates, but as the
actual MoveWindow is called on the wrapper Window and not on the toplevel
we do not call xwl_window_check_resolution_change_emulation() and we never
enable the viewport.

This commit fixes this by also calling
xwl_window_check_resolution_change_emulation() if the Window being moved
is an xwl_window itself.

Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:05:03 +01:00
Roman Gilg 6d98f840da xwayland: Check emulation on client toplevel resize
When a reparented window is resized directly check the emulation instead of
doing this only when the window manager parent window is resized, what might
never happen.

For that to work we need to make sure that we compare the current size of the
client toplevel when looking for an emulated mode.

Changes by Hans de Goede:
- Remove xwl_window x, y, width and height members as those are no longer used.
- Add check for xwl_window_from_window() returning NULL.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:05:00 +01:00
Roman Gilg 060f10062e xwayland: Make window_get_none_wm_owner return a Window instead of a Client
Make window_get_none_wm_owner return the first non-wm-window instead of the
owner (client) of the first non-wm-window and rename it to
window_get_client_toplevel to match its new behavior.

This is a preparation patch for switching to using the drawable coordinates
in xwl_window_should_enable_viewport()

Changes by Hans de Goede:
- Split this change out into a separate patch for easier reviewing
- Rename window_get_none_wm_owner to window_get_client_toplevel to match
  its new behavior

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:04:55 +01:00
Roman Gilg a69f7fbb54 xwayland: Recurse on finding the none-wm owner
An X11 window manager might add a chain of parent windows when reparenting to a
decoration window.

That is for example the case for KWin, which reparents client windows to one
decoration and another wrapper parent window.

Account for that by a recursion into the tree. For now assume as before that
all X11 window managers reparent with one child only for these parent windows.

Changes by Hans de Goede:
- Move the xwl_window_is_toplevel() from a later patch in this series here
  as it really belongs together with these changes
- Drop no longer necessary xwl_window argument from window_get_none_wm_owner
  parameters

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:04:52 +01:00
Roman Gilg 948e02872f xwayland: Reuse viewport instead of recreating
When a viewport is already created we can reuse this object instead of
destroying it and getting a new one for updating the source rectangle and
destination size.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:04:49 +01:00
Hans de Goede ded89300c1 xwayland: Cache client-id for the window-manager client
Instead of iterating over all clients which are listening for events on the
root window and checking if the client we are dealing with is the one
listening for SubstructureRedirectMask | ResizeRedirectMask events and thus
is the window-manager, cache the client-id of the window-manager in
xwl_screen and use that when checking if a client is the window-manager.

Note that we cache and compare the client-id rather then the ClienPtr,
this saves reading the ClientPtr from the global clients array when doing
the comparison.

Suggested-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2020-02-23 18:04:00 +01:00
Olivier Fourdan 4709d24f8e xwayland: Add version command line option
Xorg supports the '-version' command line option, add something similar
to Xwayland.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/976
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-02-14 17:04:44 +01:00
Zoltán Böszörményi 42aaf37241 Fix modesetting device matching through kmsdev device path
xf86platformProbeDev didn't check the device path, fix it.

This is a problem when trying to set up a non-PCI device via
explicit xorg.conf.d configuration.

An USB DisplayLink device, being non-PCI was always set up
as a GPU device assigned to screen 0 instead of a regular
framebuffer, potentially having its own dedicated screen,
despite such configuration as below. Only the relevant parts
of the configuration are quoted, it's part of a larger context
with an Intel chip that has 3 outputs:
* DP1 connected to an LCD panel,
* VGA1 connected to an external monitor,
* HDMI1 unconnected and having no user visible connector

Section "ServerFlags"
        Option          "AutoBindGPU" "false"
EndSection

...

Section "Device"
        Identifier      "Intel2"
        Driver          "intel"
        BusID           "PCI:0:2:0"
        Screen          2
        Option          "Monitor-HDMI1" "HDMI1"
        Option          "ZaphodHeads" "HDMI1"
EndSection

Section "Device"
        Identifier      "UDL"
        Driver          "modesetting"
        Option          "kmsdev" "/dev/dri/card0"
        #BusID          "usb:0:1.2:1.0"
        Option          "Monitor-DVI-I-1" "DVI-I-1"
        Option          "ShadowFB" "on"
        Option          "DoubleShadow" "on"
EndSection

...

Section "Screen"
        Identifier      "SCREEN2"
        Option          "AutoServerLayout" "on"
        Device          "UDL"
        GPUDevice       "Intel2"
        Monitor         "Monitor-DVI-I-1"
        SubSection      "Display"
                Modes   "1024x768"
                Depth   24
        EndSubSection
EndSection

Section "ServerLayout"
        Identifier      "LAYOUT"
        Option          "AutoServerLayout" "on"
        Screen          0 "SCREEN"
        Screen          1 "SCREEN1" RightOf "SCREEN"
        Screen          2 "SCREEN2" RightOf "SCREEN1"
EndSection

On the particular machine I was trying to set up an UDL device,
I found the following structure was being used to match
the device to a platform device while I was debugging the issue:

xf86_platform_devices[0] == Intel, /dev/dri/card1, primary platform device
xf86_platform_devices[1] == UDL, /dev/dri/card0

devList[0] == "Intel0", ZaphodHeads: DP1
devList[1] == "Intel1", ZaphodHeads: VGA1
devList[2] == "UDL"
devList[3] == "Intel2", ZaphodHeads: HDMI1 (intended GPU device to UDL)

When xf86platformProbeDev() matched the UDL device, the BusID
check failed in both cases of:
* BusID "usb:0:1.2:1.0" was specified
* Option "kmsdev" "/dev/dri/card0" was specified

As a result, xf86platformProbeDev() went on to call probeSingleDevice()
with xf86_platform_devices[0] and devList[2], resulting in the
UDL device being set up as a GPU device assigned to the first screen
instead of as a framebuffer on the third screen as the configuration
specified.

Checking Option "kmsdev" in code code may be a layering violation.
But the modesetting driver is actually part of the Xorg sources
instead of being an external driver, so he "kmsdev" path knowledge
may be used here.

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2020-02-12 21:29:52 +00:00
Michel Dänzer a542224ea2 xwayland: Call glamor_block_handler from xwl_screen_post_damage
In between the two phases introduced by the previous change. This makes
sure all pending drawing to the new buffers is flushed before they're
committed to the Wayland server.
2020-02-11 16:07:36 +01:00
Michel Dänzer f88d9b1f77 xwayland: Split up xwl_screen_post_damage into two phases
The first phase sets the new surface properties for all damaged
windows, then the second phase commits all surface updates.

This is preparatory for the next change, there should be no observable
change in behaviour (other than the order of Wayland protocol
requests).

Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-02-11 16:06:13 +01:00
Michel Dänzer 7b33c2d3f3 Revert "xwayland/glamor-gbm: Add xwl_glamor_gbm_post_damage hook"
This reverts commit 9e85aa9c1f.

To be replaced with a better solution.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-02-11 16:05:21 +01:00
Michel Dänzer 49553049e8 modesetting: Remove local variable only used with glamor enabled
Resulted in a build failure with -Werror:

../hw/xfree86/drivers/modesetting/drmmode_display.c: In function ‘drmmode_crtc_set_mode’:
../hw/xfree86/drivers/modesetting/drmmode_display.c:759:15: error: unused variable ‘screen’ [-Werror=unused-variable]
  759 |     ScreenPtr screen = crtc->scrn->pScreen;
      |               ^~~~~~

Fixes: c66c548eab "modesetting: Call glamor_finish from
                     drmmode_crtc_set_mode"
Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-02-11 15:58:26 +01:00
Michel Dänzer 0cb9fa7949 modesetting: Fix build with glamor disabled
Fixes: cb1b1e1847 "modesetting: Indirect the glamor API through
                     LoaderSymbol"
Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-02-10 18:41:44 +01:00
Dave Airlie 1cfdd1a965 modesetting: remove unnecessary error message, fix zaphod leases
I introduced this error with the MST hotplug code, but it can trigger
on zaphod setups, and is perfectly fine. There is no support for
MST/hotplug on zaphod setups currently, so we can just skip over
the dynamic connector handling here. However we shouldn't skip
over the lease handling so move it into the codepath.

Fixes: 9257b1252d ("modesetting: add dynamic connector hotplug support (MST) (v3)")
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2020-02-06 09:45:07 +10:00
Michel Dänzer 9e85aa9c1f xwayland/glamor-gbm: Add xwl_glamor_gbm_post_damage hook
It flushes any pending drawing to the kernel, to make sure it'll be
visible to the Wayland server.

Without this, it was possible for the Wayland server to process surface
commits before Xwayland got around to flushing the corresponding
drawing, which could result in stale or even completely random window
contents being visible.

v2:
* Make EGL backend post_damage hook mandatory, don't check for NULL in
  xwl_glamor_post_damage. (Olivier Fourdan)

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/951
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-01-31 11:15:13 +01:00
Michel Dänzer 6a5e47c57d xfree86/modes: Bail from xf86RotateRedisplay if pScreen->root is NULL
Avoids a crash in xf86RotatePrepare -> DamageRegister during
CreateScreenResources if rotation or another transform is configured for
any connected RandR output in xorg.conf. The generic rotation/transform
code generally can't work without the root window currently.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/969
Fixes: 094f42cdfe "xfree86/modes: Call xf86RotateRedisplay from
                     xf86CrtcRotate"
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-01-30 17:53:12 +01:00
Michel Dänzer 4287604425 Xephyr: Cast "red" to char* for xcb_aux_parse_color
xcb_aux_parse_color takes a non-const pointer, even though it doesn't
modify the string or take ownership of its memory.

Avoids the following warning from GCC:

../hw/kdrive/ephyr/hostx.c: In function ‘hostx_init’:
../hw/kdrive/ephyr/hostx.c:683:30: warning: passing argument 1 of ‘xcb_aux_parse_color’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  683 |     if (!xcb_aux_parse_color("red", &red, &green, &blue)) {
      |                              ^~~~~
In file included from ../hw/kdrive/ephyr/hostx.c:50:
/usr/include/xcb/xcb_aux.h:194:27: note: expected ‘char *’ but argument is of type ‘const char *’
  194 | xcb_aux_parse_color(char *color_name,
      |                     ~~~~~~^~~~~~~~~~
2020-01-28 20:35:06 +00:00
Michel Dänzer 65387391a5 loader: strdup const string assigned to local variable name
There's a free(name) at the end of the function.

GCC warned about this:

../hw/xfree86/loader/loadmod.c: In function ‘LoadModule’:
../hw/xfree86/loader/loadmod.c:702:18: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  702 |         m = name = "int10";
      |                  ^
2020-01-28 20:35:06 +00:00
David Seifert 435d41d5ff Fix building with `-fno-common`
* GCC 10 will switch the default to `-fno-common`.
  https://gcc.gnu.org/PR85678

Bug: https://bugs.gentoo.org/705880
Signed-off-by: Matt Turner <mattst88@gmail.com>
2020-01-27 21:46:31 +00:00
Michel Dänzer a24a786fc8 modesetting: Explicitly #include "mi.h"
For the miClearDrawable prototype. Apparently it doesn't get pulled in
for some build configurations, breaking the build.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2020-01-14 15:15:28 -08:00
Fabrice Fontaine 49456e0a37 hw/xfree86/common/xf86Init.c: fix build without glx
Since commit d8ec33fe05, an include on
glxvndabi.h has been added to hw/xfree86/common/xf86Init.c

However, if glx is disabled through --disable-glx and GLX headers are
not installed in the build's environment, build fails on:

In file included from xf86Init.c:81:
../../../include/glxvndabi.h:64:10: fatal error: GL/glxproto.h: No such file or directory
   64 | #include <GL/glxproto.h>
      |          ^~~~~~~~~~~~~~~

Fix this failure by removing this include which does not seem to be
needed (an other option would have been to keep it under an ifdef GLXEXT
block)

Fixes:
 - http://autobuild.buildroot.org/results/de838a843f97673d1381a55fd4e9b07164693913

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-01-08 15:55:40 +00:00
Michel Dänzer 98bfee6a1b xwayland: Include xwayland-window.h from xwayland-glamor-eglstream.c
Fixes build failure.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/954
Fixes: 89e32d00f6 "xwayland: Move Xwayland windows to its own sources"
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-01-06 15:52:35 +01:00
Aaron Plattner 4226c6d032 modesetting: Check whether RandR was initialized before calling rrGetScrPriv
Calling rrGetScrPriv when RandR isn't initialized causes an assertion
failure that aborts the server:

 Xorg: ../include/privates.h:121: dixGetPrivateAddr: Assertion `key->initialized' failed.

 Thread 1 "Xorg" received signal SIGABRT, Aborted.
 0x00007ffff78a8f25 in raise () from /usr/lib/libc.so.6
 (gdb) bt
 #0  0x00007ffff78a8f25 in raise () from /usr/lib/libc.so.6
 #1  0x00007ffff7892897 in abort () from /usr/lib/libc.so.6
 #2  0x00007ffff7892767 in __assert_fail_base.cold () from /usr/lib/libc.so.6
 #3  0x00007ffff78a1526 in __assert_fail () from /usr/lib/libc.so.6
 #4  0x00007ffff7fb57c1 in dixGetPrivateAddr (privates=0x555555ab1b60, key=0x555555855720 <rrPrivKeyRec>) at ../include/privates.h:121
 #5  0x00007ffff7fb5822 in dixGetPrivate (privates=0x555555ab1b60, key=0x555555855720 <rrPrivKeyRec>) at ../include/privates.h:136
 #6  0x00007ffff7fb586a in dixLookupPrivate (privates=0x555555ab1b60, key=0x555555855720 <rrPrivKeyRec>) at ../include/privates.h:166
 #7  0x00007ffff7fb8445 in CreateScreenResources (pScreen=0x555555ab1790) at ../hw/xfree86/drivers/modesetting/driver.c:1335
 #8  0x000055555576c5e4 in xf86CrtcCreateScreenResources (screen=0x555555ab1790) at ../hw/xfree86/modes/xf86Crtc.c:744
 #9  0x00005555555d8bb6 in dix_main (argc=4, argv=0x7fffffffead8, envp=0x7fffffffeb00) at ../dix/main.c:214
 #10 0x00005555557a4f0b in main (argc=4, argv=0x7fffffffead8, envp=0x7fffffffeb00) at ../dix/stubmain.c:34

This can happen, for example, if the server is configured with Xinerama
and there is more than one X screen:

 Section "ServerLayout"
   Identifier "crash"
   Screen 0 "modesetting"
   Screen 1 "dummy" RightOf "modesetting"
   Option "Xinerama"
 EndSection

 Section "Device"
   Identifier "modesetting"
   Driver "modesetting"
 EndSection

 Section "Screen"
   Identifier "modesetting"
   Device "modesetting"
 EndSection

 Section "Device"
   Identifier "dummy"
   Driver "dummy"
 EndSection

 Section "Screen"
   Identifier "dummy"
   Device "dummy"
 EndSection

The problem does not reproduce if there is only one X screen because of
this code in xf86RandR12Init:

 #ifdef PANORAMIX
     /* XXX disable RandR when using Xinerama */
     if (!noPanoramiXExtension) {
         if (xf86NumScreens == 1)
             noPanoramiXExtension = TRUE;
         else
             return TRUE;
     }
 #endif

Fix the problem by checking dixPrivateKeyRegistered(rrPrivKey) before
calling rrGetScrPriv. This is similar to what the xf86-video-amdgpu
driver does:
fd66f5c0be/src/amdgpu_kms.c (L388)

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-01-03 08:39:21 -08:00
Alex Goins 456dff1bf8 modesetting: Fix msSharePixmapBacking Segfault Regression
Commit cb1b1e184 modified msSharePixmapBacking() to derive modesettingPtr from
the 'screen' argument. Unfortunately, the name of the argument is misleading --
the screen is the slave screen. If the master is modesetting,
and the slave is not modesetting, it will segfault.

To fix the problem, this change derives modesettingPtr from
ppix->drawable.pScreen. This method is already used when calling
ms->glamor.shareable_fd_from_pixmap() later in the function.

To avoid future issues, this change also renames the 'screen' argument to
'slave'.

Signed-off-by: Alex Goins <agoins@nvidia.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-23 08:56:22 -08:00
Olivier Fourdan 58155baeac xwayland: Cleanup and remove `xwayland.h`
Now that each source and header should be in order, we can safely cleaup
the last remaining bits from the main `xwayland.h` which is not needed
anymore and can be removed.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan c830bd847f xwayland: Remove `MODIFIER_META` definition
It's nowhere to be used.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 4c644fd792 xwayland: Move Xwayland GLX declaration
Move the Xwayland GLX declaration to its own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 808a0a038b xwayland: Move Xwayland vidmode declaration
Move the Xwayland vidmode declaration to its own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan e8ba8a94e1 xwayland: Move Xwayland CVT declaration
Move the Xwayland CVT declaration to its own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 0617c635fa xwayland: Separate Xwayland screen code
Move Xwayland screen related code to a separate source file and header.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 211609a938 xwayland: Move Xwayland cursor declarations
Move the Xwayland cursor declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan aaeeb10b74 xwayland: Move Xwayland output declarations
Move the Xwayland output declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 091b24f13e xwayland: Move Xwayland input declarations
Move the Xwayland input declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan e23d2223d8 xwayland: Move Xwayland present declarations
Move the Xwayland Present declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan d780bdc2fd xwayland: Separate Xwayland pixmap code
Move Xwayland generic pixmap code to a separate source file and header.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 89e32d00f6 xwayland: Move Xwayland windows to its own sources
Over time, Xwayland main source file `xwayland.c` has grown in size
which makes it look cluttered and harder to read.

Move the code dealing with Xwayland window to its own source and header
files.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 3a59650ba7 xwayland: Move GLAMOR declarations to their own header
Currently, `xwayland.h` contains all the declarations, which is a bit
awkward and hard to follow.

Move the GLAMOR relevant declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan 177c8a2302 xwayland: Move SHM declarations to their own header
Currently, `xwayland.h` contains all the declarations, which is a bit
awkward and hard to follow.

Move the SHM relevant declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Olivier Fourdan c20e61fddc xwayland: Move Xwayland structures to their own header
Currently, `xwayland.h` contains all the declarations, which is a bit
awkward and hard to follow.

Move the Xwayland structures declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00
Michel Dänzer 846e81ecb8 xwayland: Create duplicate TrueColor GLXFBConfigs for Composite
Similar to what is done in Xorg. Not doing this prevented apps from
using GLX with a Composite visual, e.g. Firefox WebRender or Chromium.

v2:
* Fix inverted direct_color test, fixes Chromium as well.
* Drop Composite extension guards, since other Xwayland code calls
  compRedirectWindow/compUnredirectWindow unconditionally anyway.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/921
Fixes: 8469241592 "xwayland: Add EGL-backed GLX provider"
Reviewed-by: Adam Jackson <ajax@redhat.com> # v1
2019-12-19 11:35:19 +01:00
Michel Dänzer 02e7a497ce xwayland: Fix duplicate "direct_color" comment to say "double_buffer"
Fixes: 8469241592 "xwayland: Add EGL-backed GLX provider"
Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-12-17 18:43:07 +01:00
Michel Dänzer 9b31358c52 xwayland: Use frame callbacks for Present vblank events
Instead of only the fallback timer.

Fixes https://gitlab.freedesktop.org/xorg/xserver/issues/854

v2:
* Drop unused frame_callback member of struct xwl_present_window
  (Olivier Fourdan)

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2019-12-17 10:31:22 +01:00
Michel Dänzer c5067feaee xwayland: Use single frame callback for Present flips and normal updates
Using a list of Present windows that need to be called back.

This prepares for the following change, there should be no change in
observed behaviour.

v2:
* Use xwl_window_create_frame_callback instead of making the
  frame_listener struct non-static (Olivier Fourdan)

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2019-12-17 10:28:33 +01:00
Michel Dänzer f80eea0529 xwayland: Add xwl_window_create_frame_callback helper
This will be used by the following changes. No functional change
intended.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2019-12-13 18:26:35 +01:00
Olivier Fourdan 46e5236bbe xwayland: Take border width into account
Damage coordinates are relative to the drawable, (0,0) being the top
left corner inside the border.

Therefore, when applying damages or accumulating damages between window
buffers, we need to take the window border width into account as well,
otherwise the updates might be only partial or misplaced.

Related: https://gitlab.freedesktop.org/xorg/xserver/issues/951
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-13 16:11:09 +01:00
Olivier Fourdan 1cb886bc2a xwayland: Recycle window buffers when setting pixmap
Right now, we would recycle the window buffers whenever the window the
window is resized.

This, however, is not sufficient to guarantee that the buffers are up
to date, since changing the window border width for example would not
trigger a `WindowResize` (the border being outside the window).

Make sure we recycle the buffers on `SetWindowPixmap` to ensure that
the buffers will be recycled whenever the pixmap size is changed.

Related: https://gitlab.freedesktop.org/xorg/xserver/issues/951
Suggested-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-13 16:11:09 +01:00
dslater38 71c3a97142 XWin: Fix infinite loop in GetShift()
GetShift(int mask) can be called with mask==0, causing
it to go into an infinite loop.

Note: GetShift(mask) will return 0 for a mask of
both 0 and -1. The assumption is that if mask == 0,
then the corresponding bits for which we're calculating
the shift, are also 0.
2019-12-12 04:54:46 +00:00
Michel Dänzer 2a2234ad1a xwayland: Do flush GPU work in xwl_present_flush
The Present code sends the idle notification event to the client after
xwl_present_flush returns. If we don't flush our GPU work here, the
client may race to draw another frame to the same buffer, so we may end
up copying (parts of) that new frame instead of the one we meant to.

Fixes https://gitlab.freedesktop.org/xorg/xserver/issues/835

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2019-12-03 18:24:34 +01:00
Olivier Fourdan cd999f08c6 xwayland: Use multiple window buffers
Xwayland takes care of not attaching a new buffer if a frame callback is
pending.

Yet, the existing buffer (which was previously attached) may still be
updated from the X11 side, causing unexpected visual glitches to the
buffer.

Add multiple buffering to the xwl_window and alternate between buffers,
to leave the Wayland buffer untouched between frame callbacks and avoid
stuttering or tearing issues.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/835
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-28 17:32:44 +01:00
Olivier Fourdan 1c6f875f52 xwayland: Add multiple window buffering support
Add a mechanism to create, recycle and destroy window buffers when
needed.

Typically, this adds a new `xwl_window_buffer` structure which
represents a buffer for a given Xwayland window.

Each Xwayland window has two different pools of buffers:

 - The available buffers pool:
   Those are buffers which where created previously and that have either
   not been submitted to the compositor or submitted and released.

 - The unavailable buffers pool:
   Those are typically the buffers which are being used by the
   compositor, awaiting a release.

Initially, an Xwayland window starts with both pools empty. As soon as a
new buffer is needed, it's either created (if there is none available)
or picked from the pool of available buffers.

Once submitted to the compositor, the buffer is moved to the pool of
unavailable buffers. When the corresponding `wl_buffer` is released by
the compositor, it is moved back to pool of available buffers again to
be reused when needed.

To avoid keeping too many buffers around doing nothing, a garbage
collection of older, unused buffers also takes care of disposing the
buffers being unused for some time.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-28 17:32:44 +01:00
Olivier Fourdan 7765874186 xwayland: Add buffer release callback
The API `wl_buffer_add_listener` is misleading in the sense that there
can be only one `wl_buffer` release callback, and trying to add a new
listener when once is already in place will lead to a protocol error.

The Xwayland EGL backends may need to set up their own `wl_buffer`
release listener, meaning that there is no way to our own `wl_buffer`
release callback.

To avoid the problem, add our own callback API to be notified when the
`wl_buffer` associated with an `xwl_pixmap` is released, triggered from
the different `xwl_pixmap` implementations.

Also update the Present code to use the new buffer release callback API.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-28 17:32:44 +01:00
Kenneth Graunke 8d4be7f6c4 modesetting: Use EGL_MESA_query_driver to select DRI driver if possible
New now ask Glamor to use EGL_MESA_query_driver to obtain the DRI driver
name; if successful, we use that as the DRI driver name.  Following the
existing dri2.c logic, we also use the same name for the VDPAU driver,
except for i965 (and now iris), where we switch to the "va_gl" fallback.

This allows us to bypass the PCI ID lists in xserver and centralize the
driver selection mechanism inside Mesa.  The hope is that we no longer
have to update these lists for any future hardware.
2019-11-26 01:36:10 -08:00
Michel Dänzer 60003023fa modesetting: Use glamor_clear_pixmap in drmmode_clear_pixmap
Should be slightly more efficient.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-11-25 18:47:37 +01:00
Michel Dänzer 9ba13bac9d modesetting: Clear new screen pixmap storage on RandR resize
Fixes random garbage being visible intermittently.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-11-25 18:46:56 +01:00
Michel Dänzer 327df450ff xfree86/modes: Call xf86RotateRedisplay from xf86CrtcRotate
If a new rotate buffer was allocated. This makes sure the new buffer
has valid transformed contents when it starts being displayed.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-11-25 18:46:31 +01:00
Michel Dänzer c66c548eab modesetting: Call glamor_finish from drmmode_crtc_set_mode
This makes sure any pending drawing to a new scanout buffer will be
visible from the start.

This makes the finish call in drmmode_copy_fb superfluous, so remove it.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-11-25 18:46:04 +01:00
Michel Dänzer 06ef320e9b modesetting: Add glamor_finish() convenience macro
This will simplify backporting the following fix to the 1.20 branch.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-11-25 18:44:57 +01:00
Matt Turner e6ab7f9f34 xfree86: Test presence of isastream()
isastream() was never more than a stub in glibc, and was removed in
glibc-2.30 by commit a0a0dc83173c ("Remove obsolete, never-implemented
XSI STREAMS declarations").

Bug: https://bugs.gentoo.org/700838
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2019-11-22 15:22:43 -05:00
Adam Jackson cb1b1e1847 Revert "Revert "modesetting: Indirect the glamor API through LoaderSymbol""
Now that we've fixed LoaderSymbolFromModule this should work properly.

This reverts commit 5c7c6d5cff.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-21 14:20:57 -05:00
Adam Jackson ab61c16ef0 loader: Make LoaderSymbolFromModule take a ModuleDescPtr
The thing you get back from xf86LoadSubModule is a ModuleDescPtr, not a
dlsym handle. We don't expose ModuleDescPtr to the drivers, so change
LoaderSymbolFromModule to cast its void * argument to a ModuleDescPtr.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-21 14:20:50 -05:00
Olivier Fourdan 66da95a172 xwayland: Do not discard frame callbacks on allow commits
Currently, when a X11 client (usually the X11 window manager from a
Wayland compositor) changes the value of the X11 property
`_XWAYLAND_ALLOW_COMMITS` from `false` to `true`, all pending frame
callbacks on the window are discarded so that the commit occurs
immediately.

Weston uses that mechanism to prevent the content of the window from
showing before it's ready when mapping the window initially, but
discarding the pending frame callbacks has no effect on the initial
mapping of the X11 window since at that point there cannot be any frame
callback on a surface which hasn't been committed yet anyway.

However, discarding pending frame callbacks can be problematic if we
were to use the same `_XWAYLAND_ALLOW_COMMITS` mechanism to prevent
damages to be posted before the X11 toplevel is updated completely
(including the window decorations from the X11 window manager).

Remove the portion of code discarding the pending frame callback,
Xwayland should always wait for a pending frame callback if there's one
before posting new damages.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/333
2019-11-19 09:56:10 +00:00
Michel Dänzer 5c7c6d5cff Revert "modesetting: Indirect the glamor API through LoaderSymbol"
This reverts commit dd63f717fe.

Caused a crash at least on some systems.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/934
2019-11-15 11:32:38 +01:00
Adam Jackson dd63f717fe modesetting: Indirect the glamor API through LoaderSymbol
Prerequisite for building all of xserver with -z now.

Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692
2019-11-13 19:49:18 +00:00