1
0
Fork 0
Commit graph

9941 commits

Author SHA1 Message Date
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
Jonas Ådahl
2047d2d4e9 Introduce MetaRenderDevice{Gbm,EglStream,Surfaceless}
The purpose of MetaRenderDevice is to contain the logics related to a
render device; i.e. e.g. a gbm_device, or an EGLDevice. It's meant to
help abstract away unrelated details from where it's eventually used,
which will be by MetaRendererNative and the MetaOnscreenNative
instances.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:33:32 +02:00
Jonas Ådahl
3a6f6c264d util: Add 'render' debug topic
Meant for MetaRenderer and everything related that deals with turning
composited frames, or client buffers, into mode set updates. This is
slightly related to the debug topic 'kms' is meant for the KMS details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:14:21 +02:00
Jonas Ådahl
bd841e8dc5 util: Fix placement of META_DEBUG_WAYLAND in switch statement
When added, it was added to the wrong place; fix that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:13:23 +02:00
Jonas Ådahl
7058013660 clutter/stage: Remove 'minimum window size' logic
It was a feature relevant for when Clutter was an application toolkit
that wanted the application window to communicate a minimum size to the
windowing system.

Now, clutter is part of the windowing system component, so this feature
doesn't make any sense, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
259a906b8c cogl/winsys: Remove 'multiple-onscreen' feature
It was always set, and is no longer used; remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
b73bbecaad clutter/feature: Remove static vs multiple stage feature
This feature was configured depending on whether the Cogl backend
reported COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN or not. All cogl backends
do report this, so any code handled the 'static' case were never used.

While we only ever use one stage, it's arguable more correct to
consilidate on the single stage case, but multiple stages is something
that might be desirable for e.g. a remote lock screen, so lets keep this
logic intact.

This has the side effect of completely removing backend features, as
this was the only left-over feature detection that they handled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
85de82bb4e clutter: Remove 'stage cursor' feature
It was unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
8008f0b7b0 Explicitly create the clutter context and backend
This changes the setup phase of clutter to not be result of calling an
init function that sets up a few global singletons, via global singleton
setup vfuncs.

The way it worked was that mutter first did some initial setup
(connecting to the X11 server), then set a "custom backend" setup vfunc
global, before calling clutter_init().

During the clutter_init() call, the context and backend was setup by
calling the global singleton getters, which implicitly created the
backend and context on-demand.

This has now changed to mutter explicitly creating a `ClutterContext`
(which is actually a `ClutterMainContext`, but with the name shortened to
be consistent with `CoglContext` and `MetaContext`), calling it with a
backend constructor vfunc and user data pointer.

This function now explicitly creates the backend, without having to go
via the previously set global vfunc.

This changes the behavior of some "get_default()" like functions, which
will now fail if called after mutter has shut down, as when it does so,
it now destroys the backends and contexts, not only its own, but the
clutter ones too.

The "ownership" of the clutter backend is also moved to
`ClutterContext`, and MetaBackend is changed to fetch it via the clutter
context.

This also removed the unused option parsing that existed in clutter.

In some places, NULL checks for fetching the clutter context, or
backend, and fetching the cogl context from the clutter backend, had to
be added.

The reason for this is that some code that handles EGL contexts attempts
to restore the cogl EGL context tracking so that the right EGL context
is used by cogl the next time. This makes no sense to do before Cogl and
Clutter are even initialized, which was the case. It wasn't noticed
because the relevant singletons were initialized on demand via their
"getters".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
92b95b0b4b clutter/backend/x11: Make filter add/remove take a clutter backend
This avoids some global fetching, which is problematic if it happens
during init.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
6ae9bc9045 clutter/backend/x11: Keep a pointer to the actual backend
As with the native backend, eliminate going via some globals when
getting the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
1fbdfa8ca7 clutter/backend/native: Keep a pointer to the actual backend
This eliminates going via a global variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
cf1715ac43 backend: Get the default seat directly
In various places we retrieved the default seat from the ClutterBackend.
All the clutter backends implement this by calling
meta_backend_get_default_seat() which will then return
MetaBackendPrivate::default_seat.

Lets avoid this by fetching the default seat directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
c23c07716f clutter/backend/x11: Remove screen dimension fields
They were not used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
c6530551de clutter/backend/x11: Don't keep track of a Screen pointer
It was used during init, and nowhere else.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
08c34c887f clutter/backend/x11: Clean up ClutterBackend variable naming
Just as with MetaClutterBackendX11, lets avoid confusing it with
MetaBackend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
bbf2f6e064 clutter/backend/x11: Clean up variable naming
Rename all instances of `MetaClutterBackendX11` so they are called
`clutter_backend_x11`. This is because `MetaBackendX11` will start to be
used for some things, and having both be named `backend_x11` would be
confusing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
528ae91385 clutter: Remove option parsing support
For a long time we always passed NULL, lets take it one step further and
just remove all the options parsing stuff.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
a545fecad3 clutter/x11: Remove X11 display name field
It was unused, and we don't even let clutter open the display itself.
Lets clean that up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Jonas Ådahl
fbb586283f clutter: Remove left-over xinput debug code
The only thing that happened was a static boolean getting set but never
read.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
2021-10-18 14:36:15 +00:00
Georges Basile Stavracas Neto
fbcb078513 clutter/container: Remove clutter_container_get_children
This one is a trivial wrapper around clutter_actor_get_children(), so just
use that in the two places where clutter_container_get_children() is used,
and remove clutter_container_get_children().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2057>
2021-10-15 14:22:37 -03:00
Robert Mader
b41def4749 wayland/data-offer: Fix indentation in data_offer_finish()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2043>
2021-10-14 21:08:42 +00:00
Robert Mader
33b834c433 wayland/data-offer: Accept final preferrence of drop destination
Quoting the spec for `wl_data_device::drop`:
> If the resulting action is "ask", the action will not be considered
> final. The drag-and-drop destination is expected to perform one last
> wl_data_offer.set_actions request, or wl_data_offer.destroy in order
> to cancel the operation.

We did not respect the action choosen by the drop destination when
it called `wl_data_offer::set_actions` after `wl_data_device::drop`
if a user override was still active. This eventually resulted in
a protocol error in `wl_data_offer::finish`, as the current action
could still be `ask`.

Fix this by only allowing a user override to `ask` before `drop` is
called, thus making sure the final `set_actions` preference is
honored.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2043>
2021-10-14 21:08:42 +00:00
Olivier Fourdan
cea39b7f0c wayland/output: Always send xdg_output layout
With each wl_ouitput corresponding to a monitor, the logical monitor is
not part of the MetaWaylandOutput anymore.

Previously, send_xdg_output_events() would compare the old logical
monitor against the new one to determine whether the size and/or
position was changed and should be sent along with the xdg_output
events.

