Commit graph

52 commits

Author SHA1 Message Date
Martin Flöser
665c0535fe Add support for zwp_idle_inhibit_manager_v1
Summary:
This protocol allows to indicate that a wl_surface should inhibit idle
actions such as DPMS, screen locking if the surface is visible.

The protocol is quite simple: it just creates an IdleInhibitor for a
Surface. If such an IdleInhibitor exists the Surface is considered to
inhibit idle.

On the server side it is also exposed like that through the API. The
IdleInhibitorInterface is private to the library and only
SurfaceInterface is extended to expose whether it currently inhibits
idle.

CCBUG: 385956

Test Plan: New test case added

Reviewers: #frameworks, #kwin, #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D8396
2017-11-16 20:22:44 +01:00
David Edmundson
9b564c4069 Update SurfaceInterface outputs when an output global gets destroyed
Summary:
As per existing TODO.

A new signal is added on Global to emit so we can process the result
whist we still have a valid object. The name is overly explicit to try
and logically separate it from QObject::destroyed().

Test Plan: Updated existing unit test.

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: graesslin, anthonyfieroni, plasma-devel, #frameworks

Tags: #frameworks, #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D7531
2017-08-26 11:54:10 +01:00
Martin Gräßlin
b44a8fb556 Implementation of PointerConstraints protcol
Summary:
The pointer constraints protocol is an unstable protocol and thus
the implementation follows the semantics of unstable protocols.

The protocol allows to create a constraint on the pointer - either a
lock or a confinement on a surface. Those are not activated at once, but
when the compositor actively grants it.

During lock no further pointer motion is emitted, during confinement the
pointer is kept in a certain area.

This implements T4451.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D3466
2016-11-24 09:19:36 +01:00
David Edmundson
8b3ecf8436 Return SurfaceInterface::size in global compositor space
REVIEW: 129358
2016-11-16 14:50:50 +00:00
Martin Gräßlin
9f92a05f52 Add support for Surface enter/leave events
Summary:
This change implements support for the wl_surface events enter and
leave. Those events are emitted whenever a surface becomes visible on
an output by e.g. mapping the surface, moving or resizing it. Similar
the leave is sent whenever the surface is no longer on an output.

The server side is not yet fully complete yet. It also needs to emit
when the client binds the output another time and needs to send a
leave before destroying the output.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2528
2016-09-13 08:32:50 +02:00
Martin Gräßlin
ab98448fec [server] Standardize the destructor request handling for Resources
Summary:
This change standardizes the behavior regarding the destructor request.

The destructor should destroy the resource and nothing else. The
Wayland library invokes the static unbind method once the resource is
destroyed. The implementation provided by Resource::Private::unbind
triggers a delete later on the Resource. So there is no need to trigger
a deleteLater from the destructor request callback.

This change adds a generic implementation to Resource::Private which is
now used by all inheriting classes replacing the custom implementations.

Test Plan:
For a few Resources the test is extended to ensure that the Resource
gets deleted on server side.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1679
2016-05-30 08:16:07 +02:00
Martin Gräßlin
908f86f299 [server] Don't destroy resource from dtor of a Resource sub class
Summary:
Not needed as the dtor of the Resource ensures that the wl_resource
gets destroyed.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1680
2016-05-30 08:15:33 +02:00
Martin Gräßlin
d1a09838e1 [server] Prevent double delete of callback resources in SurfaceInterface
Summary:
When destroying a SurfaceInterface all callbacks are getting destroyed.
This used to iterate over the callbacks and performing
wl_resource_destroy on them. This triggered the destroy handler which
removes the resource from the callback list. Which means removing from
the list we are iterating on. This could result in a double delete or
accessing invalid memory.

This change copies all callbacks to a temporary list and clears the
normal lists. So the destroy handler does no longer modify the lists
currently being iterated on.

Test Plan: Added a test case which crashed with previous code

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1677
2016-05-25 09:03:10 +02:00
Martin Gräßlin
37851e2e08 [server] Add a method SurfaceInterface::surfaceAt(const QPointF&) -> SurfaceInterface*
Summary:
The new method returns the (child) surface at a given surface position
taking care of stacking order, whether surfaces are mapped, etc.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1319
2016-04-05 14:29:21 +02:00
Martin Gräßlin
a2a888bc76 [server] Add damage tracking feature to SurfaceInterface
Summary:
This change introduces a damage tracking feature in SurfaceInterface.
So far the SurfaceInterface only exposes the damage compared to the
last attached buffer. But this is not always usefull for the user of
the library. E.g. if:
* server renders
* client damages buffer and commits
* client damages buffer and commits
* server wants render

