3090 Commits

Author SHA1 Message Date
Sebastian Wick
15d4123bd1 udev: Move from backends/native/ to backends/
This makes it possible to use udev even for backends which are not
native. Specifically we want to start controling backlights in mutter
which has to happen for both native and X11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4130>
2024-12-12 15:27:11 +01:00
Bilal Elmoussaoui
1d7740d537 compositor: Move various functions to their correct namespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4131>
2024-12-11 18:29:31 +01:00
Bilal Elmoussaoui
e06592d3df util: Drop duplicated Clutter debug flags helpers
Clutter exposes those functions already.
So there is literally 0 point in duplicating them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4131>
2024-12-11 18:28:57 +01:00
Jonas Ådahl
f77d8e2a12 display: Fix cursor sprite sizes with fractional scales
This makes the cursor size match the expectation given by the theme
size. It also means the sprite size now matches GTK4 provided cursor
surfaces using wp_viewport.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
2024-12-11 16:22:57 +00:00
Jonas Ådahl
e9475b2190 tests: Add basic ref-test based cursor sprite test case
It currently contains some basic tests using the built in cursor as well
as traditional buffer scale using Wayland client in different monitor
configurations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
2024-12-11 16:22:57 +00:00
Jonas Ådahl
ea9e8bff2d debug-control: Add InhibitHwCursor property
Inhibits the hardware cursor globally when true.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3859>
2024-12-11 16:22:57 +00:00
Georges Basile Stavracas Neto
0265fa34be window: Initialize rect
As far as I can see this doesn't happen in practice, but theoretically
the uninitialized values can be used if:

 1. `did_placement` is TRUE
 2. `flags` contains both `META_MOVE_RESIZE_RESIZE_ACTION` and
    also `META_MOVE_RESIZE_MOVE_ACTION`
 3. `!meta_window_is_tied_to_drag (window)` is FALSE

In that case, the `frame_rect` variable (with uninitialized values) is
passed to `unconstrained_rect`, then passed to `constrained_rect`,
then finally the (uninitialized) X and Y values are read in the
`if (did_placement)` branch.

This is probably a regression from 3047b2ce261. I don't know if this is
the appropriate fix.

Coverity CID: #1511378

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4175>
2024-12-10 14:17:47 -03:00
Jonas Ådahl
f4201bc3d3 service-channel: Add global shotcuts portal backend client type
The global shortcuts portal backend component lives in
gnome-control-center, and is responsible for preseting the GUI for
managing client provided global shortcuts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4173>
2024-12-10 17:02:24 +00:00
Jonas Ådahl
a23d08c754 Add way to pass construct time options to plugin
This is needed to allow tests to manipulate the behavior of the test
shell plugin during startup. Since the plugin is created and started
when the MetaDisplay is created, it needs to be handled via MetaContext,
by setting the options after creating the context, but before starting.

For simplicity reasons, make the options an opaque GVariant, passed via
a an `"options"` property when the plugin object is created, if the
passed options is non-NULL. Only passing the options when non-NULL
allows for backward compatibility.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4152>
2024-12-05 00:19:12 +00:00
Nick Diego Yamane
0c42ddefad wayland/xdg-toplevel-drag: Disable show/hide effects
This disables the visibility change effects for the dragged window,
which makes it feel a bit smoother.

TODO: Double-check whether this is indeed desirable. Note: ChromeOS imp
does this and Chromium-X11 used to do this at client side.

Status:

- [x] Basic window drag triggering
- [x] Exclude the dragged window from event targets
- [x] Event forwarding (window drag vs wayland grabs)
- [x] Offset calc relative to toplevel geometry
- [x] Attach already mapped windows
- [x] Properly support not-yet-mapped windows
- [x] Disable visibility change animations
- [ ] Dnd events stream adaptations

Signed-off-by: Nick Diego Yamane <nickdiego@igalia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4107>
2024-11-29 20:51:52 -04:00
Nick Diego Yamane
1cb46f203c wayland/xdg-toplevel-drag: Support non-grabbing mode in MetaWindowDrag
- This adds a new ClutterActor parameter to meta_compositor_drag_window
  and meta_window_drag_begin such that it's possible to inject an
  external grab actor, which is then used to implement a "non-grabbing"
  mode that allow a MetaWindowDrag to be used in conjunction, for
  example, with a Wayland drag-and-drop session;
