Commit graph

855 commits

Author SHA1 Message Date
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
Bhushan Shah
85d6888504 autotests: fix minor compile time warnings 2020-10-01 12:17:42 +05:30
Vlad Zahorodnii
9707e7c443 Hopefully fix build on FreeBSD 2020-09-29 14:11:32 +03:00
Bhushan Shah
48535b8bc1 server: implement the text-input-unstable-v3
This commit implements the zwp_text_input_v3 in kwayland-server, part of
code is inspired based on the initial patch from Roman at D16735.
2020-09-29 16:16:28 +05:30
adrien faveraux
af16210c95 Migrate Window Management to new approach 2020-09-28 11:40:51 +00:00
Vlad Zahorodnii
feeafa93ed Set focused text input surface before emitting focusedTextInputSurfaceChanged()
When the focusedTextInputSurfaceChanged() signal is emitted, it is
expected that SeatInterface::focusedTextInputSurface() will return
the new focused text input surface.
2020-09-23 13:47:02 +03:00
Bhushan Shah
cff380962c autotests: rename file to reflect that it tests only TextInputV2 now 2020-09-23 08:59:59 +00:00
Adrien Faveraux
52d3e054f0 Migrate zwp_text_input_v2 to new approach
- 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>
2020-09-23 08:59:59 +00:00
Aleix Pol
d7ff3703bc Do not create a temporary QRegion unnecessarily
Just modify the one we are updating in one go
2020-09-23 04:20:17 +02:00
Vlad Zahorodnii
260d6e7a22 Keep unreferenced buffers around
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
2020-09-21 13:58:37 +00:00
Vlad Zahorodnii
e727dc2fa9 Untangle SurfaceInterface and BufferInterface
A wl_buffer object can be bound to multiple surfaces or none at all. So
the BufferInterface::surface() property makes very little sense.
2020-09-21 13:58:37 +00:00
David Edmundson
0b3cca4ae0 [DataOffer] Avoid calls on null DataSource
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
2020-09-21 11:02:58 +00:00
Vlad Zahorodnii
456106d749 autotests: Fix ASAN issues in TestWaylandSurface::testStaticAccessor
We need to store surface ids before destroying the corresponding
surfaces in order to avoid heap-use-after-free errors.
2020-09-11 14:01:55 +03:00
Vlad Zahorodnii
4ef47641ed autotests: Fix TestInputMethodInterface
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.
2020-09-11 11:34:30 +03:00
Vlad Zahorodnii
f8b9ea5680 Rename screencast wrappers according to unstable protocol naming conventions
Since the screencast protocol is unstable, the ScreencastInterface class
and the ScreencastStreamInterface class must carry version info in their
class names.
2020-09-05 14:45:43 +03:00
Vlad Zahorodnii
c3b9d76d33 Use OutputInterface instead of raw wl_resource objects
Typically, we don't expose wl_output objects as wl_resource objects in
public API. Instead, we use the OutputInterface class for that purpose.
2020-09-04 08:48:30 +00:00
Vlad Zahorodnii
77b7635593 Remove unused things in screencast_interface.h 2020-09-04 06:00:44 +00:00
Vlad Zahorodnii
f8dd1c615b Implement layer-shell v1 protocol 2020-09-03 13:42:36 +03:00
Vlad Zahorodnii
861ea96244 Fix remaining usages of REQUIRED_QT_VERSION and KF5_DEP_VERSION
REQUIRED_QT_VERSION and KF5_DEP_VERSION trace their origin back to KF5.
But in Plasma, we use QT_MIN_VERSION and KF5_MIN_VERSION instead.
2020-09-03 09:19:29 +00:00
Bhushan Shah
8ab656541b textinput: introduce a signal for when the state should be committed
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.
2020-09-03 09:08:02 +00:00
Bhushan Shah
03f5339302 input-method: make sendContentType take the TextInputInterface enums
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.
2020-09-03 09:08:02 +00:00
David Edmundson
63d2ab4ee6 Link Wayland::Server as an external dependency
Raw wl_ objects are used throughout the public headers repeatedly.

Exporting the linked library helps clients (kwin) build cleanly.
2020-09-02 17:13:11 +01:00
Vlad Zahorodnii
aebae46fe6 Remove redundant wayland-server include 2020-09-02 16:30:55 +03:00
Vlad Zahorodnii
9b15f97326 Switch to upstream version of FindWaylandProtocols
FindWaylandProtocols has been upstreamed to ECM.
2020-08-27 14:02:37 +00:00
David Edmundson
bef0f305cf Delete resources in XdgOutput teardown
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.
2020-08-25 13:45:42 +00:00
Vlad Zahorodnii
9b4e2dbdf8 xdg-shell: Add support for v2 2020-08-23 15:11:57 +03:00
Vlad Zahorodnii
7f7a46563b Post an error if the client attempts to create input panel surface for surface that already has role
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.
2020-08-21 10:54:21 +03:00
David Edmundson
11524da289 Port XdgOutput to the new approach 2020-08-20 11:41:14 +00:00
Vlad Zahorodnii
bda8665389 Remove unused forward declarations 2020-08-19 22:25:13 +03:00
Vlad Zahorodnii
a930e59fcf Revert "Don't flush in SurfaceInterface::frameRendered()"
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.
2020-08-18 13:18:58 +03:00
Vlad Zahorodnii
3cf004b68e Don't flush in SurfaceInterface::frameRendered()
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.
2020-08-18 07:28:03 +00:00