Commit Graph

1591 Commits

Author SHA1 Message Date
Quantum
9b87f4ba5e [client] egl: cycle through multiple textures for dmabuf
This avoids race conditions in GL drivers when attempting to render and
call glEGLImageTargetTexture2DOES on the same texture.

Also, when using glEGLImageTargetTexture2DOES, we do not need to allocate
storage for textures.
2021-08-09 17:12:11 +10:00
Geoffrey McRae
1fd726eed7 [client] x11: be less sensitive to frame skips
External events like launching other applications can cause latency
spikes while X11 initializes the application, we should only start
adjusting our delay if we see excessive skips over a 1s period.
2021-08-09 15:51:01 +10:00
Geoffrey McRae
bc7e59c9d7 [client] x11: prevent present event loop underruns
Queue up and maintain a list of presentation timestamps to avoid spikes
caused by X11 event processing latency.
2021-08-09 15:24:12 +10:00
Geoffrey McRae
179eaef29d [client] x11: switch to epoll for event wait loop 2021-08-09 15:23:44 +10:00
Geoffrey McRae
f50ef4c23c [client] egl: remove includes from testing 2021-08-09 14:13:03 +10:00
Geoffrey McRae
86d6b67337 [client] egl: rework egl to accomodate post-processing filtering 2021-08-09 14:08:10 +10:00
Geoffrey McRae
69f6532b8d [common] ringbuffer: allow reverse iteration 2021-08-09 14:06:32 +10:00
Geoffrey McRae
91d1b8d2cd [client] egl: refactor egl_texture_free to use project naming standards 2021-08-08 17:52:13 +10:00
Geoffrey McRae
baf9661530 [client] egl: remove texture->ops indirection 2021-08-08 17:31:52 +10:00
Geoffrey McRae
2141046da9 [client] opengl: refactor to use project naming standards 2021-08-08 17:21:25 +10:00
Geoffrey McRae
266ad27998 [client] egl: refactor to use project naming standard 2021-08-08 17:16:10 +10:00
Geoffrey McRae
f4a925a750 [client] main: destroy and finish fontconfig usage
Fixes ASAN reported memory leak
2021-08-08 16:21:48 +10:00
Geoffrey McRae
30ed563504 [client] interface: refactor to use camlCase function names 2021-08-08 15:43:42 +10:00
Geoffrey McRae
d347b28481 [client] egl: implement free for texture frambuffer 2021-08-08 15:35:13 +10:00
Geoffrey McRae
f8ae291090 [client] interface: switch to using UPCAST for the renderer's data 2021-08-08 15:32:01 +10:00
Geoffrey McRae
45d1f27fb4 [client] interface: rename LG_Renderer to LG_RendererOps
Part of the standardisation of using the `Ops` suffix for all interfaces
2021-08-08 14:43:04 +10:00
Geoffrey McRae
1a8267d55a [client] interface: cleanup the renderer interface
Removes the silly typedefs and adds some basic documentation as to the
usage of each function.
2021-08-08 14:39:40 +10:00
Quantum
b822e255d8 [client] egl: attempt DMABUF import and fallback if it fails
This should deal with drivers not supporting our DMABUF without attempting
to identify the drivers and blacklist them.
2021-08-08 09:53:47 +10:00
Geoffrey McRae
037b76750a [client] egl: revert glsync changes
`process` and `bind` are called from the same thread in order, there is
no need for atomic usage here.

This reverts commit 3d7dbd6371.
This reverts commit b3db1ba10b.
2021-08-08 09:44:59 +10:00
Geoffrey McRae
e949f2f8d2 [client] egl: texture_framebuffer should call the stream init 2021-08-08 09:43:28 +10:00
Geoffrey McRae
88c91d4752 [egl] texture: use more appropriate vairable names (parent & this) 2021-08-08 09:35:56 +10:00
Geoffrey McRae
3d7dbd6371 [client] egl: sync is now an atomic, access it as such 2021-08-08 09:26:36 +10:00
Quantum
b3db1ba10b [client] egl: eliminate GLsync object leaks
It used to be the case that we overwrite this->sync even if it was non-zero
when updating the texture, without deleting the sync object. If we update
faster than we render, the result would be leaking sync objects.

This commit ensures that sync objects are deleted when they are replaced.
2021-08-08 09:19:04 +10:00
Geoffrey McRae
16f68d6b1b [client] main: don't call stopWaitFrame if jitRender is not enabled 2021-08-08 09:01:48 +10:00
Geoffrey McRae
64da3465b8 [client] x11: invalidate the full window after timeout from expose
Invalidating the entire window on an Expose event causes poor WM
performance when dragging the window around. Instead flag to redraw and
wait for the expose events to stop for 100ms before doing it.
2021-08-08 08:49:46 +10:00
Geoffrey McRae
12d256c7c8 [client] egl: do a full redraw if nightvision is toggled 2021-08-08 08:42:08 +10:00
Quantum
3e32e01c30 [client] egl/imgui: use imgui for night vision gain configuration 2021-08-08 08:42:01 +10:00
Quantum
ac3677d9ae [client] egl: implement partial copies for framebuffer textures
This uses the same line sweep algorithm originally created to copy DXGI
textures to IVSHMEM to implement the copy from IVSHMEM to memory-mapped
pixel buffer objects.
2021-08-08 08:30:11 +10:00
Geoffrey McRae
e755f0befa [client] egl: correct letterbox area clear attempt #3 - sigh 2021-08-07 04:00:18 +10:00
Geoffrey McRae
3e08e7aafa [client] x11: prevent skew from enter/leave/focus and fullscreen events 2021-08-07 03:49:32 +10:00
Geoffrey McRae
9f6ad864ed [client] egl: correct letterbox area clear attempt #2 :) 2021-08-07 03:44:47 +10:00
Geoffrey McRae
ec56b2760a [client] x11: don't allow window manager events to skew cal timing 2021-08-07 03:39:11 +10:00
Geoffrey McRae
e5a138d854 [client] egl: properly clear the letterbox areas 2021-08-07 03:28:52 +10:00
Geoffrey McRae
ad256e0b00 [client] x11: improve presentation sync calibration 2021-08-07 02:36:11 +10:00
Geoffrey McRae
162b1b93db [client] main: don't include the swap into the render timings
If vsync is enabled the swap will block until vblank skewing the timing
metrics.
2021-08-07 01:45:42 +10:00
Geoffrey McRae
0ec66ba210 [client] main: increase render graph max scale to 10ms
Some GPUs (like my K1200) easly exceed 2ms on the render time making
this graph useless.
2021-08-07 01:45:42 +10:00
Quantum
5d3c00717a [client] egl/imgui: use imgui for scaling algorithm selection 2021-08-06 22:49:49 +10:00
Quantum
dc7fd74327 [client] egl: refactor config dialog into main egl module
This will allow other things like scaling to be implemented.
2021-08-06 22:49:49 +10:00
Quantum
5b26017a8a [client] overlay: move separator above donation prompt
It looks really weird having a separator right after a sentence ending in :.
A separator makes the list look detached from the paragraph that introduces
it, which looks awkward. Instead, this commit moves the separator before the
introducing paragraph.

