1
0
Fork 0
Commit graph

2720 commits

Author SHA1 Message Date
Carlos Garnacho
92feea3033 ui: Excise old frames UI
This is no longer used, in favor of the standalone frames client.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1077
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
f2237fa0c8 x11: Add frame synchronization to window frames
There's two meanings of "frame" there! Since SSD frames are now
rendered by an external client, and there are no actual mechanism
that ensures the frame did already get painted when the client did
respond to its NET_WM_FRAME_SYNC_REQUEST request, there may be
artifacts when resizing windows.

In order to get always the best visual result, we should actually
synchronize rendering with both the client window and the window
frame window.

This commit adds these mechanisms, so a sync alarm update is
expected on both windows until further resizes are allowed, this
ensures window and frame stay in sync, even after moving rendering
elsewhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
bbd988cbc5 core: Shuffle function to get description string from a frame
This will remain used (and mildly useful), so move it outside of src/ui.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
3994297429 x11: Integrate frames client into Mutter
Replace the in-process implementation of frames with the external
frames client.

When a client window is created and managed by Mutter, Mutter will
determine whether it is a window that requires decorations and
hint the creation of a frame for it by setting the _MUTTER_NEEDS_FRAME
property on the client window.

After the frames client created a window that has the _MUTTER_FRAME_FOR
property, Mutter will proceed to reparent the client window on the
frame window, and show them as a single unit.

Rendering and event handling on the frame window will be performed by
the external client, Mutter is still responsible for everything else,
namely resizing client and frame window in synchronization, and
managing updates on the MetaWindowActor.

In order to let the frame be managed by the external client, Mutter
needs to change the way some properties are forwarded to the client
and/or frame windows. Some properties are necessary to keep propagating
to the client window only, some others need to happen on the frame
window now, and some others needs to be propagated on both so they
are synchronized about the behavior.

Also, some events that were previously totally unexpected in frame
windows are now susceptible to happen, so must be allowed now.

MetaFrame in src/core/frame.c now acts as the wrapper of foreign
windows created by the frames client, from the Mutter side. Location,
size, and lifetime are still largely in control of Mutter, some
details like visible/invisible borders are obtained from the client
instead (through the _MUTTER_FRAME_EXTENTS and _GTK_FRAME_EXTENTS
properties, respectively).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
740b8e8cce x11: Replace MetaWindow sync request handling with MetaSyncCounter
Put the helper to use, in order to lift MetaWindow itself from this
accounting. As a bonus, the data itself now moved to the MetaWindowX11
private struct, since this may only happen with X11 windows (or its
Xwayland subclass).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:52 +00:00
Carlos Garnacho
dae981cc5c core: Avoid notifying the stack manager of frame reparents during unmanaging
This may result in a view of the stack in MetaStackManager that does not correspond
to reality, since the window is already being unmanaged, there is no point either in
notifying the stack manager about it.

This slight divergence with reality in the MetaStackManager may produce a non-accurate
view if querying its state has to go through the predicted branches. Later synchronization
with the X11 stack may even this out, but the result really depends on when it is asked.
Fixes some intermittent failures in the stacking/closed-transient-only-take-focus-parents
unit test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:52 +00:00
Carlos Garnacho
a60863838e core: Synchronize client window mapped state before showing window
The meta_window_show() method internally relies on window->mapped being
up-to-date, or attempting to focus it may fail since the window is not
mapped yet, resulting on the window being mapped, but not focused as
it would be expected.

This is moot so far, since windows with frames are created sort-of
synchronously and showing them will result in the focus attempt happening
when the window is already mapped, but things will break when this
becomes an asynchronous step.

Ensure to synchronize client state before showing, so any attempts to
focus the window are able to succeed despite the initial state when
calling meta_window_update_visibility().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:52 +00:00
Jonas Ådahl
c1982218e1 context: Add 'started' and 'prepare-shutdown' signals
The backend is changed to listen to 'prepare-shutdown' and forward, but
the 'started' signal will be used later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2716>
2022-11-25 10:26:52 +00:00
Jonas Ådahl
ec82b6e869 keybindings: Use proper enum type in MetaKeyHandler
This simplifies inspecting runtime state using gdb.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2714>
2022-11-24 12:25:29 +00:00
Jonas Dreßler
1816f21e21 window: Avoid focusing during workspace changes
We can land inside meta_window_focus() in the middle of changing the
window workspace, because some signal handler of MetaWorkspace's
"window-removed" signal triggers a focus. This can cause a crash in
`g_assert (link)` when updating the MRU list because we still think
we're on the old workspace when actually we are already removed from
this workspaces MRU list.

