1
0
Fork 0
Commit graph

9234 commits

Author SHA1 Message Date
Jonas Dreßler
a869df1dd7 util: Add a SCREEN_CAST debug topic
This is going to be useful to log dropped frames and other more common
errors about screencasting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1709>
2021-02-05 09:27:38 +00:00
Florian Müllner
ee3d26f228 keybindings: Reset modifier-only-pressed on scroll
Since commit c255031b6d, we allow some modifier+scroll events to
pass through to Clutter to enable gnome-shell to handle them. That
action shouldn't trigger a modifier-only action at the same time, so
reset the corresponding tracking just like we do for modifier+click.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Florian Müllner
ac3d9a0641 events: Process modifier+scroll after keybindings
Allowing the keybindings code to see the event enables it to
process it for its internal modifier-only-pressed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Florian Müllner
7901b98808 display: Expose window_grab_modifiers
Since commit c255031b6d we pass scroll-events through to
the compositor if the window_grab_modifiers are pressed;
in order to allow gnome-shell to check for those events,
expose the struct member as a MetaDisplay property.

Also take the opportunity to pick a more generic name, now
that the modifier is no longer used exclusively for mouse
clicks (unless we maintain the notion of scroll events as
button 4 and 5 "clicks").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Jonas Ådahl
30e1c51b33 Change all g_memdup() to g_memdup2()
Using g_memdup() is dangerous due to the type of the size argument. See
https://gitlab.gnome.org/GNOME/glib/-/issues/2319 and
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1926 for details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1708>
2021-02-04 19:16:28 +01:00
Sebastian Keller
a9d9aee6c0 kms/impl-device-atomic: Fix blob_ids array leak
release_blob_ids() only destroys the DRM property blobs, but does not
free the array they were stored in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1699>
2021-02-02 14:41:52 +00:00
Jonas Ådahl
ca22622517 screen-cast/src: Only allocate DMA buffers if other end supports it
The other end of the PipeWire stream can set the buffer data type to a
bitmask of supported buffer types. We should respect this, and not
attempt to allocate a DMA buffer if it isn't asked for.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
ca95ccdef0 screen-cast/src: Always first set spa buffer data to NULL
We use that elsewhere for sanity checking, and it's not initialized to
anything, so might be pointing to invalid memory if buffer allocation
failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
08ad107df5 screen-cast/src: Handle failing to allocate shm buffers
Don't leak the file descriptors, and don't fall over when trying to
clean up buffers that failed to allocate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
70d9a7b4bf screen-cast/src: Pass dimension and stride when needed
Instead of getters, pass the width, height and stride around when
relevant. This also removes the redudant "stream_size" and
"stream_height" variables from the src struct, as they are already part
of the video format.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Olivier Fourdan
a2e2cfe437 window/x11: Check before freezing commits
Now that we have a window actor API that can hint whether or not the
window actor would support freezing commits, use it to avoid freezing
Xwayland commit on actors that will not be thawed after paint.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1615
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1678>
2021-01-30 10:13:03 +00:00
Olivier Fourdan
df5a5d279d window-actor: Add a new can_freeze_commits() API
Mutter freezes Xwayland commits when resizing windows, and thaw them in
the window actors' after_paint() for X11.

Yet, after_paint() could be never called, as when a new window is mapped
while the overview is active in gnome-shell.

As a result, the content of the X11 window will remain invisible to the
overview.

Add a new window actor API to tell whether commits can be frozen. For
Wayland window actors, this always return FALSE, whereas for X11 window
actors, it checks whether the Clutter actor is mapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1678>
2021-01-30 10:13:03 +00:00
Jonas Ådahl
cda26b493e wayland: Only use async configured geometry if actually changed
When (un)maximizing, (un)fullscreening, the move/resize action is
flagged with 'ACTION_MOVE' and 'ACTION_RESIZE' , while e.g.
'appears-focus' does not.

When a client misbehaved and didn't immediately reply to a configure
request with a commit with the corresponding ack_configure, the
following commit would trigger a oddly timed move, making the window
appear to move back to a previous position.

Avoid this issue by only carrying over the target window position if the
configuration actually contained a new position.

We cannot only rely on the flags however, as e.g. a new position should
be respected during interactive resize, even though only 'ACTION_RESIZE'
is passed in such scenarios.

Do the same for the size, except if the window state dictates that the
size is fixed to a certain size, e.g. being fullscreen or maximized.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1445>
2021-01-30 09:49:13 +00:00
Jonas Ådahl
b2482a2069 cogl: Add CoglX11Onscreen interface
Mutter needs to fetch the X11 Window ID from the onscreen and did that
by using an X11 specific API on the CoglOnscreen, where the X11 type was
"expanded" (Window -> uint32_t). Change this by introducing an interface
called CoglX11Onscreen, implemented by both the Xlib and GLX onscreen
implementations, that keeps the right type (Window), while avoiding X11
specific API for CoglOnscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0fdf6a6405 cogl/onscreen: Move direct scanout to CoglOnscreen class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
fe72876b20 cogl/onscreen: Make swap_buffer/region CoglOnscreen class vfuncs
No need to go via the "winsys" vtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
60e1516b1c cogl/gl-framebuffer: Split up into FBO and back drivers
One is for when we're painting to the back buffer (onscreen), and the
other when we're painting to an FBO (offscreen).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0936d7bd06 cogl/onscreen: Use CoglFramebufferClass::allocate() to init
Instead of calling "init_onscreen()" on two different separate vtables
from the allocate() funtion, just have the CoglOnscreen sub types
themself implement allocate() and initialize in there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
0b568b68c6 Make all CoglOnscreen sub types inherit CoglOnscreen
Thins means that e.g. MetaOnscreenNative now inherits CoglOnscreenEgl,
which inherits CoglOnscreen which inherits CoglFramebuffer, all being
the same GObject instance.

