1
0
Fork 0
Commit graph

1544 commits

Author SHA1 Message Date
Michel Dänzer
63a7313a1b compositor: Fold meta_compositor_do_manage into meta_compositor_manage
meta_compositor_manage hasn't been public API since 4b3cab2cca
("compositor: Don't make internal API public").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
msizanoen
6b79a0bae1 cullable: Split unobscured and redraw clip region culling
This splits culling into two different phases to move unobscured region
culling to pre-paint to fix #2680. This is needed as direct scanout
skips the paint phase altogether, but the pre-paint phase always runs as
it's used for selecting the direct scanout surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3127>
2023-08-12 10:27:45 +00:00
Carlos Garnacho
71fb87a9f2 compositor: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
72c433ef02 compositor: Stop forwarding MapNotify events back through the backend
Nowadays, all our MapNotify event handling happens already prior to
the MetaCompositorX11 handling of XEvents. It does not make sense to
channel these events again through the backend, at best all it could
lead to is double handling of the same events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Bilal Elmoussaoui
a955f0e47c cleanup: Make include macro usages consistent
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
ead9a3024c cleanup: Switch to pragma once
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
8d038789f6 clutter: Remove deprecated macros usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Niels De Graef
3dd9f15eba shaped-texture: Start using MetaMultiTexture
To be able to later support more complex YUV formats, we need to make
sure that MetaShapedTexture (the one who will actually render the
texture) can use the MetaMultiTexture class.

Co-Authored-By: Robert Mader <robert.mader@collabora.com>
Co-Authored-By: Daniel van Vugt <daniel.van.vugt@canonical.com>
Co-Authored-By: Sebastian Wick <sebastian.wick@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2191>
2023-07-25 21:24:35 +00:00
Niels De Graef
5181a826d1 compositor: Add MetaMultiTexture class
In future commits, we want to be able to handle more complex textures,
such as video frames which are encoded in a YUV-pixel format and have
multiple planes (which each map to a separate texture).

To accomplish this, we introduce a new object `MetaMultiTexture`: this
object can deal with more complex formats by handling multiple
`CoglTexture`s.

It supports shaders for pixel format conversion from YUV to RGBA, as
well as blending. While custom bleding is currently only required for
YUV formats, we also implement it for RGB ones. This allows us to
simplify code in other places and will be needed in the future once
we want to support blending between different color spaces.

Co-Authored-By: Robert Mader <robert.mader@collabora.com>
Co-Authored-By: Sebastian Wick <sebastian.wick@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2191>
2023-07-25 21:24:35 +00:00
Bilal Elmoussaoui
b852bbba47 cleanup: Stop translating nick/blurb for pspecs
As those strings are intended to be used by some UI but nothing uses
that in reality except GStreamer.
So drop them similar to what GTK did at
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4717

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3101>
2023-07-19 11:33:59 +00:00
Carlos Garnacho
281d896f6a compositor: Do not repick after effects finish
This was a temporary fix until there was a better crossing event
delivery mechanism that accounted for actor changes beneath the pointer.
We nowadays have that, and don't seem to need this extra kick to get
crossing events triggered (and cursor changes, etc) when windows appear
or disappear under the pointer.

This commit is effectively a revert of commit
a64dba4d7a.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6808
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3104>
2023-07-06 11:31:32 +00:00
msizanoen
842f73ac4c window-actor: Fix screencast with fractionally scaled surfaces
Instead of using `clutter_actor_get_resource_scale()`, we now deduce the
intended buffer scale from the window by dividing the unscaled size by
the final actor size. This is more correct as while the return value of
`clutter_actor_get_resource_scale()` depends only on the monitor where
the surface resides, the actual scale of the surface is determined
solely by the application itself. `get_resource_scale` will differ from
the actual buffer scale if the application only supports 100% scaling
(Xwayland), or is performing scaling with wp_viewporter (clients using
fractional_scale_v1).

This also fixes a mismatch between the calculated buffer sizes between
`meta_window_actor_get_buffer_bounds` and
`meta_window_actor_blit_to_framebuffer` which causes broken
screencasting for Chromium 114 and later when using the native Ozone
Wayland backend.

