1
0
Fork 0
Commit graph

9941 commits

Author SHA1 Message Date
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
Robert Mader
c498ae337f wayland/surface: Do not uncoditionally process surface damage
Most clients nowadays switched to buffer damage, most notably Mesa
and Xwayland. Thus lets avoid the extra cost of allocating three
`cairo_region_t`s and doing some calculations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
c166811695 wayland/surface: Use correct default viewport for surface damage
If no viewport is set, the neutral viewport is the surface size
without viewport destination size applied - i.e. transform and
scale applied to the buffer size. Change it accordingly, giving
us the same values we'd return in `get_width` in this case.

As result, this only changes cases where a viewport destination
size but no viewport source rectangle is set.

The change fixes exactly such cases, e.g. the Gstreamer Wayland
sink. Can be tested with: `gst-play-1.0 --videosink=waylandsink`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
f4717d0ac5 wayland/surface: Switch order for calculating surface damage
Process surface damage in the right order, simplifying the
calculations.

No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +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
Marco Trevisan (Treviño)
65df817096 monitor-unit-tests: Check orientation changes with transformed panels
Ensure that orientation changes still work as expected when using a
panel that has some native transformation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2090>
2021-12-20 10:08:13 +00:00
Marco Trevisan (Treviño)
54b36d77ab monitor-unit-tests: Take panel orientation transform in account
When checking panel orientation on logical monitors we should take
panel orientation transform to check it's properly applied, so ensure
that we're checking the right one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2090>
2021-12-20 10:08:13 +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
Robert Mader
6204769fdb surface-actor: Fix unobscurred_fraction calculation
This calculation wrongly applied a `x2 - x1` pattern.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2169>
2021-12-19 23:46:11 +01:00
Jonas Ådahl
0df12ebee6 xwayland: Don't remove /tmp/.X11-unix/X0 when running tests
When Xwayland was not initalized, we'd still clean things up. What this
accidentally meant was that the uninitialized display number 0 was
cleanud up, which very likely was main display of the host session.

What this meant in practice was that /tmp/.X11-unix/X0 was often
removed, causing every Flatpak X11 application to fail to start until
Xwayland was restarted nad the X0 socket file was restored.

Fix this in two ways: firstly only shutdown Xwayland if we ever started
it, i.e. if the X11 display policy was not 'disabled'. This should fix
the issue most of the times. Secondly only clean up the socket if it was
ever initialized. This should fix things if the socket creation failed,
as if it did, the name would be set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2162>
2021-12-19 16:52:45 +00:00
Jonas Ådahl
75d8fedcf5 tests/wayland/xdg-apply-limits: Uncomment assert
The test driver is needed for the test, so assert it was found.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
6613c24f1a tests/wayland/xdg-apply-limits: Add missing whitespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
618cc5050b tests/wayland-unit-tests: Fix some style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +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
Jonas Ådahl
8a43123765 xdg-shell/popup: Reset 'dismissed-by-client' state when remapping
A popup surface can be remapped multiple times using the same
wl_surface, if a new xdg_popup object is created. To properly handle
this, we need to reset the 'dismissed_by_client' boolean to false, as
otherwise we won't allow new buffer commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
41e426af10 tests/wayland-unit-tests: Clean up toplevel_apply_limits() signal handler
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
ed4e532690 tests/wayland-test-driver: Add sync event
Will be used to signal test cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
a1d5c96e86 unit-tests: Print error when configuring context
More helpful than an assert.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
d8521ffc56 tests/wayland-test-driver: Add surface argument to sync_point request
Will allow more "specific" sync points; will be used in the future by
new tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
ed677f49ff context/test: Let g_test_init() consume argc/argv first
This allows passing e.g. -p /path/to/test to test executables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
d111c47c88 tests/wayland-unit-tests: Change to use headless backend
Change to use the headless backend with a virtual monitor, instead of
the nested backend. This means tests can create and use virtual input
devices, which isn't possible with the nested backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
7992b46566 tests/invalid-xdg-shell-actions: Avoid flakyness
The roundtrip in the handle-configure function could in theory (and in
practice in the future) happen to receive another configure event. If we
send yet another invalid geometry the second time, we log one time too
many in the server, which fails the test. Avoid this by ignoring the
second configure event; it's enough to pass through the error handling
path once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
4469042e2a workspace: Downgrade abort() to a warning when getting index
Instead of crashing on invalid input, just log a warning and return -1.
This will hopefully result in less abort():y behavior with missbehaving
Javascript code.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4203
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2134>
2021-12-19 15:16:12 +00:00
Florian Müllner
525cb7e10e display: Add meta_display_list_all_windows()
We now have a use case in gnome-shell for getting a list of all
windows (including OR ones), but the existing API is private.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2163>
2021-12-16 16:35:15 +00:00
Florian Müllner
3643e0ba1e events: Bypass windows with modal transients
The expected behavior for modal dialogs is that the user
cannot interact with the parent window. However toolkits
like GTK and Qt can only implement that behavior for windows
within the same process.

Address this by enforcing that behavior in the compositor to
get "foreign" windows and other toolkits behave consistently.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>
2021-12-14 18:23:23 +01:00
Florian Müllner
ccf6bbc673 window: Add has_modals() function
We'll soon use that to enforce modal behavior for foreign transient
windows. It'll only be used inside mutter (for the time being), so
keep it private for now.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>
2021-12-14 18:23:23 +01:00
Florian Müllner
40d9d26229 window: Add has_attached_dialogs() function
We currently only expose a function to check whether a window *is* an
attached modal dialog, not whether it *has* any.