This makes it necessary to the one creating the onscreen to know what it
wants to create. For the X11 backend, the type of renderer (Xlib EGL or
GLX) determines the type, and for the native backend, it's currently
always MetaOnscreenNative.

The "winsys" vfunc entries related to onscreens hasn't been moved yet,
that will come later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
73dc19fc58 onscreen/native: Remove uselses size check
The comment made no sense in the context it was in, and the size check
can never fail as we create views directly from mode dimenisons.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
3e4ece50d3 renderer/native: Move out CoglOnscreen code to separate file
To get meta-renderer-native.c down to a bit more managable size, and to
isolate "onscreen" functionality from other (at least partly), move out
the things related to CoglOnscreen to meta-onscreen-native.[ch].

A couple of structs are moved to a new shared header file, as
abstracting those types (e.g. (primary, secondary) render devices) will
be dealt with later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
b5afa6db23 cogl/onscreen: Change to follow mutters naming convention
The mutter naming convention for types and their instance variables is:

Type name:
   [Namespace][BaseName][SubType]

Instance name:

   [base_name]_[sub_type]

This means that e.g. CoglOnscreenGLX is renamed CoglOnscreenGlx, and
glx_onscreen is renamed onscreen_glx. This is in preparation for
GObjectification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
a057432e3d cogl/glx: Move onscreen code to a separate file
Mostly in order to untangle it from the rest, preparing turning it into
a GObject.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
7cf24ccc34 cogl/onscreen/egl: Move struct to C file
In praparation for declaring the EGL onscreen part using G_DECLARE*.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
d0831cbbcd cogl: Move CoglOnscreen struct to C file
That means all sub types need to use helper methods, so make them do
that too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:44 +00:00
Jonas Ådahl
b55b26661f workspace: Downgrade assert to warning when adding window
An extension can by accident cause us to end up in a state where we try
to add the same window to a workspace twice. When this happens we
shouldn't crash, but instead complain loudly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/992
Related: https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/157
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1692>
2021-01-29 17:14:08 +00:00
Thomas Mühlbacher
180e62519b tests/monitor-config: Improve debugging output
Make it easier to find out what went wrong with `migrated_data` by
having it included in the debug logs.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Thomas Mühlbacher
88647ae23c monitor-config: Free meta_monitor_spec safely
`g_free()` alone can't help if the value it gets is `NULL` + the offset
of the struct members.

This prevents gnome-shell from segfaulting if `monitors.xml` contains
invalid XML.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Thomas Mühlbacher
70cdd72040 monitor-config-store: Properly escape monitor spec
Makes sure that monitor specs which may be read from EDID data do not
contain characters that are invalid in XML. Makes it possible to restore
monitor configs of monitor models with characters such as '&' in them.

To make this change not break any tests, the sample monitor configs need
to be adjusted as well. Apostrophes don't strictly have to be escaped in
XML text elements. However, we now do escape the elements in
`<monitorspec>` specifically.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Sebastian Keller
c9aa43aa7a wayland/gtk-shell: Add an explicit gtk-shell surface release request
Previously the wl_resource and MetaWaylandGtkSurface corresponding to
any client gtk_surface have been kept around until the exit of the
client due to the client side destroy method not signaling the
destruction to the server. Ideally the protocol would have specified a
destroy request marked as destructor to handle this automatically,
however this is no longer possible due to the destroy method being
implicitly generated in the absence of an explicit request in the
protocol. Adding a destroy request marked as destructor now would
generate a new destroy method that unconditionally would send the
request to the server, which would break clients running on servers not
supporting that request.

So instead of modifying the destroy request add a new "release"
destructor, that indicates to the server that it can release the
resource. This can be optionally be used by clients depending on the
server protocol version.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Sebastian Keller
b41c4aec26 wayland/gtk-shell: Fix MetaWaylandGtkSurface leak on surface destroy
The MetaWaylandSurface corresponding to a MetaWaylandGtkSurface can be
destroyed before the MetaWaylandGtkSurface is destroyed. In its destroy
function MetaWaylandSurface however was unsetting the destructor of the
correspnding resource along with the gtk_surface1 interface
implementation. This was done to prevent further gtk_surface1 requests
on a NULLed MetaWaylandSurface, if it has been destroyed before the
MetaWaylandGtkSurface.