To avoid crashes like this, bail out of meta_window_focus() when we're
in the middle of a workspace change.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5368

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2691>
2022-11-24 12:09:23 +00:00
Jonas Dreßler
098c627f11 window: Move all single-bit booleans to the end of the struct
It's a bad idea to have data like this in the middle of a struct, as it
will easily cause everything behind it to be badly aligned and thus
increase memory access times.

So move all those bitfield booleans to the end of the struct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2691>
2022-11-24 12:09:23 +00:00
Bilal Elmoussaoui
74bb480753 sound player: Don't unref undefined fields
If the sound player feature is disabled, none of those fields are
instantiated which causes the crash reported in #2451

Also switch to using g_clear_pointer while we are at it

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2706>
2022-11-23 10:37:19 +01:00
Bilal Elmoussaoui
7bf07d2980 core/window: Implement GInitable
Currently, we will notify the display about a new window being created
during the constructed phase of the GObject. During this time,
property-change notifications are frozen by GObject, so we'll emit a few
::notify signals only after the window-created signal, although
the actual property change happened before that.

This caused confusion in gnome-shell code where a notify::skip-taskbar =
true emission was seen when the property already was true inside a
window-created handler before.

In order to fix that that, we notify the window creation
post-construction
of the GObject on GInitable.init vfunc

Details
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6119#note_1598983
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6119

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2703>
2022-11-22 11:29:38 +01:00
Jonas Ådahl
425e80adc2 display: Freeze stack when closing X11 display
If two X11 windows were the last two, we'd remove them from the stack
while unmanaging them. That'd hit an assert in
meta_stack_tracker_restack_managed(), resulting in the following crash
when Xwayland exited unexpectedly with two or more X11 windows being the
only windows on the stack:

  #1  g_assertion_message() at ../glib/gtestutils.c:3256
  #2  g_assertion_message_expr() at ../glib/gtestutils.c:3282
  #3  meta_stack_tracker_restack_managed() at ../src/core/stack-tracker.c:1210
  #4  on_stack_changed() at ../src/core/stack.c:142
  #5  _g_closure_invoke_va() at ../gobject/gclosure.c:895
  #6  g_signal_emit_valist() at ../gobject/gsignal.c:3456
  #7  g_signal_emit() at ../gobject/gsignal.c:3606
  #8 meta_stack_changed() at ../src/core/stack.c:265
  #9 meta_stack_remove() at ../src/core/stack.c:324
 #10 meta_window_unmanage() at ../src/core/window.c:1542
 #11 meta_x11_display_unmanage_windows() at ../src/x11/meta-x11-display.c:111
 #12 meta_x11_display_dispose() at ../src/x11/meta-x11-display.c:141
 #13 g_object_run_dispose() at ../gobject/gobject.c:1448
 #14 meta_display_shutdown_x11() at ../src/core/display.c:831

The added test specifically checks that this scenario is handled
gracefully.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2143637
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2704>
2022-11-21 16:30:06 +00:00
Bilal Elmoussaoui
6b77532a23 window: Move surface property to it subclasses
As we have specific window types per display server,
having it in the parent class makes building without wayland
harder to achieve

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
2022-11-17 11:30:56 +00:00
Bilal Elmoussaoui
c3a01e4e18 core: Untangle meta_window_shared_new
The constructor used to take Wayland/X11 specific types which makes
building without Wayland/X11 not possible.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
2022-11-17 11:30:56 +00:00
John Wudrick
d889aad7cf window: Update ongoing edge resistance flags with input
Fix a recent regression where edge resistance flags where no
longer updated during the move/resize operation.

Fixes: bd6b14a843 (window: Throttle window move grab updates)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2492
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2687>
2022-11-08 05:01:49 +00:00
Jonas Dreßler
28982ade94 gesture-tracker: Never reject sequences in Wayland sessions
In constrast to x11, Wayland has sane handling for touch events and
allows the compositor to handle a touch event while the clients are
already seeing it. This means we don't need the REJECTED state on
Wayland, since we can also grab sequences after the client has seen
them.

