1
0
Fork 0
Commit graph

11419 commits

Author SHA1 Message Date
Dor Askayo
b3d0d84823 tests: Add missing dependencies
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3091>
2023-06-29 20:07:56 +00:00
msizanoen
842f73ac4c window-actor: Fix screencast with fractionally scaled surfaces
Instead of using `clutter_actor_get_resource_scale()`, we now deduce the
intended buffer scale from the window by dividing the unscaled size by
the final actor size. This is more correct as while the return value of
`clutter_actor_get_resource_scale()` depends only on the monitor where
the surface resides, the actual scale of the surface is determined
solely by the application itself. `get_resource_scale` will differ from
the actual buffer scale if the application only supports 100% scaling
(Xwayland), or is performing scaling with wp_viewporter (clients using
fractional_scale_v1).

This also fixes a mismatch between the calculated buffer sizes between
`meta_window_actor_get_buffer_bounds` and
`meta_window_actor_blit_to_framebuffer` which causes broken
screencasting for Chromium 114 and later when using the native Ozone
Wayland backend.

Additionally, this commit also changes
`meta_window_actor_blit_to_framebuffer` from using a simple translation
to using an inverted matrix transformation of the transformation matrix
between the parent of the window actor and the surface actor to ensure
maximum sharpness for fractionally scaled windows.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3053>
2023-06-29 13:37:47 +00:00
msizanoen
742d026479 shaped-texture: Introduce get_unscaled_{width,height}
This allows other code to obtain the size of the surface after all
transformations except for scaling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3053>
2023-06-29 13:37:47 +00:00
Daniel van Vugt
1dbf37239f meta: Don't #include <wayland-*> in public headers
It's not required to define `struct wl_display` and having it in a public
header is breaking the g-ir-scanner because Wayland headers use the
non-standard keyword `__typeof__`.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2875
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3098>
2023-06-28 08:47:42 +00:00
Barnabás Pőcze
ab4c415d6e color-manager: Apply temperature after gsd.Color proxy has been created
Previously, restarting mutter in an X11 session resulted in
the previously set color temperature not being applied.
Fix that by applying the color temperature right after
the org.gnome.SettingsDaemon.Color proxy has been created.

Furthermore, only call `update_all_gamma()` from `on_gsd_color_ready()`
when the temperature has actually changed. Otherwise there is no need
since the current temperature has already been (or will soon be) applied
to all ready color devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3008>
2023-06-28 07:51:01 +00:00
Jonas Ådahl
4aeb051e9b tests: Mark some test cases as skippable
This means the mutter/tty suite won't fail when the tests can't
TakeControl, i.e. run in the already active session.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3095>
2023-06-28 01:03:35 +00:00
Jonas Ådahl
eb9ef1da8d screen-cast/src: Queue follow up frame if no buffers
If we tried to record but did so before the buffers had the chance to be
added, schedule another follow up frame once the buffers start rolling
in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3095>
2023-06-28 01:03:35 +00:00
Jonas Ådahl
c724fcae2e tests/screen-cast-client: Don't process stream on tear down
We'd get a re-entry like scenario when destroying the PipeWire stream
object, where PipeWire would call the stream process vfunc. When this
happened, we had already destroyed the stream, so don't try to dequeue
or anything, just do an early exit. Fixes the following crash in the
test case client:

  #0 pw_stream_dequeue_buffer() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #1 on_stream_process() at ../src/tests/screen-cast-client.c:348
  #2 do_call_process() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #3 flush_items() in /usr/lib64/spa-0.2/support/libspa-support.so
  #4 loop_invoke() in /usr/lib64/spa-0.2/support/libspa-support.so
  #5 impl_send_command.lto_priv.0() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #6 suspend_node.lto_priv.0() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #7 pw_impl_node_set_state() in /usr/lib64/libpipewire-0.3.so.0.367.0
  #8 client_node_removed() in /usr/lib64/pipewire-0.3/libpipewire-module-client-node.so
  #9 pw_proxy_destroy() in /usr/lib64/libpipewire-0.3.so.0.367.0
 #10 pw_stream_disconnect() in /usr/lib64/libpipewire-0.3.so.0.367.0
 #11 pw_stream_destroy() in /usr/lib64/libpipewire-0.3.so.0.367.0
 #12 stream_free() at ../src/tests/screen-cast-client.c:530
 #13 main() at ../src/tests/screen-cast-client.c:803
 #14 __libc_start_call_main() at ../sysdeps/nptl/libc_start_call_main.h:58
 #15 __libc_start_main() at ../csu/libc-start.c:360
 #16 _start() in /home/jonas/Dev/gnome/mutter/build/src/tests/mutter-screen-cast-client

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3095>
2023-06-28 01:03:35 +00:00
Corentin Noël
6b9efc3b0c wayland: Make the MetaWaylandCompositor type public
Allows mutter implementation to have access to the underlying wl_display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3092>
2023-06-27 16:17:16 +00:00
Carlos Garnacho
60ef069aa8 backends/native: Log event modifiers in input event debug output
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3094>
2023-06-26 16:41:50 +02:00
Carlos Garnacho
4b3a38a589 meta: Add docs description to META_DEBUG_INPUT_EVENTS MetaDebugTopic value
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3094>
2023-06-26 16:28:51 +02:00
Jonas Ådahl
ee6f1f9246 seat/impl: Add 'input-events' debug topic
This will log all input events we forward from libinput.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3052>
2023-06-26 12:36:04 +00:00
Jonas Ådahl
d67d22f948 backend: Init settings before initable_init
This means the settings instance is there before the backend backend's
initable_init() function gets called.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3085>
2023-06-23 11:52:08 +00:00
Shmuel Melamud
993c42e11f compositor: Mirror window placement in RTL environment
If RTL environment (such as Hebrew or Arabic) is detected, the usual new
window placement algorithm is mirrored. New windows appear near the
right side of the screen and cascading is built from the top-right
corner of the screen.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1873
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3009>
2023-06-22 13:59:24 +00:00
Sebastian Wick
985d0dc3ab tests/stage-view-tests: Unref clutter timelines
If the timelines don't get destroyed they keep references to frame
clocks. Later tests check for the destruction of those frame clocks and
then can fail if the frame clock is implemented slightly differenty.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3084>
2023-06-20 23:19:28 +00:00
Pascal Nowack
712c9a1700 screencast: Do not stop remote desktop session when a stream closes
In remote desktop sessions, streams can be created and destroyed
on-the-fly.
If a stream is gone, it is not necessarily an error.
So, don't treat that situation like an erroneous one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2911>
2023-06-20 20:13:47 +00:00
Dor Askayo
56580ea7c9 backends/native: Assume zero rendering time for direct scanout buffers
The previous logic didn't work correctly at least when priority-based
preeption wasn't supported by the DRM driver, such as in the case
of amdgpu. The call to glGetQueryObjecti64v would block on client
work which is already in progress (most likely for the next frame)
and delay notifying the ClutterFrameClock about presentation.