It would be enough to just unset the resource implementation, while
keeping the destructor to fix this leak. However the following commit
will rely on the implementation being available after the
MetaWaylandSurface has been destroyed. So instead introduce NULL checks
for all functions that can be called on the gtk_surface1 interface and
do not unset the implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Jonas Ådahl
893c0cd2f9 screen-cast/area-src: Handle monitors changes here too
Like with the monitor source, we need to reattach to the new views after
monitor changes, otherwise the screen cast will get stuck.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
e877b06fdd screen-cast/monitor-stream: Don't fall apart when monitor changes
If the monitor configuration changed, even though the streamed monitor
didn't change, we'd still fail to continue streaming, as we failed to
update the stage watchers, meaning we wouldn't be notified about when
the stage views were painted.

Fix this by reattaching the stage watches, i.e. update the painted
signalling listeners to listen to the right views, when monitor changes
happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
9f6a441665 screen-cast-stream: Add getter for stream src
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
036ce1f28e native/cogl-utils: Minor macro cleanup
We don't use 'pragma once' in mutter, and cogl/cogl.h isn't a system
include.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
caa798c672 native/cogl-utils: Fix license header
The intention was to add a license header the same as other files in the
mutter backend files, so make it so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
1d4e535e7a clutter/stage: Remove 'paint' argument in capture_into()
There are more suitable API when the stage needs to be actually painted
into something. Nothing actually used this anymore too, so remove this
functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
662e29990a input-mapper: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
9c50353ffa monitor: Stop exporting a bunch of unused symbols
No tests accessed them, so don't export them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
b883a31796 tests/monitor-unit-tests: Sanity check some monitor info
Check that some information about the monitor is the same as the main
output they are derived from.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
432682f305 monitor-manager: Clean up hot-plug paths slightly
Make the API used more shared and better named.

meta_monitor_manager_on_hotplug() was renamed
meta_monitor_manager_reconfigure(), and meta_monitor_manager_reload()
was introduced to combine reading the current state and reconfiguring.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
e48be709f8 seat-impl: Remove unused udev client instance
No point in having an unused udev client lingering.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
6ecdf03efb backend/native/clutter: Get seat ID from backend
We don't need to have MetaLauncher set it and guess it if that fails,
when we now have a getter from MetaBackendNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
2d2521a106 backend/native/clutter: Cleanup backend pointer variable naming
It was named "backend_native" and "backend" which is easily confused with
MetaBackendNative and MetaBackend which tends to have those names.
Prepare for introducing the usage of a MetaBackendNative and MetaBackend
pointers here by cleaning up the naming.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
8de3190627 udev: Fetch seat-id via backend instead of laucher
Configurations where we won't have a MetaLauncher will be added, so
avoid using its API directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
41246cb31d backend/native: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
35ecc6ba7c backend/native: Gracefully handle failing to create monitor manager
We tried to start listening to a signal even if it didn't construct
properly. Stop doing that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
f75e9032c1 meta: Remave meta_activate_session()
It's not used anywhere, lets drop it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
dce906a4d1 output/kms: Remove redundant typedef
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
e41a0e47dc monitor-manager: Cleanup class struct
It was wierdly formatted, missed argument variable names, didn't use
stdint types. Clean this up a bit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
0e9a92a429 output: Make MetaTileInfo use stdints
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
11fee3f753 monitor-manager/kms: Remove left-over struct
From the time it dealt with reading DRM file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Sebastian Keller
ff4f8d2aa0 frames: Consider events on fullscreen windows to be on the client area
Fullscreen X11 windows that attempt to change the resolution on Wayland
use a surface viewport to achieve this without affecting the resolution
of the display. This however also means that pointer events will be
delivered in the display coordinates while the code handling the window
frame is not aware of any such viewport scaling. So a right click
outside of the area corresponding to the new resolution will not be
considered to be on the client area. And since the only area that is
ignored when determining whether to perform the right click action, such
as opening the context menu, is the client area, this will result in the
action being performed, despite happening on the (scaled) client area.

While it would be possible to scale the event coordinates so that
get_control() correctly determines the frame element the cursor is on,
viewport scaling only affects fullscreen windows. Since fullscreen
windows have no frame, we can always assume that if the window gets
delivered an event for a fullscreen window, it is on the client area
without doing any additional calculations.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1592

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1661>
2021-01-28 15:30:29 +00:00
Florian Müllner
81f3694804 window: Guard can_ping() against unmanaging windows
We remove pending pings when unmanaging a window, but currently
don't prevent new pings to be scheduled after that.

The previous commit fixed a code path where this did indeed happen,
but as the result of gnome-shell trying to attach a Clutter actor
to a non-existent window actor is pretty bad, also guard can_ping()
against being called for an unmanaging window.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2467

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1676>
2021-01-28 14:47:28 +00:00
Florian Müllner
e7b58c23b8 window: Do not handle ungrabbed events when unmanaging
Once we are no longer managing a window, we have no business in
dealing with it anymore, and operations like focusing, raising or
pinging the window aren't expected to work, and can go horribly
wrong if we try.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2467

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1676>
2021-01-28 14:47:28 +00:00
Georges Basile Stavracas Neto
4927452b84 workspace-manager, x11-display: Default to a single row
This seems to have been the default in the past, but was (accidentally?) modified
by 8adab0275.