But that logic is now defeated as there is no old/new logical monitor
anymore, so the updated size or location would never be sent again.

Xwayland relies on this information to update its X11 clients and its
own internal root size, without this the X11 screen size and XRandR
information would never be updated.

To avoid that issue, always send the xdg_output size and location on
xdg_output events, Xwayland is smart enough to update its X11 clients
with XRandR only when the layout actually change.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1964
Fixes: bf7c3450 - Make each wl_output correspond to one monitor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2050>
2021-10-11 14:43:27 +02:00
Ray Strode
c1f5e57f2b keymap-x11: Don't update key types when adding key to keymap
meta_keymap_x11_replace_keycode currently reports to the X server
that the key types data is changed when adding a key to the keymap.

It's not changed. The number of key types is the same, and none of
them are modified.

This has two bad side effects:

1) It sends all of the key types data into the request
2) It hits a bug in the X server leading to the request getting
rejected entirely.  See:

https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/761

Furthmore, the changed structure used to report to the X server
that the key types data is changed doesn't actually need to modified
at all in the function.  It's already prepped by libX11 with the
correct state for the changes mutter is doing when
XkbChangeTypesOfKey is called.

This commit addresses the above two problems by just removing the
lines causing the issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2039>
2021-10-06 14:16:39 +00:00
Sebastian Keller
2740f1d2d2 keymap/x11: Stop searching through reserved keycodes explicitly
Keys in the reserved keycode list are always added for the first group.
Before the previous commit such keycodes were not found unless that was
the current group. But now that we can also find matching keycodes that
are not directly in the current group, this is not necessary anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Sebastian Keller
795418a5db keymap/x11: Consider the out of range group action
Some keys, such as enter or backspace are only bound to a single group,
even if multiple groups are configured. Because the code was previously
only looking for keysyms in the same group as the current one, no
matching keycodes for these would be found if the current group is not
the first group. This was causing those keys to not work on the X11 OSK.

To fix this use the correct action to convert an out of range group for
that key according to its group_info field.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Sebastian Keller
bb24e4ac9e keymap/x11: Check for the group earlier when finding keycode from keyval
This effectively changes meta_keymap_x11_get_entries_for_keyval() to
meta_keymap_x11_get_entry_for_keyval() and moves the check if the
keycode maps to the keyval in the current group there. This simplifies
the code a bit and will allow a followup fix.

As a side effect this now also causes the reserved kecodes to be
searched, if no keycodes were found, rather than just when only ones
matching the wrong groups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Jonas Ådahl
9179d4a4b1 kms/impl-device/atomic: Add virtio_gpu to deny list
virtio_gpu is used in virtual machine environments, meaning they need
accurate cursor hotspots, which currently needs non-atomic mode setting.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2009304
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2040>
2021-10-05 13:55:06 +00:00
Robert Mader
e42196b00a wayland/actor-surface: Restore stage update for unmapped actors
The extra stage update we schedule in `apply_state()` is mainly
needed in two situations:
 - a partial update happened only in obscurred or off-screen parts
   of a surface
 - a surface requests frame callbacks without having done damage,
   notably the (in)famous Firefox vsync implementation.

Commit 0330ce1f15 limited the update to cases when the actor
was mapped, breaking it for Firefox in the overview.

Remove the mapped check again and get the stage from the backend,
restoring previous behaviour.

Fixes 0330ce1f15
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1957

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2034>
2021-10-04 11:13:04 +02:00
Dor Askayo
98d5aa159e xwayland: Fix condition for queuing a window to META_QUEUE_CALC_SHOWING
This logic was changed by accident in df642eb15. The change caused every
Xwayland window to be queued to META_QUEUE_CALC_SHOWING on every surface
commit. As a result, X11 window management events, including _NET_WM_STATE,
were dispatched at clients on every single frame.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2032>
2021-10-02 00:12:34 +03:00
Bastien Nocera
c789b6be38 backend: Reset idletime when unplugging the power cable
Avoid having laptops suspend or lock as soon as the power cable is
unplugged as the timeout for those actions when on battery are smaller
than the timeouts when on AC.

- laptop is plugged in, and hasn't been used for X minutes
- laptop is unplugged
- the gnome-settings-daemon power plugin sets up its timeouts for
  inactivity for the "on battery" case
- those X minutes of inactivity are still counting, and are above
  the level of one of the timeouts (say, suspend or lock screen),
  mutter fires the timeouts
- gsd-power activates the action associated with the timeout

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1953
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
2021-09-30 17:45:39 +02:00
Bastien Nocera
14b6c8780d backend: Refactor "lid-is-closed" handling code
We'll need to handle another property in the same place, so refactor the
code to allow falling-through to handle another property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
2021-09-30 17:45:22 +02:00
Sebastian Keller
e38db1237d window: Don't change workspaces of unmanaged windows
If the ancestor a window is transient for has already been unmanaged
when the window is activated via meta_window_activate_full while its
transient_for property still points to that ancestor, this will cause
the already unmanaged ancestor to get added to the windows workspace.
This is after the ancestor had its workspace set to NULL when it was
unmanaged, causing this to look like an actual workspace change. Once
the window has been added to the workspace, it will never be removed
again, because the it has already been unmanaged. This confuses things
like the shell window tracker and leads to phantom windows being
considered present for apps that are not even running anymore.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4184
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2003>
2021-09-29 09:34:30 +00:00
Robert Mader
8bf87a7e73 shaped-texture: Remove mask texture handling from get_image()
It has been broken for a long time now, not handling shadows of
SSD clients well. Instead, just use the offscreen code paths.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1996>
2021-09-22 13:07:44 +00:00
Jonas Ådahl
1031de5605 tests/dbus-runner: Make sure to tear-down even on test failure
When a test failed, an exception would be raised. This meant that the
mocked service would stay alive, and the test case being run eventually
failing due to a timeout, not the failure itself.

Fix this by catching the exception during the test, ensuring that we
tear down properly, then re-raise the same exception again after having
teared down.

This avoids the dead lock, while still printing the appropriate error
message.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2008>
2021-09-22 12:37:23 +00:00
Jonas Ådahl
fca9010963 mutter: Add signal handlers
With the introduction of MetaContext, the responsibility for handling
signals was changed to the application (e.g. GNOME Shell) using
libmutter. What wasn't fixed was making the stand-alone mutter do the
equivalent as well. This commit fixes this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2007>
2021-09-22 11:38:17 +00:00
José Expósito
36b5719a3b backends/x11: Fix middle button emulation settings
Update the name of the property used to toggle middle click emulation to
"libinput Middle Emulation Enabled".

