1
0
Fork 0
Commit graph

1603 commits

Author SHA1 Message Date
Sebastian Wick
c0832b99d8 multi-texture-format: Always use the tex coords of the first plane
The texture coordinates of all planes should be the same in theory so
using the coordinates of the first plane works.

The reason for this change is that Cogl somehow doesn't manage to get us
the correct coordinates for the 3rd plane in some circumstances. This is
really a workaround but not wrong in any way.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3176
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3469>
2023-12-20 19:39:06 +00:00
Sebastian Wick
4b8798a800 shaped-texture: Don't use mipmaps for small textures
Mipmapping extremely small textures is pointless. We chose a lower limit
of 8 pixels in each direction.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3468>
2023-12-19 22:25:21 +01:00
Sebastian Wick
54c5ea9c13 texture-mipmap: Handle textures with width or height of 1
Calculating the mipmap width as half of the texture width leads to a
mipmap width of zero for textures with width of 1 which leads to an
early exit instead of a mipmap texture.

Fixes: 16fa2100d ("shaped-texture: Stop using MetaTextureTower and use GL mipmapping instead")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3468>
2023-12-19 22:24:57 +01:00
Sebastian Wick
5dc92aa134 Revert "background: Make the final monitor texture RGB instead of RGBA"
This reverts commit 93e938e22f.

The alpha channel is required for the background-color to show where the
background-image is not visible.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1911
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3459>
2023-12-19 12:30:19 +00:00
Carlos Garnacho
4179679239 x11: Adopt code to focus stage window on Clutter key focus
We currently offer the mechanism for GNOME Shell to implement, and
while this is not exercised often (our entries are typically surrounded
by a ClutterGrab ensuring key events, so this is reserved to grab-less
entries, probably there are some in extensions), this is arguably
something Mutter should cover by itself without GNOME Shell guidance.

This is only necessary on the X11 backend, although it is conceptually
more tied to the MetaX11Display connection, so perform the focus
tracking there only if not running as a Wayland compositor (i.e. --x11).

This avoids the only case where the low-level
meta_x11_display_set_input_focus_xwindow() function is used, or rather
makes it completely a MetaX11Display implementation detail, leaving
only the MetaDisplay API as the high-level entry points to handle
window key focus.

The public API that allowed GNOME Shell to implement these mechanisms
is also gone in this commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3269>
2023-12-18 17:55:27 +00:00
Sebastian Wick
7458907360 shaped-texture: Reset pipelines when texture format changes
Changing the MultiTexture may require a different set of pipelines when
the texture format is different. We keep track of the attached
MultiTextureFormat just like we do for the width and height.

This fixes misrendering when a client attaches buffers with different
MultiTextureFormats to the same surface.

Fixes: 3dd9f15eb ("shaped-texture: Start using MetaMultiTexture")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3456>
2023-12-15 11:48:32 +01:00
Ivan Molodetskikh
521668202d meta/later: Remove extra word from trace span description
This used to be the span name. Now that it's the description, repeating
the word Later is not needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3417>
2023-12-06 16:12:58 +00:00
Sebastian Keller
dfe4d218f1 clutter/actor: Make get_transformed_paint_volume() transfer full
Transfer none was achieved using a stack GArray in the stage which
would get resized to 0 at the end of every frame to "free" it.
In the case of direct scanout however, painting the next frame only
happens after leaving fullscreen again. Until then the array just kept
growing and because GArrays don't reallocate when shrunk, this memory
remained allocated even after leaving fullscreen.

There is no cache benefit from storing paint volumes this way, because
nothing accesses them after their immediate use in the calling code.
Also the reduced overhead from avoiding malloc calls seems negligible as
according to heaptrack this only makes up about 2-3% of the temporary
allocations.

Changing this to transfer full and removing the stack array simplifies
the code and fixes the "leak".

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3191
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3442>
2023-12-06 14:07:39 +00:00
Jonas Ådahl
08d2155b6c shaped-texture: Rename GObjectClass pointer variable
To be consistent with the rest of mutter, call it `object_class`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3443>
2023-12-06 13:45:03 +00:00
Jonas Ådahl
68412cedac shaped-texture: Get type from klass
We don't need to get the type from the type casted class pointer, just
get it from the one from the function argument.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3443>
2023-12-06 13:45:03 +00:00
Carlos Garnacho
6ad0114d1f compositor: Undo MetaWindowDrag on MetaWindow::unmanaged signal
The current usage of MetaWindow::unmanaging may result in confused
focus window lookups while undoing the MetaWindowDrag grab (i.e.
still pointing to the window that is now being unmanaged).

