1
0
Fork 0
Commit graph

2438 commits

Author SHA1 Message Date
Carlos Garnacho
09538422c6 backends: Update idle time after opening the lid
When handling lid state, we used to update the idle time right after
opening the lid. This behavior changed in commit 14b6c8780d due
to a typo/thinko, "if (lid_is_closed)" used to be an early return
condition before updating idle time, now it only updates in that
case.

Restore the original behavior, since this idle time update is key
in having gsd-power light up the display again, this presumably
fixes situations that required extra "light up" hints after suspend.
What it does surely fix is "ninja test" in g-s-d against recent
mutter, since the behavioral change induced a test timeout there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2272>
2022-02-07 16:52:39 +00:00
Jonas Dreßler
38f3bf6ee2 screen-cast/src: Add debug logging when creating buffers
Add some debug logging that allows checking whether we're using DMA
buffers for screencasting or system memory buffers. This can be useful
for debugging screencasting performance and CPU usage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2256>
2022-02-07 13:37:56 +00:00
columbarius
b34ca56cae screen-cast-stream: Check for a modifier in the format negotiation via pipewire
Announce SPA_PARAM_BUFFERS_dataType accordingly if the modifier key
exists in the returned SPA_PARAM_Format.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
columbarius
42047d18b6 screen-cast-stream: Announce support for implicit modifiers
With the ability to query the renderer for DMA-BUF support we can
announce support for implicit modifiers. This allows PipeWire to check
for matching modifiers while negotiation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
columbarius
72aae9d6ac screen-cast-stream: Add push_format_object function
This function is used to build EnumFormat spa_pods for format
negotiation and contains support for modifiers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
Jonas Ådahl
49ac60e346 cogl/renderer: Add 'is_dma_buf_supported()' vfunc
Returns TRUE if the active renderer backend can allocate DMA buffers.
This is the case hardware accelerated GBM backends, but FALSE for
surfaceless (i.e. no render node) and EGLDevice (legacy NVIDIA paths).
While software based gbm devices can allocate DMA buffers, we don't want
to allocate them for offscreen rendering, as we really only use these
for inter process transfers, and as buffers allocated for scanout
doesn't use the relevant API, making it return FALSE for these solves
that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
Daniel van Vugt
c970bb3e6c cogl: Merge FEATURE_ID_GET_GPU_TIME into FEATURE_ID_TIMESTAMP_QUERY
Because both code paths require the existence of `GL_TIMESTAMP[_EXT]`
which is only guaranteed if `ARB_timer_query` (included in GL core 3.3)
is implemented.

We know when that is true because `context->glGenQueries` and
`context->glQueryCounter` are non-NULL. So that is the minimum
requirement for any use of `GL_TIMESTAMP`, even when it is used in
`glGetInteger64v`.