Fix: <#1881>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2000>
2021-09-20 17:39:15 +00:00
Erfan Abdi
922878acc6 wayland/dma-buf: Add support for BGR_8888 formats
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1999>
2021-09-20 17:07:54 +00:00
Daniel van Vugt
b6857e59b2 shaped-texture: Fix whitespace/indentation warnings
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1992>
2021-09-20 16:07:59 +00:00
Marco Trevisan (Treviño)
ef0f708404 monitor-manager: Use connect_object to connect to settings signals
We were disconnecting from the wrong object, so instead of adjusting it
we can simply use "new" utility functions instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
16e335eb24 backends/native: Remove unused includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d689989ea kms/connector: Use utility function to get the property ID
We already have one for this, so use it instead of repeating the same

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
cbfb59b828 backends/native: Ignore udev events while we're paused
When the native backend is paused we still process the udev events
even though this isn't needed and may just cause unneeded events to be
triggered afterwards.

Since we'll resume with full changes on such event, we can just block
the signal hander when paused and restore it afterwards.

As per this we can cleanup also a bit the device adding signal handling
given that now we don't have to disconnect/reconnect it again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9cb35e2c80 backends/kms: Always perform full changes on KMS resume
Resume happens after we may have received various events that we've
ignored, so at this point we need to just emit an hotplug event like if
everything changed so that user settings may be re-applied.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
dd0ad3bfb1 kms/impl-device: Only update crtc/connector whose ID has changed
On hotplug events we may get informations about what CRTC or connector
changed a property (and the property itself), so in such case let's just
ignore the changes to the non-affected CRTCs/connectors, and let's read
only the affected one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
91ed95ab6f kms: Only update a device state if it contains the changed crtc/connector
On hotplug events we may receive a "CRTC" or "CONNECTOR" property that
indicates which crtc/connector property ID has changed.

In such case, instead of update data for all the devices, only update the
device containing the relative connector.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d3668a389 kms/device: Add functions to find connector and crtc in devices
Hotplug events may contain CRTC or CONNECTOR ids to notify a property
change to just one owner, so we need to find its parent device.

Also we may want to update properties directly without having to go through
all the devices, so expose a simple way to find them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
ea00c96044 udev: Pass the device as parameter on hotplug events
This will allow to find the related MetaKmsDevice that is emitting the
hotplug event

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
49501c28f2 kms: Return a more specific change if there are no devices
In case we have no devices, after a KMS update (both because they've
all have been removed or because there were none), we may need to behave
differently compared to the case in which nothing changed, so add a more
specific KMS update change type

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9ce3abad28 monitor-manager-native: Do not reload all the monitors on gamma-only change
If only gamma changed on drm CRTC's we don't have to rebuild the whole
monitors, nor to inform the backed about, the only consumer could be the
DBus API, and so we still emit a signal, but nothing else is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
a8d11161b6 kms: Only emit resources-changed signal if we recorded a change
Since we cache already all the KMS parameters we care about let's check at
each device update if anything has really changed and only in such case
emit a resources-changed signal.

In this way we can also filter out the DRM parameters that when changed
don't require a full monitors rebuild.

Examples are the gamma settings or the privacy screen parameters, that
emits an udev "hotplug" event when changed, but we want to register those
only when we handle the changed property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Christian Rauch
d2eec866ed wayland: Allow to maximize windows by client regardless of constraints
A client request for maximizing itself should always be handled by mutter
by emitting a configure event with the native maximized resolution,
regardless of the client's own set limits. This also aligns the behavior by
allowing fixed-sized windows to go into fullscreen or maximized state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1997>
2021-09-20 15:09:17 +00:00
Robert Mader
3192b0239a wayland-dma-buf: Add support for DRM_FORMAT_XBGR2101010
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1810>
2021-09-20 14:39:20 +00:00
Robert Mader
9ededb9b34 wayland-dma-buf: Use alpha-less pixel formats where appropriate
The XRGB/XBGR pixel formats do not set the cogl alpha bit. This
allows for example `MetaShapedTexture` to use the fast opaque
path for rendering and `MetaCullable` to detect whether a
`MetaSurfaceActor` is opaque.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1810>
2021-09-20 14:39:20 +00:00
Michel Dänzer
3059d3ffc8 cursor-renderer: Remove meta_cursor_renderer_is_overlay_visible
Not used anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Michel Dänzer
6c818cd8d5 screen-cast/monitor-src: Use clutter_stage_paint_to_buffer
It works correctly with scanouts, in contrast to
clutter_stage_capture_into. Inspired by
meta_screen_cast_area_stream_src_record_to_buffer.

maybe_paint_cursor_sprite is now unused and thus removed.

v2:
* clutter_stage_paint_to_buffer requires switching to recording from an
  idle callback as well. (Jonas Ådahl)
v3:
* Set human readable name for idle source. (Ivan Molodetskikh)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1940
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Michel Dänzer
10d1de2bdf screen-cast/monitor-src: Always set before-paint watch
We weren't setting it for META_SCREEN_CAST_CURSOR_MODE_EMBEDDED, so
that case didn't work correctly with scanouts.

Suggested by Georges Basile Stavracas Neto.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Corentin Noël
f140d01df2 context: Add some missing introspection data
Allows to use option groups/entries from the introspection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1976>
2021-09-16 07:23:24 +00:00
Olivier Fourdan
20bb8bf502 wayland: Avoid a race in wl_seat capabilities
The way wl_seat capabilities work, by notifying clients of capabilities
changes, and clients consequently requesting the relevant interface
objects (pointer, keyboard, touch) is inherently racy.

On quick VT changes for example, capabilities on the seat will be added
and removed, and by the time the client receives the capability change
notification and requests the relevant keyboard, pointer or touch,
another VT switch might have occurred and the wl_pointer, wl_keyboard or
wl_touch already destroyed, leading to a protocol error which kills the
client.

To avoid this, create the objects when requested regardless of the
capabilities.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1797
Related: https://bugzilla.gnome.org/show_bug.cgi?id=790932
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/77>
2021-09-16 06:52:20 +00:00
Dor Askayo
70f2eb7bfa x11: Initialize g_autofree with NULL
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1990>
2021-09-04 20:00:23 +00:00
Dor Askayo
264b5b825f xwayland: Initialize g_autofree with NULL
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1990>
2021-09-04 20:00:23 +00:00
Robert Mader
2239e7ad29 shaped-texture: Remove get_image_via_offscreen()
It duplicates functionality in `meta_window_actor_get_image()`, its
only user. Instead, make `should_get_via_offscreen()` public and
use it in the former.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1893>
2021-09-04 09:17:44 +00:00
Robert Mader
b1c8510a95 window-actor: Add paint_to_content() function
Analogous to `get_image()` this returns a `ClutterContent` for a
given `MetaWindowActor`. This can be used to implement window
effects without a roundtrip from GPU to CPU memory.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1893>
2021-09-04 09:17:44 +00:00
Robert Mader
6bbb216f07 window-actor: Factor out framebuffer creation of get_image()
So we can reuse the code in the following commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1893>
2021-09-04 09:17:44 +00:00
Marco Trevisan (Treviño)
a4223007e2 tests: Run a localed mock implementation on tests
As per this we can just warn if its proxy initialization fails.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
b3c5ca12a5 monitor-manager: Remove persistent_timeout on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
4fe7569567 orientation-manager: Use an idle to apply monitor orientation changes
In X11 when we switch to another tty all the the signals are blocked (as
the display fd is not replying back to polling, causing the main loop to
stop), and they are all handled once we switch back to the tty.