The meta_window_unmanage() function itself takes care of changing
focus outside of the window being unmanaged, so postpone the
MetaWindowDrag undoing to a point after that is done.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3073
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3376>
2023-12-05 14:16:27 +00:00
Sebastian Wick
dbdc821ca7 multi-texture-format: Expose immutable fields directly
Split the struct into mutable and immutable parts. Access the mutable
parts via getters and the immutable parts via a single struct. This
avoids copying around the immutable parts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3280>
2023-11-22 12:11:38 +00:00
Ivan Molodetskikh
2d1fc65b3a Adjust COGL_TRACE names to improve automatic processing
In profilers with a timeline or flame graph views it is a very common
scenario that a span name must be displayed in an area too short to fit
it. In this case, profilers may implement automatic shortening to show
the most important part of the span name in the available area. This
makes it easier to tell what's going on without having to zoom all the
way in.

The current trace span names in Mutter don't really follow any system
and cannot really be shortened automatically.

The Tracy profiler shortens with C++ in mind. Consider an example C++
name:

SomeNamespace::SomeClass::some_method(args)

The method name is the most important part, and the arguments with the
class name will be cut if necessary in the order of importance.

This logic makes sence for other languages too, like Rust. I can see it
being implemented in other profilers like Sysprof, since it's generally
useful.

Hence, this commit adjusts our trace names to look like C++ and arrange
the parts of the name in the respective order of importance.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3402>
2023-11-22 11:46:07 +00:00
Sebastian Wick
63c6fe11fb window-actor/wayland: Keep track of when the geometry needs to be synced
The window actor can be mapped every frame, e.g. when it is dragged in
the overview. This commit keeps track when the geometry changed and we
didn't managed to sync the geometry yet and need to sync it at a later
time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
9e036bfd23 window-actor/wayland: Map the window before trying to sync geometry
We need to chain up to the parent class to make sure the
WindowActorWayland is actually mapped which is required for the
sync_geometry_internal function to succeed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
2dbfc1c23d window-actor/wayland: Move map method to a more appropriate place
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
ee7f13fd84 window-actor/wayland: Return success status from syncing geometry
We do this by  moving it to a helper function. We will use this to keep
track of when syncing the geometry is actually needed in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
90d27e7b2e window-actor: Adjust sync_geometry
At the end of the sync_actor_geometry function the window buffer_rect
and the WindowActor position and size are the same and consistent.

Call the virtual method at the end and let the implementations look at
either the buffer_rect or the actor position/size itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
976bcef3d5 window-actor/wayland: Sync geometry only when window is mapped
In some cases the window is not mapped when the geometry changes.
Without the mapped window the surfaces are not mapped either and don't
have a sensible allocation.

This patch makes sure we abort syncing the geometry if the window is not
mapped and also make sure we sync geometry when the actor eventually
does get mapped.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3152
Fixes: 8f4ab53bd ("window-actor/wayland: Ensure to use allocation for black background check")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3401>
2023-11-15 17:03:45 +01:00
Bilal Elmoussaoui
f5dac3a5d9 build: One config file to rule them all
Group all the three config files from clutter/cogl/meta into one
and also remove unnused configurations and replace duplicated ones

This also fixes Cogl usage of HAS_X11/HAS_XLIB to match the expected
build options

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3368>
2023-11-15 12:00:19 +00:00
Michel Dänzer
ca5bf847ee wayland/surface: Rename output/protocol_state to applied/committed_state
This is more consistent with Wayland protocol spec language.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3395>
2023-11-15 10:55:21 +00:00
Bilal Elmoussaoui
8a3181f741 clutter: Make json-glib a debug only dependency
Currently, json-glib is used for two things:
- For loading scripts, nothing seems to use that in real life other
than some tests
- For debugging paint nodes

For now, the PR drops the first use case and only require json-glib
if it is a debug build

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3354>
2023-11-14 16:13:18 +01:00
Sebastian Keller
145cac3a37 surface-actor: Fix leak when setting non-empty clip region
When 655b4a9c75 ported this to MtkRegion, it removed the unref of the
copied region after setting it in the shaped texture.

