Commit graph

965 commits

Author SHA1 Message Date
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
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
Aleix Pol
5efebc3a38 Provide an initial implementation for input-method-unstable-v1
Makes it possible to implement the protocol in your favourite
compositor.
2020-08-17 20:09:21 +02:00
David Edmundson
84337d25f9 Add a workaround to prevent klipper racing with clipboard updates
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
2020-08-14 15:01:32 +00:00
David Edmundson
89433eccec [autotests] Cleanup DataControlInterface test
The tests were not fully self-encapsulating and leaky.
2020-08-14 15:01:32 +00:00
Vlad Zahorodnii
89debdef60 Undo pointer-gestures v2 changes
The release request was introduced in v2, which we currently don't support.
2020-08-06 15:42:17 +03:00
Adrien Faveraux
23ef883e84 Fix Build Warning 2020-08-05 12:25:09 +00:00
Xaver Hugl
b7bd93c567 Makes the panelAutoHideHideCallback also handle panels set to "windows can cover" 2020-07-28 23:40:43 +02:00
Vlad Zahorodnii
3407b06c58 Fix build 2020-07-28 17:46:06 +03:00
adrien faveraux
9686a31454 Apply 1 suggestion(s) to 1 file(s) 2020-07-28 13:31:03 +00:00
Adrien Faveraux
2c0f977632 migrate Shadow to new approach 2020-07-28 13:31:03 +00:00
Adrien Faveraux
8e6a525fed Migrate dpms to new approach 2020-07-28 12:07:36 +00:00
Adrien Faveraux
dad8e5a79c migrate Plasma Desktop interface to the new approach 2020-07-28 13:29:32 +02:00
Adrien Faveraux
389aec2156 Migrate Migrate XdgForeign to new approach 2020-07-28 11:23:24 +00:00
Adrien Faveraux
ed264e2c55 migrate idle interface to the new approach 2020-07-28 11:01:31 +00:00
Adrien Faveraux
87abc0e483 move idle Inhibitor to the news approach 2020-07-28 10:46:30 +00:00
Aleix Pol
dfeb71d451 linuxdmabuf: don't leak private implementations
Found when running under ASAN
2020-07-28 10:23:30 +00:00
Vlad Zahorodnii
399560973e Bump plasma window management protocol version 2020-07-28 11:45:57 +03:00
Vlad Zahorodnii
4d1847b13e Drop support for the remote-access protocol
It's been replaced by PipeWire stuff.
2020-07-23 18:16:39 +03:00
Aleix Pol
e089092b54 Implement zkde_screencast_stream_unstable_v1 2020-07-23 12:57:17 +00:00
Aleix Pol
97219ec2d5 PlasmaWindow::internalId was deprecated in favor of ::uuid 2020-07-23 12:57:17 +00:00
David Edmundson
ef539368d9 Emit signal before DataControlSource destruction
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.
2020-07-23 11:58:31 +01:00
Vlad Zahorodnii
3994faff50 Rename the aboutToBeUnbound() signal in SurfaceInterface
Rename the aboutToBeUnbound() signal to aboutToBeDestroyed() in order to
make the usage of the word "destroyed" consistent.
2020-07-16 14:31:41 +00:00
Aleix Pol Gonzalez
c57270fa4a Update surface_interface.cpp 2020-07-15 22:22:40 +00:00
David Edmundson
df9413638d Cache clientConnection in SurfaceInterface
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
2020-07-15 22:55:37 +01:00
Vlad Zahorodnii
9a23695bab Use shorter name for variable that holds cached subsurface state 2020-07-15 11:05:59 +03:00
Vlad Zahorodnii
33f4254bd1 Port the wl_compositor wrapper to the new approach 2020-07-15 11:05:59 +03:00
Vlad Zahorodnii
46e4f0948b Port the wl_surface wrapper to the new approach 2020-07-15 11:05:57 +03:00
Vlad Zahorodnii
58cd4825e7 Port the wl_region wrapper to the new approach 2020-07-15 11:04:30 +03:00
Vlad Zahorodnii
c42fc80d33 Fix testServerSideDecoration 2020-07-15 08:20:00 +03:00
Vlad Zahorodnii
551b0dc7e0 Use ssd mode enums generated by qtwaylandscanner 2020-07-14 21:50:55 +03:00
Vlad Zahorodnii
7addf10211 Fix build 2020-07-14 21:28:20 +03:00
Adrien Faveraux
095edbed4c migrate Contrast to new approach 2020-07-14 18:24:24 +00:00
Adrien Faveraux
efdc6e44ee Migrate Server Decoration to new approach 2020-07-14 20:17:46 +02:00
Vlad Zahorodnii
ddac3d14d8 Fix build 2020-07-14 13:15:26 +03:00
Adrien Faveraux
aa2626ee4e move eglstream controler to the new approach 2020-07-14 10:10:04 +00:00
Adrien Faveraux
9ead826465 move server decoration palette to new approach 2020-07-13 15:35:57 +00:00
Vlad Zahorodnii
bd62038ada Drop some tests that matter only for KWayland::Client 2020-07-08 10:35:25 +03:00
Vlad Zahorodnii
ed261e2c5b Remove pointless wl_display_terminate()
Since we don't do wl_display_run(), wl_display_terminate() is pointless.
2020-07-08 07:25:23 +00:00
Vlad Zahorodnii
0d45f15c00 Drop unused method
Display::startLoop() isn't used anywhere and it only adds maintenance
burden, so drop it.
2020-07-08 07:25:23 +00:00
Vlad Zahorodnii
a634ce77c1 Allow creating global objects before Display is started
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.
2020-07-08 07:25:23 +00:00
David Edmundson
8792a8d6b8 On bind set stacking order only to newly bound client
sendStackingOrderChanged() iterates though all clients. Only the new
client needs to be send information at this point.
2020-07-06 16:47:05 +01:00
Vlad Zahorodnii
ec0c109f4d Provide an easy way to monitor buffer size changes
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.
2020-06-30 09:25:24 +03:00
Vlad Zahorodnii
6adaf7bcc6 Document the buffer transform property
The buffer transform is a pretty confusing thing, so document it in
order to avoid misleading people.
2020-06-24 06:58:46 +00:00
Vlad Zahorodnii
ecca34dea3 Rename buffer-specific surface properties
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.
2020-06-24 06:58:46 +00:00
David Edmundson
dd825dbfb3 Fix bad merge 2020-06-23 01:03:49 +01:00
David Edmundson
5ca1e73804 Merge branch 'Plasma/5.19' 2020-06-23 00:27:00 +01:00
David Edmundson
a664677051 Scope dragAndDropActionsChanged to source lifespan
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
2020-06-23 00:23:53 +01:00
Vlad Zahorodnii
ac66d25364 Drop SurfaceInterface::inputIsInfitine
Since we don't guarantee SC and BC in KWaylandServer, we can drop
SurfaceInterface::inputIsInfitine().
2020-06-19 16:12:00 +00:00
David Edmundson
b332cb4d1f Assume enabled if DPMS is not supported
This fixes several unit tests in kwin where the virtual output is not
considered enabled causing behavioural changes.
2020-06-19 08:26:47 +00:00
Vlad Zahorodnii
45812785cf Introduce surface-to-buffer and buffer-to-surface matrices
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.
2020-06-19 06:43:31 +00:00
David Edmundson
aa3f0f53c7 Add some hopefully useful documentation for people creating new interfaces
The generated classes don't really have documentation for the generated
methods. This hopes to provide some context.
2020-06-17 17:01:53 +01:00
Vlad Zahorodnii
0c8b77edc0 Drop unnecessary emptiness check
If a buffer is attached to the surface, its width or height cannot be 0.
2020-06-17 06:48:20 +00:00
David Edmundson
562a57945b Port AppMenu Interface to use autogenerated classes
Public API is identical except the now uneeded explit create on the
global.
2020-06-15 07:28:02 +00:00
David Edmundson
e712c5db2b Introduce API round primary-selection-unstable-v1.xml AKA middle-click paste
It's mostly a copy-paste of DataDevice.
2020-06-03 14:45:30 +01:00
Vlad Zahorodnii
963551d775 Add support for the wp_viewporter protocol
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.
2020-06-02 15:33:00 +03:00
Vlad Zahorodnii
99ef521e6d Add methods for converting buffer and surface coordinates
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.
2020-06-01 17:04:50 +03:00
Vlad Zahorodnii
8651045c4b Mark the buffer transform as committed
We need to mark the buffer transform as committed or else it won't be
ever applied.
2020-06-01 17:04:50 +03:00
Vlad Zahorodnii
238f59365f Simplify code that emits mapped() and unmapped() 2020-06-01 17:04:50 +03:00
Vlad Zahorodnii
6bdd20d47b Introduce methods for retrieving individual buffer dimensions
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.
2020-06-01 17:04:50 +03:00
Vlad Zahorodnii
85161bb644 xdg-shell: Reset xdg_toplevel and xdg_popup on unmap 2020-06-01 14:48:51 +03:00
Vlad Zahorodnii
e3ad23ccd8 xdg-shell: Rewrite wrappers for the xdg-shell protocol
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.
2020-06-01 14:48:51 +03:00
Vlad Zahorodnii
5955d0486d xdg-shell: Drop support for v6
It's been deprecated for quite a while and all major toolkit already
support xdg_wm_base.
2020-06-01 14:48:51 +03:00
Vlad Zahorodnii
775dd4e134 xdg-shell: Drop support for v5
It's been deprecated for quite a while and all major toolkits already
support xdg_wm_base.
2020-06-01 14:48:51 +03:00
Adriaan de Groot
8715e441a7 Fix test-building on FreeBSD
This is the same change as
	https://invent.kde.org/frameworks/kwayland/-/merge_requests/2