Additionally, this commit also changes
`meta_window_actor_blit_to_framebuffer` from using a simple translation
to using an inverted matrix transformation of the transformation matrix
between the parent of the window actor and the surface actor to ensure
maximum sharpness for fractionally scaled windows.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3053>
2023-06-29 13:37:47 +00:00
msizanoen
742d026479 shaped-texture: Introduce get_unscaled_{width,height}
This allows other code to obtain the size of the surface after all
transformations except for scaling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3053>
2023-06-29 13:37:47 +00:00
Jonas Ådahl
0884747dce window-actor/x11: Fix using shape region for input
There were two issues with using the shape region to derive an input
region.

Firstly, the shape region is against the client rectangle, while the
surface actor needs it to be against the buffer rectangle. Fix this by
offsetting the shape region before passing it along.

Secondly, we can't just intersect the shape and input region, since that
leaves out the window decorations. Fix this by only intersecting the
input region covering the client part, and the shape region, and then
union that with the input region covering the rest.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3045>
2023-06-02 22:41:35 +02:00
Jonas Ådahl
340d585f91 compositor: Reparent the backend window unmanaging the display
Under X11 hiding the backend implies also unmapping the stage window, if
we do that after that we've closed the display we may end up in a
BadWindow error because such window seems to be destroyed together with
the compositor output parent (even though we are not notified about), so
to prevent this, reparent the backend window during compositor unmanage,
setting it back as a root window child.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Robert Mader
4a5a31edc6 mutter: Remove stray spaces
To silence code-style-check complains.

Fixes d44f02ba64

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3018>
2023-05-24 14:16:41 +02:00
Bilal Elmoussaoui
d44f02ba64 mutter: Cleanup gi-docgen annotations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2939>
2023-05-22 15:47:37 +00:00
msizanoen1
ae4755cc61 surface-actor: Fix meta_surface_actor_is_obscured_on_stage_view
`meta_surface_actor_is_obscured_on_stage_view` currently fails to
account for non-identity scaling of actor size (e.g. window actor
geometry scale or surface pixel alignment).

Fix this by using the new `meta_region_apply_matrix_transform_expand` to
calculate the unobscured region in stage coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
231729b7f2 window-actor/wayland: Check opacity before subtracting background in cull
This ensures that the background regions don't get marked as obscured if
the window itself is transparent (e.g. in window animation).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
caca38106f surface-actor: Use clutter_actor_get_paint_opacity
This prevents opaque regions from being subtracted from the unobscured
regions while MetaWindowActor is transparent (e.g. in window close
animation).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
8b3c1f4b87 cullable: Generalize actor coordinates space translation for regions
This allows MetaCullable to work with actors using arbitrary transforms
which will be needed for implementing surface pixel alignment for
fractional-scale-v1.

This also deletes meta_cullable_is_untransformed as it's no longer
necessary, and we can also stop manually scaling the region objects
while performing opaque region culling in surfaces since it's now
handled transparently by the new `meta_cullable_cull_out_children`
implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
e94b527777 surface-actor/wayland: Implement stable size and position rounding
Implement the stable rounding algorithm as described in the discussions
for the fractional-scale-v1 protocol.

This adds an override of the ClutterActor::apply_transform vfunc for
MetaSurfaceActorWayland that ensures the size and position of the
contents of the surface are rounded according to the stable rounding
algorithm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
msizanoen1
ed90c78872 window-actor/wayland: Align window content to physical pixel
Always ensure that the MetaSurfaceContainerActorWayland is aligned to physical
pixel boundary in preparation for fractional-scale-v1 protocol support.

