1
0
Fork 0
Commit graph

12939 commits

Author SHA1 Message Date
Jonas Ådahl
51b2a9a500 tests/dbus-runner: Launch pipewire via socket activation
Launching pipewire and wireplumber is racy, as there is an arbitrary
amount of time between pipewire is launched, and that the socket is
bound.

In order to eliminate this race, bind the pipewire sockets ourselves,
and launch pipewire (and wireplumber) when there is activity on the
socket. This is using the systemd method of doing socket activation,
which consists of passing the number of passed file descriptors via
$LISTEN_FDS, and the pid of the launchee via $LISTEN_PID.

The former is easy, just pass the file descriptors, but the former is
more tricky when using python, as executing code before exec() is poorly
supported and likely to be deprecated. To address this, socket
activation services are wrapped in a socket-launch.sh helper which sets
the $LISTEN_PID to itself before calling exec().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
c2683a20a6 tests/dbus-runner: Use named arguments during setup
Will be a bit nice when more arguments are added.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
6b0f7294db tests/dbus-runner: Move service launching into helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
63b59dfa89 tests/dbus-runner: Avoided nested service launch lists
list = ['one']
list.append('two,three'.split(','))

results in ['one', ['two', 'three']]

while

list += 'two,three'.split(',')

results in ['one', 'two', 'three']

which is what is expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
b2e1f968d9 tests/dbus-runner: Log more about service management
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
d4d5cd2dc1 tests/installed-dbus-session: Add --compile-schemas
This will run glib-compile-schemas in the test data directory.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
d9ead43270 tests/dbus-runner: Allow setting custom parser state and environment
This will be useful for the installed tests runner, which for some tests
need custom actions that needs to change the environment the test run
in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
d9b6101b15 tests: Split up 'native-unit' test
It had three different parts that deserve their own actual test cases
  * virtual monitors
  * screen casting
  * bezier

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
1a0be0232a tests: Include 'src/tests' in G_TEST_BUILDDIR
This will help with finding executables in installed tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
1d724e7e9d tests/ref-test: Warn if mkdir failed
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
e53bdc4416 tests/ref-test: Set output dir via env var
While when running with meson, we want the output to be in meson-logs
for convenience, such a path isn't feasible when running as an installed
test. To address this, make the destination path configurable via an
environment variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
7d4db86804 tests/installed: Don't duplicate environment sanity
Tests are run via the mutter_dbusrunner.py helper, which handles setting
the gsettings backend, runtime dir etc, so rely on that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
ecf79ce6cb tests/build: Move installed tests description to the the end
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
50e667b29b tests/stacking: Replace a couple of sleep;assert_focused with wait_focused
This should hopefully get rid of race conditions in those tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Jonas Ådahl
7637627e01 tests/test-runner: Add 'wait_focused' command
This aims to replace a reoccuring arbitrary sleep followed by a focus
assertion. The problem with these is that the sleep does not reliably
wait for long enough, due to arbitrary system resource usage in CI and
elsewhere. By instead waiting, and instead asserting we don't have any
intermediate wrong focus, we remove the race, and test for more invalid
situations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3973>
2024-08-28 14:57:51 +00:00
Michel Dänzer
c2621eca15 onscreen/native: Set latest cogl sync_fd on KMS update
See previous commit log on the effects of this.

This means the deadline evasion needs to be added in both cases in
clutter_frame_clock_notify_presented.

v2:
* Use meta_kms_update_set_sync_fd. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3958>
2024-08-28 14:42:38 +00:00
Michel Dänzer
996eb4b6ae kms/impl-device: Handle sync_fd in meta_kms_impl_device_handle_update
If the KMS thread is using the deadline timer, and a valid sync_file
descriptor is passed in:

1. The update is deferred, and the deadline timer is left armed, until
   the sync_fd signals (becomes readable).
2. Implicit synchronization is disabled for the KMS update.

This means cursor updates should no longer miss a display refresh
cycle due to mutter's compositing GPU work finishing too late.

v2:
* Use g_autoptr for GSource in meta_kms_impl_device_handle_update.
  (Sebastian Wick)
v3:
* Use meta_kms_update_get_sync_fd, don't track sync_fd in
  CrtcFrame::submitted_update. (Jonas Ådahl)
