1
0
Fork 0
Commit graph

1408 commits

Author SHA1 Message Date
Sebastian Keller
54ba64b9f2 window-actor/wayland: Only use scanout for opaque non-fullscreen windows
This could for example happen with the client window created by the
desktop-icons-ng extension which spans the entire desktop, but is not a
fullscreen window and uses transparency

On Wayland only opaque surfaces or transparent surfaces of fullscreen
windows can be used for direct scanout.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2263
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2409>
2022-05-17 10:34:20 +00:00
Sebastian Keller
dc43bb9f68 window-actor/x11: Don't use direct scanout if the window is not opaque
Some windows span the entire screen but still use transparency, such as
the desktop window of Nemo. When these windows were used for direct
scanout, the transparent areas would turn black and nothing else would
be rendered.

In addition to checking the surface for opaqueness, for X11 windows also
the window actor itself has to be checked, because its opacity might
have been changed via _NET_WM_WINDOW_OPACITY.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2263
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2409>
2022-05-17 10:34:20 +00:00
Sebastian Keller
9c8948fc04 window-actor: Add API to get the surface actor candidate for scanout
This replaces the API to get the topmost surface actor with an API to
get the surface actor that could be a candidate for direct scanout. The
advantage of this is that it allows X11 and Wayland specific
restrictions for these actors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2409>
2022-05-17 10:34:20 +00:00
Bilal Elmoussaoui
749b9be98a core: Drop the default close dialog implementation
If the MetaPlugin doesn't implement it, we don't show anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Bilal Elmoussaoui
0e092ad6b3 default-plugin: Drop default confirm display dialog
Mostly to drop the 1/3 use cases of zenity on mutter and usually
shells built on top of Mutter should implement that vfunc

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Bilal Elmoussaoui
03929ca01f build: Fix building without Wayland
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2400>
2022-05-03 16:47:02 +02:00
Jonas Ådahl
d19700604b compositor/dnd: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Jonas Ådahl
9d0f612de1 shaped-texture: Paint with the right layer snippet
When we get passed a "snippet" to the shaped texture, it's added as a
pipeline layer snippet to change how the source texture is sampled. When
we draw from a texture tower however we have allocated regular textures
which doesn't need any special layer snippet, so create separate
pipelines for those that doesn't use that snippet.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2278>
2022-04-07 07:28:44 +00:00
Jonas Ådahl
d4ffaf291f shaped-texture: Pass along the snippet to the texture tower
The snippet is used make sure the right source is sampled in the shader.
This wasn't done in the texture tower, meaning the textures from the
tower were not correct.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2278>
2022-04-07 07:28:44 +00:00
Robert Mader
7f93004809 compositor/native: Check that the surface can be scanned out untransformed
Before scanning out the surface of a native client we have
to check the following attributes that influence the
relationship between buffer and the defined result on screen:
 - buffer scale
 - buffer transform
 - viewport

In the future we can loose these checks again in cases where the
display hardware supports the required operations (scaling, cropping
and rotating).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2276>
2022-03-05 14:14:37 +00:00
Robert Mader
6330acfaa2 compositor: Some header cleanups
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2276>
2022-03-05 14:14:37 +00:00
Jonas Dreßler
672696f823 dnd: Notify about events during compositor grab from event filter
Since the introduction of ClutterGrabs, MetaDnd now no longer gets
notified about input events on the stage during grabs (for example while
the alt-tab popup is shown) and thus can't move the grab feedback actor
anymore.

To fix this, forward events to MetaDnD directly from
meta_display_handle_event() when a ClutterGrab is in effect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2308>
2022-03-02 15:12:23 +00:00
Carlos Garnacho
a870e6b38d backends/x11: Update MetaBackend on ClutterEvent processing
This should fix wonky handling of last used device and pointer
visibility on X11. At least does on --nested under presence of
touchscreen/tablet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Jonas Ådahl
35ac3a096d compositor: Destroy actors when unmanaging
When disposing, actors being destroyed might want to access the disposed
compositor; avoid that by destroying them earlier.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
dd14592314 laters: Expose MetaLaters publicly
Will allow not having to use the context-less meta_later_add().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Carlos Garnacho
b6de66e353 compositor: Remove meta_plugin_begin/end_modal
Amazingly, this is no longer used. This way to let Clutter grab input
is no longer necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
2022-01-29 02:11:37 +01:00
Carlos Garnacho
a840c039a0 core: Handle redirection changes in and out of ClutterGrab grabs
Wayland event processing and WM operations are themselves outside the
ClutterGrab loop so far. Until this is sorted out, these pieces of
event handling have got to learn to stay aside while there is a
ClutterGrab going on.

