Commit graph

163 commits

Author SHA1 Message Date
Aleix Pol Gonzalez
6c4ded2034 input: Allow different surfaces to be interacted in parallel by touch
While on pointers and keyboards the focus patterns follows rather
naturally, on touch screens it doesn't so much.
This change adapts our touch infrastructure to allow for multiple
surfaces to be issued touch events without forcing all interactions into
the same one.

Signed-off-by: Victoria Fischer <victoria.fischer@mercedes-benz.com>
2024-08-28 09:36:51 +00:00
David Edmundson
99f2cd2f51 Revert "wayland: Revert send pointer leave on drag"
Now we have server-side cursor icons, we can send the pointer leave.

This reverts commit 9302e84b95.
2024-08-23 09:42:05 +00:00
David Redondo
9e2326d3ac Generate wayland code with PRIVATE_CODE 2024-08-15 14:16:11 +00:00
David Redondo
31018c000b wayland: Check serial instead of focus for changing selections
Clients can have valid reasons to change the selection when the
same user action that also caused the selection request
to lose keyboard focus. This is notbaly the case for menus
created from a Plasma panel which itself will not take focus
but when clicking on action it only triggers after the menu
is closed.
This also matches what weston and sway do.
BUG:490803
2024-08-06 12:54:00 +00:00
Vlad Zahorodnii
442648edc0 wayland: Remove zombie ClientConnection from Display later
Otherwise it's theoretically possible to create a new ClientConnection
object for the zombie wl_client when its resources are being destroyed.
For example

- process early wl_client destroy notification
- the ClientConnection objects gets removed from the client list in Display
- process wl_resource objects getting destroyed
- if some code calls display->getConnection(zombie_client), it's going to
  reintroduce the client in the client list
- process late wl_client destroy notification, it's going to destroy the
  original and the clone ClientConnection object

This change prevents reintoducing a clone client object, by keeping the
original for a bit longer until it's actually destroyed. In the future though,
it would be great to kill the client lists in Display and ClientConnection,
and just use `static_cast<ClientConnection *>(wl_client_get_user_data())`.
2024-03-20 13:41:59 +00:00
David Edmundson
9302e84b95 wayland: Revert send pointer leave on drag
This was changed to match the behaviour of other compositors.
However what kwin did before is more sensible.

Sending a leave event breaks cursor updates by design. See
https://gitlab.freedesktop.org/wayland/wayland/-/issues/444
2024-03-11 11:32:35 +00:00
David Edmundson
5386360928 wayland: Send wl_pointer leave before data_device enter
SeatInterface currently has a separation of kwin's focus scope to
pointer input with early return guards in notifyPointerEnter and
notifyPointerLeave where clients don't get pointer events.

However we don't update the initial state when a drag is started, this
patch notifies sends a pointer leave to the new drag target before the
data_device enter so things are consistent.

This also brings it in line with Weston and Mutter.

notifyPointerLeave has it's early return removed as for wayland windows
as we know nothing will have pointer focus.
2024-02-14 12:39:32 +00:00
Vlad Zahorodnii
6510fe6e5d scene: Fix SurfaceItem::bufferTransform()
The wayland spec is not quite clear about the transforms, but the buffer
transform indicates a transform from wl_surface to wl_buffer or compositor
global coordinate space to composited buffer.

On the other hand, SurfaceItem assumes that the order is vice versa.
2024-01-09 17:42:09 +00:00
Vlad Zahorodnii
9039612c20 core: Rename OutputTransform enums 2024-01-09 17:42:09 +00:00
Aleix Pol Gonzalez
df3e894c1a wayland: Install display.h
It's needed to properly access KWin::effects->waylandDisplay().

