Commit graph

1066 commits

Author SHA1 Message Date
Vlad Zahorodnii
8f3993c91b Drop workaround for QTBUG-52092
I've been using kwaylandserver without this workaround for a while and
haven't experienced any issues. Also, there were some sub-surface fixes
in QtWayland.
2021-04-08 10:17:01 +03:00
Vlad Zahorodnii
8b7136f70d Send only current wl_output mode
Non-current output modes were deprecated due to various reasons, e.g.
it's not possible to remove some nodes; two modes can have the same
resolution and the refresh rate but different flags, but wl_output.mode
fails to communicate that properly; the usefulness of non-current modes
is questionable. For more details, please refer to [1].

[1] https://gitlab.freedesktop.org/wayland/wayland/-/issues/92
2021-04-07 11:04:26 +00:00
Vlad Zahorodnii
f30bd9e341 Rework OutputInterface following new design principles 2021-04-07 11:04:26 +00:00
Vlad Zahorodnii
f16320e693 Don't use nested private class in ClientConnection
Nested private classes are highly discouraged in KWaylandServer due to
their flaws, e.g. it's very easy to forget to put Q_DECL_HIDDEN, etc.
2021-04-06 06:45:39 +00:00
Vlad Zahorodnii
35d601bb23 Don't use nested private class in FilteredDisplay
The usage of nested private classes is highly discouraged in
kwaylandserver due to various reasons, e.g. it's easy to forget to put
Q_DECL_HIDDEN, etc.
2021-04-05 11:35:06 +03:00
Vlad Zahorodnii
f119c9470d Fix some coding style issues in FilteredDisplay 2021-04-05 11:33:54 +03:00
Vlad Zahorodnii
ba4f796e24 Remove some unused includes 2021-04-05 11:20:24 +03:00
Vlad Zahorodnii
7058710eca Use code generated by qtwaylandscanner to send xdg-exported handle
This was overlooked during the port to the new approach.
2021-04-02 10:04:49 +03:00
Vlad Zahorodnii
18815f88fb Drop SurfaceInterface::trackedDamage()
There is no need for both kwin and kwaylandserver track damage.
2021-03-31 13:33:29 +00:00
Vlad Zahorodnii
75a6fd29fd Introduce SurfaceInterface::childSubSurfacesChanged
Currently, the SurfaceInterface class has a signal that is emitted
whenever any sub-surfaces in its sub-tree changes in a way that requires
a repaint. It is emitted when a sub-surface is resized, moved, or
damaged, etc. There is no way for the compositor to track changes in the
stacking order of sub-surfaces efficiently.

This change replaces the subTreeChanged signal with a less noisy signal
that's emitted whenever the list of direct child sub-surfaces changes.
2021-03-31 13:24:58 +00:00
Vlad Zahorodnii
daadaa70de Send current primary selection after introducing focused surface
Toolkits such as GTK don't like that kwin sends the current primary
selection before the wl_keyboard.enter event.
2021-03-30 06:03:39 +00:00
Aleix Pol
4a357d503e Fix typo 2021-03-26 15:32:18 +01:00
Vlad Zahorodnii
755004acd0 Remove redundant check
Given that both pointers are not null and the size is a positive
integer, qstrncpy() can never return null.
2021-03-26 13:41:04 +02:00
Vlad Zahorodnii
c56712776a Fix management of keymap files
This is a regression that was introduced with the port to the new
approach.
2021-03-26 13:17:13 +02:00
Vlad Zahorodnii
83087817f4 Forward keyboard events via seat
This is needed for keyboard grabs. If the seat is notified about a
keyboard event, it will need to forward the event to the grab object,
which in its turn will decide what should happen to the event.
2021-03-26 09:08:12 +00:00
Vlad Zahorodnii
70daa07f27 Destroy output device globals with a delay
When hot plugging outputs, we may hit the wl_global race condition.

We need to delay the destruction of output device globals to prevent
hitting that race condition.
2021-03-26 07:50:32 +00:00
Vlad Zahorodnii
b27150387c Fix -Wunused-variable 2021-03-25 17:29:51 +02:00
David Edmundson
1fec9ed4ae Add API to remove globals without immediate destruction
Destroying a global leads to a race on the client. If a client binds
at just the wrong moment they will use an invalid ID and cause a
protocol error. The current best thing to do is to announce the removal
then remove the global (and thus the ID) only after a delay. Non-ideal,
but better than nothing.