v4:
* Clean up CrtcFrame::submitted_update members in crtc_frame_free.
v5:
* Coding style cleanup in meta_kms_impl_device_handle_update.
  (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3958>
2024-08-28 14:42:38 +00:00
Michel Dänzer
369596a82b kms/update: Add meta_kms_update_get/set_sync_fd
v2:
* Use g_steal_fd in meta_kms_update_merge_from. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3958>
2024-08-28 14:42:38 +00:00
Michel Dänzer
452e4fbf70 kms/plane: Rename META_KMS_ASSIGN_PLANE_FLAG_DIRECT_SCANOUT
To META_KMS_ASSIGN_PLANE_FLAG_DISABLE_IMPLICIT_SYNC. This describes the
effect of the flag, instead of the circumstances it's currently used
for.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3958>
2024-08-28 14:42:38 +00:00
Michel Dänzer
a589456209 kms/crtc: Conditionally return 0 in meta_kms_crtc_get_deadline_evasion
If both crtc->shortterm_max_dispatch_duration_us and
crtc->deadline_evasion_us are 0, i.e. we're not using the deadline
timer.

v2:
* Fix coding style. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3958>
2024-08-28 14:42:38 +00:00
Christian Hergert
030270ba3b compositor: Mark window drag actor invisible
If the window_drag->handle ClutterActor:visible property is FALSE,
then we avoid a full-framebuffer damage on the monitor when beginning
and ending a drag.

Testing with `mutter --wayland --display-server` still shows a full-
framebuffer damage on the first drag, but that appears to be unrelated
to this. Subsequent full-framebuffer damage which would occur on
drag-begin and drag-end have been elided.

Related: #3630
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3975>
2024-08-28 14:25:15 +00: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
Sebastian Wick
fe17e717c3 wayland-surface: Add a main-monitor property
The main monitor is role dependent. For a toplevel this comes from the
MetaWindow main monitor, for a subsurface from the parent surface, for
pointer and dnd from the cursor position.

The next commit will use meta_wayland_surface_set_main_monitor in the
different roles to keep the property up-to-date.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3941>
2024-08-27 23:22:21 +02:00
Sebastian Wick
586fd41a7e feedback-actor: Remove unused meta_feedback_actor_update
We removed the last user in the previous commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3941>
2024-08-27 19:16:36 +02:00
Sebastian Wick
20cf5fb02f wayland/data-device: Move position updates to a common function
The function will be expanded in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3941>
2024-08-27 19:16:36 +02:00
Sebastian Wick
035bbb3250 wayland/data-device: Remove unused drag_grab_update_feedback_actor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3941>
2024-08-27 19:16:36 +02:00
Sebastian Wick
a43dbd46fb cursor: Fix set_property vfunc name
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3941>
2024-08-27 19:16:36 +02:00
Daniel van Vugt
dc637e95ac tests/monitor-unit: Use the correct XML syntax
Fixes: 4175a37e4c ("tests/monitor-unit: Add layout mode migration tests")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3976>
2024-08-23 12:01:09 +08:00
Daniel van Vugt
3eebe2592a monitor-config-store: Fix typos in <layoutmode> written to monitors.xml
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3635
Fixes: 076b3664a3 ("monitor-config-store: Store and load layout mode for each configuration")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3976>
2024-08-23 11:32:19 +08:00
Florian Müllner
da828c2fcc x11/input-device: Stop using deprecated libwacom API
libwacom_has_ring/ring2 was deprecated. Switch to the replacement
function where it is available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3974>
2024-08-22 18:48:36 +00: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
Sebastian Wick
41f0194280 tests: Start pipewire and wireplumber for the native-unit test
So far, the tests relied on the host system to provide pipewire and
wireplumber. This seperates the tests from the host system which is
especially useful if the tests are run in a toolbox which has a
different pipewire installed than the host. It also should make it
harder to have a mismatch between the pipewire library and the pipewire
daemon.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3966>
2024-08-22 08:51:56 +00:00
José Expósito
c7acd6074b wayland/drm-lease: Fix list initialization bug
The new_connectors list must be initialized empty, otherwise, connectors
are duplicated.

Fixes: 115b2c1247 ("wayland/drm-lease: Make MetaDrmLeaseManager::connectors a GList")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3967>
2024-08-21 12:47:57 +00:00
Jonas Ådahl
d2be0b6950 kms: Inhibit real time scheduling until initial mode set
We're already inhibiting real time scheduling when reading new KMS state
after hot plugs, as well as when during mode sets, due to the kernel not
being able to reliably handle these within the 250 ms limit. However, we
didn't do this during initial probing, which meant that occasionally
we'd run into these kind of issues during startup.

Handle this by always inhibiting real time scheduling up front, and
don't uninhibit until all initially discovered device have finished
processing their initial mode set.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3628
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3960>
2024-08-21 12:15:59 +00:00
Peter Hutterer
d866590b78 wayland: Set current tool surface to NULL on prox-out
If an application is maximised, clutter_stage_pick_and_update_device()
goes into the
        if ((flags & CLUTTER_DEVICE_UPDATE_IGNORE_CACHE) == 0)
condition and returns the current actor for the device. This means no
CLUTTER_LEAVE/ENTER events are generated and in turn means the focus is
never invalidated and updated.

This leads to tool->focus_surface always being NULL and all events are
discarded.

Notably, tool->current is set to the right surface but
that one never changes either so meta_wayland_tablet_tool_set_current_surface()
exits early too because surface == tool->current and we thus never call
meta_wayland_input_invalidate_focus().

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3616
Fixes: fb8ac5dff7 ("wayland: Track current tablet tool focus surface")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3956>
2024-08-21 10:21:33 +00:00
Peter Hutterer
c03e64ef1d wayland: Propagate a tablet's DEVICE_REMOVED to trigger the signals
Clutter's "device-removed" signal is sent in
clutter_seat_handle_event_post(). Our tablet code is set up to handle
that signal to then notify wayland clients of removed tablet devices.

However, returning CLUTTER_EVENT_STOP for a DEVICE_REMOVED event means
we never get to the point where we send out the signals and thus never
remove the tablets.

Fixes: a37fd34bbb ("wayland: Make MetaWaylandSeat in charge of its own tablet seat")

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3615
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3955>
2024-08-20 14:06:32 +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
Michel Dänzer
bd8db38460 kms/impl-device: Track dispatch duration in crtc_frame_deadline_dispatch
And take it into account in meta_kms_crtc_get_deadline_evasion.

This uses the same fundamental approach as clutter frame clock scheduling:

Measure the deadline timer dispatch duration, keep track of the longest
duration, and set the timer to fire such that the longest measured
dispatch duration would result in it completing shortly before start of
vblank.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3612

v2:
* Move DEADLINE_EVASION_CONSTANT_US addition from
  meta_kms_crtc_determine_deadline to meta_kms_crtc_get_deadline_evasion.
* Calculate how long before start of vblank dispatch completed for
  debug output in crtc_frame_deadline_dispatch.
* Shorten over-long lines in crtc_frame_deadline_dispatch.
v3:
* Take VRR into account in crtc_frame_deadline_dispatch &
  meta_kms_crtc_update_shortterm_max_dispatch_duration. (Robert Mader)
v4:
* Check if deadline has already passed in meta_kms_crtc_determine_deadline,
  set the deadline for one refresh interval later if so.
* Fix indentation in crtc_frame_deadline_dispatch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3934>
2024-08-17 19:16:01 +00:00
Michel Dänzer
d7012d2ad3 kms/impl-device: Use KMS_DEADLINE in crtc_page_flip_feedback_flipped
It's useful for this to match the debug topic in
crtc_frame_deadline_dispatch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3934>
2024-08-17 19:16:01 +00:00
Jonas Ådahl
e5827ea06b monitor-config-utils: Use g_list_copy_deep() to clone lists
It makes things a bit more easy to follow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Ådahl
b8394c68f5 monitor-config-store: Use auto pointers in a couple of places
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
4175a37e4c tests/monitor-unit: Add layout mode migration tests
Let's add a bunch of tests for the newly introduced monitor config
migration code. We're verifying that:

- monitor configs get migrated and monitors.xml is updated on startup

- existing monitor configs in LOGICAL layout mode (ie.
"scale-monitor-framebuffers" was enabled before updating mutter) get
migrated

- the migration of various more complex monitor layouts from PHYSICAL
to LOGICAL layout mode works

- for monitor layouts where conversion to LOGICAL fails, the PHYSICAL
layout mode still is migrated, while for LOGICAL at least primary
monitor and disabled monitors are preserved

- simple monitor configurations (with no scaled monitors, or with only
"irrelevant" scaled monitors at the end of the layout) do not go through
the conversion code paths

- monitor configs in PHYSICAL layout mode with integer scale factors
which will result in non-integer logical monitor sizes get converted
to the closest fractional scale factor

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
05cc8a56e1 monitor-config-store: Save configs after layout mode detection/conversion
We don't want to do the work of the layout mode detection and conversion
every time we read the monitors.xml file.

Instead, when the detection logic is used, set a flag to automatically
update the config files after the parsing is finished.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
2c8b383a7e monitor-config-store: Attempt to convert physical to logical layout modes
Introduce some "best effort" conversion code to migrate monitor configurations
from PHYSICAL (the old default) to LOGICAL (the new default on wayland)
layout mode.

This conversion will only be used when the old PHYSICAL layout-mode
configuration is not compatible with the new LOGICAL layout-mode one.
This only applies if 1) there's a monitor that needs scaling in the
layout, and 2) the scaled monitor comes before other monitors in the
coordinate system (ie. it's not the rightmost or bottommost monitor).

There are two algorithms added here to convert monitor layouts:

- One for "simple" 1-dimensional monitor layouts, where all monitors are
aligned on a vertical or horizontal strip.

Here's a few (inaccurate) examples of how this would look with different
layouts (left side is PHYSICAL, right side is LOGICAL, x is the origin of
the coordinate system, the numbers are scales of the monitors):

```
x──────┬──────┬──────┐     x  ┌──────┐
│  2   │  1   │  2   │    2┌──┤  1   ├──┐2
│      │      │      │ ──► └──┤      ├──┘
└──────┴──────┴──────┘        └──────┘

         x    ┌──────┐     x  ┌──────┐
         ┌────┤  1   │     ┌──┤  1   │
         │ 2  │      │ ──► └──┤      │
         └────┴──────┘      2 └──────┘

    x      ┌────┐
    ┌──────┤    │          x──────┐
    │      │    │          │      ├─┬────┐
    │  1   │ 3  │      ──► │  1   │3│ 1  │
    │      │    │          │      ├─┴────┘
    └──────┤    │          └──────┘
           │    ├────┐
           │    │ 1  │
           └────┴────┘
```

- A second more complex algorithm for 2-dimensional monitor layouts with
a common baseline that all monitors are aligned to.

And examples for this one:

```
             x      ┌──────┐
             ┌──────┤      │
             │  1   │  2   │     x──────┐
             │      │      │     │  1   ├────┐
             └──┬───┴───┬──┘ ──► │      │ 2  │
                │  3    │        ├──┬───┴────┘
                │       │        └──┘3
                └───────┘

       x     ┌──────┬──────┐
             │  1   │      │
             │      │      │     x──────┬──────┐
       ┌─────┴──────┤  1   │     │  1   │      │
       │            │      │     │      │      │
       │            │      │ ──► └──┬───┤  1   │
       │     3      │      │        │ 3 │      │
       │            ├──────┘        └───┤      │
       │            │                   │      │
       │            │                   └──────┘
       └────────────┘

x                  ┌───────┐
┌──────┐           │       │     x         ┌───────┐
│  2   │    ┌──────┤   1   │               │       │
│      │    │  1   │       │      2 ┌──────┤   1   │
└────┬─┴────┴─┬────┴───────┘ ──► ┌──┤  1   │       │
     │        │                  ├──┴┬─────┴───────┘
     │   2    │                  │ 2 │
     │        │                  └───┘
     └────────┘
```

These algorithms will fail for any more complex 2d monitor layout, eg.

```
x   ┌───┬────┐
    │ 2 │ 1  │
    │   ├────┘
┌───┴┬──┘
│ 1  │
└────┘

x───┬───┬───┐
│ 1 │ 2 │ 1 │
├───┼───┼───┤
│ 1 │ 1 │ 1 │
├───┼───┼───┤
│ 1 │ 1 │ 1 │
└───┴───┴───┘
```

In those cases where the conversion failed, we fall back to aligning
the monitors on a horizontal line, preserving the scale, the primary
monitor and the disabled monitors.

Note that we also need to convert the scale factor in some cases,
because LOGICAL layout mode also behaves different here:
When the scale results in a fractional logical monitor size (eg.
the native monitor width is 2560px, and a scale of 3 is set =>
2560px / 3 = 853.333px), in LOGICAL mode we won't use that scale.
Instead we have an algorithm (see
meta_monitor_get_closest_scale_factor_for_resolution()) to find
the nearest fractional scale factor which doesn't result in
fractional logical monitor size. We reuse this algorithm here for
the conversion.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
96791f111a monitor: Move check to limit fractional scales to certain monitor sizes
We'll reuse meta_monitor_get_closest_scale_factor_for_resolution() for the
conversion of monitor configs, and during those conversions, we probably don't
want to impose the same limits to fractional scales that we usually impose.
This means that we can even convert physical layout configs where the user
manually changed to a value higher than what our fractional scale calculations
would allow.

Move this check into the calling function so that it's not imposed by
meta_monitor_get_closest_scale_factor_for_resolution() directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
078d95cc15 monitor: Make function to calculate fractional scale factor public
We'll need this function for migrating from PHYSICAL layout mode to LOGICAL
layout mode soon, so make it public.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
0d23eb1da8 monitor-config-manager: Move verification of logical monitor configs into utils
We'll need these verification utilities in the next commits where we introduce
detection for physical vs logical layout modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
bbb34c2a80 monitor-config-store: Detect unkown layout modes based on the configuration
When there is no layout mode set in a logical monitor config, we currently just
assume the configuration matches the mode that the system expects. This blows
up when the layout mode expected by the system changes (eg. by turning on
"scale-monitor-framebuffers" in mutter): Suddenly configs fail the validation
check and get thrown away.

Since we now can add one configuration for each layout mode to the config store,
we can do better here: Let's only add configurations to the store where we
verified beforehand that the monitor layout is compatible with that mode, either
because we set it ourselves using the <layout_mode> key, or by detecting which
modes the layout is compatible with.

Also update monitor config ifiles to adjust for the new layout_mode, as
they all are assumed to be "logical".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
becee89fb9 monitor-config-manager: Verify more things about logical monitor configs
Verify even more assumptions we make about logical monitor configs:

- Have a more explicit check that the monitor modes in the logical monitor are
all equal

- Complain if scale factor with physical layout mode is fractional

- Make sure that scale factor with logical layout mode actually scales to a
non-fractional width and height

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
a203020c4b monitor-config-manager: Move some things into common file for config utils
We'll need a few of those things from the monitor config store soon, also it's
generally useful to have a prefix which makes it clear where functions are
defined.

So factor some things out into a new monitor-config-utils.c file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
076b3664a3 monitor-config-store: Store and load layout mode for each configuration
Store and load the layout mode for each logical monitor configuration in
monitors.xml by introducing a new <layoutmode> element. The value of the
element can be either "logical" or "physical". The layout mode is also
made part of the monitor configuration key.

Right now this isn't doing a lot:

When no <layoutmode> is found on the config (this is the case with all
existing configs), we'll keep using the layout mode expected by the system,
without updating the config file.

When changing an existing, or introducing a new configuration, we'll now
store the current layout mode with the config though, and load it again
on the next start of mutter. This is still not problematic as long as
mutters expected layout mode doesn't change (eg. by turning on/off
"scale-monitor-framebuffers").

