1
0
Fork 0
Commit graph

30069 commits

Author SHA1 Message Date
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
Georges Basile Stavracas Neto
81c9c43d26 clutter/stage: Assign frames to paint context
When rendering through the 'paint-view' handler, assign the frame
to the paint context. Otherwise, when rendering outside of the
frame clock schedule, don't.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:19:23 +02:00
Georges Basile Stavracas Neto
82b037e74c clutter/paint-context: Allow assigning a ClutterFrame
This is not yet used, but next commits will need to assign a frame
to the paint context whenever painting onscreens.

Assigning a frame to the paint context is a one-way operation, and
treats multiple assignments strictly as a programming error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2804>
2023-04-07 12:19:23 +02:00
Corentin Noël
eeee654031 cursor-tracker: Enhance the documentation and increase annotation coverage
Add the (optional) parameters when they are actually supported and at least add
the minimal documentation on functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2951>
2023-04-07 11:30:40 +02:00
Salman
776e3f329d screen-cast-stream-src: Export damaged video regions
This change will export the damaged regions (when available) out
to the pipewire client. This change is currently specific to
virtual streams only (where I was able to test the change) and
maintains the current behavior for other screencast stream types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2775>
2023-04-06 23:09:43 +00:00
Salman
6223742996 screen-cast-stream-src: Minor adjustment
This change makes it easier to add/remove stream params during test/dev.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2775>
2023-04-06 23:09:43 +00:00
Salman
43cee4b6b6 stage-impl: Do clipped redraws when drawing offscreen
This change allows clipped redraws for offscreen. The net
effect of this change is to preserve the original redraw clip when
possible (rather than overwriting it with the full view redraw) in
the paint context.

This eventually helps in retrieving the fine grained updated regions of
the frame since last redraw and sending it to the pipewire client
(as shown in a subsquent CL).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2775>
2023-04-06 23:09:43 +00:00
Jonas Ådahl
ab36baa9b1 frames/content: Use gtk_widget_compute_point()
The non-graphene-point variant is deprecated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2949>
2023-04-05 16:38:16 +00:00
Florian Müllner
018786dab8 output-xrandr: Don't treat 0 as invalid backlight value
Whether a value is in range depends on the backlight-min/max values,
and I didn't spot anything that excludes 0 as a valid lower limit
outright.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2947>
2023-04-04 19:30:06 +00:00
Florian Müllner
aa1eaa8120 output-xrandr: Consistently return -1 on error
Returning FALSE does not indicate an error, but a valid backlight
value of 0. Consumers expect a negative value to indicate no
backlight support, so return -1 in case of error, just like we
already do for invalid values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2947>
2023-04-04 19:30:05 +00:00
Carlos Garnacho
1e459c8302 x11: Wrap X call with error traps
Lest it fails. Try to recover from that and keep reading
the mimetypes present in the atom list.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6555
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2945>
2023-04-04 18:35:11 +00:00
Carlos Garnacho
2e82702084 x11: Pass Atom directly
We convert an atom to string just to convert it to an atom. We
can avoid the roundtrip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2945>
2023-04-04 18:35:11 +00:00
Marco Trevisan (Treviño)
20e2adc4fc frames/window-tracker: Select StructureNotifyMask X11 events
The window tracker is filtering XEvents manually as it only requires a
subset of the ones that Gdk listens to in the root window, and this is
nice, but we were restricting the set a bit too much because due to this
we were not notified when an xsettings manager was available, and thus
in case gsd-xsettings was launched after meta-window-tracker (a normal
scenario under X11), no xsetting was actually applied to the decoration
windows.

As per this, the default settings were used for everything and never
updated, until a restart of the window-tracker.

In order to be able to monitor the XSettings changes at startup, we also
need to select the StructureNotifyMask as gtk always do by default.

See also:
  https://gitlab.gnome.org/GNOME/gtk/-/blob/4.11.1/gdk/x11/gdkscreen-x11.c#L947-950

Fixes: #2580
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2948>
2023-04-04 10:50:42 +00:00
Chris Mayo
28a599631d backend: Fix build with -Dremote_desktop=false
../mutter-44.0/src/backends/meta-backend.c: In function ‘meta_backend_real_post_init’:
../mutter-44.0/src/backends/meta-backend.c:560:7: error: ‘MetaBackendPrivate’ {aka ‘struct _MetaBackendPrivate’} has no member named ‘remote_access_controller’
  560 |   priv->remote_access_controller =
      |       ^~

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2655
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2935>
2023-04-03 21:34:54 +00:00
Nathan Follens
29c14ba0a5 Update Dutch translation 2023-04-02 13:06:15 +00:00
Ngọc Quân Trần
0d385f544a Update Vietnamese translation 2023-04-01 01:21:46 +00:00
Jonas Ådahl
8ca94f4d3f backends: Use meta_gamma_lut_new_sized() in a few more places
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2944>
2023-03-30 11:21:02 +00:00
Carlos Garnacho
f3f1db5e33 compositor: Drop anchor_window_pos field from MetaWindowDrag
This is now only set and never used. We can remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Carlos Garnacho
7eb0130425 compositor: Use relative anchor coordinates for window drags
The anchor position calculations are somewhat unnecessarily complex
based on root coordinates of pointer and frame positions. This requires
tracking both things, and we don't always get it quite right with the
latter (e.g. window repositions, resizes or overshrinks, leaving the
anchor position visually outside the window).