Pragmatically this affects only:
Blur/Contrast/Slide/Output/OutputDevice

See https://gitlab.freedesktop.org/wayland/wayland/issues/10 for more.
2021-03-25 12:31:03 +00:00
Vlad Zahorodnii
71d4b463f0 autotests: Drop testPlasmaWindowModel
KWaylandServer doesn't implement the KWayland::Client::PlasmaWindowModel
class so there is no point for carrying this test.
2021-03-25 08:19:19 +00:00
Vlad Zahorodnii
0b688f6b6e Improve code readability in xdg-foreign wrapper
This moves out code that links/unlinks imported toplevels and child
surfaces in functions to improve code readability.
2021-03-25 07:53:36 +00:00
Vlad Zahorodnii
060940e426 Remove unused method in XdgImporterV2Interface 2021-03-25 07:53:36 +00:00
Vlad Zahorodnii
77a065e8de Remove redundant anonymous namespace
static functions already have translation unit internal linkage.
2021-03-24 15:08:31 +02:00
Vlad Zahorodnii
06cfe1a24a Fix a typo
This probably needs to be currentPrimarySelection.
2021-03-23 21:10:07 +02:00
Vlad Zahorodnii
a50f84a868 Merge notifyPointerPress() and notifyPointerRelease()
This brings the API of the SeatInterface class and the PointerInterface
class closer the corresponding Wayland API.
2021-03-23 11:20:03 +02:00
Vlad Zahorodnii
2af2ba6d4c Use common doxygen comment terminator style
In plasma code, it's more common to see `/** ... */` doxygen comments
rather than `/** ... **/`.

This change fixes up doxygen comment terminators to prevent inconsistency
issues.
2021-03-23 08:14:02 +00:00
Vlad Zahorodnii
c94787bbf4 Move DESIGN.md to toplevel directory
This makes DESIGN.md more noticeable.
2021-03-22 21:30:43 +02:00
Vlad Zahorodnii
a3ab80677c Fix handling of the case where specified surface can't imported
An xdg_imported resource must be created no matter whether there is an
exported surface with the specified handle.

This change fixes handling of that case in kwaylandserver by introducing
a dummy imported object.

If there is no exported surface with the given handle, the compositor
should create an xdg_imported resource and immediately send the
destroyed event.

A dummy imported object is needed because generated code sets resource
implementation; otherwise we would set an implementation without any
user data to mark the resource as inert.
2021-03-22 17:46:12 +00:00
Vlad Zahorodnii
d4901d16fa Call XdgImportedV2Interface::send_destroyed() that takes no resource
XdgImportedV2Interface already knows what the associated resource is, so
we can call send_destroyed() method that takes no resource to let auto
generated code figure out what resource must be used. It simplifies code.
2021-03-22 19:42:05 +02:00
Vlad Zahorodnii
e4b9f9761f Simplify emission of XdgForeignInterface::transientChanged signal
We can emit the transientChanged signal directly on the foreign object.
2021-03-22 17:15:02 +00:00
Vlad Zahorodnii
9445bfb6d8 Simplify QHash lookups
QHash provides a convenience helper to lookup a value, use it. It makes
the code simpler.
2021-03-22 17:15:02 +00:00
Vlad Zahorodnii
2f102e7544 Fix various minor coding style issues
This fixes various coding style issues, e.g. wrong variable name
capitalization, wrong brace placement, etc.
2021-03-22 17:15:02 +00:00
Vlad Zahorodnii
e5bde36e96 Get rid of unnecessary private classes in xdg-foreign wrappers
There's no point for using the d-pointer pattern because the importer
and the exporter classes are private already, they are not exposed in
public api.
2021-03-22 17:15:02 +00:00
Vlad Zahorodnii
5b060bcab0 Remove since version tag in OutputInterface
kwaylandserver is an unstable library, this renders since version tags
highly unreliable.
2021-03-22 18:58:48 +02:00
Vlad Zahorodnii
ca69d9e62a Remove noop destructors 2021-03-22 17:42:28 +02:00
Vlad Zahorodnii
0461b7fe27 autotests: Fix testXdgForeign
Currently, testXdgForeign fails because imported and exported resources
are destroyed immediately from destructor request handlers and code that
performs cleanup in the exported-imported mapping tables accesses the
dangling pointers.