So disallow moving sequences to the REJECTED state on Wayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2508>
2022-11-04 19:09:56 +00:00
Jonas Dreßler
fc1b4ae149 gesture-tracker: Only track actions which are actually enabled
Tracking disabled actions doesn't make sense, these will never recognize
anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2508>
2022-11-04 19:09:56 +00:00
Jonas Ådahl
1efb93e145 profiler: Allow enable tracing via env var
This is helpful to e.g. trace e.g. launching.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
2022-11-01 21:04:21 +00:00
Jonas Ådahl
ca2057da9a Move MetaProfiler from the backend to core
It's not really a backend thing, and we'll want to profile e.g. loading
the backend too, so create it very early and destroy it very late and
let MetaContextMain own it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
2022-11-01 21:04:21 +00:00
Jonas Ådahl
bd6b14a843 window: Throttle window move grab updates
There is no point in moving a window at the input event refresh rate,
when the end result will only be used once per update, thus, throttle
the move done during grabs to once per stage update.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2233
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2652>
2022-10-18 18:12:03 +00:00
Jonas Ådahl
11a50fffa2 window: Throttle resize-grab updates to stage updates
With high frequency mouse devices, we would send very many configure
events per each update cycle, which had the end result that some clients
constantly re-allocating and redrawing their buffers far too often, if
they did this in direct response to xdg_toplevel configure events.

Lets throttle the interactive resize updates to stage updates, to avoid
having these clients doing the excessive buffer reallocation.

This also removes some old legacy X11 client resize throttling, that
throttled a bit arbitrarily on 25 resizes a second; it is probably
enough to throttle on stage updates for these clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2652>
2022-10-18 18:12:03 +00:00
Jonas Ådahl
a331d4e45a window: Type check some wm functions
These might get called from JS, so avoid crashing on bogus calls.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5952
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2661>
2022-10-17 11:41:55 +00:00
Jonas Ådahl
47c8063b30 window/wayland: Calculate position also for acked fullscreen configs
An acked fullscreen window also need to have its position updated in
response to a configure ack, so that it's moved to the right position
(e.g. correct monitor).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
f4645b0a37 window: Make the caller decide when to constrain
There were some magic conditions that decided when
meta_window_constrain() was to be called or not. Reasoning about and
changing these conditions were complicated, and in practice the caller
knows when constraining should be done. Lets change things by adding a
'constrain' flag to the move-resize flags that makes this clearer. This
way we can, if needed, have better control of when a window is
constrained or not without leaking that logic into the generic
to-constrain-or-not expression.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Sebastian Wick
ed7a9af62a tests/stacking: Add workspace management commands
New commands to set the number of workspaces, activate a workspace, with
and without focus, move windows to specific workspaces, and check the
stacking on a specific workspace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
b4b9a7c90f core: Move remaining default focus window handling to workspace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
3a96ef023b core: Focus on most recently focused window when switching workspaces
When switching workspaces we previously focused on whatever window is on
top of the stack. If a window is marked as "always on top" then it would
always receive focus when switching workspaces.

Fixes #2240
Fixes gnome-shell#5162
Fixes #178
Fixes #678

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
deae8aa7b1 core/window: Update workspace MRU list earlier
We want to use the workspace MRU list to decide the default focus but
Globally Active Input clients don't call
meta_window_set_focused_internal and therefore don't update the MRU
list. Move the update to meta_window_focus instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Jonas Ådahl
a9740074ca util: Remove left-over declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Daniel van Vugt
a1873e0c4f core/events: Don't update the cursor renderer on motion under X11
Doing so was unnecessary and seemed to cause feedback to Xorg resulting
in heavy stuttering and random freezes.

We do however keep the call to `meta_cursor_tracker_invalidate_position`
so as to not undo the intention of 9bdf4b35.

Suggested by Carlos Garnacho.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5861 and
       https://launchpad.net/bugs/1989582

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2625>
2022-09-15 11:59:09 +00:00
Simon McVittie
4bc5833144 Consistently pass timestamp as uint64 when creating MetaStartupSequence
Passing the wrong type to a varargs function can cause a mismatch
between marshalling and unmarshalling on the stack, particularly on
32-bit architectures. This results in a build-time test failure.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2065
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2182>
2022-09-02 15:21:27 +00:00
Alessandro Bono
33dc8ca187 window: Notify about size-change when changing monitor
When moving to another monitor the window size may change in some
cases. While unconditionally notifying a size change is not always
correct, it animates the window when moved to another monitor in
GNOME Shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2558>
2022-09-02 13:12:09 +00:00
Bilal Elmoussaoui
02110976dc workspace: Mark a string as translatable
This also replaces the wording as a desktop is no longer used to refer
to a workspace

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2375>
2022-09-02 08:04:31 +00:00
Bilal Elmoussaoui
7902fa3f9f core: Make sound player feature optional
Mutter can play sounds in some contexts and also provides an API
for libmutter users to do so using libcanberra internally.