Conveniently, the Wayland transactions mechanism guarantees that all
fences of a dma-buf buffer are signalled before the buffer is
included in a frame, which means that dma-buf buffers are ready for
presentation when being directly scanned-out.

Direct scanout is only supported for dma-buf buffers too, which means
that all buffers going through direct scanout are effectively ready
and require no GPU rendering before presentation.

Assuming zero rendering time for dma-buf buffers going through direct
scanout simplifies the code and removes the need for
glGetQueryObjecti64v, thus avoiding the aforementioned issue where it
could block for longer than expected.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2766
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3080>
2023-06-20 15:32:25 +00:00
Carlos Garnacho
c858ad7f91 wayland: Unset keyboard focus if surface is destroyed
Depending on the ordering of the surface-associated resources
being destroyed, we may fall into the following situation:

 - wl_surface is destroyed
 - destruction notifications for the surface runs
 - The MetaWaylandKeyboard attempts to synchronize the window
   focus
 - The MetaWindow is not destroyed yet, so the focused window
   remains the same, and the MetaWaylandKeyboard keeps the same
   focus MetaWaylandSurface.
 - wl_surface finalizes destruction, MetaWaylandSurface now has
   a NULL resource
 - xdg_toplevel destructor kicks in, it unmanages the window
 - The current focus window is again looked up, forced to look
   a different window
 - The MetaWaylandKeyboard focus now changes, tries to leave the
   old surface, but it has a NULL resource already, and raises
   a protocol error.

If the order is inverted, the window being unmanaged triggers a
focus change into a different window, the MetaWaylandKeyboard
triggers a focus change while the MetaWaylandSurface is still
intact, it succeeds, and the window gets properly destroyed.

In order to make this independent of the order, it makes sense
to make MetaWaylandKeyboard do like the other objects tracking
focus surfaces, and have it care of its own little parcel. The
surface destructor changed to simply unsetting the keyboard focus
to NULL (guaranteeing that the old focus is left while the surface
resource is still up), and leaving potential focus changes to
the xdg_toplevel_destructor->unmanage->update_focus paths.

Doing that alone is basically a revert of commit 228d681b, thus
is still subject to keyboard focus being lost after a popup is
destroyed. Change the approach to trigger the focus sync (and
new focus surface lookup) so it happens from xdg_popup_destructor
specifically to popups and alike xdg_toplevel.

Fixes: 228d681b ("wayland: Trigger full focus sync after keyboard focus surface is destroyed")

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2853
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3077>
2023-06-19 13:13:54 +00:00
Florian Müllner
a95a3a0d30 prefs: Remove titlebar-font preference
It has been unused since decorations moved into the frames client.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3075>
2023-06-15 16:51:20 +00:00
Sebastian Wick
87bd574598 core/window: Change MRU behavior for windows on secondary output
Current behavior pushes a window which receives focus to the start of
the MRU list on every workspace it is on. By focusing a sticky window
the default focus on all other workspaces changes as well. This is fine
for sticky windows explicitly marked as sticky by the user but if a
window is on a secondary output and workspaces are only on the primary
output the behavior is unexpected. Instead we want the window to be the
default focus only on the current workspace but also keep those windows
in a relative MRU order to each other on all workspaces.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2681
Fixes: 058981dc1 ("workspace: Focus the default window only if no window is focused")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2909>
2023-06-15 12:39:58 +02:00
Sebastian Wick
3bbff537d9 Revert "workspace: Focus the default window only if no window is focused"
This reverts commit 058981dc12.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2909>
2023-06-15 12:09:31 +02:00
Dor Askayo
a738132486 profiler: Actually free ThreadInfo when a thread unregisters
The previous commit only freed the list node.

Fixes: a731017ec ("profiler: Free ThreadInfo when a thread unregisters")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3078>
2023-06-14 23:54:41 +03:00
Dor Askayo
edc5d2a933 profiler: Free ThreadInfo when a thread unregisters
This avoids leaking the the ThreadInfo object when a thread unregisters.

Fixes: e16d68372 ("profiler: Add API to register profiler threads")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3076>
2023-06-14 19:48:12 +03:00
Dor Askayo
f49b2a3c7d profiler: Free ThreadInfo list on MetaProfiler finalize
This avoids use-after-free when handle_start() is called following
handle_stop() during the lifetime of the MetaProfiler. This happens
on repeated profiling sessions using Sysprof.

Fixes: e16d68372 ("profiler: Add API to register profiler threads")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3076>
2023-06-14 19:44:48 +03:00
Carlos Garnacho
bc04fcb89d core: Change MetaWaylandTextInput event forwarding to IMs
We need to juggle with some things here to keep key event ordering
and accounting consistent.

The keyboard internal state changes (and maybe modifier event emission)
happening through meta_wayland_seat_update() should ideally happen
from the same key events that reach the client through wl_keyboard.key,
so that wl_keyboard.modifier events are emitted in the right relative
order to other key events.

In order to fix this, we need to decide at an earlier point whether
the event will get processed through IM (and maybe be reinjected),
thus ignored in wait of IM-postprocessed events.

This means we pay less attention to whether events are first-hand
hardware events for some things and go with the event that does
eventually reach to us (hardware or IM).

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5890
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
eaa09be17c wayland: Account for doubly pressed/released keys in MetaWaylandKeyboard
Given the presence of IMs and the different paths in event handling to reach
one of them, we cannot make guesses about whether should stick to the original
hardware-triggered event, or wait/prefer a second hand IM event that might or
might not arrive. We also have no say for other IM foci unrelated to wayland
(e.g. ClutterText) triggering the double event emission.

So go with it and maintain our own internal state for keys, we already kinda
do, but mainly for warning purposes, at the time of updating the
MetaWaylandKeyboard state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
7b26aab08d wayland: Add compositor API to get the text input object
We need to open code a bit the event handling of MetaWaylandTextInput,
in order to avoid out of order events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
7716b62fa2 clutter: Separate ClutterInputFocus event processing and filtering
Currently, we let the same function handle key event filtering as they
are passed to the IM, and the IM events resulting in actions like text
commit or preedit changes.

Split these two aspects into filter/process functions, and port
ClutterText to it. MetaWaylandTextInput still handles everything in
a single place, but that will be split in later commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Carlos Garnacho
ff4953caa6 wayland: Remove redundant ifdef
It's already surrounded by the same ifdef

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3044>
2023-06-13 14:21:41 +00:00
Jonas Ådahl
63767df59a backend: Initialize cursor renderer position too
This means initializing the pointer position in MetaSeatImpl
synchronously too, otherwise it's not guaranteed querying the seat state
will result in the expected position.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3071>
2023-06-13 13:22:59 +00:00
Jonas Ådahl
0b0f863428 seat/native/impl: Also init core pointer coordinates
Otherwise clutter_seat_query_state() doesn't give us the expected value,
since it doesn't check the seat pointer coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3071>
2023-06-13 13:22:59 +00:00
Michel Dänzer
4d664fd797 output/kms: Use meta_kms_connector_get_preferred_mode in init_output_modes
I have a monitor which can report two preferred modes: 5120x1440@240
and 3840x1080@60. Since they are enumerated in this order by KMS,
init_output_modes would end up using 3840x1080@60 (and it was impossible
to select any 5120x1440 mode in the GNOME display settings).