and removes an unneeded #include
2020-05-31 22:40:11 +02:00
Benjamin Port
9ffee262f7 Fix class names for keyboard shortcuts inhibit 2020-05-29 11:30:10 +02:00
Benjamin Port
a452ff1642 Add keyboard_shortcuts_inhibit protocol
Reviewers: zzag, davidedmundson, apol

Subscribers: romangg, crossi, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D29231
2020-05-29 10:46:47 +02:00
Vlad Zahorodnii
ca210bf2b4 Add missing parameter name 2020-05-28 11:09:27 +03:00
Vlad Zahorodnii
6fd661bba9 Add some boring documentation for data control wrappers
This change adds some documentation that describes the purpose of data
control wrappers in a few words.
2020-05-28 11:09:27 +03:00
Vlad Zahorodnii
fc38e55547 No auto
"auto r" implies that it's a resource, but it's not.
2020-05-28 11:09:27 +03:00
Vlad Zahorodnii
1c3059c74b Fix class names for data control wrappers
The data control protocol is unstable. Therefore, class names must have
"V1" suffix.
2020-05-28 11:09:02 +03:00
Vlad Zahorodnii
c3094c686e Pedantic whitespace changes 2020-05-28 10:48:06 +03:00
David Edmundson
6156f86548 Add DataControl iface
Summary:
This patch makes use of wlroot's DataControl interface to support
clipboard management.

Unlike wl_data_device clipboards are sent on every change to all
watchers.
If the data device has a selection set it updates immediately.

Because it was started a year ago it uses the existing style of
wrapping objects. The unit test uses the new approach.

Test Plan:
Updated kwin
used wlroot's wl-copy, wl-paste which are xclip replacements to
show that the clipboard updated correctly

Reviewers: #kwin

Differential Revision: https://phabricator.kde.org/D29330
2020-05-26 13:32:56 +01:00