Also added logic to properly pluralize the sentence.
2021-08-06 22:49:02 +10:00
Quantum
6bd454f77f [client] overlay/config: switch to use new URL widget when possible 2021-08-05 22:43:46 +10:00
Quantum
08f3ad504c [client] imgui: implement new widget for displaying URLs
Note that actually opening the browser is not implemented yet.
2021-08-05 22:43:46 +10:00
Geoffrey McRae
afbee641b1 [client] implement support for KVMFR_FEATURE_SETCURSORPOS 2021-08-05 22:19:35 +10:00
Geoffrey McRae
719fec0a45 [client] don't terminate after successful upgrade of LGMP 2021-08-05 21:45:50 +10:00
Geoffrey McRae
2fa09dbd95 [client] allow the user to upgrade if the LGMP version doesn't match 2021-08-05 21:43:49 +10:00
Quantum
65e550a61c [client] egl: pad buffer damage by 1px when rendering desktop
We want to add extra padding to deal with scaling, which may end up blending
with neighbouring pixels.
2021-08-05 08:05:30 +10:00
Geoffrey McRae
0603a55492 [client] x11: prevent possible calibration underflow 2021-08-05 07:11:23 +10:00
Geoffrey McRae
a37b527bbd [client] main: make core overlays register before everything else
The display servers and renderers may want to register their own
overlays in the future, as such we need g_state.overlays to be
initialized to allow for this.
2021-08-05 07:01:28 +10:00
Geoffrey McRae
0af558345f [client] wayland: fix build with libdecor after invalidateWindow change 2021-08-05 06:58:43 +10:00
Geoffrey McRae
44f815409d [client] imgui: ensure the pointer shape is correct
Since we only update imgui's cursor location when the overlay is
enabled, if the last cursor position was showing a shape that is
incorrect when we re-enter the overlay the cursor will be wrong. This
corrects this by updating the location as we enter overlay mode.
2021-08-05 06:55:41 +10:00
Geoffrey McRae
6e7f39edee [client] app: allow selective full invalidation
Overlays only need to trigger a new frame if they have changed and not
full window invalidation, this change allows for this.
2021-08-05 06:47:36 +10:00
Geoffrey McRae
6c84c0eca6 [client] overlay: move keybinds and config into the overlays
This adds a new `earlyInit` call which allows the overlay to register
options before actually being intialized. Also the keybind handling and
state tracking for each overlay has been moved internal to the overlay
itself.
2021-08-05 06:40:06 +10:00
Geoffrey McRae
d90e658e3b [client] main: fix incorrectly hiding the cursor dot in captureOnly mode 2021-08-05 06:11:12 +10:00
Geoffrey McRae
85f3a71dd5 [client] overlay: remember and restore the grab and pointer state
When entering overlay mode if the cursor was previously grabbed we
should restore the state when exiting overlay mode. This will also
correct the pointer setting it to NONE or SQUARE depending on the prior
grab state.
2021-08-05 06:03:09 +10:00
Geoffrey McRae
38ddfc0b61 [client] core: never allow warp when the overlay is active 2021-08-05 05:48:59 +10:00
Geoffrey McRae
ff01a197f3 [client] overlay: don't use the internal function directly for config 2021-08-05 00:57:54 +10:00
Geoffrey McRae
6c44bbb53e [client] egl: use a ui switch for damage display instead of a keybind 2021-08-05 00:56:31 +10:00
Geoffrey McRae
f3f0157d3c [client] overlay: allow registration of runtime configuration options 2021-08-05 00:56:31 +10:00
Quantum
51b9cd4e5a [all] copyright: use unicode copyright sign ©
This is done for consistency with the license strings in appstrings.c.
2021-08-04 21:16:35 +10:00
Quantum
0941bd0fe5 [client] imgui: move cursor change to after rendering overlays
This allows it to take into the overlays into consideration when deciding
which cursor is to be shown.
2021-08-04 10:52:05 +10:00
Quantum
8ebaf92006 [client] main: rename frameTimings to uploadTimings 2021-08-04 10:38:30 +10:00
Quantum
62cd5e9c57 [client] main: add graph for time spent rendering
This is the time spent in the on_render function, not the time between
frames. Having this information helps diagnose slowdowns in renderers.
2021-08-04 10:38:30 +10:00
Geoffrey McRae
9192e2039a [client] imgui: another missed file
Clearly I need to get some sleep :)
2021-08-04 10:37:05 +10:00
Geoffrey McRae
d2c36b8449 [client] overlay: add new configuration overlay [wip] 2021-08-04 10:27:47 +10:00
Geoffrey McRae
80c9f7223a [client] wayland: fix failure to build 2021-08-04 07:21:57 +10:00
Geoffrey McRae
c15d0dc672 [client] ds: waitFrame now returns a bool to force rendering if needed
X11 needs to calibrate to get the best possible latency, as such it
needs the scene to render so that the render time of the scene can be
accounted for in the delay calculation.
2021-08-04 06:49:35 +10:00
Geoffrey McRae
0f7fa32d12 [client] x11: move sleep and calibration code outside of the event loop
Sleeping in the x11 event loop is not ideal as it will introduce latency
when processing other events, instead do this in the waitFrame handler.
2021-08-04 06:34:27 +10:00
Geoffrey McRae
6933c278ce [client] x11: cosmetics 2021-08-04 06:14:27 +10:00
Geoffrey McRae
7fc717a839 [client] x11: don't setup XPresent if jitRender is not enabled 2021-08-04 06:12:21 +10:00
Geoffrey McRae
4e435e6199 [client] ds: tell the display server if jitRender is requested 2021-08-04 06:05:42 +10:00
Geoffrey McRae
366ec16a63 [client] config: use DEBUG_WARN, not fprintf for output 2021-08-04 05:55:34 +10:00
Geoffrey McRae
04c9694ffa [client] config: ensure mouseRedraw is on if jitRender is in use 2021-08-04 05:54:59 +10:00
Geoffrey McRae
f7682c289a [client] egl: always render the black bar areas
Failure to render these causes artifacts/ghosting when the overlays are
using this area, as such we need to always render this area of the
screen.
2021-08-03 22:29:04 +10:00
Geoffrey McRae
4b4a75475a [client] egl: fix out by one error with letterbox rendering
This replaces the scaled `destRect` with a version that uses doubles
correcting the rounding error that is causing a failure to properly
clear the black bar areas.
2021-08-03 22:27:46 +10:00
Quantum
55703b61b7 [client] egl: remove texture copy in DMABUF path
With more efficient rendering due to buffer age support, we no longer need
to copy the texture to avoid excessive dmabuf copies.
2021-08-03 21:37:31 +10:00
Quantum
8545d15c85 [client] egl: warn when EGL_EXT_buffer_age is not supported 2021-08-03 21:37:31 +10:00
Quantum
87aac8cf03 [client] egl: use buffer age extension to render only damaged parts
We avoid rendering any area that has not changed since the buffer was used
and also not covered by an overlay.
2021-08-03 21:37:31 +10:00
Quantum
f9977332a6 [client] egl: convert desktop to use desktop_rects 2021-08-03 21:37:31 +10:00
Quantum
2dca056526 [client] egl: refactor damage mesh generation into desktop_rects
This mesh will later be used to render only damaged portions of the desktop.
We also moved the coordinate transformation for damage overlay into a matrix
and computed by the shader.
2021-08-03 21:37:31 +10:00
Quantum
dd31a7ef93 [client] egl: clean up splash background shader 2021-08-03 21:12:46 +10:00
Quantum
a25c93b28e [client] wayland: document wlroots viewport handling workaround
Add a comment so we don't forget and remove the "useless" code.
2021-08-03 21:12:25 +10:00
Geoffrey McRae
03ed8b7304 [client] x11: added code to calibrate a delay for presentation
XPresent doesn't give us the time before presentation, but the time just
after. This code calculates and calibrates a delay to sleep for before
signaling the wait event for render when using jitRender
2021-08-03 07:51:03 +10:00
Geoffrey McRae
504bf02855 [client] x11: provide an empty rect region to XPresentPixmap
Providing None informs the comppositor that there is full screen damage,
instead we provide an empty rectangle to prevent this behaviour.
2021-08-03 07:49:59 +10:00
Geoffrey McRae
4d9ab81ef4 [client] egl: assert the update provdided is a dmabuf 2021-08-03 04:03:37 +10:00
Geoffrey McRae
f3413815a9 [client] egl: re-implement DMABUF (untested) 2021-08-03 03:59:03 +10:00
Geoffrey McRae
50f9baedba [client] x11: remove junk code from evaluation 2021-08-03 01:11:46 +10:00
Quantum
5d5e4ede1a [client] egl: use new EGL damage count semantics
After the damage queue PR, EGL damage count 0 means no change, and -1 means
invalidate the entire window. However, several other places have different
semantics, and we are not handling them correctly:

1. KVMFR uses 0 to signal invalidating the entire frame, so if we receive 0
   rectangles in egl_on_frame, we should set damage count to -1.
2. The damage overlay treated 0 as full damage, which is now incorrect. This
   is fixed, and now it treats 0 as no update, and -1 as full damage.
2021-08-03 00:57:32 +10:00
Quantum
8d78a5aa95 [commit] wayland: invalidate window on scale changes
This makes it not require new frames for new scale to be properly applied.
2021-08-03 00:57:04 +10:00
Geoffrey McRae
14839dc54e [client] egl: there should only ever be a single sync object 2021-08-03 00:47:59 +10:00
Geoffrey McRae
891ee3e789 [client] x11: make use of the x11 present extension for jitRender
This implementation is a bit dodgy and needs some work but is currently
functional. Consider this feature highly experiemental under X11.
2021-08-02 23:59:26 +10:00
Geoffrey McRae
037788f562 [client] egl: do not set ops, this is done in texture.c 2021-08-02 23:42:46 +10:00
Geoffrey McRae
13d9c84dc9 [client] egl: replace monolithic EGLTexture with modular version
The way things were handled in EGLTexture is not only very hard to
follow, but broken. This change set breaks up EGLTexture into a modular
design making it easier to implement the various versions.

Note that DMABUF is currently broken and needs to be re-implemented.
2021-08-02 23:37:33 +10:00
Geoffrey McRae
e23144aecd [client] overlay: add new needs_render for realtime overlays 2021-08-01 21:13:59 +10:00
Quantum
23c77e8508 [client] egl: use a lock for desktop damage to eliminate all races
There used to be a possible race when a bunch of rectangle is appended, but
the total count is not updated before it's read. Using a lock eliminates
all such races.
2021-08-01 19:54:56 +10:00
Quantum
f08e2ece93 [client] wayland: implement stopWaitFrame 2021-08-01 19:54:28 +10:00
Quantum
f64310320a [client] ds: add stopWaitFrame to terminate waitFrame early
This is used on exit to unblock the render thread.
2021-08-01 19:54:28 +10:00
Geoffrey McRae
695b7b793c [client] main: allow 'catchup' when using jitRender 2021-08-01 19:32:01 +10:00
Quantum
986f92d0db [client] main: use skipFrame and signal frameEvent
We need to signal frameEvent to render the first frame. Otherwise, wayland
fails to configure the window, as configuration happens in EGL swap.
2021-08-01 18:54:55 +10:00
Quantum
2e4614cbc4 [client] wayland: make waitFrame work when not rendering
Implement skipFrame and do various things to wake waitFrame.
2021-08-01 18:54:55 +10:00
Quantum
16aa04d539 [client] ds: add skipFrame method to interface
If this exists, it should be called when waitFrame returns but we don't
wish to render.
2021-08-01 18:54:55 +10:00
Geoffrey McRae
9d95154b85 [client] main: make use of new needs_render call 2021-08-01 18:44:35 +10:00
Geoffrey McRae
f8e1ab8f31 [client] renderers: add new needs_render method to the interface
With jitRender the renderer needs to tell the main application if it
needs to be rendererd, such as during the initial splash screen fade
out.
2021-08-01 18:18:08 +10:00
Geoffrey McRae
2d74c93232 [client] main: alerts and overlay toggles should invalidate the window 2021-08-01 18:04:43 +10:00
Geoffrey McRae
17687fdea3 [client] main: only render if there is actually something to render 2021-08-01 17:39:52 +10:00
Quantum
77b3d45e0e [client] ds: change signalNextFrame to waitFrame 2021-08-01 17:29:15 +10:00
Quantum
37196f1f0e [client] config: disable JIT rendering by default
Without configuring Wayland compositors to send frame callbacks as late as
possible, JIT rendering can increase latency by more than one frame.