In some specific use cases of Mutter, we would like to not depend
on libcanberra and not have any sound playing feature by default.

The changes keeps the sound player API but make it no-op if the
sound_player feature is disabled to not make it possible to break
a gnome-shell build.

See https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2270
for relevant discussion

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2375>
2022-09-02 08:04:31 +00:00
Jonas Ådahl
ccb6a7e84f monitor: Allow vendor/product/serial to return NULL
Same applies to MetaOutput. The reason for this is to make it possible
to more reliably know when there was EDID telling us about these
details. This will be used for colord integration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
b6aea1318d util: Add 'color' debug topic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Dreßler
84396baafb stage: Mark stage as active on wayland when it has key-focus
The "activate" and "deactivate" signals on ClutterStage are used by
Cally to track the key-focus when the user is interacting with shell UI.
key-focus only gets tracked while the stage is activated.

Wayland has no concept of the stage receiving focus or not, so right now
the activation state is bound to whether there's a focus_window in
meta_display_sync_wayland_input_focus(). Since display->focus_window is
set pretty much all the time, this effectively binds activation state to
whether the stage holds a grab or not. This is almost good enough, but
it misses cases where key-focus is on the stage without a grab, for
example when keyboard-navigating the panel after using Ctrl+Alt+Tab.

It seems to make more sense to bind the activation state to whether
key-focus is set to an actor or to NULL, so let's do that instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2329>
2022-08-24 10:00:22 +00:00
Jonas Ådahl
4ed9653757 window: Add monitor finder using stored IDs
This will be used to find new monitors on e.g. "winsys ID" of previous
monitors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
cf848c577e window: Get backend from context when updating monitors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
24965a78da window: Make monitor from rect finder helper more clearly named
The function finds a suitable logical monitor given the window
rectangle; this wasn't all that clear from the name
"calculate_main_logical_monitor".

This is in preparation for finding a new logical monitor using things
other than the geometry of the window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
0debb24e12 barriers: Make barriers fully part of the backend
Prior to this commit, barriers were created with a MetaDisplay pointer,
despite being entities related and owned by the backend. In the X11
case, it was also not hooked up to the backend X11 connection, but the
clutter one, meaning for example that the logic was active (but dormant)
also for the Xwayland connection.

Fix this by moving X11 barrier management and event processing fully to
the backend. Also replace passing a display pointer with passing a
backend pointer. Keep the display pointer around for a release, but mark
it as deprecated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2442>
2022-07-26 20:27:24 +00:00
Robert Mader
2ade26ebf8 boxes: Swap 90 and 270 degree transforms in meta_rectangle_transform()
`meta_rectangle_transform()` is used in the stack to *compensate* for a
`MetaMonitorTransform` applied to a output, not to apply it again.
Change the function accordingly.

Context:
Experimenting with direct scanout on offscreen-rotated outputs revealed
that the 90/270 degree cases were actually interchanged.
Further digging revealed that we use `meta_rectangle_transform()` with
those values swapped in every single case, papering over the issue.

Either a unintuitive and unexplained `meta_monitor_transform_invert()`
was added, in which case "flipped" values would be wrong, or, in case
of Wayland buffer transforms, the values were swapped by interpreting
the Wayland enums accordingly, see commit 8d9bbe10.

Swapping the 90/270 degree values in `meta_rectangle_transform()`:
1. fixes hardware cursor positioning with flipped output transforms
2. fixes rendering issues with offscreen-rotated flipped output transforms
3. allows us to drop unexplained `meta_monitor_transform_invert()`s in
follow-up commits
4. allows us to make `META_MONITOR_TRANSFORM` and `WL_OUTPUT_TRANSFORM`
enums match again (reverting 8d9bbe10, as already done)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2459>
2022-07-26 18:41:43 +00:00
Florian Müllner
640ca57c34 window: Close window when unsetting transient_for
Since b443bd42ac, we unmanage a wayland window when clearing its
transient parent. That's to make sure that xdg-foreign doesn't
leave the dialog around after the imported surface was destroyed.

While that behavior is sound, it is problematic to implement it
by unmanaging the window, as that happens entirely behind the
client's back.