Fix this by using meta_kms_connector_get_preferred_mode, which returns
the first KMS mode with DRM_MODE_TYPE_PREFERRED.

v2:
* Use meta_kms_connector_get_preferred_mode. (Jonas Ådahl)

Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3055>
2023-06-12 18:59:06 +00:00
Jonas Ådahl
49e6ce459c backend: Dispatch initial burst of events synchronously on init
This will consist of device-added events, meaning before init finishes,
we can derive some state that depends on the set of input devices
available on startup, such as cursor visibility.

This avoids cursor visibility switching between hidden and visibility
during startup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Jonas Ådahl
27606cf1fb seat/native/impl: Start reading input device events when starting
This opens up for a possibility to handle initial events (devices
discovered on startup) during initialization, meaning we can figure out
a more correct initial state that depends on available input devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Jonas Ådahl
af078264fa backend: Init pointer position with clutter_seat_init_pointer_position()
Also fix a function name and remove an unused struct field.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Jonas Ådahl
060c4c2dfc clutter/seat: Add API to initialize pointer position
This is different from "warping" as it doesn't necessarily result in a
pointer motion event. This can be helpful during initializing so we can
avoid faked pointer events that would otherwise need to be special cased
to not appear as actual pointer movements.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
2023-06-12 18:16:01 +00:00
Timotej Šulík
97f0e2e691 monitor: Ensure the preferred mode is always included
If there are two display modes present with the same flags,
and one of them is the preferred mode, it could have been
excluded from the resulting list of display modes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2858
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3061>
2023-06-12 15:26:47 +00:00
Jonas Ådahl
bea2fdc12b profiler: Add missing call to stop profiling
Otherwise the profiling backend (cogl-trace.c) doesn't actually stop,
and will complain if we try to start it up again.

Fixes: ab39eaf131 ("cogl/trace: Make global start/stop more explicit")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3068>
2023-06-12 12:20:38 +00:00
Jonas Dreßler
26344fb533 clutter/actor: Don't store a second stage-views list for the stage
The stage already maintains its own list of stage-views via
clutter_stage_peek_stage_views(), it's a bit superfluous to copy that list
around all the time into priv->stage_views of ClutterActor. Let's deal with
that by returning clutter_stage_peek_stage_views() when
clutter_actor_peek_stage_views() gets called for the stage.

In order to make sure ClutterActor::stage-views-changed still gets emitted
correctly for the stage, always emit that signal on the ClutterStage when
the stage views get invalidated. This now depends on the backend only
actually invalidating the views and calling
clutter_stage_clear_stage_views() when things have actually changed, but
that should be the case.

This needs a change in one of the stage-views tests, namely the one which
tests stage-view-changed emission on the stage: Here we now see an emission
of stage-views-changed, but that signal emission actually seems correct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2679>
2023-06-06 11:41:01 +00:00
Jonas Ådahl
0884747dce window-actor/x11: Fix using shape region for input
There were two issues with using the shape region to derive an input
region.

Firstly, the shape region is against the client rectangle, while the
surface actor needs it to be against the buffer rectangle. Fix this by
offsetting the shape region before passing it along.

Secondly, we can't just intersect the shape and input region, since that
leaves out the window decorations. Fix this by only intersecting the
input region covering the client part, and the shape region, and then
union that with the input region covering the rest.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3045>
2023-06-02 22:41:35 +02:00
Sebastian Keller
6274bb3518 x11: Use input region from frame window for decorated windows
Previously the input region was ignored for decorated windows, which
since the introduction of the frames client meant that the entire shadow
region of the frame window was considered interactive.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2706
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3031>
2023-06-02 20:21:56 +00:00
Bilal Elmoussaoui
9a6ee5d7c7 clutter: Drop unnused cairo specific APIs
The APIs are not used by Mutter and GNOME Shell, so they should be safe to remove

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3040>
2023-06-01 16:10:13 +00:00
Sebastian Keller
2b58efbcbb meta: Remove unused MetaFrameFlags enum
It has been unused since 04fa926e, but could not be removed before
branching due to being in a public header.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3036>
2023-06-01 12:15:20 +00:00
Jonas Ådahl
798a6e450a kms/impl-device/dummy: Add empty disable() implementation
We don't need to do anything, since we have no mode setting devices to
disable in the dummy implementation.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2841
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3037>
2023-06-01 11:29:09 +00:00
Jonas Ådahl
b413f45bee profiler: Enable tracing on threads added while running
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
ab39eaf131 cogl/trace: Make global start/stop more explicit
Don't try to handle things by threads enabling/disabling the main trace
context on-demand, just have a clear start/stop API. For the D-Bus API,
it becomes more straight forward, and for the persistent variant too, as
it avoids having to pass garbage input when it's known that arguments
will be discarded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
33a210d768 x11/events: NULL Check input event when getting name
Fixes a SIGSEGV when trying to get the name of an XIEvent for profile
trace data gathering. We don't use GDK anymore, so we can't rely on any
GDK semantics.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
e4b2b141d9 seat/impl: Trace libinput dispatching and event processing
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
1ca76e9b9c context: Start persistent profiling via command line argument
Persistent profiling was started via an env var, but that's rather hard
to discover and remember without grepping; change to use a command line
argument.

The profiler is started early, even during (though late in)
configuration, but configuration should ideally be instant and pointless
to configure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
e16d683721 profiler: Add API to register profiler threads
The registered threads will get tracing turned on when MetaProfiler is
started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
604aeba9b3 events: Trace handling of event
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Jonas Ådahl
340d585f91 compositor: Reparent the backend window unmanaging the display
Under X11 hiding the backend implies also unmapping the stage window, if
we do that after that we've closed the display we may end up in a
BadWindow error because such window seems to be destroyed together with
the compositor output parent (even though we are not notified about), so
to prevent this, reparent the backend window during compositor unmanage,
setting it back as a root window child.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Marco Trevisan (Treviño)
f013764b57 x11/backend-x11: Close the X11 Display where it's created
We open the clutter backend display inside MetaBackendX11, but we end
up closing it MetaClutterBackendX11, that is not it's direct owner.

So do it where it belongs

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Marco Trevisan (Treviño)
889cd056e7 x11/x11-errors: Use the default error handler when display is destroyed
An X11 server connection may still be around when we close the display,
and mutter_x_error could be triggered when x11_display has been already
destroyed leading to a crash.