The latter is interesting as well, but the code currently lives in a
gnome-shell helper function. Mutter is in a better position to filter
out unmanaging windows though, so add corresponding API.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>
2021-12-14 18:23:23 +01:00
Florian Müllner
844445b807 window: Fix up comment
Whoops, someone sneaked in a stray verb ...

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>
2021-12-14 18:23:23 +01:00
José Expósito
cea5c47671 wayland/pointer: Return on scroll without client
Return early from handle_scroll_event if no client is focused to avoid
redundant calculations.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
José Expósito
d703ba56c3 wayland/pointer: Call wl_resource_get_version once
Call wl_resource_get_version once for each pointer resource.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +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
Carlos Garnacho
d2998a8e41 wayland: Check keyboard serials for activation
We are using internal API that has the benefit of checking that the
focus surface still matches, but has the drawback that it does not
check the MetaWaylandKeyboard state.

In order to fix this, look for keyboard focus and serial matches
specifically when triggering activation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2148>
2021-12-13 14:49:14 +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
Georges Basile Stavracas Neto
87a66830dc cogl: Drop cogl-wayland-server.h
This header only defines one function that doesn't exist anymore,
and nothing else. It can be safely dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2145>
2021-12-07 18:34:00 -03:00
Jonas Ådahl
3eeecd42b0 tests/dbus-runner: Don't log to a loose ended pipe
We created pipes for the stdout of the spawned mock services. This
resulted in the pipe being filled if enough things were logged, as
nothing was reading from it. Change this to allow for two modes:
verbose - where output is logged to the parent stderr, as well as non-verbose
(default) - where things are logged directly to /dev/null.

This fixes frozen tests when running with --repeat and a high enough
repeat count.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2139>
2021-12-07 20:33:26 +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
5e93708d86 wayland: Mark sprite as invalid after cursor changes
This will be used to hint the backend that the cursor surface
might need uploading again.

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
Carlos Garnacho
a7fc74032e tests: Ensure pointer entered the stage at actor-event-hold test
This test is injecting input events without checking the correct stage/
device state. Wait for the pointer to enter the stage, so the event gets
correctly forwarded across.

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
Jonas Ådahl
3c1f50a85e Move D-Bus interface files to dedicated directory
Place the XML files in data/dbus-interfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2126>
2021-12-07 18:52:29 +00:00
Jonas Ådahl
d459df9a28 tests/test-client: Log to stderr
The test-client reports command results to stdout, so make sure to log
e.g. debug messages to stderr, so they don't interfere with the result
test-runner reads.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/450
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2095>
2021-12-07 18:15:06 +00:00
Carlos Garnacho
c07c50d189 wayland: Make the pointer leave non-alive surfaces
Listen to changes in MetaWindow::is-alive, so that the pointer
can logically leave the surface as soon as that happens. This
helps prevent flooding the client socket while it is stalled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2122>
2021-12-07 17:15:21 +00:00
Carlos Garnacho
26676a829e core: Change behavior of "application is alive" checks
Change some things in these "app is alive" checks:
- The dialog timeout is separated from the ping timeout, in order
  to show it again at a constant rate after dismissing, despite in
  flight pings. It still shows immediately after the first failed
  ping.
- As we want to tap further into is-alive logic, MetaWindow now
  made it a property, that other places in code can fetch and
  subscribe.
- Motion events trigger ping (as long as there was none other in
  flight for the same window), and are counted between ping and
  pong, in order to preemptively declare the window as not alive
  before there is trouble with event queues being overflown.

This results in a separate logic between "the application does
not respond" and "we are showing the close dialog" so that the
former may get triggered independently.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2122>
2021-12-07 17:15:21 +00:00
Jonas Ådahl
29141afd0f xwayland: Handle the died callback being cancelled more gracefully
If we were cancelled, it could mean we teared down, meaning fetching
manager instances will attempt to fetch past freed instances. Handle
this by waiting with the fetching until we know we weren't cancelled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2140>
2021-12-07 16:38:20 +00:00
Jonas Ådahl
ad0d70d5d5 wayland: Detach event source on tear down
No reason keeping it attached; would one continue using a main loop on
the default main context after tear down, we'd get callbacks causing
use-after-free issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2140>
2021-12-07 16:38:20 +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
Fernando Monteiro
44aa6ab735 cogl: Remove cogl_texture_new_with_size
Replace the deprecated function with the suggested alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
612da58c72 cogl: Remove cogl_texture_new_from_sub_texture
This function is deprecated and must be replaced to the alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
0c5cf1ec58 tests: Rename 'material' variables to 'pipeline'
This should replace all usages of the material variable to
the pipeline variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
29c62fabac cogl: Remove cogl_material_set_layer_point_sprite_coords_enabled
This function is deprecated and must be replaced to the alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +00:00
Fernando Monteiro
8285091585 cogl: Remove material_set_layer_filters
This function is deprecated and must be replaced to the alternative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2058>
2021-12-07 15:32:21 +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
Carlos Garnacho
e3702c8b9a backends: Only default to builtin panel on touchscreen devices
Non-display-attached tablets (e.g. Intuos) may find no match, which
should mean "use the span of all monitors", not "pick one for me".
Reserve this fallback to touchscreen devices, since these might
still benefit from it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2107>
2021-12-07 14:59:57 +00:00
Carlos Garnacho
04eda556e7 backends: Do not emit pointless signals remapping pad devices
The matrix and aspect ratio of the tablet is irrelevant on pads, and
it actually triggers warnings when trying change that on those devices:

gnome-shell:42536): mutter-CRITICAL **: 17:22:41.994: meta_input_device_native_get_mapping_mode_in_impl: assertion 'device_type == CLUTTER_TABLET_DEVICE || device_type == CLUTTER_PEN_DEVICE || device_type == CLUTTER_ERASER_DEVICE' failed