For GNOME 40, we'll be returning to our root with horizontal workspaces, so instead
of overriding it in GNOME Shell side, change the default back to what it once was.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1684>
2021-01-27 11:48:10 -03:00
Daniel van Vugt
f512d4fefa shaped-texture: Update the full bounding box of each clip rectangle
When using fractional scaling this matters, so that you don't miss a
line of pixels at the edge of the clip rectangle by rounding down. This
was observed as a line of corrupt pixels in Firefox (Wayland) tooltips.

Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/1500

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1554>
2021-01-27 17:05:38 +08:00
Jonas Ådahl
ff25ec3f36 tests/monitor-unit-tests: Set up async waiter after X11 client
We'll have two persistent client connections alive for the whole test,
one X11 client, and one Wayland client. So in order to be able to set up
the async waiter, do so after setting up the X11 client, as after that
we know we'll have a MetaX11Display ready to use.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
798fc63755 tests/utils: Spawn Xwayland before X11 test client
This is so we can add our async waiter up front. Using
XOpenDisplay(NULL) didn't work; for some reason it dead locked when
XInitThreads() had been called prior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
02859221ea tests/test-runner: Hook up async waiter on demand
Not all tests will spawn Xwayland; so don't expect it to be there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
d8e75027a4 xwayland: Split Xwayland display name getter into two
One for the public channel, and one for the private maintainance
channel. Use the public one for test clients, otherwise tests become
flaky, and the private one for MetaX11Display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
fb38c451b5 kms: Add atomic MetaKmsImplDevice backend
This adds a MetaKmsImplDevice backend using atomic drmMode* API in constrast to
non-atomic legacy drmMode* API used in MetaKmsImplDeviceSimple.

This has various behavioral differences worth noting, compared to the
simple backend:

 * We can only commit once per CRTC per page flip.

This means that we can only update the cursor plane once. If a primary
plane composition missed a dead line, we cannot commit only a cursor
update that would be presented earlier.

 * Partial success is not possible with the atomic backend.

Cursor planes may fail with the simple backend. This is not the case
with the atomic backend. This will instead later be handled using API
specific to the atomic backend, that will effectively translate into
TEST_ONLY commits.

For testing and debugging purposes, the environment variable
MUTTER_DEBUG_ENABLE_ATOMIC_KMS can be set to either 1 or 0 to
force-enable or force-disable atomic mode setting. Setting it to some
other value will cause mutter to abort().

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/548
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
8e235768da kms/update: Encapsulate custom page flip fields in object
Makes more sense to pass around an encapsulated object with the relevant
data, than passing around a vfunc and a gpointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
4afe3afdf0 kms/impl-device/simple: Make process update vfunc type a typedef
It made the function type declaration a bit unreadable, so split it out.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6bffeeed28 kms/page-flip: Pass ownership of listener user data along with closure
In order to reliably manage the reference count of the user data passed
to page flip listeners - being the stage view - make the ownership of
this data travel through the different objects that take responsibility
of the next step.

Initially this is the MetaKmsPageFlipListener that belongs to a
MetaKmsUpdate.

When a page flip is successfully queued, the ownership is transferred to
a MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. In the
simple impl device, the MetaKmsPageFlipData is passed to
drmModePageFlip(), then returned back via the DRM event. In the future
atomic impl device, the MetaKmsPageFlipData is stored in a table, then
retrieved when DRM event are handled.

When the DRM events are handled, the page flip listener's interface
callbacks are invoked, and after that, the user data is freed using the
passed GDestroyNotify function, in the main context, the same as where
the interface callbacks were called.

When a page flip fails, the ownership is also transferred to a
MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. This page
flip data will be passed to the main context via a callback, where it
will discard the page flip, and free the user data using the provided
GDestroyNotify.

Note that this adds back a page flip listener type flag for telling the
KMS implementation whether to actively discard a page flip via the
interface, or just free the user data. Avoiding discarding via the
interface is needed for the direct scanout case, where we immediately
need to know the result in order to fall back to the composite pipeline
if the direct scanout failed. We do in fact also need active discard via
the interface paths, e.g. in the simple impl device when we're
asynchronously retrying a page flip, so replace the ad-hoc discard paths
in meta-renderer-native.c and replace them by not asking for no-discard
page flip error handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6d6fd9c43d kms/page-flip: Make tha data struct use gatomicref instead of int
While there are no threads that makes this necessary, lets change this
now so we don't forget later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d2ccc824ce kms/page-flip: Add helpers for closure constructor and destroyer
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5dca49b6d6 kms/crtc: Log some CRTC state when updating
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
f0318d8964 kms: Update device state when resuming
Suspending might have changed the CRTC configuration, turning some off,
some on, etc. We need to update our internal representation of this
state, so that we know how to reconfigure upon resuming, e.g. what CRTCs
to turn off again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
214850143d crtc/kms: Turn g_debug()s to meta_topic()s
This way they can easily be enabled with e.g. MUTTER_DEBUG=kms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
588c0a456a renderer/native: Keep onscreens alive until after the next mode set
Destroying an onscreen destroyes the gbm_surface, the gbm_bo's, and the
fb_id's. Doing this (drmModeRmFB() of the fb_id specifically), may on
some hw implicitly disable the CRTC of the plane that framebuffer was
assigned to. This would cause following atomic commit that attempts to
disable the CRTC to fail as disabling an already disabled CRTC is not
allowed.