Signed-off-by: Georg Leugner <georg.leugner@mbition.io>
2024-01-08 23:06:43 +00:00
Jonathan Esk-Riddell
cc4eac4c85 Port to renamed kwayland
https://invent.kde.org/plasma/kwayland/-/merge_requests/107  use renamed kwayland
2023-11-23 19:34:24 +00:00
Vlad Zahorodnii
79d5a70c01 wayland: Make SurfaceInterface::{frameRendered,takePresentationFeedback} not touch subsurface tree
This gives us greater flexibility and in general more cleaner code.
2023-11-14 14:58:40 +00:00
Xaver Hugl
15d6d8c336 wayland/surface: add the output a surface is on the most 2023-11-07 20:23:06 +01:00
Vlad Zahorodnii
d7b1661e08 Merge libkwineffects into libkwin
libkwineffects was introduced when kwin used to be an executable. It
provided an api to implement effects and shielded from the technical
quirks in kwin.

Over the time, kwin internals had been split and abstractions were
refactored so they can be consumed in scripts or plugins. Besides that,
new ways to implement extensions have been introduced, which use
kwin's internal abstractions.

On the other hand, effects continue using libkwineffects specific apis.
This has a few issues: qtquick effects use both apis and it bites us,
duplicating same apis.

The best solution so far is to merge libkwineffects with libkwin, and
replace libkwineffects abstractions with libkwin abstractions, e.g.
EffectScreen -> Output, etc. This change takes care of adjusting libs.

Obviously, the main disadvantage of doing so is that binary effects
have to be recompiled every time new libkwin is released. But it's
already the case with libkwineffects too.
2023-10-25 12:46:12 +00:00
Aki Sakurai
115ea7454b Send tablet events to every bound wl_resource
Some apps, notably Tablet KCM, will rebind the tablet interface and consume all events that should be sent to the GUI toolkit.
This commit sends events to every consumer and also stores the latest cursor indexed by wl_client instead of wl_resource.
BUG:473126
2023-10-24 11:22:27 +00:00
Laurent Montel
bc6116c5a7 There's no QVector anymore, QList is the QVector in Qt6 2023-10-19 13:43:53 +00:00
Vlad Zahorodnii
5246d3924f wayland: Destroy ClientConnection immediately
With QObject::deleteLater(), the client object can unexpectedly outlive
the expected lifetime as in 03d0a226fb.
2023-10-09 06:32:14 +00:00
Vlad Zahorodnii
7e99ab9438 Build wayland tests with same build options as other tests 2023-10-06 11:21:00 +00:00
Vlad Zahorodnii
7d56aa3687 Merge wayland tests with other tests
This makes wayland tests organization consistent with other kwin tests.
2023-10-06 11:21:00 +00:00
Martin Gräßlin
d6dd4af8cf Rename autotests/wayland to autotests/integration
It's not about Wayland, but more about Integration. It can test both
Wayland and X11 windows.

Reviewed-By: Bhushan Shah
2016-06-29 10:29:45 +02:00
Martin Gräßlin
c9984094de Add support for ToolTip Role on PlasmaSurface
Summary:
It's mapped to be on all desktops in order to properly have tooltips
show for the panel (which is on all desktops) instead of just on the
desktop it's created.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2032
2016-06-29 09:06:01 +02:00
Martin Gräßlin
3493e97655 Support for syncing the clipboard from X11 to Wayland and vice versa
Summary:
The clipboard sync is done by a dedicated helper binary launched by
KWin. This helper binary is forced to xcb platform to piggy-back on
Qt's implementation of the X11 clipboard. In addition it implements
the Wayland clipboard - which is much simpler. Reading the Wayland
clipboard is based on the implementation in QtWayland.

KWin internally knows the DataDeviceInterface belonging to the helper
application. Whenever an xwayland client is focussed, this DataDevice
is allowed to set the selection and KWin manually updates the current
selection in the SeatInterface. By that the sync from X11 to Wayland
is implemented. When afterwards a Wayland client is selected, it's sent
the current selection which references the X clipboard and a data
transfer can be initiated in the normal Wayland way.

For the other direction KWin sends the current selection to the helper's
DataDevice whenever an xwayland window is focused. The helper application
reads the Wayland clipboard and sets it on the X11 clipboard. Thus the
Wayland clipboard is synced to X11.

The approach used here will also be useful for implementing a clipboard
manager (aka klipper).

Currently the implementation is not yet fully completed. We need to
make sure that the helper application gets restarted in case of a crash.