- This new API is going to be used to implement the toplevel drag
  protocol in a subsequent commit.

Signed-off-by: Nick Diego Yamane <nickdiego@igalia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4107>
2024-11-29 20:35:15 -04:00
Nick Diego Yamane
3047b2ce26 wayland/xdg-toplevel-drag: Add MetaWindowActor tied_to_drag state
- Skip placement constraints when it is set.
- Required to properly support about-to-be-mapped windows, which get
  "detached" when dragged out of its original owning window.

Signed-off-by: Nick Diego Yamane <nickdiego@igalia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4107>
2024-11-29 20:31:24 -04:00
Olivier Fourdan
5a231a4d27 window: Add a window helper function for MetaWindowConfig
The MetaWindowConfig can indicate whether the configuration reflects on
the initial configuration, before the window is first mapped.

Add a smaller helper (private) window function to create the appropriate
"type" of MetaWindowConfig depending whether the window was already
showed or not.

This is preparation work for the following commits where this function
will be used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4076>
2024-11-12 16:01:35 +01:00
Olivier Fourdan
d44fd167bb window: Add a "configure" signal
This conveys the initial window configuration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4076>
2024-11-12 16:01:35 +01:00
Olivier Fourdan
4c20584b11 window: Use the MetaWindowConfig
This is a fairly large refactoring to replace the window rect and
fullscreen flag with the new MetaWindowConfig object.

No functional change intended at this point.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4076>
2024-11-12 16:01:35 +01:00
Olivier Fourdan
a7ef0b137e window: Use the fullscreen API
Use the meta_window_is_fullscreen() API instead of accessing the
fullscreen field of the MetaWindow structure directly.

This is both a (small) cleanup and preparation work for the next commit.

No function change (intended).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4076>
2024-11-12 16:01:35 +01:00
Olivier Fourdan
7e098ae671 window: Add a MetaWindowConfig type
This is intended to be used in place of the window rect and fullscreen
flags.

That will also allow for a pre-configuration signal to be added, passing
the configuration so that a plugin can tweak the configuration before it
gets applied first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4076>
2024-11-12 16:01:35 +01:00
Jonas Ådahl
2cd84f9263 context/main: Remove unnecessary macro endif/if
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4064>
2024-11-08 22:08:21 +01:00
Sebastian Wick
6b72184173 core/context: Fix if/else cascade for disabled native backend
If the native backend is disabled but X11 and wayland are enabled, there
is a free standing else. Fix this by relying on the returns for control
flow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4123>
2024-11-06 22:02:44 +00:00
Bilal Elmoussaoui
eb5e6036be window: Add get_client_content_rect
In acbb14f34bc8fee14e77db3c100e5d116d8e3d60, we have dropped the
is_client_decorated except it was still being used by gnome-shell
to adjust the window coordinates in case it is using server side
decoration.

Instead of re-adding the same function, expose a new function that
takes care of getting the whole client area while taking into account
SSD for X11 clients.