This is unnecessary to do on pad devices, these just need to be moved
together with their respective stylus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2107>
2021-12-07 14:59:57 +00:00
Erik Massop
7bb0055acd plugins/default: Use local vars for refs
Since the completion callback (on_switch_workspace_effect_complete) sets
priv->tml_switch_workspace1 to NULL, the unref was trying to unref NULL,
and the reffed ClutterTimeline was not getting unreffed.

This could be triggered by rapidly switching workspaces, switching again
before the animation of the initial switch was done.

Found while working on #2038.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2120>
2021-12-07 13:57:58 +00:00
Pascal Nowack
d5f2ec6f1e backends/native: Stop freeing slow keys list twice
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1225
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2138>
2021-12-07 09:35:26 +01:00
Jonas Ådahl
65d8164833 backend: Expose get_monitor_manager() publicly
So that it can eventually replace the standalone singleton getter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2128>
2021-12-03 15:43:40 +00:00
Jonas Ådahl
5afe51b143 monitor-manager: Add 'has-builtin-panel' property
Will be TRUE if there are any built in panels. Can for example be used
to determine whether a machine is a laptop or a desktop computer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2128>
2021-12-03 15:43:40 +00:00
Jonas Ådahl
a6644adc28 mutter: Add missing newline in error messages
It's using g_printerr() which isn't like g_message()/g_warning() and
friends that expect no newline in the end.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2133>
2021-12-03 15:47:12 +01:00
JoseExposito
8d34b50918 wayland/pointer-gestures: Implement hold gesture
Update the pointer gestures protocol to version 3 and implement the new
hold gesture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
JoseExposito
c545ffac43 wayland/pointer-gestures: Update protocol to v2
Update the pointer gestures protocol to version 2 and implement the new
release method.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
JoseExposito
d4ba16252b backends/native/meta-seat: Capture hold events
Receive hold gesture events from libinput and enqueue them as Clutter
events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
JoseExposito
d6dd105cfb tests/clutter: Add hold event conform tests
Add tests to check that	the hold events recieved by actors have the
required properties.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
JoseExposito
dca9d57eea tests/clutter: Add hold event to existing test
Add CLUTTER_TOUCHPAD_HOLD to existing interactive tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
JoseExposito
af1f3304e4 clutter/event: Add ClutterEventType.CLUTTER_TOUCHPAD_HOLD
Add a enum for hold gestures in ClutterEventType as well as the
required functions to get information about the event: coordinates,
finger count, event phase, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
Jonas Ådahl
7b83735aea wayland/output: Always set xdg_output interface implementation
This avoids the following crash, that could happen in certain rare race
conditions, e.g. in tests:

  0) wl_closure_invoke (closure=0x2fbf9e0, target=0x2e5b3d0, opcode=0)
     at ../src/connection.c:1014
  1) wl_client_connection_data () at ../src/wayland-server.c:432
  2) wl_event_loop_dispatch () at ../src/event-loop.c:1027
  3) wayland_event_source_dispatch () at ../src/wayland/meta-wayland.c:104
  4) g_main_dispatch () at ../glib/gmain.c:3381

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2127>
2021-12-02 20:07:49 +00:00
Jonas Ådahl
50ccab567f util: Add back topic prefix to meta_topic() messages
Was lost when changing to use g_message(); lets add it back.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2125>
2021-12-01 19:37:59 +00:00
Carlos Garnacho
fa31c97aec stack: Add prerequisites to some stack API
Passing a NULL workspace does not make sense, since it silently
returns no windows. Mandate that a workspace is explicitly requested,
and while at it check the other arguments as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2124>
2021-12-01 15:39:34 +01:00
Carlos Garnacho
e74e8061a4 wayland: Specify workspace when looking for Xdnd drop target
The meta_stack_get_default_focus_window_at_point() function started silently
requiring a workspace, returning always NULL otherwise. Specify the current
workspace here.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2042
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2124>
2021-12-01 15:39:08 +01:00
Jonas Ådahl
5ca43e7017 renderer/native: Set EGLContext when creating secondary GPU data
When changing to using MetaRenderDevice, setting the EGLContext was
mistakenly dropped. Add it back. Fixes hybrid graphics setups.

Fixes: d4e8cfa17a
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2032
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2111>
2021-11-26 15:04:39 +00:00
Jonas Ådahl
00c329a2e5 cursor-renderer/native: Use MetaCrtcNative API to check capabilities
The cursor renderer shouldn't assume all the CRTCs of a logical are KMS
CRTC's, as we'll end up checking hardware capabilities for CRTC's of
virtual monitors as well, when they were created to not embed the cursor
image directly in the framebuffer.

Instead, use the newly introduced API for checking CRTC cursor
capabilities. This fixes a crash with the following backtrace:

 0) get_plane_with_type_for at ../src/backends/native/meta-kms-device.c:150
 1) meta_kms_device_get_cursor_plane_for at ../src/backends/native/meta-kms-device.c:173
 2) has_cursor_plane at ../src/backends/native/meta-cursor-renderer-native.c:678
 3) foreach_crtc at ../src/backends/meta-logical-monitor.c:247
 4) meta_monitor_mode_foreach_crtc at ../src/backends/meta-monitor.c:1920
 5) meta_logical_monitor_foreach_crtc at ../src/backends/meta-logical-monitor.c:274
 6) crtcs_has_cursor_planes at ../src/backends/native/meta-cursor-renderer-native.c:718
 7) should_have_hw_cursor at ../src/backends/native/meta-cursor-renderer-native.c:881
 8) meta_cursor_renderer_native_update_cursor at ../src/backends/native/meta-cursor-renderer-native.c:1085
 9) meta_cursor_renderer_update_cursor at ../src/backends/meta-cursor-renderer.c:411

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2000183
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
2021-11-26 14:30:27 +00:00
Jonas Ådahl
e82685d049 crtc/native: Add API to check whether the CRTC supports hardware cursors
On a KMS backed CRTC, hardware cursor are supported when there are
cursor planes to assign them to. Note that when using legacy mode
setting, fake cursor planes are added when adequate.

