1
0
Fork 0
Commit graph

360 commits

Author SHA1 Message Date
Niels De Graef
689c7f4107 clutter: Remove unused ClutterWaylandSurface
This allows for some further cleanups, since it is the sole consumer of
some functions in Cogl.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/624
2019-06-18 09:54:00 +02:00
Jonas Ådahl
5eac1d696d wayland/surface: Clear texture when attaching NULL
When 252e64a0ea moved the texture
ownership to MetaWaylandSurface, it failed to handle the case when a
NULL-buffer is attached, leaving the texture reference in place. This
caused issues when the surface should have been hidden (e.g. attaching a
NULL buffer to a cursor surface for hiding the cursor sprite).

Related: https://gitlab.gnome.org/GNOME/mutter/issues/630
2019-06-07 16:06:47 +00:00
Niels De Graef
1c6ea5d1db Use a consistent style for enum braces
https://gitlab.gnome.org/GNOME/mutter/merge_requests/361
2019-02-28 09:31:01 +01:00
Jonas Ådahl
252e64a0ea wayland: Move surface texture ownership to MetaWaylandSurface
Prior to this commit, MetaWaylandSurface held a reference to
MetaWaylandBuffer, who owned the texture drawn by the surface. When
switching buffer, the texture change with it.

This is problematic when dealing with SHM buffer damage management, as
when having one texture per buffer, damaged regions uploaded to one,
will not follow along to the next one attached. It also wasted GPU
memory as there would be one texture per buffer, instead of one one
texture per surface.

Instead, move the texture ownership to MetaWaylandSurface, and have the
SHM buffer damage management update the surface texture. This ensures
damage is processed properly, and that we won't end up with stale
texture content when doing partial texture uploads. If the same SHM
buffer is attached to multiple surfaces, each surface will get their own
copy, and damage is tracked and uploaded separately.

Non-SHM types of buffers still has their own texture reference, as the
texture is just a representation of the GPU memory associated with the
buffer. When such a buffer is attached to a surface, instead the surface
just gets a reference to that texture, instead of a separately allocated
one.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/199
2019-02-25 15:35:38 +00:00
Jonas Ådahl
d2f1edd6c6 wayland/surface: Process damage also for non-actor surfaces
The texture still needs to be updated with damaged content.

https://gitlab.gnome.org/GNOME/mutter/issues/199
2019-02-25 15:35:38 +00:00
Robert Mader
ba7af4f7d3 wayland/surface: Add support for wp_viewporter
This adds the required bits to wayland surfaces and ties them up
to the compositor parts.

It is based on and very similar in nature to buffer transforms.

From the specification:
> The global interface exposing surface cropping and scaling
> capabilities is used to instantiate an interface extension for a
> wl_surface object. This extended interface will then allow cropping
> and scaling the surface contents, effectively disconnecting the
> direct relationship between the buffer and the surface size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/323
2019-02-06 12:24:03 +00:00
Jonas Ådahl
12a42a9295 wayland: Move DND surface role into its own file
This avoids a -Wredundand-decls warning about the get_type() function.
2019-01-22 18:32:28 +01:00
Jonas Ådahl
19e3c21667 wayland/surface: Don't make destoryed actor reactive
When destructing a xdg_toplevel, we'll disassociate the actor from the
MetaWaylandSurface, to allow it to animate out. After having done this,
avoid trying to set it as unreactive when unsetting the window.

This fixes the runtime warning:

clutter_actor_set_reactive: assertion 'CLUTTER_IS_ACTOR (actor)' failed
2018-12-04 14:20:45 +00:00
Jonas Ådahl
da5a2d3cb8 wayland/surface: Intersect buffer damage with buffer rect
Before processing the buffer damage region, intersect it with the buffer
rectangle to avoid trying to damage content outside the surface.

This fixes the runtime warning "GL error (1281): Invalid value"
happening when a client posts too large buffer damage larger.
2018-12-04 14:20:45 +00:00
Robert Mader
e4de9ed580 wayland/surface: Add support for buffer transforms
This adds the required bits to wayland surfaces and ties them up
to the compositor parts.

The central part here is to recalculate the surface size accordingly
and to translate surface damage into buffer damage.

The choosen approach additionally lays groundwork for wp_viewporter
support, which is closely related in its nature.

A further explanation of buffer transforms from the specification:
> The purpose of this request is to allow clients to render content
> according to the output transform, thus permitting the compositor
> to use certain optimizations even if the display is rotated.
> Using hardware overlays and scanning out a client buffer for
> fullscreen surfaces are examples of such optimizations.
2018-12-03 19:13:51 +01:00
Carlos Garnacho
f8cd1e55a4 wayland: Make DnD role inherit from MetaWaylandActorSurface
It is meant to hold surfaces that require a ClutterActor, just like wl/xdg
shell surfaces and subsurfaces. Make it inherit from MetaWaylandActorSurface
so it gets that for free.