It'd also mean we'd always disable the plane before having finished next
mode set, leaving it monitor content potentially empty when not really
necessary.

Solve this by keeping the CoglOnscreens (thus the gbm_surface, gbm_bo
and fb_id) alive until the following global mode set has completed, i.e.
the new state has been fully committed and applied.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
ae812ca81e renderer/native: Make dummy power save flips symbolic
They won't have a timestamp, thus isn't meant to be used for timing
calculations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5f6aee3419 kms/update: Make power saving an update wide change
This makes "power save" (i.e. when you make a monitor go into power save
mode, or make it come out of power save mode), a per device action when
turning on power saving (power save being set to 'off'), and implicitly
handled when turning off power saving (power save being set to 'on')
when doing a mode set.

This is needed as with atomic mode setting, the configuration of DPMS
(Display Power Management Signaling), is replaced by directly turning on
or off CRTCs, and via the CRTC drm properties. Thus in order to handle
both with a common API, make that API high level enough for both cases
being covered.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
3ec5418104 backend/native: Set CRTC gamma once per frame
Before we received new gamma updates via D-Bus and posted the update to
KMS directly. This won't be possible with atomic KMS, since one can only
update the state of a CRTC once per cycle.

Thus, to handle this, when configured by D-Bus, only cache the value,
and mark it as invalid. The next frame, the native renderer will pick
up the newly cached gamma value and configure the CRTCs accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7d8dd6cc75 kms/crtc: Make MetaKmsCrtcGamma reusable
Expose it outside the private realms of MetaKms* so that e.g.
MetaMonitorManagerKms can use it too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
88e6400052 monitor-manager/kms: Turn on DPMS together with mode set
We cannot switch DPMS state to 'on' first, then mode set later, when
using atomic KMS. So when we're turning it on, just let the eventual
mode set handle DPMS too.

When switching DPMS to 'off', do it directly, synchronously, both by
setting the DPMS state and switching off CRTCs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d8279ba474 kms/device: Add plane getter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
dd03ffa89d renderer/native: Prepare for real page flips without primary plane changes
This is something that the atomic backend will need, as cursor updates
go through page flips too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
c985753442 cursor-renderer/native: Update HW state during frames
Before each frame is maybe redrawn, push any new cursor KMS state to the
pending update. It'll then either be posted during the next page flip,
or when the same frame finishes, in case nothing was redrawn.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
487ea0dd95 kms: Add symbolic page flips and cogl frame infos
This makes it possible to post a symbolic page flip and frame callback,
meant to be used by immediate symbolic page flip reply when emulating
cursor plane changes using legacy drmMode* functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
84f454fd4f clutter/frame-clock: Add notify_ready()
In constrast to notify_presented(), notify_ready() also returns the
state machine to the idle state, but without providing new frame
information, as no frame was actually presented.

This will happen for example with the simple KMS impl backend will do a
cursor movement, which will trigger a symbolic "page flip" reply in
order to emulate atomic KMS behavior. When this happen, we should just
try to reschedule again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
fea8ebcca9 cursor-renderer/native: Store struct in CRTC private
In this struct, for now only the buffer is stored, but it'll be used for
more state in later commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
447c51e68e renderer-native: Always post device wide updates during mode set
Don't mode set each CRTC in separate KMS updates, as reconfiguring one
CRTC might cause other CRTCs to be implicitly reset thus as well,
causing KMS return EBUSY if using atomic modesetting.

Prepare for this by compositing each CRTC first including adding steps
to the KMS update, but wait until all views has rendered at least once
before posting the initial update. After this each CRTC is posted
separately.

Using EGLStreams instead of normal page flipping seems to fail when
doing this though, so handle that the old way for the EGLStream case,
i.e. eglSwapBuffers() -> mode set with dumb buffer -> eglStream
"acquire" (resulting in page flip under the hood).

For this we also introduce a new error code so that we don't use client
buffers when doing mode sets, which could accidentally configure the
CRTC in a way that is incompatible with the primary plane buffers.

Do the same also when we're in power save mode, to only have one special
case path for this scenario in the regular swap-buffer path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
92d4cb5184 clutter/frame: Make rendering backends set the frame result
Instead of setting the frame result in the most generic layer, have the
backends do it themselves. This is necessary to communicate that a
swap-buffer call didn't really succeed completely to present the swapped
buffer, e.g. errors from KMS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6bda72e3eb kms/plane: Make get_primary_plane() actually get the primary plane
The plane was not type checked, so it retrieved whatever plane happened
to come first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
249512b068 cogl/onscreen: Add opaque user_data pointer to onscreen present calls
This argument is intended to be used by clutter to be able to
communicate with the onscreen backend, that happens to be the native
backend. It will be used to pass a ClutterFrame pointer, where the
result of page flips, mode sets etc can be communicated whenever it is
available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
72b35e07c0 clutter: Introduce ClutterFrame
ClutterFrame aims to carry information valid during dispatching a frame.
A frame may or may not include redrawing, but will always end with a
result.

