Commit Graph

17496 Commits

Author SHA1 Message Date
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 b5b529799a meson: split udev from udev_kms which requires systemd
DragonFly and FreeBSD can use xf86-input-libinput with config/udev.

ld: error: undefined symbol: xf86PlatformDeviceProbe
>>> referenced by xf86platformBus.c
>>>               xf86platformBus.c.o:(xf86platformProbe) in archive hw/xfree86/common/libxorg_common.a

ld: error: undefined symbol: xf86PlatformDeviceCheckBusID
>>> referenced by xf86platformBus.c
>>>               xf86platformBus.c.o:(xf86platformProbeDev) in archive hw/xfree86/common/libxorg_common.a

ld: error: undefined symbol: xf86PlatformReprobeDevice
>>> referenced by xf86platformBus.c
>>>               xf86platformBus.c.o:(xf86platformVTProbe) in archive hw/xfree86/common/libxorg_common.a

ld: error: undefined symbol: NewGPUDeviceRequest
>>> referenced by udev.c
>>>               udev.c.o:(device_added) in archive config/liblibxserver_config.a

ld: error: undefined symbol: DeleteGPUDeviceRequest
>>> referenced by udev.c
>>>               udev.c.o:(device_removed) in archive config/liblibxserver_config.a
2020-05-27 07:16:02 +00: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
Jan Beich f2cf236da8 os: unbreak xsha1 on FreeBSD
../os/xsha1.c:36:10: fatal error: 'sha1.h' file not found
 #include <sha1.h>
          ^~~~~~~~
../os/xsha1.c:45:5: error: implicit declaration of function 'SHA1Init' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    SHA1Init(ctx);
    ^
../os/xsha1.c:54:5: error: implicit declaration of function 'SHA1Update' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    SHA1Update(sha1_ctx, data, size);
    ^
../os/xsha1.c:63:5: error: implicit declaration of function 'SHA1Final' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    SHA1Final(result, sha1_ctx);
    ^
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
Peter Hutterer 6ef1b0108e gitlab CI: use the fdo ci-templates repository
wayland/ci-templates was moved to freedesktop/ci-templates, everything
else stayed the same so the sha is still valid.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2020-05-20 11:01:13 +10: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
Martin Weber 9bf33bab32 test: Fix struct initialization warning 2020-05-08 16:45:50 +02: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
Alexander Volkov 89f42b8821 gitlab-ci: Bump DEBIAN_TAG to build with gcc 9.3.0 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
Adam Jackson 5684d436e2 xinput: Remove PropagateMask
Initialized to a constant value, never modified, never varied by device.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2020-03-30 21:48:11 +00:00
Adam Jackson 4520ec9bd5 xinput: Remove ExtExclusiveMasks
Initialized to a constant value, never modified, never varied by device.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2020-03-30 21:48:11 +00:00
Adam Jackson 1e29f3ea3e glx: Require screens match for share contexts for classic CreateContext
The GLX_ARB_create_context path (with which this should all get unified,
someday, sigh) already enforces this, but the classic path does not.
It's effectively assumed by the implementation anyway, so let's enforce
it rather than do crashy things.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2020-03-30 17:32:22 -04:00
Vasily Khoruzhick b56e501092 glx: fixup symbol name for get_extensions function
glxProbeDriver() concatenates __DRI_DRIVER_GET_EXTENSIONS with driver name
to get symbol name for get_extension function. Unfortunately that doesn't
work for drivers that have hyphen in their name, e.g. sun4i-drm --
get_extensions() for these uses underscore instead.

As result dlsym() doesn't find get_extension() function and AIGLX
initialization fails resulting in following message in Xorg.0.log:

(EE) AIGLX error: sun4i-drm does not export required DRI extension

Replace all non-alpha-numeric characters with underscore to fix the issue.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
2020-03-23 20:50:30 +00: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
Peter Harris de940e06f8 xkb: fix key type index check in _XkbSetMapChecks
This code block was moved from a function that returns 0 for failure to a
function that returns 0 for Success in commit
649293f6b6. Change the return value to
BadValue to match the other checks in _XkbSetMapChecks.

Set nTypes to xkb->map->num_types when XkbKeyTypesMask is not set, to
allow requests with the XkbKeyTypesMask flag unset in stuff->present to
succeed.

Fixes a potential heap smash when client->swapped is true, because the
remainder of the request will not be swapped after "return 0", but
_XkbSetMap will be called anyway (because 0 is Success).

Signed-off-by: Peter Harris <pharris@opentext.com>
2020-02-25 12:12:55 -05:00
Peter Harris 270e439739 xkb: only swap once in XkbSetMap
The server swaps part of the request in _XkbSetMapChecks instead of
SProcXkbSetMap (presumably because walking the XkbSetMap request is hard,
and we don't want to maintain another copy of that code).

Swap the first time _XkbSetMapChecks is called, not the second time.

Signed-off-by: Peter Harris <pharris@opentext.com>
2020-02-25 12:12:55 -05: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