1
0
Fork 0
Commit graph

121 commits

Author SHA1 Message Date
Jonas Ådahl
bbec8abb68 wayland/surface: Rename MetaWaylandPendingState to MetaWaylandSurfaceState
The name didn't communicate it was about surface state, and it somewhat
confusingly had the name "pending" in it, which could be confused with
the fact that while it's used to collect pending state, it's also used
to cache previously committed pending state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
d60d671fec wayland: Use helper to access pending state from the outside
With the eventual aim of exposing the internals of MetaWaylandSurface
outside of meta-wayland-surface.c, make users of the pending state use a
helper to fetch it. While at it, rename the struct field to something
more descriptive.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
8dc730e5ca wayland/surface: Move subsurface synchronization logic to role
It's an implementation detail of subsurfaces when to cache state
and when not to, so move that logic to the subsurface role
implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Georges Basile Stavracas Neto
94682e69aa Replace ClutterRect by graphene_rect_t
https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Jonas Ådahl
b5f50028f2 wayland: Untie MetaWindowXwayland lifetime from the wl_surface
For the most part, a MetaWindow is expected to live roughly as long as
the associated wl_surface, give or take asynchronous API discrepancies.

The exception to this rule is handling of reparenting when decorating or
undecorating a window, when a MetaWindow on X11 is made to survive the
unmap/map cycle. The fact that this didn't hold on Wayland caused
various issues, such as a feedback loop where the X11 window kept being
remapped. By making the MetaWindow lifetime for Xwayland windows being
the same as they are on plain X11, we remove the different semantics
here, which seem to lower the risk of hitting the race condition causing
the feedback loop mentioned above.

What this commit do is separate MetaWindow lifetime handling between
native Wayland windows and Xwayland windows. Wayland windows are handled
just as they were, i.e. unmanaged together as part of the wl_surface
destruction; while during the Xwayland wl_surface destruction, the
MetaWindow <-> MetaWaylandSurface association is simply broken.

Related: https://gitlab.freedesktop.org/xorg/xserver/issues/740
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/762

https://gitlab.gnome.org/GNOME/mutter/merge_requests/774
2019-10-07 20:25:20 +00:00
Robert Mader
77229f99b8 wayland: Implement subsurface.place_below() for parents
Flatten the subsurface actor tree, making all surface actors children
of the window actor.
Save the subsurface state in a GNode tree in MetaWaylandSurface, where
each surface holds two nodes, one branch, which can be the tree root
or be attached to a parent surfaces branch, and a leaf, which is
used to save the position relative to child branch nodes.

Each time a surface is added or reordered in the tree, unparent all
surface actors from the window actor, traverse all leaves of the
tree and readd the corresponding surface actors back to the window
actor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/664
2019-08-27 11:31:00 +03: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
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
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
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
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
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
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
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
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
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
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
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
Jonas Ådahl
f21df37190 wayland: Let shell surface role sync generic window state
Instead of having each final role do the same call, lets just make the
common role object deal with synchronizing window buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
817911d9d3 wayland: Keep track of configured position
Besides the configured dimension, also keep track of the configured
position. This will later be used by popup position feedback.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
3a75e55cd8 wayland: Move gtk_surface fields out of MetaWaylandSurface
Let the gtk_shell extension unit handle its own state.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
335cd8e74c MetaWaylandSurface: Move 'destroying' field
It is not related to the gtk_surface extension, so move it to other
generic fields.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
3b3f40a1aa MetaWaylandSurface: Allow passing parameters when assigning role
Allow passing parameters (only GObject parameters supported for now) so
that role assignment can affect the paremeters set during construction.

If a role was already assigned when assigning, the passed parameters
are set using g_object_set_valist().

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Carlos Garnacho
1acfcbda6c wayland: Add MetaWaylandSurface::destroy signal
There's places where it would be convenient to add listeners to this,
so add the signal. The signal is only emitted once during destruction,
it is convenient for the places where we want notifications at a time
the object is still alive, as opposed to weak refs which notify after
the fact.
2016-05-03 13:05:06 +02:00
Jonas Ådahl
f318ec9df5 wayland: Move shell surface role fields to the role structs
Don't keep all the role specific fields in MetaWaylandSurface and have
the roles manage the needed fields themself.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
229a143eac wayland: Add 'MetaWaylandPopupSurface' bridge between popup and surface
Add a bridge between the MetaWaylandPopup object and the corresponding
popup surface role. This bridge replaces communicating dismissed and
unmapped popup events.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
9028e30b39 wayland: Move out window state application into the roles
A large part of meta_wayland_surface_apply_window_state() was only
relevant for xdg_surface. Make this more obvious by splitting it up,
moving the relevant parts to the relevant roles.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
e66f176c29 wayland: Add get_toplevel() vfunc to the role class
How to find the toplevel surface of a surface depends on the surface
role, so let the roles implement it themself.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
f8878ac907 wayland: Let the roles handle their windows being managed
Move xdg_shell specific code from generic Wayland code into the xdg
shell code unit by letting the roles handle the corresponding
MetaWindow being managed.