For example, by default, sway asks applications to render right after a
vblank, and does its own composition right after a vblank, resulting in
~2 frame's worth of latency. If max_render_time is set on the output,
it composes that many milliseconds before the vblank, losing ~1 frame's
worth of latency. If max_render_time is set on the window also, the frame
callback is sent that many milliseconds before composition, and we achieve
perfectly low latency.

Therefore, out of the box, JIT rendering should not be enabled, as manual
compositor configuration is required for optimal results.

For reference, the following sway settings results in the best latency:

    output <insert output name> max_render_time 1
    for_window [app_id="looking-glass-client"] max_render_time 1

This reverts commit 3baed05728.
2021-08-01 17:29:00 +10:00
Quantum
b3b71d6f02 [client] egl: fix cursor handling when invalidating
If we invalidate the window, we used to not update this->cursorLast, and
this causes us to lose track of the cursor. Now we update this->cursorLast
unconditionally, and this fixes the issue.
2021-08-01 17:28:40 +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
3baed05728 [client] config: enable JIT rendering by default 2021-08-01 12:38:17 +10:00
Quantum
aed370c7ce [client] main: implement just-in-time render mode
When requested, JIT render mode will be used if the display server supports it.
Otherwise, a warning is generated instead.

This essentially uses the signalNextFrame logic for imgui, but for everything.
We automatically enable this mode when overlay is on.

Currently, this exposes some damage tracking bugs in the EGL renderer.
2021-08-01 12:24:19 +10:00
Quantum
b9a7ce17fe [client] egl: use queue of damages
This prevents damage from being overwritten when frames are received
faster than could be rendered.

This implementation cycles between two queues, removing all need for
memory allocation.
2021-08-01 12:11:54 +10:00
Geoffrey McRae
66df99f5fd [client] imgui: don't free the IniFilename until imgui destruction 2021-08-01 00:55:36 +10:00
Quantum
7c3c68b84b [client] imgui: put imgui.ini in $XDG_CONFIG_DIR/looking-glass 2021-07-31 21:19:26 +10:00
Quantum
6109067275 [client] config: load config file based on new lgConfigDir() 2021-07-31 21:11:09 +10:00
Geoffrey McRae
fcbd255e99 [client] app: allow overlay exit with KEY_ESC 2021-07-31 20:51:38 +10:00
Geoffrey McRae
f49948506b [client] move imgui input state reset to it's own core function 2021-07-31 20:51:08 +10:00
Geoffrey McRae
a11a20411b [client] overlay: disable the imgui demo window 2021-07-31 20:32:06 +10:00
Geoffrey McRae
5e2f1b3fac [client] overlay/help: do not always show when in overlay mode 2021-07-31 20:30:52 +10:00
Geoffrey McRae
75a14b8b45 [client] overlay/graphs: allow the window position and size to be saved
This change allows the window position and size to be changed, and
saved/loaded by imgui. Additionally the plots will now scale to the
window size.
2021-07-31 20:21:34 +10:00
Geoffrey McRae
b0c1714777 [client] overlay/fps: allow the window posisiton to be saved 2021-07-31 20:21:17 +10:00
Geoffrey McRae
361ead59d3 [client] overlay/help: use the interactive argument 2021-07-31 19:14:58 +10:00
Geoffrey McRae
41c5688fca [client] overlay: let the overlay know if it's in interactive mode
This also removes the need for the flags member as the overlay can just
opt to not render if it's not in interactive mode.
2021-07-31 19:11:40 +10:00
Quantum
c8dc037e94 [client] imgui: use signalNextFrame if possible
This allows imgui to be rendered at screen refresh rate for supported display
server backends.
2021-07-31 19:05:21 +10:00
Quantum
a213ee960a [client] wayland: implement signalNextFrame with frame callbacks 2021-07-31 19:05:21 +10:00
Quantum
3043296e52 [client] ds: add optional method signalNextFrame(LGEvent)
This method takes an LGEvent and signals it when the next frame should be
rendered in time for the next vblank.

We will be using this to render imgui at screen refresh rate, but this could
potentially be used later to implement a better form of vsync for supported
display servers.

This must be invoked before swapping buffers.
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
9959578cbe [client] app: prevent buttons/keys from being held when focus is lost 2021-07-31 16:40:14 +10:00
Geoffrey McRae
971e91238a [client] main: bump the minimum fps to 60fps when showing the overlay 2021-07-31 16:19:55 +10:00
Geoffrey McRae
3143dc1e84 [client] x11: call app_handleWheelMotion for imgui scroll interaction 2021-07-31 16:12:52 +10:00
Geoffrey McRae
8898496eba [client] imgui: respect WantCaptureKeyboard
If the overlay is active and imgui has set WantCaptureKeyboard we should
ignore the escape key sequences.
2021-07-31 15:55:58 +10:00
Geoffrey McRae
7eb00bd24c [client] app: update imgui key release when guest input is disabled 2021-07-31 15:41:21 +10:00
Geoffrey McRae
a098bab114 [client] overlay: allow the fps and graph windows to be moved 2021-07-31 15:35:53 +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
75e57baf6c [client] config: optionally load config from XDG_CONFIG_HOME
We look for the client config in $XDG_CONFIG_HOME/looking-glass/client.ini.
This is done because it's more conventional, and also allows us to add
additional configuration files, e.g. for the host.