So, synchronize foci and other state when grabs come in or out, and
make it sure that Wayland event processing does not happen while
grabs happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Florian Müllner
5b720a157c compositor/plugin-manager: Split start() from new()
In order to support dynamic imports, gjs added an implicit mainloop
that can drive the main context independently from other mainloops
like the one from GApplication or MetaContext.

That means that sources can now get dispatched to the main context
from the moment the plugin is started, resulting in a crash as the
association between compositor and plugin manager doesn't exist until
meta_plugin_manager_new() returns.

Make sure this doesn't happen by only starting the plugin after
meta_plugin_manager_new() has returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2242>
2022-01-25 15:15:13 +01:00
Robert Mader
df3f81e709 compositor/native: Consider Wayland subsurfaces for scanout
If a Wayland subsurface is the topmost actor, consider in for
scanout as well. This will extend our scanout capabilities to apps
like Firefox

While on it, correct a unnessary type check to a NULL check.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2211>
2022-01-07 18:54:27 +00:00
Robert Mader
8abe876d15 window-actor: Add API to get the topmost surface actor
On Wayland a window actor may have more than one surface actor,
most importantly when subsurfaces are used.
Add a new function to request the one which is at the top -
it will be used in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2211>
2022-01-07 18:54:27 +00:00
Mark
888e69d3a4 plugins/default: Fix broken switch_workspace()
Swap which windows are switched with which in the workspace switching
animation of the default plugin since this was backwards (resulting in
failures), but animate only those which are on either the current
workspace or the one to switch to. Have the animation span the entire
screen as intended.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2038
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2076>
2022-01-06 16:49:25 +00:00
Jonas Ådahl
43161c6660 compositor/native: Track what Wayland surface is a scanout candidate
For the current candidate, set the candidate CRTC on that surface. This
will later be used to send DMA buffer feedback for direct scanout purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Robert Mader
58f82d0624 texture-tower: Fix code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2199>
2022-01-03 14:38:09 +01:00
Robert Mader
cd781758eb surface-actor-x11: Fix code style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2199>
2022-01-03 14:12:01 +01:00
Robert Mader
f99d3c01a4 shaped-texture: Fix code style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2199>
2022-01-03 14:11:54 +01:00
Sebastian Keller
450ab0fdb9 window-group: Disable culling when rendering to non-stage-view buffer
When rendering to a buffer that is not the stage view buffer, we can not
know where the buffer will be displayed on the screen. As a result we
also can not know what translation would need to be applied to culling.

This was causing glitches when the gnome-shell magnifier was applying
offscreen effects. ClutterOffscreenEffect causes MetaWindowGroup to be
rendered to an offscreen buffer at an offset, because it draws to a
slightly larger texture with an accordingly translated origin. This
translation then later is canceled out again when the offscreen buffer
is drawn. To meta_actor_painting_untransformed() however which only sees
the translation used when drawing to the buffer this looked like the
window group was being rendered at the offset. This then lead to
redraw_clip getting translated accordingly, resulting in wrong
coordinates used for culling.

Similarly this was leading to issues when taking area screenshots while
at 1x zoom.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1678
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4876
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2080>
2022-01-03 11:20:50 +00:00
Sebastian Keller
3941597485 window-actor/wayland: Fix child actor list leak on dispose
The list returned by clutter_actor_get_children() is caller owned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2193>
2022-01-02 05:06:47 +01:00
Robert Mader
6204769fdb surface-actor: Fix unobscurred_fraction calculation
This calculation wrongly applied a `x2 - x1` pattern.

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Georges Basile Stavracas Neto
87a66830dc cogl: Drop cogl-wayland-server.h
This header only defines one function that doesn't exist anymore,
and nothing else. It can be safely dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2145>
2021-12-07 18:34:00 -03:00
Fernando Monteiro
44aa6ab735 cogl: Remove cogl_texture_new_with_size
Replace the deprecated function with the suggested alternative.

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

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

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