To prevent this use the default X11 error handler.

As per this, also move the ownership of the error traps to x11-errors.

See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Marco Trevisan (Treviño)
6d992e9e45 tests: Perform x11 test in both sync and async modes
The former allows better catching of issues, so do both cases

See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Robert Mader
ed1d8bed93 Revert "backend/native: Sending modifiers to clients can be disabled via udev"
This is unused now. For testing purposes,
`MUTTER_DEBUG_SEND_KMS_MODIFIERS=0` can still be used.

This reverts commit efc4fa333c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3030>
2023-05-30 14:25:28 +02:00
Jonas Ådahl
cef1a5d377 wayland/actor-surface: Only set input region of non-X11 window actors
Xwayland nevers sets the input region since that is handled using
`XShapeGetRectangles()` called with `ShapeInput`. Setting it from the
wl_surface would mean setting it to "infinite", effectively undoing what
`ShapeInput` communicated.

https://gitlab.gnome.org/GNOME/mutter/-/issues/2788

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3022>
2023-05-29 13:21:14 +00:00
Jonas Ådahl
e829862249 wayland/actor-surface: Set opaque region even without X11 client support
A `#ifdef` macro wrapped too much making opaque regions no longer being
set if mutter would be compiled without X11 client support.

Fixes: 6e818c8c38 ("build: Allow disabling xwayland")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3022>
2023-05-29 13:21:14 +00:00
Carlos Garnacho
b5900dd97a backends: Avoid orientation changes around suspend/resume if locked
We currently lock the capability of the MetaOrientationManager to emit
the ::orientation-changed signal, but otherwise keep reading the current
orientation and returning it if we are asked politely through
meta_orientation_manager_get_orientation().

This may bring issues e.g. around suspend/resume, since there may be other
parts of the code trying to get the current orientation without receiving
::orientation-changed signals, this may result in the display orientation
being effectively rotated, then stay locked after that.

In order to fix this, make the MetaOrientationManager return a fixed
orientation while locked, only updated after changes in the lock state.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2600
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3021>
2023-05-27 19:19:09 +00:00
Carlos Garnacho
410c08e1e2 backends/x11: Chain up in nested backend cursor renderer
This is missed, leaving the cursor renderer disconnected from the stage
updates that could trigger further frame callbacks on the cursor, leaving
some clients like Xwayland stuck with cursors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3025>
2023-05-27 10:23:20 +00:00
Marco Trevisan (Treviño)
079745ca9f tests/dbusmock-templates/colord: Remove unused variables
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3016>
2023-05-25 09:21:57 +00:00
Marco Trevisan (Treviño)
7d95a41ec2 tests/dbusmock-templates/colord: Support usernames with dash chars
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3016>
2023-05-25 09:21:57 +00:00
Robert Mader
4a5a31edc6 mutter: Remove stray spaces
To silence code-style-check complains.

Fixes d44f02ba64

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3018>
2023-05-24 14:16:41 +02:00
Georges Basile Stavracas Neto
894b4c713f meta/stage: Remove "actors-painted" signal
It is currently unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3007>
2023-05-23 12:47:07 +00:00
Carlos Garnacho
8c0809995a backends: Do not prevent mapping/keep-aspect changes on integrated tablets
We do in fact allow these combinations of configuration since the Settings
Wacom panel revamp. We no longer need to look up Wacom device features,
since this is allowed for all the devices that have these settings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3012>
2023-05-22 17:01:59 +00:00
Carlos Garnacho
ee412cc4a3 backends/native: Change handling of display mapping for rel tablet tools
We avoided setting the device matrix applying to the tablet tool (used if the
tablet is in absolute coordinates mode) if the device is configured for relative
motion, but forgot to apply the matrix if changing the device back to absolute
mode, this made the device seemingly forget its attached display until later
configuration changes.

In order to avoid the hassle of looking up the right display again on unrelated
configuration changes, make the matrix be always set on the device, but only
actually used in absolute coordinates mode. This makes the device able to
seamlessly switch between modes and remain mapped to the right display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3012>
2023-05-22 17:01:59 +00:00
Carlos Garnacho
558f3156dc backends/native: Fix relative motion filtering for tablet tools
This was somewhat ineffective since it was applied after figuring out
the x/y absolute coordinates. Change the order (filter first, then
figure out abs coords), and use coordinates from the correct device
while at it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3012>
2023-05-22 17:01:59 +00:00
Carlos Garnacho
3bea86298d core: Avoid placing hidden windows too early on Wayland
This check only waited for windows without a buffer for wayland
clients. This should happen for all windows on a Wayland backend
here, unlike the other places calling client_window_should_be_mapped()
that expect to get ahead of the window state.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2786
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2999>
2023-05-22 16:12:36 +00:00
Bilal Elmoussaoui
d44f02ba64 mutter: Cleanup gi-docgen annotations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2939>
2023-05-22 15:47:37 +00:00
Carlos Garnacho
4fcfd0350e core: Sync actor frozen state after destroying frame
A window may become undecorated while the frame window is
frozen due to updates. In that case we would both miss a
reply for the frame window, and any other means to trigger
the window actor being thawed.

Check the frozen state after destroying the frame, so that
meta_window_x11_are_updates_frozen() may end up changing
opinion if the frame window was caught in this situation.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2639
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2996>
2023-05-22 15:13:30 +00:00
msizanoen1
ae4755cc61 surface-actor: Fix meta_surface_actor_is_obscured_on_stage_view
`meta_surface_actor_is_obscured_on_stage_view` currently fails to
account for non-identity scaling of actor size (e.g. window actor
geometry scale or surface pixel alignment).

Fix this by using the new `meta_region_apply_matrix_transform_expand` to
calculate the unobscured region in stage coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
231729b7f2 window-actor/wayland: Check opacity before subtracting background in cull
This ensures that the background regions don't get marked as obscured if
the window itself is transparent (e.g. in window animation).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
caca38106f surface-actor: Use clutter_actor_get_paint_opacity
This prevents opaque regions from being subtracted from the unobscured
regions while MetaWindowActor is transparent (e.g. in window close
animation).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
8b3c1f4b87 cullable: Generalize actor coordinates space translation for regions
This allows MetaCullable to work with actors using arbitrary transforms
which will be needed for implementing surface pixel alignment for
fractional-scale-v1.

This also deletes meta_cullable_is_untransformed as it's no longer
necessary, and we can also stop manually scaling the region objects
while performing opaque region culling in surfaces since it's now
handled transparently by the new `meta_cullable_cull_out_children`
implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
ae403f2e94 wayland: Use new highest scale monitor tracking for fractional_scale_v1
This ensures consistency with the surface pixel alignment transforms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
e94b527777 surface-actor/wayland: Implement stable size and position rounding
Implement the stable rounding algorithm as described in the discussions
for the fractional-scale-v1 protocol.