This is not a problem for most of external events, but in case of
accelerometer changes, once we reactivate a mutter session we'll get
them all together, causing lots of monitor reconfigurations leading to
black screen for some seconds and most of the times to a wrong
configuration being applied.

To avoid this, batch all these events using an idle to only apply the
last one we got in a loop.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1217
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
d5f397977e monitor-unit-tests: Add tests with dynamic orientation changes
Verify monitors disposition when we have rotation changes coming from
MetaOrientationManager, using our mock dbus implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
d0a9dfefc8 monitor-transform: Add function to compute from orientation
We have two places in the code where we compute the monitor
transformation from the device orientation, avoid duplicating this
code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
bf54a16f92 tests: Add MetaOrientationManager tests via SensorsProxy mock
Create a test system bus and use it to run all the tests, add a mock
SensorsProxy (via dbusmock template) server that implements the
net.hadess.SensorProxy interface.

To make testing easier, the service is created on request of a proxy for
it, whose lifetime controls the mock service lifetime as well.
This is done using a further mock service that is used to manage the
others, using python-dbusmock to simplify the handling.

Add basic tests for the orientation manager.

As per the usage dbusmock, we're now launching all the tests under such
wrapper, so that local dbus environment won't ever considered, and
there's no risk that it may affect the tests results both locally and in
CI.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:00 +02:00
Marco Trevisan (Treviño)
f1228c4a51 orientation-manager: Expose the number of valid orientations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
617e1b30e2 monitor-config-manager: Rename builtin monitor lookup utility function
It's only meant to find the builtin monitor configuration, for any
rotation, so no need to specify that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
c326313370 monitor-config-manager: Find builtin configuration even when inactive
When creating the configuration for the builtin monitor we try to get
the panel configuration for the builtin panel, but we don't proceed if
that monitor is currently inactive.

This is fine when adjusting an active configuration to the current
device rotation, but it isn't correct when we want to create a new
configuration based on another where the monitor is configured but not
yet enabled.

So, only find the panel configuration without looking the current state
but ensuring that the passed configuration will enable it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
f803c0ee0a monitor-manager: Add config relationships and use it for orientation events
When we get an orientation event we don't care about keeping track of the
configuration changes, but actually we can consider the new configuration
just a variant of the previous one, adapted to floating device hardware
events, so we only want to apply it if possible, but we don't want to keep
a record of it for reverting capabilities.

Doing that would in fact, break the ability of reverting back to an actual
temporary or persistent configuration.
For example when device orientation events happen while we're waiting for
an user resolution change confirmation, we would save our new rotated
configuration in the history, making then impossible to revert back to
the original persistent one.

So in such case, don't keep track of those configurations in the history,
but only keep track of the last one as current, checking whether the
new current is child or sibling of the previously one.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1221
Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/646

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
db68a2a91c monitor-unit-tests: Add tests to verify config manager history
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
d773aaf7a9 monitor-manager: Apply built-in monitor orientation to previous configurations
When we reuse a monitor configuration (from the storage or previously
used), we need to make sure that the built-in monitor rotation matches
with the current sensors status.

So, instead of trying to apply a previously used or stored configuration
with a wrong orientation and fix it later, if orientation is managed by
sensor, try to create another configuration based on the previous one that
uses the current built-in monitor orientation and use it.

Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/646

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/592
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/646
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/954
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
dbf5e38f03 monitor-config-manager: Ignore orientation if it is not managed
When creating a configuration taking orientation into account we're using
the sensors orientation even if this is currently not used (for example
when an accelerator is available, but there's no touch screen).

This would cause to have a different behavior when configuration is
created and when we're loading a known configuration on startup.

So always honor whether the monitor's orientation is managed or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
2289f56112 monitor-manager: Don't apply unneeded orientation changes
There's no need to ensure monitor orientation changes if the wanted
orientation is matching the current one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
e976137d97 monitor-manager: Only manage orientation if we have a built in panel
All the auto-rotation code is expecting to have a built-in panel, but we
still monitor accelerometer changes if we don't have one (uncommon, but
possible).

Thus manage the panel orientation in such case and update it on monitors
changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
f78e21c45a monitor-manager: Remove some trailing spaces in orientation code
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Carlos Garnacho
405ec8edc2 wayland: Forward button press / touch down to Wayland text-input impls
These are ClutterInputFocus subclasses, so this will trigger reset of
the input method. As the .done event is possibly deferred in the
zwp_text_input_v3 implementation, ensure the changes caused by the
reset are flushed immediately, before the button press is forwarded
to the client by MetaWaylandPointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1940>
2021-09-03 22:05:46 +00:00
Piotr Lopatka
b328c8cc8b onscreen/native: Pass damage rectangles when page flipping
This commit passes damage rectangles metadata to the (KMS) primary
plane.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:37:56 +01:00
Piotr Lopatka
af0460d0ce kms: Allow passing framebuffer damage metadata
This commit adds support to atomic KMS backend for optional plane property
prop_fb_damage_clips. Some drivers (e.g. EVDI) take advantage of this
property and process only updated regions of the screen instead of
processing the full frame. This can save system resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:10:35 +01:00
Nishal Kulkarni
7555688d8d display: Set xattr on focus window cgroup dir
Added a function `meta_window_set_inactive_since` it sets
xattr on the cgroup directory for the given MetaWindow.

Resource management daemons can then monitor these changes on xattr
and make allocation decisions accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Nishal Kulkarni
c2efe25597 window: Add cgroup management to MetaWindow
Currently the only way to get cgroup for a MetaWindow is to get it's
PID and perform a bunch of file accesses and string manipulations.
This is especially not feasible if we want to get the cgroup every
time a MetaWindow has gained or lost focus.

A solution to this is to cache the GFile for a cgroup path.
The creation and access of this GFile is handled by
`meta_window_get_unit_cgroup` function.

`meta_window_unit_cgroup_equal` is a utility function which allows
us to compare whether two MetaWindows belong to the same cgroup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Nishal Kulkarni
4a0c86ea4c meson: Add optional libsystemd dependency
To utilize the API provided by libsystemd it would be better to
create a separate HAVE_LIBSYSTEMD configuration option instead of
having to rely on HAVE_NATIVE_BACKEND.

For now this will be utilized for getting the control group of a
MetaWindow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Robert Mader
5ffd77c36b tests/wayland: Test reattaching subsurface after parent was destroyed
and the subsurface was not previously detached from it using
`wl_subsurface_destroy()`.