The type declaration is also made completely private, in order to avoid
cyclic dependency between meta-wayland-surface.h and
meta-wayland-actor-surface.h. We just require the GType fro assign_role()
anyway.
2018-12-01 09:42:48 +00:00
Jonas Ådahl
00619f3a1c wayland: Add MetaWaylandGtkShell object
To be used to store state.

https://gitlab.gnome.org/GNOME/mutter/issues/276
2018-11-27 15:34:13 +01:00
Jonas Ådahl
2f4a68c8c3 Clean up include macros mess
The order and way include macros were structured was chaotic, with no
real common thread between files. Try to tidy up the mess with some
common scheme, to make things look less messy.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
0ace58d05f wayland/surface: Add API to cache frame callbacks
Sometimes it may be useful for roles to put callbacks in the generic
surface frame callback queue. The surface frame callback queue will
either eventually be processed on the next surface role assignment that
places the frame callbacks in a role specific queue, processed at some
other point in time by a role, or cleaned up on surface destruction.

https://gitlab.gnome.org/GNOME/mutter/issues/240
2018-08-27 11:43:53 +00:00
Robert Mader
db22c13c4f wayland: Use surface size helper functions
Use meta_wayland_surface_get_width / meta_wayland_surface_get_width
to determine the size of a surface.
2018-08-20 14:37:10 +00:00
Robert Mader
ad864083f9 wayland/surface: Add get_width() and get_height() helper functions
With viewporter / transformations it get's more complicated to
figure out the dimensions of a surface. Bundle it in this helper-
functions.
2018-08-20 14:37:09 +00:00
Armin Krezović
1d5e37050d Stop using MetaScreen where it is unnecessary
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Miguel A. Vico
22723ca371 wayland: Always realize buffers at surface commit time
Clients using EGLStream-backed buffers will expect the stream to be
functional after wl_surface::attach(). That means the compositor-side
stream must be created and a consumer attached to it.

To resolve the above, this change realizes buffers even when the attach
operation is deferred (e.g. synchronized subsurfaces).

https://bugzilla.gnome.org/show_bug.cgi?id=782575
2018-06-15 13:45:25 -07:00
Olivier Fourdan
52fdd24467 wayland: avoid a crash in is_effectively_synchronized()
To check if a subsurface is effectively synchronized, we walk the
subsurface hierarchy to look for a non-subsurface parent or a subsurface
being synchronized.

However, when client is closing, the parent surface might already be
gone, in which case we end up with a surface being NULL which causes a
NULL pointer dereference and a crash.

Check if the parent surface is NULL to avoid the crash, and consider
it's already synchronized if it is NULL to avoid further updates.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/124
2018-05-03 11:39:33 +02:00
Carlos Garnacho
4ef886f51e wayland: Avoid actor updates non actor_surface role wl_surface.commit
We used to maintain an actor for cursors, even though we would possibly
use hw overlays or even some other overlay actor for those. This happens
no more, so check whether we are dealing with an actor-backed surface role
before fiddling with it.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
22485ba36f wayland: Refactor surface actor into MetaWaylandActorSurface
All surface roles that do need a backing actor inherit from this
class, it makes sense to move actor management there. This also
means the MetaWaylandActorSurface is in charge of emitting
::geometry-changed on the MetaWaylandSurface.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
8df2a1452c wayland: Notify actively of xwayland window/surface associations
Instead of scheduling a meta_later, keep track of the unassociated
windows, and look for matches as soon as the MetaWaylandSurface is
created on our side.

This will ensure the surface is given the Xwayland role before receiving
the first wl_surface.commit.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
b12c92e206 wayland: Add MetaWaylandSurface::geometry-changed signal
Abstract this instead of having callers connect to notify:: signals
on the surface actor.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
70036429bd wayland: Abstract access to the actor corresponding to a wl_surface
The actor itself will be shuffled around, abstract all external
access to it behind a function to make that easier later on.
2018-04-23 12:24:46 +02:00
Carlos Garnacho
44502be560 wayland: Do not reset frame list when merging pending state
In the synchronized subsurface case, the destination list may
contain other elements from previous wl_surface.commit calls.
Resetting the list will leave those dangling frame callbacks
that will lead to invalid writes when those get to be destroyed
(eg. on client shutdown).
2018-04-22 00:52:48 +02:00
Carlos Garnacho
b6f5bab212 wayland: Plug surface pending state contents leak
When moving the pending state of an effectively synchronized subsurface
so it is applied together with the parent, perform a merge of the source
MetaWaylandPendingState into the destination one, instead of simply
overwriting the struct.

