Commit Graph

91 Commits

Author SHA1 Message Date
Quantum
11a5864969 [client] wayland: implement support for other cursors 2021-07-31 14:56:04 +10:00
Quantum
da28db2ca4 [client] ds: change showPointer to setPointer for more cursors
Currently everything only supports LG_POINTER_NONE and LG_POINTER_SQUARE.
2021-07-31 14:56:04 +10:00
Quantum
134829cbf2 [client] imgui: make graph y-axis configurable
The default of [0, 50] makes sense for FPS/UPS graphs, but does not for
things like the import graph. The latter should not take more than 5 ms
for sure.

This commit allows the min/max y-axis value to be specified when registering
the graph.
2021-07-29 15:54:15 +10:00
Quantum
e7761abf3c [client] wayland: invalidate window on configure
This avoids sending potentially meaningless damage values after a surface
configuration event.
2021-07-25 15:36:44 +10:00
arcnmx
3b37898eb2 [all] use cmake FindPkgConfig IMPORTED_TARGETs 2021-07-24 12:35:48 +10:00
Quantum
b26067b0a0 [client] wayland: use new libdecor pkgconfig package name 2021-07-23 15:52:05 +10:00
Quantum
85f34602f4 [client] wayland: do not leak wp_presentation_feedback objects 2021-07-22 13:12:47 +10:00
Quantum
bb60107a3b [client] wayland: dispatch events through libdecor when using it
Currently, we dispatch the events on the wayland display server ourselves.
This is fine when using the cairo backend of libdecor, as it does the same
thign we do, but other backends may require other things to be dispatched.

This commit lets libdecor dispatch events instead through libdecor_get_fd
and libdecor_dispatch, which should hopefully makes things less sketchy.
2021-07-22 12:03:55 +10:00
Quantum
3f7261d7d9 [client] wayland: do not crash when presentation time is unavailable
We don't need the presentation time protocol, so fail gracefully when
it's unavailable.
2021-07-20 14:23:08 +10:00
Quantum
0cbc529640 [client] ds: refactor common EGL swap with damage logic
This commit creates a new utility library, eglutil.h, which contains code
to detect and use EGL_KHR_swap_buffers_with_damage or its EXT equivalent.

This logic used to be duplicated between the X11 and Wayland display servers,
which is not ideal.
2021-07-19 19:35:52 +10:00
Quantum
09893fd728 [client] wayland: display swap to photon latency graph 2021-07-18 16:15:10 +10:00
Quantum
e87bc3a83e [client] wayland: measure presentation time 2021-07-18 16:15:10 +10:00
Quantum
48ae5c69f4 [client] wayland: fix typo in warp usage
The unwanted ! was introduced in 4b99bba200.
This basically caused warp to never be used.
2021-07-15 08:40:36 +10:00
Quantum
6419279c3c [client] wayland/clipboard: prefer text/plain over text/html
When both text/plain and text/html are available, we should prefer the plain
text as we can't paste HTML.
2021-06-26 12:49:47 +10:00
Quantum
f3a1eaf557 [client] wayland: fix full screen toggle in capture mode regression
This was fixed in 9db3cd7b and accidentally broke again in 4b99bba2.
2021-06-20 09:27:33 +10:00
Quantum
4b99bba200 [client] wayland: lock confine-related code to avoid race
This should fix the occasional Wayland protocol errors that arise when
the UI thread and the cursor thread race.

Example of error that is fixed:

    zwp_pointer_constraints_v1@11: error 1: a pointer constraint with a wl_pointer of the same wl_seat is already on this surface
2021-06-08 21:04:14 +10:00
Quantum
7f5f46c448 [client] wayland: offer all supported clipboard formats
This commit restructures the Wayland clipboard handling for host->VM.

Before, we select one clipboard format and buffers the data for it, to
be presented to spice when needed.

Now, we simply offer all clipboard formats supported, and only when spice
asks for the data do we actually read the wl_data_offer. The wl_data_offer
is kept around until a new offer is presented, the offer invalidated, or
when we lose keyboard focus. This is in accordance with the specification
for wl_data_device::selection, which states that:

> The data_offer is valid until a new data_offer or NULL is received or
> until the client loses keyboard focus. The client must destroy the
> previous selection data_offer, if any, upon receiving this event.

We still buffer the entire clipboard data into memory because we have no
knowledge of the clipboard data size in advance and cannot do incremental
transfers.