Previously, it wasn't an issue because the destruction of exported and
imported resources was delayed using QObject::deleteLater().
2021-03-22 15:31:41 +00:00
Kevin Ottens
d92fa7f140 Add the activity management protocol server implementation 2021-03-22 11:28:57 +00:00
Vlad Zahorodnii
b822c1e63a Simplify handling of inert input method context
If the input method context object becomes inert, just delete it.
2021-03-22 10:16:34 +00:00
Weng Xuetian
823a34a10d Add explicit done to OutputInterface and deprecate zxdg_output_v1.done if version 3 is used.
In zxdg_output_v1 version 3, done is deprecated and should be replaced
with wl_output.done. This makes automatically send done upon change not
suitable for the usage. OutputInterface user should now use done()
explicitly to send the update.

CCBUG: 433224
2021-03-19 10:39:07 -07:00
Usarin Heininga
2414deb86b Expose missing client UUids in plasma windowManagementInterface
StackingOrder.
2021-03-19 13:54:50 +00:00
Vlad Zahorodnii
61a6ee4b07 Rename some methods in xdg-foreign classes 2021-03-17 10:46:11 +02:00
Vlad Zahorodnii
1f83657c65 Remove unused signals 2021-03-17 10:46:02 +02:00
Vlad Zahorodnii
8fc6cb85a6 Remove redundant class forward declarations 2021-03-17 10:43:58 +02:00
Vlad Zahorodnii
9763aec020 Send an icon only if there is one
Currently, plasma window model test fails because the null icon is
received after executing the main body of the test.

    FAIL!  : PlasmaWindowModelTest::testVirtualDesktops() '!dataChangedSpy.wait(100)' returned FALSE. ()
       Loc: [/data/projects/src/kwayland-server/autotests/client/test_plasma_window_model.cpp(583)]

We can fix the test by waiting for the iconChanged signal to be emitted,
but we will need to wait in all tests too. Furthermore, it doesn't make a
lot of sense to wait for an icon that was never set.

This change makes the compositor send an icon only if there is one.

It's a behavioral change, but it shouldn't regress anything because kwin
always sets icons via the plasma window management protocol even for apps
that have no valid app id.

It also makes the api of the PlasmaWindowInterface class more intuitive.
2021-03-16 15:43:59 +02:00
Vlad Zahorodnii
f321882177 autotests: Fix testWindowmanagement
Currently, testIcon fails because the actual and the expected pixmaps
have mismatching formats.

The root cause is that images with an alpha channel will loose the alpha
channel if they are converted to QPixmap using QPixmap::fromImage().

The >> stream operator for the QPixmap class will deserialize pixel data
in a temporary QImage and then use QPixmap::fromImage() to get a pixmap
object.

The >> stream operator for the QIcon class will delegate the task of
reading the icon from a QDataStream to QPixmapIconEngine, which uses the
>> stream operator under the hood to deserialize icon data.

In order to fix testIcon, this change constructs a dummy icon from a
pixmap object returned by QPixmap::fromImage().
2021-03-16 15:28:46 +02:00
Vlad Zahorodnii
bdb138bdcd Remove @since version tags
Currently, we have a mix of Frameworks versions and Plasma versions in
@since tags, which leads to some confusion. Since this is an unstable
library, one cannot rely on since version tags, we are free to add,
change, and remove apis to serve best to kwin requirements. Thus, we can
simply remove all since version tags to fix mixing up different product
versions.
2021-03-16 10:08:21 +02:00
Vlad Zahorodnii
a6ef2cc9e4 Remove pointer asserts in gesture related functions
These asserts were overlooked in 59ae762300.
2021-03-15 18:53:24 +02:00
Vlad Zahorodnii
59ae762300 Replace input device asserts with if checks
KWin may call pointer or touch-related function even if the
corresponding capabilities are missing.
2021-03-15 16:41:14 +00:00
Vlad Zahorodnii
62c8a3829c Don't print a warning if the compositor sets focused surface without wl_keyboard capability
KWin may set focused keyboard surface even if there is no wl_keyboard
capability. :/
2021-03-15 16:41:14 +00:00
Vlad Zahorodnii
43a56a6ce8 Explicitly destroy inert tablet resources
This makes handling of inert resources easier.
2021-03-15 16:34:46 +00:00
Vlad Zahorodnii
16db81b5cc Make RegionInterface private
If a Wayland protocol deals with regions, they will be exposed as
QRegion objects in public API. Therefore, it makes sense to make
RegionInterface private as it's an implementation detail and it's
not intended to be used in public api.