We fallback to $HOME/.config as is standard, and then as a last resort use
getpwuid(getuid())->pw_dir. This is also recommended by the getpwuid manpage:

> An application that wants to determine its user's home directory should
> inspect the value of HOME (rather than the value getpwuid(getuid())->pw_dir)
> since this allows the user to modify their notion of "the home directory"
> during a login session.
2021-07-31 15:06:59 +10:00
Quantum
68d8d95266 [client] config: do not attempt to load non-files as config
Currently, we load /etc/looking-glass-client.ini and/or
~/.config/looking-glass-client.ini as long as they exist, even if they are
not files. We should only load them if they are files.
2021-07-31 15:06:37 +10:00
Quantum
7d78cba38c [client] client: release escape key on focus loss
This prevents the escape key from being treated as held down indefinitely when
losing focus while holding the escape key.
2021-07-31 15:02:57 +10:00
Quantum
b8b70e772e [client] config: print error when app:configFile is not a valid file
This makes it clear to the user that app:configFile is at fault.
2021-07-31 14:59:00 +10:00
Quantum
64c906b801 [client] main: prevent the user from launching looking glass as setuid
We don't want to encourage craziness of people making the client suid to
bypass permission issues on the shm file.

Note: I see no evidence of this happening in the wild, but let's be
proactive.
2021-07-31 14:58:48 +10:00
Quantum
72ccd44681 [client] wayland: pass mouse wheel motion events to imgui 2021-07-31 14:58:35 +10:00
Quantum
7ca5e14938 [client] imgui: implement mouse wheel motion support
The display server should call app_handleWheelMotion as necessary.
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
86b50cc8ab [client] imgui: initialize keymap
This allows ImGui to understand some of the basic key presses.

Also moved the include guard from kb.c to kb.h where it actually makes sense.
2021-07-31 14:57:41 +10:00
Quantum
10a27e7a27 [client] config: automatically update embedded copyright string
The refresh-copyright script now automatically updates the copyright string
embedded in config.c. In order to achieve this, refresh-copyright gained the
ability to reflow text as the situation needs.
2021-07-31 14:57:24 +10:00
Quantum
edabd1bae7 [client] imgui: remove no longer used overlay_utils.cpp 2021-07-31 14:56:49 +10:00
Quantum
f1b1da60ea [client] imgui: improve method for high DPI
We now give ImGui the true logical size of the window and tell it to scale
the framebuffer. To fix the blurry fonts, we continue to load fonts at the
scale necessary for the DPI and use FontGlobalScale to shrink the fonts back
to the logical size. The font rectangle is then expanded by the framebuffer
scaling, resulting in good text rendering.

This method has the advantage of not messing up the sizes of resizable
overlays when moving across monitors.
2021-07-31 14:56:49 +10:00
Quantum
0402dd521a [client] imgui: ask display server to display cursors 2021-07-31 14:56:04 +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
c991de7ccd [client] imgui: improved overlay input handling
1. Overlay always releases confines.
2. Overlay turns off mouse sync with guest.
2021-07-31 14:54:53 +10:00
Quantum
ea2651e39b [client] imgui: darken background when rendering overlays
This replaces the alert that says whether the overlay is enabled or not.

Also, we now always display the help menu in overlay mode.
2021-07-29 19:10:15 +10:00
Quantum
a980cd9406 [client] egl: log when EGL_EXT_image_dma_buf_import is unavailable 2021-07-29 17:03:44 +10:00
Quantum
1c58b3a087 [client] imgui: implement keyboard input forwarding and capture 2021-07-29 17:02:59 +10:00
Quantum
065d90c3f7 [client] imgui: add mode to forward mouse input to imgui 2021-07-29 17:02:59 +10:00
Quantum
6c64965703 [client] egl: make functions that do not need linking static 2021-07-29 16:54:56 +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
009ae02e32 [client] egl: add graph tracking time taken to import frame
This tracks the time taken to load the frame buffer into an OpenGL texture.
2021-07-29 10:08:52 +10:00
Quantum
6ed1f4662d [client] imgui: report failed font atlas building
Also removed the inefficient code to build the default atlas.
2021-07-26 17:08:02 +10:00
Quantum
120fe63c0f [client] egl: keep x/y coordinates of cursor rectangle non-negative
This shifts the rectangles upwards instead of cutting off the rectangles,
but it keeps the code simple.
2021-07-26 07:56:46 +10:00
Quantum
181b165a4b [client] egl: generate correct cursor damage with cursor rotation 2021-07-25 17:35:29 +10:00
Quantum
d9cdc8d26c [client] egl: rotate damage rectangles according to client side rotation 2021-07-25 16:56:48 +10:00
Quantum
d0722349e6 [client] egl: make damage overlay support rendering rotated rectangles 2021-07-25 16:56:48 +10:00
Geoffrey McRae
2ef80a5d34 [client] overlay: cosmetic changes to the overlay display 2021-07-25 16:49:25 +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
Geoffrey McRae
60a58d4d8d [client] all: make it possible to signal full window invalidation
Now that we are drawing with damage rects, when the window is hidden and
then exposed the window may not get fully redrawn. This provides
`app_invalidateWindow` for the display server backend to call when the
screen needs a full redraw.
2021-07-25 15:29:29 +10:00
Geoffrey McRae
8c2a77e84e [client] don't skip the first frame if we do not yet have a frame
A frame serial of `0` is valid and will happen if either the host app
has just started, or the serial has overflowed.
2021-07-25 15:10:40 +10:00
Geoffrey McRae
9dffde74b2 [client] main: skip duplicate frames
When a new client connects to our session the host will repeat the last
valid frame for the new client. This change will detect this and skip
the duplicated frame.
2021-07-25 13:46:48 +10:00
arcnmx
3b37898eb2 [all] use cmake FindPkgConfig IMPORTED_TARGETs 2021-07-24 12:35:48 +10:00
arcnmx
aa2ea05af9 [client] removed unused GMP dependency 2021-07-24 12:35:48 +10:00
arcnmx
38cb348201 [all] make OPTIMIZE_FOR_NATIVE a tristate option 2021-07-24 12:35:17 +10:00
arcnmx
be664c49c8 [all] cmake: use -march=x86-64-v2 when it becomes available
Moves the logic in 0525515 to a common cmake include, and applies it to
the other binaries.
2021-07-24 12:35:17 +10:00
Quantum
f09738678e [client] fonts: remove font rendering machinery 2021-07-23 20:18:12 +10:00
Quantum
0c35d9b057 [client] opengl: remove font management 2021-07-23 20:18:12 +10:00
Quantum
cb9774bbd2 [client] egl: remove font management 2021-07-23 20:18:12 +10:00
Quantum
dd0edc1394 [client] renderers: remove alert handling 2021-07-23 20:18:12 +10:00
Quantum
be44249c05 [client] imgui: converted alerts to use imgui 2021-07-23 20:18:12 +10:00
Quantum
efb5019176 [client] overlay/help: switch to using ImGui's table facility 2021-07-23 18:04:05 +10:00
Quantum
5153d35bb5 [client] renderer: remove on_help from renderer interface 2021-07-23 18:04:05 +10:00
Quantum
036f16b9ef [client] imgui: convert help overlay to use imgui 2021-07-23 18:04:05 +10:00
Quantum
436986d182 [client] imgui: make UI font and size configurable 2021-07-23 16:07:42 +10:00
Quantum
5d053128ac [client] imgui: use improved high DPI rendering
This actually makes imgui render at a higher resolution, avoiding scaling
and resulting blurriness.
2021-07-23 16:07:42 +10:00
Quantum
b5c5ecc074 [client] imgui: support high DPI by scaling framebuffer
This allows overlays to render at correct positions on high DPI displays.
2021-07-23 16:07:42 +10:00
Quantum
56308fcbd1 [client] overlay: use utility function to get ImGui rectangle 2021-07-23 15:54:18 +10:00
Quantum
628bdab21b [client] overlay: remove space checking
Every overlay is now guaranteed to be able to write MAX_OVERLAY_RECTS rects,
and running out of space is now an error.
2021-07-23 15:54:18 +10:00
Quantum
df0397b10b [client] imgui: track last rectangles for overlays
This is necessary in case overlays change size. When this happens, we must
damage the larger of the overlays' rectangles this frame and last frame.
This erases the overlay from where it is no longer appears.

