testError expects that the compositor will post a protocol error if the
client tries to create several plasma shell surfaces for the same wayland
surface.
This is a minor regression introduced with the refactor of the
KeyboardInterface. We need to update pressed key status even if there is
no focused surface, otherwise some keys may get stuck in the pressed
state.
This improves the readability of the setFocusedSurface() method in the
KeyboardInterface class. Currently, it's easy to overlook that the
sendEnter() function also sends modifiers.
This change renames methods that are used by the compositor to notify the
seat about input events.
There isn't anything special about the proposed naming scheme, for what
it is worth, it was established in weston. "notify" methods are used to
notify kwaylandserver about something, and "send" methods actually send
relevant events to wayland clients.
PlasmaWindowInterface is a "Server-managed multicasting resources". We
no longer need our wrapper to outlive objects so we can tidy that up.
It's weird to have a method call to an object delete the object, so
memory management is moved to the caller to be consistent.
The protocol spec indicates that the compositor has to accumulate seat
capabilities and post a protocol error if a client requests an input
device and the seat has never had the corresponding capability.
This rewrites the wl_seat protocol implementation to adhere to the new
design principles.
Effectively, we've been supporting wl_seat v7 so the version was also
bumped from 5 to 7.
With this design, a single PointerInterface manages multiple wl_pointer
objects. This makes the API tidier and allows implementing things such as
keyboard grabs more easier.
In addition to that, the PointerInterface doesn't inject its own frame
events anymore. It's up to the compositor to decide when it has to be
sent. However, the PointerInterface may still send a frame event if the
pointer focus changes.
Besides re-writing the pointer interface, this change, unfortunately,
also affects the implementation of pointer-gestures and relative-pointer
protocols because previously they were coupled to individual instances
of PointerInterface.
During a drag the source can disappear at any time. The other client
will be notified, but it may have actions in flight.
Other methods were guarded but not data_offer_finished.
Currently, the compositor is supposed to pass the position of the touch
point to the touchDown() function and in return get its unique global
id. The id can be be passed to subsequent touchMotion() and touchUp().
The compositor is responsible for mapping between libinput slots and
internal touch point ids.
The mapping step is unnecessary and adds in some complexity as the input
code now has to keep the mapping table up to date.
This change makes the touch API more convenient to use by making
relevant functions take touch ids that are assigned by the compositor.
Usually, compositor would use libinput_event_touch_get_seat_slot() to
get touch ids.
It also allows introducing event objects that can be useful later in the
future.
This is a copy of the code from Qt5.15 with some backported patches from
development branch of Qt.
One of the upcoming fixes introduces new API, which is why we can't rely
on distro packaging.
The cmake macro is mostly copied from ECM, but set to rebuild generated
code when the scanner changes.
The following order of events are legal:
Typically order is:
- server announces a new output
- client binds to a new output
- server updates the surface to be on new output
But we can have events occur in the following order:
- server announces a new output
- server updates the surface to be on new output
- client binds to a new output
At which point when we update the surface there is no ID to tell the
client which output the surface is on.
This patch watches for clients binding to output and updates
appropriately.
Be more explicit about the types, prefer passing semantically correct
parents and keep track of the pads from the object rather than relying
on them being initialised properly.
We send modifiers to the active client when they change, and when we
focus an existing client we send the cached state.
For this reason it's important we always update our internal store of
modifiers regardless of whether a surface is currently active.
Unit test is adopted accordingly.
BUG: 429930
The main reason why we have factory methods is that up to some point,
kwayland had its own signal to indicate when globals have to be removed.
Now that all globals add destroy listeners for the wl_display object,
we don't have that signal. Most factory methods are equivalent to doing
new T(display).
Besides adding unnecessary boilerplate code, another reason to get rid
of the factory methods is to reduce the amount of merge conflicts. If
several persons work on implementing wayland protocols at the same time,
sooner or later someone will have to resolve merge conflicts in Display.
libwayland-server allows the wl_display accept client connections on
more than one socket. We currently don't listen on multiple sockets,
but it would be nice if Display supported such operation mode.
And make them public in th keyboard_interface, there's no point in
wrapping this in seat_interface with new approach
See also: plasma/kwayland-server#13
A threshold exists to stop users flooding the server for no reason.
However, there is a usecase for small timeouts.
rsibreak has a "please relax for 20 seconds" interface. Here it makes
perfect sense to know if a user is active in small increments. The plan
is to start a 1s timer and wait for that. Then we wait locally for 20s
without a resume event.
We cannot end a drag after the destroyed() signal for the source data
device is emitted because DataDeviceInterface and its d pointer are gone
by that time.
One of the most disappointing things when writing autotests is dealing
with a race condition where destructor requests are processed after all
globals have been destroyed.
With this change, the Display object will destroy all clients and their
resources before destroying the wl_display object. The good thing about
doing so is that shut down logic becomes simple. We don't have to assume
that wl_resource objects can outlive their wl_global objects, etc. The
bad thing is that it exposed a couple of pre-existing latent bugs in the
data device and the xdg foreign code.
closesplasma/kwayland-server#2
Getting the object associated with the particular wl_resource is not
difficult, but it involves a pretty reasonable amount of boilerplate
code.
This change, introduces a helper function with an intend to reduce the
amount of boilerplate code.
It can be used as resource_cast<const ObjectPrivate *>(resource) or
just simply resource_cast<ObjectPrivate *>(resource).
Every time the icon surface is committed, we need to accumulate the
surface offset. However, this is not easy to do on the compositor side
with the current design.
This change introduces a new class DragAndDropIcon that defines a
surface role as well as accumulates surface offsets on every commit.
This fixes a bug where the dnd icon jumps all of sudden while dragging
an image from Firefox to other applications.
This change rewrites implementation of subsurfaces with qtwaylandscanner
and fixes various smaller issues, such as proper handling of position
updates for subsurfaces in the desync mode and getting rid of QPointer in
the public API.
Parenting both registry and the client connection to the test leads to a
confusing teardown order. Especially as m_connection is explicitly
deleted in cleanup()
Scoping registry to where it's actually used solves that
It is allowed to call surface_attach multiple times with the same
buffer. We want to only connect once.
Found whilst debugging a freeze, going through the list of
BufferInterface connections I had multiple to the same SurfaceInterface.
CCBUG: 428361
Currently, Firefox will stuck in "dnd" mode if you try to drag any of
its tabs. The main reason for that is that kwin doesn't send the
wl_data_source.cancelled event if the pointer button has been released
and there is no target surface or if the data source hasn't been
accepted by anyone.
CCBUG: 427528
During DataDevice migration we moved dataDevicesForSurface away from the
existing template macro due to inheritance reasons at the time.
The SeatInterface::setDragTarget() is used with null surfaces
- Get rid of the KF5 deprecated methods related to keymap,
kwayland-server is not source compatible with kwayland, so we don't
need to keep the deprecated methods
- Move the key repeat, modifiers and keymap handling fully into the
KeyboardInterface.
- Get rid of some of the keyboard related code base from the
seat_interface.
Co-Author: Bhushan Shah <bshah@kde.org>
Some input related code in kwin is mislead by the fact that when the
input region is infinite, SurfaceInterface::input() is going to return
an empty QRegion object.
We cannot really do that because the client could have just set a valid
empty wl_region object to ignore all input events.
This change makes SurfaceInterface assign an actually infinite region
when a NULL input region has been passed to set_input_region().
modifiers request by the input method is supposed to send the raw
modifiers based on the keymap of the keyboard grabbed as result of the
grab_keyboard request. If input method client is not using the keysym
functionality it can decide to not send out the modifiers_map, since it
is already known to compositor as part of keymap event sent by it.
While at it also guard against empty modifiers_map, if this happens
ideally compositor should handle that information based on the keymap
sent out using grab_keyboard function, but since currently, we do not
have the grab_keyboard implemented in here, send out the NoModifier if
that happens.
When touching a surface that doesn't register to wl_touch events, KWin
didn't send frame events (which it does for regular pointer and touch
events), causing severe updating issues with some clients.
Test Plan:
Launch a client that doesn't attach to wl_touch (for instance,
rootston) with WAYLAND_DEBUG=client and watch the logs while touching
its window.
The xdg-output spec omits whether the compositor has to destroy all xdg-
output resources when the associated wl_output global is removed.
This means that no xdg-output resource should be destroyed unless the
client has called the destructor request; otherwise the client may panic
due to protocol errors.
Starting with Qt 5.15.2, it's okay to destroy generated wrapper objects
without destroying associated resources. Destructor requests will be
handled behind the scenes for inert and orphaned resources by code that
is generated by qtwaylandscanner.
BUG: 426293
If we track the commit counts at compositor global, this will fail
horribly for anything other than the first text-input-v3 client, as for
new client the serial count will not be what it expects in the done()
request and it will simply consider events as outdated and will refuse
to accept those events
s_version is used only to initialize a global so there is no point for
storing protocol version in a static member field and use funky syntax
in the cpp file to initialize it. This change also simplifies the code.
If a frame callback resource is destroyed, it will unregister itself
from corresponding lists in current, pending, and cached state.
However, this means that we need to be super duper careful when the
compositor wants to destroy all frame callbacks. We need to make a copy
of a frameCallbacks list; otherwise a call to removeOne() will
invalidate iterators and the compositor may crash.
Currently, that copy is made implicitly. Some people may see that code
and add qAsConst() without realizing the consequences it will lead to.
This change improves the readability of that code by making explicit
copies of frameCallbacks in code that shuts down SurfaceInterface.
This was done mostly because I wanted to get rid of the Resource
dependency in AbstractDataSource so I can make our xwl bridge direct,
but this also fixes up some issues with object lifespan present in the
previous version and keeps all our clipboard code in-line.
When the focusedTextInputSurfaceChanged() signal is emitted, it is
expected that SeatInterface::focusedTextInputSurface() will return
the new focused text input surface.
- Drop the v0 support, it is no longer used by anything
- Adapt the text-input related methods in seat interface to include
versioning, this will be useful for when zwp_text_input_v3 support is
included in kwayland-server
- Refactor SeatInterface to get rid of globalTextInput, it is no longer
needed with the new approach
- Refactor out the ContentHints and ContentPurpose enums in separate
header file which can be shared by zwp_text_input_v2/3 implementation
Co-Author: Bhushan Shah <bshah@kde.org>
One problem with delaying destruction of buffer objects is that the
compositor may create a shadow that references defunct buffers.
One way to fix that issue is to immediately destroy buffers. However,
there is other way to address the issue - keep released buffers alive.
If a buffer is kept alive by the client, then it will most likely be
used again. It also simplifies buffer management.
BUG: 425233
A DataOffer can slightly outlive a DataSource; a client will still be
told it's deleted but could call a method in a race.
DataOfferInterface correctly checks for source being still valid, but
nothing updates it when it gets deleted.
BUG: 396308
If the underlying wl_surface object has been removed, the input panel
surface will be still alive.
Unfortunately, in order to make the test pass, the input panel surface
interface must have a destructor request.
So, the code that tests the destruction of an input panel surface had
been removed.
Since the screencast protocol is unstable, the ScreencastInterface class
and the ScreencastStreamInterface class must carry version info in their
class names.
In v1 to v3 of textinput protocol, updates for the text input state
needs to be updated explcitly using commit or update state request, so
send out this information to compositor, which can use it to update the
input method state.
We need to convert the content hint and content purpose to the
protocol values before passing it to the input method since text-input
v0, v2 and v3 have a different values for some of enums. We need to do
manual translation.
Generated code typically cleans up resource objects when the client
calls the relevant destructor.
In multi-cast mode our wrapper can be deleted at any time, whilst a
client resource exists any existing resources that have a pending
message will then crash the compositor.
Deleting resources ahead of time also resolves this. calls to this
resource will no-op. The zxdg_output_v1::destroy_func will then be
called to delete the Resource object.
If a client attempts to create an input panel surface for a wl_surface
that already has a role assigned, we must post a protocol error or else
the behavior of the input panel surface will be undefined.
Posting an error of 0 is not really correct, but on the other hand the
spec has no any error enums.
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.
We have a situation where some clients drop their old offer before
creating a new one. This means klipper tries to fill in the empty
clipboard at the same time the client posts its new real contents.
This adds in a flag (via a hidden mimetype) that klipper is trying to
replace a null clipboard. If this flag is set and our clipboard is not
null because the client has updated it in the meantime we ignore the
klipper update.
It's a workaround, rather than an ideal fix at a data level, but it
solves the problem in the interim.
CCBUG: 424855
SeatInterface cleans up when a data source goes away. However the
cleanup also makes use of metaobjects so needs to run before the leaf
class destructor is run.
All other AbstractDataSource objects emit the unbound signal, which
SeatInterface also connects to do a earlier cleanup. Otherwise we get a
crash if a data control source replaces itself.
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
It can be especially useful if the compositor wants to ensure that all
globals have been created before starting to accept client connections.
Unfortunately, start() and terminate() stuff doesn't align well with it,
so the terminate() method was dropped to ensure that Display always
returns the same wl_display object.
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 source can have a different lifespan to the offer being made.
If a source is removed and we get a drag actions changed before the
offer is cancelled we don't want to crash.
Couldn't reproduce locally, but the trace was good.
BUG: 423127
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.
The new methods can be useful when one wants to get the size of the
buffer along some specific dimension, e.g. width or height.
Of course, size() could be used for this purpose, but with the new
helper methods, one has to type less.
The current xdg-shell wrappers don't match existing abstractions in the
xdg-shell protocol well, which makes it more difficult to refactor code
that is responsible for managing configure events and geometry in kwin.
Given that the xdg_decoration and the xdg_shell protocols are tightly
coupled together, I had to rewrite our wrappers for the xdg_decoration
protocol as well.