A asynchronous page flip, for example, will result in a
CLUTTER_FRAME_RESULT_PENDING_PRESENTED, while a frame that only
dispatched events etc will result in CLUTTER_FRAME_RESULT_IDLE. Instead
of this being implicit, make the ClutterStageWindow implementation
handle this itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
722f7ae2c3 clutter/stage-window: Pass 'view' to finish_frame() too
Not used yet, just done separately to decrease future diffs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
3bd0037fa1 tests/monitor: Check that the CRTC "layout" is correct
The layout should be the region of the stage the CRTC represents; check
that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7215b0d88c output: Tie the output to the monitor it's part of
Outputs correspond to active connectors, that we translate into
monitors. Make this association more real by adding a pointer back to
the monitor from the output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5edc118d62 monitor-manager: Connect assigned CRTCs to their outputs both ways
We had a pointer from the output to the assigned CRTC, but had no way to
get the outputs an CRTC was assigned to. Add that connection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
b7441514fe kms: Add some basic debug logging
Enabled using MUTTER_DEBUG=kms or via
Meta.add_verbose_topic(Meta.DebugTopic.KMS) in looking glass.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
c0e9a6fe15 kms/impl-device: Make the actual implementation handle the drm event
The way drm events are handled depends on whether we're using atomic or
not. Lets move the handling to the implementation, so that later the
atomic backend can handle the event they it need to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
b693e58c53 kms/update: If reassigning a plane handle the fb changed flag
If we reassign e.g. a cursor plane twice before it's updated, we need to
make sure the 'fb-unchanged' flag is correctly handled, so that if we
changed the fb first, then updated the assignment again only changing
the position, the new assignment should not be flagged with
fb-unchanged.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
3bad37482d kms: Add way to preserve failed update
When we e.g. try to post an direct client buffer scanout update, it
might arbitrarily fail; when this happen we still will want to post the
rest of the update when we try again after having composited the primary
plane. To do this, add a way to preserve the metadata of an update if it
failed, only dropping the failed plane assignments. This involves
unlocking a previously locked MetaKmsUpdate, so that e.g. a new primary
plane can be assigned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
8876b217af kms/update: Change 'seal' to 'lock'
Sealing is a one way operation, but in the next commit, the "seal" will
be broken, so to avoid missusing the "seal" terminology, rename related
methods and variables to use the term "lock" instead. E.g.
meta_update_is_sealed() is now meta_update_is_locked().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
4f89f159ca cursor-renderer/native: Postpone cursor update if modeset is pending
If a modeset is pending, it's likely that the cursor update will not
work; thus, wait with updating the cursor so that it's applied together
with the mode set update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
afd0a272cd kms/update: Add way to receive result from later posted update
Something might want to affect the next update that is going to be
posted, but without posting it immediately. For example, changing the
cursor might need to wait for mode setting. Make it possible to get
feedback from posting the update, in order to gracefully handle any
errors.

Note, the API for notifiying about results take out the result listener
from the update, and notifies them in an open coded for loop. The reason
for this is that in the next commit we'll sometimes reuse updates, and
we only want notify about the results once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5c7e2bfe22 kms/update: Make explicit page flip just listeners
Page flipping shouldn't necessarily be an actively requested action, but
happen implicitly depending on the given state. Thus, change the "page
flip" update into adding listeners for page flip feedback instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
0acae7f3c1 kms/feedback: Make getter take consts
This will be necessary later, as places that wants to use them will only
have the const variants of the feedback pointers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
411ec5fd18 kms: Allow update passing with failed plane assignments
This will later make it possible to pass cursor plane assignments,
together with a complete update including the primary plane, but not
failing the whole update if just processing the cursor plane failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a2b8668544 kms/impl: Dont discard page flips in callback when failed up front
If posting an update resulted in an immediate error, don't communicate
this failure using the page flip feedback callbacks, but directly as a
return value.

This makes it possible for the direct client buffer scanout path not to
pass around flags triggering this behavior, meaning we can handle such
direct scanouts better.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
2df6327367 kms: Post pending updates per device
Instead of a "post all pending updates", pass an update specific to a
single device. This gets rid of the awkward "combine feedback" function,
and makes it possible to queue updates to a multiple devices without
always posting them together.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5ba2d79076 kms/update: Make custom page flip be per update
Custom page flips are meant to allow using e.g. EGLStream API to
indirectly trigger page flip queueing, when the KMS API cannot be used
directly. This is really something that is specific to a device, so
instead of making part of the page flip API, make it a configuration of
the update itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
94ab6d8736 crtc/kms: Remove page flip helper
The only thing it did was shuffle around arguments and calling a getter.
lets just do that ourself in the call site.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
f07d6d1f43 kms/crtc: Keep track of ACTIVE property value
When atomic modesetting isn't enabled, this property may not exist, so
emulate by assuming ACTIVE is set to true if a mode is set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
28facbfa3a kms/update: Assign planes with MetaDrmBuffer instead of fb ids
This will eventually allow better lifetime control.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7842517519 kms/impl-device: Keep a path string around
This is useful for e.g. logging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
deb8f07c65 kms/device: Get driver details before constructing impl device
Eventually the type of impl device will depend on the driver details, so
get that information before constructing the impl device. This commit
doesn't introduce any new usage of the details, it just prepares for
the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
84bde805fe native: Consolidate DRM buffer management to MetaDrmBuffer types
This commit consolidates DRM buffer management to the MetaDrmBuffer
types, where the base type handles the common functionality (such as
managing the framebuffer id using drmModeAdd*/RMFb()), and the sub types
their corresponding type specific behavior.