This introduces an override of ClutterActor::apply_transform vfunc for
MetaSurfaceContainerActorWayland that always ensures the actor content is aligned
to physical pixel boundary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2726>
2023-05-22 14:44:33 +00:00
Bilal Elmoussaoui
15b25568b2 compositor/x11: Drop duplicated methods calls
Those are called in the handler of MetaDisplay::x11-display-opened

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:41:54 +02:00
Bilal Elmoussaoui
3e95609073 compositor/dnd: Guard X11 types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
aaa3f34cc0 compositor: Guard X11 types
This also moves meta_compositor_x11_redirect_windows to DisplayX11
where it makes more sense as meta_display_x11_redirection_windows

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:23:37 +02:00
Marco Trevisan (Treviño)
8039b58410 x11/x11-display: Always set the compositor manager selection on init
Set the compositor manager selection during the initialization phase as
we do with the window manager selection

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:37 +02:00
Marco Trevisan (Treviño)
2625edec10 x11/x11-display: Set compositor selection earlier on XWayland
When the X11 display is actually XWayland there's no point to delay the
compositor selection, given that mutter itself is the compositor and
doing this may cause the first X11 client that starts not to receive the
right information (and in some cases misbehave).

Since some toolkits are not handling the compositor selection changes
properly at later times, let's make their life easier by just
initializing the selection as early as the other X11 properties, given
that in this case there's nothing to replace.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:04:59 +02:00
Jonas Ådahl
802c1baec7 compositor-view: Chain up finalize()
The chaining up to the GObject finalize() method was missing, fix that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2991>
2023-05-09 10:31:38 +00:00
Robert Mader
9884a2c3d2 shaped-texture: Move variable declaration to the top
Just a minor cleanup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2990>
2023-05-07 23:18:33 +02:00
Jonas Ådahl
61b42e5303 build: Use / operator instead of join_paths everywhere
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2985>
2023-05-04 12:35:38 +00:00
msizanoen1
3f85158b85 surface-actor: Queue rectangles of update region separately
This aims to help reduce the amount of pixels redrawn on the screen in
case the damage rectangle is partially occluded by another surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2965>
2023-05-03 08:53:36 +00:00
msizanoen1
ce0d9ccb37 dnd: Clear Wayland drag source when cancelled from stage grab context
This ensures that applications are notified when a drag gets cancelled
because the user dropped or press ESC while in overview.

This fixes an issue with Chromium on Wayland refusing to acknowledge
wl_pointer::enter events after accidentally dropping a
Chromium-originated object in GNOME Shell overview.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2953>
2023-04-15 10:11:07 +00:00
Carlos Garnacho
f3f1db5e33 compositor: Drop anchor_window_pos field from MetaWindowDrag
This is now only set and never used. We can remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Carlos Garnacho
7eb0130425 compositor: Use relative anchor coordinates for window drags
The anchor position calculations are somewhat unnecessarily complex
based on root coordinates of pointer and frame positions. This requires
tracking both things, and we don't always get it quite right with the
latter (e.g. window repositions, resizes or overshrinks, leaving the
anchor position visually outside the window).

In order to improve this, capture the window-relative coordinates
when starting the window drag, and ensure the window is always repositioned
in that position, relative to its current size.

This avoids these glitches when unmaximizing a window (e.g. dragged from
the bottom through super+button1 press), or moving windows between monitors
with different scales.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2730
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Carlos Garnacho
179124dc61 compositor: Avoid use of variable during resize
Since we only track changes to window_drag->anchor_window_pos
during move operations through on_grab_window_size_changed(), this
rectangle is in essence the same than window_drag->initial_window_pos
all the time. Just use that and move away from the anchor_window_pos
rectangle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942>
2023-03-29 16:36:28 +00:00
Jonas Dreßler
7455c293c6 window-actor-x11: Check array bounds before accessing array
scan_visible_region() scans through each value of a uint8_t array and checks
whether that value is 255. Right now it always checks one value too much
though, resulting in a buffer overflow. Fix that by checking the array
bounds before actually accessing the array.

Found by running gnome-shell with address sanitizer and starting
GIMP.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2856>
2023-03-26 11:51:02 +00:00
Florian Müllner
f14dcb023d compositor/window-drag: Fix keyboard resize
Both GRAB_OP_KEYBOARD_MOVING and GRAB_OP_KEYBOARD_RESIZING_* are
defined as GRAB_OP_WINDOW_BASE with FLAG_KEYBOARD set, but the
latter have additional bits set to indicate the direction.