In order to improve this, capture the window-relative coordinates
when starting the window drag, and ensure the window is always repositioned
in that position, relative to its current size.

This avoids these glitches when unmaximizing a window (e.g. dragged from
the bottom through super+button1 press), or moving windows between monitors
with different scales.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2730
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Carlos Garnacho
179124dc61 compositor: Avoid use of variable during resize
Since we only track changes to window_drag->anchor_window_pos
during move operations through on_grab_window_size_changed(), this
rectangle is in essence the same than window_drag->initial_window_pos
all the time. Just use that and move away from the anchor_window_pos
rectangle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Daniel van Vugt
61801a713a onscreen/native: Avoid freezing the frame clock on failed cursor commits
Since 73fb64cbb6 we have preferred to handle failed updates via callback
but the cursor-only update path was forgotten and so wasn't getting frame
notifications. And so the frame clock would freeze.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2691
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2933>
2023-03-29 10:43:31 +00:00
Boyuan Yang
b215a65776 Update Chinese (China) translation 2023-03-27 16:14:54 +00:00
Jonas Dreßler
7455c293c6 window-actor-x11: Check array bounds before accessing array
scan_visible_region() scans through each value of a uint8_t array and checks
whether that value is 255. Right now it always checks one value too much
though, resulting in a buffer overflow. Fix that by checking the array
bounds before actually accessing the array.

Found by running gnome-shell with address sanitizer and starting
GIMP.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2856>
2023-03-26 11:51:02 +00:00
Sebastian Keller
679d2fb4e0 build: Don't disable checks in release builds
Both Clutter and Cogl use g_return(_val)_if_fail() to safeguard
introspected API. Release builds were dropping these checks, which could
result in a much more crashy experience, especially when considering
extensions, but also due to bugs in the shell code itself.

This won't affect any major distro, because they all use "plain" builds.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2930>
2023-03-24 12:51:49 +00:00
Simon McVittie
d6af73ba68 tests: Use a more interoperable path to bash
On systems that have undergone the /usr merge, /bin/bash and
/usr/bin/bash can be used interchangeably, but on systems where /bin and
/usr/bin are separate (such as Debian 11 or older), bash was traditionally
in /bin and there is no bash in /usr/bin.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2385
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2900>
2023-03-22 15:16:06 +00:00
Jonas Ådahl
83a6a011d7 backend/nested: Ignore setting pointer constraint
This avoids a crash when pointer constraints are enabled by Wayland
clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2932>
2023-03-22 13:46:21 +00:00
Emmanuele Bassi
bc9cad5124 clutter: Safely transform paths to strings and vice versa
GValues containing objects and strings can be set to NULL, which means
the transformation functions from ClutterPath to string and vice versa
must be NULL-safe.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2625
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2929>
2023-03-21 13:47:51 +00:00
Ivan Molodetskikh
4f47ba26be Export meta_window_has_pointer ()
It is needed in gnome-shell in the screenshot UI to tell which window has a pointer over it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2928>
2023-03-20 20:23:02 +00:00
Florian Müllner
f14dcb023d compositor/window-drag: Fix keyboard resize
Both GRAB_OP_KEYBOARD_MOVING and GRAB_OP_KEYBOARD_RESIZING_* are
defined as GRAB_OP_WINDOW_BASE with FLAG_KEYBOARD set, but the
latter have additional bits set to indicate the direction.

That is, the GRAB_OP_KEYBOARD_MOVING bitmask cannot be used to
differentiate between move- and resize operations. Instead,
check that no direction bits are set.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2908>
2023-03-20 16:13:32 +00:00
Sebastian Wick
3988f5a47f backends: Fall back to the default and not the unknown color space
The unknown color space's only purpose is to signal that the current KMS
state has a unknown color space set. It is not one of the color spaces
that can be set. We already only try to set a color space if the default
color space is supported so we should use the default color space as a
fallback instead of the unknown color space.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2693
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2915>
2023-03-20 10:00:36 +00:00