This means that drmModeAdd*/RmFB() handling is moved from meta-gpu-kms.c
to meta-drm-buffer.c; dumb buffer allocation/management from
meta-renderer-native.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
40e5633fab cursor-renderer/native: Change guint to unsigned int
No need to use GLib types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
17712f7905 kms/update: Make dst_rect a int rectangle
It's never used as a 16.16 fixed point rectangle so no reason it should
be passed around as one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7f60d8bd66 kms/update: Fix a couple of style issues
Include macro order was incorrect, and a line was incorrectly indented.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7137bd4b10 kms: Move impl backend inherit MetaKmsImplDevice instead of MetaKmsImpl
This allows different types of backends to coexist, would e.g. one
device support atomic but another not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
37fe30c515 kms/update: Make each MetaKmsUpdate update a single device
For now feedbacks from an update are combined, meaning we might lose
error information. The feedback API may have to be reconsidered and
redesigned when planes gets a more front seat position.

This means we need to avoid trying to post updates if we're in power
save mode, as it may be empty.

Note that this is an intermediate state during refactoring that aims to
introduce atomic mode setting support, and we'll stop combining
feedbacks completely in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a7a1391de7 renderer/native: Fix 'notify-frame-complete' function name
It had the word "queue" in it, which was incorrect, as it invoked the
listeners directly without queueing anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a8d724d058 kms/impl: Manage a list of impl devices
Accessing the device list directly from MetaKms might not be safe if we
introduce threads, so keep a list completely within the impl context.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
eb78b62515 kms/crtc: Find GAMMA_LUT property
To be used by the atomic backend to implement setting gamma ramps.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
8808d518cc kms/impl-device: Construct using GInitable
Instead of a constructor method, use the type directly and handle error
reporting using GInitable.

The DRM capability setting is done before construction, as later it'll
determine what type of impl device should be constructed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d3c630f637 kms/connector: Look up CRTC_ID property
To be used by the atomic backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
1959a872b8 kms/impl-device: Make type derivable
This means moving things from the private struct _MetaKmsImplDevice into
a instance private struct. No other changes made.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
837501ab25 native: Remove left-over flip waiting functionality
With the frame clocks split up, we never wait for page flip callbacks
anymore, so remove the functions that implement that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
9d7be40502 monitor-manager-kms: Set gamma on MetaKmsUpdate directly
The meta_kms_crtc_* helper didn't do anything more than call another
function with the exact same arguments.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
ec7667fc31 kms/connector: Set DPMS and underscanning directly on the update
Instead of telling MetaKmsConnector fill a MetaKmsUpdate with connector
property changes, make the update itself aware of the changes, making
the impl side translate that to property changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
c1ce36f08e kms/update: Make plane assignment take rotation instead of property list
Instead of having MetaKmsPlaneAssignment carry a low level property
list, set the actual state change, and then have the implementation
translate that into the necessary property changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
2b7b4576fb kms/plane: Parse IN_FORMATS via prop table parse vfunc
With the aim at always using the property table to fetch and parse
property metadata, move IN_FORMATS handling to the property table, using
the newly introduced parse vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
1b3e8b4a27 kms/impl-device: Make property ID lookup also handle parsing
Values may need to be processed and parsed in custom ways; make this
possible via the property table infrastructure using a callback.
Will be used for e.g. parsing rotation and formats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
a9ae202327 kms/plane: Find property IDs to be used for atomic modesetting
Currently undiscovered, as we haven't enabled the atomic modesetting
capability, but lets get the infrastructure to get the property IDs in
place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
11966dc6cb kms/crtc: Find MODE_ID and ACTIVE property IDs
Will be used by the atomic KMS backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
df89e8ce4b kms/connector: Make property ID fetching more declarative
Instead of relatively verbosely going through the DRM properties finding
the properties we care about and saving their ID's, add a more
declarative way to fetch property metadata. This'll allow for fetching
more property IDs with relatively less code, which will be useful for
the atomic backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
309651df6b kms/update: Make change updates to take MetaKmsMode
This will be needed for state keeping connected to turning mode infos
into blobs later used by the atomic modesetting implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
abac217617 crtc-mode-kms: Wrap MetaKmsMode instead of drmModeModeInfo
We'll need to use the MetaKmsMode later on for state keeping.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
e15bb68d8f gpu-kms: Fix mode ID type
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d3abaf46a1 output-kms: Hand over fallback mode management to MetaKms
Eventually we need MetaKmsMode for more than carrying the
drmModeModeInfo, so prepare for that by having the KMS layer create
MetaKmsMode for those as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
0fa0eeef57 kms/mode: Add getter for name
Gets the name directly from the DRM mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
2c4a3c5959 kms/mode: Add mode flags
Will be used to add flags modes specific to MetaKmsMode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
eb66449ab7 kms/mode: Add API to create blob IDs for modes on demand
Will be used by the atomic KMS backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
f0d3201dab kms: Add MetaKmsMode abstraction
This contains a copy of a drmModeModeInfo, describing a mode. It also
has an unused pointer to the impl device it is associated with. It'll
later be used to get a blob ID for the mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Olivier Fourdan
22b926eea7 xwayland: Check for listenfd option
Current Xwayland has marked the command line option "-listen" as
deprecated in favor of "-listenfd".