When the expected layout mode of mutter switches between
restarts, the monitor config is now still loaded but remains unused,
and mutter will create (and store) a new one with the other layout mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
de56634fd0 Remove monitor migration support from v1 monitors.xml format
We'll introduce some new migration code with the next few commits to introduce
a layout_mode property in monitors.xml. This will be significantly easier
without keeping around the old monitor migration code, so drop it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
4105827254 monitor-config-manager: Do more verification of logical monitor configs
We have meta_verify_logical_monitor_config() already, and it does a few checks that
meta_verify_monitors_config() doesn't do yet, so let's also call
meta_verify_logical_monitor_config() when verifying the whole config.

We'll rely on this being part of meta_verify_monitors_config() soon, because we'll
stop calling meta_verify_logical_monitor_config() from the config parser.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Jonas Dreßler
72b324d686 monitor-config-manager: Verify the whole monitor layout is connected
We forgot to check whether multiple groups of monitors are actually
all connected with each other, so fix that.

[jadahl: Rewrote algorithm to detect split groups]
[jadahl: Added test case]

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3596>
2024-08-14 13:07:47 +00:00
Carlos Garnacho
2e82a2049f wayland: Register touchpoint info on CLUTTER_ENTER
The first event happening for a new touch will be the CLUTTER_ENTER
event generated when picking it. Use this event for registration of
the touch info, so that MetaWaylandEventHandler.get_focus_surface may
get the right focus surface for the device/sequence on the first try.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3889>
2024-08-14 11:47:01 +02:00
Carlos Garnacho
77b21ef8dc wayland: Only cancel touch when a new event handler takes over
And notably, don't cancel touch when an event handler is being
removed. Touch events are largely unaffected by most Wayland
grabs (pointer constraints, popups), so we might be cancelling
input too early if one of these wayland grabs was effective when
touch interaction began, but stopped sometime between touch updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3889>
2024-08-14 11:47:01 +02:00
Carlos Garnacho
08c903a359 wayland: Ignore touch events in seat default focus handler
Touch events are implicitly grabbed to the surface they began in,
and are not affected by the focus handler. However these events
will appear to come from the core pointer device, which might lead
to the wrong device being updated.

Ignore events with a sequence, since the default focus handler
does not intend to do anything with them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3889>
2024-08-14 11:46:55 +02:00
Daniel van Vugt
c436e7cb17 kms/impl-device: Add/remove deadline timer as required
On a hybrid machine with i915 primary and nvidia-drm (470) secondary,
`meta_render_device_egl_stream_initable_init` calls
`meta_kms_inhibit_kernel_thread` to change from the default 'kernel'
thread type to 'user'. And soon after that it would
`meta_render_device_egl_stream_finalize` because I'm not actually
using that GPU, and calls `meta_kms_uninhibit_kernel_thread`.