Test Plan: See added test case

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1973
2016-06-29 09:03:40 +02:00
Bhushan Shah
a69b47f7b7 [autotests] Extend StrutsTests for setup on mobile
This testcase tries to emulate the panel setup on the phone,

- Window placement strategy is set to maximizing
- Top panel with height of 60
- Bottom panel with height of 150

However this is still not complete testcase, some todo items:

- Create Plasmashell desktop window before creating panels
- Create normal window and verify if its placement/position is right

Reviewed-by: Martin Gräßlin <mgraesslin@kde.org>
2016-06-28 16:53:35 +05:30
Martin Gräßlin
1a779ccd88 Merge branch 'Plasma/5.7' 2016-06-28 12:43:36 +02:00
Martin Gräßlin
c81d8204f9 Add support for new Notification role on PlasmaSurface
Summary:
Sets notifications on all desktop and doesn't activate them.

Unfortunately doesn't work on Plasma yet. Seems the windows don't get
tagged properly.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1930
2016-06-27 11:47:50 +02:00
Martin Gräßlin
7adf69dece Update Keyboard focus when the Surface of the active client changes
Summary:
For XWayland windows the window might be activated before the Wayland
Surface is set for it. Thus the keyboard focus is not passed to the
window. Only on the next activate after the window got created the
window got keyboard focus.

This change addresses this problem by emitting a signal from Toplevel
when the surface changes. The KeyboardInput listens to this signal
for the active client and updates keyboard focus again if the surface
changes. Thus keyboard focus is properly passed to XWayland windows.

Test Plan:
Test case which creates an X11 window is adjusted to verify
the condition.

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2009
2016-06-26 16:07:31 +02:00
Martin Gräßlin
02ba1e7c0a Don't crash if a decoration doesn't get created
Summary:
With the NoBorder option set the DecorationBridge won't create
decorations. Thus we get a nullptr and obviously should not call
into it. There was already a check for whether decoration is null,
so that is a rather embarrassing bug.

Test Plan: Test case added which exposes the crash

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1980
2016-06-23 11:28:08 +02:00
Martin Gräßlin
8a85cc5f9c Do not activate on-screen-display windows
Summary:
Plasma's OSD windows were stealing focus on Wayland. We can be sure
that they should not get keyboard focus, so a check to acceptsFocus
is added.

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1927
2016-06-17 09:26:15 +02:00
Martin Gräßlin
4560f8d253 Handle ShellClient::windowShown in Workspace
Summary:
When a ShellClient gets unmapped and mapped again the signal windowShown
gets emitted. We need to handle this in Workspace to ensure the window
is in the proper layer and gets focus.

This fixes applications like KRunner/Yakuake not having focus on a
second show. Unfortunately it also brings back the problem that
notifiations steal focus (this needs to be fixed by passing a proper
window type to a notification).

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1864
2016-06-16 11:13:59 +02:00
Martin Gräßlin
e5fe3137b8 Fix the ignore struts multi-screen handling
Summary:
The checks in Client::adjustedClientArea were a little bit too
agressive, excluding also valid setups.

This change addresses the regression by keeping the actual intended
improvements in place.

The check in Client::adjustedClientArea is now only done for the
special case of desktopArea == area. This ensures that a strut excluding
a complete screen won't affect the overall workarea.

In addition new checks are introduced in Workspace::updateClientArea.
When calculating the new sareas a check is performed whether the
intersection with the adjustedClientArea would result in the sarea
becoming empty (thus a screen being completely removed). If that's the
case the geometry is ignored to not exclude a complete screen.

Interestingly I should have noticed that something with the logic is
odd. As the test case had two commented geometries which we now get.

BUG: 363804

Reviewers: #plasma, apol, lbeltrame

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1744
2016-06-15 14:48:13 +02:00
Martin Gräßlin
39e7b26243 Introduce a RequestGeometryBlocker in ShellClient
Summary:
The idea is to not send multiple resize requests to a client when we
know that we might have multiple geometry changes. E.g. when going
from maximized to restored the borders change and trigger a resize in
addition to the resize from switching to restored.

