Commit Graph

8544 Commits

Author SHA1 Message Date
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
Adam Jackson 45f35a0c66 modesetting: Indirect the shadow 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
Adam Jackson 8760fab0a1 loader: Move LoaderSymbolFromModule() to public API
Bare LoaderSymbol() isn't really a great API, this is more of a direct
map to dlsym like you want.

Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692
2019-11-13 19:49:18 +00:00
Aaron Plattner e5e9a8ca91 xfree86: Call ScreenInit for protocol screens before GPU screens
During startup, the xfree86 DDX's InitOutput() calls PreInit for
protocol screens first, and then GPU screens. On teardown, dix_main()
calls CloseScreen in the reverse order: GPU screens first starting with
the last one and then working backwards, and then protocol screens also
in reverse order.

InitOutput() calls ScreenInit in the wrong order: for GPU screens first and then
for protocol screens. This causes a problem for drivers that have global state
that is tied to the first screen that calls ScreenInit.

Fix this by simply re-ordering the for loops to call PreInit for
protocol screens first and then for GPU screens second.
2019-11-13 17:29:34 +00:00
Alex Goins 562c7888be modesetting: Implement ms_covering_randr_crtc() for ms_present_get_crtc()
ms_present_get_crtc() returns an RRCrtcPtr, but derives it from a xf86CrtcPtr
found via ms_dri2_crtc_covering_drawable()=>ms_covering_crtc(). As a result, it
depends on all associated DIX ScreenRecs having an xf86CrtcConfigPtr DDX
private.

Some DIX ScreenRecs don't have an xf86CrtcConfigPtr DDX private, but do have an
rrScrPrivPtr DDX private. Given that we can derive all of the information we
need from RandR, we can support these screens by avoiding the use of xf86Crtc.
This change implements an RandR-based path for ms_present_get_crtc(), allowing
drawables to successfully fall back to syncing to the primary output, even if
the slave doesn't have an xf86CrtcConfigPtr DDX private.

Without this change, if a slave doesn't have an xf86CrtcConfigPtr DDX private,
drawables will fall back to 1 FPS if they overlap an output on that slave.

Signed-off-by: Alex Goins <agoins@nvidia.com>
2019-11-11 14:35:57 -08:00
Alex Goins 797e7a0ceb modesetting: Fix ms_covering_crtc() segfault with non-xf86Crtc slave
DIX ScreenRecs don't necessarily have an xf86CrtcConfigPtr DDX private.
ms_covering_crtc() assumes that they do, which can result in a segfault.

Update ms_covering_crtc() to check the XF86_CRTC_CONFIG_PTR() returned pointer
before dereferencing it. This will still mean that ms_covering_crtc() can't fall
back to the primary output when a drawable overlaps a slave output (going to the
1 FPS default instead), but it won't segfault.

Signed-off-by: Alex Goins <agoins@nvidia.com>
2019-11-11 14:35:57 -08:00
Alex Goins 3ef9029ace modesetting: Fix ms_covering_crtc() segfault with non-modesetting slave primary
ms_covering_crtc() uses RRFirstOutput() to determine a primary output to fall
back to if a drawable is overlapping a slave output.

If the primary output is a slave output, RRFirstOutput() will return a slave
output even if passed a master ScreenPtr. ms_covering_crtc() dereferences the
output's devPrivate, which is invalid for non-modesetting outputs, and can
crash.

Changing RRFirstOutput() could have unintended side effects for other callers,
so this change replaces the call to RRFirstOutput() with ms_first_output().
ms_first_output() ignores the primary output if it doesn't match the given
ScreenPtr, choosing the first connected output instead.

Signed-off-by: Alex Goins <agoins@nvidia.com>
2019-11-11 14:35:57 -08:00
Olivier Fourdan eddad048e3 xwayland: Cosmetic, fix indentation
For some reason, indentation for EGL backend hooks was broken.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-08 10:54:55 +01:00
Olivier Fourdan 4a857b161c xwayland/shm: Use `calloc()`
Currently, Xwayland pixmap SHM code uses `malloc()` to allocate the
xwl_pixmap.

Use `calloc()` instead, as the EGLstream backend does, as it is safer
(initializing the allocated data to 0).

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-08 10:54:52 +01:00
Olivier Fourdan 0d4667b65a xwayland/glamor-gbm: Use `calloc()`
Currently, glamor GBM backend uses `malloc()` to allocate the
xwl_pixmap.

Use `calloc()` instead, as the EGLstream backend does, as it is safer
(initializing the allocated data to 0).

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-08 10:54:48 +01:00
Olivier Fourdan 2c5acdef3a xwayland/eglstream: Fix order of `calloc()` args
The definition by the manual is `calloc(size_t nmemb, size_t size)`.

Swap the arguments of calloc() calls to match the definition.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-08 10:54:44 +01:00
Dor Askayo 0e9a0c203c xwayland: clear pixmaps after creation in rootless mode
When a pixmap is created with a backing FBO, the FBO should be cleared
to avoid rendering uninitialized memory. This could happen when the
pixmap is rendered without being filled in its entirety.

One example is when a top-level window without a background is
resized. The pixmap would be reallocated to prepare for more pixels,
but uninitialized memory would be rendered in the resize offset until
the client sends a frame that fills these additional pixels.

Another example is when a new top-level window is created without a
background. Uninitialized memory would be rendered after the pixmap is
allocated and before the client sends its first frame.

This issue is only apparent in OpenGL implementations that don't zero
the VRAM of allocated buffers by default, such as RadeonSI.