https://bugzilla.gnome.org/show_bug.cgi?id=757623

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
c2643ba5ac wayland: Keep wl_shell_surface state during loss of window
It has been common practice (in QT5 for example) to set
wl_shell_surface state at situations where mutter will have destroyed
the MetaWindow. This commit keeps track of the relevant state
separately from MetaWindow, and synchronizes when needed.

https://bugzilla.gnome.org/show_bug.cgi?id=757623

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
7fd585fe98 wayland: Split out shell surface code from meta-wayland-surface.c
Move xdg_shell related functionality to a new meta-wayland-xdg-shell.c
and wl_shell related functionality to a new meta-wayland-wl-shell.c,
and adapt role object tree.

Common functionality related to the surface being drawn as a
MetaSurfaceActor was moved to a MetaWaylandSurfaceRoleActorSurface role.

The subsurface role GObject is made to inherit the actor surface GObject.

Shell surface hooks (configure, ping, close, popup done) were added to
a MetaWaylandSurfaceRoleShellSurface GObject which inherits the
surface actor role GObject.

The shell surface roles (xdg_surface, xdg_popup, wl_shell_surface) are
made to inherit the shell surface GObject and implement the relevant
API.

https://bugzilla.gnome.org/show_bug.cgi?id=757623

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
f44238a72f MetaWaylandSurface: Keep an extra buffer use count for role-less surfaces
Whether a surface needs to keep the committed wl_buffer un-released
depends on what role the surface gets assigned to. For example a cursor
role may need an unreleased shm buffer in order to create a hw cursor from
it.

In order to support this, keep a separate reference and use count to
the buffer on behalf of the in the future assigned role, and release
those references after the surface was assigned a role. A role that
needs its own references and use counts, must in its assign function
make sure to add those.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
10a0114856 wayland: Move buffer use count to MetaWaylandSurface
Each wl_surface.commit with a newly attached buffer should result in
one wl_buffer.release for the attached buffer. For example attaching
the same buffer to two different surfaces must always result in two
wl_buffer.release events being emitted by the server. The client is
responsible for counting the wl_buffer.release events and be sure to
have received as many release events as it has attached and committed
the buffer, before reusing it.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
aa7bc501d5 wayland: Replace buffer destroy wl_signal with a GObject signal
Don't use the libwayland-* utilities when we have our own that do the
same thing.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:02:31 +08:00
Jonas Ådahl
20908b9c2c MetaWaylandPointerConstraint: Make per surface state a quark
Make the per surface pointer constraint related state (list of
constraints on given surface) a quark managed from the pointer
constraints unit.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Jonas Ådahl
62ac9df43d MetaWaylandPointerConstraint: Fix effective region calculation
The when surface->input_region is NULL, it should be interpreted as the
whole surface region. If not, the effective input region is the
intersection of the buffer region and the input region set by
wl_surface.set_input_region. Add
meta_wayland_surface_calculate_input_region() that does this
calculation.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Jonas Ådahl
d340c3a6dd wayland: Don't unset surface->buffer when wl_buffer destroyed
Don't unset the surface->buffer if the associated wl_buffer object is
destroyed. The MetaWaylandBuffer doesn't really only represent a
wl_buffer object, but also the data (texture) created from the given
wl_buffer. Thus, for example destroying a released SHM wl_buffer should
not destroy the MetaWaylandBuffer instance, because the texture may
still be used.

This commit also fixes a race where calc_showing would hide a window
because, at the time of calculation whether it should be showing, the
surface's buffer had been destroyed as described above.

https://bugzilla.gnome.org/show_bug.cgi?id=762716
2016-03-01 13:33:13 +08:00
Ray Strode
bed82427c6 wayland: change accessible boolean to use_count counter
Since a buffer can be used by multiple surfaces at once,
we need to release the buffer only after all surfaces
are finished with it.  Currently we track whether or
not to release the buffer based on the accessible boolean.
This commit changes it to a counter to accomodate multiple
users.

Also, each surface needs to know whether not it is done with
the buffer, so this commit adds a buffer_used boolean to the
surface state.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-19 08:57:56 -05:00
Jonas Ådahl
495c89401a Implement support for the wp_pointer_constraints protocol
The wp_pointer_constraints protocol is a protocol which enables clients
to manipulate the behavior of the pointer cursor associated with a seat.

Currently available constraints are locking the pointer to a static
position, and confining the pointer to a given region.

Currently locking is fully implemented, and confining is implemented for
rectangular confinement regions.

What else is lacking is less troublesome semantics for enabling the lock
or confinement; currently the only requirement implemented is that the
window that appears focused is the one that may aquire the lock.

This means that a pointer could be 'stolen' by creating a new window that
receives active focus, or when using focus-follows-mouse, a pointer
passes a window that has requested a lock. This semantics can be changed
and the protocol itself allows any semantics as seems fit.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
e2efc85b08 wayland: Make the pending surface state a GObject
Making the pending state an GObject makes it easier to extend it with
additional optional state without putting everything inside one big
struct.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
bc8ec2d90d wayland: Add global to surface coordinate helper
https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:47 +08:00