That is, the GRAB_OP_KEYBOARD_MOVING bitmask cannot be used to
differentiate between move- and resize operations. Instead,
check that no direction bits are set.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2908>
2023-03-20 16:13:32 +00:00
msizanoen1
aad0baf70d shaped-texture: Account for linear sampling when calculating actor damage
Linear sampling can influence the value of surrounding pixels beyond
the scaled framebuffer extents calculated during stage view rendering,
resulting in flickering graphical artifacts due to unaccounted pixel
changes. This is exhibited in xfreerdp and wlfreerdp at 150% display
scaling.

Fix this by ensuring that all pixels that may be affected by linear
scaling is included in the framebuffer redraw clip by padding the actor
redraw clip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2771>
2023-03-04 18:23:34 +00:00
Carlos Garnacho
1fbbb73343 compositor: Add utility function to convert region to cairo_t path
We were relying on gdk_cairo_region() to convert a cairo_region_t
into a path ready to fill/stroke in a cairo_t. This is a small
and detached helper that we can do ourselves, so put it together
with all other region helper functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Robert Mader
4409dd24b6 surface-actor/wayland: Ensure screen-casted surfaces have a primary view
Surfaces belonging to a screen-casted window should always be considered
visible even if they are not visible on any stage view - be it because
they are on a different workspace, minimized or occluded.

Doing this in an optimal fashion is highly complex right now -
interdependent with (and somewhat similar to) ClutterClones. Thus treat
stream-casted surfaces similar to those with clones, with the small
difference that even a fully invisible surface still gets a primary view
- the fastest one. This ensures that clients never refresh too slow for a
screen-cast, at the cost of sometimes refreshing too fast.
The later only happens on certain multi-monitor setups and should thus be
acceptable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2789>
2023-02-28 12:03:50 +01:00
Robert Mader
2d5dd06a50 screen-cast/window: Add API to check if stream-cast is active
Screen-casted windows need to be considered visible in various situations
but existing APIs such as `clutter_actor_is_effectively_on_stage_view()`
don't do so. Add new API that allows checking if a surface belongs to a
screen-casted window for the respective cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2789>
2023-02-28 12:01:17 +01:00
Carlos Garnacho
5bdc08099e compositor: Fix handling of keyboard-driven window resize
The introduction of the META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED
flag threw off some checks around keyboard-driven resize. This
was partly because there were some == checks that did not account
for that flag maybe being enabled, but also the handling
of META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN into a definite
resize direction was maybe unsetting that flag. Fix both things
at the same time.

Fixes: 2d8fa26c8e ("core: Pass "frame action" grab operations as an "unconstrained" grab op")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2629
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2871>
2023-02-27 18:28:44 +00:00
Jonas Ådahl
b2579750a7 cogl: Remove legacy OpenGL driver support
This means the two Cogl drivers left are OpenGL >= 3.1 and GLES >= 2.0.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2672>
2023-02-21 18:09:28 +00:00
Jonas Dreßler
65b93e1d45 window-drag: Check whether window is set when hiding tile preview
In the case where we early-out from meta_window_drag_begin(), the
effective_drag_window might not be set yet. In this case, we might finalize
the object before effective_drag_window is set, leading to a NULL pointer
when accessing window->display in hide_tile_preview().

To avoid that crash, add a check whether the window is set already. If no
window is set, we can just skip hiding the preview anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2858>
2023-02-20 17:16:56 +00:00
Sebastian Wick
17c52854b7 default-plugin: Handle unmanaging windows in switch_workspace
Also add a regression metatest.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2559
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2782>
2023-02-01 16:21:55 +01:00
Carlos Garnacho
c6d23f67f0 compositor: Move tiling preview management to MetaWindowDrag
And release MetaDisplay from handling this management. Window tiling
previews are only triggered from window drags, and are implicitly tied
to them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
f04d84de65 compositor: Move edge resistance data to MetaWindowDrag
At least indirectly, this is set as object qdata while the
window drag is ongoing, and reset/reconstructed if needed.

