Commit Graph

158 Commits

Author SHA1 Message Date
Christian Hergert
6a024f0e5d Merge branch 'bilelmoussaoui/reconfigure' into 'main'
display: Reconfigure screen when size change

See merge request chergert/libmks!13
2023-05-17 20:11:49 +00:00
Bilal Elmoussaoui
c259212be5 dmabuf: Properly propagate damage area
The current approach makes use of
- A tiled rendering to work around gdk_texture_diff only doing pointer
comparaison
- Assumes that we would only recieve a scanout cmd followed by multiple
flush ones

In reality, with virtio-gpu at least, the scanout cmd is always
submitted followed by a flush one containing the damaged region.

With the assumption currently made, we end up creating a new paintable
for every scanout cmd causing a full redraw instead
of only redrawing the damaged areas.
Isntead we create the paintable once and call import whenever
we receive a flush cmd (UpdateDMABUF) so we can properly
pass the damage area when creating a GdkGLTexture making
the tiled rendering no longer needed.
2023-05-17 13:08:37 -07:00
Bilal Elmoussaoui
51f8615099 build: Set the pkg-config name when generating GIR
Should help gi-docgen figure out the pkg-config name to display in the
docs
2023-05-14 19:03:01 +02:00
Bilal Elmoussaoui
2636c9e1a9 build: Various fixes to auto generated sources
Needed to fix the build when GTK is also built from a subproject
2023-05-14 19:03:01 +02:00
Bilal Elmoussaoui
a804f766f9 display: Reconfigure screen when size change
Otherwise the VM would have no idea about the size of the target widget.
To do so, we introduce a ScreenResizer object that remembers the previous
screen attributes as well the next attributes to configure.
Taking care of scheduling resize operations and avoids submitting
the same attributes twice.
2023-05-10 00:32:35 +02:00
Christian Hergert
cd7825d9d5 build: allow -Dtracing for more logging information 2023-04-20 14:00:04 -07:00
Christian Hergert
15e6667292 Merge branch 'add-vala-support' into 'main'
Add VAPI (vala) support

See merge request chergert/libmks!11
2023-04-20 20:46:21 +00:00
Felipe Borges
14c368d9e7 Add VAPI (vala) support 2023-04-17 12:46:26 +02:00
Bilal Elmoussaoui
26f4b72708 display-picture: Don't compute min-width/min-height
They are not useful for us as we would like the user to be able to
shrink the picture.
It is a leftover of migrating from GtkPicture
2023-04-13 15:13:27 +02:00
Bilal Elmoussaoui
b4fade7fe1 cleanup: Drop useless conditions 2023-04-13 15:04:40 +02:00
Christian Hergert
188c63a183 Merge branch 'bilelmoussaoui/fix-focus' into 'main'
display: Grab focus on MksDisplayPicture

See merge request chergert/libmks!8
2023-04-04 03:28:32 +00:00
Christian Hergert
02edb73d2a Merge branch 'bilelmoussaoui/expose-translate-keycode' into 'main'
keyboard: Expose keycode translation helper

See merge request chergert/libmks!7
2023-04-04 03:26:14 +00:00
Christian Hergert
5d1f5818c9 Merge branch 'bilelmoussaoui-main-patch-70944' into 'main'
display-picture: Fix keyval value

See merge request chergert/libmks!6
2023-04-04 03:23:29 +00:00
Christian Hergert
8e7702012a Merge branch 'bilelmoussaoui/fix-session-ctor' into 'main'
session: Fix the display dbus path