Signed-off-by: Dor Askayo <dor.askayo@gmail.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/636
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-07 12:25:42 +01:00
Olivier Fourdan a506b4ecb6 xwayland: make context current to check GL version
`glGetString(GL_VERSION)` will return NULL without a current context.

Commit dabc7d8b (“xwayland: Fall back to GLES2 if we don't get at least
GL 2.1 in glamor”) would check the context is created, but it is made
current just after, so the call to `epoxy_gl_version()` would return 0,
hence defeating the version check.

Make the context current prior to call `epoxy_gl_version()`.

Fixes: dabc7d8b - xwayland: Fall back to GLES2 if we don't get at least
                  GL 2.1 in glamor
Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/932
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/324
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2019-11-06 16:01:45 +01:00
Adam Jackson dabc7d8bf2 xwayland: Fall back to GLES2 if we don't get at least GL 2.1 in glamor
Some particularly unfortunate hardware (Intel gen3, mostly) will give
you GLES2 but not GL 2.1. Fall back to GLES2 for such cases so you still
get accelerated GLX.
2019-11-05 15:57:17 +00:00
Hans de Goede 741bd73429 glamor/xwayland: Define EGL_NO_X11
Define EGL_NO_X11 everywhere were we also define MESA_EGL_NO_X11_HEADERS,
EGL_NO_X11 is the MESA_EGL_NO_X11_HEADERS equivalent for the egl headers
shipped with libglvnd.

This fixes the xserver not building with the libglvnd-1.2.0 headers:

In file included from /usr/include/EGL/eglplatform.h:128,
                 from /usr/include/epoxy/egl_generated.h:11,
                 from /usr/include/epoxy/egl.h:46,
                 from glamor_priv.h:43,
                 from glamor_composite_glyphs.c:25:
/usr/include/X11/Xlib.h:222:2: error: conflicting types for 'GC'
  222 | *GC;
      |  ^~
In file included from glamor.h:34,
                 from glamor_priv.h:32,
                 from glamor_composite_glyphs.c:25:
../include/gcstruct.h:282:3: note: previous declaration of 'GC' was here
  282 | } GC;
      |   ^~

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-11-04 20:49:33 +01:00
Adam Jackson ff310903f3 mi: Add a default no-op miSourceValidate
Slightly simplifies the callers since they don't need to check for
non-NULL anymore.

I do extremely hate the workarounds here to suppress misprite taking the
cursor down though. Surely there's a better way.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-10-30 16:26:01 +00:00
Adam Jackson 89a9927b1e include: Remove now-empty site.h 2019-10-30 16:17:04 +00:00
Adam Jackson fc671085ee dmx: Stop overriding the vendor string 2019-10-30 16:17:04 +00:00
Ville Syrjälä 0e4bd71d02 modesetting: Fix possible_crtcs
Populate outout possible_crtcs as the union of possible_crtcs from
the encoders rather than the intersection. Otherwise we're easily left
with possible_crtcs==0 when all the possible encoders have
non-overlapping possible_crtcs.

No idea what the magic 0x7f is about, but keep it around in case
it matters.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-10-29 22:14:06 +00:00
Jon Turney a1e3dfa50a xquartz: Remove trailing quote to fix build
Fix xquartz build after typo in 3c78d637 ("global: Remove BUILD_DATE and
BUILD_TIME")
2019-10-26 19:29:01 +01:00
Keith Packard 0cf15714e1 modesetting: typo in drmmode_display.c -- ',' instead of ';' at end of line
This seems like a simple typo to me; thanks to C it isn't caught by
the compiler.

Signed-off-by: Keith Packard <keithp@keithp.com>
2019-10-23 14:16:30 -07:00
Robert Mader 427f8bc009 xserver: Fix a typo
If `need_rotate` is TRUE, we should check for the right rotate.
2019-10-16 18:57:31 +00:00
Michel Dänzer 535f14656a Revert https://gitlab.freedesktop.org/xorg/xserver/merge_requests/235
Caused assertion failures / crashes with Xorg.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/916
2019-10-14 12:48:24 +02:00
Hans de Goede 5315f988d9 xwayland: Set _XWAYLAND_RANDR_EMU_MONITOR_RECTS property for resolution emulation
Apps using randr to change the resolution when going fullscreen, in
combination with _NET_WM_STATE_FULLSCREEN to tell the window-manager (WM)
to make their window fullscreen, expect the WM to give the fullscreen window
the size of the emulated resolution as would happen when run under Xorg (*).

We need the WM to emulate this behavior for these apps to work correctly,
with Xwaylands resolution change emulation. For the WM to emulate this,
it needs to know about the emulated resolution for the Windows owning
client for each monitor.

This commit adds a _XWAYLAND_RANDR_EMU_MONITOR_RECTS property, which
contains 4 Cardinals (32 bit integers) per monitor with resolution
emulation info. Window-managers can use this to get the emulated
resolution for the client and size the window correctly.

*) Since under Xorg the resolution will actually be changed and after that
going fullscreen through NET_WM_STATE_FULLSCREEN will size the window to
be equal to the new resolution.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede 0c305dbff8 xwayland: xwl_window_should_enable_viewport: Add extra test
Games based on the allegro gaming library or on ClanLib-1.0 do not size
their window to match the fullscreen resolution, instead they use a
window covering the entire screen, drawing only the fullscreen resolution
part of it.