Instead, send a close event for the window. Unless the client has
good reasons, it should honor the request. (And if it has good
reasons - like unsaved work - then effectively hiding the window
from both the user and client is probably not the best idea anyway).

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2499>
2022-07-08 21:00:13 +00:00
Florian Müllner
7ff1c04c8f window: Guard minimize()
Not all windows can be minimized: X11 clients can disable the
functionality, and so do we for windows that aren't shown in
the alt-tab popup or the shell overview, so there would be no
way of getting them back.

While we make sure that we respect that ourselves (keybinding,
window menu, etc.), we don't guard meta_window_minimize(), so
clients or extensions can still minimize a window that isn't
supposed to be minimized.

That can lead to all kinds of issues, from the hidden window
being lost (as far as users are concerned) to a crash when
the minimzed window has a transient parent.

Just add an explicit check to make sure the unexpected doesn't
happen after all, and print a warning if it does.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2491>
2022-07-08 20:05:32 +00:00
George Barrett
9bdf4b3572 core/events: Fix cursor tracking for other backends
The cursor rendering code path used by the screen cast code relies on
the cursor tracker machinery to determine where to blit the cursor
texture, but at the moment the cursor position invalidation is behind
a check for whether the shell is using a Wayland backend. (This code
path used to be Wayland-specific before 00cbcb7ba1 but has been
backend-agnostic since).

This commit removes the check for a Wayland compositor, allowing
cursor drawing to function correctly on X11 when screen casting in
embedded cursor mode.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1780
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2474>
2022-07-07 19:39:07 +00:00
Dor Askayo
1f03a20939 window: Reuse existing function
This open-coded section is identical to the function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2485>
2022-07-01 16:05:33 +00:00
Jonas Ådahl
fdde7e0f37 x11: Let X11 connection owners call XSynchronize() themselves
Only make the context carry the boolean state, but move the two libX11
calls into their corresponding connection handler objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2444>
2022-06-03 13:43:26 +00:00
Bilal Elmoussaoui
89d036cca0 context/main: Disable X11 specific options
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2429>
2022-06-01 11:25:17 +00:00
Jonas Ådahl
f772b4cde6 restart: Make API that needs context take a context
This allows avoiding looking up old singletons.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2446>
2022-05-31 16:42:46 +00:00
Jonas Ådahl
81860229ba restart: Don't pass error as unused user data
We passed the pointer to a GError * as user data on an async I/O call.
The callback function didn't make use of it, so it was never written to,
thus remained NULL, thus was dead code. Remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2446>
2022-05-31 16:42:46 +00:00
Jonas Ådahl
6c0a917832 selection: Return an error if trying to transfer from NULL source
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Florian Müllner
f73ad1d8d2 display: Remove META_EVENT_ROUTE_COMPOSITOR_GRAB
Nothing sets the value anymore since the port to ClutterGrab, and
we just removed the last code references.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
75856043d4 display: Bypass focus window during grabs
This is what the old COMPOSITOR_GRAB check effectively did (by
returning the grab_window, which is only set during window grab
operations).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
937651cf0e display: Remove another COMPOSITOR_GRAB check
The event-route is never set to COMPOSITOR_GRAB nowadays, so the
condition will never be met.

Furthermore, it is expected that ClutterGrabs only happen when
events are routed normally, so the remaining NORMAL check should
already fully cover the old COMPOSITOR_GRAB case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
022f47ebfe events: Remove obsolete COMPOSITOR_GRAB check
We already bypass wayland if there is a ClutterGrab, so the case
that used to be covered by the event-route check is already handled,
and we can just remove the obsolete check.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Carlos Garnacho
50e89e3760 core: Avoid focusing window in presence of Clutter grabs
This is the same circumstance than the event_route not being NORMAL,
since events may or may not eventually reach the window. It should not
attempt to get focus out of the stage in that situation. This used
to be covered by META_EVENT_ROUTE_COMPOSITOR_GRAB, but this is no longer
set when ClutterGrab came in to replace it.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4858
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2433>
2022-05-28 09:04:48 +00:00
Sebastian Keller
bc9762eebb display: Properly store later ID when adding window to queue
The code is already trying to avoid creating new laters when there
already is one for the queue type, but this wasn't working because the
ID of the later was never stored after creating a new one. This would
then result in as many laters as meta_display_queue_window() was called
and all of them would run the handler function, even if only the first
one had a non-empty window queue.