Without 'window-actor/wayland: Remove subsurface actors on dispose' this
test would fail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Robert Mader
dd416dd3e2 window-actor/wayland: Remove subsurface actors on dispose
Destroying the window actor also destroys all its children. Subsurfaces
however may get reused. If the client did not unparent them before
the window actor got destroyed, they will be left without actor
which results in a crash.

Unparent all actors of subsurfaces on dispose to avoid that.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Robert Mader
f41696b0fc wayland/subsurface: Handle node unlinking on parent destroyed
It concerns subsurface state and the subsurface already listenes
for the parent to get destroyed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Robert Mader
2a2f9300d0 wayland/subsurface: Check for parent actor before unparenting
No need to assume the actor still has a parent. This silences warnings
in normal builds and prevents a crash in fully optimized ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Florian Müllner
d17e9adc73 context: Add (hidden) --unsafe-mode option
When running gnome-shell, it is possible to toggle unsafe-mode in
looking glass. We'll eventually start using the property in mutter
as well, so to make stand-alone debugging easier, also expose it
as a hidden command line option.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1983>
2021-09-02 16:58:46 +00:00
Florian Müllner
c62e86cb23 context: Add :unsafe-mode property
We are going to restrict several sensitive D-Bus APIs to a set
of allowed callers (like Settings or portal implementations).

Add an :unsafe-mode property to the context to allow turning off
those restrictions temporarily, in order to not get in the way
of development/debugging.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1983>
2021-09-02 16:58:46 +00:00
Ray Strode
2cb617e9e0 backend: Clean up renderer after clutter backend
commit c4a73e7950 added
code to cleanup the renderer when the meta backend is
disposed. Unfortunately, this introduced a crash when
the window manager is replaced.

This is because cleaning up the renderer involves talking
to the X server over a display connection that's closed
two lines higher as part of the clutter_backend_destroy
call.

This commit fixes the crash by swapping their order.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1965>
2021-08-31 16:41:11 +00:00
Jonas Ådahl
ef8c428ef9 background-image: Properly clear the failed to be filled texture pointer
Otherwise we'll unref and effectively free it, eventually resulting in
use after free, causing wierd issues like crashes and infinite
recursions.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1989726
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1979>
2021-08-31 08:25:32 +00:00
Jonas Ådahl
04994ebddf background-image: Use autoptrs for errors when loading image
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1979>
2021-08-31 08:25:32 +00:00
Florian Müllner
41d1a8407e keybindings: Remove 'panel-run-dialog' handler
There is very little point in sending an X11 client message to
gnome-panel in case gnome-shell isn't handling the binding. We
can just as well do nothing, so do exactly that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1886>
2021-08-30 21:43:34 +00:00
Florian Müllner
b5ba216163 keybindings: Remove support for 'panel-main-menu' binding
Nothing uses it anymore, and probably nobody expects mutter to
send an X11 client message to gnome-panel in that case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1886>
2021-08-30 21:43:34 +00:00
Robert Mader
021c1dd7fa surface-actor: Remove get_image() function
It is unused and removing it allows us some further cleanups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1978>
2021-08-28 13:59:52 +02:00
Robert Mader
9f8242658e surface-actor: Remove some unused and useless functions
These functions only added some extra redirections.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1978>
2021-08-28 13:58:48 +02:00
Robert Mader
eede3d1836 wayland/actor-surface: Remove some needles redirections
We already interact with the `MetaShapedTexture` directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1978>
2021-08-28 13:58:48 +02:00
Daniel van Vugt
cd355b5d74 onscreen/native: Remove a tab character
To resolve CI warnings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1972>
2021-08-24 16:44:44 +08:00
Florian Müllner
6288763671 build: Stop using source_root()/build_root()
They were deprecated in meson 0.56.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1957>
2021-08-22 17:32:12 +00:00
Jonas Ådahl
ea46ebea99 tests/stage-view: Added test for incorrect frame clock scheduling
The test attempts to reproduce gnome-shell#4486, and is fixed by
"window-actor/x11: Don't cache the frame-drawn frame clock".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1947>
2021-08-22 17:06:53 +00:00
Jonas Ådahl
d2186f6f1a window-actor/x11: Don't cache the frame-drawn frame clock
We fetch a frame clock that we schedule update on when queuing
_NET_WM_FRAME_DRAWN events. In some situations this frame clock is the
one from the stage, and if there are multiple hotplugs in a row, we
failed to update it as there were no stage views changes on the window
actor itself. As an actor updates the stage views list on layout, When a
queue_frame_drawn() call was done (typically from an X11 event) after a
second hotplug, it'd attempt to schedule an update on the frame clock
from the previous hotplug, as it didn't get notified about any
stage-views changes since for itself there was none.

Fix this by not caching the frame clock at all and just fetch it every
time.

In the majority of cases, this fetching means iterating over a very
short list (most often a single entry, rarely more), so it's very
unlikely to be of any relevance. The only situations where it might be a
heavier operation is the short time between a hotplug and a layout, as
it will attempt to traverse up to the stage to find a clock, but that's
likely only a few levels, so even that is unlikely to be an issue.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4486
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1947>
2021-08-22 17:06:53 +00:00
Jonas Ådahl
c8fb98a0a7 wayland/output: Fly-by coding style fix
Change 'GList *iter' to 'GList *l' in a few places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
bf7c34507d wayland/output: Make each wl_output correspond to one monitor
This is more in line with the protocol, and allows us to remove some
awkward code that tries to "combine" different metadata from different
monitors into one, which sometimes meant picking an arbitrary "main"
monitor, or "and" metadata together to find a common ground.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
4615da2122 monitor: Add hash function
Will be used to keep a monitor spec as a hash table key.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
fcbeae5f60 wayland/output: Move struct to C file
Avoids leaking implementation details outside.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
2b59b85d85 wayland: Fetch wl_output logical monitor via helper
Will be useful when wl_output gets tied to a MetaMonitor, instead of a
MetaLogicalMonitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
99531f9d4b wayland/surface: Get wl_output resource list via helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Ivan Molodetskikh
f6bf1ceb92 cursor-tracker: Add meta_cursor_tracker_get_scale ()
Used in the screenshot UI (and arguably should be used in the existing
gnome-shell screenshot drawing code).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1967>
2021-08-22 15:02:38 +00:00
Alexander Mikhaylenko
ed391eb06b window: Make default focus window on each workspace appear focused
Makes workspace transitions in gnome-shell look more seamless, since
both outgoing and incoming workspace have focused windows.

This is only done for click focus mode, since it's not known which
window would be focused for the other modes.