This commit adds a check for these games, so that we correctly apply a
viewport to them making fullscreen work properly for these games under
Xwayland.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede 38de626081 xwayland: Add vidmode mode changing emulation support
Add support for fake mode changes using viewport, for apps which want to
change the resolution when going fullscreen.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede bcad1b813a xwayland: Add xwlVidModeGetCurrentRRMode helper to the vidmode code
crtc->mode reflects the mode set through the xrandr extension, once we
add support for also changing the mode through the vidmode extension this
will no longer correctly reflect the emulated resolution.

Add a new xwlVidModeGetCurrentRRMode helper which determines the mode by
looking at the emulated_mode instead.

Likewise add a xwlVidModeGetRRMode helper and use that in
xwlVidModeCheckModeForMonitor/xwlVidModeCheckModeForDriver to allow any
mode listed in the randr_output's mode list.

This is a preparation patch for adding emulated mode/resolution change
support to Xwayland's XF86 vidmode extension emulation.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede 43c8007812 xwayland: Add xwlRRModeToDisplayMode() helper function
This is a preparation patch for adding emulated mode/resolution change
support to Xwayland's XF86 vidmode extension emulation, using the
Wayland viewport extension.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede d99b9ff0f2 xwayland: Add support for randr-resolution change emulation using viewport
Add support for per client randr-resolution change emulation using viewport,
for apps which want to change the resolution when going fullscreen.

Partly based on earlier work on this by Robert Mader <robert.mader@posteo.de>

Note SDL2 and SFML do not restore randr resolution when going from
fullscreen -> windowed, I believe this is caused by us still reporting the
desktop resolution when they query the resolution.  This is not a problem
because when windowed the toplevel window size includes the window-decorations
so it never matches the emulated resolution.

One exception would be the window being resizable in Windowed mode and the
user resizing the window so that including decorations it matches the
emulated resolution *and* the window being at pos 0x0. But this is an
extreme corner case. Still I will submit patches upstream to SDL2
and SFML to always restore the desktop resolution under Xwayland,
disabling resolution emulation all together when going windowed.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede aca0a588eb xwayland: Add support for storing per client per output emulated resolution
Add support for storing per output randr/vidmode emulated resolution
into the per client data.

Since we do not have a free/delete callback for the client this uses
a simple static array. The entries are tied to a specific output by the
server_output_id, with a server_output_id of 0 indicating a free slot
(0 is the "None" Wayland object id).

Note that even if we were to store this in a linked list, we would still
need the server_output_id as this is *per client* *per output*.

This is a preparation patch for adding randr/vidmode resolution
change emulation.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede 905cb8b9e2 xwayland: Add per client private data
Add per client private data, which for now is empty.

This is a preparation patch for adding randr/vidmode resolution
change emulation.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Robert Mader e89872f51a xwayland: Use RandR 1.2 interface (rev 2)
This adds the RandR 1.2 interface to xwayland and allows modes
advertised by the compositor to be set in an undistructive manner.

With this patch, applications that try to set the resolution will usually
succeed and work while other apps using the same xwayland
instance are not affected at all.

The RandR 1.2 interface will be needed to implement fake-mode-setting and
already makes applications work much cleaner and predictive when a mode
was set.

[hdegoede@redhat.com: Make crtc_set only succeed if the mode matches
 the desktop resolution]

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Hans de Goede 0d656d7960 xwayland: Add fake output modes to xrandr output mode lists
This is a preparation patch for adding support for apps which want to
change the resolution when they go fullscreen because they are hardcoded
to render at a specific resolution, e.g. 640x480.

Follow up patches will fake the mode-switch these apps want by using
WPviewport to scale there pixmap to cover the entire output.

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Robert Mader 7c6f17790d xwayland: Use buffer_damage instead of surface damage if available
When a viewport is set, damage will only work properly when using
wl_surface_damage_buffer instead of wl_surface_damage.

When no viewport is set, there should be no difference between
surface and buffer damage.

This is a preparation patch for using viewport to add support for fake
mode-changes through xrandr for apps which want to change the resolution
when going fullscreen.

Changes by Hans de Goede <hdegoede@redhat.com>:
-Split the damage changes out into their own patch
-Add xwl_surface_damage helper
-Also use buffer_damage / the new helper for the present and cursor code

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Robert Mader 47bba46253 xwayland: Add wp_viewport wayland extension support
This commit adds support for the wayland wp_viewport extension, note
nothing uses this yet.

This is a preparation patch for adding support for fake mode-changes through
xrandr for apps which want to change the resolution when going fullscreen.

[hdegoede@redhat.com: Split the code for the extension out into its own patch]

Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-10-12 12:19:14 +02:00
Emil Velikov b2a0d6065d vfb: add DRI3/glamor support
This commit adds DRI3/glamor support, effectively translating into
hardware GPU support.

Theoretically it should be possible to use DRM/GPU drivers such as
virtio or vgem, although only the intel i915 driver is currently tested.

Since Xvfb does no modeset, it opens the render node. Currently that is
fixed to "/dev/dri/renderD128" and will be tweaked with future commits.

Specific use-cases are left for the reader - testing glamor, GL driver
or others.

v2: Drop GLAMOR_NO_XV, use GLAMOR_FOR_XORG instead (Michel Dänzer)
v3: Fix build w/o glamor
v4:
 - Split out glamor dependency patch for meson (Pekka)
 - Enhance commit message (Pekka)
 - Use O_CLOEXEC with open() (Pekka)
 - Enhance error path, memory leak comments (Pekka)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2019-10-11 12:03:42 +00:00