The corresponding test was dropped because the CompositorInterface
no longer emits a signal to indicate that a wl_region has been created.
It should be also noted that wl_region stuff is already tested via
other means, e.g. surface damage, etc.
2021-03-15 16:28:30 +00:00
Vlad Zahorodnii
a60ed431f1 Fix testError
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.
2021-03-15 16:27:41 +00:00
Vlad Zahorodnii
8c32edcd12 Implement wl_keyboard.release
The destructor request was added in version 3. Currently, we support v7.
2021-03-15 12:34:35 +02:00
Vlad Zahorodnii
9089fc5357 Update pressed keys even if there is no focused 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.
2021-03-15 10:30:34 +00:00
Vlad Zahorodnii
14ccbb8b94 Remove redundant nullptr check
We always check if focusedSurface is not nullptr before calling
sendModifiers().
2021-03-15 10:30:34 +00:00
Vlad Zahorodnii
9526b1c3fe Explicitly send keyboard modifiers
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.
2021-03-15 10:30:34 +00:00
Vlad Zahorodnii
4918519eec Simplify KeyboardInterface
KeyboardInterface no longer has a concept of a focused child surface, so
remove relevant dead code.
2021-03-15 10:30:34 +00:00
Xaver Hugl
264bb6c53d Consider the tool type in TabletSeatV2Interface::toolByHardwareSerial 2021-03-14 23:53:19 +01:00
Vlad Zahorodnii
4e16b10e82 Rename some SeatInterface methods following consistent naming scheme
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.
2021-03-12 10:19:03 +00:00
Adrien Faveraux
d7a1067a7a move output management to the new approach 2021-03-12 11:06:35 +01:00
Aleix Pol
a0419faecb Include implementation of declared method 2021-03-11 13:49:38 +01:00
David Edmundson
1a0020b18f Move PlasmaWindowInterface lifespan management to the caller
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.
2021-03-11 12:01:52 +00:00
Adrien Faveraux
54d3d7e68f move output device to the news approach 2021-03-11 11:12:25 +01:00
Vlad Zahorodnii
d853b08659 Post a protocol error if missing seat capability
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.
2021-03-10 22:19:00 +02:00
Vlad Zahorodnii
1d7bc7128d Port SeatInterface to the new approach
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.
2021-03-10 22:18:59 +02:00
Adrien Faveraux
09126dab41 migrate ifndef to pragma once 2021-03-10 20:16:46 +00:00
Vlad Zahorodnii
6289875418 Remove SeatInterface::keyboardCreated signal
It's pointless with the new design.
2021-03-10 17:33:51 +02:00
Vlad Zahorodnii
c08adf1388 Port wl_touch wrapper to the new approach
With the new design, a single TouchInterface manages multiple wl_touch
objects. This allows implementing things such as touch grabs, etc.
2021-03-10 16:06:24 +02:00
Vlad Zahorodnii
6748a31cd1 Rename methods to send press and release events in PointerInterface
This makes the naming scheme consistent. Most methods don't use past
tense to describe what we send, i.e. sendMotion instead of sendMoved.
2021-03-10 14:05:20 +00:00
Vlad Zahorodnii
a9d480ec0d Minor style fixes 2021-03-10 14:05:20 +00:00
Vlad Zahorodnii
178c5d0595 Rewrite wl_pointer implementation with new approach
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.
2021-03-10 14:05:20 +00:00
Vlad Zahorodnii
eb123a40b7 Introduce SurfaceInterface::mapToChild()
The new method provides a convenient way to map a point from the
parent's coordinate system to a child's coordinate system.
2021-03-10 14:05:20 +00:00
Aleix Pol
5a968c89fe Still tell about received pings if they timed out
There's a good chance the user still cares about it. They're free to
ignore it if they want.
2021-03-01 13:09:59 +00:00
David Edmundson
09a45da505 Port all connects
This is mostly all automatic from clazy, though it got confused by a few
namespace issues.
2021-02-25 13:48:11 +00:00
Vlad Zahorodnii
13e03bde1d Prevent sending enter events to already focused surfaces
If the surface already has keyboard focus, do nothing.
2021-02-17 12:18:54 +00:00
Vlad Zahorodnii
377385fa6e Send enter and modifiers events if wl_keyboard is bound by focused client
We need to send out these events; otherwise the client may have
incorrect state for the new wl_keyboard object.
2021-02-17 12:18:21 +00:00
Vlad Zahorodnii
13fa83c7a6 Make some getters in ClientConnection const 2021-02-17 12:18:21 +00:00
Vlad Zahorodnii
3c0b35cd81 Remove unimplemented keyboardsForSurface() method 2021-02-17 13:23:54 +02:00
David Edmundson
6202dbc0a8 Guard against DataSource being deleted during transfer
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.
2021-02-16 10:47:28 +00:00
Vlad Zahorodnii
64744103dc Simplify SeatInterface::touchDown() api
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.
2021-02-15 20:03:11 +02:00
Vlad Zahorodnii
b0a20b2815 Prevent setting invalid buffer transform and scale
At the moment, it is possible to crash the compositor if some client
sets a buffer scale less than 1.
2021-02-11 10:10:12 +02:00
David Edmundson
4047053829 Initialise variable 2021-02-02 19:04:25 +00:00
Vlad Zahorodnii
ae5a31acd1 Introduce SurfaceInterface::hasFrameCallbacks()
The new method can be used to check if the surface has a pending frame
callback.