In order to do this, we must keep track of the rectangles for every overlay
with no exception. We cannot short-circuit the generation of rectangles if
we run out of buffer space, and we must allocate space for MAX_OVERLAY_RECTS
rectangles for every frame. Otherwise, we will not know where to erase the
overlay if it disappears.
2021-07-23 15:54:18 +10:00
Quantum
334bfeecea [client] egl: correctly handle mixing imgui and non-imgui overlays
This allows the full frame to be damaged when both types are visible.
2021-07-23 15:53:59 +10:00
Quantum
b26067b0a0 [client] wayland: use new libdecor pkgconfig package name 2021-07-23 15:52:05 +10:00
Quantum
947eac52f6 [client] renderers: treat -1 as full damage and 0 as no overlay
This makes everything consistent.
2021-07-22 18:57:34 +10:00
Geoffrey McRae
eb5c588af9 [client] overlay: call igEnd before return 2021-07-22 18:38:32 +10:00
Geoffrey McRae
3b6ad957e3 [client] overlay: increment totalRects 2021-07-22 18:38:00 +10:00
Geoffrey McRae
4acbf2e9a0 [client] overlay: rework the interface to avoid possible race conditions 2021-07-22 18:33:50 +10:00
Geoffrey McRae
50f7a1a99c [client] overlay: properly free the graphs before ll free 2021-07-22 18:32:28 +10:00
Quantum
515f08d2da [client] egl: transform overlay damage coordinates
EGL uses bottom-up y-coordinate while we use top-down.
2021-07-22 18:32:18 +10:00
Quantum
58ab77d237 [client] egl: avoid overflowing damage buffer
We allocate 10 rectangles for overlay damage as agreed on Discord.
2021-07-22 18:32:18 +10:00
Geoffrey McRae
fdbdf6f167 [client] app: implement new overlay rendering framework
This change set implements a framework for overlays to be registered
that make use of ImGui. See `overlay/fps` for a simple implementation
example.
2021-07-22 17:27:30 +10:00
Geoffrey McRae
30c4a4786b [client] overlay: cosmetic, fix typo 2021-07-22 14:50:10 +10:00
Geoffrey McRae
a34d3bbab4 [client] overlay: windowRects is not an array of pointers 2021-07-22 14:48:08 +10:00
Geoffrey McRae
2310920e79 [client] overlay: added new interface for overlay windows using ImGui 2021-07-22 14:42:54 +10:00
Quantum
85f34602f4 [client] wayland: do not leak wp_presentation_feedback objects 2021-07-22 13:12:47 +10:00
Quantum
27e3be3778 [client] egl: free desktop damage after rendering 2021-07-22 13:12:07 +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
Geoffrey McRae
08293c8721 [egl] damage: only update the damage vbo if there was a new frame 2021-07-21 17:29:46 +10:00
Geoffrey McRae
6389a06903 [client] main: let the renderer know if it's rendering a whole new frame
While the renderer can internally track this it would be better to
simply provide this information to the renderer directly so it can make
better decisions on how best to update the screen.
2021-07-21 17:26:48 +10:00
Geoffrey McRae
8cf444ef31 [client] main: sync to the ups if the ups exceeds minFrameTime 2021-07-21 16:56:49 +10:00
Geoffrey McRae
1c8af28f26 Revert "[client] main: increase the ups/fps update rate to once per 100ms"
This reverts commit b877bab48f.
There is no need for this anymore after the prior commit which removed
this faulty implementation
2021-07-21 16:50:49 +10:00
Geoffrey McRae
9b472d62a9 [client] main: remove/fix faulty upsTime code
The implementation was flawed, instead we just update the presentation
time if there was not an early wakeup.
2021-07-21 16:47:37 +10:00
Quantum
1a88996c47 [client] opengl: don't include <GL/glx.h>
The OpenGL renderer backend should not depend on any particular
implementation of OpenGL, as it's used by both X11 and Wayland.
2021-07-21 12:33:01 +10:00
Geoffrey McRae
3c0ebd54ec [client] main: improve frame rate sync lock with the guest
If the guest is not sending frames at a constant rate, the minimum FPS
timeout may expire drawing an additional frame. This change calculates
the average ups frame time over the past 100ms and adds this to the
timeout value allowing this value to be dynamic.
2021-07-20 15:41:56 +10:00
Geoffrey McRae
b877bab48f [client] main: increase the ups/fps update rate to once per 100ms
This is so that we can use the ups information in the following commit.
2021-07-20 15:40:57 +10:00
Geoffrey McRae
e6e07e8f3f [client] main: use the monotonic clock to calculate the ups/fps
The accumulated time is not the best way to do this as the timer
function callback may not be exactly every 1000ms, by using the
monotonic clock we will get more accurate results.
2021-07-20 15:40:51 +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
563ad18f4e [client] egl: improve cursor damage logic
1. Use atomics and return exact cursor positions from egl_cursor_render
   to avoid race conditions between cursor render and update.