Until now, Raspberry Pi (OpenGL 2.1) would find a working implementation
of `glGetInteger64v` but failed to check whether the driver understands
`GL_TIMESTAMP` (it doesn't).

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2107
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2253>
2022-01-27 22:58:59 +00:00
Jonas Ådahl
b49421d8e8 monitor-config-store: Allow changing D-Bus configuration policy
Adding a <dbus/> element containing a boolean (yes/no) determines
whether org.gnome.Mutter.DisplayConfig ApplyMonitorsConfig will be
callable. The state is also introspectable via the
ApplyMonitorsConfigAllowed property on the same interface.

For example

    <monitors version="2">
      <policy>
        <dbus>no</dbus>
      </policy>
    </monitors>

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
c611b64c53 monitor-config-store: Add way to define config store loading policy
This adds a way to define a way, at the system level, to define a policy
of how monitor configuration files are loaded.

The intended use case is to e.g. either prefer system level monitor
configurations before user levels, or only allow system level
configurations.

Examples:

Prefer system over user level configurations:

    <monitors version="2">
      <policy>
        <stores>
          <store>system</store>
          <store>user</store>
        </stores>
      </policy>
      <configuration>
        ...
      </configuration>
    </monitors>

Only allow system level configurations:

    <monitors version="2">
      <policy>
        <stores>
          <store>system</store>
        </stores>
      </policy>
      <configuration>
        ...
      </configuration>
    </monitors>

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
6c4380ed41 monitor-config-store: Fix incorrect string comparison with empty string
strncmp() always return 0 if the passed length is 0. What this means is
that whatever the first string check happens to be, if the parsed XML
cdata was empty (e.g. if we got <element></element>), the first
condition would evaluate to true, which is rather unexpected.

Fix this by making sure the string length is correct first. Also move it
into a helper so we don't need to repeat the same strlen() check every
time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
b74e99b10b monitor-config-store: Make parsing a bit more forgiving
Allow unknown XML elements inside <monitors>. This makes extending in
the future easier.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
2d7a8c3ce9 kms: Don't enter power saving via updates
The way device backends implement power saving differ, and power saving
needs to contain nothing incompatible in the same update. Make it
impossible to e.g. mode set, page flip, etc while entering power save by
not using MetaKmsUpdate's at all for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
2e774e8e14 tests/kms: Check predicted state is correctly predicted
When we're predicting state, i.e. when having posted an update while
avoiding reading KMS state, copy the predicted state, update the actual
state, and check that the predicted state matches the newly updated one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
2478000c73 kms: Properly predict power saving effect on tracked state
Entering power saving effectively disables CRTCs, and thus the CRTC id a
connector is associated with. Make sure that the tracked state reflects
this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
8ea49fe9d9 kms/connector: Add missing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
0fab55dbc0 tests/kms/device: Add mode setting test
Checks that the relevant device state is correct after mode setting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
feadaacfdd kms/connector: Add getter for preferred mode
This replaces a helper used in tests. The intention is to use it from
other tests, and seemed like a good fit to place it under the KMS
connector object itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
c35e8f5a51 kms: Concentrate update processing in MetaKmsDevice
It was a bit scattered, with it being split between MetaKms and
MetaKmsImpl, dealing with MetaKmsDevice and MetaKmsImplDevice
differentation. Replace this by, for now, single entry point on
MetaKmsDevice: meta_kms_device_process_update_sync() that does the right
thing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
43a1ba3432 tests: Add KMS device tests
As other KMS tests, depends on being DRM master and vkms being loaded.

Currently consists of a sanity check that checks for the expected set of
connectors, CRTCs, planes, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
23a530cb09 monitor-manager/native: Get CRTC gamma from cache if available
Right now gamma is set only via the D-Bus API (from gsd-color), but the
actual gamma isn't right after SetCrtcGamma(), meaning if one would call
GetCrtcGamma() right after setting it, one would get the old result.
Avoid this by getting the "current" CRTC gamma from the cache we manage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
cd517216ae kms/impl-device: Clear fd source on prepare-shutdown
This ensures we won't receive any untimely page flip callbacks during
later phases of shutting down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
4276e9ddd3 tests/kms-update: Add mode setting sanity tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
65073c145c tests/kms: Add basic plane assignment update tests
Test that adding a couple of plane assignments were correctly added to
the update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
758e5e23fa kms/mode: Add width/height getters
This avoids some situations where one would otherwise need to fetch the
drm mode to check the dimensions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
de06d5d9e7 kms/update: Add init helper macros for fixed 16 rects
META_FIXED_16_INIT(), taking MetaFixed16's, and META_FIXED_16_INIT_INT()
taking integers, converting them to MetaFixed16.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
acd51a7e69 tests: Add some basic MetaKmsUpdate unit tests
Mostly rudimentary sanity testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
bf398a5f84 kms/update: Add getter for cursor plane assignment
To be used in tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
501b6f52d3 monitor-manager/native: Fix include macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Marco Trevisan (Treviño)
8cf3485ab0 monitor-manager: Notify privacy screen changes on hotkey press
When privacy screen is changed and this happens on explicit user request
(that is not a setting change) we should notify about this via an OSD.

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

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

Fixes: #2105
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
47d7bc7a13 backends/kms: Implement privacy screen handling and setting
Privacy screen events on connector are handled as notification events
that won't cause any monitors reconfiguration but will emit monitors
changed on DBus, so that the new value can be fetched.

We monitor the hardware state so that we can also handle the case of
devices with hw-switchers only.

In case a software state is available it means we can also support
changing the state, and if so expose the state as unlocked.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
4b0a10c562 backends/kms/update: Add ability to remove result listeners
We may need to remove a result listener once we've added it, and before
that it ha been processed, so add support for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
fd1f6094c9 monitor-manager: Expose the privacy screen state on DBus current state
Expose each monitor state as two booleans, not to expose the whole flags

Related-to: GNOME/gnome-control-center#909
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
f96a167aea monitor-manager: Apply privacy monitor settings on changes
When both a setting change and a monitor change happens we need to
ensure that the monitor settings are applied.
This is currently only related to privacy settings, but will in future
also handle other monitor parameters such as brightness.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
55469fda78 settings: Read desktop privacy settings and monitor privacy-screen option
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
f231672084 monitor: Add support to privacy screen
Some monitors support hardware features to enable the privacy screen
mode that allows users to toggle (via software or hardware button) a
state in which the display may be harder to see to people not sitting
in front of it.

Expose then this capability to the monitor level so that we can get its
state and set it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Sebastian Wick
8ebdae8092 launcher: Use $XDG_SESSION_ID if available
In some cases mutter is started in the user scope from a TTY (for
example using toolbox). Using sd_pid_get_session fails because it's not
in the session scope so it falls back to the primary session
(sd_uid_get_display). We want to start mutter on the TTY we started
mutter on however. Instead of relying on the scope to figure out the
correct session we first look at $XDG_SESSION_ID which is set by
systemd_pam.so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2254>
2022-01-24 18:09:44 +01:00
Michel Dänzer
5127f7df56 native/cogl-utils: Add 10 bpc format support
Avoids assertion failure in meta_drm_buffer_gbm_fill_timings with direct
scanout of a 10 bpc EGL client surface (which works now with dma-buf
feedback).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2230>
2022-01-17 10:39:13 +00:00
Daniel van Vugt
6673fbcf68 onscreen/native: Remove a goto in DisplayLink fallback
At first glance the `goto` looks like a loop, or potentially an infinite
loop. It's not a loop because the mode has changed at that point to
`META_SHARED_FRAMEBUFFER_COPY_MODE_PRIMARY`. But we can make it more
obvious and avoid the need for a goto.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2240>
2022-01-17 10:03:17 +00:00
Jonas Ådahl
35fa75a085 clutter/backend/x11: Remove stray whitespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
e4e0eaac9d clutter/backend/x11: Stop keeping track of the screen and root window
They are now only ever accessed via the actual X11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
cf00ee9724 stage/x11: Get root window from the X11 backend
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
c41d2a17da xkb-a11y/x11: Get X11 display from X11 backend
Instead of from ClutterX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
4622bd7ca8 xkb-a11y/x11: Cleanup include macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
7851e69bbf virtual-input-device/x11: Get X11 display and screen from X11 backend
Instead of from ClutterX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
d796c40156 seat/x11: Get root window from X11 backend
Instead of going via ClutterX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
b1fb8cbf57 backend/x11: Add API to get the X11 screen
Will be used to replace a similar ClutterX11 API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
440359e85f virtual-input-device/x11: Cleanup include macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
39e1d5a214 stage/x11: Fetch the X11 display pointer from the X11 backend
This eliminates going through the clutter backend singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
5eae0c84ed stage-impl: Change the backend pointer to MetaBackend
A pointer to the real backend is more useful, so lets use that. This
affects various places that now need to fetch e.g. the clutter backend
via the real backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
c0fb52cfe6 stage-impl: Move properties from the stage window here
The stage window is an interface, that added properties, that were only
then actually managed by MetaStageImpl. Shuffle things slightly, and let
the MetaStageImpl object deal with these things itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
ed112fe0c6 keymap/x11: Store a MetaBackend pointer instead of ClutterBackend
What the keymap eventually is after, are things handled by the actual
backend (MetaBackendX11), so let it keep a pointer to that. This
eliminates some usages of globals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:50 +01:00
Jonas Ådahl
eae1e532dd seat/x11: Make clutter backend variable naming more consistent
Name ClutterBackend pointers clutter_backend. That'll make things less
confusing when mixed with MetaBackend pointers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
fc3b80fc60 input-device/x11: Get X11 state from the X11 backend
Go directly to the X11 backend to get the root window and X11 display
connection. This eliminates some uses of clutter globals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
05b655e60f seat/x11: Add API to get backend
Will be used instead of going via globals by places that already has a
seat to fetch things from.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
dfbe97a8e5 backend/x11: Add API to get the root window
Will later be used from here instead of via the clutter backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
6f80c1e7b5 seat/x11: Keep a pointer to the backend
This adds a pointer to the backend and replaces places that fetched
backend resources via globals (mostly via clutter).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
585befbf7d tests: Add test for constraining pointer on hotplug
It tests that if we go from (x is the pointer cursor)

    +--------+
    |        |
    |     X  |
    +--------+

to
             +----------------+
             |                |
             |                |
    +--------+                |
    |        |                |
    |     X  |                |
    +--------+----------------+

i.e. making sure that X ends up somewhere within the logical monitor
region.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Carlos Garnacho
5e3f89e342 backends: Do not try to move pointer onscreen in common code
This is now handled inside the input thread in the native backend,
and X11 has always done something similar to this. This common code
is no longer necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Carlos Garnacho
70e44c281c backends/native: Ensure pointer is onscreen in input thread
It's slightly racy to have the main thread update the views and warp
the pointer, since the input thread may not be aware yet of the new
viewport layout.

Make the input thread clamp the pointer so it remains onscreen
instead, when the new viewports are obtained.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/64
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Jonas Ådahl
1cc786ffd3 launcher: Pass fallback session/seat ID when in test mode
When we test, we might not have a systemd session to rely on, and this
may cause some API we depend on to get various session related data to
not work properly. Avoid this issue by passing fallback values for these
when we're running in test mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
8b628f0ae4 launcher: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
c8c9d49f79 Add rudimentary mode setting test
Add a test that uses vkms to test that mode setting works, and that
rendering works. It renders 10 frames in a row after mode setting, then
exits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
124a1582e1 native: Replace 'headless' property with 'mode' property
There will be another mode added later, 'test'; prepare for this by
changing the existing "mode" boolean ('headless') to a mode, which is
either 'default' or 'headless'. Checking the is_headless variable is
changed to using the function is_headless(), except for one place, being
VT switching, which in preparation is only allowed on the 'default'
mode. Other places where it makes sense, the conditions are changed to
switch statements.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
719a6c0006 egl: Don't set an error when there is none
Some API will return NULL or the equivalent; sometimes it's an error,
and sometimes it's not, and the way to check that is by looking at the
return value of eglGetError(). When we check this, don't set the GError
if it returned EGL_SUCCESS, as that indicates that the return value is
expected behavior, and not an error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Carlos Garnacho
e9addb0ad7 clutter: Add ClutterSeat private API to grab devices
This will be necessary to string along ClutterGrab with backend
behavior, and mostly for the X11 backend so implement this pair
of vfuncs there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Jonas Ådahl
bb6ae40a0f onscreen/native: Always free the next framebuffer on dispose
There was a sanity check that complained if there was still a "next
framebuffer" when disposing an onscreen. This is correct to complain
about under normal operation, as we always wait until receiving the page
flip callback before cleaning up the onscreen and their state.

However, when there are many hotplugs occurring, we might end up with
race conditions when the above sanity check is not valid: when we have
more than one monitor active, paint 1 one of them, but receive a hotplug
event before we paint the other(s), we will discard the already painted
onscreen before really issuing a page flip.

In this situation, we will have the "next framebuffer", but having that
is not a bug, it's a race condition, thus to not leak in this situation,
make sure to clean up the next framebuffer here too.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2081
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2225>
2022-01-09 23:03:02 +00:00
Jonas Ådahl
8e91c6295d renderer/native: Clear old KMS updates on views rebuild
If there are any pending updates, for example if we painted one of
multiple monitors but without having posted the update due to waiting
for another monitor to be painted, but before we paint all of them and
post the update, another hotplug event happens, we'd have stale pending
KMS update. When that update eventually would be processed, we'd try to
apply out-of-date updates which may contain freed memory.

Fix this by discarding any update when we're rebuilding the views. We
can be sure not to need any of the old updates since we're rebuilding
the whole content anyway.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1928
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2216>
2022-01-09 22:34:16 +00:00
Robert Mader
af08847126 Revert "backends: Don't include damage history in swap region"
This reverts commit a82dd68605.

It causes severe issues in multi monitor setups - lets back
out for now and reland a fixed version later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2220>
2022-01-08 16:01:24 +01:00
Erico Nunes
a82dd68605 backends: Don't include damage history in swap region
Following the EGL_KHR_swap_buffers_with_damage specification, the
surface damage used by eglSwapBuffersWithDamage does not need to
contain the damage history.
Rework that to reduce the amount of rectangles that get passed to
the backend.

Also rework some of the regions that were using fb_clip_region and
missing the last scaling to support fractional scaling.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2089>
2022-01-07 21:53:09 +00:00
Georges Basile Stavracas Neto
77d5c8c928 screen-cast/monitor-stream: Immediately record scanout frames
When the before-paint function is executed, it's only purpose
is to check if there's any scanout queue, and immediately
record it if any.

However, since [1], we regressed in this specific case with the
introduction of an idle callback in the before-paint function.
The regression only happens when the PipeWire stream is using
DMA-BUF buffers, and it would operate as follows:

 1. In before-paint, when there's a scanout available, we queue
    an idle callback to capture the monitor. The idle callback
    (almost always) executes after the scanout is pulled from
    the stage view

 2. meta_screen_cast_stream_src_maybe_record_frame() is called
    by the idle callback. In the DMA-BUF case, it then runs
    meta_screen_cast_monitor_stream_src_record_to_framebuffer()

 3. In meta_screen_cast_monitor_stream_src_record_to_framebuffer(),
    because the stage view doesn't have a scanout anymore, it
    ends up calling cogl_blit_framebuffer() with the stage view
    framebuffer. This is the regression bug.

This regression presents itself in the form of the screencast
stream showing the desktop when there's an unredirected fullscreen
application window running.

Revert before-paint - and only that - back to immediately capturing
any available scanout. Only record these frames when the target
buffer is a DMA-BUF handle. Nothing is captured on before-paint if
the stream is not using DMA-BUF, since the regular paint routine
will handle these frames regularly post-paint.

[1] https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2186>
2022-01-07 19:59:36 +00:00
Georges Basile Stavracas Neto
8fe45d7750 screen-cast/stream: Add DMABUF-only record flag
Next commits will reintroduce a certain behavior of stage
capturing that can only happen with DMA-BUF buffers. To
control this, add a new flag tp MetaScreenCastRecordFlags
for this behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2186>
2022-01-07 19:59:36 +00:00
Jonas Ådahl
8a2fcf3be0 wayland: Use new KMS update test API to try acquiring scanout
This significantly increases the chance of a fullscreen surface buffer
being scanned out instead of being painted via composition. This is
assuming the client supports the DMA buffer feedback Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
a14923e993 kms: Add update test API
This API can be used to construct a MetaKmsUpdate with plane assignments
that in isolation will be tested against the current KMS state. How it
is tested depends on the KMS implementation; in the simple / legacy KMS
backend, the tests are identical to the current scanout requirements
(dimension, stride, format, modifiers, all must match), and with atomic
KMS, it uses the TEST_ONLY on a real constructed atomic mode setting
commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
7ce481bf69 egl: Add eglQueryDisplayAttribEXT() helper
To be used to fetch the EGLDevice used for an EGL display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Robert Mader
6d1bd87b32 egl: Fix code style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Jonas Ådahl
ae086a31dd device-pool: Remove duplicate include macro
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:24:36 +01:00
Robert Mader
36481b8d21 gen_default_modes: Add more refresh rates to fallback modes
Refresh rates >60Hz become ever more common. In order to allow users
to keep hight refresh rates when not running at a natively advertized
resolution, add common refresh rates to our fallback modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2189>
2022-01-03 10:48:29 +00:00
Robert Mader
fb9564b87b output/kms: Filter out duplicate fallback modes
Right now we often add a duplicate fallback mode that's almost
identical to the native mode. This adds unnecessary clutter to
UIs, thus filter out such modes.

In order to keep the code small, use `MetaCrtcModeInfo` directly
instead of recalculating the values. And to keep consistency, do
the same in the loop above.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2189>
2022-01-03 10:48:29 +00:00
Robert Mader
60d7cd82ba crtc-mode-xrandr: Take RR_DoubleScan and RR_Interlace flags into account
Otherwise we often advertise wrongly calculated modes.
Original patch from Jonas Ådahl and the xrandr project.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2190>
2022-01-02 21:10:31 +00:00
Sebastian Keller
97dd5d8877 backends/x11: Fix memory leak in meta_x11_handle_event()
The event was leaked after it had been processed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2192>
2022-01-02 12:36:30 +00:00
Jonas Ådahl
fc1de74442 cursor: Hold reference to cursor tracker
This is so that it can unregister from it on tear down. The tracker owns
references to cursors too, but this cycle is already broken as the
backend calls 'g_object_run_dispose()' when tearing the cursor tracker
down.

Fixes a crash on shutdown.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2181>
2021-12-22 19:37:16 +01:00
Jonas Ådahl
287908e05a renderer/native: Don't clear GPU data with pending page flips
An incorrect assumption that after mode set there would be no pending
page flips was made. This meant that if there was a mode set, followed
by a page flip, if that page flip was for a CRTC on a now unused GPU,
we'd crash due to the renderer GPU data having already been freed. This
commit avoids that by keeping it alive as long as the page flips are
still in the air. It fixes crashes with backtraces such as

  0) meta_render_device_get_egl_display (render_device=0x0)
     at ../src/backends/native/meta-render-device.c:320
  1) secondary_gpu_state_free (secondary_gpu_state=0x1c8cc30)
     at ../src/backends/native/meta-onscreen-native.c:560
  2) meta_onscreen_native_dispose (object=0x1cb65e0)
     at ../src/backends/native/meta-onscreen-native.c:2168
  3) g_object_unref (_object=<optimized out>)
     at ../gobject/gobject.c:3540
  4) g_object_unref (_object=0x1cb65e0)
     at ../gobject/gobject.c:3470
  5) clutter_stage_view_finalize (object=0x1cbb450)
     at ../clutter/clutter/clutter-stage-view.c:1412
  6) g_object_unref (_object=<optimized out>)
     at ../gobject/gobject.c:3578
  7) g_object_unref (_object=0x1cbb450)
     at ../gobject/gobject.c:3470
  8) meta_kms_page_flip_closure_free (closure=0x1d47e60)
     at ../src/backends/native/meta-kms-page-flip.c:76
  9) g_list_foreach (list=<optimized out>, func=0x7fb3ada67111 <meta_kms_page_flip_closure_free>, user_data=0x0)
     at ../glib/glist.c:1090
 10) g_list_free_full (list=0x1cb4d20 = {...}, free_func=<optimized out>)
     at ../glib/glist.c:244
 11) meta_kms_page_flip_data_unref (page_flip_data=0x1c65510)
     at ../src/backends/native/meta-kms-page-flip.c:109
 12) meta_kms_callback_data_free (callback_data=0x227ebf0)
     at ../src/backends/native/meta-kms.c:372
 13) flush_callbacks (kms=0x18e2630)
     at ../src/backends/native/meta-kms.c:391
 14) callback_idle (user_data=0x18e2630)
     at ../src/backends/native/meta-kms.c

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
4159c76a5b cursor-renderer/native: Clear GPU state before closing device
This ensures we don't have any left over cursor GPU buffers (via
gbm_bo's) after destroying the corresponding gbm_device (owned by
MetaRenderDevice).