See merge request chergert/libmks!5
2023-04-04 03:23:13 +00:00
Bilal Elmoussaoui
5783b6a8ce display: Grab focus on MksDisplayPicture 2023-04-03 22:17:31 +02:00
Bilal Elmoussaoui
57370d5a73 keyboard: Expose keycode translation helper
Useful for exposing keyboard shortcuts triggers on the UI
Similar to what Boxes does for Ctrl+Shift+F
2023-04-03 17:33:11 +02:00
Bilal Elmoussaoui
df42bbb20e display-picture: Fix keyval value 2023-04-03 13:31:33 +00:00
Bilal Elmoussaoui
266f1ae834 session: Fix the display dbus path
As that is what implements the ObjectManager interface
2023-03-31 10:57:10 +02:00
Bilal Elmoussaoui
c7ba1c0104 build: Add an option to disable introspection 2023-03-30 13:15:00 +02:00
Bilal Elmoussaoui
89d37ada0d lib: Add missing headers & fix enums install dir 2023-03-29 13:09:33 +02:00
Christian Hergert
1d68a4d8f4 lib: wire up various signal handlers for audio out listener 2023-03-02 20:38:30 -08:00
Christian Hergert
378c9614ed lib: use source for cairo fill operator 2023-03-02 17:55:30 -08:00
Christian Hergert
088e1b5ce4 keyboard: add tracing macros 2023-02-28 18:57:17 -08:00
Christian Hergert
b3a0a4028c lib: add tracing for MksMouse 2023-02-28 12:49:37 -08:00
Christian Hergert
edd88dcec3 util: add simple tracing macros 2023-02-27 20:23:25 -08:00
Christian Hergert
e4d089fb52 util: fix typo 2023-02-27 20:16:17 -08:00
Christian Hergert
1d51bffe8f lib: implement basics for audio out stream 2023-02-27 18:44:42 -08:00
Christian Hergert
ec60165c70 lib: ensure UnixFDList availability for AudioIn/Out 2023-02-27 18:43:39 -08:00
Christian Hergert
98032981cd util: add socketpair GDBusConnection helper 2023-02-26 10:57:50 -08:00
Christian Hergert
294e01836d speaker: add autoptr cleanup func 2023-02-26 10:57:33 -08:00
Christian Hergert
39a0bb2658 lib: add MksSpeaker
This isn't attached to AudioOut interface yet, but starts on the API to
be defined for that.
2023-02-18 09:44:21 -08:00
Christian Hergert
af901239d0 lib: remove unused typedefs 2023-02-17 16:43:58 -08:00
Christian Hergert
826967840a lib: handle NULL display during gir generation 2023-02-17 16:40:53 -08:00
Christian Hergert
04e2bf0b00 lib: don't propagate when creating inhibitor 2023-02-17 16:30:46 -08:00
Christian Hergert
a12ee6da68 build: add -lm to library 2023-02-17 16:27:53 -08:00
Christian Hergert
4c7711823a lib: make cairo formats conditional 2023-02-17 16:27:36 -08:00
Christian Hergert
8ed9c7eedc lib: dont set initial cursor to none
Honestly, Qemu *probably* should be calling into us with the cursor after
we connect to get this right, but it doesn't which leaves the user with a
bit of an issue if there is no active cursor.
2023-02-17 16:02:16 -08:00
Christian Hergert
f5935b38cf lib: handle any potential changes to type 2023-02-17 15:59:48 -08:00
Christian Hergert
459cb173b0 lib: add MksDisplay:ungrab-trigger
This allows setting a customizable trigger which may be used to ungrab
the display. Currently, the default is ctrl+alt+g and the only thing that
will be released is the shortcut inhibition.
2023-02-17 15:50:02 -08:00
Christian Hergert
1a4bcb8c31 lib: release inhibitor with dispose 2023-02-17 15:38:06 -08:00
Christian Hergert
3794f43ee1 lib: acquire inhibitor on first mouse-press
This will allow us to receive input like Super for the activities overview
while the widget is active.

We still need a way to release the grab, but that will come soon.
2023-02-17 15:34:36 -08:00
Christian Hergert
edfe01bf99 lib: add inhibitor helper
This is an object which is meant to be acquired/released in response to
user input. Currently, it will inhibit the shortcuts in the display server
if possible.

Some additional things may be added eventually like relative pointers or
similar (by grabbing pointer input).
2023-02-17 15:33:40 -08:00
Christian Hergert
87a800510b lib: use GDK_SCROLL_SMOOTH to enumlate wheel scroll
It's really annoying when a touchpad doesn't work at all in a MKS session.
So instead of doing nothing, at least try to send a wheel event so that
some amount of scroll may occur.

Eventually, we need a real touchpad D-Bus interface to deliver events.
2023-02-17 11:49:33 -08:00
Christian Hergert
d0909732f4 lib: add MksDisplayPicture
This is a child widget to the MksDisplay which contains just the paintable
region of the remote screen. Doing so allows us to avoid having to handle
crossing events carefully for things like cursors.