On virtual CRTCs, used with virtual monitors, the equivalent of hardware
cursor are always supported, as they are sent using embedded PipeWire
stream metadata.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1991>
2021-11-26 14:30:27 +00:00
Michel Dänzer
2c70120555 surface-actor-wayland: Do not acquire scanout if actor appears obscured
This can happen if a texture was newly assigned to the actor, but the
unobscured region hasn't been updated yet. Without bailing here, the
actor would display correctly via direct scanout, but other parts of
mutter would continue considering it obscured, which would e.g. result
in no frame callbacks getting sent for its surface.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1636
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2112>
2021-11-26 12:47:44 +01:00
Daniel van Vugt
858b5c12b1 background-content: Anti-alias texels that intersect the circle boundary
Previously we chose to only anti-alias texels inside the boundary
(`clip_radius - 1.0`) but zoomed in you could see it was slightly smaller
than the correct curve (#2024).

Similarly if you choose to only anti-alias texels outside that edge
(`clip_radius + 1.0`) then you'd get an overly convex curve that doesn't
match up with the straight line sections.

So now we anti-alias texels that intersect the circle boundary, regardless
of which side they are mostly on. For efficiency we define "intersect" to
mean any texel whose center is within 0.5 of the theoretical edge.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2024
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2102>
2021-11-24 15:55:20 +00:00
Daniel van Vugt
acadf5b3f7 onscreen/native: Increase buffer ref count in copy_shared_framebuffer_cpu
It was dropping to zero after the first frame because it hadn't been
incremented high enough. So the second frame would crash with:
```
  #0 g_type_check_instance_cast
  #1 META_DRM_BUFFER
  #2 copy_shared_framebuffer_cpu
```
That's the CPU-copy path (fallback-fallback) that probably no one is using
but it does work after this fix. Exactly the same issue as was fixed
in `copy_shared_framebuffer_primary_gpu` by 36352f44f9.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2104>
2021-11-24 15:15:24 +00:00
Jonas Ådahl
7f720a40b4 wayland/activation: Don't grab if no serial or surface was provided
A client can create a token without any seat, serial, or surface. In
this case, we'd still try to grab, which would run into some unforseen
code paths, potentially resulting in the following crash:

  0) meta_wayland_tablet_seat_device_added (tablet_seat=0x55dff4271c90,
                                            device=0x7f87b80655b0) at
       ../src/wayland/meta-wayland-tablet-seat.c:200
  1) meta_wayland_tablet_seat_new (seat=0x0, manager=0x55dff3ec7b40) at
       ../src/wayland/meta-wayland-tablet-seat.c:283
  2) meta_wayland_tablet_manager_ensure_seat (manager=manager@entry=0x55dff3ec7b40,
                                              seat=seat@entry=0x0) at
       ../src/wayland/meta-wayland-tablet-manager.c:239
  3) meta_wayland_tablet_manager_ensure_seat (seat=0x0, manager=0x55dff3ec7b40) at
       ../src/wayland/meta-wayland-touch.c:595
  4) meta_wayland_seat_get_grab_info (seat=0x0, surface=0x55dff43ff5b0,
                                      serial=0, require_pressed=0, x=0x0, y=0x0) at
       ../src/wayland/meta-wayland-seat.c:479
  5) activation_activate (...) at
       ../src/wayland/meta-wayland-activation.c:261

Fix this by not trying to grab if not enough parameters was passed when
creating the token. Also add a test case that reproduces the above
crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Jonas Ådahl
d420a39a02 tests: Split out Wayland tests into its own test case
Makes it easier to run it, as one doesn't need to wait for all the other
unit tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Jonas Ådahl
eed6599867 startup-notification: Fix source return value
Use G_SOURCE_CONTINUE and G_SOURCE_REMOVE intead of TRUE and FALSE.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Jonas Ådahl
c41657bc4f wayland/activation: Remove token from hash table on timeout
When an activation times out, we'll be signalled two signals on the
startup sequence object: "timeout", and "complete".

Normally, the "complete" signal is emitted when a startup sequence is
completed succesfully by it being used for activation, and in this case,
the xdg_activation implementation should remove the sequence from the
startup notification machinery.

However, in the timeout case, we should not remove it, as the startup
notification machinery itself will deal with this. If we would, we'd end
up with use-after-free issues, as the sequence would be finalized when
removed the first time.

To avoid this, just clean up the Wayland side in the "timeout" signal
handler, leaving the "complete" signal handler early out if it was
already handled by it.

This avoids crashes like:

  0) g_type_check_instance (type_instance=type_instance@entry=0xdd6740)
  1) g_signal_handlers_disconnect_matched (instance=0xdd6740, ...)
  2) meta_startup_notification_remove_sequence (sn=0x4cc890,
                                                seq=0xdd6740) at
       ../src/core/startup-notification.c:544
  3) startup_sequence_timeout (data=0x4cc890, ...) at
       ../src/core/startup-notification.c:504
  4) g_timeout_dispatch (...) at ../glib/gmain.c:4933

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Jonas Ådahl
a2cf75ccd5 startup-notification: Fix naming of handle ID
It was named the same as the callback function itself, which was
confusing. ADd the `_id` suffix, which is the convention.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Jonas Ådahl
734ae26ff7 core/close-dialog: Don't pass DISPLAY
We set it via setenv(), and might not have the MetaX11Display at hand.
This fixes a crash when the stuck-client dialog (using zenity) appears
without any X1 client having appeared.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2081>
2021-11-24 15:20:59 +01:00
Sebastian Keller
b28a6e50a0 tests: Add test for maintaining constraints after client resizes
This test ensures that windows that were resized such that they extend
beyond the screen will be moved to be fully on the screen (if possible).