Track the state and recompute it when it changes, to avoid redrawing
the windows needlessly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:41:40 +05:00
Alexander Mikhaylenko
7afefbbb61 workspace: Add meta_workspace_get_default_focus_window()
Each workspace has a window that will be focused when switching to that
workspace. Add a function to retrieve that window.

This is only relevant for click-to-focus focus mode, since with the two
other modes no window will be focused upon switching, and will only gain
focus when hovered.

This will be used in the next commit to make this window appear focused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:39:05 +05:00
Alexander Mikhaylenko
448ffaefc5 stack: Check workspace in get_default_focus_window()
Check against the window argument, instead of active workspace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:39:05 +05:00
Jonas Ådahl
26e06845e3 plugins/default: Switch to g_spawn_check_wait_status()
The old one is deprecated and equivalent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1941>
2021-08-12 13:11:31 +00:00
Jonas Ådahl
23bebf3385 xwayland-grab-keyboard: Switch to g_pattern_spec_match_string()
The g_pattern_match_string() variant is deprecated, switch to the
properly namespaced one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1941>
2021-08-12 13:11:31 +00:00
Robert Mader
a96caf6def wayland-dma-buf: Fix 'kms-modifiers' experimental setting
The setting was ignored in favor of whatever the backend
returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1953>
2021-08-06 10:28:13 +00:00
Robert Mader
287c715df6 shaped-texture: Do not apply y-inverts to shape masks
This was introduced by accident in commit 1467b6b02a

y-inverted textures in combination with shape masks appear to
be only commonly used with EGLstreams. However, as we draw the
shape mask ourselves, we don't want to apply the y-invert to it
as testified by the left over `cogl_pipeline_set_layer_matrix()`.

Note that we still allow to apply viemports and buffer transforms,
as the Xwayland mode setting emulation may use it (in fact only
the former, but it probably does not hurt to leave the later as well).

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1937>
2021-08-04 15:08:12 +00:00
Florian Müllner
111055acdd wayland/gtk-shell: Add titlebar_gesture request
This allows client to delegate titlebar gestures to the compositor,
which allows for better consistency with server-side decorations,
and a wider range of actions (including lower-on-middle-click).

The protocol addition is based on a suggestion from Carlos Garnacho
and Jonas Ådahl.

https://gitlab.gnome.org/GNOME/mutter/-/issues/602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1944>
2021-08-04 14:41:43 +00:00
Florian Müllner
eed1db4379 window: Add meta_window_lower_with_transients()
The only thing x11-specific about the existing code is that it is only
used to implement titlebar actions on server-side decorations.

We are about to bring that functionality to wayland, so move the code
into MetaWayland.

https://gitlab.gnome.org/GNOME/mutter/-/issues/602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1944>
2021-08-04 14:41:43 +00:00
Marco Trevisan (Treviño)
3baf750e42 monitor-test-utils: Add debug friendly statements during tests
Monitor configuration check tests can be very complex and in case of
failures we can't easily catch where a failure happened without entering
in debug mode, something that isn't always an option in CI or external
builders.

So add more debug statements in configuration check functions and use
macros to ensure that we print the caller function and location on more
complex check functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
37e154c832 monitor-config-manager: Use match rule to check laptop panel visibility
Use the MONITOR_MATCH_VISIBLE match rule instead of doing the same check when
initializing the list of disabled monitor specs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
e59da5ad83 monitor-conifig-manager: Generate primary monitor config with others
Primary monitor is just the same of the other monitors, but it has a
primary monitor flag. Since the computation of the scaling isn't
dependent anymore on the computed configuration we can now generate the
primary monitor config together with the others.

However, we've to ensure that the primary monitor is the first of the
configs list in order to properly compute the positioning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
e8b84441a4 monitor-config-manager: Computer monitor scale in caller
Compute the monitor scaling in a separated function using the primary
monitor (not its config) and pass it to the creation function instead.

This will allow removing the special logic for the primary monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
aeea2882e5 monitor-config-manager: Use monitor match filters to create config
Factorize the creation of a configuration inside one function that looks for
the primary monitor and the other monitors using the matching rules and
dispose them according to the chosen policy (checking if the result is valid
when using the suggested positioning).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
3dbec4d709 monitor-config-manager: Define cleanup functions for structs
Monitor configuration structures can be used inside containers such as GList
and in order to have smart cleanups we need to define the relative free function

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
4574f2d9af monitor-config-manager: Use single filter function to build configs
Add a find_monitors function that allows to search for monitors that match
the MonitorMatchRule filter and use this to look for the primary monitor and
the other monitors that need to match the requested filter in order to be
configured.

Having just one function doing this kind of checks reduces the possibility
of unexpected results.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
32d7c5fbfb monitor: Only assign suggested positions to valid pointers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
ab48b6b933 monitor-unit-tests: Check suggested configuration has adjacent outputs
Verify that the suggested monitor configuration contains only adjacent monitors,
and that if this is not the case we fallback to the linear configuration.

This can happen in case of multi-DPI setup, so add a test checking this too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
be9e6dcc4f monitor-config-manager: Reject a suggested config with gaps
It could happen that monitors suggest to use coordinates that don't take
in consideration the scaling applied to one monitor, and such the
generated configuration is not valid because not all the monitors are
adjacent.

So enforce this check before accepting a suggested configuration as it
is.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
58c2f423f7 boxes: Add function to check if rectangle is adjacent to region
We may need to check if rectangles region has adjacent neighbors and
so if there are no gaps in between monitors.

This can be done by checking if each monitor is adjacent to any other in
the same region.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
d3602e9fef monitor-unit-tests: Add test for overlapping monitor config
Verify that when we've monitors with overlapping preferred configuration, we
fallback to the default linear configuration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Carlos Garnacho
36299494dd x11: Add COGL_HAS_TRACING checks around tracing code
This code sneaked unconditionally, even though we can disable
tracing code with -Dprofiler=false. Add some COGL_HAS_TRACING
checks so that this code is also optionally built.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1951>
2021-08-02 17:15:33 +02:00
Carlos Garnacho
a42c470efd compositor: Add COGL_HAS_TRACING checks around tracing code
This code sneaked unconditionally, even though we can disable
tracing code with -Dprofiler=false. Add some COGL_HAS_TRACING
checks so that this code is also optionally built.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1951>
2021-08-02 17:15:23 +02:00
Jonas Ådahl
ffb88bffc5 x11/window: Add tracing for X11 synchronization events
Add tracing and data gathering for processing related to
_NET_WM_FRAME_DRAWN and _NET_WM_FRAME_TIMINGS, used by some X11 clients
for synchronized rendering.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:37:12 +02:00
Jonas Ådahl
d956f63d67 x11/events: Trace X11 event handling
Traces the type of event, and how much time was spent processing it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
6c7765439f x11/events: Fly-by coding style cleanup
A large else block didn't have {}, so added them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
72704f787c x11/events: Clean up event name getting
Preparation for adding a generic "get event name" getter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Pascal Nowack
537e2dfafe core/selection: Cancel selection transfer requests after a timeout
When a selection owner advertises a mime type, but does not provide the
content upon a request for the mime type content, the requesting side
might wait indefinitely on the content.
To avoid this situation, add a timeout source, which will cancel the
selection transfer request after a certain timeout (15 seconds) passed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1874>
2021-07-28 15:26:04 +00:00
Pascal Nowack
20db6af4e6 remote-desktop: Check pipe fd before assuming existing read() operation
Currently, if g-r-d closes the read end of the pipe for a
SelectionRead() operation, due to realizing that the application, that
should provide the mime type content, does not provide any content,
mutter won't notice that and still assumes that the read() operation
on the pipe in g-r-d is still happening, as mutter never writes to the
pipe in that situation and therefore cannot realize that the pipe is
already closed.
The effect of this is, that if g-r-d aborts a read() operation and
requests a new read() operation via SelectionRead(), mutter will deny
the request since it assumes that the previous read() operation is
still ongoing.