Consequently, this edge data does not need to be stored in
the MetaDisplay struct anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
675d0df09b compositor: Make cleaning cached edges go through MetaWindowDrag
Even though the data is still stored in the display, add a "high
level" meta_window_drag_update_edges() call, so that the cached
edges may be updated while a window drag operation is ongoing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
60f11e419f compositor: Pass MetaWindowDrag to edge resistance functions
This code will be poked exclusively from the MetaWindowDrag, so
change the API to start passing this object around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
36bda45888 core: Move edge-resistance handling to src/compositor
This is now something that is mainly handled from the compositor
side, so it makes sense to move it there. Following commits will
cut all ties with src/core.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
d687e5634d core: Pass device/sequence on meta_window_begin_grab_op()
This is a public API change. Add device/sequence parameters to this
operation, so that window dragging and resizing can stick to one
set of pointing events of them all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
b2ebe9c262 core: Move accounting of "shaken_loose" to MetaWindowDrag
It's entirely accessed from there (besides reset and initialization),
so can be completely taken there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
bec8a5860a core,wayland,compositor,x11: Migrate to MetaWindowDrag
Flip the switch in using MetaWindowDrag, leaving display grab
ops and a bunch other code unused. Some places checked the grab op
and/or window in complex ways, others just checked for grab existence
and should now look for clutter ones, and others already were already
doing this in addition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
db1c64fe06 compositor: Add window/grab_op getters to MetaWindowDrag
This will be useful in porting, since there's still places that
check the current grab operation, or check a window against the
currently dragged window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
fc4287cd20 compositor: Add high level API to deal with MetaWindowDrag
This helper object (and the whole window drag operation) will be
requested to the compositor instead of created directly, and only
one of those can exist at a time, so the compositor will also
safeguard that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
e6d0e0fda6 compositor: Add method to update MetaWindowDrag after resizes
Since SSD X11 windows require synchronization between frame and client
windows on resizes, updates do not always happen immediately but in
control of external factors (i.e. when both windows become to have
a coherent size).

This method will be used to update the window position between
resize/sync operations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
14006adf6f compositor: Handle pointing events in window drags
This code is largely copied from src/core/window.c, taking care
of pointer/touch interaction during window drag operations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
dd3e5d2b52 compositor: Handle keyboard events in window drag operations
This is code largely copied from src/core/keybindings.c, taking
care of keyboard interaction during window drag operations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
d8f6b4be9b compositor: Add MetaWindowDrag helper object
This compositor-side object will single-handedly drive a window
drag operation. Currently, this largely copies meta_display_begin_grab_op
and meta_display_end_grab_op, except grabbing is done through a
ClutterGrab instead of direct meta_backend_grab_device() calls. This
also means that the switch from passive to active keyboard grabs is
handled differently.

Currently, this object is dormant. It requires moving more code from
other places to become a fully functional replacement.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Jonas Ådahl
08b0e563d4 clutter: Pass 'ClutterFrame' in all stage update signals
That means before-update, prepare-paint, before-paint, paint-view, after-paint,
after-update. While yet to be used, it will be used as a transient frame
book keeping object, to maintain object and state that is only valid
during a frame dispatch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 15:57:50 +01:00
Carlos Garnacho
2b6651327e compositor: Observe frame opaque region when updating shapes
Apply either frame or client window opaque regions (or both as
an union). For client windows without an alpha channel, the frame
shape already contains the client area. If the client window does
have an alpha channel, the client rectangle is cleared to let the
client's opaque region take care of it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2555
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
e4ee40d7ff compositor: Wrap x11 surface actor destruction in error trap
This does a number of X11 calls. For what it might happen, better
wrap these in error traps.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2793>
2023-01-19 13:57:35 +00:00
Carlos Garnacho
2be5662ee9 compositor: Wrap XDamageCreate call with error trap
I hit this rare error running the "x11" test from the suite locally:

(mutter:194027): Gdk-ERROR **: 18:21:52.525: The program 'mutter' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
  (Details: serial 663 error_code 9 request_code 143 (DAMAGE) minor_code 1)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