Fixes: 655b4a9c7 ("Port to MtkRegion")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3140
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3365>
2023-11-06 20:30:37 +01:00
Corentin Noël
a772c709aa wayland/surface: Make MetaWaylandSurface public
Only expose the method to get the associated MetaWindow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3340>
2023-11-04 01:12:11 +00:00
Sebastian Wick
5dbb6c31e9 cogl: Rename COGL_PIXEL_FORMAT_G_16 with COGL_PIXEL_FORMAT_R_16
Mechanical rename. The format already describes the first two (rg/xy)
components.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3276>
2023-11-04 00:11:52 +00:00
Sebastian Wick
764d5dd67b cogl: Rename COGL_PIXEL_FORMAT_G_8 with COGL_PIXEL_FORMAT_R_8
Mechanical rename. The format already describes the first (r/x)
component.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3276>
2023-11-04 00:11:52 +00:00
Bilal Elmoussaoui
c683d971a1 compositor: Move region_to_cairo_path helper where it is used
The helper is X11 specific and only used once in that file. Moving
it there would help us in the future to build without cairo if x11 is disabled

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
655b4a9c75 Port to MtkRegion
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
058afb67f4 actor/frames: Check if frame bounds existing before copying them
Avoids a failure once we port to MtkRegion as we ensure that the region is not NULL

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
9b9e12edb2 cogl: Port Node/Pipeline/PipelineLayer away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
863163cc6e cogl: Port Texture* away from CoglObject
- Make Texture a parent GObject class and move the vtable funcs as vfuncs
instead of an interface as we would like to have dispose free the TextureLoader.
- Make the various texture sub-types inherit from it.
- Make all the sub-types constructors return a CoglTexture instead of their respective
specific type. As most of the times, the used functions accept a CoglTexture,
like all the GTK widgets constructors returning GtkWidget.
- Fix up the basics of gi-docgen for all these types.
- Remove CoglPrimitiveTexture as it is useless: It is just a texture underhood.
- Remove CoglMetaTexture: for the exact same reason as above.
- Switch various memory management functions to use g_ variant instead of the cogl_ one

Note we would still want to get rid of the _cogl_texture_init which is something
for the next commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
312d5c367e cogl: Port Snippet away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
98bd2aa2c2 clutter: Move cairo pixel format to cogl
As Cogl already defines a pixel format enum, it makes sense to move such
endian dependant pixel format there

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3086>
2023-10-25 20:03:08 +00:00
Robert Mader
8f4ab53bd6 window-actor/wayland: Ensure to use allocation for black background check
The surface actors may not have a valid allocation when running the
test. The preferred height, which `clutter_actor_get_size()` returns
in that case, can be wrong in certain cases, making us not add the black
background when it's actually needed.

Query the allocation instead, even at the expense of additional
relayouts.

While on it, sneak it some small cleanups.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3024
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3310>
2023-10-05 04:48:54 +02:00
Robert Mader
eafe331cf7 compositor-view/native: Skip direct scanout when using software cursors
If a cursor is visible over the scanned out actor and we can't use
hardware planes we need to go through the paint machinery.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3302>
2023-10-03 15:41:05 +00:00
Robert Mader
a9c24ff653 multi-texture-format: Add P010 YCbCr format
It's the 10 bit equivalent to NV12 and uses the same layout as P016, i.e.
16 bit components with the lowest 6 bits set to 0 (padding), allowing us
to use 16 bit "subformats".

Thus adding support is quite trivial as we can reuse the NV12 shader.
The format is widely supported in decoding and display hardware (on Intel
since Kaby Lake), as well as modern codecs (AV1, VP9, HEVC) and has
visible quality advantages over NV12.

Note that the additional colors are lost if composited to a 8 bit RGB
framebuffer. Switching between direct scanout and compositing can thus
cause quality differences. This is no new phenomena, however, as the
same is the case already for e.g. GL clients using 10 bit formats -
including video players.

Also note that P012 and P016 could trivially added as well - it's not
done here as they are uncommen and thus hard to test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
2023-09-13 14:11:27 +02:00
Robert Mader
66799c1aa0 multi-texture-format: Generalize shader names
These shaders can be used for similar formats with other component
sizes since the values are represented as floats. So whether the source
value was stored in 8bit, 10bit or 16bit doesn't matter - the driver
will covert it for us.

Thus use a Weston-inspired, more general naming scheme.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
2023-09-13 14:11:27 +02:00
Robert Mader
6be2add1b0 multi-texture-format: Initialize format info list with enums
To make the relations more obvious.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
2023-09-13 14:11:27 +02:00
Carlos Garnacho
80e15775a5 compositor: Fix surface accounting at MetaWindowActor
When the actor gets a new "main" surface assigned, it adds the
new surface to the stack of surface actors, but forgets to remove
the old one.

This stale pointer in the array may cause invalid reads and crashes
after the assigned surface is disposed, e.g. when destroying the
MetaWindowActor tries to disconnect signals from all accounted
surface actors.

Fixes: 9a2c8b2592 ("window: Add suspend state")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3252>
2023-09-06 18:13:00 +02:00
Florian Müllner
bc74d166dd window: Really fix portrait orientation check for tiling
Commit 3bfcb6d1 fixed the check for tiling via keybindings, but
ignored a subtle edge case when tiling with the pointer: The
monitor used for tiling is the monitor with the pointer, which
is not necessarily the one that contains the largest part of the
window.

That is, the correct monitor to check against depends on the
context where the function is called. We can either figure
it out automatically via the current window drag, or make it
a parameter.

The latter is clearer, because the callers already decide which
monitor to use for tiling anyway.