Emil Velikov 86c8458f3d vfb: clarify code flow in vfbScreenInit
v2: Enhance commit message (Pekka)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2019-10-11 12:03:42 +00:00
Emil Velikov f3ab3d0c61 glamor_egl: disable modifiers via glamor_init()
Currently we parse through xf86Info.debug to check if we the modifiers
should be disabled. Handle that within DDX and pass GLAMOR_NO_MODIFIERS
into the glamor_init() flags.

This allows individual DDX control over the setting - say when modifiers
are woking OK with one implementation and not the other.

Most importantly, this removes the final xf86 piece from the codebase.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2019-10-11 12:03:42 +00:00
Emil Velikov 4018811838 glamor_egl: don't use ScrnInfoRec::privates
Move from the xf86 specific ScrnInfoRec::privates, to the dix private
handling. Since there's no FreeScreen function in ScreenPtr, fold the
former within the existing CloseScreen.

Users, such as modesetting are updated, and out of tree drivers will
need equivalent, yet trivial, patch.

Note: we need to ensure that the screen private is unset and the screen
callbacks are restored in our CloseScreen function.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2019-10-11 12:03:42 +00:00
Sven Joachim de0d39f825 modesetting: Fix broken manpage in autoconf build
The autoconf build for the modesetting driver still relied on
xorg-macros.m4 for string replacements and did not include the
top-level manpages.am.  As a result, no substitutions took place after
commit 2e497bf887.

This should be a candidate for the 1.20 branch.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-10-04 10:29:23 +02:00
Sven Joachim 726e4230c6 xwayland: Add more files to .gitignore
Also sort the file again, missed in commit c8c276c956.
2019-10-02 18:25:17 +02:00
Adam Jackson b2de577f63 xfree86: Merge vbe into int10
There's not really a good reason to keep these separate, the vbe code
requires int10 and is not very large. This change eliminates the
build-time options for vbe; if you build int10, you get vbe.

Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-10-02 10:03:26 -04:00
Sven Joachim 47387916fb Fix various spelling errors 2019-10-01 17:05:28 +00:00
Adam Jackson 2a9268e4a0 dri2: Set fallback driver names for Intel and AMD chips
i965 and radeonsi, respectively, are the drivers that have been
receiving new hardware support. It's really silly to need to update the
server side to know specific new devices IDs every time a new ASIC comes
out.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-09-30 12:57:22 -04:00
Adam Jackson cbdde938cb modesetting: Reduce "glamor initialization failed" message to X_INFO
This might be an error or not, for example refusing to work on llvmpipe
is normal and expected. glamor_egl_init() will print X_ERROR messages if
appropriate, so we don't need to here.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-09-30 11:24:06 -04:00
Alan Coopersmith 6036e84527 meson: fix builds on Solaris 11.4
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-09-23 16:28:42 -07:00
Andres Rodriguez cca4bc342c xf86: Disable unused crtc functions when a lease is revoked
This fixes 'non-desktop' displays staying powered on after their lease
has been revoked.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111620
Cc: Keith Packard <keithp@keithp.com>
Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
2019-09-23 16:01:27 +00:00
Olivier Fourdan 0f19381f49 xwayland: Don't create wl_buffer backing pixmap
In non-rootless mode, not all pixmaps need a wl_buffer backing.

Suggested-by: Twaik Yont (@twaik) in #834
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-09-23 13:27:24 +00:00
Jonas Ådahl edf964434e xwayland/glamor-gbm: Handle DRM_FORMAT_MOD_INVALID gracefully
The compositor may send DRM_FORMAT_MOD_INVALID instead of a list of
modifiers for various reasons. Handle this gracefully by ignoring it.

Without this, if a compositor would send DRM_FORMAT_MOD_INVALID, it'd
result in empty windows provided by Xwayland.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-09-23 13:14:14 +00:00
Jon Turney bcf2dd0cd2 hw/xwin: Add -icon option to set the screen window icon in windowed mode
Add an -icon option to set the screen window icon in windowed mode

Allow cygwin paths in an icon-specification

Update man pages and system.XWinrc appropriately

Also, log an error if the icon specified for TRAYICON cannot be loaded

Also, fix a bug in appending a '\' to IconDirectory only if it doesn't
already end with one, which was fortunately benign.

Note: LoadImageComma would be simpler if we just stated that XWinrc
paths are Cygwin paths on Cygwin, Windows paths on MinGW, but that could
break existing .XWinrc files

Note: Given that we can specify paths in an icon-specifier, I'm not sure
what IconDirectory wins us.

v2:
Fix formatting problems in man page additions

v3:
Fix some more s/_/@/g in man pages
2019-09-18 19:11:45 +00:00
Carlos Garnacho 7ad1d0d384 xwayland: Allow passing a fd for set up clients
This FD also triggers the "wait for WM_S0" paths, so that the
compositor may set up a "maintenance line" for Xwayland, for
services that are essential to run before any client (eg. xrdb).
Those services would use this FD, disguised as an extra display
connection.

This -initfd can be seen as a generalization of -wm, a Wayland
compositor may use -initfd to launch its WM and any other clients
that should start up, or it may use -wm as a dedicated connection for
the WM and optionally use -initfd for the misc. startup clients.

If either of -wm or -initfd is passed, Xwayland will expect a selection
notification on WM_S0 before incorporating the FDs in -listen to the
poll list.