Instead, now the MksDisplay calculates the area for the picture and
allocates it there. The MksDisplayPicture will always snapshot the
paintable using the full area it has been allocated.

Event processing can also largely move into the Picture widget which
simplifies bounds checking.
2023-02-17 11:40:47 -08:00
Christian Hergert
24dafbe067 lib: handle GL textures with y0 at top 2023-02-15 19:40:48 -08:00
Christian Hergert
5657997f4a lib: set controller to capture phase
Just so we don't chance it and loose events to GTK.
2023-02-15 19:22:57 -08:00
Christian Hergert
d533773cf7 lib: fix absolute x,y mouse position 2023-02-15 18:02:51 -08:00
Christian Hergert
a57f55e24c lib: remove "none" initial cursor
We don't always get a cursor from the peer at startup. So ignore it until
we get a cursor delivered.
2023-02-15 18:00:29 -08:00
Christian Hergert
7d7ccea630 lib: allow shrinking display 2023-02-15 17:52:48 -08:00
Christian Hergert
62f084b0b4 lib: robustness fixes for mouse movement 2023-02-15 17:52:40 -08:00
Christian Hergert
0a7c1ff21c lib: use mouse-set from peer to update local position
We may need to tweak this for relative mouse positions if we find we dont
get reliable information from the peer. But this is a start, which I see
we get back from Qemu at least when we're in -enable-kvm mode.
2023-02-15 12:16:47 -08:00
Christian Hergert
03f64892e5 lib: add marshallers for internal use 2023-02-15 12:15:54 -08:00
Christian Hergert
5c52047800 lib: set cursor from guest provided texture data 2023-02-15 12:02:03 -08:00
Christian Hergert
8dd08014b1 lib: set "none" for cursor in display
We have a remote cursor to deal with.
2023-02-15 11:34:38 -08:00
Christian Hergert
3d89b77ed2 lib: ensure display widget is focusable
Otherwise we won't get keyboard input.
2023-02-15 11:34:17 -08:00
Christian Hergert
7c63e051fd lib: use legacy event controller
Now that we are doing our own paintable management, we can more easily
transition to doing our own event management with the Legacy event
controller (which, despite the name, really just allows us to get more
direct GdkEvent for processing).

Additionally, this adds support for scroll events to the guest.
2023-02-15 10:38:24 -08:00
Christian Hergert
eb32afc2a9 lib: add util to check for inverted scroll
This has limited functionality because what we really need is support for
wayland!183 as it would only work unsandboxed.

But it provides a convenient abstraction point for implementing that as
well once we have it.
2023-02-15 10:32:05 -08:00
Christian Hergert
2286183747 lib: export paintable properties
This is mostly useful so that we can see things within the inspector at
runtime in case we need to debug what backends are used.
2023-02-15 07:01:32 -08:00
Christian Hergert
a8505e1245 lib: remove use of GtkPicture
We want a bit more control over things than we can get with GtkPicture so
do the snapshot/measure internally. This allows us to know where the
picture is to be allocated so that we can translate pointer events to the
location within the console.
2023-02-15 06:47:10 -08:00
Christian Hergert
b626904171 lib: fix texture clipping and bounds for DMA-BUF 2023-02-14 17:35:44 -08:00
Christian Hergert
2e842f7e7f lib: add GdkDmabufPaintable
This just starts on the DMA-BUF code and abstracts MksPaintable so it can
encapsulate both MksDmabufPaintable and MksCairoFramebuffer.

Currently, the dmabuf just tailes everything (fully) but we can fix that
with snapshot work stil. Either way, want to get the abstraction landed
first before we dive deeper into that.
2023-02-14 16:27:09 -08:00
Christian Hergert
f335b4cb45 lib: use 128 pixel textures
These come out to 64kb with 4 bytes-per-pixel which seams reasonable
enough for texture uploads.
2023-02-14 14:26:23 -08:00
Christian Hergert
6c5829d949 lib: make clicks and motion work
We need to handle a mouse that is not absolute positioned (the default it
seems) and this does that (crudely for the moment until we have some sort
of grab management).