Use the pkg-config variable "have_listenfd" (if available) from Xwayland
to determine if we should use that option, to avoid a deprecation
warning when spawning Xwayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1682>
2021-01-22 11:40:30 +01:00
Olivier Fourdan
26cc51a1a5 xwayland: Do not retry the same display
Mutter listens to two display connections, one for regular X11 clients
and another one for the so called "managed services".

Once an available display number is found for the regular X11 clients,
mutter would then redo the work to find another available display number
for the managed services.

Yet, it does so starting from the same initial display, which is a waste
of time since it just tried all displays to find the first available
one, so all these, including the regular display it just took, are now
in use.

So instead of starting over from the beginning when looking for a
display available for the managed services, continue from the next
display immediately after the one we found precedently.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1680>
2021-01-21 18:08:48 +01:00
Carlos Garnacho
d43f95703d backends/native: Update keymap state on latched modifier updates
The input thread refactors missed to update the MetaKeymapNative state when
the keys that trigger the latched modifiers are being pressed. Let that happen
here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1679>
2021-01-21 15:35:06 +01:00
Olivier Fourdan
eb06d9e165 xwayland: Do not rely on X-lock files
Some X11 servers may not always create a lock file, yet mutter uses the
lock file to find a possible display number and then tries to bind to
the socket corresponding to that display number.

If it fails to bind, it will simply bail out. As a result, if an X11
server is already listening on that display but hadn't created a lock
file, mutter won't be able to start Xwayland.

To avoid that possible issue, make mutter retry with another display
for a given number of tries when binding fails even though the display
was supposed to be available based on the lock file presence.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1604
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 12:57:07 +01:00
Olivier Fourdan
f6b4665b02 xwayland: Check for X11 unix directory only once
The function choose_xdisplay() calls open_display_sockets() which calls
ensure_x11_unix_dir().

We don't need to do that from within the loop though, as the directory
/tmp/.X11-unix is the same regardless of the display number.

Move the call to ensure_x11_unix_dir() from open_display_sockets() to
choose_xdisplay() prior to enter the display loop.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
Olivier Fourdan
1bd42e8779 xwayland: Propagate error if display sockets failed
In case of failure to open the display sockets, we would not propagatre
the error which can cause a crash when trying to show the error message.

Properly propagate the error to avoid the crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
James Henstridge
063db30c50 xwayland: Start Xwayland on connection to either public X11 socket
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1454
(cherry picked from commit 7b2815077fa1053069e00c0a21b2c3038f4b0d1c)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
James Henstridge
df4b6d4ca5 Revert "wayland: Drop Xwayland abstract socket"
This reverts commit e2123768f6.  Various
container/chroot (e.g. Snaps, pressure-vessel) systems still depend on
the presence of the abstract X11 socket.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1613
(cherry picked from commit ea2192c4899ac7897efca31e8e85c157895950ac)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1669>
2021-01-21 08:48:39 +01:00
Carlos Garnacho
5671888775 wayland: Handle forced Xwayland shutdown elegantly
In the shutdown paths we check with the X11 display whether there's
remaining clients. However this happens in paths that happen after
the MetaX11Display vanished in the case of Xwayland crash.

Since in that situation the clients are forcibly vanishing too,
skip the client check.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1677>
2021-01-20 16:55:08 +01:00
Jonas Ådahl
1c6dd7f30a backend/native: Destroy logind helper after seat
Otherwise we don't actually close input devices using it, since that
would happen after meta_launcher_free() was called.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 22:54:32 +01:00
Jonas Ådahl
db6bf9d14e backend: Tear down in dispose() instead of finalize()
This means backend implementations can have more control of the order of
how things are destroyed. To be precise, this will, in the next commit,
allow us to destroy the logind integration after the clutter backend
thus the libinput owning seat, that uses the logind integration to
release input devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 22:54:32 +01:00
Jonas Ådahl
05765daabf seat/native: Explicitly destroy MetaSeatImpl
We can't post tasks to the input thread when cleaning up the
MetaSeatImpl, as that will make the GTask complain about adding
references to a to be purged object. Avoid this by adding an explicit
meta_seat_impl_destroy() function that handles the destruction of the
MetaSeatImpl properly.

This also does more of the cleanup in the input thread, as that is where
it was managed. Will likely not make a difference as before this
happened after tearing down the thread, but lets tear down things in the
thread they were managed for good measure.

This fixes the last log spew I see right now when terminating mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1670>
2021-01-19 22:54:32 +01:00