1
0
Fork 0
Commit graph

2924 commits

Author SHA1 Message Date
Bilal Elmoussaoui
ead9a3024c cleanup: Switch to pragma once
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Carlos Garnacho
cd39ba8baf core: Get per-direction pad feature labels for rings/strips
Let the caller specify the directions, so that the pad OSD UI may
assign distinct labels to each direction, instead of showing an
unified one on both directions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
3e3660ae5f core: Drop META_PAD_DIRECTION_NONE
Avoid this strange value, and stick with the ones suitable
for rings/strips.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
3e6f7a9463 core: Drop META_PAD_FEATURE_BUTTON value
This is now handled externally through separate API calls.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
2da9b67673 core: Separate pad button labels in high-level MetaDisplay API
These "features" are somewhat less featured, it's becoming too ugly
to handle all of them with a single API call. The clear outlier are
buttons, so move them to a separate function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
b6a6e9f187 core: Separate MetaPadActionMapper pad button labeling
This will be handled separately in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Carlos Garnacho
85ac3a2d1a wayland: Separate pad button labeling from other pad features
This will be fully split in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Carlos Garnacho
233e612ef8 core: Rename MetaPadActionType to MetaPadFeatureType
We want to separate pad buttons from strips and rings for
purposes of labeling. Start by renaming the enum "features"
to use a less englobing word.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Sebastian Keller
7faf4a308e constraints: Delay initial maximization until after reparenting is done
For SSD windows the decoration window from the frames client might have
a different maximization state than the client window and would end up
restoring it once shown. Avoid this issue by waiting until all
reparenting is done before applying the initial maximization (and
minimization).

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2579
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3035>
2023-07-21 11:38:17 +00:00
Bilal Elmoussaoui
b852bbba47 cleanup: Stop translating nick/blurb for pspecs
As those strings are intended to be used by some UI but nothing uses
that in reality except GStreamer.
So drop them similar to what GTK did at
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4717

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3101>
2023-07-19 11:33:59 +00:00
Jonas Ådahl
a7954f4a75 onscreen/native: Move out timeval to timestamp helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
2023-07-17 21:19:34 +02:00
Peter Hutterer
a6d406d7bf backends/eis: Hook eis into the debug system
To be enabled with MUTTER_DEBUG=eis

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
2fb3bdf774 input-capture: Hook up capturing of events to active session
This adds the actual input capturing rerouting that takes events and
first hands them to the input capture session, would it be active.
Events are right now not actually processed in any way, but will
eventually be passed to a libei client using libeis.

A key binding for allowing cancelling the capture session is added
(defaults to <Super><Shift>Escape) to avoid getting stuck in case the client
doesn't even terminate the session.

The added test case makes sure that the pointer moves again after
pressing the keybinding.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Jonas Ådahl
f9b18d90c6 keybindings: Make event handlers take a const ClutterEvent
This avoids discarding the const qualifier.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
2023-07-14 22:23:45 +00:00
Brendan William
23b98db004 core: Never automatically switch focus in strict focus mode
With window_is_terminal gone, "strict" and "smart" focus mode have no
behavioural difference. Let's broaden the scope of strict focus mode,
such that windows never automatically focus unless they are an ancestor
to the transient.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3063>
2023-06-30 22:40:20 -07:00
Brendan William
3bd36d506b core: Remove window_is_terminal and friends
As noted in the comments of window_is_terminal, this is a hack. This
code has not been touched for the better part of a decade. App res_class
tends to differ between Wayland and X11, so it is likely that none of
these apps have been recognised as terminals under Wayland ever. Also,
there are reports that strict focus mode also does not work under X11,
likely due to changes in these terminal apps over the years resulting
in different res_class than those manually specified in here. Let's remove
this hack and change strict focus mode accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3063>
2023-06-30 22:40:16 -07: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
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
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
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
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
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
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
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
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
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
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
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
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
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)
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
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
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
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
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
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
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
Jonas Ådahl
08bdee58c9 Revert "core: Avoid setting up frames on fullscreen windows"
This caused feedback loops with old statically compiled SDL
applications. The bug is fixed in upstream SDL, but that doesn't help
when the executables have old SDL's built into them.