This has been working on X11 since forever, but on Wayland only since
the last commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2103>
2021-11-23 00:51:01 +00:00
Sebastian Keller
0e736af301 window: Ensure constraints after a Wayland client resize
The client may have changed the window size in a way that it now
violates some of the constraints. To ensure constraints are applied
again after a client resize we need to queue a mutter side resize. This
will apply the constraints and send the new size to the client.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1956
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2103>
2021-11-23 00:51:01 +00:00
Sebastian Keller
d66e3e2d8a window/wayland: Detect client resizes with pending non-resizes
The previous code was trying to detect client resizes by only
considering resizes without any pending configurations as client
resizes. There can however be pending configurations that do not involve
resizing, such as ones triggered by state changes. These may also stay
unacknowledged by the client until the next size change. This was
causing client resizes after showing the window (and therefore changing
its status to focused) to not be detected as client resize.

Fix this by checking whether the queue has any configuration with size
changes rather than just whether it is empty.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2023
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2103>
2021-11-23 00:51:01 +00:00
Sebastian Keller
67033b0acd wayland/window-configuration: Fix maximized check in fixed size check
This was always true and therefore resulting in all configurations being
considered as having a size, even when they don't change the size, such
as a state change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2103>
2021-11-23 00:51:01 +00:00
Jonas Ådahl
4bb8b2a9f3 util: Remove unused logging functions
They are tunneled through g_message() now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2094>
2021-11-21 20:53:33 +00:00
Jonas Ådahl
e280589661 util: Implement meta_verbose() using meta_topic()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2094>
2021-11-21 20:53:33 +00:00
Jonas Ådahl
59166d745e util: Implement meta_topic() using g_message()
This will get us things like timestamps.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2094>
2021-11-21 20:53:33 +00:00
Jonas Ådahl
8c8bbb8008 util: Remove push/pop no msg prefix logging
Used to log multiple line entries. Just make continue prefix things, no
need to mess with maybe-prefixing; it'll just complicate using some less
custom logging functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2094>
2021-11-21 20:53:33 +00:00
Jonas Ådahl
cbdd62c197 kms/impl-device: Report 'full' change if we removed connectors
If some connectors disappeared, but the rest didn't change, we missed
actually removing the ones that disappeared, as we incorrectly assumed
nothing changed. Fix this by only assuming nothing changed if 1) we
didn't add any connector, and 2) we have the same amount of connectors
as before the hotplug event. The connector comparison checking makes
sure we report changes if anything of the still available connectors
changed.

Fixes: a8d11161b6
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2007
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:55:22 +01:00
Jonas Ådahl
c765730af7 kms/crtc: Always log whether we updated CRTC state
Change a few early-outs to handle the state changes without returning.
This means we'll get to log the result in all cases, which might help
debugging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:55:22 +01:00
Jonas Ådahl
8546ca31ff kms/connector: Fix updating the state when drmConnector is NULL
When a docking station is disconnected, a few previously existing DRM
connectors may now be gone. When this happens, getting them via the
libdrm API results in NULL pointers returning, and we need to handle
this gracefully by making sure the connector state is properly updated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2097>
2021-11-18 17:15:57 +01:00
Sebastian Keller
989cc2e247 tests: Add test for unfullscreening followed by immediate strut change
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Jonas Ådahl
028ed0685d tests/test-client: Add 'stop_after_next' and 'continue' commands
The 'stop_after_next' will execeute one command, then not return to the main
loop until a 'continue' command is passed. Commands will still be
processed between 'stop_after_next' and 'continue'.

This is intended to be used to induce race conditions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Sebastian Keller
2eda6d0a7c tests/test-runner: Add commands to set and remove struts
This will be useful for tests that require strut changes to reproduce an
issue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Sebastian Keller
6902a724ce window: Store unconstrained_rect everytime a size is requested
Currently the stored unconstrained_rect is only ever updated if there
was a move, resize or state change according to the move_resize_internal
implementation.  For Wayland windows however resizes or state changes
are done in two steps, first the new configuration is sent to the client
and then once client acknowledges it, it is set on the mutter side in
another move_resize_internal call. Only the second call would result in
the unconstrained_rect being updated.

This started causing problems when unfullscreening windows was
immediately followed by a strut change. These strut changes started
happening in gnome-shell due to the visibility of the panel now being
considered for the struts and the presence of a fullscreen causing it to
be hidden until unfullscreen. In this situation first the unfullscreen
would resize the window to its pre-fullscreen size as expected, but then
the strut change triggers another window resize. This window resize is
based on the stored unconstrained_rect, which is still at the fullscreen
size because the unfullscreen resize only has sent its configuration,
but it has not been acknowledged yet. As a result the strut change
causes a resize to the fullscreen size which due to the constraints now
looks like a maximized window.

To fix this always update the unconstrained_rect when the requested size
has changed, but not when a previous request has been acknowledged
unless it is originating from the client itself.

If this included the move_resize_internal call from acknowledging the
size as well, it would be possible for this to be delayed long enough on
the client side to overwrite an intermediate resize originating from
mutter. And if this did not include resizes originating from the client,
clients would not be able to set an initial window size.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Sebastian Keller
8eb268fc3b window/wayland: Differentiate between requested and direct resizes
meta_window_wayland_finish_move_resize() is called for both, finishing
a resize that has been requested through/by mutter and for resizes
directly done by the client. This introduces a CLIENT_RESIZE flag to
differentiate the former from the latter. Having this distinction is
required to know what the last requested size by either the client or
mutter is while ignoring older requests that might only have been
applied now.