The implementation is inspired by the GeometryUpdateBlocker.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1808
2016-06-14 07:40:14 +02:00
Martin Gräßlin
53a3740082 Request the resize of ShellSurface after Decoration updated the borders when maximizing
Summary:
This ensures that we don't send a size request with the borders still
added.

Test Plan:
Verified that a maximized window is properly sized and
doesn't have empty borders

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1807
2016-06-14 07:39:37 +02:00
Martin Gräßlin
c7828eab8f Ensure that WaylandServer::shellClientAdded only gets emitted once
Summary:
When a shell client got mapped, unmapped and mapped again we emitted
the shellClientAdded signal in WaylandServer again. This resulted in
e.g. Workspace, EffectsHandler, etc. to start managing the window again.
This can be a reason for problems we see with such windows like the
Plasma panel dialog when opened the second time.

Test Plan:
Needs extensive testing on real world system as that changes
behavior now.

Reviewers: #kwin, #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1784
2016-06-14 07:36:33 +02:00
Martin Gräßlin
2343a90aa5 UpdateClientArea from ShellClient::doSetGeometry if the ShellClient has a strut
Summary:
This ensures that resizing a panel updates the client area. On X11 there
is an event when the struts change, but on Wayland the struts are implied
from window type (panel) and the panel behavior, so we need to trigger it
manually.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1811
2016-06-10 12:56:33 +02:00
Martin Gräßlin
58db477796 Fix the strut handling for wayland clients
Summary:
The implementation was broken as it transformed the QRects into QRegions,
subtracted the geometries and took the bounding rect again. In several
setups this could result in the strut getting ignored.

This change improves the calculation of the struts by creating a QMargin
which describes the area which needs to be subtracted from a screen rect.
The QMargin is only adjusted for the edge the window borders. We can
assume that a window with a strut needs to border a screen on Wayland.

With this change we are also able to support panels between screens.
On Wayland a panel placed on the right of a left screen affects the
maximization area of the left screen, but does not affect the overall
workarea.

CCBUG: 167852

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1803
2016-06-10 12:36:15 +02:00
Martin Gräßlin
c95ddb7102 Pass the maximized signal to DecoratedClient
Summary:
From the famous category: "How could that code ever have worked".

Maximized state changes were never passed to window decorations. For
X11 windows the decoration updated the state nevertheless, for Wayland
windows the state did not get updated, thus a maximized window had
borders and was shown with a not maximized button.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1805
2016-06-09 13:35:38 +02:00
Martin Gräßlin
c65c9728d1 [autotest/wayland] Add a test case for maximize windows
The added test exposes the problem that a shell surface might request
being maximized and then provide an incorrectly sized buffer. In this
case the ShellClient is incorrectly considered as maximized.

I don't have a good idea how to address this yet, but still publish
the test case exposing the problem.
2016-06-07 10:27:02 +02:00
Martin Gräßlin
9d0360b3ef [autotests] Skip PlasmaWindowTest::testLockScreenNoPlasmaWindow on build.kde.org
Needs to start kscreenlocker_greet which needs EGL which we don't have.
2016-06-07 10:03:12 +02:00
Martin Gräßlin
0388ed02a6 Call destroyWindowManagementInterface from ShellClient::destroyClient
Summary:
So far destroyWindowManagementInterface was only called when the
ShellClient got unmapped. But it's possible (although not recommended)
to just destroy the Surface without prior unmapping. In that case the
PlasmaWindow got leaked.

This change addresses this problem by always calling
destroyWindowManagementInterface from ShellClient::destroyClient.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1762
2016-06-06 08:37:53 +02:00
Martin Gräßlin
210d57bb45 Set ShellClient on all desktop depending on Plasma Surface role
Summary:
If a PlasmaShellSurface is a Desktop, a Panel or an OSD it implies
that the window is on all desktop. So let's set it like that.

Test Plan: Auto test added and also confirmed by manual testing

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1747
2016-06-06 08:36:11 +02:00
Martin Gräßlin
76de85b449 Don't setup PlasmaWindowManagement integration for lock screen windows
Summary:
We don't want external processes to know anything about the lock screen
windows. Especially we don't want them to be able to request close on
them.