Additionally, click events are propagated to the Qemu instance as well.
2023-02-14 14:19:12 -08:00
Christian Hergert
beb7299d25 lib: add basic input controllers to MksDisplay
Still plenty to do on the motion bits, but at least basic key controller
events propagate now.
2023-02-14 13:34:45 -08:00
Christian Hergert
9609a63e2a lib: add xorgevdev to qnum translations
We'll likely need more of these, but this is the basic needed to get things
going on Linux, where this is intended to work for now.
2023-02-14 13:34:06 -08:00
Christian Hergert
cc7d267814 lib: add missing finish functions for key press/release 2023-02-14 13:33:29 -08:00
Christian Hergert
ddd6a58adc lib: use g_variant_get_data_as_bytes() to get byte array
We don't want to go through get_bytestring() as this is a bit cleaner as
to ensure we're holding onto references for the rest of the function
lifetime. Otherwise, completing the operation could cause our parameters
to be released (at least theoretically).
2023-02-14 12:24:15 -08:00
Christian Hergert
de3505e864 lib: remove debug code 2023-02-14 12:23:24 -08:00
Christian Hergert
2efcaed79a lib: use cairo_paint()
We don't care about paths here, so just use cairo_paint().
2023-02-14 12:23:06 -08:00
Christian Hergert
441b7355ef lib: tweak cairo drawing a bit and fix invalidation 2023-02-14 11:59:04 -08:00
Christian Hergert
6beaf8b925 lib: encapsulate GtkPicture within MksDisplay
We don't need to do this manually now that we have GtkPicture working
correctly with content-fit. We still want to maintain our own widget to
manage things like grabs and all that though.
2023-02-14 11:18:48 -08:00
Christian Hergert
d8d2b60a93 lib: fix height usage in aspect ratio 2023-02-14 10:37:12 -08:00
Christian Hergert
d20dcd2674 lib: start on MksDisplay widget 2023-02-13 21:53:57 -08:00
Christian Hergert
3bc40bdb7b lib: remove scaling code
This is a GtkPicture oddity and we shouldn't paper over it here. Instead
we can handle it in the display widget.
2023-02-13 20:55:49 -08:00
Christian Hergert
01dab99590 lib: add MksCairoFramebuffer
This adds MksCairoFramebuffer which does tessellation to get damage regions
for the framebuffer. Still some bugs involved, but good enough to get some
bits on the screen which is what I'm looking for right now.
2023-02-13 17:38:30 -08:00
Christian Hergert
84d1d827c1 lib: start wiring up framebuffer to paintable
Still things to sort out here, but just wanted to lay some plumbing
between the two objects.
2023-02-12 10:39:14 -08:00
Christian Hergert
2a0f0be8c0 lib: decode pixman_format_t into cairo_format_t 2023-02-11 09:19:29 -08:00
Christian Hergert
204271fafd lib: add pixman format conversion to cairo format 2023-02-10 17:32:09 -08:00
Christian Hergert
35d99a50b1 lib: stub out success for various RPCs 2023-02-10 17:21:33 -08:00
Christian Hergert
56e9997919 lib: connect asynchronously to socketpair peer
Because the other side is doing AUTHENTICATION_SERVER, which really it
has no business doing any flags, we have to connect asynchronously or we'd
block because it doesn't yet have our FD to communicate with.

So connect asynchronously, return our FD, and then process from there.

This is somewhat annoying because it means you can't connect your
object until the otherside already sees our connection. We delay message
processing to help with that though.
2023-02-10 17:13:05 -08:00
Christian Hergert
bcf65d7374 lib: add mks_session_ref_screen()
This is just a helper to get the first screen.
2023-02-10 16:29:57 -08:00
Christian Hergert
084edf38eb lib: fix params to socketpair() 2023-02-10 16:29:38 -08:00
Christian Hergert
ed03ea5148 lib: move PaintableListener into MksPaintable
The goal here is to keep the MksPaintableListener inside of MksPaintable
so that we don't have to create API between the two. Additionally, the
MksPaintable can own it's own G-DBus connection as we don't want to share
them for updates with anything else (as they can have large data chunks
coming across).
2023-02-10 16:14:51 -08:00
Christian Hergert
07158dfa07 lib: add a framebuffer paintable
This is intended to be the software fallback path where we have to take
Update() and Scanout() method invocations from the Qemu instance. It
implements paintable and tries to reuse a backing texture until a threshold
has been met at which point it does a full redraw.