In this situation the last damage information is not helpful to the
user of the library. It would need the combined damage information over
all attached buffers.

The new API combines the damage of the two commits in the example above.
The user of the library can then call resetTrackedDamage once it
processed the current damage (e.g. by updating the OpenGL texture).

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1281
2016-04-04 08:59:27 +02:00
Martin Gräßlin
d727d2e477 [server] Workaround for QtWayland bug https://bugreports.qt.io/browse/QTBUG-52192
Summary:
QtWayland doesn't map the parent sub-surfaces in a sub-surface tree.
According to the spec this would mean also the child sub-surface is not
mapped. But being strict according to the spec will make applications
like SystemSettings fail badly. Embedded child windows will not be
rendered and QtWayland is going to hard freeze. This is not acceptable,
thus we need to workaround this QtWayland bug till it's fixed.

It's worth mentioning that Weston as the reference compositor also
doesn't handle this situation according to spec and renders the
sub-surface. See https://bugs.freedesktop.org/show_bug.cgi?id=94735

The difficult part for the workaround is to determine whether a surface
should be considered unmapped. E.g. when the parent gets unmapped we need
to really unmap it. But what's the difference between an unmapped parent
surface which should be considered mapped and an unmapped parent surface
which should be considered unmapped?

The implementation goes with considering a new sub-surface always as
mapped - independently of whether it ever got a buffer attached. As soon
as it had a buffer attached and it gets unmapped again, it will go back
to a standard conform way.

The behavior now is not standard conform, thus the autotest is adjusted
to have QEXPECT_FAIL for the now no longer standard conform areas.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1250
2016-04-04 08:55:59 +02:00
Martin Gräßlin
7053e4fce6 [server] Don't emit unmapped if the Surface wasn't mapped
Summary:
If a Surface doesn't have a buffer attached and a null buffer gets
attached the buffer state doesn't really change. Thus neither the
unmapped signal nor the damaged signal should not be emitted.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1261
2016-04-04 08:55:17 +02:00
Martin Gräßlin
d44b2ee30d [server] Add a convenient method to check whether a Surface is mapped
Summary:
In a SubSurface tree a Surface is only considered mapped if the Surface
has a buffer applied and the parent Surface is mapped.

The added method implements this check. It's useful for the compositor
to easily check this condition as it allows to easily figure out whether
a SubSurface needs to be rendered and it's also useful for implementing
the input handling as a not mapped sub-surface should not get any input
events.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1247
2016-03-29 12:08:10 +02:00
Martin Gräßlin
6d529abf8e [server] Remove sub-surface from parent when it's surface is destroyed
Summary:
From spec:
If the wl_surface associated with the wl_subsurface is destroyed,
the wl_subsurface object becomes inert. Note, that destroying either
object takes effect immediately.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1211
2016-03-24 16:05:00 +01:00
Martin Gräßlin
04ccf04596 [server] Add a workaround for a freeze in QtWayland
Summary:
See: https://bugreports.qt.io/browse/QTBUG-52092

Freeze happens if a sub-surface is rendered to before the main surface
is rendered. The compositor has no chance to know that this is a window
which needs to be rendered, thus the application might freeze without
ever becoming visible.

Famous example applications being affected: all kcms with a nested
QQuickView. E.g.: kcmshell5 kwineffects

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1208
2016-03-23 17:04:26 +01:00
Martin Gräßlin
bfc94ce985 [server] Improve variable naming
transformFactorChanged -> transforChanged. It's not a factor.

Reviewed-By: sebas
2016-03-23 14:34:51 +01:00
Martin Gräßlin
610fbc672f [server] Don't double buffer adding/removing of sub-surfaces
QtWayland doesn't commit the parent surface when creating a sub-surface.
This results in a QtWayland application to freeze as it renders to the
surface and waits for the frame rendered, which it will never get as the
Compositor waits for the commit on the parent prior to mapping the
sub-surface.

To work around this behavior, we apply the adding/removing directly.
The behavior around this is actually not fully documented, so QtWayland
is not wrong per se. See:

https://lists.freedesktop.org/archives/wayland-devel/2016-March/027540.html

Once this is properly clarified and implemented in the Client, we should
revert this change.

Differential Revision: https://phabricator.kde.org/D1191
2016-03-23 14:21:29 +01:00
Martin Gräßlin
263e5d7969 [server] Add a subSurfaceTreeChanged signal to SurfaceInterface
The idea behind this signal is to notify whenever the tree of sub
surfaces changes in a way that a repaint of the Surface is required.
Possible situations are:
* surface damaged
* surface unmapped
* subsurface added/removed
* subsurface moved (position changed)
* subsurface stacking changed