This adds an override of the ClutterActor::apply_transform vfunc for
MetaSurfaceActorWayland that ensures the size and position of the
contents of the surface are rounded according to the stable rounding
algorithm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
ed90c78872 window-actor/wayland: Align window content to physical pixel
Always ensure that the MetaSurfaceContainerActorWayland is aligned to physical
pixel boundary in preparation for fractional-scale-v1 protocol support.

This introduces an override of ClutterActor::apply_transform vfunc for
MetaSurfaceContainerActorWayland that always ensures the actor content is aligned
to physical pixel boundary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
e4d7667c43 core/window: Track monitor with the highest scale value
This is used for Wayland fractional scale pixel alignment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
Jonas Ådahl
875922fbe3 tests/test-runner: Log each command before running
With verbose mode test runner will log every command before it executes
it. Hopefully this will help in some cases when tests fail in CI with a
timeout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2893>
2023-05-22 13:21:39 +00:00
Robert Mader
f73fdfb465 drm-buffer-gbm: Bail out early if FBO allocation fails
A failing allocation is non-fatal here, however if it fails later in a
lazy allocation triggered by `cogl_framebuffer_create_timestamp_query()`
we end up crashing. Thus force the allocation early, like we already do
in other places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3004>
2023-05-17 13:37:50 +00:00
Carlos Garnacho
18e06c2484 backends/x11: Use backend-side error traps for input configuration
While it's obviously good to trap possible errors from X calls, we are
mixing the Clutter error trap with the MetaX11Display one for these
calls.

This may result in situations where a X call within a Clutter error
trap fails, but it's actually handled in these sections using the
MetaX11Display error trap. This one will consider the serial out
of the "handled" parts and raise an error.

It is better to stay consistent here, and use the same error traps
than the rest of the X11 backend.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2796
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3002>
2023-05-16 16:02:43 +00:00
Carlos Garnacho
3218626d7e x11: Do not unminimize windows with initial IconicState
This is a revert of commit be5c2ebc, adapted to this day and age.
While this worked around issues in wine/proton, it did contravene
icccm in the interpretation of initially iconic windows.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2043
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3001>
2023-05-16 15:34:25 +00:00
Bilal Elmoussaoui
b9a6891910 display: Drop the indirection when initializating Xwayland
The init function didn't do much other then calling into the xwayland
one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:47:06 +02:00
Bilal Elmoussaoui
15b25568b2 compositor/x11: Drop duplicated methods calls
Those are called in the handler of MetaDisplay::x11-display-opened

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:41:54 +02:00
Bilal Elmoussaoui
02a436d607 wayland: Move surface check to MetaWaylandSurface
Allows dropping various HAVE_XWAYLAND ifdef as the function would always
return false if Mutter is built without XWayland

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:41:54 +02:00
Bilal Elmoussaoui
a27b9d9707 wayland: Guard XWayland types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:41:54 +02:00
Bilal Elmoussaoui
0f88f0931c core/events: Guard X11 types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
3e95609073 compositor/dnd: Guard X11 types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
761a254e6f core/display: Guard X11 types
This also moves a couple of function calls to
MetaDisplay::x11-display-opened a signal handler

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
aaa3f34cc0 compositor: Guard X11 types
This also moves meta_compositor_x11_redirect_windows to DisplayX11
where it makes more sense as meta_display_x11_redirection_windows

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:23:37 +02:00
Marco Trevisan (Treviño)
184b8e9c8c x11/x11-display: Fix some wrong code style to please CI checker
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:40 +02:00
Marco Trevisan (Treviño)
c9c4b06429 tests/test-client: Use proper style for main arguments
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:39 +02:00
Marco Trevisan (Treviño)
8039b58410 x11/x11-display: Always set the compositor manager selection on init
Set the compositor manager selection during the initialization phase as
we do with the window manager selection

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:37 +02:00
Marco Trevisan (Treviño)
c653f30283 tests/test-client: Ensure that screen has always a compositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:05:00 +02:00
Marco Trevisan (Treviño)
b48351005e tests: Add check for compositor state on XWayland startup
Check that the first X11 window started has a compositor defined.

See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472#note_1582262
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:05:00 +02:00
Marco Trevisan (Treviño)
28bd3da21a tests/meson: Make tests depending on test-client to actually depend on it
It allows meson to rebuild the client-related sources when a single test
is running using the client, also ensuring that test-run dependencies
are correctly setup

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:05:00 +02:00
Marco Trevisan (Treviño)
2625edec10 x11/x11-display: Set compositor selection earlier on XWayland
When the X11 display is actually XWayland there's no point to delay the
compositor selection, given that mutter itself is the compositor and
doing this may cause the first X11 client that starts not to receive the
right information (and in some cases misbehave).

Since some toolkits are not handling the compositor selection changes
properly at later times, let's make their life easier by just
initializing the selection as early as the other X11 properties, given
that in this case there's nothing to replace.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:04:59 +02:00
Bilal Elmoussaoui
05dd401b64 tests: Make wayland-x11-interop depends on xwayland feature
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2938>
2023-05-15 11:52:35 +00:00
Jonas Ådahl
99a58be104 build: Set built headers as libmutter_dep sources
This should help avoiding compiling objects depending on built headers
to fail if they happen to be built before the sources are built.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3000>
2023-05-15 13:06:40 +02:00
Barnabás Pőcze
f01428bd96 backends/x11: Fix type confusion about object data
Since c390f70edc ("backend: Set up and use ownership chains")
the type of the ClutterInputDevice object's "meta-input-settings-xdevice"
data is `DeviceHandle`, but that commit failed to change the one place
where the object data is queried. As a consequence, that part still
considers it to be an `XDevice`, so everything that uses the return
value of `device_ensure_xdevice()` works with invalid data. Furthermore,
`device_handle_free()` incorrectly uses the `user_data` as the argument
for `XCloseDevice()` leading to a double free.