This reverts commit beeeea546b.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2678
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2921>
2023-03-18 18:25:39 +00:00
Carlos Garnacho
5daddf0bc7 core: Retrieve DESKTOP_AUTOSTART_ID early on startup
With the move away from GTK3, and the indirect dependency on GTK4
grown in the GNOME Shell side, we've indirectly gotten a small sneaky
behavioral change: The GTK4 library will, right on dlopen, get
DESKTOP_AUTOSTART_ID for itself and delete it from the environment.

This happens before our own X11 session management code is
initialized, which confuses the hell out of it, into thinking
initialization is actually shutdown, gnome-session does not follow
along with this request, which leaves GNOME Shell into a confused
startup state where it never calls SmcSaveYourselfDone() and grinds
startup to a halt until gnome-session decides to move things forward.

In order to fix this, get the DESKTOP_AUTOSTART_ID before we lend
control to GNOME Shell bits and GTK4 is possibly initialized, and
feed it directly to our X11 session manager bits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2906>
2023-03-18 15:40:17 +00:00
Florian Müllner
f90749916a prefs: Add get_keybinding_label() method
Commit 7e9d9c7eb9 added new API to replace GTK for accelerator
parsing.

Unfortunately there is another case in gnome-shell, where we have
to get the label from the logical binding name rather than the
modifier+keysym combination.