Ideally it would be possible to provide the actual area which needs
repainting, but due to the possible complexity of the tree, synced
and desynced changes this doesn't look worth the effort. A user of
the signal might trigger too many repaints with it, but if it really
wants to be only notified about the actual changes, it can just track
the individual sub-surfaces.
2016-03-23 14:20:26 +01:00
Martin Gräßlin
b7f470e51b [server] Cache the state of synchronized sub surfaces
When committing the state of a sub-surface, the state should not
be immediately applied if the sub-surface is in synchronized mode.
Instead it should be cached and only applied after the parent surface's
state is applied.

To implement this the Surface::Private has now a third cached state
buffer. When committing the state is either swapped between pending and
current or pending and subSurfacePending. Once the parent state is
applied the state is swapped between subSurfacePending and current.

The logic for applying state changes is changed. Instead of copying the
complete state object, the individual state changes are now copied and the
source gets completely reset to default values. Only the children tree is
copied back, as that list needs to be modified.
2016-03-23 14:20:26 +01:00
Martin Gräßlin
05993458e2 [server] Send frameRendered to all sub-surfaces
If a surface got rendered it implies that all sub-surfaces also got
rendered. So pass the frameRendered to the complete sub-surface tree.
2016-03-21 16:03:31 +01:00
Martin Gräßlin
219b1b755c [server] Flush client after sending a frameRendered callback 2015-11-04 14:50:15 +01:00
Sebastian Kügler
239e702f0f Fix Typo in Surface::inputIsInfitine
- add correctly named method
- forward the wrongly named one
- adjust autotests

REVIEW:125260
2015-09-16 16:45:09 +02:00
Marco Martin
4b9ee54d66 Interface for a Slide effect
a kwayland interface plus autotests for
the slide KWin effect, marks a window the direction
it wants to slide from and the offset from the screen edge
2015-09-09 17:37:36 +02:00
Martin Gräßlin
5e3bb70612 Fix doxygen generation
Doxygen doesn't like our callback listener at all. We need to hide
it from doxygen, otherwise docu doesn't get generated.
2015-09-09 16:39:50 +02:00
Marco Martin
1f4beb0334 Wayland protocol for background contrast
new wayland protocol used to define regions behind a window
in which the kwin background contrast effect should be applied
REVIEW:125030
2015-09-03 16:12:23 +02:00
Marco Martin
4c3aa31cd3 Blur protocol in KWayland
a protocol to activate the blur behind windows and to
optionally set a sub region of the window where to apply
the blur to, in case the window is shaped
REVIEW:125015
2015-09-02 14:42:57 +02:00
Martin Gräßlin
69832442a1 Add a Shadow protocol
The shadow protocol is inspired by the KWin's X11 protocol and the
DecorationShadow in KDecoration2.

A shadow is attached to a surface (after a commit on surface) and
consists of several image parts (represented through a buffer):
* top-left
* top
* top-right
* right
* bottom-right
* bottom
* bottom-left
* left

In addition there is an offset on each side.

For more information see also the X11 protocol described at [1].

Note: the protocol is currently missing documentation and changing
the shadow is not yet properly delegated to the server API.

[1] https://community.kde.org/KWin/Shadow
2015-07-15 11:11:30 +02:00
Martin Gräßlin
19c03da560 [server] Don't discard callbacks on surface commit
Old callbacks need to be kept around, otherwise mesa might freeze.
2015-06-03 21:16:53 +02:00
Martin Gräßlin
713dbc51fa [server] Restrict damage to the surface geometry
Before emitting the new damage we need to restrict it to the geometry
of the surface. That's required by the documentation and at least
QtWayland/OpenGL emits non-sense damage events.
2015-05-26 11:42:38 +02:00
Martin Gräßlin
260c33e75d [server] Call wl_resourc_destroy from destroyCallbacks
That's what weston does.
2015-04-20 13:56:41 +02:00
Martin Gräßlin
fd6ab581a1 [server] ServerSurface::get takes id and client
id is in client scope, thus we need to include the client as well.
2015-04-02 09:41:48 +02:00
Martin Gräßlin
33a37f99b7 [server] Add a size property to SurfaceInterface
Basically just wraps the size of the attached buffer. Convenience to
not have to go down to the Buffer to read the size.