CCBUG: 428499
2021-02-02 14:00:34 +00:00
Nicolas Fella
ca6fa1cbf0 Use versionless Qt cmake target
This makes it easier to build against both Qt5 and Qt6

GIT_SILENT
2021-01-30 17:24:42 +01:00
Vlad Zahorodnii
db6647a8a2 Simplify handling of inert sub-surfaces
With the local copy of qtwaylandscanner, it's possible now to simplify
handling of inert sub-surfaces.
2021-01-29 13:23:02 +00:00
Vlad Zahorodnii
16bf88b67c Print warning messages in KWAYLAND_SERVER logging category
This makes it easier to analyze logs.
2021-01-26 09:22:39 +02:00
David Edmundson
fe8a0a28b5 Import local copy of qtwaylandscanner
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.
2021-01-26 06:53:59 +00:00
Vlad Zahorodnii
46604a3ca2 xdg-shell: Provide more helpful description for invalid window geometry error 2021-01-21 15:24:45 +00:00
David Edmundson
fbe8aff439 Send SurfaceInterface::enter events after clients bind to outputs
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.
2021-01-12 11:10:50 +00:00
Aleix Pol
6566c91e39 tablet_v2: Readability
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.
2021-01-06 02:33:12 +01:00
Aleix Pol
e57f925dfc tablet: Address how he clean resources up 2021-01-06 02:23:13 +01:00
Aleix Pol
1d904daf65 tablet_v2: Further implements missing components
Namely TabletPadV2Interface, TabletPadRingV2Interface,
TabletPadStripV2Interface and TabletPadGroupV2Interface were entirely
missing.
2021-01-06 02:23:13 +01:00
Aleix Pol
c80086ceda tablet_v2: consistency
Add an m_removed attribute to all elements that can send a removed
event.
Never advertise an object that has been marked as removed already.
2021-01-06 02:21:54 +01:00
Carson Black
4fe4a50aa4 xdgshell: wrap v3 of xdgshell protocol 2021-01-05 21:25:38 +00:00
Aleix Pol
9641aa42ec tablet: small cleanups
Add missing &
Remove unnecessary namespace
Consistant m_ prefix
2020-12-16 02:44:17 +01:00
Andrey Butirsky
03fc51ef2f keyboard_interface: Always update modifiers cache
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
2020-12-14 17:09:38 +00:00
Vlad Zahorodnii
09e079b78f Remove factory methods in Display
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.
2020-12-14 13:04:59 +00:00
Xaver Hugl
b5434e51e8 add setCurrentMode(size,refreshRate) 2020-12-12 20:22:40 +00:00
Vlad Zahorodnii
f1f36f3223 Remove COPYING.LIB
LICENSES directory contains full description of every license that is
used in kwayland-server.
2020-12-09 14:36:49 +02:00
Vlad Zahorodnii
329abecabb autotests: Port remaining tests to SPDX license markers 2020-12-09 14:36:18 +02:00
Vlad Zahorodnii
1247a53eba Allow accepting client connections on multiple sockets
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.
2020-12-09 07:20:42 +00:00
Adrien Faveraux
e12bfaa53c Migrate Fake Input into the new approach 2020-12-07 07:52:54 +00:00
Adrien Faveraux
2780d0557a Move slide interface to the new approach 2020-12-01 12:03:48 +01:00
Bhushan Shah
bfc174ea58 keyboard_interface: remove wrapper methods from the seat_interface
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
2020-11-19 06:05:06 +00:00
Aleix Pol
0dffc569ea Notify subsurfaces about output changes
Otherwise they wouldn't notice and wouldn't update to the settings of
the new output, like the new output's scaling.
2020-11-17 14:55:07 +00:00
David Edmundson
f91271b29e Allow small timeout intervals in IdleInterface
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.
2020-11-17 13:10:22 +00:00
David Edmundson
02dd1d45a5 Port PlasmaShellSurface to the new approach
This gets rid of some boiler plate and simplifies some code.
2020-11-16 10:04:40 +00:00
Vlad Zahorodnii
0613e8f4c9 Safely end drag if the source data device gets destroyed
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.
2020-11-11 16:14:45 +02:00
Vlad Zahorodnii
34982850e2 Destroy all clients before destroying wl_display
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.