Also, correct a minor typo in the listenfd argument output,
give → given.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
2019-09-10 15:15:42 +00:00
Carlos Garnacho 78cc8b6f96 xwayland: Handle the case of windows being realized before redirection
If Xwayland gets to realize a window meant for composition before the
compositor redirected windows (i.e. redirect mode is not RedirectDrawManual
yet), the window would stay "invisible" as we wouldn't create a
wl_surface/wl_shell_surface for it at any later point.

This scenario may happen if the wayland compositor sets up a X11 socket
upfront, but waits to raise Xwayland until there are X11 clients. In this
case the first data on the socket is the client's, the compositor can hardly
beat that in order to redirect subwindows before the client realizes a
Window.

In order to jump across this hurdle, allow the late creation of a matching
(shell) surface for the WindowPtr on SetWindowPixmapProc, so it is ensured
to be created after the compositor set up redirection.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2019-09-10 00:08:10 +02:00
Carlos Garnacho c2e8ae9640 xwayland: Refactor surface creation into a separate function
This is just called from xwl_window_realize() ATM, but will be useful in
future commits.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
2019-09-05 17:07:26 +02:00
Carlos Garnacho 4e50440ae2 xwayland: Separate DamagePtr into separate window data
This will be dissociated in future commits to handle the cases
where windows are being realized before there is a compositor
handling redirection.

In that case, we still want the DamagePtr to be registered upfront
on RealizeWindowProc before a corresponding xwl_window might be
created. Most notably, it cannot be lazily created on
SetWindowPixmapProc as damage accounting gets broken.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
2019-09-05 17:07:26 +02:00
Simon Ser 01ed478c65
xwayland: add support for xdg-output-unstable-v1 version 3
This adds support for xdg-output-unstable-v1 version 3, added in [1].

This new version deprecates zxdg_output_v1.done and replaces it with
wl_output.done. If the version is high enough, there's no need to wait for both
an xdg_output.done event and a wl_output.done event -- we only care about
wl_output.done.

[1]: 962dd53537

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2019-09-05 11:36:59 +03:00
Maarten Lankhorst f0d78b47ac modesetting: Disable atomic support by default
The atomic driver has issues with modesetting when stealing
connectors from a different crtc, a black screen when doing rotation
on a different crtc, and in general is just a mapping of the legacy
helpers to atomic. This is already done in the kernel, so just
fallback to legacy by default until this is fixed.

Please backport to 1.20, as we don't want to enable it for everyone
there. It breaks for existing users.

The fixes to make the xserver more atomic have been pending on the
mailing list for ages.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110375
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110030
References: https://gitlab.freedesktop.org/xorg/xserver/merge_requests/36/commits
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2019-09-03 18:52:02 +00:00
Christopher Chavez 4f27d1e05f XQuartz: translate additional mouse buttons
Old behavior was to translate the middle mouse button, as well as
every other button that isn't the left or right mouse button,
to act as the middle mouse button (2).

New behavior is to translate only the middle mouse button to 2,
and translate higher-numbered buttons to 8 and higher.
This allows additional mouse buttons to behave under XQuartz
more like they do by default under X11 on other platforms
(e.g. Linux and BSD distributions).

Signed-off-by: Christopher Chavez <chrischavez@gmx.us>
2019-08-24 00:57:02 +00:00
Ville Syrjälä 0c5179c280 modesetting: Update props for dynamically added outputs
Dynamically added outputs should have their properties
properly updated as well. Otherwise we're left with an output
with many of its propeties not exposed.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Michel Dänzer <michel@daenzer.net>
2019-08-22 12:41:39 +00:00
Olivier Fourdan c0bbc29ae5 meson: Move requirements in a single place
Some modules are required in multiple places in the meson file.

Move the actual requirements to the top of the file as a variable so
that updating a version does not require changing the actual value in
multiple places.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2019-08-15 17:08:04 +00:00
Adam Jackson 3c78d63755 global: Remove BUILD_DATE and BUILD_TIME
All this does is make reproducible builds impossible.
2019-08-15 16:38:22 +00:00
Hans de Goede c69b37e8da modesetting: Only log 1 error for consecutive flip failures
Only log 1 error for consecutive flip failures, instead of filling the
log and the disk with errors for each attempted flip.

Despite our best efforts we may end up with a BO which gets refused
when we try to import it as a framebuffer, see e.g. :
https://bugs.freedesktop.org/show_bug.cgi?id=111306
This should not happen, but as the above bugs shows sometimes it does
and chances are it will happen again.

Note ideally we should check if the import is possible at
ms_present_check_flip time, like the amdgpu code is doing since:
https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/merge_requests/35
but that requires a chunk of refactoring work on the modesetting driver,
so for now this will have to do.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-09 10:51:12 +02:00
Hans de Goede 3dc838f77d modesetting: Improve page-flip error reporting
Before this commit ms_do_pageflip logged a single error for both the
drmmode_bo_import failure path as well as for the queue_flip_on_crtc
path. This commit splits this into 2 separate error logs so that it is
clear what the cause of the flip-failure is.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-09 10:51:06 +02:00
Hans de Goede 12821852f0 modesetting: Avoid duplicate error messages on present-flip errors
Currently on present-flip failures we log 2 messages for each failure,
1 from ms_do_pageflip and then another one from ms_present_flip which
is the caller of ms_do_pageflip. This commit adds a log_prefix argument
to ms_do_pageflip so that its log messages can show if it is a DRI2 or
a Present flip which fails and removes the redundant error message from
ms_present_flip.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-09 10:50:55 +02:00
Dave Airlie 078277e4d9 xf86: autobind GPUs to the screen
This is a modified version of a patch we've been carry-ing in Fedora and
RHEL for years now. This patch automatically adds secondary GPUs to the
master as output sink / offload source making e.g. the use of
slave-outputs just work, with requiring the user to manually run
"xrandr --setprovideroutputsource" before he can hookup an external
monitor to his hybrid graphics laptop.

