This reverts commit 3cf004b68e.
Unfortunately, 3cf004b broke a couple of tests in kwin due to Qt not
emitting QAbstractEventDispatcher::aboutToBlock() signal when macros
such as QTRY_VERIFY() or QTRY_COMPARE() spin the event loop.
Frame callbacks only indicate when the client can start rendering a new
frame, it's not meant to be precise. If the client wants to do some
black magic with frame scheduling and so on, it needs to use a protocol
such as presentation_time. This change removes the pointless flush to
prevent over-flushing client connections.
Order of a client teardown is:
- ClientConnection is removed from the static map
- All our client owned resources are torn down
- ClientConnection is deleted (via a previous deleteLater)
The recent refactor led to a behavioural change where ::client could
return a null pointer.
We want the client getter to be valid throughout the lifespan of
SurfaceInterface, by doing the lookup once we achieve that.
BUG: 424255
The main purpose behind the kwaylandserver library is to provide a set
of re-usable wayland compositor extension implementations. However, it's
worth noting that the design of kwaylandserver is far from perfect at
the moment.
KWaylandServer tries to hide all low level wayland details from the
compositor. But it's not the case with buffers, which diminishes the
whole point behind the library.
Creating OpenGL textures from Wayland buffers is the responsibility of
the compositor. So, when it comes to client buffers, we are one foot in
KWaylandServer, and the other foot in the compositor.
Since the surface size is a logical size, the compositor can't use it
for allocating memory for OpenGL textures. This change adds the buffer
size property in SurfaceInterface that can be used for allocating memory
for textures as well as monitoring buffer size changes.
I must say that the introduction of the buffer size property is a crude
hack because BufferInterface just needs to provide an OpenGL texture for
each plane. The main blocker for that is that it would involve moving
the backend, the compositor, and the wayland bits in the same place, for
example kwayland-server or ultimately kwin.
The buffer scale and the buffer transform property specify transforms
that had been applied to the buffer's contents. Neither one of those
properties apply to the surface, in other words the buffer transform
property doesn't indicate that the surface was rotated or flipped or both.
This change doesn't gain anything in terms of new features, etc. It just
attempts to make things more clear.
The compositor needs to monitor changes in the mapping between the
surface local coordinates and the buffer coordinates because texture
coordinates correspond to the latter. One way to do it is to monitor
things such as the surface size, the buffer size, the buffer scale,
etc. The main problem with doing so is that there are so many factors
that contribute to how mapping between the surface local coordinate
space and the buffer coordinate space is performed.
In order to provide a generic way for monitoring changes in the mapping
between the surface local coordinate space and the buffer coordinate
space, this patch introduces two new matrices. The first one specifies
how the surface-local coordinates are mapped to buffer coordinates, and
the other one specifies how to map the buffer coordinates to surface
local coordinates.
With the new two matrices, the compositor has a generic way to get
notified when it has to re-compute texture coordinates.
The wp_viewporter compositor extension allows clients to crop and scale
their surface. It can be useful for applications such as video players
because it may potentially reduce their power usage.
Unfortunately, in order to map a point from the surface-local coordinate
space to the buffer pixel coordinate space, one cannot divide the point
by the scale factor since the buffer might be rotated or flipped.
This change introduces a couple of helper methods for converting points,
regions, and rectangles from the surface-local coordinates to the buffer
pixel coordinates and vice versa.
Summary:
In KWin, we need to know when a sub-surface becomes mapped or unmapped
so we can generate or filter out window quads for the sub-surface.
Reviewers: #kwin, davidedmundson, apol
Reviewed By: #kwin, davidedmundson, apol
Differential Revision: https://phabricator.kde.org/D29256
Summary:
These signals can be very useful when one wants to monitor changes in a
sub-surface tree.
Reviewers: #kwin, apol
Reviewed By: apol
Subscribers: apol, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D27860
Summary:
The spec says nothing about the order between damage_buffer and attach
requests.
Test Plan: Firefox doesn't become frozen. Although there are still issues with resizing.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D28147
Summary:
The new method provides a convenient way for determining the rectangle
that bounds the given surface and all of its sub-surfaces. This can be
very handy when determining the effective window geometry.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: apol, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D27828
Test Plan:
Unit test
Will be tested by hotspots in drag icons
Reviewers: #kwin
Subscribers: kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D27190
Summary:
So far all double-buffered properties in our implementation of xdg-shell
weren't actually double-buffered. When a property setter is invoked, we
pray to the God hoping that the client committed associated surface.
This change introduces private SurfaceRole class. The new class provides
a way for SurfaceInterface to commit pending state of associated shell
surface.
The chosen architecture allows us to do more in the future. For example,
we could use SurfaceRole to prevent associating several roles to a single
wl_surface object, e.g. xdg-toplevel to a pointer surface, etc.
Test Plan: This change breaks support for client-side decorated clients in KWin.
Reviewers: #kwin
Subscribers: kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D23745
Summary:
Missing from our surface handling was the damage_buffer call introduced in
version 4 of the wl_compositor interface.
Its only difference to a normal damage call is that the damaged region is
supposed to be defined by the client in buffer coordinates instead of
surface coordinates. This damage must be tracked separately in KWayland
and on commit with the buffer transformation united with the normal damage.
Test Plan: Autotest updated.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, zzag, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D15910
Summary:
Whilst some interfaces that are double-buffered against the wl_surface
are proxied through SurfaceInterface, some are not, most notably
XdgShell.
We need some low level signal to know when the surface has been
committed which doesn't rely on their being a damaged buffer.
Test Plan:
Unit test
Used in kwin
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D18582
Summary:
Allows a compositor to set a proxy surface to handle drag and drop
operations place of the actual surface the drag originated from.
One proxy surface can handle multiple origin surfaces at the same time. These
need to get registered once. The active remote surface gets set when a pointer
button is pressed on the surface.
Test Plan: Manually with KWin's Xwayland DnD patches.
Reviewers: #kwin
Subscribers: davidedmundson, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D15421
Summary:
KWayland takes always the top-most child surface at a given position for its
pointer input. But if a sub-surface sets its input region, it should not select
this one when the position is out of its input region, but rather try the
surface below.
Test Plan:
My testing was only on my Xwayland branch. Supposed to also fix a problem
with Firefox native Wayland port.
Reviewers: #frameworks, graesslin, davidedmundson
Reviewed By: davidedmundson
Subscribers: davidedmundson, zzag, kde-frameworks-devel, graesslin, plasma-devel
Tags: #frameworks, #plasma_on_wayland
Differential Revision: https://phabricator.kde.org/D7038
Summary:
Firefox sends
wl_surface@37.damage(0, 0, 808, 622)
wl_surface@37.attach(wl_buffer@34, 0, 0)
Which we silently treat as an error.
There's nothing in the spec to forbid this. The only thing that matters
is the state on commit. This moves a check there.
CCBUG: 397834
Test Plan:
Had a debug in there which was being activated
Gets firefox slightly further (but not complete)
Reviewers: #kwin
Subscribers: kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D15912
Summary:
Use lambda function to reduce code duplication and put
function definitions in the same order as in the header file.
Test Plan: All autotests succeed.
Reviewers: #plasma, davidedmundson
Reviewed By: #plasma, davidedmundson
Subscribers: davidedmundson, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D13191
Summary:
Qt seems to damage and commit child subsurfaces although their parent
got destroyed. This actually doesn't make any sense as without a parent
surface they cannot be shown. But nevertheless we should not crash in
such a situation.
This change guards the places in the commit handling code where the
parent gets accessed.
BUG: 389231
Test Plan: New test case which exposes the problem
Reviewers: #frameworks, #kwin, #plasma
Subscribers: plasma-devel
Tags: #plasma, #frameworks
Differential Revision: https://phabricator.kde.org/D10300
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
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
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
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
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
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
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
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
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
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
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
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
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
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