The other approach had 2 kind of leaks, one that would happen everytime
a wl_surface.commit happens on a sync subsurface (both surface/buffer
damage regions are leaked). The other more unlikely one would apply on
the rest of pending state data, happening whenever the compositor gets
>1 wl_surface.commit calls on the subsurface before the parent surface
gets its own.

The function has also been renamed to use the more descriptive "merge"
term.

Related: gnome-shell#64
2018-04-12 23:35:20 +02:00
Olivier Fourdan
17a745bf81 wayland: update enter/leave output after effects
Compositor effects change the actor size and position, which can lead to
inconsistent output enter/leave notifications, leaving clients' surfaces
without any output set.

Update output enter/leave notifications after all compositor effects are
completed so that we give clients accurate output location.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/104
2018-04-09 10:19:26 +02:00
Jonas Ådahl
4345906663 wayland: Define abstract role types as actually abstract
They should not be instantiated by themself, only as actual roles.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 19:07:49 +08:00
Jonas Ådahl
d714a94d97 wayland: Add support for stable xdg-shell
This commit adds support for xdg_shell (the stable version). This was
done by first copying the old xdg-shell unstable v6 implementation into
a separate .c .h file pair (including various symbol renaming) then
porting the old xdg-shell unstable v6 implementation to the new stable
version.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:53 +08:00
Jonas Ådahl
44624736c5 wayland: Push actor state instead of itself pulling
Make the Wayland objects push the state relevant to their role to the
MetaSurfaceActor instead of MetaSurfaceActorWayland pulling the state
from the associated surface.

This makes the relationship between the actor and the objects that
constructs it more clear; the actor is a drawable that the protocol
objects control, not the other way around.

This will make it easier to "detach" a surface actor from a surface,
which is necessary when unmapping a window while the underlying surface
is yet to be destroyed and potentially reused.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:47 +08:00
Jonas Ådahl
704b73b041 wayland: Restructure surface role building blocks code
This commit moves out non-core wl_surface related code into separate
code units, while renaming types to fit a common scheme. The changes
done are:

 * ClutterActor based surface roles built upon
   MetaWalyandSurfaceRoleActorSurface. This object has been renamed to
   MetaWaylandActorSurface and related functionality has moved into
   meta-wayland-actor-surface.c.

 * The code related to roles backed by a MetaWindow (i.e. built upon
   MetaWaylandShellSurface) was moved into meta-wayland-shell-surface.c

 * The majority of subsurface related code was moved into into
   meta-wayland-subsurface.c and the object was renamed
   MetaWaylandSubsurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:40 +08:00
Jonas Ådahl
bd5e36cf0e wayland/surface: Stop using deprecated g_object_newv
Replace it with g_object_new_with_properties. This fixes a warning
about using deprecated API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:38 +08:00
Jonas Ådahl
d8f13f6b4c wayland: Shorten MetaWaylandSurfaceRoleShellSurface name
It was annoyingly long, so rename it to MetaWaylandShellSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:25 +08:00
Jonas Ådahl
07745b3082 wayland/surface: Disconnect actor handlers before unassigning role
The handlers depend on a role being assigned. Destroying the window
causes it to become unmapped, which would sometimes trigger one of the
handlers, resulting in an is-assigned assert hitting in one of the
handlers. Avoid this by disconnecting the handlers earlier, so that
there is no risk that any them being triggered before the role is
assigned.

https://bugzilla.gnome.org/show_bug.cgi?id=789552
2017-10-27 19:08:38 +08:00
Carlos Garnacho
08e4cb54a8 wayland: Trigger wl_output updates on actor position changes
Both notify::position on the surface actor and position-changed on
MetaWindow are listened to, in order to trigger wl_output updates for
wl_surfaces whenever the surfaces move across them.

Both signals are necessary in order to cater for toplevel and subsurface
relocations (Because it's the parent window actor what changes position
in this last case).

Also, shuffle signal disconnection, so each signal goes away with
the object reference held by MetaWaylandSurface.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-10-26 12:51:44 +02:00
Jonas Ådahl
4e7405aca9 wayland/surface: Send buffer release events immediately
Just queuing the buffer release event is prone to starvation, so send
the release immediately. See
https://lists.freedesktop.org/archives/wayland-devel/2017-September/035147.html
for more detailed explanation.

https://bugzilla.gnome.org/show_bug.cgi?id=788197
2017-09-28 09:58:17 -04:00
Olivier Fourdan
dd12f569d9 wayland: add inhibit shortcut mechanism
Add a mechanism to MetaWaylandSurface that inhibits compositor's own
shortcuts when the surface has input focus, so that clients can receive
all key events regardless of the compositor own shortcuts.

This will help with implementing "fake" active grabs in Wayland and
XWayland clients.

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-08-02 11:58:55 +02:00
Jonas Ådahl
9af6ec78ab wayland: Add support for wl_surface.damage_buffer
Implements support for the wl_surface.damage_buffer request, which
damages the buffer using buffer coordinate space.