Fix this behaviour by also checking the pipe fd in mutter before
denying a SelectionRead() request.

https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/issues/60

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1874>
2021-07-28 15:26:04 +00:00
Daniel van Vugt
9e6a3f537b background-content: Shrink and optimize the rounded-clip shader
The main benefit being it now fits within the hardware limits for the
i915 Mesa driver, and runs on the GPU instead of software fallback.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4251,
       https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4425

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1860>
2021-07-26 16:17:46 +08:00
Marco Trevisan (Treviño)
3e1e2cb91f monitor: Do not overlap when checking for applicable scaling values
With some resolutions (such as 4096x2160) we may compute duplicated
scale factors because we used a too wide threshold to check for an
applicable value.

In fact, while when we're at the first and last values it's fine to
search applicable values up to SCALE_FACTORS_STEP, on intermediate ones
we should stop in the middle of it, or we're end up overlapping the
previous scaling value domain.

In the said example in fact we were returning 2.666667 both when
looking to a scaling value close to 2.75 and 3.00 as the upper bound of
2.75 (3.0) was overlapping with the lower bound of 3.0 (2.75).
With the current code, the lower and upper bounds will be instead 2.875.

Adapt test to this, and this allows to also ensure that we're always
returning a sorted and unique list of scales (which is useful as also
g-c-c can ensure that this is true).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:19:15 +02:00
Marco Trevisan (Treviño)
c86a1e00c0 monitor-unit-tests: Check integer scaling values are matching expectations
A per previous commit we can now ensure that all the scaling values
when using non-fractional scaling have the value we expect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:06:10 +02:00
Marco Trevisan (Treviño)
98f3f96978 monitor: Never return fractional scale values when NO_FRAC is used
We introduced META_MONITOR_SCALES_CONSTRAINT_NO_FRAC to get global scale
values however, this didn't work properly for some resolutions.

In fact it may happen that for some resolutions (such as 3200x1800) that
we did not compute some odd scaling levels (such as 3.0) but instead
its closest fractional value that allowed to get an integer resolution
(2.98507452 in this case).

Now this is something relevant when using fractional scaling because we
want to ensure that the returned value, when multiplied to the scaled
sizes, will produce an integer resolution, but it's not in global scale
mode where we don't use a scaled framebuffer.

So, take a short path when using no fractional mode and just return all
the applicable values without waste iterations on fractional values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:06:08 +02:00
Marco Trevisan (Treviño)
f6e2059a65 monitor: Replace some useless goto with clearer returns
There was no point to use goto in place of normal returns here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 15:54:03 +02:00
Marco Trevisan (Treviño)
b088dbd90b monitor-unit-tests: Add tests to verify the computed scaling values
Scaling values computation code served us well in the past years but
it's quite delicate and it has some issues in edge cases, so add a test
that verifies that the computed scaling values for all the most common
resolutions (and some that may be common in future) are what we expect
to be.

This may also serve us in future when we'd define a better algorithm to
compute the preferred scale, but this not the day.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 15:50:44 +02:00
Marco Trevisan (Treviño)
4ca5a97ea8 monitor-manager: Only derive global scales supported by all monitors
When deriving the global scale from current monitor, we were just checking the
supported value by the primary monitor, without considering weather the current
scale was supported by other monitors.

Resolve this by checking if the picked global scale is valid for all active
monitors, and if it's not the case, use a fallback strategy by just picking the
maximum scale level supported by every head.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
1ab79c79a5 monitor-manager: Derive configured global scale using common value
When deriving the global scale from config, we need to ensure that the value
is matching all the monitor configurations.

If not, we should fallback to the normal scale value.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
7c87c1c24f monitor-manager: Check if all monitor scales are matching in global mode
When global scaling is set we need to ensure that all the requested scale
configurations are matching, otherwise we'd end up in a mixed setup that
we don't support in this scenario.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
1ac63fcd77 monitor-manager-xrandr: Use monitor to calculate scaling
In Xrandr we were caching the available scaling modes that were computed just
for the current mode, for each monitor, while we can actually reuse the
default implementation, by just passing the proper scaling constraint.

In monitor we need then to properly filter these values, by only accepting
integer scaling factors that would allow to have a minimal logical monitor
size.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:02 +02:00
Marco Trevisan (Treviño)
67eb60c19a monitor-manager: Pass the Logical mode when computing the monitor scale
In order to compute proper default scaling value we need to know if the
fractional scaling is enabled or not and thus if we're using a logical
mode or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 13:14:01 +02:00
Florian Müllner
ff14ed5ad9 compositor: Update outdated URL
The file was moved a while ago. Update the link to the new location,
and specify a particular tag instead of master to make sure this
doesn't happen again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1930>
2021-07-18 23:14:16 +02:00
Carlos Garnacho
414302fa82 backends: Promote g_debug() MetaStageImpl message to meta_topic()
We now have a META_DEBUG_BACKEND topic that can suit this bag of
assorted debug messages. Assign it to these, instead of plain
G_MESSAGES_DEBUG=mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:12:01 +02:00
Carlos Garnacho
dc6d3cead2 backends: Shuffle ClutterBackendX11 code into MetaClutterBackendX11
We have a Clutter implementation of the X11, just to subclass it in
our backends. Move the implementation entirely to src/backends/x11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
e77e88894b backends: Excise MetaStageView to its own file
It was implemented together with MetaStageImpl, move it to a separate
file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
d5c3c80dfe backends: Rename ClutterStage[View]Cogl API and types
Rename to MetaStageImpl and MetaStageView, so they are in line with
the rest of the backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
8f839b2f9c clutter: Move ClutterStageCogl[View] code to src/backends
This is now MetaStageImpl in backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
0ac257212e core: Add private utility function to get Clutter debug flags
This will be used to fetch the debug flags from backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
5785d8cde0 backends/native: Remove unused array definition
This array is a relic from the input code belonging to Clutter,
and is nowadays unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Jonas Ådahl
a2937a47bb onscreen/native: Change some g_debug() meta_topic()
g_debug() is inconvenient to use; change to meta_topic() with the 'kms'
topic. This makes it possible to enable valuable debug output at
runtime.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
d057762cdb device-pool: Add debug logging
Enabled by enabling the 'backend' debug topic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
4b6631338e util: Add 'backend' debug topic
Meant for backend things that are not large enough to warrant their own
topic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
b65555a958 renderer/native: Include error message in log entries
We had a GError handed to us, where we logged a warning, but didn't log
the message from the error. Do that so it becomes easier to find out
what might have failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:10:56 +02:00
Jonas Ådahl
58f053d437 drm-buffer/dumb: Return TRUE when init succeeded
Returning FALSE means it failed, but we returned FALSE even when it
succeeded, meaning it would never succeed.