Fixes: c390f70edc ("backend: Set up and use ownership chains")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2995>
2023-05-14 23:15:55 +00:00
Jonas Ådahl
1a4f03bd79 wayland/surface: NULL check surface resource in handle_output_bound()
Otherwise binding new wl_output's might try to send enter to the
destroyed resource. Fixes the following crash:

     #0 wl_resource_get_client at ../src/wayland-server.c:801
     #1 handle_output_bound at ../src/wayland/meta-wayland-surface.c:1287
     #3 signal_emit_unlocked_R.isra.0 at ../gobject/gsignal.c:3812
     #6 ffi_call_unix64 at ../src/x86/unix64.S:104
     #7 ffi_call_int at ../src/x86/ffi64.c:673
     #8 ffi_call at ../src/x86/ffi64.c:710
     #9 wl_closure_invoke at ../src/connection.c:1025
    #10 wl_client_connection_data at ../src/wayland-server.c:438
    #11 wl_event_loop_dispatch at ../src/event-loop.c:1027
    #12 wayland_event_source_dispatch at ../src/wayland/meta-wayland.c:125
    #15 g_main_context_iterate.isra.0 at ../glib/gmain.c:4276
    #17 meta_context_run_main_loop at ../src/core/meta-context.c:482

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2196527
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2992>
2023-05-09 15:26:32 +00:00
Jonas Ådahl
802c1baec7 compositor-view: Chain up finalize()
The chaining up to the GObject finalize() method was missing, fix that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2991>
2023-05-09 10:31:38 +00:00
Robert Mader
9884a2c3d2 shaped-texture: Move variable declaration to the top
Just a minor cleanup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2990>
2023-05-07 23:18:33 +02:00
Robert Mader
2dd5196267 egl: Set EGL_IMAGE_PRESERVED_KHR on DMABUF import
Otherwise drivers would be free to alter the buffer content. While no
driver is known to do so, it's probably good to make things explicit.
See also `import_simple_dmabuf()` in Weston.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2990>
2023-05-07 23:16:37 +02:00
Jonas Ådahl
29ec2d2e20 screen-cast/src: Never dequeue pw_buffer's we refuse to record to
The DMA buffer paths vs MemFd paths differ slightly in when content is
recorded. This was in some places done by trying to record but bail if
the dequeued buffer had the wrong type. This is problematic for two
reasons: we'd update the timestamp even if we refused to record, making
the follow-up attempt fail, and we'd dequeue and queue buffers that
didn't get any content, meaning the receiving end would see empty
buffers potentially with only cursor updates.

Fix this by keeping track if a stream is DMA buffer able or not, and
don't attempt to record at all in the places we would previously require
DMA buffers. This avoids both issues: we don't dequeue/queue pw_buffers
that we refuse to record to, and we won't update the recorded timestamp
when we didn't intend to record to begin with.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2783
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2987>
2023-05-04 13:00:07 +00:00
Jonas Ådahl
8a4095308e build: Use / operator instead of format for Wayland protocol paths
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
Jonas Ådahl
61b42e5303 build: Use / operator instead of join_paths everywhere
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
Jonas Ådahl
dcaca398f1 tests: Set a dummy XDG_CONFIG_HOME variable
This avoids a local ~/.config/monitors.xml messing up tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
Andy Holmes
07184e099c docs: Add missing flag documentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2983>
2023-05-04 11:46:09 +00:00
msizanoen1
3f85158b85 surface-actor: Queue rectangles of update region separately
This aims to help reduce the amount of pixels redrawn on the screen in
case the damage rectangle is partially occluded by another surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2965>
2023-05-03 08:53:36 +00:00
adarshgm
7f18cae282 edid: Integrate libdisplay-info for edid parsing
Hides libdisplay-info under a build time default-off flag,
provides provision to parse essential edid parameters with
APIs provided by libdisplay-info. This implementaion increases
readibility, avoids code duplication and decreases complexity
of edid parsing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2642>
2023-05-02 17:37:01 +00:00
Sebastian Keller
d643eb5c6f frames: Disable XDND support on the frame window
All X11 surfaces created by gtk4 claim to support XDND via the XdndAware
property. This was leading some clients, e.g. Qt, to consider the frame
window as drop target instead of the client window.

Avoid this issue by removing the XdndAware property again after gtk has
created the surface.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2715
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2978>
2023-04-28 12:46:58 +02:00
Carlos Garnacho
18be74edeb core: Fix map transitions for X11 windows on Wayland
We are attempting to show windows that do not yet have a
surface/buffer, this makes GNOME Shell avoid transitions
for these windows.

Since on Wayland X11 windows are also Wayland surfaces,
this check is also valid for these, and is thus made more
generic to also cater for these windows.

Eventually, meta_window_update_visibility() is called
when the surface gets its buffer, so the window can be
neatly animated.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2611
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2975>
2023-04-25 17:34:24 +02:00
Carlos Garnacho
5eb17a362e tests: Avoid CSD window in test
This ATM triggers missed .commit events for the window in question,
to be addressed in Xwayland. Since the test does not seem to specifically
rely on this window being CSD, make it a regular window instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2975>
2023-04-25 17:34:24 +02:00
Carlos Garnacho
57fdd7efd2 frames: Use cairo renderer on GTK frames
Going for the default GL renderer is known to trigger rendering
artifacts using the NVidia proprietary driver. Since we don't have
too many expectatives about frames being flashy (not to the point
of mandating GL), resort to the cairo renderer in the mean time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2976>
2023-04-24 12:07:06 +02:00
Sebastian Wick
cca07612b8 output: Check the EDID for the supported sink Colorimetry
Just like the HDR Metadata property the Colorspace property values only
indicate that the display driver supports signaling certain colorimetry.
It does not indidcate that the sink actually supports processing the
colorimetry. For this we have to look up the colorimetry support in the
EDID.

The default colorimetry is always supported. If we want bt.2020 we might
get either the RGB or YCC variant even if we ask for the RGB variant but
there is nothing we can do about it so let's just pretend it's a driver
issue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2919>
2023-04-21 00:00:24 +02:00
Robert Mader
754a1a1ce6 wayland/dma-buf: Enable modifiers by default on non-native backend
If the used EGL backend supports it. In practice this should currently
only affect the nested backend.

Enabling modifiers can help with app development. An example is
`weston-simple-dmabuf-v4l`, which requires the linear modifier to be
available.

Note that Weston behaves similar already.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2972>
2023-04-20 15:34:00 +00:00
Sebastian Keller
04fa926eea core: Remove meta_frame_get_flags()
It is private and the last caller was removed in 92feea30.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2971>
2023-04-20 15:49:55 +02:00
Robert Mader
b56ab36704 xdg-shell: Always handle frame callbacks in popup_apply_state()
Just like we do in `toplevel_apply_state()`.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/2752

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2963>
2023-04-20 12:34:47 +00:00
Daniel van Vugt
dd6be7cf2a backends/x11: Trap errors from XIChangeProperty
And report them as warnings instead of crashing.

https://launchpad.net/bugs/2014986

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2960>
2023-04-18 20:18:01 +00:00
Jonas Ådahl
86b5d9d809 Replace using sscanf() to parse mode strings with new helper
This fixes issues when the locale uses characters other than `.` in
floating point numbers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
2023-04-18 18:38:03 +00:00
Jonas Ådahl
2fd9834d94 monitor: Add helper to parse simple mode strings
This will be used to extract the resolution and refresh rate from
strings like "1920x1080@60.0" or "1280x720". This aims to replace the
use of the locale dependent sscanf() function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
2023-04-18 18:38:03 +00:00
Jonas Ådahl
550a1dadf1 monitor: Don't use locale dependent mode ID string
The result of printf("%f", number) depends on the locale. To avoid
unpredictable mode IDs, make sure they always are generated the same no
matter the locale.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
2023-04-18 18:38:03 +00:00
Michel Dänzer
db24557e40 wayland/xdg-shell: Bail from popup_configure if resource was destroyed
This function gets called when a surface state transaction is applied.
Applying a transaction can get delayed, so the Wayland resource may have
already been destroyed when we get here. In that case we cannot send
events, so there's nothing to do.