This excludes client resizes when there are still pending
configurations, because the resize is known to be only temporary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Simon McVittie
a49c98d8d8 tests: Don't continue if setup commands fail
Because POSIX sh was, with hindsight, not a particularly well-designed
programming language, if we don't 'set -e', then we'll respond to failure
of a setup command such as cd by carrying on regardless.

Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2009>
2021-11-17 09:04:07 +00:00
Simon McVittie
7af1043865 tests: Don't use TestEnvironment
The assumption here seems to be that it's an overlay onto the
current environment which would make sense; but the implementation in
gnome-desktop-testing currently removes all other environment variables
(see GNOME/gnome-desktop-testing#1). This causes test failure when the
tests are run in Debian's autopkgtest framework, possibly because PATH
is cleared.

Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2009>
2021-11-17 09:04:07 +00:00
Piotr Łopatka
33529426a9 backend: Copy damage rectangles to secondary GPU when available
Systems with AMD GPUs do not take advantage of Mutter's zero-copy path
when driving DisplayLink screens. This is due to a very slow CPU access
to the zero-copy texture. Instead they fall back on primary GPU doing a
copy of the texture for fast CPU access. This commit accelerates texture
copy by working through damage regions only.

Tests on a 4K screen with windowed applications show significant
reduction of GPU utilisation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2033>
2021-11-17 08:24:15 +00:00
Jonas Ådahl
802d4e0cf8 clutter/actor: First clear all stage views before emitting they changed
If one would end up with an actor attached to mapped actor, where the
attached actor doesn't itself have an up to date stage view list while
listening on the stage for updating, when clearing the stage views of
the list, anything that would query the stage views list at this time
would end up accessing freed memory.

This could happen if

 1) An actor was added to a newly created container actor attached to
    the stage
 2) The actor got a timeline attached to it
 3) The actor was moved to a container that already was mapped
 4) A hotplug happened

After (1) both the container and actor would not have any stage views.
After (2) the timeline would listen on the stage for stage views
updates. After (3) the actor would still listen on the stage for stage
views updates. When (4) happened, the actor would be signalled when the
stage got its stage view cleared, at which point it would traverse up
its actor's tree finding an appropriate stage view to base its animation
on. The problem here would be that it'd query the already mapped
container and its yet-to-be-cleared stage view list, resulting in
use-after free, resulting in for example the following backtrace:

  0)  g_type_check_instance_cast ()
  1)  CLUTTER_STAGE_VIEW ()
  2)  clutter_actor_pick_frame_clock ()
  3)  clutter_actor_pick_frame_clock ()
  4)  update_frame_clock ()
  5)  on_frame_clock_actor_stage_views_changed ()
  6)  g_closure_invoke ()
  7)  signal_emit_unlocked_R ()
  8)  g_signal_emit_valist ()
  9)  g_signal_emit ()
  10) clear_stage_views_cb ()
  11) _clutter_actor_traverse_depth ()
  12) _clutter_actor_traverse ()
  13) clutter_actor_clear_stage_views_recursive ()
  14) clutter_stage_clear_stage_views ()
  ...

Avoid this issue by making sure that we don't emit 'stage-views-changed'
signals while the actor tree is in an invalid state. While we now end up
traversing tree twice, it doesn't change the Big-O notation. It has not
been measured whether this has any noticible performance impact.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1950
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2025>
2021-11-06 14:25:40 +00:00
Jonas Ådahl
5b35860b31 tests/stage-view: Verify stage view list length after updating
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2025>
2021-11-06 14:25:40 +00:00
Jonas Ådahl
666a30952c tests/stage-view: Disable animations
Animations may interfere with test cases, e.g. by triggering relayouts,
repaints, when not expected. Disable them, so that more precise test
cases can be added.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2025>
2021-11-06 14:25:40 +00:00
Jonas Ådahl
f1f2c96784 plugins/default: Add env var to disable animations
Intended to be used by tests, as animations may interfere with testing.
Eventually, a dedicated test plugin should be added, but it is out of
scope for this branch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2025>
2021-11-06 14:25:40 +00:00
Ray Strode
6060b6a240 backends/x11: Fix key repeat of on-screen keyboard for second level keysyms
Certains keys (such as ~ and |) are in the keyboard map behind the
second shift level. This means in order for them to be input, the
shift key needs to be held down by the user.

The GNOME Shell on-screen keyboard presents these keys separately on
a page of keys that has no shift key. Instead, it relies on mutter
to set a shift latch before the key event is emitted. A shift latch
is a virtual press of the shift key that automatically gets released
after the next key press (in our case the ~ or | key).

The problem is using a shift latch doesn't work very well in the face
of key repeat. The latch is automatically released after the first
press, and subsequent repeats of that press no longer have shift
latched to them.

This commit fixes the problem by using a shift lock instead of a shift
latch. A shift lock is never implicitly released, so it remains
in place for the duration of key repeat.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2045>
2021-11-04 13:15:25 +00:00
Mark
8e1a125f70 startup: Optionally run (and exit with) a command
Treat the first non-option as a command, and any others as its CLI
arguments. Run the command with those arguments; communicate its exit
status (if nonzero); and exit with it. Document this added functionality
in the manpage and usage description.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1981
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1982>
2021-11-04 04:18:32 -05:00
Jason Gerecke
64ff1f20f8 input-mapper: Reverse sort order of display score comparator
The `guess_candidates()` function scores each display that an input
device could be mapped to and then uses the `sort_by_score()` comparator
to find the best option. The function expects the list to be sorted from
best to worst, but the comparator currently sorts them in the opposite
order. This causes the function to end up returning the _worst_ match
rather than the the best. This commit reverses the sort order of the
comparator so that the best display can be returned as intended.