TODO: apply buffer scale and transform.
2015-03-03 10:16:11 +01:00
Martin Gräßlin
1927c3a1ae [server] Add static SurfaceInterface *SurfaceInterface::get(quint32 id) 2015-02-09 14:33:50 +01:00
Martin Gräßlin
5b03dfe324 Improve attaching buffer and commiting in SurfaceInterface
Now the code handles correctly the attaching of a null buffer
(emits a signal unmapped) and if a commit doesn't have a pending
buffer it won't be reset. Damage requests are ignored if no buffer
has been attached yet.
2014-11-28 08:33:32 +01:00
Martin Gräßlin
68ce470231 Add a parentResource to Resource 2014-11-20 16:40:14 +01:00
Martin Gräßlin
b243eea6cd Add createResource to ClientConnection
One place to rule all createResource calls.
2014-11-19 19:01:15 +01:00
Martin Gräßlin
c71cf3999c Resource holds a ClientConnection instead of a wl_client 2014-11-19 16:53:56 +01:00
Martin Gräßlin
8685a0e972 Create wl_resource in Resource::Private instead of subclasses
Required information is passed through the ctor of Private.
::create is still virtual as ShellSurfaceInterface is retrieving
client information. This can be fixed once we have a better wl_client
encapsulation class.
2014-11-14 15:33:21 +01:00
Martin Gräßlin
57de2df55e Track all created Resources in Resource::Private
Also provide static method to map a wl_resource to the Resource
sub class.
2014-11-14 15:13:06 +01:00
Martin Gräßlin
cee32f902a Move static unbind method from derived classes to Resource::Private
All classes had exactly the same implementation, so it's a good idea
to share the implementation.
2014-11-14 11:01:54 +01:00
Martin Gräßlin
0fb42d102e Move q-ptr to Resource::Private
In the derived classes a q_func() is added which casts the q-ptr
back to the Resource derived class.
2014-11-14 10:55:06 +01:00
Martin Gräßlin
de62216357 Add cast from wl_resource to Private to Resource::Private
Replaces the custom implementation in each of the derived classes.
2014-11-14 10:20:43 +01:00
Martin Gräßlin
53a4455c47 [server] Introduce a base class Resource
The Resource base class is supposed to be used by all interface
classes which get created for a wl_resource.

Most interface classes are adjusted, but there are some exceptions:
* BufferInterface: is different as the wl_resource is already created
* PointerInterface and KeyboardInterface: those two need changes, the
  implementation differs from all other interface implementations.
2014-11-14 09:45:02 +01:00
Martin Gräßlin
dd50148187 [server] Interface method returning wl_resource* is called ::resource
Simplifies using the library as all Interfaces have the same methods.
Note: there are interfaces not providing the wl_resource* method.
2014-11-13 13:05:01 +01:00
Martin Gräßlin
ec16b7c40e Use a destroy listener in BufferInterface
This fixes a crash when closing a connected Xwayland server.
2014-11-07 09:04:19 +01:00
Martin Gräßlin
5debfb6832 Add support for opaque and input region to Surface
Implemented on both Client and Server side.
2014-10-16 14:59:01 +02:00
Martin Gräßlin
ee24e4e08a Add support for wl_subcompositor and wl_subsurface
This implements the subcompositor and subsurface protocol on both
Client and Server side.

Client:
New classes SubCompositor and SubSurface. The SubCompositor can be
created through the Registry and creates the SubSurface which is
bound to a Surface and has a parent Surface. The SubSurface class
provides convenient wrappers for all calls exposed in the
wl_subsurface interface.

Server:
New classes SubCompositorInterface and SubSurfaceInterface. Support
for all commands is added, though the API probably still can need
some fine tuning. The synchronized vs. desynchronized behavior is
not yet exposed in the API. This could also be delegated towards
the user of the library.
2014-10-16 08:19:52 +02:00
Martin Gräßlin
e448b84a82 Add d-pointer to Server::SurfaceInterface
It also adds a
static SurfaceInterface *get(wl_resource*)
to SurfaceInterface which can find the SurfaceInterface for the
given wl_resource. This is needed for ShellSurfaceInterface which
can no longer just cast the wayland user data.
2014-09-19 07:06:31 +02:00
Martin Gräßlin
a8c7c16c94 Use namespace KWayland::Server instead of KWin::WaylandServer
It's no longer part of KWin.
2014-09-17 16:10:38 +02:00
Martin Gräßlin
3c87cea7a8 Change to LGPLv2+
I'm the only copyright holder of the code in this repository, thus
I can change from GPL to LGPL!
2014-09-17 15:57:56 +02:00