The only call from the Damage extension in use by Mutter that could
return BadDrawable is XDamageCreate(), and it's likely to be this
call. Wrap this X11 in an error trap, in order to catch possible
failures.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2793>
2023-01-19 13:57:35 +00:00
Bilal Elmoussaoui
8b42bc77dc build: Make GTK dependency specific to X11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
4d7aedf90a compositor: Drop debug helpers
They can no longer be used as libmutter will drop it gdk/gtk
dependencies in the upcoming commits

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
b0b21e8274 default-plugin: Remove unnused field
This drops the usage of GdkRGBA

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:09:03 +01:00
Bilal Elmoussaoui
fb4161853f cleanup: Make GDK dependency specific to X11
This way, the dependencies on GTK/GDK could be completely dropped if
built with Wayland only.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:09:03 +01:00
Jonas Ådahl
d7f26136b4 later: Remove old API
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
d7f5477103 compositor: Enable introspection
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
7a62e55c54 laters: Turn into GObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
4b3cab2cca compositor: Don't make internal API public
Things like meta_compositor_destroy() and meta_compositor_add_window()
isn't intended to be used externally, and if they was, things would
probably fall apart rather quickly.

MetaCompositor also isn't introspected, meaning things that technically
belong to the compositing parts isn't easily available via some object,
but much take detours via other objects like MetaDisplay.

So move the API intended for internal usage to compositor-private.h, and
leave API that is meant to be expose in the public compositor.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
5e67e35ec5 compositor: Setup and use ownership chains
As with the backend commit, this means all objects can reach the
MetaContext by walking up the chain, thus can e.g. get the backend from
the context, instead of the global singleton.

This also is a squashed commit containing:

compositor: Get backend via the context

The MetaCompositor instance is owned by MetaDisplay, which is owned by
MetaContext. Get the backend via that chain of ownership.

dnd: Don't get backend from singleton

window-actor: Don't get backend from singleton

dnd: Don't get Wayland compositor via singleton

background: Don't get the monitor manager from the singleton

plugins: Don't get backend from singleton

This applies to MetaPlugin, it's manager class, and the default plugin.

feedback-actor: Pass a compositor pointer when constructing

This allows getting to the display.

later: Keep a pointer to the manager object

This allows using the non-singleton API in idle callbacks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
4cc5e6d2bd compositor: Add API to get feedback group
It already had, except it was accessed via the MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
7e974ba6cc backend: Get 'is-stage-views-scaled' from backend
It did, but used the old backend singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 13:52:51 +00:00
Robert Mader
f9085b9f58 window-actor/wayland: Return NULL instead FALSE in get_scanout_candidate
Fixes 2933ca9e1c

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2765>
2022-12-16 20:42:45 +01:00
Robert Mader
3d618d5e45 window-actor/wayland: Ignore unmapped subsurfaces in direct scanout check
Clients expect us to ignore them, thus do so. Right now, if the topmost
subsurface is an unmapped subsurface, it will fail the
`meta_surface_actor_is_opaque()` check if it was never mapped before.
Further more, unmapped subsurfaces would wrongly disable our "only one
surface and fullscreen" optimization.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2755>
2022-12-16 17:20:11 +00:00
Robert Mader
292a8500ed surface-actor-wayland: Clean up and optimize check for primary view
Avoid some allocations, save some CPU cycles and make the code easier
to read.

Behaviourwise the only expected change is that now, if there are mapped
clones, we unconditionally choose the view with the highest refresh
rate the actor (or one of its clones) is on and don't check the
obscurred region any more.

Thus in some cases a client may receive a higher rate of frame callbacks
when obscured on a faster view while a clone is present on a slower
one. The assumption is that cases like this are relatively rare and
that the reduction of code complexity, the reduction of allocations in
`meta_surface_actor_is_obscured_on_stage_view()` whenever the actor is
not fully obscured and has clones on other views, as well as generally
fewer lookups and less code in most common cases, compensate for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2671>
2022-12-16 16:27:33 +00:00
Robert Mader
04655c8bff feedback-actor: Disable direct scanout during lifetime
We only support feedback-actors, such as DnD-icons, in the compositing
path at the moment.

The approach is similar to how we handle certain shell elements.
Implementations need to ensure no references to the object keep
around longer that necessary.