Closes: #1889
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1934>
2021-11-02 17:17:21 +00:00
Carlos Garnacho
33ca5e3d80 tests: Drop dependency on click count
This call is being removed, in favor of in-place handling, or a
ClutterGestureAction eventually.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Carlos Garnacho
a084fc10f7 frames: Keep accounting of double clicks in place
Instead of relying on ClutterEvent information.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2024>
2021-10-29 00:27:18 +02:00
Quytelda Kahja
af6fb2a702 clutter: Fix event axes array indices in axis broadcasts
A clutter event's axes array is indexed by `ClutterInputAxis`.
However, a few lines accidentally use `ClutterInputAxisFlags` as
indices, reading incorrect values from elsewhere in memory. As a
result, broadcasted axis values for the tilt, rotation, and wheel
axes don't reflect actual event data.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1982
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2065>
2021-10-28 16:20:20 +00:00
Carlos Garnacho
5125f66afa core: Use b/w unicode for tablet mode OSD
This unicode was initially meant to be b/w, but fonts and pango
eventually had another plan and we ended up with color glyphs
being used here, so we get strings like "". Change the
unicode used to ensure these are simpler b/w glyhps like
"● ○ ○ ○" that are easier to read on the OSD (and maybe even a
bit less ugly).

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4733
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2064>
2021-10-28 10:56:26 +00:00
Carlos Garnacho
ab45ae18ff x11: Initialize struct early
Since we now use the common error paths, this could fallback at a point
where it was trying to free uninitialized memory.

CID: #1508193
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2063>
2021-10-27 14:12:35 +02:00
Erico Nunes
577c4711e1 backends: Enable partial update on clipped redraws
Mutter already calculates and tracks the damage rectangles to redraw
only areas of the screen that change since the last time a buffer was
used.
This patch extends this by using the EGL_KHR_partial_update extension to
inform the GPU in advance that only those areas will be changed, which
may allow for further optimization.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2023>
2021-10-26 16:56:39 +00:00
Jonas Ådahl
c0bc821f62 wayland/output: Remove wl_output global when making it inert
This will make clients immediately aware of the output disappearing,
while still allowing for a grace period of 10 seconds for attempting to
bind to it before it turning into a protocol error. This API added as
part of wayland 1.18.

This requires us to not add the output resource to the output resource
list, if the output was made inert. This effectively makes the resource
useless, but that is harmless, since shortly after, the client will
clean it up anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 17:31:46 +02:00
Jonas Ådahl
257ccf5e80 xwayland: Unset shutdown idle id when source removed by callback
We failed to do this when the experimental "auto-close Xwayland" setting
was not enabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
1dd79c52ad xwayland: Trap errors when setting primary RANDR output
This will be crucial when we start to remove the global directly when an
output is removed, as that means Xwayland might have removed the output
before we managed to get our queries in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
39f80885c1 xwayland: Setup RANDR integration with MetaX11Display
This doesn't gain us anything right away, but will allow us to trap
errors, which will soon be necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
fb78ac4016 xwayland: Init/shutdown DND using MetaX11Display
Before it was passed an Display pointer, and had to e.g. fetch the root
window from GDK instead of the MetaX11Display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:55:12 +02:00
Jonas Ådahl
b4fe1fdd95 xwayland: Make setup/teardown a bit more symmetrical
We setup Xwayland in an early phase of the X11 display, before we had a
MetaX11Display, and teared down in a couple of places happening when
tearing down the Xwayland integration if the X server died or
terminated. It was a bit hard to follow what happened and when it
happened. Attempt to clean this up a bit, with things being structured
as follows:

 * Early during X11 display connection setup, only setup the rudimentary
   X11 hooks, being the libX11 error callbacks, and adding the local
   user to XHost.

 * Move "initialize Xwayland component" code to a new
   'x11-display-setup' signal handler. Things setup here are cleaned up
   in the 'x11-display-closing' handler.

 * Connect to 'x11-display-setup' and 'x11-display-closing' up front,
   and stay connected to these two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:54:58 +02:00
Jonas Ådahl
69f9b36643 xwayland: Pass the manager object to XSetIOErrorExitHandler
This means we can avoid going through global singletons in the handler.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:32:27 +02:00
Carlos Garnacho
ccaa4c049b wayland: Plug leak in error condition
If we fail to bind the X11 socket, free the lock file string.

CID: #1505865
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
025dbbbc94 x11: Drop fallback on ~/.mutter paths
This old handling of session files looked on ~/.mutter, which has
been unused and unsupported for a long time. It also had paths were
the GError was leaked. Fix both by dropping the legacy code, and
falling back to the common error paths.

CID: #1502682
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
b3046cca2d backends/x11: Fix off by one in debug output
We are looking the atom name based on the wrong index, as the
axis is incremented to cater for the extra CLUTTER_INPUT_AXIS_IGNORE
value.

CID: #1418330
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
8ede36b2ef compositor: Remove dead code
When grabbing the devices, there's no error paths that would quit
late enough that both pointer and keyboard would need ungrabbing,
so the keyboard checks were dead code.

Fix this by dropping the boolean variable checks, and adding goto
labels to unroll the operation properly at every stage.

CID: #1418254
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
0a7547a195 core: Drop code to do edge resistance on timeouts
This has been long indirectly disabled (these timeouts were defined
as 0ms long, thus not set), so edge resistance timeouts can be safely
deemed dead code.