Similarly this was causing the later to not be removed if the window
queue got empty after meta_display_unqueue_window().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Sebastian Keller
b289c8f01e window: Ensure window-visibility-updated is emitted when flushing queue
Currently the signal is getting emitted accidentally, because even when
removing a window from the queue, the later handler of that queue will
still get run due to a bug. This bug is going to get fixed in the next
commit, but some things might depend on the signal getting emitted when
the visibility of a window has changed.

This change affects the behavior in two ways. First the signal is now
emitted immediately rather than from an idle. And second it now
correctly includes the window in the should_show or should_hide list.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Sebastian Keller
2a3c964e64 display: Add method to flush a single window from the queues
This can be used when a state change needs to be applied immediately for
a specific window and will be used in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Sebastian Keller
f493a78641 display: Fix typo in trace message
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Jonas Ådahl
8ec8a26717 display: Unmanage windows before compositor
Prior to 'compositor: Destroy actors when unmanaging', window actors
were destroyed when the compositor object was destroyed, long after the
windows were unmanaged, however, when this instead changed to happen
when unmanaging, with the original goal to avoid having these actors try
to interact with the disposed MetaCompositor instance, it caused an
issue where window actors would be indirectly destroyed as a side effect
of their parents being destroyed, which caused some fallout in the logic
handling window-close animation tracking, which relies on
meta_window_actor_queue_destroy() being called before a window actor is
actually destroyed.

Fix this by unmanaging windows before unmanaging the compositor.

From an X11 point of view, this should be harmless, since all it really
do is call XCompositeUnredirectSubwindows().

For the native backend and the common behavior, all unmanaging the
compositor instance does is destroy clutter actors, so doing so after
window actors were already cleaned up should not be a problem, as this
was the case before too.

Fixes: 35ac3a096d
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5330
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2403>
2022-05-11 15:37:23 +00:00
Kazuki Hashimoto
38314fe5fd util: Fix compilation when !WITH_VERBOSE_MODE
Fixes the following linker error:

`meta_add_verbose_topic':
<artificial>:(.text+0x372f): undefined reference to `ensure_logfile'

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2405>
2022-05-07 11:53:41 +09:00
Bilal Elmoussaoui
97fc21adc1 core: Drop zenity show_dialog
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Bilal Elmoussaoui
749b9be98a core: Drop the default close dialog implementation
If the MetaPlugin doesn't implement it, we don't show anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Sebastian Keller
c3210b0ab2 Revert "workspace: Use existing focus_window when asked to focus default window"
This reverts commit d0de671c1d.

The change introduced a regression when focusing java/swing windows.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5395
Reopens: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5162
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2402>
2022-05-04 23:29:39 +02:00
Jonas Ådahl
36de8baf55 display: Get the backend from the context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Carlos Garnacho
91ae72acdf core: Account ClutterStage grabs on Wayland key focus synchronization
When switching between the existence and not of a stage ClutterGrab, we
would correctly attempt to synchronize key focus from the perspective of
the Wayland clients.

But this synchronization should do its own checks about existing stage
grabs before determining a client window has key focus or not.

Add that check, so that grabs correctly unfocus the keyboard in Wayland
clients, in addition to pointers and touch.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2194
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2366>
2022-04-20 14:38:23 +00:00
Jonas Ådahl
8c656a7f40 startup-notification: Fix some introspection annotations
This avoids a bunch of warnings and fixes a transfer annotation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2374>
2022-04-13 12:03:27 +02:00
Corentin Noël
c2b8582e0f startup-notification: Specify the actual type in the "changed" signal
Allows to have type checks and the introspection to be aware of the actual type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2362>
2022-04-05 14:05:23 +02:00
Corentin Noël
9132f984ce mutter: Add missing nullable annotation when possible
Add missing (nullable) annotation when a possible NULL return value is expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2362>
2022-04-05 14:05:23 +02:00
Sebastian Wick
1760dcb0d7 window: Check fullscreen status when window changes monitor
For wayland meta_window_move_to_monitor sends a configure to the client
without actually moving the window, yet and the
meta_display_queue_check_fullscreen call won't detect any changes.
Checking for fullscreen in meta_window_update_monitor fixes the problem
because it is called whenever the window actually changed the monitor it
is on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2325>
2022-03-30 13:01:29 +00:00
Carlos Garnacho
861c4b8535 core: Port to input device capabilities in pad mapper
Check for tablets and pad devices using capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Jonas Dreßler
d0de671c1d workspace: Use existing focus_window when asked to focus default window
We use meta_workpace_focus_default_window() to sync the input focus back
to a window after it was on shell UI, this is not really necessary on
Wayland, but it is on X11. What this function does internally is ask
MetaWindowStack about the topmost window and focus+raise that window.