Helps https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7984

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4087>
2024-11-06 11:04:15 +00:00
Bilal Elmoussaoui
a5be92e03d Use _once variant of g_[timeout_idle]
Nice helpers that were added in GLib 2.72, so safe to make use of as we
depend on 2.81.1 already.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4115>
2024-11-04 21:18:37 +00:00
Bilal Elmoussaoui
0f5ec2ec16 window: Use getter for fullscreen state
Avoids going through struct field directly as we might replace that with
a WindowConfiguration type soon-ish.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4111>
2024-10-30 16:25:47 +01:00
Bilal Elmoussaoui
8e5433d82a window: Replace barely used macros with func equivalents
To avoid mostly going through struct fields in macros as we might soon
move those first to a WindowConfiguration & maybe even make the window
struct private with time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4111>
2024-10-30 16:25:37 +01:00
Bilal Elmoussaoui
d92893b6f3 clutter/threads: Remove _full functions variant
As they are not used anywhere, in the next commit
we will just remove the whole thing and use glib helpers directly as
there is nothing specific about ClutterThread anymore

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4077>
2024-10-30 08:32:46 +01:00
Sebastian Wick
2f3ad4be5c core/debug-control: Add new ForceHDR debug control
It will be used to force the color state of all monitors to be as if
they managed to turn on HDR mode. This is useful for debugging shaders
in an environment where an HDR mode capable display is not available,
such as the nested mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4035>
2024-10-15 10:37:36 +00:00
Florian Müllner
34c2767f81 keybindings: Pass generic ClutterEvent* to handlers
While the events when processing keybindings are quite obviously
key events, the individual structs are all opaque and all public
API is provided by the generic ClutterEvent type. That means that
any handler that uses the passed in event must cast it to
ClutterEvent anyway, so drop the cast to ClutterKeyEvent when
processing key events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4080>
2024-10-14 14:10:05 +02:00
Bilal Elmoussaoui
3eb5381c46 wayland/inhibit-dialog: Drop duplicated hide call
the destroy and the response handler, already hide the dialog
themselves. The calls here were unnecessary.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3048
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4034>
2024-10-09 10:24:12 +00:00
Jason Gerecke
d46352b23f display: Do not crash attempting to display OSD for unknown Wacom device
The gnome-control-center has recently allowed unknown tablets to appear
in its UI. The UI provides a "Map Buttons" button that tries to open the
OSD, but if a device is not known there may be no Wacom object to actually
act on.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3722
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4059>
2024-10-04 20:38:55 +00:00
Carlos Garnacho
8b9bf6b051 core: Add async save method to MetaSessionManager
Allow saving the session gvdb file in the background, with as little
overhead in the main thread as possible. We still need to serialize
all created/deserialized MetaSessionState to a GVDB hashtable there,
in order to avoid these being poked from the async task thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
6c3c17daa6 tests: Make test context able to create a session manager
And create an empty one when asked for it. This session data is not
saved on disk, except for the purpose of creating an empty file FD.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
2074e4e146 core: Add debug control setting for session management
We will at the moment want it guarded behind a setting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
920de400f5 core: Make MetaContext manage the MetaSessionManager singleton
Make this core object own the MetaSessionManager, for the window management
code to access.

At this level, we will be able to integrate with systemd notification
system, and use systemd fdstore to keep the mapped memory warm for
us for the case of soft reboot. This is at the moment not implemented
here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
fa9c70a1d4 core: Add MetaSessionManager
This core object will be the manager of "client sessions", allowing
the windowing-specific paths to generate MetaSessionState objects to
track their clients.

This object is unused at the moment, and will be integrated in later
commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Carlos Garnacho
c6acf3aef5 core: Add MetaSessionState
This is an abstract base class to implement a "client session",
carrying the accounting of the windows, and allowing to serialize/read
their state into a Gvdb table.

Since different windowing backends may require slightly different
data to be saved for each window, this is meant to have windowing-specific
implementations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Sebastian Wick
777c89f10d Add debug topic "session-management"
This is used to print debug information for session management.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Jonas Ådahl
c3cfd5266a context: Add 'nick' property
A nick property is a bit similar to the nick of a GObject property, in
that it's a shorter version of the name. It's intended to be used to
store state on the file system, where the state depends on the desktop
environment being used. E.g. gnome-shell sets the name "GNOME Shell",
which is, if no nick is explicitly set, transformed into the nick
"gnome-shell", which will be used for file paths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3825>
2024-09-14 13:47:21 +00:00
Jonas Ådahl
6e8c7c5f84 Add experimental mode to use native scaling of Xwayland clients
Allow scale-aware Xwayland clients to scale by an integer scale
themselves, instead of letting them render them at 1x scale and then
scaling up the texture, making it look blurry.

When monitor framebuffers are scaled, this special cases Xwayland and
sends output regions in a way that Xwayland think everything is N times
as large as the logical region, where N is the ceil of the max monitor
scale.