CID: #1418253
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
70a5f29ef1 core: Drop repeated early return condition in function
We are already checking for prev_state == META_SEQUENCE_PENDING_END,
no need to do it twice.

CID: #1418251
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-24 19:16:42 +02:00
Carlos Garnacho
820aa18126 backends/native: Use rtkit to get realtime priority
Instead of using sched_setscheduler directly (and relying that we
somehow got CAP_SYS_NICE), use rtkit to do this for us.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2284
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2060>
2021-10-22 08:35:15 +00:00
Simon McVittie
7c6fe21daf tests: Add additional debug in wait_for_orientation()
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2049>
2021-10-22 07:43:19 +00:00
Simon McVittie
838d5656c3 tests: Make it easier to keep track of where we are
The monitor orientation tests do a lot of things in sequence. Replace
some of the comments with g_test_message() so that the log from a failed
test gives us a better idea of how far we got.

Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2049>
2021-10-22 07:43:19 +00:00
Simon McVittie
27ce84962a tests: Change how we wait for an orientation change
Previously, we were waiting up to 300ms for the signal, then proceeding
anyway. However, 300ms is not necessarily long enough to wait on an
autobuilder that might be heavily loaded, particularly if it's a non-x86
with different performance characteristics.

Conversely, if mutter responds to the D-Bus signal from the mock sensor
before we have connected to the signal, then we cannot expect to receive
the signal - it was already emitted, but we missed it. In this case, we
need to avoid waiting.

One remaining use of wait_for_orientation_changes() that would previously
always have timed out was in
meta_test_orientation_manager_has_accelerometer(), which does not
actually expect to see an orientation-changed signal. Make this wait
for the accelerometer to be detected instead.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/1967
Bug-Debian: https://bugs.debian.org/995929
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2049>
2021-10-22 07:43:19 +00:00
Jonas Ådahl
ac907119ae wayland: Only init EGLStream controller if we didn't end up with gbm
When we use gbm together with the NVIDIA driver, we want the EGL/Vulkan
clients to do the same, instead of using the EGLStream paths. To achieve
that, make sure to only initialize the EGLStream controller when we
didn't end up using gbm as the renderer backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2052>
2021-10-20 13:08:06 +00:00
Jonas Ådahl
8fc1325e8e renderer/native: Try the gbm renderer before the EGLDevice renderer
This switches the order of what renderer mode is tried first, so that
the gbm renderer mode is preferred on an NVIDIA driver where it is
supported.

We fall back to still try the EGLDevice renderer mode if the created gbm
renderer is not hardware accelerated.

The last fallback is still to use the gbm renderer, even if it is not
hardware accelerated, as this is needed when hardware acceleration isn't
available at all. The original reason for the old order was due to the
fact that a gbm renderer without hardware acceleration would succeed
even on NVIDIA driver that didn't support gbm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2051>
2021-10-19 17:43:13 +02:00
Jonas Ådahl
e8249a572d renderer/native: Log render mode per device
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2051>
2021-10-19 17:43:12 +02:00
Sebastian Keller
c2bb80a26d util: Export and annotate meta_get_clutter_debug_flags
This will be useful for getting the initial state when adding switches
for these flags to looking glass.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3968
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2028>
2021-10-18 16:46:59 +00:00
Jonas Ådahl
d4e8cfa17a renderer/native: Use MetaRenderDevice
This replaces functionality that MetaRenderDevice and friends has
learned, e.g. buffer allocation, EGLDisplay creation, with the usage of
those helper objects. The main objective is to shrink
meta-renderer-native.c and by extension meta-onscreen-native.c, moving
its functionality into more isolated objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:36:18 +02:00
Jonas Ådahl
8662f33b9e render-device: Add API to allocate dumb buffers
All render devices that have a device file backing them might be able to
allocate dumb buffers, so add a helper for doing that. Will indirectly
result in an error up front on a surfaceless render device due to lack
of a device file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:36:17 +02:00
Jonas Ådahl
986588ade2 render-device: Add API to import other buffers
This more or less is a helper for creating MetaDrmBufferImport objects
with a bit more friendly API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:35:26 +02:00
Jonas Ådahl
802e7eb56f render-device: Add API to allocate DMA buffers
Only possible with the gbm implementation; aims to make it easier for
users of render devices to allocate DMA buffers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:34:31 +02:00
Jonas Ådahl
9292eba035 render-device/gbm: Add getter for gbm_device
Will be needed, at least during a transition period, to e.g. deal with
gbm_surface's et. al. without having MetaRenderDevice learning about
render surfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
b3dffb43b3 drm-buffer: Don't always generate fb_id on construction
It might not be needed by the user of the buffer, so don't always
require it up front. Instead make sure that any user that needs it first
calls "meta_drm_buffer_ensure_fb_id()" to create the ID.

Only the plain gbm implementation creates the ID lazilly, the other
still does it on construction due to the objects used to create them
only existing during construction.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
a1266e19f4 drm-buffer: Add API to export buffer file descriptor
Practically ends up in gbm_bo_get_fd(). For dumb buffer, an
'unsupported' error is returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
6ba86366b3 drm-buffer: Replace 'use-modifier' boolean with flags
This lets us add more customization to the buffer instance without
adding more boolean arguments.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
99f51d2866 drm-buffer: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
e078718180 drm-buffer: Add getters for more metadata
Mostly calls into gbm_bo_* API, or something somewhat similar when on
dumb buffers. Added API are:

 * get offset for plane
 * get bpp (bits per pixel)
 * get modifier

This will allow users of MetaDrmBuffer to avoid having to "extract" the
gbm_bo to get these metadata.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00
Jonas Ådahl
bece36b4ad renderer/native: Get bpp from gbm_bo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:33 +02:00