Furthermore, if the user performs drag-and-drop on our window, we may have
need to handle multiple wl_data_offer objects at the same time. Therefore,
instead of storing state on the global wlCb object, we instead allocate
memory and store it as user_data on the wl_data_offer. As a result, we also
handle drag-and-drop so that we can free the memory.
2021-06-06 12:20:42 +10:00
Quantum
24d0aa0c18 [all] normalize copyright on all source files 2021-06-06 11:53:05 +10:00
Quantum
75a9e38e3a [client] wayland: remove sync transfer for VM->host copies
Since we are using epoll, there is no longer any need to remove O_NONBLOCK
with fcntl, and the comment is also no longer relevant.
2021-06-02 22:22:59 +10:00
Quantum
000d91afca [client] wayland: prefer PNG over other image types
Support for non-PNG types is optional in the spice agent, so we should
avoid sending those if PNG is available.

Currently, the spice VDAgent supports only PNG and BMP formats.
2021-05-30 14:32:18 +10:00
Quantum
437bba1897 [client] wayland: update to support new spice clipboard type list 2021-05-30 12:39:00 +10:00
Quantum
9db3cd7b51 [client] wayland: avoid protocol error when warping in capture mode
When using locked pointer (i.e. capture mode), it doesn't make sense to
warp the cursor, so we disable it. This fixes #540.
2021-05-22 13:22:31 +10:00
Quantum
fd531bd39b [client] wayland: use util_hasGLExt for swapping buffers with damage 2021-05-19 19:37:14 +10:00
Quantum
e70cfd84fb [client] egl: use eglSwapBuffersWithDamageKHR for cursor-only updates
Instead of damaging the entire surface when rendering a cursor move,
we can use the EGL_KHR_swap_buffers_with_damage extension to only
damage the part of the window covered by the cursor. This should
reduce the cursor movement latency on Wayland.
2021-05-19 18:56:36 +10:00
Quantum
f9a9953071 [client] egl: use new util_hasGLExt helper to check extensions
We previously used strstr, which can be prone to false positives when
the name of one extension is a substring of another extension.

This commit creates the helper function util_hasGLExt, which asserts
that the substring found in extension list is bounded by either spaces
or the beginning/end of the string.
2021-05-19 15:58:54 +10:00
Quantum
edbd6f6ade [client] wayland: implement minimize operation
This commit implements minimize for both xdg-shell and libdecor
pseudo-shell. This fixes #535.
2021-05-08 10:08:37 +10:00
Geoffrey McRae
903cc9815f [client] x11/sdl/wayland: implement new minimize (stub for wayland)
This implements the new minimize function introduced in the last commit
for x11 and SDL. Wayland at current is just a stub and needs some
attention.
2021-05-06 22:25:38 +10:00
Quantum
0f2fd84724 [client] ds: avoid util_cursorToInt when warping pointer
Using util_cursorToInt messes with the error tracking for normal movements,
and is not necessary since we are computing an absolute position on the
client window.

Instead, we should pass doubles directly to display servers and let them
decide how to best handle them. For example, XIWarpPointer accepts doubles
directly.
2021-05-04 19:02:13 +10:00
Quantum
71c9680245 [client] wayland: use locked pointer to implement capture mode
This prevents the host cursor from moving into another window in capture
mode, solving the problem of input going to an overlapping window in
capture mode, and also preventing loss of focus with focus_follows_mouse.
2021-05-04 18:17:19 +10:00
Quantum
00c2773e6b [client] ds: separate grab and capture logic
Currently, (un)grabPointer is used both for tracking/confining the mouse
in normal mode, as well as entering/exiting capture mode. This makes it
impossible to use separate cursor logic for capture mode, which is needed
to deal with overlapping windows for the Wayland backend.

This commit creates separate (un)capturePointer for entering/exiting
capture mode. There should be no behaviour changes.
2021-05-04 18:17:19 +10:00
Quantum
ee380451ca [client] wayland: synchronize host cursor position with guest
This mirrors the x11 implementation, allowing the pointer to move
correctly into overlapping windows.
2021-05-04 09:18:35 +10:00
Geoffrey McRae
d0a12f6097 [client] ds: detect when the cursor exits into an overlapping window
This adds a new method to the display server interface to allow the
application to notify the ds when there is a guest cursor position
update along with the translated local guest cursor position. This makes
it possible for the display server to keep the local cursor position in
sync with the guest cursor so that window leave events can be detected
when the cursor would move into an overlapping window.