Fixes crashes with backtraces such as

  1) meta_drm_buffer_gbm_finalize at ../src/backends/native/meta-drm-buffer-gbm.c:450
  4) invalidate_cursor_gpu_state at ../src/backends/native/meta-cursor-renderer-native.c:1167
  9) update_cursor_sprite_texture at ../src/wayland/meta-wayland-cursor-surface.c:70
 10) meta_wayland_surface_role_apply_state at ../src/wayland/meta-wayland-surface.c:1869
 11) meta_wayland_surface_apply_state at ../src/wayland/meta-wayland-surface.c:832
 12) meta_wayland_surface_commit at ../src/wayland/meta-wayland-surface.c:993
 13) wl_surface_commit at ../src/wayland/meta-wayland-surface.c:1158
 14) ffi_call_unix64 at ../src/x86/unix64.S:76
 15) ffi_call at ../src/x86/ffi64.c:525

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
ada524265f backend: Return NULL cursor renderer if there is no seat
During tear down, if anything teared down after the seat tries to get
the cursor renderer, we'd crash trying to get it as the seat would
already be gone. Avoid this by returning NULL when there is no seat.

It's assumed that any path that will happen during tear down that relies
on getting the cursor renderer will gracefully handle it not being
present, e.g. by relying on the cursor rendering cleaning up itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
c87779f62e cursor-tracker: Add missing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
25ed64b61d cursor-sprite: Register all cursor sprites with the cursor tracker
This will later be used to invalidate GPU state when closing device
nodes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Olivier Fourdan
56939abd2f cursor-renderer/native: Add a means to disable HW cursors
When dealing with a faulty hardware or bugs in the driver, it might be
interesting to force the use of software cursors for debugging purposes.