In gnome-shell we set the input focus to the default window every time
the key-focus changes to NULL (see shell-global.c ->
sync_stage_window_focus()). Now when closing the alt-tab switcher and
activating a window while there's an always-on-top window on the
workspace, meta_workspace_focus_default_window() will focus that
always-on-top window right after closing the alt-tab switcher, making it
impossible to focus another window using alt-tab.

To fix this, make meta_workspace_focus_default_window() check if there's
an existing focus_window first, if there is, use that, and if there
isn't, resort to just focusing the topmost one.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5162
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2328>
2022-03-30 11:41:52 +00:00
Jonas Dreßler
0280b0aaa5 events: Use the event target actor to determine window for event
We use get_window_for_event() to check whether an event happened on top
of a window or on top of shell UI to decide whether to bypass delivering
the event to Clutter. In case of crossing events though, we can't just
use the device actor to determine whether to forward the event to
Clutter or not: We do want to forward CLUTTER_LEAVE events which
happened on top of shell UI. In that case the device actor is already a
window actor (the pointer already is on top of a window), but the shell
still needs to get the LEAVE crossing event.

Since the event source actor got removed from the detail of
ClutterEvent, the context we're looking for (which actor did the pointer
leave) is now the target actor that the event gets emitted to. Since the
last commit, we also made event filters aware of this context by passing
the target actor to them, so use this context now to determine whether
we're on top of a window or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2321>
2022-03-21 23:08:40 +00:00
Jonas Dreßler
2aad56b949 clutter: Pass target actor of events to event filter functions
We'll need the additional context of which actor the event will be
emitted to in mutters event filter (see next commit), so pass that
target actor to the event filters that are installed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2321>
2022-03-21 23:08:40 +00:00
Jonas Ådahl
546b94545e window: Make a better guess at initial monitor
We'd guess the initial monitor before it was actually calculated by
looking at the initial geometry. For Wayland windows, this geometry was
always 0x0+0+0, thus the selected monitor was always the primary one.

This is problematic if we want to provide initial more likely
configurations to Wayland clients. While we're not doing that yet, it'll
be added later, and this is in preparation for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
17e239246a window: Add function to calculate current bounds
This will later be used to tell Wayland clients about a size they
shouldn't exceed.

If the window doesn't have a main monitor, this function does nothing
and returns FALSE.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Carlos Garnacho
52002d042e core: Move away from clutter_event_get_source()
Instead ask the stage for the target actor for the given device/sequence.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Jonas Dreßler
672696f823 dnd: Notify about events during compositor grab from event filter
Since the introduction of ClutterGrabs, MetaDnd now no longer gets
notified about input events on the stage during grabs (for example while
the alt-tab popup is shown) and thus can't move the grab feedback actor
anymore.

To fix this, forward events to MetaDnD directly from
meta_display_handle_event() when a ClutterGrab is in effect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2308>
2022-03-02 15:12:23 +00:00
Jonas Dreßler
8a11069dca events: Only get MetaWaylandCompositor once
We get the MetaWaylandCompositor a bunch of times, but we can do with
getting it only once and then also replace the is_wayland_compositor()
checks with a if (wayland_compositor).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2308>
2022-03-02 15:12:23 +00:00
Dor Askayo
2a5506170a core: Initialize g_autofree with NULL
This prevents build warnings about use of potentially uninitialized
variables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2301>
2022-02-23 20:48:10 +00:00
Carlos Garnacho
1ad98879b7 core: Mark both directions in rings/strips as (un)handled altogether
If going on a direction has a keycombo associated and the other does
not, it does not make sense to let the wayland bits handle pad
ring/strip events that only go in one direction.