2. Instead of messing with lastCursorValid in various overlays, simply use
   the hasOverlay/hadOverlay logic for cursor damage. This simplifies the
   logic greatly.

As a result, I believe all cursor-related artifacts are fixed.

Note to reviewer: as atomic_init and atomic_store are implemented as macros,
it is currently not possible to pass structs as compound literals due to the
comma being interpreted as an argument separator by the preprocessor.
2021-07-20 11:29:13 +10:00
Quantum
b8effaf42c [client] egl: use glGetError and codes for errors in gl* functions
We used to use DEBUG_EGL_ERROR for gl* functions, which just yields
EGL_SUCCESS even when there are errors.
2021-07-19 19:36:46 +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
Geoffrey McRae
2de9912ac0 [client] egl: EGL_KHR_swap_buffers_with_damage returns EGLBoolean 2021-07-19 13:32:56 +10:00
Geoffrey McRae
33bf668697 [client] app: correct FPS to use an actual per second value 2021-07-19 10:58:40 +10:00
Geoffrey McRae
e4e1451eaa [client] app: give some transparency to the new FPS window 2021-07-18 21:22:16 +10:00
Quantum
7c872d2d9e [client] egl: properly use OpenGL ES
Instead of using the desktop <GL/gl.h>, we properly use the OpenGL ES 3.x
headers. Also, we now use GL_EXT_buffer_storage for MAP_PERSISTENT_BIT_EXT
and MAP_COHERENT_BIT_EXT as the core versions are only available in desktop
OpenGL 4.4. Similarly, we need GL_EXT_texture_format_BGRA8888 for GL_BGRA_EXT
as GL_BGRA is desktop-only.
2021-07-18 20:44:32 +10:00
Geoffrey McRae
ab31040d5f [client] all: use imgui for FPS/UPS display 2021-07-18 20:43:17 +10:00
Quantum
42d8f31eba [client] imgui: use ES 3.0 and remove glew dependency
If we specifically tell ImGui's OpenGL 3.x backend to target OpenGL ES 3.0,
then no extension loader is necessary.
2021-07-18 18:50:12 +10:00
Quantum
c6a6230a56 [client] egl: revert "only copy damaged areas when using dmabuf"
This reverts commit a14de25661.
Frame is sometimes incorrect.
2021-07-18 18:48:35 +10:00
Quantum
a14de25661 [client] egl: only copy damaged areas when using dmabuf
This speeds up the copy significantly when the frame only has small
amount of damage.
2021-07-18 17:41:29 +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
6da9428d85 [client] imgui: use struct for graph metrics instead of array
This allows the members to be named, making the code much easier to read.
2021-07-18 16:15:10 +10:00
Quantum
15bc6a1509 [client] imgui: support registering new graphs
Currently, our struct ll doesn't support removing elements from the middle,
so we will not be removing anything for now.
2021-07-18 16:15:10 +10:00
Quantum
a4bf3c8088 [client] egl: use debug context and make it configurable
The boolean option egl:debug is used to control whether we want debug
output or not. This defaults to true to aid in debugging.
2021-07-18 15:55:50 +10:00
Quantum
6472c28473 [client] egl: upload damage vertices with glBufferSubData
This avoids the issues surrounding glMapBuffer and glMapBufferRange in
OpenGL ES.
2021-07-18 15:55:27 +10:00
Quantum
f49f2af6cd [client] egl: implement error reporting callback
This reports useful information from OpenGL on supported platforms.
2021-07-18 13:54:16 +10:00
Quantum
061b9ba6c2 [client] egl: use vertex array objects in model.c
This eliminates the need to bind the buffers and set up the vertices on
every frame.
2021-07-18 11:58:47 +10:00
Quantum
d4f8426ae4 [client] egl: correctly clean up vertex buffer objects
The code used to use hasBuffer, which was never set to true, so buffer
objects were always leaked instead.
2021-07-18 11:58:47 +10:00
Quantum
e0c9a71cd8 [client] spice: remove dpi which is no longer used
DPI was originally added to workaround cursor movement scaling, but since
due to changes with mouse handling, it's no longer required.
2021-07-18 10:50:57 +10:00
Geoffrey McRae
d44d87ee7f [client] spice: update to use the new epoll version of PureSpice 2021-07-18 10:48:56 +10:00
Quantum
2b3f31700b [client] egl: implement frame damage display 2021-07-18 10:41:50 +10:00
Quantum
12cb3e512f [client] util: add function for merging overlapping rectangles
This will be used to merge overlapping rectangles in order to avoid copying
the same rectangles multiple times.
2021-07-18 10:41:50 +10:00
Quantum
00eb26a34f [client] egl: do not use damage when overlays are visible
This allows the overlays to show up correctly.
2021-07-18 10:41:50 +10:00
Quantum
442ab318fd [client] egl: use desktop frame damage information 2021-07-18 10:41:50 +10:00
Quantum
6695ca3f34 [client] ds: remove SDL display server 2021-07-18 10:34:41 +10:00
Quantum
eb357fa58a [client] egl: use glCopyTexSubImage2D to copy when using DMA
This removes the need for the driver to allocate texture storage and deleting
the previous allocation on every frame update.
2021-07-18 10:34:21 +10:00
Quantum
39ec32b2ef [client] cimgui: build as static library 2021-07-18 10:31:45 +10:00
Geoffrey McRae
df2f623599 [client] app: add keybind to toggle frame timing information display 2021-07-18 09:59:37 +10:00
Geoffrey McRae
73357988e6 [client] main: don't trigger redraws if the video feed is disabled
If the video feed is disabled we are not drawing the cursor, so don't
cause needless redraws
2021-07-17 21:09:51 +10:00
Geoffrey McRae
03c247a9ff [client] x11: make use of eglSwapBuffersWithDamage if it's available 2021-07-17 21:09:51 +10:00
Geoffrey McRae
092ce61908 [client] main: copy & release KVMFR messages sooner
The renderer may take time to process the cursor update due to various
internal factors, as such it's best we copy the data and mark the
message as done ASAP. This prevents the host from filling up the queue
as easily when a high dpi mouse is in use.
2021-07-17 21:09:51 +10:00
Geoffrey McRae
b9d7674b20 [client] imgui: calculate min/max/avg/fps and add them to the plots 2021-07-17 21:09:51 +10:00
Geoffrey McRae
8e3df5a38f [client] main: dont push an invalid value into the timings buffers 2021-07-17 21:09:51 +10:00
Geoffrey McRae
2e76c874cc [client] app: initial imgui frame timings 2021-07-17 21:09:51 +10:00
Geoffrey McRae
c3bc5fb0ff [client] app: collect render and frame timing information 2021-07-17 21:09:51 +10:00
Geoffrey McRae
bcffd70270 [client] app: init/destroy imgui context on run/shutdown 2021-07-17 21:09:51 +10:00
Geoffrey McRae
f08163fd72 [client] imgui: added imgui to the client and OpenGL/EGL renderers 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
59efa6f0ad [client] config: default minimizeOnFocusLoss to off 2021-07-08 08:49:00 +10:00
Geoffrey McRae
1effd5fddc [common] debug: add color support to debug messages
People often miss the warnings about invalid arguments in their command
line, this last minute patch attempts to address this by making
warnings, errors, fixme's and fatal errors stand out if stdout is a TTY.
2021-07-07 23:05:46 +10:00
A.J. Ruckman
1a7b7ce01e [client] Fix narrowing issues with win:shrinkOnUpscale param
Conversion from the float values srcW/srcH to the int values for the client window dimensions would sometimes round down, causing the client to scale instead of matching the host's resolution.
2021-07-06 01:46:33 +10:00
Geoffrey McRae
7c1e8a85cd [client] egl: fix race on resolution change
A resolution switch could cause the renderer state to become invalid as
the texture format may change while it's being rendered. This fixes this
by adding a lock around the format change and render calls to the
renderer.
2021-07-04 21:56:16 +10:00
arcnmx
1345e92ec0 [client] install cmake target 2021-07-03 03:30:53 +10:00
Geoffrey McRae
7b95cc72ed [client] opengl: do not render a sync pending texture 2021-07-02 21:48:31 +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
Geoffrey McRae
d24b031fc5 [client] opengl: cosmetics 2021-07-02 20:10:25 +10:00
Geoffrey McRae
55d185ef9c [client] opengl: no need to re-bind the already bound texture 2021-07-02 19:51:22 +10:00
Geoffrey McRae
9cbc255448 [client] opengl: do not prematurely delete overlay textures
Overlay textures exist for the lifetime of the renderer and as such
should not be deleted when the resolution changes.
2021-07-02 19:50:31 +10:00
Geoffrey McRae
212cc32097 [client] opengl: deconfigure is idempotent 2021-07-02 19:50:15 +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
Geoffrey McRae
9f25f7fced [client] main: display error when the frame has been truncated 2021-06-12 19:06:32 +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
Geoffrey McRae
f07e4839b1 [client] egl: fix dmabuf support 2021-06-08 20:51:09 +10:00
Geoffrey McRae
964403b4f8 [client] egl: tex is now an array, so check it properly for assignment 2021-06-08 20:45:37 +10:00
Geoffrey McRae
20d20f5c8a [client] egl: fix incorrect texture usage
The existing code would overwrite the texture's data even if the texture
is currently being used to render to screen. This changeset generates a
texture for each buffer preventing this invalid usage.
2021-06-08 20:41:22 +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
Geoffrey McRae
b2974c38ef [client] app: cleanup clipboard option logic 2021-06-02 22:19:37 +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
28640295f1 [client] spice: update to support sending clipboard type list 2021-05-30 11:37:15 +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
77c2b895c6 [client] app: only minimize if lost focus when in full screen mode
This fixes a regression caused by the move from SDL2 which handled this
itself. We should only minimize when focus is lost if the application
was in full screen mode.
2021-05-28 19:32:26 +10:00
Geoffrey McRae
09a7e177fa [client] core: fix use of unintalized variable
util_guestCurToLocal may not be able to provide the local position if
we do not yet know where the guest cursor is, or the destination render
rect dimensions. Acting on this when this information is unknown causes
undefined behaivour.
2021-05-28 17:00:13 +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
Jonathan Rubenstein
b2e460d19d [client] doc: Remove README.md as it has been absorbed into doc/install.rst 2021-05-25 16:57:52 +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
Geoffrey McRae
f698e4589d [client] ds: add new minimize function to the ds interface
This change is to allow the application to minimize the window on focus
loss if the user's preferences are configured to do this.
2021-05-06 22:24:42 +10:00
Geoffrey McRae
bdfb18299d [client] core: clamp the local position to the dstRect correctly
When running in a mode that is letterboxed the dstRect origin is not 0x0
2021-05-05 23:18:13 +10:00
Geoffrey McRae
9dd11b5e04 [client] main: fix failure to obey win:autoResize 2021-05-05 23:17:15 +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
Geoffrey McRae
7acbc57bc7 [client] x11: remove pointer motion event mask
This was added as a test when developing the overlapping window code and
is not needed/used.
2021-05-04 18:11:30 +10:00
eater
62725bcb9d [client] egl: show error for glMapBufferRange instead of glBindbuffer 2021-05-04 10:30:03 +10:00