Fixes: 10c4bc6e3f
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1880
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1888
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1932>
2021-07-16 17:18:55 +02:00
Jonas Ådahl
8a4aa92a54 context: Move the signal handling and dir management to user
Signals and changing current directory is a process global action, thus
isn't that suitable for a library. Thus, move that responsibility to
gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 13:40:34 +02:00
Jonas Ådahl
9cda0bd719 tests: Make common test code a shared library
This will require some symbol exporting, but the benefit is that have
better control of what external test cases can do in terms of creating
more testing specific contexts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 13:40:34 +02:00
Jonas Ådahl
d8107027ef tests/test-utils: Move test client path ensure helper to private header
It's only used from the test context, and the main test utils header
file will be used to export helper functionality, so move it out,
preparing for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
724a7eee74 tests: Move 'wait-for-X11-display' helper to MetaContextTest
Gets rid of a un-prefixed helper function relying on a global singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
e8742be568 tests/test-utils: Remove unused init function
This is now dealt with by MetaContextTest.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
3d5a2b2ffb context/test: Make type derivable
This makes it possible to declare the type in an installed header (so
that e.g. META_CONTEXT_TEST(context) works), but without having to
expose the MetaContextClass struct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
acb0a44224 tests: Prefix test plugin name getter with meta_
It'll be used via the new shared library, so prefix it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
9f1f3139b8 tests/utils: Prefix AsyncWaiter with Meta
This too will be used by test cases via a shared library.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
4a6e22311a tests/utils: Prefix TestClient with Meta
Soon we'll expose it via a libmutter-test library.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
f74d311d61 tests: Rename test-utils.c/h to meta-test-utils.c/h
Otherwise it'll conflict with other files with identical filenames,
if one would add src/tests/ to the include path, which will happen in a
later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:39 +02:00
Jonas Ådahl
ff0afb186a context: Move 'replace-current-wm' tracking to the context
This move yet another scattered global static variable into the
context's control.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
50ed027b6f context: Move X11 display policy under the context
The context implementations already effectively dictate the policy, so
let them do it more directly instead of going indirectly via global
variables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
e62f7e2910 context: Allow controlled destruction
Add a method meta_context_destroy() that both runs dispose and unrefs
the context. Tear down is moved to dispose() so that things owned by the
context are destroyed when calling meta_context_destroy(), or when the
last reference is released.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
2deb751fd9 context: Add explicit state tracking
This will help finding out when things happen in the wrong order.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
c1beb204c2 x11-display: Get _GNOME_WM_KEYBINDINGS from the context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
7d0aaa14d1 x11-display: Get _NET_WM_NAME from context
It's equivalent to the name that was passed when the context was
created.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
d3b7d8df0d wayland: Initialize in a single step
Before we first created the MetaWaylandCompositor instance, which would
repare Clutter/Cogl so they could initialize and turn on Wayland display
server features, then later to initialize the rest. Now that part is
done by the Wayland infrastructure itself, so we don't need the early
initialization. Simplify things a bit by centralizing it all into a
single meta_wayland_compositor_new() call.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
0330ce1f15 context: Make the context own MetaWaylandCompositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
6768b509ea Remove meta_quit()
It is no longer used, so remove it. This also removes the intermediate
MetaContext global singleton, as it is no longer needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
122aa94642 x11/session: Use MetaContext to terminate instead of meta_quit()
This is done by keeping around a pointer to MetaContext as
"client_pointer" (which is practically the same as "user_pointer"
elsewhere), as well as creating a `MetaIceConnection` wrapper for ICE
connections.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
9523120241 x11/events: Use MetaContext to terminate instead of meta_quit()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
e8af5fd398 display: Keep pointer to the context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
4be9bc9db4 stage/x11: Terminate using MetaContext instead of meta_quit()
Done for the nested backend when clicking the close button.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
7d116bee0f main: Move MetaX11DisplayPolicy to a new meta-private-enums.h
As with the compositor type enum, also have the X11 display policy enum,
as it's also effectively part of the context configuration. But as with
the compositor type, move it to a header file for enums only, and since
this is a private one, create a private variant meta-enums.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:36 +02:00
Jonas Ådahl
68b376a944 context: Make context owner of MetaDisplay
It may still be closed from elsewhere, e.g. when being replaced, but the
reference is owned by MetaContext instead of itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
b1c643eeaa context: Make the context owner of the backend
There is still the `_backend` singleton still, as there are still the
`meta_get_backend()` that needs to work for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
1972d4ec90 main: Remove now unused functions used for running mutter
The way to do this now is using a MetaContext.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
ed53dd90f3 context: Add way to add custom option group
This will be used by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
d76743736f context: Add way to set plugin GType instead of name
Will be used by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
fe0ce2814e main: Remove meta_test_init()
This was the last user of the configuration override API, so that goes
as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
1d4224ab07 tests/persistent-virtual-monitor: Port to MetaContext
Since this tests the `--virtual-monitor` command line argument, it uses
the `MetaContextMain` variant of the context, as it's there that command
line argument is handled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
725510ea29 mutter: Port to MetaContext
Uses the new MetaContextMain, replacing piece by piece "real display
server" setup done using mostly main.c functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
aa306ac3ca Introduce MetaContextMain
This object intends to replace the scattered functions that are used to
make up what is effectively a "mutter context". It takes care of the
command line arguments that is now done in main.c, persistant virtual
monitors, and the like.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
2ac262f138 tests/clutter: Port to MetaContext
The clutter tests neeed to start and stop, thus uses their own main loop
instead of the one in MetaContext. Shouldn't matter, since nothing
in mutter should happen that makes the test self-terminate from inside
mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
2f19a5f28d context/test: Add 'no-x11' and 'test-client' constructor flags
The 'no-x11' one will inhibit Xwayland from starting, and 'test-client'
will make sure the test client path is properly discovered.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
07384e18c5 clutter: Remove clutter_init_with_args()
Not used anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00