So during startup Mutter would default to a realtime kernel thread,
switch to a user thread (which doesn't support realtime), and then
switch back to a realtime kernel thread.

In the middle of all that, while the thread type was 'user' and
realtime disabled, something was invoking `ensure_crtc_frame` which
created a `CrtcFrame` without a deadline timer. Soon after that the
thread type changed back to 'kernel' with deadline timers expected, but
our existing `CrtcFrame` has no deadline timer associated with it. And
so it would never fire, causing the cursor to freeze whenever the primary
plane isn't changing. And the problem was permanent, not just the first
frame because each `CrtcFrame` gets repeatedly reused (maybe shouldn't
be called a "Frame"?).

Now we adapt to switching between kernel and user thread types by adding
and removing the deadline timer as required.

Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/3464
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3950>
2024-08-14 15:50:48 +08:00
Sebastian Wick
82fa9e676a color-device: Don't create colord profiles for virtual monitors
Colord is a system service which will result in a polkit dialog showing
up when connecting a remote session.

We want to get rid of colord eventually anyway, so disconnecting virtual
monitors from colord isn't an issue.

Fixes: f5ce2ddf3c ("color-manager: Create color devices also for virtual monitors")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3942>
2024-08-13 22:10:03 +00:00
Robert Mader
bb55a1e83a compositor-view/native: Add debug flag to force-disable direct scanout
In order to make it easier to test composited paths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3949>
2024-08-13 21:09:50 +02:00
Bilal Elmoussaoui
4ea693bc20 surface-actor: Pass damage area as MtkRectangle
All the corresponding calls ends up creating a rectangle anyways

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3945>
2024-08-13 14:08:48 +02:00
Bilal Elmoussaoui
cbe88c8e71 surface-actor: Replace \r\n with \n
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3945>
2024-08-13 14:08:48 +02:00
Jonas Ådahl
8e2587c197 kms: Don't disarm deadline timer when compositing
If we finish compositing in time, the composited result will be
submitted prior to the deadline timer is triggered, and we'll be fine,
and if not, at least the cursor updates will be smooth, which makes it
appear smoother than not.

There is a risk that this can negatively impact composited updates when
moving the cursor, so make it possible to toggle a paint-debug flag for
now until this has been more tested.

This also mean we need to disarm the deadline timer after handling
update, as there might be a scheduled cursor update pending, but we
already handled it, so disarm the timer.

Here is an illustration of the difference.

In the following scenario, with disarming, the composited frame E, and
the cursor movement C gets presented. With this branch, only the cursor
movement C gets presented.
```
 * A: beginning of composited frame
 * B: begin notification reaches KMS thread
 * C: cursor moved
 * D: calculated deadline dispatch time (disabled with the branch)
 * E: KMS update posted
 * F: KMS update reaches KMS thread
 * G: actual deadline (and with branch and gets committed)
Compositor thread: --------A---------------E---------
                            \               \
                             \               \
KMS thread:        -----------B------C----D---F-G----
```

In the following scenario, by not disarming, the cursor update C will be
presented, and the would-be-delayed composited frame E would be delayed
anyway, i.e. fixing cursor stutter.
```
 * A: beginning of composited frame
 * B: begin notification reaches KMS thread
 * C: cursor moved
 * D: calculated deadline dispatch time (and with branch will be dispatched)
 * E: KMS update posted
 * F: actual deadline
 * G: KMS update reaches KMS thread (and with branch gets postponed)
Compositor thread: --------A---------------E---------
                            \               \
                             \               \
KMS thread:        -----------B------C----D-F-G------
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3184>
2024-08-13 10:09:05 +00:00
Jonas Ådahl
6ec1312384 renderer-view/native: Update deadline evasion each frame
The deadline evasion depends on debug flags, but they are not trackable,
so update the deadline evasion each time we schedule an update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3184>
2024-08-13 10:09:05 +00:00
Daniel van Vugt
4c91616ff2 kms/update: Don't count trivial custom page flips as empty updates
This includes most frames when using EGL_DEVICE.

While it would be nice to skip all update processing in this case,
we can't go quite that far because EGL_DEVICE is still waiting on
page flip callbacks.

Fixes: 27ed069766 ("kms/impl-device: Add deadline based KMS commit scheduling")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3196
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3939>
2024-08-13 13:55:52 +08:00
Daniel van Vugt
cfb2100d40 onscreen/native: Associate the kms_crtc with EGL_DEVICE updates
Although we track updates for EGL_DEVICE, they are often empty because
the primary plane has a custom page flip method. That means there's
no CRTC latched yet, but we do know exactly which CRTC is associated
with the flip. Set it so the update can still be processed.

Fixes: 27ed069766 ("kms/impl-device: Add deadline based KMS commit scheduling")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3939>
2024-08-13 13:53:17 +08:00
Carlos Garnacho
c179bebb70 wayland: Bypass popup grab focus if other handlers are in effect
If other handlers (e.g. DnD) are on top of the popup grab focus, we
may want it to move outside same-client surfaces as the popup grab
specifies.

Check that it is the current handler before making same-client checks,
so that these handlers on top have an opportunity to find other
surfaces, e.g. during DnD from a popup.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1681
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3937>
2024-08-12 13:50:24 +00:00
Carlos Garnacho
22362378ea wayland: Track pressed mouse buttons for popup grabs through modifiers
Move away from tracking presses/releases directly, since there might be
other event handlers on top that might prevent the popup event handler
to fully track all events. The replacement is using event state modifiers,
which will use information set from the backend, and is enough to determine
there's no more pressed buttons without tracking prior event history.

This makes the popup event handler able to interact with other event
handlers that might be on top, and consume button release events for
themselves (e.g. DnD), no longer resulting in a stuck popup grab.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3937>
2024-08-12 13:50:24 +00:00
José Expósito
115b2c1247 wayland/drm-lease: Make MetaDrmLeaseManager::connectors a GList
The relationship between MetaKmsConnector and MetaDrmLease is already
stored in MetaDrmLeaseManager::leased_connectors.

Change the type of MetaDrmLeaseManager::connectors to a GList.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3922>
2024-08-12 10:25:36 +00:00
José Expósito
fc44437876 wayland/drm-lease: Withdrawn leased connectors
As in the protocol definition for wp_drm_lease_connector_v1::withdrawn:

    Sent to indicate that the compositor will no longer honor requests
    for DRM leases which include this connector. [...] Compositors are
    encouraged to send this event when [...] the connector gets leased
    to a client.

Withdrawn the leased connectors and, if they are available once the
lease finishes, advertise them again.

Related to: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/322/

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3922>
2024-08-12 10:25:36 +00:00
José Expósito
fc8b28a2bd wayland/drm-lease: Remove unused function
The meta_drm_lease_manager_get_connector_from_id() function is not used
and a future commit would need to change it.
Remove the unused code instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3922>
2024-08-12 10:25:36 +00:00
José Expósito
5cd15d8aaf wayland/drm-lease: Reset reused variable in loop
The `lease` variable is reused in a loop and might contain values from
previous loop iterations.

Fixes: 4a5fcef38d ("native/kms-lease: Implement leasing out a set of connectors")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3922>
2024-08-12 10:25:36 +00:00
Sebastian Wick
608d66afa5 renderer-view: Set ClutterColorStates from a MetaColorDevice
And stop passing in the color states from the RendererNative. We also
keep the color states updated by listening for changes in the color
device.

The RendererX11Cm has a single view and no mapping to a specific color
device, so we handle the absense of a color device as well and rely on
ClutterStageView to have the default color states.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
a91fd4a72c clutter/stage-view: Move offscreen creation from renderer to view
This allows us to destroy and create a new offscreen dynamically, when
the rotation or color state changes.

An idle gsource with priority higher than CLUTTER_PRIORITY_REDRAW is
used to ensure the an offscreen exists when required without having to
allocate in the redraw process.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
0ed160bc5a stage-view: Move transform from MetaRenderereView to ClutterStageView
This is possible because MonitorTransform is a Mtk type now. It will
allow us to create the offscreens in ClutterStageView.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
243140069c renderer-native: Get the color state for the view from the MetaColorDevice
The color state will eventually not be derivable just from the monitor
configuration alone but the color device will be able to track all of
this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
ccede14a09 renderer: Pass through the monitor to the create_view vfunc
We will want to use the monitor in a later commit and going there from a
logical monitor or output is ambiguous.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
af83233be3 wayland/outputs: Return a monitor instead of a logical monitor
Going from the monitor to a logical monitor is possible but going from a
logical monitor to a monitor is ambiguous.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +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
Sebastian Wick
54b2abfe1b backends: Move monitor_transform_from_orientation to orientation manager
This removes the dependency on MetaOrientation from MetaMonitorTransform
which makes it possible to move MetaMonitorTransform to Mtk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
adf28cad71 tests/x11: Get the right mutter pid and be more verbose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3918>
2024-08-09 08:29:21 +00:00
Carlos Garnacho
ef3de1e58e wayland: Also cancel XDnD drops with no selected target
This is usually an indication of a failed drop operation if the
drop site didn't request any target. Check for this specifically
on XDnD button release, so that we can cancel the DnD operation
right away.

Inspired on a fix from Jonas Ådahl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3821>
2024-08-08 12:38:24 +00:00
Carlos Garnacho
6f2f4c5767 wayland: Fix thinko checking for pointers with pressed buttons
These are bail out paths, so we should ignore pointers with no
buttons pressed. Spotted by Jonas Ådahl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3821>
2024-08-08 12:38:24 +00:00
Carlos Garnacho
fd1d8c778b wayland: Redirect the focus explicitly to the Xdnd drag source
We were relying on the drag source surface to keep receiving events
thanks to it being implicitly grabbed by the button press. This
broke at some point, making the Xdnd drag source unable to keep
directing the DnD operation as it is expected by X11 clients.

To fix this, make the Xdnd MetaWaylandEventInterface stick itself
to the drag source surface keeping the focus of the device driving
the DnD operation, so that the X11 client can still handle events
from it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3511
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3821>
2024-08-08 12:38:24 +00:00
Carlos Garnacho
a4ec154c8b wayland: Add getter for DnD origin surface
This private method will be used in later commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3821>
2024-08-08 12:38:24 +00:00
Sebastian Wick
4bf02746e2 tests/kvm: Use the anonymous git remote to check out the kernel
Otherwise this fails if one can't authenticate to gitlab.freedesktop.org
or is banned there for whatever reason.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3931>
2024-08-08 02:40:58 +02:00
Bilal Elmoussaoui
9c7eafc8c3 clutter/context: Track if accessibility enabled
Currently, we would only disable a11y if a certain flag is passed
but the function is always called with NONE flag. Instead
drop the flag, use a new environment variable for that

That value is then used by actors to short-circuit get_accessible
implementation and return NULL if the accessibility is not enabled

Also clean the other accessibility functions

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3917>
2024-08-07 22:46:16 +00:00
Bilal Elmoussaoui
ec028553d3 accessibility: Set various accessible names
For actors that are created by libmutter itself.
Although, not sure if such names should be translatable?

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3917>
2024-08-07 22:46:16 +00:00
Bilal Elmoussaoui
43f24b03e5 cally: Merge inside Clutter
Only do the build system bits, we would have to rename
the types and expose at least CallyActor as ClutterActorAccessible

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3917>
2024-08-07 22:46:16 +00:00
Bilal Elmoussaoui
7571ae6f05 clutter/stage: Track is_active
Instead of doing that in both MetaStage & CallyStage.
This allows ClutterStage to also emits the relavant acessibility
bits directly without having a roundtrip through Cally

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3917>
2024-08-07 22:46:16 +00:00
Sebastian Wick
e3afa1a1d1 color-device: Apply HDR and colorspace calibration
The color device now updates the white point via a LUT and sets the
colorspace and HDR metadata properties on monitors to get into the
required configuration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:45:26 +02:00
Sebastian Wick
dc6632f19b color-device: Derive color space from monitor calibration
This ignores the white point calibration for now because our color state
isn't expressive enough, yet.

Co-authored-by: Joan Torres <joan.torres@suse.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:45:10 +02:00
Sebastian Wick
357e5c92f2 backends: Let the color manager know about monitor changes earlier
This makes it possible to set monitor/output properties before the stage
views get re-created.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:40:56 +02:00
Sebastian Wick
a539071548 output: Fix minor coding style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:40:56 +02:00
Sebastian Wick
6dc9cab14b backends: Move MetaOutputHdrMetadata from KmsConnector to Output
This makes it independent of the native backend and allows us to use it
in more places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:40:56 +02:00
Sebastian Wick
fefcc6edec color-device: Track the ClutterColorState of the device
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:40:56 +02:00
Sebastian Wick
c123178f1c color-device: Rename signal "updated" to "calibration-changed"
The generic term updated can mean anything. This is specifically about
calibration related updates like changing the sink colorimetry
(Colorspace, HDR metadata) and changes to the white point for night
light etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:40:56 +02:00
Sebastian Wick
f5ce2ddf3c color-manager: Create color devices also for virtual monitors
We will need color devices on all monitors soon.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:40:56 +02:00
Sebastian Wick
431c4d12b9 color-device: Make it possible to outlive the active monitors
Previously the color device was destroyed when it was attached to a
monitor that was going away. However, the MetaMonitor objects are
ref-counted and can stay around for longer, even if the underlying
resources went away. We need color devices for as long as the
MetaMonitors are alive.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:40:48 +02:00
Sebastian Wick
a10b56e946 color-manager: Dispose instead of finalize
Otherwise we'll keep references to color devices for too long.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 16:30:04 +02:00
Sebastian Wick
a50e0a76b6 color-device: Create devices without a ready color manager
Every monitor should eventually have a corresponding color device. To
make sure this can work, we must handle situations where the color
manager didn't connect to colord yet, and thus isn't ready.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 15:53:39 +02:00
Sebastian Wick
25e5c59202 color-device: Avoid roundtrip through manager when assining a profile
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 15:53:39 +02:00
Sebastian Wick
6452c21b85 color-device: Let the device check if it should skip updating
Not everything will require the device to be "ready" (i.e. have a ICC
profile assigned).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 15:53:39 +02:00
Sebastian Wick
8eeec32c90 color-device: Get temperature from the manager
Instead of passing it to the update function. This decouples the
updating from being specifically about the temperature/white point.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 15:53:39 +02:00
Sebastian Wick
682ce3222c color-manager: Rename function to avoid the term gamma
It currently changes the white point using a LUT and will do more things
in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
2024-08-07 15:53:38 +02: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
Daniel van Vugt
a04d90d9e7 backends/native: Avoid duplicating or losing KMS property sets
When triple buffering, `meta_onscreen_native_prepare_frame` for the next
frame is called before `notify_view_crtc_presented` for the previous frame.
So our booleans were unfortunately still TRUE in the second prepare_frame,
resulting in two frames with the same property updates.

When double buffering, having roughly one frame interval between
`meta_onscreen_native_prepare_frame` and `notify_view_crtc_presented`
meant that property updates signalled between the swap and presentation
wouldn't get attached to a KMS update, and would be forgotten when
`notify_view_crtc_presented` resets the flags to FALSE.

To solve these we now keep a separate flag and counter per property,
tracking invalidation and pending updates respectively. The latter is a
counter rather than a boolean in support of triple buffering where two
updates may be pending concurrently (next and posted).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3912>
2024-08-07 04:01:17 +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
Daniel van Vugt
7937f78c7e backends/native: Only warn about cursor sizes once
Because if the current theme has exceeded the dimensions of
`DRM_CAP_CURSOR_WIDTH/HEIGHT` then the warning is just going to repeat
every time the cursor changes. We still fall back to software cursors
just fine so it's not important to repeat the warning.

In Mutter 46 the warning was "Invalid theme cursor size". Same problem.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3597
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3924>
2024-08-06 09:58:44 +00:00
Jonas Ådahl
3c070604dd backend/x11/clutter-backend: Group glib header include correctly
glib.h is not a bundled header, so move it accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3923>
2024-08-05 21:32:38 +02:00
Jonas Ådahl
de76e007b5 cogl: Fix some whitespace issues
The removal of the onscreen template left some function definitions and
declarations incorrectly indented.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3923>
2024-08-05 21:31:43 +02:00
Bilal Elmoussaoui
b684dc0382 clutter/backend: Provide a default get_display implementation
As there is no on screen template checks done on the x11 backend implementation
so simplify that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3915>
2024-08-05 15:47:29 +00:00
Bilal Elmoussaoui
5277e33d37 cogl: Remove no longer used OnscreenTemplate
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3915>
2024-08-05 15:47:29 +00:00
Bilal Elmoussaoui
3b386ba5d7 cogl: Remove no longer used FramebufferConfig
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3915>
2024-08-05 15:47:29 +00:00
Bilal Elmoussaoui
41ec1aa0ca cogl: Remove use_stereo_stage config
Nothing sets it from the X11 backend API, so just get rid of it

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3915>
2024-08-05 15:47:29 +00:00
Daniel van Vugt
e389178180 onscreen/native: Return GErrors from secondary GPU updates
And return early from `swap_buffers_with_damage` if the error would have
led to flipping a NULL buffer.

This is also the perfect time to remove the `egl_context_changed` parameter
and move `_cogl_winsys_egl_ensure_current` closer to the code that actually
needs it.

Related: https://bugs.launchpad.net/bugs/2069565
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3817>
2024-08-02 10:27:54 +00:00
Daniel van Vugt
45a97a5e3f onscreen/native: Set frame result to IDLE on swap failure
So that swap failure messages are not also followed by:

meta_stage_native_redraw_view: runtime check failed: (!META_IS_CRTC_KMS (crtc))

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3817>
2024-08-02 10:27:54 +00:00
Daniel van Vugt
0de83166db onscreen/native: Unify the failure paths of swap_buffers_with_damage
They're both the same and a third one will be added soon.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3817>
2024-08-02 10:27:54 +00:00
Bilal Elmoussaoui
a05caa6338 cogl/texture2d: Rename from_egl_image constructor
Similar to the from_egl_image_external one, to give it the correct
namespace

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
2024-08-01 11:06:33 +00:00
Bilal Elmoussaoui
a9ec604eba cogl/renderer: Expose handle_event
As it was originally the function to be used before
making it private and providing safer wrappers around it for x11/win32.

Nowadays, it is only used in x11 and only internally in mutter, exposing
a 'safer' variant costs us exposing more of x11 renderer APIs without
much benefits.

With this change, the only internal xlib renderer we need from meta is
set_foreign_display which can't be easily worked around

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
2024-08-01 11:06:33 +00:00
Bilal Elmoussaoui
b07c772fc8 cogl: Rename Shader/Program constructors
Otherwise they end up as global functions instead of constructors
of their corresponding types. Helps with better docs

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
2024-08-01 11:06:33 +00:00
Bilal Elmoussaoui
6c1739ea1c cogl: Move get_graphics_status to Context
That is where it belongs & avoids a global function in the docs
when it shouldn't be one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
2024-08-01 11:06:33 +00:00
Bilal Elmoussaoui
97c43f9eec cogl/egl: Move get_egl_display to Context
Allows us to get rid of the extra header

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
2024-08-01 11:06:33 +00:00
Bilal Elmoussaoui
0f405e9270 Rename remaining usages of material to pipeline
material is almost no longer used in the code base and the
few remaining references makes it confusing when looking at parts
of the codebase. So rename the rest as well.

Note that this renames a DeformEffect property and the only extension
making use of it doesn't use the property so i think it is okay to do
so without deprecating the old property for a few releases

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
2024-08-01 11:06:33 +00:00
Bilal Elmoussaoui
5f1ffb5304 cogl: Remove unused Primitive APIs
This also removes a clutter interactive test, but as those
tests don't serve that much any more for being no longer executed..

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3910>
2024-08-01 11:06:33 +00:00
Sebastian Wick
a71166618d clutter/color-state: Create blending ColorState from ColorState
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3905>
2024-07-31 23:36:13 +00:00
Bilal Elmoussaoui
1f255be055 cogl: Properly export required functions by cogl-pango
Needed for moving cogl-pango out of tree

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3909>
2024-07-30 20:20:45 +00:00
Robert Mader
dfa5238bf9 multi-texture-format: Fix limited range quantization
And stop pre-computing values, making errors like this harder to spot.

The values 0.0625 (16/256) and 0.5 (128/256) were slightly off,
resulting e.g. in "black" not being #000000 but #010001 RGB instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3906>
2024-07-29 14:44:42 +00:00
Daniel van Vugt
3eb32cf750 cogl/tests: Avoid floats when converting between int formats
All we need is an intermediate int format with twice as many bits and
to put division at the end to avoid any loss of precision.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3903>
2024-07-26 09:23:46 +00:00
Daniel van Vugt
7df6b5c4ed cogl/tests: Avoid rounding/truncation ambiguity in 8/16bpc conversion
The OpenGL specs say rounding is preferred, but not required. Let's
avoid that uncertainty by choosing a test value that rounds and truncates
to the same integer either way. Only green needs fixing since our red,
blue and alpha values already follow this rule.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3903>
2024-07-26 09:23:46 +00:00
Daniel van Vugt
5360c58fe5 cogl/tests: Avoid converting 16bpc -> float -> 16bpc
Instead just assign 16bpc -> 16bpc

This avoids variations in CPU and GL driver behaviour when using
floats as intermediate values.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3582
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3903>
2024-07-26 09:23:46 +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
Jonas Ådahl
a68385a179 display: Rename mandatory X11 initialization function
Simply to make it clear that the renamed function is specific to a
particular X11 initialization mode (mandatory Xwayland), put that in the
name, so that it's easier to understand when this function is relevant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-07-25 19:56:20 +02:00
Jonas Ådahl
93d1eb01a6 tests/x11: Fix replace test to catch the second instance failing
The test never noticed that the second instance never actually managed
to load; it was looping a multi second retry session trying to redirect
windows, meaning it failed to catch https://gitlab.gnome.org/GNOME/mutter/-/issues/3089.

Fix the test so that it always waits for mutter to finish loading
successfully, just like it waits fro the first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-07-25 19:56:19 +02:00
Jonas Ådahl
2e2dfc0bf5 display: Move X11 initial focus handling to MetaX11Display
It's X11 specific, so put it in the X11 display manager object.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-07-25 19:56:19 +02:00
Jonas Ådahl
f3a33e9bd1 x11-display: Make subwindow redirection call mode specific
This means that for X11 sessions we'll do it before any windows are
mapped, and before any plugin implementation is started. Doing it before
a plugin is started is important, because things that the plugin does
during startup can have consequences on how compositing on Xorg works.

For the Xwayland case, we'll do it relatively in the setup phase. It
appears to have been harmless to do it later in the post-opened signal,
but there is no harm in doing it as one of the earlier steps.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3089
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-07-25 19:56:19 +02:00
Sebastian Wick
682935fefa core/debug-control: Introspect it to export the dbus service with lg
by executing `global.context.get_debug_control().exported = true`.

This makes it possible to get access to the debug service without having
to start with `--enable-debug`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3902>
2024-07-24 21:52:47 +00:00
Sebastian Wick
c974bcf4b2 core/debug-control: Enable HDR only via DebugControl and META_DEBUG_
This removes the experimental HDR property from the monitor manager and
unifies all the debug features in DebugControl.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3902>
2024-07-24 21:52:47 +00:00
Sebastian Wick
2693cac83a clutter/color-manager: Add a method to get the default color state
This avoids re-creating new color states objects to the default state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
2024-07-24 21:33:30 +00:00
Sebastian Wick
b1370a483e clutter/color-state: Add a way to query if fp16 is needed for storage
Some color states, currently only the ones with linear transfer
characteristics, need at least half float formats for storing components
of that color state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
2024-07-24 21:33:30 +00:00
Sebastian Wick
6a2ce066b0 clutter/color-state: Add a helper to print the color state
And use it in MetaRendererNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
2024-07-24 21:33:30 +00:00
Jonas Ådahl
1223f8df68 clutter/pipeline-cache: Return a copy of the pipeline
This means the pipeline can be manipulated after retrieving. This also
fixes a leak when adding pipelines to the cache, as we the pipeline
would take a ref, but when adding, we wouldn't clean up our own ref.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
2024-07-24 21:33:30 +00:00
Jonas Ådahl
3359b67686 clutter/color-state: Handle adding snippet to pipeline
While no functional changes right now, this allows us to add extra hooks
like adding uniforms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3897>
2024-07-24 21:33:30 +00:00
Bilal Elmoussaoui
c65bb3b9ce cogl: Remove poll renderer
As it is only composed of idle callbacks now, replace
those functions where they are used

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3887>
2024-07-24 14:33:29 +00:00
Bilal Elmoussaoui
a7b87f250f cogl/renderer: Always try to use GLX_NV_robustness_video_memory_purge
It was always set to TRUE and mutter is the only user.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3887>
2024-07-24 14:33:29 +00:00
Ivan Kuzmenko
2c5f874eaa orientation-manager: Expose MetaOrientationManager to introspection
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3880>
2024-07-23 17:49:11 +00:00
Sebastian Wick
6d78ff9373 tests/kvm: Update the kernel repo remote to gitlab.freedesktop.org
The drm subsystem has been moving over to gitlab for some time now and
the old anongit.freedesktop.org remote is becoming unusable. Contains
the same repo with the same tags, so this shouldn't result in any
differences.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3896>
2024-07-23 11:10:04 +00:00
Jonas Ådahl
eb786b749c window: Add simpler meta_window_move_resize()
This one hides the place flags and gravity, which is irrelevant in many
places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 21:25:37 +02:00
Jonas Ådahl
c7ddc839f1 window: Only deny focus if mostly overlapped with always-on-top window
Having an always-on-top window affects focus granting logic if the
to be showing window overlaps with any of them. Instead of triggering
the focus denying logic if a new window ever so slightly touches an
always-on-top window to only triggering if it's covered more than 60% by
always-on-top windows.

This is intended to make using always-on-top windows a bit less annoying
and not cause as many unintended focus-on-map denials.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 21:25:28 +02:00
Jonas Ådahl
74f58674e7 window: Don't check always-on-top overlap before placing
When we show a window, we'll check if it overlaps with an existing
always-on-top window with the intention to deny focus. However, we did
this potentially before having placed the window, meaning we effectively
checked as if it was placed at (0, 0), which created unexpected results.

Instead check the overlap state after placing. A window placement test
case is added to verify this works as expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 21:25:24 +02:00
Jonas Ådahl
c68d6c4958 window: Fix minor coding style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
5e36e5aae1 window: Clarify expression for deciding whether to auto-maximize
Calculate areas and store them in descriptively named variables, and
then compare them, instead of doing it all in one go.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
d7daf50d62 window: Move required condition into main if statement in show()
No logical changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
9ebbf83e95 window: Add place flags
Replace a boolean argument and a temporary MetaWindow struct field with
a `MetaPlaceFlag` passed where relevant. This includes
`meta_window_move_resize_internal()` and `meta_window_constrain()`, as
placement may happen during constraining, and also
`meta_window_force_placement()`.

The struct field (denied_focus_and_not_transient) was only ever set in
meta_window_show(), before meta_window_force_placement(), and
immediately unset as a side effect of that. In .._show() we'll always
force placement if the window wasn't already placed, and in
meta_window_constrain(), we'd only ever call meta_window_place() if the
window wasn't already placed, meaning the variable would only ever be
relevant during `meta_window_show()`. Having it as a flag makes that
relationship and temporary state clearer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
f4b79441fa tests/test-runner: Allow tweaking 'center-new-windows' pref
This will allow tests to test placement algorithms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
d8cdc56ec4 place: Remove a couple of comments about X11 roundtrips
It's not relevant in the context where the comment is, and don't need to
be reminded of X11 quirks here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
22533f8454 place: Move and clean up finding relevant windows
Split up the condition a bit, use an auto pointer for a list, and use
current convention for list iteration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
463c7ab989 window: Clean up formatting and naming of stacking adjustment condition
The function checking whether a 'always-on-top' window covers the
showing window now has that in the name, to make it more obvious. That
function was also changed to use the more common way of iterating a
list, and now uses auto cleanup pointers for the list.

The condition itself was updated to follow the current coding style.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Jonas Ådahl
76e044c39d window: Include window title in debug description
Useful to reason about MUTTER_DEBUG=stack logs when using metatests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
2024-07-22 20:59:18 +02:00
Bilal Elmoussaoui
6da869d575 cogl: Move has_feature to Context namespace
That is where it belongs anyways..

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3895>
2024-07-22 13:06:33 +02:00
Daniel van Vugt
21bc7432dc onscreen/native: Squash adjacent switch statements
Because we can. And it's now clearer that `buffer` is only used in
`META_RENDERER_NATIVE_MODE_GBM`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3891>
2024-07-18 17:37:06 +08:00
Daniel van Vugt
c4d0e970dc onscreen/native: Move next_frame storage to later in the function
It won't be used until later when we flip, and in fact assigning
it early could have led to its own assertion failing on the next frame
in the unlikely event that we return with "Failed to ensure KMS FB ID...

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3891>
2024-07-18 17:26:38 +08:00
Jonas Ådahl
288d57f6a5 window: Propagate stickyness across modal dialog chains
While marking a parent window as sticky or non-sticky always propagates
to the children, also propagate to the parents if the dialog in question
is modal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Jonas Ådahl
c079e2696d tests/test-runner: Add (un)set_modal
Ends up calling gtk_window_(un)set_modal() in the client.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Jonas Ådahl
9628806b37 window: Ignoring unmanaging ancestor when finding root
This avoids the following critical warning happening sometimes when a
Wayland client exits taking all its window with it in an arbitrary
order:

    CRITICAL: meta_window_set_stack_position_no_sync: assertion 'window->stack_position >= 0' failed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Jonas Ådahl
d80f1944ef tests: Add tests for stickyness
The test tests how sticky windows and their transient-for dialog windows
behave together.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Jonas Ådahl
b206e146ea tests/test-runner: Add stick/unstick commands
These can be used to toggle the "showing on all workspaces" state.

An assertion for checking stickyness was added too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Jonas Ådahl
559bdefcc7 tests:test-runner: Add 'assert_stacking_showing'
This, in contrast to 'assert_stacking' only checks showing windows. This
is useful when doing workspace tests, where one want to check what
windows are currently visible.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Jonas Ådahl
7b8558ef9a window: Inherit stickyness from parent when becoming transient
When a transient window becomes transient, check if the parent is
sticky, and if it is, make the transient sticky as well. This handles
situations where e.g. a utility dialog (such as search and replace) is
opened on a sticky window, also making the utility dialog sharing the
same stickyness state.

This is also more in line with the semantics of making a window sticky,
where transient would implicitly become sticky as a side effect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Jonas Ådahl
2466b9accb window: Don't switch workspace on sticky transient when activating
If a transient window is sticky (visible on all workspaces) and it gets
activated, we'd call move_worskpace() which would effectively unstick
it, which is rather unexpected. It'd also effectively unstick its parent
as well, due to moving a transient window also moves its descendants and
ascendants.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
2024-07-17 15:25:52 +00:00
Peter Hutterer
d9ead043c7 backends: Add support for tablet tool pressure ranges
Introduced in libinput 1.26 this feature allows restricting the
tablet tool pressure range to a subset of its physical range. The
use-case is either to require some higher-than-usual minimum pressure
before the pen reacts, or lower-than-usual pressure to reach the maximum
logical pressure.

libinput takes a [0.0, 1.0] normalized range which we expose as percent
in the gsettings. The wacom driver doesn't have an exact equivalent but
it has a Threshold setting (range [1, 2048]) that defines when a button
is generated for tip down.

See gsettings-desktop-schemas!84

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3794>
2024-07-16 12:05:13 +02:00
Peter Hutterer
d65c89d8b9 core: Add a MetaToolActionMapper for tablet tools
This mapper hooks into CLUTTER_BUTTON_PRESS/RELEASE events with a
clutter button of zero but a nonzero evcode (e.g. BTN_STYLUS).
It then looks up the available button actions and implements
switch-monitor and keybindings using the MetaTabletActionMapper parent
class.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Peter Hutterer
7e7a9322fa backends: Expose the tool button mapping via InputSettings
Unlike most other schemas the path for a tool requires a bit of
processing (serial number or tablet vid/pid if there's no serial number).
Let's make the tool settings available through the MetaInputSettings
instead of having to duplicate that path composition in the caller.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Peter Hutterer
7ab5a8cf95 backends/native: Handle new stylus actions as zero button events
Stylus actions that don't map into LMR or back/forward are now created
as a clutter button event with a button number of zero. Nothing is
actually done with those events for now, they're just discarded later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Peter Hutterer
829adfcfaa backends/native: Store the stylus actions as actions
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Peter Hutterer
5fdf1fa892 backends/native: Apply stylus button mappings before anything else
For stylus buttons we apply a button mapping, e.g. secondary button ->
right. This mapping was previously applied to the clutter event's evdev
code only, not the actual clutter button. As a result, gnome-shell would
always treat the BTN_STYLUS as middle and BTN_STYLUS2 as right,
regardless of the mapping.

Move the mapping up so we first adjust our evcode, then proceed with
the usual mappings.

Note that this temporary breaks the stylus mapping to Back/Forward which
will be fixed in a follow-up commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Peter Hutterer
ae59acad76 backends/native: Use helper functions to map buttons
Use the helper function for mapping a stylus tool evdev code to a
clutter button code. This fixes a (theoretical) issue - if a tool were
to send any button other than the one we handled those would likely be
BTN_SIDE and friends and we'd likely end up with negative button
numbers. The BTN_TOOL_PEN range is not predicable enough to do any sort
of calculation conversion because things like BTN_TOOL_DOUBLETAP have
specific meanings that aren't actually buttons.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Peter Hutterer
dfcb160321 backends: Add helpers to convert from clutter tool button to evcode
This complements the existing clutter->evdev and evdev->clutter helpers,
but this time for buttons we expect from a stylus tool. We also need to
convert left/middle/right for the Wacom puck/lens cursor tools but that
particular conversion is lossy.

Note that these are more restrictive than the normal codes - if we
get "other" buttons from a stylus we don't really know what they could
possibly map to. So we safely map what looks like buttons from a mouse
but otherwise complain and return zero.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Peter Hutterer
6c77af1493 core: Add a MetaTabletActionMapper as parent of the MetaPadActionMapper
This is prep work for using the same functionality for tablet tools as
well. The new MetaTabletActionMapper takes care of the event bubbling
via the device-added/removed and input-event signals and provides the
helper functions to cycle outputs and/or emulate keybindings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
2024-07-16 09:33:29 +00:00
Sebastian Keller
31e027d1b1 edid: Ensure strings owned by MetaEdidInfo are freed
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3888>
2024-07-16 03:37:02 +02:00
Sebastian Keller
a541aa9a8c edid: Fix di_info leak after we are done parsing
This was only affecting builds using libdisplay-info.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3888>
2024-07-15 23:52:31 +02:00
Bilal Elmoussaoui
f5c376e860 cogl: Move PrimitiveTexture functions to Texture
Since the move to GObject for CoglTexture, CoglPrimitiveTexture was
removed. So drop remaining of that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3885>
2024-07-15 21:42:38 +02:00
Bilal Elmoussaoui
9ee1a0fc34 cogl: Expose Renderer.get_proc_address
Allows to get rid of the cogl_get_proc_address

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3857>
2024-07-15 14:39:23 +00:00
Bilal Elmoussaoui
b3ae934304 cogl: Pass Context to cogl_flush
Avoids using the global variable & also move the function to
it proper context

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3857>
2024-07-15 14:39:23 +00:00
Bilal Elmoussaoui
194fa80cdd cogl: Pass a Context param to winsys_has_feature
Avoids using the global variable

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3857>
2024-07-15 14:39:23 +00:00
Jonas Ådahl
a72ee3be0d cursor-renderer/native: Transform cursor sprite into output color state
This avoids making the cursor too bright when HDR is enabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:59:25 +02:00
Jonas Ådahl
b0e4d7c6ad cursor-sprite: Tag each cursor sprite with a color state
So far, always set a default color state. For Wayland cursors, it will
probably be more dynamic in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:59:07 +02:00
Jonas Ådahl
0bbb78f29e cursor-renderer/native: Pre-process cursor sprite with Cogl
Instead of using cairo for scaling and rotating cursors before putting
them on a plane, use Cogl. For now still download them back to the CPU
so we can place them on a dumb buffer, but can explore rendering to a
DMA buffer directly as a future improvement.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
20c7653d49 compositor-view/native: Don't scan out surface with color state mismatch
If the color state of a surface doesn't match the output, don't try to
scan it out, as it needs to pass through color state transformations to
look correct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
aaba08e5aa Set names of various Cogl pipelines
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
b7291cfe48 shaped-texture: Use color aware rendering
This looks at the color state it got from the actor on construction, and
the target color state from the paint context and generates (and caches)
color aware pipelines used for painting. One of the purposes here is for
mixing SDR and HDR content and painting to a HDR monitor. If HDR (or
optical blending) isn't activated, the produced shaders will be
equivalent to what we had before.

Also add some names to the piplines, as this helps identifying what
pipeline source is associated with what pipeline.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:07 +02:00
Jonas Ådahl
6836a511db shaped-texture: Pass around paint context instead of Cogl context
In some of the places we need more context than just the CoglContext, so
prepare for that by passing around the paint context, which carries
this, everywhere instead. It won't be needed everywhere, but lets stay
consistent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:06 +02:00
Jonas Ådahl
d49bfbc6ec background-content: Fix annotation
The annotations were missing a #MetaDisplay argument.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:06 +02:00
Jonas Ådahl
4238512764 clutter: Introduce color transform aware pipeline cache
Color aware rendering needs shaders / pipelines that adapt to what
output they render to. For example if we want to render to a linear
BT.2020 intermediate framebuffer on one monitor, and a non-linear sRGB
direct target buffer on another, the shader for the same paint node or
content will depend on where they are going to be presented.

In order to help keeping track of what shader should target what
monitor, without having to regenerate them each time, introduce a
pipeline cache that knows how to handle differentiating between
transforming between different color state.

The cache is meant to handle caches for multiple pipeline users, where
each user might potentially want to keep track of multiple pipelines
itself. Lookup should be O(1), and in order to achieve this, separate
the cache into 3 levels.

The first level is the "pipeline group", where e.g. a ClutterContent
type allocates a group where it can store its pipelines. Each group has
a fixed number of "slots" where it can store a pipeline. Each slot has a
hash table where the key is derived from a color state transform, and
where the value is a CoglPipeline where the thame color state
transformation is expected to be handled.

A content will when painting know about its own color state, and the
target state it should render into, retrieve a cached pipeline for the
correct transform, or if the cache didn't have it, generate it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:56:06 +02:00
Jonas Ådahl
0c2fa8e9a8 clutter/stage-view: Add linear intermediate color space buffer
Allow compositing in a linear color space and do so either when forcing
it via the debug controls D-Bus API, or when the experimental HDR mode
is enabled.

This relies on paint nodes etc to actually transform everything into the
linear target color space, which isn't done yet, so enabling it right
now will cause a broken result. Yet, introduce this now, so that
painting can be fixed piece by piece.

Linear blending is automatically enabled on monitors where HDR is
enabled, as this makes it possible to use an linear color space when
blending content from different color spaces with different transfer
functions.

Linear blending requires extra precision, i.e. 16 bit per channel
in the intermediate buffer due how the values are distributed,
so only enable the experimental HDR mode if the Cogl context supports
half float formats.

By default, no intermadiate linear offscreen framebuffer is used.

To test, do e.g.

  ./tools/debug-control.py --toggle ForceLinearBlending

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:55:54 +02:00
Jonas Ådahl
beb3415d7e renderer/native: Use format from onscreen when creating offscreen
This means we'll get the same bit depth etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:51:30 +02:00
Jonas Ådahl
b275af95b7 clutter/paint-context: Add content and target color state tracking
The initial target color state is the color state of the stage view
being painted to. If we're painting to an arbitrary framebuffer, it's
currently hard coded to sRGB/electrical.

The content color state is not set on construction, but when starting to
paint, it's set to the color state of the stage itself. Whenever an
actor is painted, it'll set the color state to the color state of
itself. The intention is that offscreen rendering pushes a target color
state that causes painting to it to not necessarily be in the stage view
color state.

Pass color state with offscreen framebuffer, as this avoids hard coding
sRGB in the lower level bits of paint contexts. It's still practically
hard coded, only that it's derived from somewhere else (e.g. the stage
or window actor).

Nothing is actually using this yet, but will eventually.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:51:30 +02:00
Jonas Ådahl
d7bbc9712f clutter/color-state: Pass the ClutterContext when constructing
This will be used to cache pipeline snippets shared by multiple color
states.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3433>
2024-07-09 18:00:58 +02:00