Commit Graph

167 Commits

Author SHA1 Message Date
Quantum
77b3d45e0e [client] ds: change signalNextFrame to waitFrame 2021-08-01 17:29:15 +10:00
Quantum
96bcfff28b [client] wayland: use zxdg_output_manager_v1 version 3 if possible
Version 3 does not send xdg_output.done events, instead guaranteeing that
all xdg_output.* events are sent before wl_output.done. This saves us from
doing the work twice.
2021-08-01 13:05:41 +10:00
Quantum
0ad469178a [client] wayland: make it possible to disable fractional scaling
The method used is not guaranteed to work on all Wayland compositors,
so offer a way out. We need to support it anyways in case xdg_output
or wp_viewporter protocols are not available.
2021-08-01 13:05:41 +10:00
Quantum
b3ca872cef [client] wayland: improve fractional scale handling
Currently, we scale the desktop up to the next largest integer, and rely on
the wayland compositor to scale it back down to the correct size.
This is obviously undesirable.

In this commit, we attempt to detect the actual fractional scaling by finding
the current active mode in wl_output, and dividing it by the logical screen
size reported by xdg_output, taking into consideration screen rotation.

We then use wp_viewporter to set the exact buffer and viewport sizes if
fractional scaling is needed.
2021-08-01 13:05:41 +10:00
Quantum
a213ee960a [client] wayland: implement signalNextFrame with frame callbacks 2021-07-31 19:05:21 +10:00
Geoffrey McRae
5e2dd589a1 [client] x11: implement cursor support for the imgui overlay
This commit adds libxcursor to the dependencies for X11.
2021-07-31 18:23:05 +10:00
Geoffrey McRae
3143dc1e84 [client] x11: call app_handleWheelMotion for imgui scroll interaction 2021-07-31 16:12:52 +10:00
Geoffrey McRae
7f6fd02d06 [client] x11: Add event handling for ungrabed mouse press/release
The imgui overlay requires input even if the display is not captured and
operating in raw mode. XInput2 correctly only sends
XI_Press/ReleaseButton events if the device has not been captured, as
such it's safe to handle both raw and non raw buttons events at the same
time.
2021-07-31 15:23:31 +10:00
Quantum
72ccd44681 [client] wayland: pass mouse wheel motion events to imgui 2021-07-31 14:58:35 +10:00
Quantum
6b6b3b724a [client] wayland: reject horizontal scroll events
Currently, we handle horizontal scroll events as if they are vertical scrolls.
This is not correct and we should instead reject them.
2021-07-31 14:57:56 +10:00
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
Geoffrey McRae
3905834807 [client] x11: call app_invalidateWindow on expose 2021-07-25 15:30:56 +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
6695ca3f34 [client] ds: remove SDL display server 2021-07-18 10:34:41 +10:00
Geoffrey McRae
03c247a9ff [client] x11: make use of eglSwapBuffersWithDamage if it's available 2021-07-17 21:09:51 +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
Geoffrey McRae
203ebc73eb [client] x11/opengl: enable double buffering for OpenGL
Drawing to the front buffer directly requires special handling to
prevent seeing the draw progress (avoiding glClear, etc) and as a result
the output is quite bad unless a compositor is running. Also vsync if
enabled will not function without double buffering enabled.

As OpenGL is the legacy fallback, there are no plans to implement clean
front buffer draw support, so just enable double buffering.
2021-07-02 21:45:12 +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
Geoffrey McRae
facbb54776 [client] x11: create _NET_WM_BYPASS_COMPOSITOR if it doesn't exist
If a compositor has not yet started or is not running the atom
`_NET_WM_BYPASS_COMPOSITOR` may not have yet been created. As such we
need to create it so that if a compositor is started it will see this
propery and honour it.
2021-06-17 11:16:26 +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
5c00f73d23 [client] x11: use correct spelling of _NET_WM_BYPASS_COMPOSITOR
The incorrect spelling, NETWM_BYPASS_COMPOSITOR, somehow worked in the
past, but it appears to not work right now. Corrgan on Discord reported
the issue and confirmed that changing the spelling allowed the compositor
to be bypassed and the client to update faster than 60 Hz on his mixed
refresh rate setup.
2021-06-07 11:17:06 +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
Geoffrey McRae
9ddfacc1a8 [client] x11: update to support new spice clipboard type list 2021-05-30 11:37:31 +10:00
Geoffrey McRae
118d9a086e [client] x11: implement win:noResize
This is the final fix for #506
2021-05-28 20:16:22 +10:00
Geoffrey McRae
3be645a357 [client] x11: fix BadAtom when pasting large buffers
To start a clipboard incr transfer the client has to delete the INCR
window property as the reply to the selection. This deletion generates a
property change event with the type delete, errornously triggering the
incr processing of the data. This patch corrects this by ignoring
property deletions.
2021-05-27 18:41:54 +10:00
Geoffrey McRae
95ec206b36 [client] x11: cosmetics 2021-05-27 18:41:54 +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