Arguably this should be replaced by a more robust and implicit actor
hierachy detection in the direct scanout code at some point.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2677>
2022-12-16 15:25:41 +01:00
Robert Mader
2933ca9e1c window-actor: Add 'render' debug prints
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2680>
2022-12-09 20:14:26 +00:00
Robert Mader
bf6e735ef7 compositor-view/native: Add 'render' debug prints
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2680>
2022-12-09 20:14:26 +00:00
Georges Basile Stavracas Neto
381de44c5d window-actor: Use logical monitor scale on cursor scale
When using 'scale-monitor-framebuffer', it's important to use the
monitor's scale on top of the cursor texture scale. This matches
what the monitor screencast source does.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2737>
2022-12-03 15:22:31 -03:00
Georges Basile Stavracas Neto
1f705ee10a window-actor: Apply resource scale to cursor position
meta_screen_cast_window_stream_src_set_cursor_metadata() relies
entirely on meta_screen_cast_window_transform_cursor_position()
to return the correct relative cursor position.

However, this function actually does not return the expected
values, since it does not apply the resource scale to the
transformed position.

Actually apply the cursor scale when calculating the cursor
position.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2737>
2022-12-03 15:21:46 -03:00
Carlos Garnacho
20bf7f5ceb x11: Delay next resize op after sync resize until frame is painted
Since the frames are now rendered by a separate process, we no longer
can guarantee at this point that all updates were handled. Engaging
in a new synchronous resize operation will again freeze the actor,
so sometimes we are left with a not-quite-current buffer for the
frame+window surface.

In order to ensure that the right changes made it onscreen, delay
this next synchronous resize step until the moment the surface was
repainted. This avoids those glitches, while still ensuing the
resize operation ends up in sync with the pointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
9feac5ce62 compositor: Opt out compositor shadows from windows with frames
Let the frames client render its own shadow. In order to do that,
avoid double painting a shadow on the compositor side, and extend
the mask area of the frame, so it does unveil the (so far)
hidden frames-client-side shadows.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
f2237fa0c8 x11: Add frame synchronization to window frames
There's two meanings of "frame" there! Since SSD frames are now
rendered by an external client, and there are no actual mechanism
that ensures the frame did already get painted when the client did
respond to its NET_WM_FRAME_SYNC_REQUEST request, there may be
artifacts when resizing windows.

In order to get always the best visual result, we should actually
synchronize rendering with both the client window and the window
frame window.

This commit adds these mechanisms, so a sync alarm update is
expected on both windows until further resizes are allowed, this
ensures window and frame stay in sync, even after moving rendering
elsewhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
b891f8a52c compositor: Move frame drawn x11 management to MetaSyncCounter
This is part of the same MetaSyncCounter mechanism, so move it together
on one place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:52 +00:00
Carlos Garnacho
740b8e8cce x11: Replace MetaWindow sync request handling with MetaSyncCounter
Put the helper to use, in order to lift MetaWindow itself from this
accounting. As a bonus, the data itself now moved to the MetaWindowX11
private struct, since this may only happen with X11 windows (or its
Xwayland subclass).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:52 +00:00
Carlos Garnacho
ab06232dbe compositor: Ensure atom existence initializing DnD
These only exist because GTK creates them ahead of us, stop relying
on that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:52 +00:00
Michel Dänzer
80c6b7d82b wayland/surface: Use transactions for all sub-surface hierarchy changes
And keep track of the hierarchy separately for the Wayland protocol and
for output. Protocol state is updated immediately as protocol requests
are processed, output state only when the corresponding transaction is
applied (which may be deferred until the next commit of the parent
surface).

v2:
* Directly add placement ops to a transaction, instead of going via
  pending_state.
* Use transaction entry for the sub-surface instead of that for its
  parent surface.
v3:
* Use transaction entry for the parent surface again, to ensure proper
  ordering of placement ops, and call
  meta_wayland_surface_notify_subsurface_state_changed only once per
  parent surface.
* Drop all use of wl_resource_add_destroy_listener, transactions are
  keeping surfaces alive as long as needed.
v4:
* Rebase on https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2501
* Drop ClutterActor code from meta_wayland_surface_apply_placement_ops.
  (Robert Mader)
v5:
* Rename MetaWaylandSubSurfaceState to MetaWaylandSurfaceSubState, since
  the next commit adds not sub-surface specific state to it.
v6:
* Move include of meta-wayland-subsurface.h from
  meta-wayland-transaction.c to .h, since the latter references
  MetaWaylandSubsurfacePlacementOp.
