Commit Graph

600 Commits

Author SHA1 Message Date
Quantum
c7666b065a [client] main: print out CPU information on startup 2021-08-31 20:14:10 +10:00
Quantum
79a9127c04 [client] imgui: use consistent modal background colours
The translucent white modal background sort of cancels out the dark
background we apply to the overlay, which is undesirable. It should
instead further darken the background.

For consistency, we now use igGetColorU32Col(ImGuiCol_ModalWindowDimBg)
to draw the overlay background, to avoid hardcoding the same colour in
multiple places.
2021-08-31 09:09:26 +10:00
Quantum
31249da533 [client] imgui: run animations at consistent speeds
Currently, this is visible through how fast the cursor blinks, with it
blinking faster at higher refresh rates. This commit makes the timing
consistent.
2021-08-31 08:16:07 +10:00
Quantum
9bd205a527 [client] imgui: fix modifier key modification race
imgui really hates it when we update the modifier key state after igNewFrame.
The result is:

    void ImGui::ErrorCheckEndFrameSanityChecks(): Assertion
    `(key_mod_flags == 0 || g.IO.KeyMods == key_mod_flags) &&
    "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"'
    failed.

Therefore, we buffer the modifier state information and update it in the IO
object right before we call igNewFrame.
2021-08-20 13:21:50 +10:00
Quantum
c0fa6c414c [client] spice: do not warp host cursor if guest cursor is not visible
This avoids warping the host cursor when the guest-side warp has not finished,
which will result in the host cursor exiting at the wrong position if it exits
at that moment.
2021-08-20 13:21:26 +10:00
Quantum
11a661ce3a [client] spice: don't display mouse before realignment finishes
This avoids showing the mouse briefly at the old position when reentering
the window.
2021-08-20 13:21:26 +10:00
Geoffrey McRae
c246b4a719 Revert "[client] core: realign in the enter/focus handlers if possible"
This reverts commit 17617cc421.
2021-08-19 23:19:59 +10:00
Geoffrey McRae
17617cc421 [client] core: realign in the enter/focus handlers if possible 2021-08-19 22:57:03 +10:00
Geoffrey McRae
e1a4401ffa [client] core: wait for the host to process the cursor move 2021-08-19 22:17:22 +10:00
Geoffrey McRae
3c3c0f70be [all] bump the LGMP version to obtain access to data serial tracking 2021-08-19 21:29:03 +10:00
Quantum
429620c48b [client] egl: dynamically import glBufferStorageEXT
On some implementations (e.g. llvmpipe), the function can only be queried via
eglGetProcAddress.
2021-08-19 21:28:45 +10:00
Quantum
1c7d14169e [client] kb: rename key code arrays from xfree86_* to linux_*
We are using Linux key codes defined in input-event-codes.h, not XFree86
stuff.
2021-08-17 19:08:07 +10:00
Quantum
81c38e825c [client] remove all casts around malloc
The cast is unnecessary in C and should be removed to avoid clutter.
2021-08-16 16:26:58 +10:00
Quantum
8a5efef622 [client] spice: avoid spice_key_modifiers when input is disabled 2021-08-16 16:25:11 +10:00
Tudor Brindus
14ad83c6b8 [client] use variable-relative sizeof where possible 2021-08-16 16:22:55 +10:00
Quantum
3a00277e93 [client] spice: add ability to set keyboard LED state in guest
FIXME: update PureSpice
2021-08-15 09:46:31 +10:00
Quantum
9414449408 [client] app: add ability to receive keyboard typing in overlays 2021-08-14 14:44:26 +10:00
Quantum
5f3bd778c0 [client] egl: add debug prints for renderStartup errors 2021-08-14 12:20:12 +10:00
Quantum
16adbab5d4 [client] all: remove needless initalization 2021-08-14 12:19:07 +10:00
Quantum
579f998519 [client] all: replace assert with DEBUG_ASSERT 2021-08-14 12:19:07 +10:00
Quantum
85a96d1e06 [client] all: use DEBUG_UNREACHABLE instead of assert
Due to the way assert is defined in standard C, compilers in release mode
will not treat it as unreachable. This explains a lot about those pesky
uninitialized variable bugs, actually.
2021-08-14 12:19:07 +10:00
Quantum
a76b274e1a [client] main: use ARRAY_LENGTH macro 2021-08-13 20:24:01 +10:00
Geoffrey McRae
35bd641d2a [client] overlay: remove the unused menu bar 2021-08-12 15:54:16 +10:00
Geoffrey McRae
6387bf2d2e [client] rework the configuration overlay to allow for tabs 2021-08-12 09:04:45 +10:00
Quantum
7e982a6658 [client] util: replace util_mergeOverlappingRects with common version 2021-08-11 19:01:52 +10:00
Geoffrey McRae
4f1136d0cd [client] core: dont warp the cursor if the overlay is active 2021-08-10 16:08:13 +10:00
Geoffrey McRae
f2b8ff9e8d [client] app: make overlay mode more transparent 2021-08-10 01:15:31 +10:00
Geoffrey McRae
69f6532b8d [common] ringbuffer: allow reverse iteration 2021-08-09 14:06:32 +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
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
16f68d6b1b [client] main: don't call stopWaitFrame if jitRender is not enabled 2021-08-08 09:01:48 +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
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
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
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
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
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
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
Geoffrey McRae
f3413815a9 [client] egl: re-implement DMABUF (untested) 2021-08-03 03:59:03 +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
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
Geoffrey McRae
9d95154b85 [client] main: make use of new needs_render call 2021-08-01 18:44:35 +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
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
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
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
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
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
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
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