Found while working on #2038.

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

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

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

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

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2024
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2102>
2021-11-24 15:55:20 +00:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Robert Mader
7d3e2c5f9c shaped-texture: Fix damage propagation for rotated transforms with viewport
When a viewport source rect or destination size is set, `stex->dst_width`
gives us the the cropped and/or scaled size. At this step, we need the
uncropped/unscaled size however.

Note: this is only ever relevant if buffer transform and viewport are
used together - otherwise the values are the same.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1836>
2021-04-21 20:29:14 +02:00
Jonas Dreßler
99abb086fb window-actor-x11: Invalidate paint volume when shadow changes
The shadow size is factored into the paint volume MetaWindowActorX11
returns in its get_paint_volume() vfunc override, so we should
invalidate the paint volume every time that shadow might change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1829>
2021-04-19 17:56:08 +00:00
Robert Mader
2ded9c4bf2 shaped-texture: Apply viewport and rotation in right order
When using buffer transforms and viewports together, we currently
apply the transformation (read: rotation) first, resulting in
wrong buffer coordinates for viewport source rects.

Flip the order in whitch we apply our matrix transformations.

This can be tested e.g. via:
`weston-simple-damage --use-viewport --transform=flipped-180`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1832>
2021-04-19 15:03:05 +02:00
Robert Mader
f7768874e5 window-actor/wayland: Cleaner subsurface reordering
Currently when reordering subsurfaces, we un- and reparent all child
actors of the window actor. This is unnecessarily wasteful and
triggers bugs in clutter. While the underlying issue should be fixed
eventually, simply reorder the actors with the tools clutter provides
us with, avoiding those bugs and likely being faster as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1831>
2021-04-19 11:55:49 +00:00
Robert Mader
5772c27e04 shaped-texture: Expose ensure_size_valid() API
When the texture size is invalidated using `invalidate_size()`, the new
size will only get calculated the next time `update_size()` is
called. This happens e.g. in `meta_shaped_texture_get_preferred_size()`
via `ensure_size_valid()`.

`update_size()` can chain up to `clutter_content_invalidate_size()`
as well as emitting a `size-changed` signal. If this happens during
layout, the result is a 'change the layout conditions during layout'
issue, causing heavy breakage in e.g. the Shell overview.

To fix this, expose `ensure_size_valid()` as API so callers can make
sure the texture has a valid size without creating redundant size
invalidations calls.

Note that if a buffer with a new size is attached we already trigger
`update_size()` explicitely, avoiding such situations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1799>
2021-03-29 15:47:25 +00:00
Robert Mader
50ba52b1b5 shaped-texture: Use G_APPROX_VALUE to compare viewport source rects
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1799>
2021-03-29 15:47:25 +00:00
Robert Mader
1bfd932f15 region-utils: Fix typo in crop_and_scale() fastpath
Fixes 09b1bbb1cf

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1786>
2021-03-29 15:17:48 +00:00
Robert Mader
52547cb9ea shaped-texture: Viewport update calculation fixes
If only a viewport destination size is set, the noop viewport has
to take the buffer scale into account.

If a viewport source but no viewport destination size is set, the
destination size is that of the viewport source, not of the whole
texture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1786>
2021-03-29 15:17:48 +00:00
Marco Trevisan (Treviño)
2744722b8c later: Handle gracefully calls with unset display
This can happen when the display has been already closed, in such case
we should not crash but warn about the error and return early.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1780>
2021-03-13 15:12:36 +00:00
Jonas Ådahl
ba38057067 plugins/default: Initialize background color in a predictable manner
The order of which function argument expressions are executed is
undefined, so don't rely on this for setting the background colors, as
it results in different colors on different architectures.

For example, it has been observed that the order of execution is
reversed comparing x86_64 and aarch64, making these two architectures
having different background color.