closes plasma/kwayland-server#2
2020-11-11 09:26:57 +02:00
Vlad Zahorodnii
ed83cea823 Store drag-and-drop focus resource using QPointer
We need to clean up the target data device if it has been destroyed in
the middle of a drag and drop. Weston does a similar thing.

BUG: 425793
2020-11-10 23:54:56 +02:00
Aleix Pol
22bf1087a1 Remove unnecessary SKIP_AUTOMOC call
ecm_add_qtwayland_server_protocol() is already doing this.
2020-11-09 11:06:43 +00:00
Vlad Zahorodnii
794e89c3f8 Get rid of private nested classes in tablet interfaces
With the new design, no private nested classes should be used.
2020-11-06 10:20:38 +00:00
Vlad Zahorodnii
d456214ecc Fix license headers for tablet v2 interfaces
We use SPDX license markers in kwayland-server.
2020-11-05 09:29:05 +02:00
Vlad Zahorodnii
fbda5f9d73 Remove unused includes 2020-11-05 09:26:01 +02:00
Vlad Zahorodnii
0a9351039e Rename tablet interfaces according to the current naming conventions
Tablet interface classes must have "V2" in their names because the
corresponding protocol is still unstable.
2020-11-05 07:09:20 +00:00
Vlad Zahorodnii
426e41f500 Check for subsurface loops
If subsurfaces form a loop, kwin will get stuck in an infinite
recursion while it constructs a window pixmap tree.
2020-11-04 23:41:44 +02:00
Vlad Zahorodnii
0ed0066d74 Port pointer-constraints-v1 to the new design 2020-11-04 06:19:13 +00:00
Vlad Zahorodnii
d0c93b5bc5 Post invalid_positioner error to the right resource
The invalid_positioner error is defined for the xdg_wm_base interface,
not xdg_surface.
2020-11-04 06:17:02 +00:00
Vlad Zahorodnii
9f83741621 Introduce resource_cast<> helper function
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).
2020-11-04 08:15:31 +02:00
Vlad Zahorodnii
1c412b0f16 Introduce DragAndDropIcon
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.
2020-11-03 19:53:12 +00:00
Vlad Zahorodnii
94e3c5a21a Port pointer-gestures-v1 interface to the new design 2020-11-03 19:49:57 +02:00
Vlad Zahorodnii
a7f7a5fb17 Port relative-pointer-v1 interface to the new design 2020-11-03 19:49:54 +02:00
Aleix Pol
9bf4b6b624 Remove double lookups 2020-11-02 16:45:42 +01:00
Vlad Zahorodnii
6c113e1cef Rewrite subsurface wrappers following the new design principles
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.
2020-11-02 08:26:57 +02:00
Vlad Zahorodnii
17cda4bc9b Introduce SurfaceRole name property
This can be useful for protocol error messages.
2020-10-31 18:10:49 +02:00
David Edmundson
071dd60ab2 [autotests] Keep registry on the stack
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
2020-10-30 16:12:40 +00:00
Vlad Zahorodnii
454265f4c5 Add missing context object 2020-10-30 17:17:41 +02:00
Vlad Zahorodnii
3a72048547 autotests: Hopefully fix all ASAN issues in DataControlInterfaceTest
In general, the destructor is not needed since cleanup() destroys all
client and server resources.
2020-10-30 13:49:10 +00:00
David Edmundson
a8883c35a5 Don't use Qt::UniqueConnection on a lambda
It won't detect properly, instead the same code is moved into a member
function.
2020-10-29 12:49:36 +00:00
Vlad Zahorodnii
74c1b0f336 Store dnd icon surface in a QPointer
If the drag-and-drop icon has been destroyed, return a nullptr rather
than a dangling pointer.