v7:
* Drop superfluous !entry check from meta_wayland_transaction_apply.
v8:
* Rename output/protocol fields to output/protocol_state. (Jonas Ådahl)
v9:
* Use meta_wayland_surface_state_new in
  meta_wayland_transaction_add_placement_op.
v10:
* Fix a few style issues per check-style.py.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880>
2022-12-01 12:41:32 +01:00
Jonas Ådahl
db1000e264 plugin-manager: Don't try to starte effect when shutting down
Add internal state (starting, running, stopping), and use this instead
of MetaDisplay struct fields to determine whether to start animations.

This fixes issues when we try to animate things when shutting down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2716>
2022-11-25 10:26:52 +00:00
Corentin Noël
66dcef7ac1 window-actor: Add several (nullable) annotations
Many getters might return a NULL value, let's reflect this in the annotations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2715>
2022-11-24 15:16:13 +01:00
Jonas Ådahl
eb7abdacd8 plugin/default: Autostart localed when querying keyboard layout
Otherwise it's required that systemd-localed is already running, which
is unlikely, since it will auto-terminate by default.

Fixes: 562024f746
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2710>
2022-11-24 01:16:31 +00:00
Bilal Elmoussaoui
6b77532a23 window: Move surface property to it subclasses
As we have specific window types per display server,
having it in the parent class makes building without wayland
harder to achieve

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
2022-11-17 11:30:56 +00:00
Sebastian Wick
d6d6dc65c1 window-actor/wayland: Do not crash when there is no monitor
When all monitors are blanking or after suspending there might not be
any monitors temporarily. We can't draw a black background when we don't
know the size of the monitor it's fullscreen on but it's fine because
there actually is no monitor.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2508
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2695>
2022-11-15 22:46:30 +01:00
Sebastian Krzyszkowiak
e331e38a19 shaped-texture: Reset pipelines after setting a texture with new size
Attaching a new buffer with a different size than the old one means
that the viewport needs to be recalculated.

Not doing this caused the viewport to be incorrectly applied when
viewport_src_rect remained the same after attaching such buffer.
Pipeline reset usually happens when applying a new viewport,
but it doesn't happen when the viewport values remain the same.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2689>
2022-11-13 18:02:30 +00:00
Jonas Ådahl
562024f746 plugin/default: Don't load properties when getting locale proxy
This cuts away between 7 and 40 ms from the startup of tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
2022-11-01 21:04:21 +00:00
Sebastian Keller
46fc94b67f surface-actor-x11: Only unredirect fullscreen windows for full damage
When deciding if a window should be unredirected because it was causing
fullscreen damage in the past, it was not considered whether the window
is still fullscreen. This could result in a floating window being
unredirected if it was chosen for unredirection because of
_NET_WM_BYPASS_COMPOSITOR = 1 and was previously fullscreened for >= 100
frames, long enough to change does_full_damage, before getting
unfullscreened.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2434
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2651>
2022-10-21 12:58:07 +00:00
Robert Mader
4079afe0c7 surface-actor-wayland: Fix assumption in get_current_primary_view
Unlike the multi-view path, the optimized/single-view one doesn't check
if the surface-actor is really present on the view. That is the case
whenever it's hidden - e.g. when the window is minimized.

Fixes 3b7137cb35

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2662>
2022-10-15 21:45:10 +02:00
Sebastian Wick
909616b208 window-actor/wayland: Draw black background for fullscreen windows
Fullscreen Wayland toplevel surfaces don't need to respect the
configured size in which case it should be shown centered on the monitor
with a black background. The black background becomes part of the window
geometry.

The surface container is responsible for correctly culling the surfaces
and making sure the surface actors are removed from the actor tree to
avoid destroying them.

The window actor culling implementation assumes all surfaces to be direct
children of said actor. The introduction of the surface_container actor
broke that assumption. This implements the culling interface in
MetaWindowActorWayland which is aware of the actor surface_container and
fullscreen state.

v2: Fix forwarding culling to surface even if there is a background.
v2: Don't alter passed geometry.
v2: Update window geometry code documentation to reflect these changes.
v2: Only use constrained rect if we're acked fullscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00