Fix this confusion, and also reproduceability in future reference tests,
by making the order of execution predictable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Dreßler
b770ea606a background-content: Optimize rounded clipping shader a bit
We're using the gtk4 shader for rounded rect clipping here, and gtk just
introduced a small optimization to make this shader a bit faster, so
let's do the same.

See 57e354c297

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1774>
2021-03-11 22:59:07 +01:00
Jonas Ådahl
9b90b5a1b0 window-actor/x11: Queue full actor redraw when redraw queued
With frame timings, we might end up in a situation where a frame drawn
is expected, but no damage was posted. Up until now, mutter handled
this, if the window wasn't completely hidden, by posting a 1x1 pixel
damage region. The problem with this is that we now are a bit more
aggressive optimizing away no-op redraws, meaning we still might end up
not drawing, making things get stuck.

Fix this by doing a full actor redraw, as that is the only reliable way
to both a new frame being drawn, as well as the actor in question itself
getting redrawn.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1516
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3369
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1471
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1754>
2021-03-09 17:42:58 +00:00
Jonas Ådahl
44a4e61665 compositor/x11: Notify the sync ring about frames on updates
The sync ring has an API about "frames", where it is notified about
the end of frames. However, its "insert wait" call is done before
updates, meaning that some "insert waits" will never see the "after
frame" if there was no frame drawn. This will cause mismatching in the
frame counting, causing freezes in the synchronization until something
else triggers an actual frame, effectively "unfreezing" the sync ring.

Fix this by not only notifying the sync ring about frames when there
were actual frames drawn, but also on plain updates which didn't result
in a drawn frame.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1516
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1754>
2021-03-09 17:42:58 +00:00
Ivan Molodetskikh
4810164885 cogl: Make presentation time always MONOTONIC
This concerns only the cases when the presentation timestamp is received
directly from the device (from KMS or from GLX). In the majority of
cases this timestamp is already MONOTONIC. When it isn't, after this
commit, the current value of the MONOTONIC clock is sampled instead.