Add a debug environment variable MUTTER_DEBUG_DISABLE_HW_CURSORS to
disable hardware cursors and force using software cursors.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2046
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2150>
2021-12-20 10:41:28 +00:00
Hans de Goede
cc9bb7c516 monitor-manager: Fix orientation changes on devices with 90° mounted panels
Commit 2289f56112 ("monitor-manager: Don't apply unneeded orientation
changes") added an early return to handle_orientation_change () in case
the transform is unchanged.

But this did not take the correction of the transform for devices
with 90° mounted panels into account causing a desired orientation
change to get skipped if the new orientation matches the corrected
logical orientation from the previous transform setting.

Fix this by calling meta_monitor_crtc_to_logical_transform () on the
transform before comparing it, matching the
meta_monitor_crtc_to_logical_transform () call in
create_for_builtin_display_rotation ().

Related: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2090>
2021-12-20 10:08:13 +00:00
Jonas Ådahl
3602762a18 tests/wayland-unit-tests: Add test case for remapping popup with subsurface
This test reproduces the crash in
https://gitlab.gnome.org/GNOME/mutter/-/issues/1828. It does not
reproduce with 'window-actor/wayland: Remove subsurface actors on
dispose' (dd416dd3e2). applied. This test case differs slightly
from the one that came with the dd416dd3e2 as in that it uses
withdrawn popup surfaces instead of explicitly client managed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
José Expósito
2e8aef6f8a backends/native: Refactor LIBINPUT_EVENT_POINTER_AXIS handling
Move the logic to handle LIBINPUT_EVENT_POINTER_AXIS events to its own
function (handle_pointer_scroll).

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
Jonas Ådahl
d43cc776ef renderer/native: Allow forcing EGLStream backend
The GBM support in the NVIDIA driver is fairly new, and to make it
easier to identify whether a problem encountered is related to using GBM
instead of EGLStreams, add a debug environment variable to force using
EGLStream instead of GBM.

To force using EGLStream instead of GBM, use

    MUTTER_DEBUG_FORCE_EGL_STREAM=1

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2045
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2132>
2021-12-08 15:47:35 +00:00
Carlos Garnacho
eda7588190 backends: Replace MetaCursorSprite::prepare-at with in-place function
Since this signal is in a hot path during input handling, it makes sense
not to have this be a signal at all, currently most of the time spent in
it is in GLib signal machinery itself.

Replace it with a function/user data pair that are set on the sprite
itself. Only the places that create an sprite are interested in hooking
one ::prepare-at behavior per sprite, so we can do with a single pair.

This makes meta_cursor_sprite_prepare_at() inexpensive enough.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
8310766845 backends: Upload xcursor texture only after invalidations and theme changes
Make realize_texture() return FALSE for the situations that we do not need
to push again the cursor texture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
508c08fa09 backends: Only reload sprite cursor on changes
Let the meta_cursor_sprite_realize() function return a boolean value
telling whether there was an actual change in the sprite cursor. E.g.
the surface/icon for it changed in between.

This is used in the native backend to avoid converting/uploading again
the cursor surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
49045b2ab9 backends: Remove superfluous intermediate variable
Having this intermediate variable is not of much use anymore, remove
it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
35b8346a33 backends/x11: Use clutter_do_event() for event delivery
It'll do some things that will be no longer optional here. So don't
avoid this step towards event emission.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Jonas Ådahl
70c6d28fca ScreenCast: Allow recording new streams on active sessions
This is useful if you have a session, and want to "hot-plug" new sources
over time; there is no point in having to create separate sessions for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2131>
2021-12-07 19:23:52 +00:00
Jonas Ådahl
764c75d2fb screen-cast-session: Add is-active tracking
Will be used to determine one can start a new recording or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2131>
2021-12-07 19:23:52 +00:00
Joan Torres
754c834590 Add method to show if in headless mode
MetaBackend can now show whether it is in headless mode or not
using a vfunc is_headless.

Fallback of is_headless returns FALSE.

MetaBackendNative implements is_headless returning its
is_headless property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2130>
2021-12-07 16:03:10 +00:00
Carlos Garnacho
67a27a82d9 backends: Do not exclude devices from an output based on capability
This is a strange thing to do since MetaInputMapper also does take care of
devices with an output configured through settings, since we might have
devices that were configure through settings exclude other devices that
belong together with an output (e.g. a display-integrated tablet).

This was essentially here as a last resort to avoid matching two very
similar looking tablets to one of two very similar looking outputs. There
was a 50% chance already that the choice was wrong, and now these devices
can all be configured specifically through settings, so this shouldn't
be missed either.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2107>
2021-12-07 14:59:57 +00:00