Fixes: 3bfcb6d1b9 ("window: Fix portrait orientation check for tiling")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3248>
2023-09-06 12:36:57 +00:00
Daniel van Vugt
7c8f1b4cc0 compositor/multi-texture-format: Cache snippets
These snippets are retrieved anew every time a window is resized. But
callers never modify them, they're effectively read-only so cache them
at the place of creation.

This is required to convince the pipeline hash that each reuse of the
same snippet really is the same snippet and so the pipeline is unchanged.
`CoglPipelineSnippetList` only does shallow comparisons and there's no
need right now to reimplement it as a deep comparison.

This eliminates the log message:

> Over 50 separate %s have been generated which is very unusual,
> so something is probably wrong!

which isn't actually a leak but more a warning about wasting time.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6958
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3224>
2023-09-06 10:26:48 +00:00
Bilal Elmoussaoui
1abef24154 mtk: Move Rectangle.from_graphene_rect from Meta
And drop the clutter helper

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
a93471eb90 mtk: Move Rectangle.to_graphene_rect from Meta
Also drops the clutter equivalent

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
3d693e8309 mutter: Completely replace MetaRectangle with MtkRectangle
There are still various helpers that might be worth to move to mtk as
well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
eafe07de31 mtk: Move Rectangle.overlap_* from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
af7c7befd8 mtk: Move Rectangle constructors from Meta
Also rename the rect constructor from mtk_rect to mtk_rectangle_new so
it is detected as a proper constructor instead of a random function by
g-ir-scanner

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
565acaed9c mtk: Move Rectangle.intersect from Meta
Also replaces it usage everywhere & remove the Clutter helper. Note the
tests were not moved yet to mtk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
9b2cba4e86 mtk: Move Rectangle.equal from Meta
Moves equal the equal function and removes the clutter equivalent. The
tests were not moved until all the remaining helper functions are moved.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
918ae0f4d4 mutter: Replace cairo_rectangle_int_t with MtkRectangle
Note: the various helpers in boxes.c were not ported yet, see the next
commit. This was intentionally done to simplify the porting process

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Sandro Bonazzola
ff4d87727b Update license access method
Dropped obsolete Free Software Foundation address pointing
to the FSF website instead as suggested by
https://www.gnu.org/licenses/gpl-howto.html
keeping intact the important part of the historical notice
as requested by the license.

Resolving rpmlint reported issue E: incorrect-fsf-address.

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3155>
2023-08-30 08:48:23 +02:00
Bilal Elmoussaoui
b004d1c577 cleanup: Drop empty vfuncs overrides
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3209>
2023-08-29 23:38:32 +00:00
Jonas Ådahl
87b7b073d3 window-actor: Don't update suspend state if no window
If the window is gone, don't try to update it. This might happen on
unmap animations with active clones.

Fixes: 9a2c8b2592 ("window: Add suspend state")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2984
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
9a2c8b2592 window: Add suspend state
The 'suspend state' is meant to track whether a window is likely to be
visible any time soon. The hueristics for this are as follows:

 * If a window is hidden, it will enter the 'hidden' state.
 * If a window is visible, and unobscured, it will enter the 'active'
   state.
 * If a window is visible, but obscured by another window, it will enter
   the 'hidden' state.
 * If there is a mapped clone of a window, it will enter the 'active'
   state.
 * If the window has been in the 'hidden' state for 3 seconds, it will
   enter the 'suspended' state.

This will eventually be communicated to Wayland clients so that they can
change their behaviour to e.g. save power.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:58 +00:00
Jonas Ådahl
2d7a062913 window-actor: Be more consistent declaring the property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:57 +00:00
Sebastian Keller
193a21c601 surface-actor-wayland: Fix leak in apply_transform()
Using g_object_get() to get the allocation creates a copy that needs to
be freed by the caller.

Fixes: e94b52777 ("surface-actor/wayland: Implement stable size and position rounding")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-16 21:24:28 +02:00
Carlos Garnacho
90a00dae99 compositor: Handle grab state through ClutterStage::is-grabbed handler
This is something the compositor could now track by itself, instead of
being pushed through events. It also makes more sense to do this directly
when the grabbing conditions change, as opposed to the next event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Bilal Elmoussaoui
cd27cb5c85 cleanup: Fix various typos
Using the typos cli app

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3169>
2023-08-12 20:13:37 +00:00
Michel Dänzer
3b847f28ad Remove unused meta_region_scale_double
Unused since 8b3c1f4b87 ("cullable: Generalize actor coordinates space
translation for regions").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
bdad097af1 Remove unused *_menu_for_rect functions
Unused since 84785951fd ("x11: Remove MetaX11WindowControl").

v2:
* Leave struct _MetaPluginClass::show_window_menu_for_rect, still used
  by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
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