Wayland currently just has a stub for this, and the X11 implementation
still needs some minor tweaking.
2021-05-04 06:35:36 +10:00
Quantum
30c3b399f2 [client] wayland: do not leak cursor wl_buffer and wl_surface 2021-04-19 17:03:25 +10:00
Quantum
a380803d37 [client] libdecor: fix gcc compile warnings-turned-errors
This commit fixes the -Wmissing-field-initializers warning, which can only
be disabled with a pragma. GCC wants us to Initialize libdecor reserved
fields, which requires knowing how many reserved fields there are.
This is an implementation detail, and so we can only disable the warning.

This also fixes -Wincompatible-pointer-types, which is an actual bug.
2021-04-19 17:03:13 +10:00
Quantum
ba3243f88a [client] wayland: make input handlers aware of multiple surfaces
This prevents input handlers from breaking in presence of subsurfaces,
which are used by libdecor for client-side decorations.
2021-03-15 10:54:35 +11:00
Quantum
d6a290a31d [client] wayland: implement libdecor pseudo-shell backend
This allows decorations to be drawn on GNOME and other crazy compositors
that do not support server-side decorations.
2021-03-15 10:54:35 +11:00
Quantum
82e107af8a [client] cmake: support building with libdecor 2021-03-15 10:54:35 +11:00
Quantum
4031a862df [client] wayland: split xdg-shell handling into a module
This will allow libdecor to be added as a new pseudo-shell.
2021-03-15 10:54:35 +11:00
Quantum
854b53e28c [client] wayland: use consistent naming in poll module
Some of the functions were named WaylandEpoll*, which is inconsistent.
This commit changed them to be WaylandPoll*.
2021-03-03 16:38:23 +11:00
Tudor Brindus
484012a90c [client] wayland: bind no-op drag-and-drop handlers
Otherwise, libwayland aborts when a drag into the Looking Glass window
occurs.
2021-02-27 14:49:06 +11:00
Tudor Brindus
97009027d1 [client] wayland: require wl_compositor v3 instead of v4
The only addition to v4 was `wl_surface_damage_buffer`, which we do not
use.

This change should allow running on more compositors (even though v4 is
already old -- 5 years now).

Ref
3384f69ecf.
2021-02-27 14:48:40 +11:00
Tudor Brindus
d6b8823dce [client] wayland: gracefully downgrade to wl_output v2
We don't necessarily need `wl_output.release`, which is the only
addition in v3.

This allows Looking Glass to run on Ubuntu 20.04 without having to go
difficult lengths to acquire newer Wayland packages. Since 20.04 is an
LTS release, this seems worthwhile for the small amount of complexity
this introduces.

Fixes
https://forum.level1techs.com/t/latest-build-allow-inhibiting-shortcuts-dialog-ubuntu/168684/6.
2021-02-27 14:48:28 +11:00
Quantum
5551420983 [client] wayland: clean up #includes in wayland.c
This was missed when splitting up wayland.c into multiple modules.
This commit also drops the useless #include <SDL2/SDL.h>, bringing
SDL removal one step closer.
2021-02-26 09:44:59 +11:00
Quantum
798a1aadb5 [client] wayland: fail gracefully when interfaces are too old
Before, we just attempt to bind, causing an obscure Wayland error.
This commit checks the interface versions and print better error
messages.
2021-02-26 09:43:38 +11:00
Quantum
389d8824e2 [client] wayland: handle output scale changes
If the scale factor of an wl_output changes while the client is running,
the maximum scale factor is not updated. This may result in incorrect
scaling.

Therefore, when the scale factor is changed, we should generate a
resize event.
2021-02-23 20:28:25 +11:00
Quantum
447aedc9a3 [client] wayland: pass scale factor information to renderer 2021-02-21 19:06:53 +11:00
Quantum
b35e19fc27 [client] renderer: add interface for high DPI rendering 2021-02-21 19:06:53 +11:00
Quantum
6b26089353 [client] wayland: keep track of wl_output scale information
This will later be used to control the size of the underlying EGL buffers
in order to handle high DPI.
2021-02-21 19:06:53 +11:00
Quantum
5649d1ad95 [client] wayland: split Wayland display server into modules
The Wayland display server is getting unwieldy due to the sheer size.
To make it easier to edit in the future, I split it into many components
based on logical boundaries.
2021-02-21 10:31:49 +11:00
Quantum
1ba1108099 [client] wayland: add option to enable cursor warp
This is enabled on default. Specify wayland:warpSupport=no to disable it,
which may be useful on certain compositors that do not warp when the
pointer is confined.
2021-02-21 10:31:49 +11:00