The alternative is to store the clock id alongside the timestamp, with
possible values of MONOTONIC, REALTIME (from KMS) and GETTIMEOFDAY (from
GLX; this might be the same as REALTIME, I'm not sure), and then
"convert" the timestamp to MONOTONIC when needed. An example of such a
conversion was done in compositor.c (removed in this commit). It would
also be needed for the presentation-time Wayland protocol. However, it
seems that the vast majority of up-to-date systems are using MONOTONIC
anyway, making this effort not justified.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Jonas Ådahl
3bbfaa03b3 background-content: Fix pipeline cache size
The cache had the size 9, which was "big enough" in the past, but when
more ways pipelines could be constructed, the size was not enough. The
need to increase the cache size was hard to spot though, since adding
pipeline flag didn't give any hints about the cache being directly tied
to these flag values.

So, when enough flag bits were set when attempting to retrieve and put a
pipeline in the cache, it'd instead overwrite some arbitrary stack
memory, which would sooner or later result in a memory corruption
induced crash. Valgrind could not detect this particular memory
corruption, as it messed up stack memory, not e.g. freed heap memory, so
it instead got confused and thought plain stack values were unreadable.

Fix these two issues by making the cache size the combination of all
pipeline flags + 1, so that we can safely put any flag combination in
the cache.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1747>
2021-02-24 15:59:58 +00:00
Robert Mader
6eeeffdc68 src: Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:52:27 +01:00
Jonas Dreßler
9512d58c28 display: Don't add MetaDisplay argument to grab-op-* signals twice
GObject signals pass the emitting GObject as the first argument to
signal handler callbacks. When refactoring the grab-op-begin/end signals
to remove MetaScreen with commit 1d5e37050d,
the "screen" argument was replaced with a "display" argument instead of
being removed completely. This made us call the signal handlers with two
identical MetaDisplay arguments, which is very confusing and actually
wasn't handled in a grab-op-begin handler in gnome-shell.

So fix this by not adding the MetaDisplay as an argument to those
signals, GObject will take care of that for us.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1734>
2021-02-19 14:52:22 +01:00
Jonas Dreßler
5527b6e483 background-content: Add support for rounded clipping when drawing
We're going to round the workspace backgrounds in the new overview for
gnome-shell 40.

So far corner-rounding was only possible for StWidgets because the
rounded clipping was done using cairo drawing. We now need rounded
clipping for ClutterActors too because backgrounds are drawn using
ClutterActors (or more specifically a ClutterContent). To implement
that, first a ClutterOffscreenEffect subclass together with a fragment
shader from GSK (see gskSetOutputColor() [1] in the GSK GL renderer
code) was investigated, and while that was generic and worked quite
well, it was extremely slow for the case of drawing wallpapers because
of all the FBOs that had to be allocated.

This is the new, more performant approach: Use the same fragment shader,
but perform the rounded clipping right in MetaBackgroundContent while
we're painting the wallpaper. This has almost no performance impact,
with the downside of not being a generic solution.

To allow for rounded clipping not only at the edges of the wallpaper,
but using any given bounding rectangle, the API exposes not only the
radius, but also a bounding rect.

[1] https://gitlab.gnome.org/GNOME/gtk/-/blob/master/gsk/resources/glsl/preamble.fs.glsl

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1717>
2021-02-18 20:26:42 +00:00
Carlos Garnacho
437f5d1c66 compositor: Sync pointer after begin/end modal on X11
Ensure we issue a motion event for the current pointer position,
as there might be situations where compositor modals get X grabs
from other clients stacked on top, or missed events in between
otherwise.

Ensure the Clutter state is still up-to-date afterwards here. This
replaces some sync_pointer() calls done in GNOME Shell code, always
done after modality changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1659>
2021-02-14 13:23:29 +00:00
Carlos Garnacho
00c7f45a0f compositor: Refactor backend-specific code into MetaCompositor vfuncs
Do these Wayland operations (that apply on both native and nested backends)
in the MetaCompositorServer subclass. We want to add more backend specific
behavior here in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1659>
2021-02-14 13:23:29 +00:00
Olivier Fourdan
3322e4fa54 surface-actor-wayland: Handle Xwayland vanishing gracefully
When a game is playing fullscreen, mutter may use a direct scanout of
the surface.

However, if that surface is from Xwayland and Xwayland had vanished (now
that mutter can survive that), the actual surface might be NULL, so
check for that case to avoid a crash.

Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/1638
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1718>
2021-02-09 19:06:22 +00:00
Ivan Molodetskikh
9b44aa77b6 clutter: Remove clutter_stage_set_sync_delay
The sync_delay field is never accessed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Robert Mader
7da34f154b compositor/dnd-actor: Take geometry scale into account on DnD-cancel
Technically this is still wrong if the source actor or dnd actor are
transformed in other ways. However geometry scale is the by far most
common case and we currently lack convenience API in Clutter to
easily compute the right values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Robert Mader
dfa659b5b5 feedback-actor: Add API to set and get geometry scale
Analogous to MetaWindowActor. Also take it into account for positioning
when an anchor is set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Olivier Fourdan
df5a5d279d window-actor: Add a new can_freeze_commits() API
Mutter freezes Xwayland commits when resizing windows, and thaw them in
the window actors' after_paint() for X11.

Yet, after_paint() could be never called, as when a new window is mapped
while the overview is active in gnome-shell.

As a result, the content of the X11 window will remain invisible to the
overview.

Add a new window actor API to tell whether commits can be frozen. For
Wayland window actors, this always return FALSE, whereas for X11 window
actors, it checks whether the Clutter actor is mapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1678>
2021-01-30 10:13:03 +00:00
Daniel van Vugt
f512d4fefa shaped-texture: Update the full bounding box of each clip rectangle
When using fractional scaling this matters, so that you don't miss a
line of pixels at the edge of the clip rectangle by rounding down. This
was observed as a line of corrupt pixels in Firefox (Wayland) tooltips.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1554>
2021-01-27 17:05:38 +08:00
Daniel van Vugt
93e938e22f background: Make the final monitor texture RGB instead of RGBA
The monitor texture is the final background image. It doesn't need to
have any alpha channel. Cross-fades (which is the process of rendering
*into* the monitor texture) still work just fine.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1665>
2021-01-11 15:08:27 +08:00
Carlos Garnacho
a64dba4d7a compositor: Trigger repick after window effects here
Just because of implementation details, this is only relevant to Wayland,
and is done via ::effects-completed handlers there. Ideally, Clutter should
notice by itself about effects starting, finishing, and affecting picking.
Doing this in generic code seems slightly cleaner in the interim.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
745ccc5b01 compositor: Fix warning with -Wmaybe-uninitialized
Assert that the region is created, thus we passed a valid enum value
to the get_scaled_region() function. Fixes:

  ../../../../Source/gnome/mutter/src/compositor/meta-surface-actor.c: In function ‘get_scaled_region’:
  ../../../../Source/gnome/mutter/src/compositor/meta-surface-actor.c:113:10: warning: ‘scaled_region’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    113 |   return scaled_region;
        |          ^~~~~~~~~~~~~

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1624>
2020-12-08 13:35:50 +00:00
Robert Mader
3b7137cb35 surface-actor-wayland: Optimize get_current_primary_view for single view
In case we only have a single view (or there's only one view left to
check and the actor is visible on previous views) we can take a short-
cut, saving a region allocation and some calculations.

While on it, declare float numbers in '.f' style to make them more
recognizable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1596>
2020-11-23 14:49:42 +01:00
Robert Mader
ff94ed0ebf surface-actor-wayland: Add API to pick a primary stage view
Add a simple heuristic how to choose the primary stage view to drive events
like frame callbacks for a given surface actor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1468>
2020-11-19 19:43:40 +01:00
Robert Mader
9db09e327c surface-actor: Add API to check obscuredness per stage view
Our main use case of `is_obscured()` is frame callback emission.
Since we now support stage views running at differt speeds, we
need to know whether an actor is visible on a specific stage view
in order to schedule frame callbacks accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1468>
2020-11-19 19:42:08 +01:00
Robert Mader
09b1bbb1cf region-utils: Always use FLT_EPSILON when comparing floating point values
As you should always do. Using the `float` variant even if `scale` is
a `double` as values passed in are potentially computed at `float`
precission.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1565>
2020-11-16 19:27:20 +01:00
Robert Mader
91c9416259 region-utils: Reduce temporary allocations
This applies the optimizations from 0c55e87d8f to serveral
similar places in region-utils.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1565>
2020-11-16 19:27:20 +01:00
Daniel van Vugt
c7a0ab3eb8 background-content: ceilf the actor size instead of roundf
We want the bounding box so `ceilf` seems more appropriate. It was
only written using `roundf` before as a workaround for inaccuracies
coming out of `clutter_actor_get_transformed_size` that would have
tricked `ceilf` into landing on the wrong integer. But that's since
been fixed by 67cc60cbda so we can use `ceilf` now.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1532
2020-10-27 19:33:30 +00:00
Georges Basile Stavracas Neto
8d47f79b2c clutter/actor: Remove '_paint' suffix from clutter_actor_should_pick_paint
We're not using paint to pick anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Georges Basile Stavracas Neto
05b6b6a88d clutter/actor: Use pick context in clutter_actor_should_pick_paint()
Pass the ClutterPickContext to clutter_actor_should_pick_paint() and
check the pick mode from it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-26 09:20:38 -03:00
Daniel van Vugt
a24b2f4b0f background-content: Assume background clones are always transformed
Because clones may not have identical geometry to their source actors.
So we can't use the geometry of the source actor to decide to take the
more optimized (more clipped) path.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1480
2020-10-23 22:54:25 +00:00
Jonas Ådahl
5a58ccbece texture-tower: Use memory management helpers more
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
1cc82cf759 background: Use memory management helpers more
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
eb14da3874 cogl: Turn CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects
A first step towards abandoning the CoglObject type system: convert
CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects.
CoglFramebuffer is turned into an abstract GObject, while the two others
are currently final. The "winsys" and "platform" are still sprinkled
'void *' in the the non-abstract type instances however.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Robert Mader
1c1c8b25ed window-actor: Freeze subsurfaces as well
In order to prevent glitches in animations, make sure we freeze all
surfaces of a window actor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1339
2020-10-14 15:53:53 +00:00