Commit Graph

52 Commits

Author SHA1 Message Date
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
Christian Hergert
353a6d905d session: create MksScreen from GDBusObject
This uses the object manager object instead of the proxy directly to
create the MksScreen instances.

We might want to move the object initialization to MksDevice since it
is likely to be copied across a number of device types.
2023-02-09 01:36:54 -08:00
Christian Hergert
b976580e43 session: use GDBus object manager to track objects
This changes things to use the object manager to discover the VM instance.
We'll have to add support for other wrappers to use object managers so that
they can be added to the devices list as they are seen.
2023-02-09 01:14:47 -08:00
Christian Hergert
0af4760feb build: ensure access to enums from libmks_dep 2023-02-09 00:23:37 -08:00
Christian Hergert
169acba1bc screen: add MksScreen:number property
This correlates to "head" of the D-Bus interface, which makes for a
terribly non-descriptive property name.
2023-02-08 23:26:35 -08:00
Christian Hergert
d16440566b screen: add width and height properties
Keep them up to date when the underlying MksQemuConsole properties are
notified of having changed.
2023-02-08 23:21:06 -08:00
Christian Hergert
12edec8262 screen: add keyboard and mouse properties
Adds MksKeyboard and MksMouse types. Setup a MksScreenKind for the
MksScreen based on MksQemuConsole:type property. Currently the keyboard
and mouse are not wired up, but here for scoping out the properties.
2023-02-08 21:58:35 -08:00