Add another small method to cover that use case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2899>
2023-03-06 01:57:27 +01:00
Carlos Garnacho
3ac82a58c5 core: Avoid focusing windows on map during grabs
Normally, mutter implicitly allows a window being shown to take
focus. This is normally desired, except it steals input from
GNOME Shell self. Avoid focusing the just shown window in those
situations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Carlos Garnacho
7de834b915 Revert "x11: Do not move X11 input focus during grabs"
This reverts commit a68b8e9595.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Jonas Ådahl
65ef0cb9e8 constraints: Don't apply titlebar constraint on non-drag user-op move
2d8fa26c8e ("core: Pass "frame action" grab operations as an
"unconstrained" grab op") changed the behaviour to treat non-grab
related window moving that has the "user action" flag set to still apply
the "constrain_titlebar_visible" constraint.

The fact that it wasn't applied before was relied upon by some
extensions. While it should arguably exist a better API that for such
extensions to use that have a bit more predictable behavior, until that
is so, restore the old semantics.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2891>
2023-03-04 20:31:33 +00:00
Olivier Fourdan
32e173c3ce startup-notification: Delay cursor feedback updates
A Wayland client repeatedly requesting activation of its surface using
the xdg-activation protocol would make mutter constantly update the
cursor.

To avoid needlessly updating the cursor back and forth between busy and
default, add a timeout to delay the update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
2023-03-04 09:07:44 +00:00
Carlos Garnacho
beeeea546b core: Avoid setting up frames on fullscreen windows
Ensure we preserve the fast zero-copy paths in Xwayland fullscreen
windows, instead of maybe rendering the client surface on top of the
frame surface, and providing the latter to the compositor.

To achieve this, additionally synchronize frame state when
recalculating features (e.g. after fullscreen/unfullscreen), and
account for this new condition when creating or destroying frames.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2797>
2023-03-03 20:33:18 +00:00
Carlos Garnacho
2a182b91fb core: Sync after issuing key/button passive grabs
Try to collect any possible errors in place, instead of maybe
delegating asynchronous errors to maybe another error handler.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
a7e89453a7 core: Trap errors during passive button/key grabs
These are done on the backend X11 connection, so it is unclear
what is the interplay through the borrowed global XSetErrorHandler()
that triggers issues for us here.

Anyways, better to be explicit, and use error traps the MetaBackendX11
style, in coherence with the rest of the things happening in that
display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Robert Mader
b521747d81 Remove support for window shading
It's been broken for an unknown time and was never supported on Wayland.
Thus let's remove the leftovers.

Helpful command: `rg 'shade(?!r)' --pcre2`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2884>
2023-03-03 19:17:51 +00:00
Robert Mader
92ac922519 window: Fix an if-block indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2884>
2023-03-03 19:17:51 +00:00
Jonas Ådahl
f27ca241f9 renderer/native: Move per frame KMS update to MetaFrameNative
In order to make things more and more asynchronus and to each time we
paint be an isolated event, that can be potentially be applied
individually or together with other updates, make it so that each time
we draw, we use the transient MetaFrameNative (ClutterFrame) instance to
carry a KMS update for us.

For this to work, we also need to restructure how we apply mode sets.
Previously we'd amend the same KMS update each frame during mode set,
then after the last CRTC was composited, we'd apply the update that
contained updates for all CRTC.

Now each CRTC has its own KMS update, and instead we put them in a per
device table, and whenever we finished painting, we'll merge the new
update into any existing one, and then finally once all CRTCs have been
composited, we'll apply an update that contains all the mode sets for all
relevant CRTCs on a device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
2023-03-02 01:40:16 +01:00
Jonas Dreßler
256bdba309 constraints: Remove unnecessary if-check
One of those two must be TRUE because we're already inside exactly this
condition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2873>
2023-03-01 09:48:14 +00:00
Jonas Dreßler
f68b1ff030 window: Allow can-maximize when size hints are exactly screen sized
This looks like a bug: There's no reason why windows which advertise
min-size hints that are exactly the size of the workarea should not be
allowed to maximize, so change the checks here to allow for that.

The commit message of 7f64d6b9 also makes the point that this was not
intended, as it says "larger than".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2873>
2023-03-01 09:48:14 +00:00
Carlos Garnacho
5bdc08099e compositor: Fix handling of keyboard-driven window resize
The introduction of the META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED
flag threw off some checks around keyboard-driven resize. This
was partly because there were some == checks that did not account
for that flag maybe being enabled, but also the handling
of META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN into a definite
resize direction was maybe unsetting that flag. Fix both things
at the same time.

Fixes: 2d8fa26c8e ("core: Pass "frame action" grab operations as an "unconstrained" grab op")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2629
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2871>
2023-02-27 18:28:44 +00:00
Jonas Ådahl
bac7b3f4e6 window: Add missing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2867>
2023-02-23 22:26:02 +01:00
Florian Müllner
e74573e165 window: Add raise_and_make_recent() method
After !2489, the active workspace's MRU list is now used to pick
the next focus window instead of the stack order.

This list is currently only updated on focus, which can lead to
surprising behavior when closing a window after activating its
ShellApp in the shell.

That is because raising a window (as part of shell_app_activate())
will only change the stacking order, so when closing the active
app window, the focus will switch to whatever had focus before the
app was activated, not the app's next window.

In order to allow gnome-shell to address this, add a new
raise_and_make_recent() method that also adjust the MRU order.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2866>
2023-02-23 20:40:58 +00:00
Florian Müllner
79f5059df7 window: Fix compiler warning
Commit b5d873a8ac changed the flag parameter type in the
function definition, but not in the declaration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2865>
2023-02-23 20:33:49 +01:00
msizanoen1
dbf3584a9b window/xwayland: Handle _NET_WM_FULLSCREEN_MONITORS for XRandR emulation
Handle a specific case of _NET_WM_FULLSCREEN_MONITORS used by GLFW to
make XRandR emulation work with it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2725>
2023-02-20 16:55:36 +00:00
Jonas Ådahl
01353fdc08 profiler: Set 'persistent' state when persistent
This makes sure calling Start() and Stop() doesn't work, since we're
always recording.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2846>
2023-02-14 20:53:17 +00:00
Jonas Ådahl
f5176101cd window: Recalculate attachedness for Wayland window parent changes
When modal dialogs are attached, and we set the parent/transient-for
after setting the modal type, the attachedness isn't updated. This is
(apparently) not the case for X11 windows, as they go through a
unmanage/manage dance avoiding the issue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2810>
2023-02-13 15:34:24 +00:00
Jonas Ådahl
d870b08580 window: Simplify transient_for assignment
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2810>
2023-02-13 15:34:24 +00:00
Jonas Ådahl
74fcdb9a62 Introduce the 'service channel' D-Bus service
The service channel D-Bus interface aims to be a "back door" for
services that needs special casing in Mutter, e.g. have custom private
protocols only meant to be used by that particular service.

There are currently no special casing implemented; only the basic
service channel infrastructure is added. There is a single method on the
interface, that is meant to eventually be used by
xdg-desktop-portal-gnome to open a Wayland connection with a private
protocol needed for the portal backend's rather special window
management needs.

The service channel Wayland client works by allowing one instance of
each "type", where each time needs to be defined to work in parallel. If
a new service client connects, the old one will be disconnected.

MetaWaylandClient's are used to manage the service clients, and are
assigned the service client type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2810>
2023-02-13 15:34:24 +00:00
Carlos Garnacho
a68b8e9595 x11: Do not move X11 input focus during grabs
On X11, the stage itself is backed by an XWindow, and moving the
input focus elsewhere will bypass any Clutter-level grabs.

This effectively allows newly opened windows to steal the focus
from gnome-shell itself, which is clearly undesirable. To prevent
that, only allow moving the X11 focus to a Window when no grab is
in place, just like commit 50e89e376 did for the stage focus.

But particularly the updating of x11_display->focus_xwindow is not
prevented. Since it's more consistent to the MetaDisplay/MetaX11Display
dual focus tracking and across Wayland/X11 backends, ensure the X11
input focus is actually set on the last focus Window after the
grabs are gone and windows became interactable again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2832>
2023-02-13 12:45:37 +00:00
Carlos Garnacho
df16cb9fb7 Revert "display: Do not move X11 input focus during grabs"
This patch unfortunately results in situations where it is intended
that the focus change happens while a grab is present (e.g. Alt+tab
popup), resulting in confused focus state.

This commit is reverted in order to try a similar approach at a
different level.

This reverts commit 7531669b4f.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2832>
2023-02-13 12:45:37 +00:00
Carlos Garnacho
caf68a6563 x11: Handle accounting of ignored serials in X11 code
Move this out of MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Carlos Garnacho
67a69709b9 core: Make "adding ignored serials" private API
This sounds unnecessary from shell code, and possibly even harmful.
Make this API private and move it into the X11 parts where it belongs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Carlos Garnacho
3356823ca2 x11: Reset ignored crossing serials from X11 code
They are only ever set and ignored from X11 code, we can also move
this bit of sloppy/mouse mode handling to the X11 parts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Sebastian Wick
e38002b206 workspace: Do not raise default focus window with raise-on-click
This avoids raising a window when switching input methods or returning
from the overview when it is unwanted with raise-on-click disabled.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2545
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2742>
2023-02-03 17:09:12 +00:00
Jonas Dreßler
d374feb55f events: Make MetaGestureTracker work with the action event delivery
ClutterActions now no longer receive their events via
clutter_actor_event(), instead they get special treatment by the stage
now. Make the MetaGestureTracker work with this and stop emitting events
directly to Clutter via clutter_actor_event(), but instead let them get
through to Clutter (but still not to Wayland).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2342>
2023-02-03 12:10:22 +00:00
Sebastian Wick
ec58e74cc5 window: Keep proportional position in meta_window_move_between_rects
The previous logic tried to keep the position of the top left corner of
the window relative to the top left corner of the monitor. This allowed
the window to move out of the target monitor. This change keeps the
proportions of the distance between the window and the monitor borders
instead if possible. Otherwise it keeps the relative position of the
center of the window clamped to [0,1] to make sure the window lands on
the right output.

This also slightly changes what monitor is considered to be on: the
monitor which contains the center of the window and, if the center is on
no monitor, the monitor wich overlaps the most with the window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2591>
2023-02-01 22:58:34 +00:00
Jonas Ådahl
e8e8a63054 core/delete: Avoid warnings when there is no close dialog
The "ensure dialog" function didn't ensure there was a dialog created,
so the function was renamed. The callers was updated to handle the
dialog not being created.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2807>
2023-01-30 13:17:19 +00:00
Carlos Garnacho
48dc8073de core: Drop META_GRAB_OP_GET_BASE_TYPE define
This was only left used to know whether a MetaGrabOp was about
a window drag operation, but all grab ops are about windows now.
This is redundant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
c6d23f67f0 compositor: Move tiling preview management to MetaWindowDrag
And release MetaDisplay from handling this management. Window tiling
previews are only triggered from window drags, and are implicitly tied
to them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
f04d84de65 compositor: Move edge resistance data to MetaWindowDrag
At least indirectly, this is set as object qdata while the
window drag is ongoing, and reset/reconstructed if needed.

Consequently, this edge data does not need to be stored in
the MetaDisplay struct anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
675d0df09b compositor: Make cleaning cached edges go through MetaWindowDrag
Even though the data is still stored in the display, add a "high
level" meta_window_drag_update_edges() call, so that the cached
edges may be updated while a window drag operation is ongoing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
36bda45888 core: Move edge-resistance handling to src/compositor
This is now something that is mainly handled from the compositor
side, so it makes sense to move it there. Following commits will
cut all ties with src/core.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
e88891a1d5 core: Cleanup header includes
There's some X11 includes we no longer need in these files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
d687e5634d core: Pass device/sequence on meta_window_begin_grab_op()
This is a public API change. Add device/sequence parameters to this
operation, so that window dragging and resizing can stick to one
set of pointing events of them all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
f2ff317206 core: Drop unnecessary code
This is already handled by the meta_compositor_grab_begin/end
calls, for the Wayland cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
b2ebe9c262 core: Move accounting of "shaken_loose" to MetaWindowDrag
It's entirely accessed from there (besides reset and initialization),
so can be completely taken there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
39f1b6dca0 core: Delete now unused code
Since MetaWindowDrag took a lot of this code to handle window drags
internally with less interactions with the rest of the stack, this
code in display/window/keybindings is unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
bec8a5860a core,wayland,compositor,x11: Migrate to MetaWindowDrag
Flip the switch in using MetaWindowDrag, leaving display grab
ops and a bunch other code unused. Some places checked the grab op
and/or window in complex ways, others just checked for grab existence
and should now look for clutter ones, and others already were already
doing this in addition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
14006adf6f compositor: Handle pointing events in window drags
This code is largely copied from src/core/window.c, taking care
of pointer/touch interaction during window drag operations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
49cc761aaf core: Drop unused includes
This file does not do anything directly related to X11 inside it,
these headers are no longer necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
58e88fc8db core: Simplify grab tracking
We only allow partial grabs in the case of a keyboard-type MetaGrabOp
happening while the pointer cannot be grabbed. In that case, it's not
a big stretch to unconditionally ungrab the pointer device at the time
of undoing the grab, as it will be always ineffective (not even implicit
grabs on frame windows can happen now, inside Mutter).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
452e4f4801 core: Drop MetaX11Display ungrab before MetaDisplay grabs
This is no longer necessary, since the SSD frames are no longer
part of Mutter process, so it is not the MetaX11Display connection
which holds the implicit grab when a mouse button is pressed over
a window frame (say, to start a drag).

As the SSD frames client communicates the same way than CSD windows
for window operations, it is also expected to undo its implicit
grab before requesting a window move/resize operation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
b8ab24d816 core: Drop MetaEventRoute
This is no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
ee94b07159 core: Move away from MetaEventRoute
We can check MetaGrabOp for the same effect, just do that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
12773cf8e2 window: Drop frame_action argument from meta_window_begin_grab_op()
The final effect of this boolean can now be expressed through the
META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED flag to MetaGrabOp. Use that
in the relevant places, and drop the argument.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
f62200a17b core: Drop unused arguments to meta_display_grab_op()
Now that it is called from a single place, there's a few arguments
that are unnecessary:

- button and modifiers are unused
- already_grabbed was originally added to handle grab transitions between
  window menus (GtkMenus, back in the day) with display grabs. It's no
  longer necessary now
- frame_action can be passed through the META_GRAB_OP_WINDOW_FLAG UNCONSTRAINED
  flag

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
57e56ee866 core: Make MetaDisplay grab API private
Leave meta_window_begin_grab_op() as the only public API to initiate
a display grab. There's no longer grab operations that don't attain
windows, and ending these grabs usually happen through user interaction
when the right circumstances happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
84ed992a18 core: Port to meta_window_begin_grab_op()
There is no longer reason to call meta_display_begin_grab_op() except
for window grab operations, and meta_window_begin_grab_op() is a
perfectly fine entry point for all window grab operations.

Move away from meta_display_begin_grab_op().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
5e4d69c3a8 core: Make meta_window_begin_grab_op() more generic
Currently, it is thought out to be called with META_GRAB_OP_KEYBOARD*
grab op parameters. Make it more generic so it can also be called for
pointer operations (avoiding pointer warping in that situation).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
43081fc8bd core: Simplify handling of ungrabbing condition
Unlike the comment suggests, this piece of event handling manages
the ungrabbing of a window on button press in the following 2
conditions:

- If a keyboard grab operation was triggered, the window does
  additionally follow the pointer, and first button press ends
  the grab.

- If a button-press grab is ongoing on the window, but more buttons
  are pressed.

We can simplify this to just happen every time a button press event
is received while a window grab op is ongoing. The only case where
this might diverge a bit is same button presses from different
pointer devices, and it's not a big stretch to also undo the grab
in that situation.

This also happens to make the "button" argument in
meta_display_begin_grab_op() completely unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
2d8fa26c8e core: Pass "frame action" grab operations as an "unconstrained" grab op
The frame_action boolean is only used by constraints.c code, in order to
determine whether a moving window should be able to move past the top
bar or not.

We can avoid the special casing by passing this information as a
META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED flag passed with the grab op.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
589ec26b04 core: Drop META_EVENT_ROUTE_WAYLAND_POPUP
This is now unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
a91feeb5df core: Drop check on META_EVENT_ROUTE_WAYLAND_POPUP grabs
Query the MetaWaylandCompositor directly for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
cca531339d core: Drop META_GRAB_OP_WAYLAND_POPUP
This is no longer used, these being fully handled on the wayland
side.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
1198fe700a core: Use is_grabbed() method to find existing grabs
The whole reason for META_GRAB_OP_WAYLAND_POPUP to exist is to
avoid windows from being activatable/movable/resizable when a
grabbing xdg_popup is active.

Use the meta_display_is_grabbed() method which can tell this
from existing MetaWaylandCompositor grabs, so that this remains
true after dropping META_GRAB_OP_WAYLAND_POPUP.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
1e990ad823 core: Change meta_display_get_grab_op() to has_grab()
Make this public API check just return a boolean about whether
there is an existing grab, instead of exposing MetaGrabOp.

It is desirable to avoid exposing details like
META_GRAB_OP_WAYLAND_POPUP, so that MetaDisplay and wayland
grabs can port to ClutterGrab at their own pace, but also
this further information is unused.

This is likely to be temporary API anyways, after both
MetaDisplay and wayland grabs port to Clutter, it will be
possible to check the ClutterStage for all of them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
1e289e8d81 keybindings: Minor refactor
Rewrite this codepath so it handles the grab ops that it cares
about, and ignores the rest. This way the code works despite
possible future modifications to MetaGrabOp (e.g.
META_GRAB_OP_WAYLAND_POPUP removal).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
a7b8f06196 core: Move grab_op check for handling window events from passive grabs
This piece of event handling only applies on windows receiving events while
the display is ungrabbed (i.e. for raising it, or beginning a move/resize
operation).

Move the checks on the current grab operation outside of window.c and into
events.c, so all checks about the current grab operation move closer to the
main event handler.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
a5bd0c39fe core: Drop META_EVENT_ROUTE_FRAME_BUTTON
With META_GRAB_OP_FRAME_BUTTON gone, this is no longer used. Drop
this event route.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
970ef35a62 core: Drop META_GRAB_OP_FRAME_BUTTON
This is no longer used, since frames and their buttons are no longer
handled by Mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Florian Müllner
7531669b4f display: Do not move X11 input focus during grabs
On X11, the stage itself is backed by an XWindow, and moving the
input focus elsewhere will bypass any Clutter-level grabs.

This effectively allows newly opened windows to steal the focus
from gnome-shell itself, which is clearly undesirable. To prevent
that, only move the X11 focus when no grab is in place, just like
commit 50e89e376 did for the stage focus.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2776>
2023-01-25 13:31:49 +00:00
Jonas Ådahl
11d35f99be util: Make meta_topic() log using the debug level in tests
Some tests expect warnings to be logged, and handle that using
g_test_expect_message(). However, if debug topics are enabled, this
causes g_logv() to expect expected messages to also contain entries with
the debug level 'message' or higher to be listed in the expected message
list. Since meta_topic() always logged using g_message(), enabling debug
topics caused any test that used g_test_expect_message() and had debug
logging somewhere along the code path to fail.

Fix this by changing the log level of meta_topic() to 'debug' if we're
in a test. This doesn't mean they won't be visible, they still will
since debug log entries are printed by default during testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2800>
2023-01-24 13:09:42 +00:00
Carlos Garnacho
4752a8055c core: Update frame opaque region from _NET_WM_OPAQUE_REGION property
Both read this property on frame creation, and listen to property changed
events about it in the frame window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
82b2b76882 core: Add infrastructure to keep window frames' opaque regions
These frames client will use a visual with alpha information, and
report the opaque frame shapes through the _NET_WM_OPAQUE_REGION
window property. We can use this information in the Mutter side
for accurate opaque shapes, despite X11 windows with frames now
being seen as possibly transparent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
909eaa117d core: Delete _MUTTER_NEEDS_FRAME property when destroying frame
If the window is unmapped or otherwise unmanaged while still existing,
we would fail to let the frames client follow up in destroying the
frame for the window.

Delete the _MUTTER_NEEDS_FRAME property, so that the frames client
can react to meta_window_destroy_frame(), this avoids stale invisible
frame windows for clients that simply unmap windows to reuse them
later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2791>
2023-01-18 15:35:58 +01:00
Carlos Garnacho
78a3631d15 core: Wrap XMapWindow() request with error traps
Other X11 calls happening during the process of assigning a frame
to a window are already wrapped with error traps, wrap this as well
to avoid possible X11 errors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:07:32 +01:00
Carlos Garnacho
2019536f3c core: Wrap an extra X11 call with error trap
This XChangeWindowAttributes call was never surrounded by an error trap
and was not really expected to fail with BadWindow since the frame window
would be owned by Mutter itself.

This however is no longer true, and we might be getting a BadWindow from
the frame window given the right timing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:00:52 +01:00
Bilal Elmoussaoui
6e818c8c38 build: Allow disabling xwayland
Mostly moving things around to allow a build without xwayland.
Note that more work might still be needed once the x11 build option
lands as that would allow us to have a proper xwayland only build
without the x server part.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2399>
2023-01-03 20:45:04 +00:00
Bilal Elmoussaoui
d1d2496c99 core: Replace MetaVirtualModifier
By making all the types uses ClutterModifierType instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
7e9d9c7eb9 core: Add meta_accelerator_name
As we have switched to using meta_parse_accelerator in PadActionMapper.
We need a function that does the other direction for the client side
usage. See
https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/f1d50a4a/js/ui/padOsd.js#L107

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
abef37f5ee core: Add a copy of GDK_PRIORITY_EVENTS
Quoting Carlos:
The META_PRIORITY_EVENTS ± 1 happening below are in order to set these idles
and timeouts in a priority that is relative to the literal GDK event priority,
making those diverge is a likely way to sneakily break things.
But that's unlikely to happen, and decoupling mutter from GTK further
should make it moot, so perhaps it's alright after all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
809eaf6e91 core: Replace gtk_accelerator_parse usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
c710f14cc5 core: Replace gtk_get_default_locale usage
Clutter has an API to get the text direction but used to depend
on gtk3's translation domain. In order to avoid broken i18n
in case gtk3 is not installed, move the transtalable string to
clutter itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
64ee8d02f7 core: Add a in-tree copy of GtkBorder
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
fb4161853f cleanup: Make GDK dependency specific to X11
This way, the dependencies on GTK/GDK could be completely dropped if
built with Wayland only.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:09:03 +01:00
Robert Mader
7441d4f8e1 core/selection: Set display on creation
Otherwise the getter always returns `NULL`.

Fixes dd2beae6a8

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2768>
2022-12-17 16:47:46 +01:00
Jonas Ådahl
471d23ba43 Remove meta_get_display()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
d7f5477103 compositor: Enable introspection
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
4b3cab2cca compositor: Don't make internal API public
Things like meta_compositor_destroy() and meta_compositor_add_window()
isn't intended to be used externally, and if they was, things would
probably fall apart rather quickly.

MetaCompositor also isn't introspected, meaning things that technically
belong to the compositing parts isn't easily available via some object,
but much take detours via other objects like MetaDisplay.

So move the API intended for internal usage to compositor-private.h, and
leave API that is meant to be expose in the public compositor.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
f8376a43d3 Always queue MetaLater via compositor instance
The "later" API is used to queue actions in relation to compositing,
thus is owned by the MetaCompositor instance. Make users of this
functionality get MetaLaters instance from the compositor, and stop
using the global meta_later() API.

display: Use non-singleton MetaLater API

tests: Use non-singleton MetaLater API

meta/common: Make docs refer to context aware MetaLater API

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
342c94076d display: Destroy unmanaged compositor a bit later
This allows for things that want to get some state or manager objects
(MetaLaters to be specific) a bit later in the tear down procedures.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
e5908f5752 startup-notification/x11: Let the libsn user handle API annoyances
The API has no concept of user data, and requires the user to some how
get an instance without context, i.e. via static globals. Limit this to
the file where this is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
2731f0cda4 wayland: Setup and use ownership chains
As elsewhere, make sure objects that need to have a ownership up to the
context, and use this ownership chain to find relevant components, such
as the backend or the Wayland compositor object instance.

wayland/data-device: Hook up data devices to seats

They are tied to a seat - make that connection in struct fields too, so
that related objects can get to the context via it.

wayland: Don't get Wayland compositor via singleton getter

This means via the ownership chain or equivalent.

xwayland: Hook up manager to Wayland compositor

Same applies to the drag-n-drop struct.

xwayland: Make X11 event handling compositor instance aware

This avoids finding it via singletons in the callee.

xwayland: Don't get Wayland compositor from singleton

xwayland: Pass manager when handling dnd event

window/xwayland: Don't get Wayland compositor from singleton

xwayland/grab-keyboard: Don't get backend from singleton

xwayland: Don't get backend from singleton

wayland: Always get the backend from the context

This means traveling up the ownership chain or equivalent when
necessary.

wayland: Hook up data devices, offers and sources to the compositor

This allows tying them to a context without going through any
singletons.

wayland: Don't get display from singleton

xwayland: Don't get display from singleton

tablet: Don't get display from singleton

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
dd2beae6a8 core: Setup and use ownership chains
As with other parts, make objects have the ability to walk up the
ownership chain to the context, to get things like the Wayland
compositor or backend instances.

Contains these squashed commits:

display: Don't get backend from singleton

window: Don't get backend from singleton

keybindings: Don't get backend from singleton

workspace: Don't get backend from singleton

display: Don't get Wayland compositor from singleton

selection: Add display getter

context/main: Get backend directly from the context

clipboard-manager: Don't get display from singleton

stack-tracker: Don't use singleton MetaLater API

startup-notification: Hook up sequences and activations to display

This allows using context aware API directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
7e974ba6cc backend: Get 'is-stage-views-scaled' from backend
It did, but used the old backend singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 13:52:51 +00:00
Jonas Ådahl
c45ab10c0e Make VT switch API explicitly part of the native backend
It already was, more or less, but make it a bit more in your face.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 13:52:51 +00:00
Jonas Ådahl
e709853ad3 workspace: Sanity check input to activate*()
The passed argument should be a workspace, and it should not have been
removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2707>
2022-12-17 13:25:13 +00:00
Jonas Ådahl
9d9fcc0bb1 workspace: Cleanup workspace switch sound function
Expand aggressively abbreviated variable names; some style cleanups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2707>
2022-12-17 13:25:13 +00:00
Jonas Ådahl
8a64746ce4 workspace: Warn instead of abort on incorrect API usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2707>
2022-12-17 13:25:13 +00:00
Sebastian Wick
0d69fabbe6 window: Update mru list for every workspace the window is on
If the window is on all workspaces we should update the mru list for all
those workspaces, otherwise the default focus window for a specific
workspace can be unexpected.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2548
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2747>
2022-12-17 10:39:02 +00:00
Sebastian Wick
058981dc12 workspace: Focus the default window only if no window is focused
This might happen when the workspace is not switched and
focus_default_window is called or when 'workspace on primary display
only' is enabled, a secondary display exists and the workspace is
switched.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2747>
2022-12-17 10:39:02 +00:00
Carlos Garnacho
753c768578 core: Remove redundant ifdef
This code is already surrounded by the same ifdef.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2754>
2022-12-16 20:57:11 +00:00