Thus better never show thus windows to them.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1760
2016-06-03 16:22:52 +02:00
Martin Gräßlin
5d396add12 Restrict when to expose a ShellClient to PlasmaWindowManagement
Summary:
For some windows we don't want to create a PlasmaWindow. Not all
ShellClients are something the outside world should see. This change
introduces the first restrictions:
* KWin internal windows are hidden
* transients not accepting focus are hidden

The latter case doesn't work though if the Surface is mapped prior
to creating the shell surface. In such a situation it's racy as KWin
handles the create surface request before we get the setTransient
request. This is difficult to handle as we do want to react quickly.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1759
2016-06-03 16:22:52 +02:00
Martin Gräßlin
67b869218f [autotest/wayland] Force kscreenlocker_greet to QMLSCENE_DEVICE softwarecontext
OpenGL/EGL doesn't work on build.kde.org. Because of that the
kscreenlocker_greet aborts on startup and we cannot really test whether
it works on build.kde.org. E.g. we never actually see the window.

This change just makes sure that QMLSCENE_DEVICE=softwarecontext is
passed to the greeter in the LockScreenTest. Hopefully that fixes it
on build.kde.org.
2016-06-03 14:18:45 +02:00
Martin Gräßlin
4034795893 [autotests/wayland] Add a test case for PlasmaWindow
The new added test case verifies a few cases in which a PlasmaWindow
should or should not be created or destroyed.

Some cases are clearly wrong and are marked with expect_fail.
2016-06-03 09:28:46 +02:00
Martin Gräßlin
fdb04e6f75 [autotests] Correct the expected values from 1a23ab7cf0 2016-06-02 10:07:47 +02:00
Martin Gräßlin
1a23ab7cf0 [autotest] Add test case exposing problem of bug 363804
The test case sets up apol's screen setup and the panel as described
in the attachements in bug 363804. As the test shows the panel's strut
is incorrectly ignored.

CCBUG: 363804
2016-06-02 09:29:53 +02:00
Martin Gräßlin
ff88f93852 Support touch events on KWin internal windows
Summary:
Qt's touch event API is rather difficult and complex to implement.
As none of KWin's internal windows supports multi-touch gestures yet,
this is going the easy route and just simulates a left mouse button
press. If in future need arises for touch gesture support on KWin's
internal windows, this can be added.

Test Plan: Tested on exopc with DebugConsole and auto test

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1661
2016-05-23 18:40:06 +02:00
Martin Gräßlin
d758eae6c5 [autotests/wayland] Try to make PointerInputTest::testMouseActionActiveWindow more robust
It's currently failing on build.kde.org. I'm not able to reproduce the
failure localy so I can only interpret the failure. The failure looks
like a window is still present in the next executed test case thus
breaking the positioning.

This change ensures that the window is properly gone before going into
the next test case.
2016-05-23 11:19:29 +02:00
Martin Gräßlin
73fae5e63d Support touch events in DecorationEventFilter
Summary:
Touch events are emulating mouse events, in particular left mouse
button.

With this change one can move windows through the decoration, use
the decoration buttons and also support the double click action.

As finding the decoration is pretty much exactly the same as for
pointer events, a new base class is introduces which provides the
functionality of updating the decoration and the shared common
variables.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1604
2016-05-17 07:33:02 +02:00
Martin Gräßlin
14d12c0585 Do not limit mouse actions to titleBarArea but allow on complete titleBarPosition
Summary:
Mouse actions like wheel and double click were restricted to the titleBar
area. This made the top most pixel non-interactive as it's not part of the
titleBarArea.

This change makes the complete titlebarPosition interactive. That is it
includes for a "normal" (top) setup also the TopLeft/Top/Right section.
Thus the top most pixel can be double clicked, mouse wheeled, etc.

For the Wayland case the test case is adjusted.

BUG: 362860
FIXED-IN: 5.7.0

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1596
2016-05-12 16:58:15 +02:00