This is done by introducing a "stage" vs "protocol" coordinate space for
X11, where the "protocol" coordinate space is "stage" multiplied by a
scaling factor.

Xwayland thus will have its own "effective scale", sent via
wl_output.scale. The effective Xwayland scale is also used for the
internal MetaWaylandSurface scale internally, unless there is a viewport
dst size set on the same surface, in which case the scale is still set
to 1, to not interfere with wp_viewport semantics.

We're guarding this behind a new experimental feature
"xwayland-native-scaling", which can only come into effect when enabled
together with "scale-monitor-framebuffer".

[v2]:

Move stage_to_protocol/protocol_to_stage to generic window class.

This means parts that aren't aware of any windowing system specific
logic, only that coordinates originate from there for a given window,
can still get their coordinates properly handled.

In particular, this means coordinates from IBus that originates from the
client, can be scaled properly when that client is using X11.

Also make them properly introspected.

[v3]:

Split up coordinate transform API.

Make it one that takes a MtkRectangle, and another that takes a point.

This means the rounding strategy becames explicit when transforming a
point, while when it's a rectangle, it's still always "grow".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3567>
2024-08-30 20:32:01 +00:00
Sebastian Wick
6fa61a088f core/debug-control: Allow changing the reference luminance of outputs
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3953>
2024-08-30 20:03:43 +00:00
Sebastian Wick
1b2d0a4d4a debug-control: Add property for toggling color management protocol
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3893>
2024-08-29 23:00:34 +00:00
Bilal Elmoussaoui
98c36ad1c6 input/action-mapper: Get ClutterBackend from MetaBackend
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:40 +02:00
Bilal Elmoussaoui
faa0860e9d window: Get Backend from actor's associated context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:39 +02:00
Sebastian Wick
757f8b6d69 wayland/surface-role: Keep track of the surface main monitor
Toplevels get the main monitor from their MetaWindow and have no main
monitor when the toplevel is not mapped.

Subsurfaces get the main monitor from their parent surface.

DnD and cursors get the main monitor from the current cursor position no
matter if the cursor is actually being shown or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3941>
2024-08-27 23:22:21 +02:00
Bilal Elmoussaoui
5176a828eb core/util: Drop duplicated MetaLocaleDirection
Clutter has an enum for that already, just use it instead of mapping between the types

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Carlos Garnacho
ae35c1efe0 core: Use event return value defines in keybinding code
Make the fate of the given event in every return path more
evident.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3935>
2024-08-20 10:50:06 +00:00
Carlos Garnacho
cdf427039d core: Let unhandled key release events be propagated by keybindings
This leads to possibly missed key release events being propagated down to
clients, and in the case of X11 clients, to stuck keys e.g. after switching
workspace with Ctrl+Alt+Left/Right and ending up with a X11 client focused.

Fixes: 11a4d56185 ("keybindings: Send trigger when a key accelerator is deactivated")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3935>
2024-08-20 10:50:06 +00:00
Sebastian Wick
dcaa57c2c8 mtk: Move meta_rectangle_transform to Mtk
Both MtkMonitorTransform and MtkRectangle are Mtk types, so we can push
this into Mtk and start using it in Clutter as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
89af55d8aa mtk: Move MetaMonitorTransform to Mtk
This makes it possible to use MtkMonitorTransform in Clutter which will
be used to track the transform in ClutterStageView.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
sid
9e24fa52c6 core: Include the pkgconfig-specified gdesktop-enums.h
Follow up to commit 7658e07be

Refer https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1370

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3916>
2024-08-07 09:34:52 +00:00
Georges Basile Stavracas Neto
cdbe0a27a2 service-channel: Add client type for filechooser portal
Add a new service client type for a filechooser portal client, and
expose the x11_interop protocol to it.

This will be used to make Nautilus a file chooser portal implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3694>
2024-08-06 16:07:48 +00:00
Bilal Elmoussaoui
d283f84d6c window: Call set_normal_hints on Wayland windows as well
As that would initialize the hints which would otherwise be 0
causing a division by 0

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3572
Fixes: 377455402 ("core/window: Guard some x11 calls")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3894>
2024-07-25 22:24:25 +02:00