The backing texture is reused between snapshots to increase the chance that
we may skip a followup VRAM upload to the GPU. The damage rectangles will
be re-uploaded each frame. There is some opportunity to optimize that
last part by keeping them around and adding a secondary damage region.

Of course, we would still want things to go the MksDmabufTexture path
when possible.
2023-02-10 12:47:35 -08:00
Christian Hergert
8abd0b22cf build: keep sources list near other sources 2023-02-10 12:44:50 -08:00
Christian Hergert
81d4c9639c lib: create scaffolding for DMA-BUF texture
This will eventually be used with two copies of the texture, and then
swap between them.
2023-02-10 10:37:07 -08:00
Christian Hergert
ed27fc97d8 build: fix various GObject Introspection notation 2023-02-10 10:29:29 -08:00
Christian Hergert
629cfd0e28 lib: add mks_screen_attach()
This is ultimately going to give us back a paintable, but it's only in
partial state right now. We need to figure out the right semantics for
ownership between the listener/paintable/screen/etc.

We may want the widget to be the owner of everything (and keep the
painable/listener internal API) which is likely the most convenient from
an object ownership standpoint.
2023-02-09 17:32:00 -08:00
Christian Hergert
5e75216318 lib: stub internal listener skeleton
This is an org.qemu.Listener using the gdbus-codegen generated skeleton as
the parent type.

What will probably happen here, is that we create a MksPaintable which is
given to the listener to call internal API upon.

The paintable code will be a bit more complex than originally anticipated
in that we are going to need to do our own tessellation so that we get
damage regions which are not the whole widget. Very similar to what I did
in the GdkMacosTile for gdk/macos/.
2023-02-09 17:30:38 -08:00
Christian Hergert
c9aa3a1a03 lib: add missing D-Bus annotations for UnixFDList 2023-02-09 17:28:25 -08:00
Christian Hergert
9bb71b8ea8 lib: add MksScreenAttributes and mks_screen_configure()
MksScreenAttributes is an opaque type with setters so that we can
potentially extend it in the future without ABI issues.

Furthermore, this adds a configure API for both sync and async to
MksScreen.

Currently, I get NOT_SUPPORTED back from Qemu, but I think that's because
I'm not even past the bootloader/EFI stage for tests.
2023-02-09 15:39:03 -08:00
Christian Hergert
0478d202f8 lib: add session weak pointer to devices
This is handy because it gives devices the ability to locate/coordinate
with other subsystems.
2023-02-09 12:54:48 -08:00
Christian Hergert
dac3fc284a lib: add MksPaintable
This is intended to be connected to a MksScreen and create a Listener to
get DMA-BUF scanout from Qemu.
2023-02-09 04:38:48 -08:00
Christian Hergert
96f3235897 lib: add MksMouse press, release, and motion API 2023-02-09 03:44:45 -08:00
Christian Hergert
8898636ac4 lib: add MksScreen:device-address
Can be handy when troubleshooting things, so wrap that too.
2023-02-09 03:21:43 -08:00
Christian Hergert
c35baef43e lib: add MksMouse:is-absolute property 2023-02-09 03:10:42 -08:00
Christian Hergert
76b74b0769 lib: add press and release MksKeyboard API
This currently wraps the internal layers. The real magic will happen in
a GtkWidget with event controllers to proxy things here.
2023-02-09 03:00:36 -08:00
Christian Hergert
4075f1c2ba lib: expose keyboard modifiers as flags property 2023-02-09 02:47:42 -08:00
Christian Hergert
4d110d5791 lib: make MksDevice classes internal
We want to use the vfunc of the class to implement devices coming from a
Qemu object on D-Bus, but we don't want to expose that in public API.

Instead, we can keep the object instance and class internal but still
expose the subclasses as public API. We have to do old-style class
definitions to do that, but worth the ability to keep public API limited
so that we can make changes later.
2023-02-09 02:23:18 -08:00
Christian Hergert
ec09aaaa07 lib: add various include guards 2023-02-09 02:21:29 -08:00