Ensure that's the case, and also while figuring out the ring/strip
direction based on the initial events.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1886
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>
2022-02-14 15:24:27 +00:00
Carlos Garnacho
952caf6b71 core: Refactor strip/ring direction guessing in action handling
Make it all happen in meta_pad_action_mapper_handle_action(), since
we'll need better handling here than just "return FALSE".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>
2022-02-14 15:24:27 +00:00
Carlos Garnacho
101cae03f3 core: Handle mixture of keycombo/no action in pad rings/strips
When generating the action label, we expect both directions of these
features to have consistent settings (either both get a keycombo, or
they don't) or these just return NULL altogether.

Since one of the directions has an action associated, this is
misleading, so be more lenient at the time of generating the action
label.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>
2022-02-14 15:24:27 +00:00
Carlos Garnacho
4e85e0e1b3 core: Drop handling of updates to the last used device
This is now done in the backend for the Wayland case, so we can
drop this update here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Jonas Ådahl
169dd2fb7a window: Move some display level window processing to MetaDisplay
meta_window_(un)queue() was implemented with global arrays in window.c
that managed MetaLater handle IDs and lists of window queues. In order
to rely less on scattered static variables and making it clearer that
we're dealing with per display window management and not something
specific to a single window, move the window resize/calc-showing queue
management to MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
ac5d728abd window: Fix coding style in meta_window_unqueue()
As with meta_window_queue(), it had some comments duplicating code, so
those were removed too to increase readability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
aeae90d5d9 window: Move icon management to X11 implementation
It's still used by e.g. GNOME Shell to produce fallback icons for X11
applications that doesn't come with a .desktop file. Geometry stays in
the generic class because it's used for minimize animations and is
configured by the panel (e.g. the one in gnome-shell-extensions).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
73c010d8b0 window: Remove musings from meta_window_queue()
The comments in this function tells a story of C programmer self
reflecting about data types and Perl. While that can be nice, the rest
consisted mostly of repeating what the code line below did, with the end
result being that the function didn't fit on screen, resulting in worse
readability overall.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
b5d873a8ac window: Clean up coding style of meta_window_queue()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Olivier Fourdan
6427b27602 mutter: Raise the NOFILE limit if a Wayland compositor
When being run as a Wayland compositor, raise the NOFILE limit to
mitigate the risk of running out of file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:47 +01:00
Olivier Fourdan
acded0648c core: Restore the NOFILE limit
When restarting or when running a dialog, the original NOFILE limit
should be restored.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:47 +01:00
Olivier Fourdan
8b9341131a context: Add a new API to raise and restore NOFILE limits
Wayland, especially when using SHM buffers, can use a lot of file
descriptors and can possibly reach the NOFILE soft limit.

Add a new API to MetaContext to raise and restore the NOFILE limit so
that the Wayland compositor can use as many file descriptors as the hard
limit allows.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1283
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:42 +01:00
Carlos Garnacho
d838460fe9 core: Do not eat both wayland and clutter events with wayland popups
There may be situations where we may stack a ClutterGrab on top of a
wayland popup's. Since ClutterGrab should win over client grabs, we
mostly correctly figure out that it should start doing
bypass_wayland=TRUE and bypass_clutter=FALSE while the ClutterGrab
holds, however the late checks for the MetaDisplay event route can
still toggle bypass_clutter on, resulting in neither handling events.

This check for wayland popups in the display event route should just
enforce wayland handling if wayland is meant to be receiving events,
so ensure these don't mix together.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5020
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2271>
2022-02-04 18:24:19 +01:00
Jonas Ådahl
0205398d96 constraints: Try place popup on the same monitor as the anchor rect
When we'd place a popup, if the initially calculated position would be
on another monitor than the anchor rect on the parent window, the
later constrained position would end up on another monitor than the
parent window. This could for example happen if a popup menu opening
towards the right was opened very close to the screen edge of a right
most monitor in a two side by side monitor setup.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1783
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1768
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2252>
2022-01-31 13:14:22 +00:00
Carlos Garnacho
e8ed9ece1c core: Drop META_GRAB_OP_COMPOSITOR
There is no longer meta_plugin_begin_modal(), so this grab operation
is no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
2022-01-29 02:11:37 +01:00
Carlos Garnacho
a840c039a0 core: Handle redirection changes in and out of ClutterGrab grabs
Wayland event processing and WM operations are themselves outside the
ClutterGrab loop so far. Until this is sorted out, these pieces of
event handling have got to learn to stay aside while there is a
ClutterGrab going on.

So, synchronize foci and other state when grabs come in or out, and
make it sure that Wayland event processing does not happen while
grabs happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Marco Trevisan (Treviño)
8cf3485ab0 monitor-manager: Notify privacy screen changes on hotkey press
When privacy screen is changed and this happens on explicit user request
(that is not a setting change) we should notify about this via an OSD.

To perform this, we keep track of the reason that lead to a privacy
screen change, and when we record it we try to notify the user about.

When the hardware has not an explicit hotkey signal but we record a
change we must still fallback to this case.

Fixes: #2105
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00