v2:
* Drop code comment, expand commit log instead. (Jonas Ådahl)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2737
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2967>
2023-04-18 10:37:18 +00:00
Jonas Ådahl
867494d3df wayland/cursor-surface: Update cursor on dispose
Otherwise we'll have a cursor sprite backed by a surface that no longer
exist. This usually doesn't happen, but can happen in rare situations
related to pointer capability changes Wayland client cursor changes and
hotplugs.

Fixes the following crash:

  #0 meta_wayland_buffer_get_resource() at ../src/wayland/meta-wayland-buffer.c:128
  #1 realize_cursor_sprite_from_wl_buffer_for_gpu() at ../src/backends/native/meta-cursor-renderer-native.c:1649
  #2 realize_cursor_sprite_for_gpu() at ../src/backends/native/meta-cursor-renderer-native.c:1869
  #3 realize_cursor_sprite() at ../src/backends/native/meta-cursor-renderer-native.c:1887
  #4 meta_cursor_renderer_native_update_cursor() at ../src/backends/native/meta-cursor-renderer-native.c:1100
  #5 meta_cursor_renderer_update_cursor() at ../src/backends/meta-cursor-renderer.c:414
  #6 meta_cursor_renderer_force_update() at ../src/backends/meta-cursor-renderer.c:449
  #7 update_cursors() at ../src/backends/meta-backend.c:328
  #8 meta_backend_monitors_changed() at ../src/backends/meta-backend.c:338
  #9 meta_monitor_manager_notify_monitors_changed() at ../src/backends/meta-monitor-manager.c:3590
 #10 meta_monitor_manager_rebuild() at ../src/backends/meta-monitor-manager.c:3678
 #11 meta_monitor_manager_native_apply_monitors_config() at ../src/backends/native/meta-monitor-manager-native.c:343
 #12 meta_monitor_manager_apply_monitors_config() at ../src/backends/meta-monitor-manager.c:706
 #13 meta_monitor_manager_ensure_configured() at ../src/backends/meta-monitor-manager.c:779
 #14 meta_monitor_manager_reconfigure() at ../src/backends/meta-monitor-manager.c:3738
 #15 meta_monitor_manager_reload() at ../src/backends/meta-monitor-manager.c:3745

or the following on gnome-43:

 #0 meta_wayland_surface_get_buffer at ../src/wayland/meta-wayland-surface.c:441
 #1 meta_cursor_sprite_wayland_get_buffer at ../src/wayland/meta-cursor-sprite-wayland.c:83
 #2 realize_cursor_sprite_from_wl_buffer_for_gpu at ../src/backends/native/meta-cursor-renderer-native.c:1612
 #3 realize_cursor_sprite_for_gpu at ../src/backends/native/meta-cursor-renderer-native.c:1836
 #4 realize_cursor_sprite at ../src/backends/native/meta-cursor-renderer-native.c:1854
 #5 meta_cursor_renderer_native_update_cursor at ../src/backends/native/meta-cursor-renderer-native.c:1087
 #6 meta_cursor_renderer_update_cursor at ../src/backends/meta-cursor-renderer.c:413
 #7 meta_cursor_renderer_force_update at ../src/backends/meta-cursor-renderer.c:448
 #8 update_cursors at ../src/backends/meta-backend.c:344
 #9 meta_backend_monitors_changed at ../src/backends/meta-backend.c:354

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2185113
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2968>
2023-04-17 19:53:35 +00:00
Jonas Ådahl
9252131348 cursor-tracker: Don't leak window cursor on exit
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2968>
2023-04-17 19:53:35 +00:00
Robert Mader
a7a7933e03 wayland: Emit frame events in GSource after "empty" updates
Under certain conditions a stage-view update does not trigger a kms
update.

In such cases we still want the next update to run within the same
refresh cycle, as otherwise we'd waste the remaining time in the
current one.
At the same time we currently use the `after-update` signal for Wayland
frame events, which again may result in more "empty" updates -
creating an unthrottled feedback loop. This can trigger excessive
load both in the compositor as well as in clients.

Introduce a new GSource that is dispatched once per refresh cycle at
maximum per stage view and use it to emit frame events. Do so by
computing the time from when on we can be sure that an update resulting
from a client commit would certainly get scheduled to the next refresh
cycle.

Note: this only works on the native backend. Given that chances are
small that we hit the corresponding issue on e.g. the nested backend,
stick to the previous behavior there for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2823>
2023-04-17 09:16:10 +00:00
Robert Mader
020d128d15 frame/native: Remember whether the frame carried a kms update
So that information is available in e.g. after_update handlers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2823>
2023-04-17 09:16:10 +00:00
Sebastian Keller
dddaf19d07 x11: Always initialize all fields of XEvents sent via XSendEvent
The X server ignores the send_event and serial in incoming XEvents, so
they were not initialized when calling XSendEvent in a few places.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2641
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2964>
2023-04-17 01:52:36 +02:00
Sebastian Keller
6b57ab8975 workspace: Only consider windows that should be showing as focusable
When selecting the default focus window, is_focusable() was not
considering the new conditions for whether a window should be shown or
hidden that were added to meta_window_should_be_showing() in 39942974.
As a result the default focus window could end up a window already
hidden or hidden once meta_window_flush_calc_showing() is called by
meta_window_focus() when focusing the default window. This would cause
meta_window_focus() to fail, which is an issue if it prevents us from
unfocusing a window when it is getting unmanaged.

Fixes: 399429742 ("x11: Integrate frames client into Mutter")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2644
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2962>
2023-04-16 11:48:37 +02:00
Sebastian Keller
a86900091d wayland: Set compositor when creating MetaWaylandDataSourceXWayland
create_and_send_dnd_offer() sets the compositor of the offer to the one
from the MetaWaylandDataSource. This then later gets used in
display_from_offer() when trying to get the context from the compositor.
meta_wayland_data_source_xwayland_new() however was not setting the
compositor, so this was causing crashes when dragging things from X11
windows on Wayland.

Fixes: 2731f0cda ("wayland: Setup and use ownership chains")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2723
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2956>
2023-04-15 16:01:42 +00:00
msizanoen1
1b140e8cb9 wayland/data-device: Clear data source when cancelling drag with ESC
This ensures a consistent code path with other cases where the drag
operation might be cancelled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2953>
2023-04-15 10:11:07 +00:00
msizanoen1
ce0d9ccb37 dnd: Clear Wayland drag source when cancelled from stage grab context
This ensures that applications are notified when a drag gets cancelled
because the user dropped or press ESC while in overview.