https://bugzilla.gnome.org/show_bug.cgi?id=784080
2017-07-12 12:08:57 +08:00
Carlos Garnacho
cf1edff9ed wayland: Use notify::allocation notification to update surface outputs
Instead of updating the surface outputs on each actor ::paint.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-05-22 17:27:11 +02:00
Jonas Ådahl
704bd4c331 wayland/subsurface: Handle clients committing on destroyed subsurface
A client can still commit state to a destroyed subsurface. It wont
update anything on the screen, since the subsurface will not be
visible, but mutter should still handle it and not crash.

https://bugzilla.gnome.org/show_bug.cgi?id=781391
2017-04-21 17:46:17 +08:00
Jonas Ådahl
36f2d5b0f1 wayland: Make surface role vfunc better named
It checks whether a surface is on a given "logical monitor", not
output. Output here is the Wayland name for the same thing, but should
not be confused with MetaOutput.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
842ff5d6aa Rename MetaMonitorInfo MetaLogicalMonitor
In preparation for further refactorizations, rename the MetaMonitorInfo
struct to MetaLogicalMonitor. Eventually, part of MetaLogicalMonitor
will be split into a MetaMonitor type.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Olivier Fourdan
1ab6ac2996 wayland: disconnect mapped signal handler on destroy
Commit 5eb5f72 - wayland: Check surface outputs after mapped state
changes connected the ::mapped signal handler, we need to disconnect it
on destroy to avoid a possible assertion failure in
update_surface_output_state()

https://bugzilla.gnome.org/show_bug.cgi?id=776036
2016-12-13 15:34:03 +01:00
Carlos Garnacho
5eb5f72434 wayland: Check surface outputs after mapped state changes
So they consistently receive wl_surface.leave after the surface
is not visible anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=775478
2016-12-02 12:04:40 +01:00
Jonas Ådahl
eed4dab0fc wayland: Add support for EGLStream client buffers
This commit adds for a new type of buffer being attached to a Wayland
surface: buffers from an EGLStream. These buffers behave very
differently from regular Wayland buffers; instead of each buffer
reperesenting an actual frame, the same buffer is attached over and
over again, and EGL API is used to switch the content of the OpenGL
texture associated with the buffer attached. It more or less
side-tracks the Wayland buffer handling.

It is implemented by creating a MetaWaylandEglStream object, dealing
with the EGLStream state. The lifetime of the MetaWaylandEglStream is
tied to the texture object (CoglTexture), which is referenced-counted
and owned by both the actors and the MetaWaylandBuffer.

When the buffer is reattached and committed, the EGLStream is triggered
to switch the content of the associated texture to the new content.
This means that one cannot keep old texture content around without
copying, so any feature relying on that will effectively be broken.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
41c96921d6 wayland: Add support for EGL_WAYLAND_Y_INVERTED_WL
Add support for inverted Y Wayland buffers. OpenGL textures are by
default inverted, so adding support for EGL_WAYLAND_Y_INVERTED_WL
effectively means adding support for non-inverted, which makes the
MetaShapedTexture apply a transformation when drawing only when querying
EGL_WAYLAND_Y_INVERTED_WL resulted in the response "EGL_FALSE".

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
23455985cd wayland: Make MetaWaylandBuffer handle texture generation itself
Don't rely on the Cogl layer having Wayland specific paths by
determining the buffer type and creating the EGLImage ourself, while
using the newly exposed CoglTexture from EGLImage API. This changes the
API used by MetaWaylandSurface to make the MetaWaylandBuffer API be
aware when the buffer is being attached. For SHM and EGL buffers, only
the first time it is attached will result in a new texture being
allocated, but later for EGLStream's, more logic on every attach is
needed.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
fccdd00f74 MetaWaylandSurface: Move destroy signal even earlier
Move the MetaWaylandSurface::destroy signal before starting the actual
destruction, in wl_surface_destructor, so that all fields (e.g. surface
role) are intact when the listeners are invoked.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Olivier Fourdan
4f58a46217 wayland: add min/max size from xdg-shell v6
Implement min/max size request from xdg-shell-v6 and plug it into the
existing code so that windows with fixed size cannot be tiled/maximized
in Wayland just like in X11.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=770226
2016-09-06 08:54:08 +02:00
Olivier Fourdan
1f570d542e wayland: Survive an unsupported buffer size
If cogl fails to create a texture from the client's given buffer,
mutter would raise a fatal error and terminate.

As a result, a broken client might kill gnome-shell/mutter and take the
entire Wayland session with it.

Instead of raising a fatal error in this case, log the cogl error
message and send the client an OOM error, so mutter/gnome-shell can
survive an unsupported buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=770387
2016-08-26 11:16:07 +02:00