There is one problem with this patch, which is why it was not upstreamed
before. What to do when a secondary GPU gets detected really is a policy
decission (e.g. one may want to autobind PCI GPUs but not USB ones) and
as such should be under control of the Desktop Environment.

Unconditionally adding autobinding support to the xserver will result
in races between the DE dealing with the hotplug of a secondary GPU
and the server itself dealing with it.

However we've waited for years for any Desktop Environments to actually
start doing some sort of autoconfiguration of secondary GPUs and there
is still not a single DE dealing with this, so I believe that it is
time to upstream this now.

To avoid potential future problems if any DEs get support for doing
secondary GPU configuration themselves, the new autobind functionality
is made optional. Since no DEs currently support doing this themselves it
is enabled by default. When DEs grow support for doing this themselves
they can disable the servers autobinding through the servers cmdline or a
xorg.conf snippet.

Signed-off-by: Dave Airlie <airlied@gmail.com>
[hdegoede@redhat.com: Make configurable, fix with nvidia, submit upstream]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
---
Changes in v2:
-Make the default enabled instead of installing a xorg.conf
 snippet which enables it unconditionally

Changes in v3:
-Handle GPUScreen autoconfig in randr/rrprovider.c, looking at
 rrScrPriv->provider, rather then in hw/xfree86/modes/xf86Crtc.c
 looking at xf86CrtcConfig->provider. This fixes the autoconfig not
 working with the nvidia binary driver
2019-08-07 12:26:59 +02:00
Hans de Goede 0aaac8d783 modesetting: Disable pageflipping when using a swcursor
The miPointerSpriteFunc swcursor code expects there to only be a single
framebuffer and when the cursor moves it will undo the damage of the
previous draw, potentially overwriting what ever is there in a new
framebuffer installed after a flip.

This leads to all kind of artifacts, so we need to disable pageflipping
when a swcursor is used.

The code for this has shamelessly been copied from the xf86-video-amdgpu
code.

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

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-06 17:22:02 +02:00
Hans de Goede 0331153b22 modesetting: Fix compiler warning
Fix the following compiler warning:

drmmode_display.c: In function ‘drmmode_create_bo’:
drmmode_display.c:1019:9: warning: ISO C90 forbids mixed declarations and code [
 1019 |         uint32_t num_modifiers;
      |         ^~~~~~~~

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-06 17:03:55 +02:00
Hans de Goede 13f359fa83 modesetting: Remove obsolete, unused msPixmapPrivate declaration and macro
When the pixmapPrivateKeyRec was moved from a global to being embedded
inside the drmmode_rec these 2 where missed, clean them up.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-06 17:03:41 +02:00
Hans de Goede f9e7cdf659 xf86: dri2: Use va_gl as VDPAU driver for Intel i965 GPUs
The modesetting driver (which now often is used with Intel GPUs),
relies on DRI2ScreenInit() to setup the DRI and VDPAU driver names.

Before this commit it would always assign the same name to the 2 names,
but the VDPAU driver for i965 GPUs should be va_gl.

This commit adds a special case for the i965 case, replacing the
VDPAU driver name with "va_gl" if the GPU is using the i965 driver
for DRI.

Note this commit adds a FIXME comment for a related memory leak, that leak
was already present and fixing it falls outside of the scope of this commit.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1413733
Cc: kwizart@gmail.com
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-06 16:25:39 +02:00
Ross Burton 6f41bf3105 sdksyms.sh: don't embed the build path
This script generates a header that has a comment containing the build path for
no real reason.  As this source can end up deployed on targets in debug packages
this means there is both potentially sensitive information leakage about the
build environment, and a source of change for reproducible builds.
2019-08-05 22:19:57 +00:00
Alan Coopersmith b7dae57f1d Fix NO_UNDEFINED build with statically linked fb
Stop trying to link to a shared library we no longer build

Fixes: commit c1703cdf3b - "xfree86: Link fb statically"
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-04 10:28:51 -07:00
Olivier Fourdan f107bde1e2 xwayland: Fix build warning without glamor
Building Xwayland without glamor support would raise a warning at build
time:

  xwayland.c: In function ‘xwl_screen_init’:
  xwayland.c:980:10: warning: unused variable ‘use_eglstreams’
    980 |     Bool use_eglstreams = FALSE;
        |          ^~~~~~~~~~~~~~

When building without glamor support, we cannot have EGL Streams support
either, the two being related. So we do not need to declare the variable
`use_eglstreams` if glamor is not enabled.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2019-07-31 18:20:59 +00:00
Olivier Fourdan 8587bbd85a xwayland: Fix build without glamor
When building Xwayland without glamor support enabled using automake,
the build would fail at link time trying to find `glamor_block_handler`:

  /usr/bin/ld: xwayland-glx.o: in function `egl_drawable_wait_x':
  hw/xwayland/xwayland-glx.c:102: undefined reference to
  `glamor_block_handler'

Make sure we don't try to build `xwayland-glx.c` without glamor in the
Xwayland Makefile.

Note: Meson build is fine because it's already build only with glamor
enabled.

Fixes: commit 8469241 - "xwayland: Add EGL-backed GLX provider"
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2019-07-31 09:44:12 +02:00
Adam Jackson c1703cdf3b xfree86: Link fb statically
There's no real benefit to leaving this loadable, virtually every driver
is going to load it.

Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk>
2019-07-23 14:24:00 -04:00
Olivier Fourdan d9ec525059 xwayland: Do not free a NULL GBM bo
Both `gbm_bo_create()` and `gbm_bo_create_with_modifiers()` can fail and
return `NULL`.

If that occurs, `xwl_glamor_gbm_create_pixmap()` will not create a
pixmap for the (NULL) GBM bo, but would still try to free the bo which
leads to a crash in mesa:

  [...]
  #7  <signal handler called>
  #8  in gbm_bo_destroy (bo=0x0) at ../src/gbm/main/gbm.c:439
  #9  in xwl_glamor_gbm_create_pixmap () at xwayland-glamor-gbm.c:245
  #10 in ProcCreatePixmap () at dispatch.c:1440
  #11 in Dispatch () at dispatch.c:478
  #12 in dix_main () at main.c:276

To avoid the crash, only free the GBM bo if not `NULL`.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Bugzilla: https://bugzilla.redhat.com/1729925
2019-07-23 11:58:36 +02:00
Adam Jackson 454b3a826e hw: Rename boolean config value field from bool to boolean
"bool" conflicts with C++ (meh) and stdbool.h (ngh alright fine). This
is a driver-visible change and will likely break the build for mach64,
but it can be fixed by simply using xf86ReturnOptValBool like every
other driver.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2019-07-22 20:28:27 -04:00
Paolo Borelli 074c98cf53 Xvfb: set rotations ret value 2019-07-22 12:47:57 +02:00
Yaakov Selkowitz 011b87a8c6 hw/xwin: Add EWMH properties for describing multiple desktops to the root window
mate-terminal apparently requires these to be present to work

We just set them to describe one desktop, for the moment.

It seems we can safely ignore the _NET_WM_DESKTOP property on child
windows, and any _NET_WM_DESKTOP messages, as we only support one
desktop for windows to be on.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2019-07-21 14:44:26 +01:00
Colin Harrison 3d493e91ab hw/xwin: Respect -notrayicon option on taskbar restart 2019-07-21 14:44:24 +01:00
Jon Turney a588e6f81b hw/xwin: Rename WM_WM_MAP{2,3} to WM_WM_MAP_{UN,}MANAGED
WM_WM_MAP was removed in 52e05b92

Rename WM_WM_MAP2 as WM_WM_MAP_UNMANAGED (meaning an override-redirect
window, which manages it's own activation)

Rename WM_WM_MAP3 as WM_WM_MAP_MANAGED (meaning a normal window, which
is activated when clicked)
2019-07-21 14:44:23 +01:00
Jon Turney a47e7eb247 hw/xwin: Log counts of pixel formats which couldn't be used
Log a count of pixel formats which couldn't be used for various reasons
2019-07-21 14:44:21 +01:00
Ignacio Casal Quinteiro 82225aab81 vfb: set gamma size to avoid xrandr to complain about it missing 2019-07-17 13:09:32 +00:00
Ignacio Casal Quinteiro 492639f5e1 vfb: factor out method to free a single screen info 2019-07-17 13:09:32 +00:00
Ignacio Casal Quinteiro 356ffd6729 vfb: no need for else if we are returning 2019-07-17 13:09:32 +00:00
Adam Jackson d0850241c6 xwayland: Expand the RANDR screen size limits
There's not really a good way to query this from the wayland server, so
just set the maximum to the X11 protocol limits. While we're at it,
lower the minimum screen size to something implausibly small too, just
in case.

Fixes: xorg/xserver#850
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2019-07-16 12:58:03 -04:00
Olivier Fourdan fe4cd0e7f5 compiler.h: Do not include sys/io.h on ARM with glibc
<sys/io.h> on ARM hasn't worked for a long, long time, so it was removed
it from glibc upstream.

Remove the include to avoid a compilation failure on ARM with glibc.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/840
2019-07-15 18:59:59 +00:00
Olivier Fourdan ce9455b5ee xwayland: Update screen pixmap on output resize
Running Xwayland non-rootless and resizing the output would lead to a
crash while trying to update the larger areas of the root window.

Make sure we resize the backing pixmap according to the new output size
to avoid the crash.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/834
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2019-07-12 16:23:36 +00:00
Adam Jackson a530b6e892 meson: Fix libshadow.so linkage
Don't link against fb, it's the driver's responsibility to load that
first. Underlinking like this is unpleasant but this matches what
autotools does.

Fixes: xorg/xserver#540
2019-07-10 14:56:28 +00:00
Matt Roper a8d9ebeb43 dri2: Sync i965_pci_ids.h from mesa
Copied from Mesa with no modifications.

This update brings in a significant number of new platform ID's.

Syncs with mesa up to commit e334a595e ("intel/icl: Add new ICL
PCI-IDs").

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2019-07-10 10:40:13 -04:00
Jon Turney ff6b771eee hw/xwin: Improve data returned for RANDR queries
Set a linear gamma ramp.  This avoids the xrandr command always warning
'Failed to get size of gamma for output default'
(perhaps we should be using GDI GetDeviceGammaRamp(), if possible?)

Make CRTC report non-zero physical dimensions initially
2019-06-28 17:44:58 +00:00
Jon Turney 2549ab2065 hw/xwin: Always keep RANDR fake mode information up to date
The rrGetInfo hook is not called for all RANDR requests (e.g.
RRGetOutputInfo), so we must always keep the fake mode information up to
date, rather than doing it lazily in the rrGetInfo hook)

Because we are so bad, most GTK+3 versions treat the output name 'default'
specially, and don't try to use RANDR with it.  But versions 3.21.6 to
3.22.24, don't do this, and get badly confused by a CRTC with size 0x0.

See:
https://bugzilla.gnome.org/show_bug.cgi?id=771033
https://bugzilla.gnome.org/show_bug.cgi?id=780101

Future work: Rather than reporting a single fake CRTC with a mode matching
the entire virtual display, the fake CRTCs we report should match our
'pseudo-xinerama' monitors
2019-06-28 17:44:58 +00:00
Jon Turney b078e03410 hw/xwin: Make QueryMonitor() slightly less insane
Make QueryMonitor() slightly less insane, making it return TRUE if the
specified monitor exists, rather than always returning TRUE (which we
are uselessly checking, and then also checking if the specified monitor
exists)

(Note that EnumDisplayMonitors() doesn't seem to have meaningful way to
return errors, see 5940580f)

Also: Spamming the long UseMsg() after "Invalid monitor number" isn't very
helpful.

Also: If we are exiting in ddxProcessArgument() due to an error in
options, use a non-zero exit status.
2019-06-28 17:44:58 +00:00
Jon Turney 8f7e4b56d2 hw/xwin: Fix transposed RaiseVolume and LowerVolume scan codes 2019-06-28 17:38:36 +00:00
Colin Harrison bfcaaecc55 hw/xwin: Add the Belgian (Comma) keyboard layout 2019-06-28 17:38:36 +00:00
Colin Harrison 188f461463 hw/xwin: Add Russian keyboard layout 2019-06-28 17:38:36 +00:00
Olivier Fourdan b3f3d65ed3 xwayland: Add "-listenfd" option
Using the existing command line option "-listen" for passing file
descriptors between the Wayland compositor and Xwayland is misleading,
Xwayland should add is own command line option for that specific use.

As XWayland is spawned by the Wayland compositor, we cannot just change
the option, as that would break all existing Wayland compositors using
Xwayland, so we add a new options "-listenfd" and mark the previous one
as deprecated and log a warning, but it still works for backward
compatibility.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/214
2019-06-19 22:03:50 +00:00
Olivier Fourdan 4a287cc2b6 xwayland: Allow for regular transport types for listen
Xwayland uses the command line option “-listen” to pass file descriptors
from the Wayland compositor.

That breaks the traditional, documented behavior of the “-listen”
command line option which is to enable a transport type.

Checks if the given option starts with a digit, otherwise treat it as a
regular transport type.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/817
Suggested-by: Rodrigo Exterckötter Tjäder
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2019-06-19 22:03:50 +00:00
Adam Jackson 0dc0cef495 xwayland-glx: Fix GLX visual mask setup
a2rgb10 configs would end up with channel masks corresponding to
argb8888. This would confuse the GLX core code into matching an a2rgb10
config to the root window visual, and that would make things look wrong
and bad.

Fix this by handling more cases. We're still not fully general here, and
this could still be wrong on big-endian. The XXX comment about doing
something less ugly still applies, ideally we would get this information
out of EGL instead of making lucky guesses. Still, better than it was.

Fixes: xorg/xserver#824
2019-06-18 14:57:16 -04:00
Jon Turney 2afee831a4 hw/xwin: Add an option to use alpha channel in multiwindow mode
Add an option to turn on the use of the X window's alpha channel in
multiwindow mode, i.e. this uses the X window's alpha channel for
compositing into the native desktop.

This works on W7/Vista (using DwmEnableBlurBehindWindow()), and Windows
10 (using the undocumented SetWindowCompositionAttribute()), but not on
Windows 8/8.1

-compositewm must be enabled for this to be useful, as we only have a
pixmap with an alpha channel for the X window in that case.  The
framebuffer/root window doesn't have one (unless perhaps you are using
the rootless extension, maybe...).

v2:
Update meson.build

Future work:

A window property to control use of alpha?
Option to turn off blur on W7/Vista
Implement _NET_WM_WINDOW_OPACITY
2019-06-17 21:56:35 +00:00
Jon Turney 2e1bc74373 hw/xwin: Set convenience variables for WM_CREATE as well
Set convenience variables in winTopLevelWindowProc() for WM_CREATE as
well.
2019-06-17 21:56:35 +00:00
Jon Turney f67918353a hw/xwin: Improve performance of -compositewm
I think that a major cost in the current implementation is doing a
CreateDIBSection()/DestroyObject() on every refresh.  So provide our own
CreatePixmap() instead, which does the CreateDIBSection(), once.

Testcase: glxgears or foobillard with direct swrast
Testcase: scrolling in a full-screen xterm

v2:
Fix handling of RENDER Scratch Pixmaps
(A problem easily shown with gitk or emacs)

v3:
Note that we don't own screen pixmap to release in DestroyPixmap
Log if unimplemented slow-path ever gets hit
2019-06-17 21:56:35 +00:00
Jon Turney 6865fe7147 hw/xwin: Avoid artefacts when resizing a window
Fill the area outside the current window size with black, rather than
leaking framebuffer contents or leaving it undrawn.
2019-06-17 21:56:35 +00:00