This fixes an issue with Chromium on Wayland refusing to acknowledge
wl_pointer::enter events after accidentally dropping a
Chromium-originated object in GNOME Shell overview.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2953>
2023-04-15 10:11:07 +00:00
Carlos Garnacho
2a600ac98e frames: Forward _NET_WM_STATE during frame initialization
Ensure the frame window is created at the right fullscreen state
before showing it and assigning it to the client window.

A peculiarity of this property on frame windows is that it is
typically single-handedly updated from the Mutter side, in synchronization
with client window state. It can only differ during creation, since
GTK still likes to apply its own state.

Also, the only relevant property seems to be _NET_WM_STATE_FULLSCREEN,
since the others are less relevant to the role of the frames client,
and get applied to the MetaWindow as a whole, instead.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2712
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2961>
2023-04-14 13:55:23 +00:00
Sebastian Keller
6fbe4286ea x11: Fix remaining leaks from switch to XGetAtomName()
After this got changed from gdk_x11_get_xatom_name() to XGetAtomName(),
this no longer returns a const char* and it now also needs to be freed.

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
94bd5c7319 x11: Use Atoms when constructing a new MetaX11SelectionOutputStream
This was pointlessly being converted between atom and string and back,
which with the switch from gdk_x11_get_xatom_name() to XGetAtomName()
also introduced a leak for every XGetAtomName() call.

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
01ae1d32ee x11: Remove unused member variables from MetaX11SelectionInputStream
The private format and type member variables were not being used by any
of the callers, so they can simply be removed. This also fixes a leak of
type which was introduced when switching from gdk_x11_get_xatom_name()
to XGetAtomName().

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
5a4b67dd9e wayland: Don't leak XDnD mime type strings
After this got changed from gdk_x11_get_xatom_name() to XGetAtomName(),
this no longer returns a const char* and it now also needs to be freed.

Fixes: 014cde646 ("wayland: Do not use GDK functions on XDnD implementation")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Jonas Ådahl
47b6e76578 xdg-shell: Early out of apply if dismissed
We might end up trying to apply a pending state late if it was delayed
by DMA buffers not being ready. Trying to discard the pending state from
the transaction when dismissing is hard, because we might be applying a
chain of transactions that would disqualify subsequent transactions if a
former one dismisses the popup, so lets just drop what the apply would
otherwise do, if we're not going to use it anyway.

This fixes the following crash:

  0) meta_wayland_surface_get_window (surface=0x0)
  1) meta_wayland_xdg_popup_apply_state (surface_role=0xf5ee80, pending=0xf662a0)
  2) meta_wayland_surface_role_apply_state (surface_role=0xf5ee80, pending=0xf662a0)
  3) meta_wayland_surface_apply_state (surface=0xf5e640, state=0xf662a0)
  4) meta_wayland_transaction_apply (transaction=0xf56170, first_candidate=0x7fffffffcee8)
  5) meta_wayland_transaction_maybe_apply_one (transaction=0xf56170, first_candidate=0x7fffffffcee8)
  6) meta_wayland_transaction_maybe_apply (transaction=0xf56170)
  7) meta_wayland_transaction_dma_buf_dispatch (buffer=0xf448a0, user_data=0xf56200)
  8) meta_wayland_dma_buf_source_dispatch (base=0xf5f140, callback=0x0, user_data=0x0)
  9) g_main_dispatch (context=0x41baa0)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2940>
2023-04-13 21:02:08 +02:00
Jonas Ådahl
50a37a7fc0 wayland/xdg-shell: Dismiss instead of destroy invalid popup
Destroying is insufficient as it doesn't end any popup pointer grab, if
the dismissed popup was the last. This would later hit an assert as the
popup grab is assumed to always have at least one popup in its chain.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2728
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2940>
2023-04-13 21:02:03 +02:00
Jonas Ådahl
697b99ee13 wayland/xdg-shell: Ignore reposition if popup was dismissed
If the popup was dismissed (i.e. has no MetaWindow anymore), it'll also
have no parent surface. With no parent surface, we'd try to fetch a
transaction from NULL and crash, but if we don't try if we were
dismissed, we won't reach here anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2940>
2023-04-13 21:02:03 +02:00
Carlos Garnacho
f744acefee core: Create passive button grab on topmost Window
With the frames client, we do no longer handle events for the
frame window inside Mutter. This means we do not get events
"for free" to handle focus on a just clicked frame window.
This results in a background window not ending up focused if
clicked on its frame.

In order to fix this, make the passive button grab extend to
the frame window if a window has one. This brings back
focus-on-click behavior, while treating windows further as
a unitary surface.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2727
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
2023-04-12 11:28:50 +02:00
Carlos Garnacho
a42bc34e4d core: Pass MetaWindow on passive button grab machinery
In practical effects the passed Window is always window->xwindow,
so pass the MetaWindow and get the better X11 Window deep in the
call stack.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
2023-04-12 11:28:50 +02:00
Carlos Garnacho
e30abee5a2 core: Minor refactor
Do not make code live before variable declarations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
2023-04-12 11:28:50 +02:00
Georges Basile Stavracas Neto
bc19f55129 screen-cast/monitor-src: Record frames with presentation time
Pass the timestamp of the frame as the target timestamp of the
record. This makes the rudimentary frame throttling mechanism
inside MetaScreenCastStreamSrc work with the timing variability
that dynamic dispatch times introduced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
bc2f1145d8 screen-cast/monitor-src: Record DMA-BUF frames immediately
Instead of always, unconditionally scheduling an idle callback for
frame recording, try to record a DMA-BUF only frame, and only if
that's not possible, schedule the idle callback.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
7f28fa6c79 screen-cast/src: Shuffle a variable around
This GError is only used within the frame recording block, so move
it there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
ded7b8dfba screen-cast/src: Clean up DMA-BUF only error paths
When a stream source subclass asks for a DMA-BUF only frame record,
it is legitimate to return FALSE in do_record_frame() - meaning that
a frame was not recorded - but not return an error - meaning nothing
actually failed.

This avoids spamming the journal with warnings on a legitimate case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:53 +02:00
Georges Basile Stavracas Neto
16aa2943e2 screen-cast/src: Add frame recording variant with timestamp
Add meta_screen_cast_stream_src_maybe_record_frame_with_timestamp()
which operates on arbitrary timestamps; and make the current function
meta_screen_cast_stream_src_maybe_record_frame() just call into the
new variant, passing g_get_monotonic_time() as the timestamp.

This will be useful later we start using the target timestamp of the
frame for screencasting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:49:48 +02:00
Georges Basile Stavracas Neto
b47d96b862 backends/stage: Pass ClutterFrame to MetaStageWatchFunc
We'll need to access the timestamp of the frame later on, so pass
it to stage watchers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:19:23 +02:00