BUG: 428399
2020-10-29 09:05:06 +02:00
David Edmundson
d5ca50deb3 Only connect to BufferInterface::aboutToBeDestroyed once
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
2020-10-28 18:16:46 +00:00
Vlad Zahorodnii
f6e98a34b2 Send a cancelled() event if the dnd data source is not accepted
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
2020-10-28 17:42:32 +00:00
Vlad Zahorodnii
decfb64ada autotests: Fix TestDragAndDrop
Currently, most of tests in TestDragAndDrop should fail because they
don't specify accepted mime type.
2020-10-28 17:42:32 +00:00
Vlad Zahorodnii
a6e78f9340 Check for protocol errors before converting dnd actions
It kind of makes more sense to check for errors and then start doing
the actual work.
2020-10-28 15:37:29 +02:00
David Edmundson
3c7715ce30 Fix crash on drag and drop from xwayland to wayland clients
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
2020-10-26 18:01:12 +00:00
Aleix Pol
571b7e86a8 OutputDevice: only report the scale when scaleFChanged is emitted
scaleChanged and scaleFChanged are emitted at the same time, there's no
reason to send them twice.
2020-10-21 20:47:36 +02:00
Laurent Montel
026923db94 Remove not implemented method 2020-10-21 08:14:39 +02:00
Adrien Faveraux
68e0604ad7 move keyboard to the new approach and refactor the keyboard_interface
- 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>
2020-10-20 20:09:51 +05:30
Vlad Zahorodnii
0561c17552 Simplify how infinite input regions are handled
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().
2020-10-19 08:48:52 +03:00
Bhushan Shah
0117122679 input-method-v1: Fix bug regarding the modifier handling
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.
2020-10-16 17:05:42 +05:30
Sebastian Krzyszkowiak
4da1822100 Send wl_pointer.frame when emulating pointer events out of touch ones
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.
2020-10-15 00:53:56 +02:00
Bhushan Shah
e84c1dcac2 input-method-v1: improve the test coverage of the class 2020-10-14 09:34:00 +05:30
Bhushan Shah
65111fcbbd autotests: convert file to use SPDX for license and add my name 2020-10-14 09:34:00 +05:30
Bhushan Shah
afef22a57c input-method-v1: remove unused method InputPanelSurfaceV1Interface::id
This was simply unused
2020-10-14 09:34:00 +05:30
Vlad Zahorodnii
780dba4966 Properly handle destruction of XdgOutputV1Interface
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
2020-10-13 08:58:04 +03:00
Aleix Pol
489fc93fcf keystates: use the qtwaylandscanner instead of having the boilerplate 2020-10-09 13:17:30 +00:00
Bhushan Shah
c9c05c3899 input-method-v2: pass the reason state was updated to compositor
This removes the signals the requestReset and stateCommitted and
replaces it with single stateUpdated signal.
2020-10-08 17:50:46 +05:30
Bhushan Shah
30a5cc766c text-input-v3: track commit counts per resource
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
2020-10-07 11:38:46 +05:30
Vlad Zahorodnii
e3e05d291a Use global static variables to store protocol version
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.
2020-10-02 16:47:19 +00:00
Vlad Zahorodnii
430aa08714 Improve readability of code that destroys frame callback resources
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.
2020-10-02 09:07:15 +03:00
David Edmundson
096deea9ec Port DataDevice to the new inheritance approach
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.
2020-10-01 14:49:33 +00:00