1
0
Fork 0
Commit graph

2720 commits

Author SHA1 Message Date
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
Carlos Garnacho
02d4a07822 core: Consider ClutterGrabs checking whether windows are interactive
There's 2 users of this, meta_display_sync_wayland_input_focus() which
does already perform these checks on its own, and MetaCursorTracker's
update_displayed_cursor() to determine whether it should go with the
Wayland client's cursor.

This second check should also consider the existing ClutterGrabs, so
make meta_display_windows_are_interactable() handle them for both
callers.

Fixes the cursor shown over windows while e.g. there are menus opened.

Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/2553
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2754>
2022-12-16 20:57:11 +00:00
Michael Webster
ec17d19c76 tiling: Remove unnecessary update_edge_constraints().
Both meta_window_maximize and meta_window_tile use
meta_window_maximize_internal(), and edge constraints are already
recalculated and updated there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2579>
2022-12-05 18:57:20 +00:00
Michael Webster
559e6ff327 tiling: Skip the resize effect for tiled windows during user grabs.
meta_window_tile gets called by the grabbed window's match during
tile resizing. These incremental changes don't need to be animated.

Closes: #2246
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2579>
2022-12-05 18:57:20 +00:00
Carlos Garnacho
9feac5ce62 compositor: Opt out compositor shadows from windows with frames
Let the frames client render its own shadow. In order to do that,
avoid double painting a shadow on the compositor side, and extend
the mask area of the frame, so it does unveil the (so far)
hidden frames-client-side shadows.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00