Commit Graph

73 Commits (a15966c72383f7dd7793158f3de8a5eecd6eb9aa)

Author SHA1 Message Date
Vlad Zahorodnii 4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii 1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Aleix Pol d71672a0d1 XdgPopupClient can also be a PlasmaShellSurface
Debugging the panel thumbnails I realised that the setPosition calls
didn't have an effect. This is probably not the only way to fix this bug
but does fix the bug.
At the moment it only brings the position from the interface.
2020-08-06 11:00:43 +00:00
Xaver Hugl 901a9a2373 make the panelAutoHideHideRequested callback also handle panels set to "windows can cover" 2020-07-29 11:25:43 +00:00
Benjamin Port 0ec34afdcc On wayland, prevent changeMaximize to raise client 2020-07-27 09:26:25 +00:00
Vlad Zahorodnii 555885072d Check if we successfully restored input focus
In rare cases, Workspace::restoreFocus() may fail, for example when the
most recently activated client is about to be destroyed or unmapped.

If it happens that we cannot restore the focus, then mark the window in
FocusIn event as active.

CCBUG: 424223
2020-07-22 12:29:41 +00:00
Vlad Zahorodnii 9c55c01767 Introduce a signal that notifies about new buffer geometry
The new signal can be useful if one wants to watch a toplevel for buffer
geometry updates. This can be especially useful for input related code
because the position of the upper left corner of the main surface is used
to compute the input transformation matrix.
2020-07-17 11:56:22 +00:00
Vlad Zahorodnii 4a6badc22c Ignore setActive() for windows that are being deleted
We may call setActive() on a window that is being deleted. We cannot
guarantee that at that moment the X11 window or the Wayland surface is
still valid. So, the best course of actions is to do nothing.

BUG: 424255
2020-07-16 17:04:09 +03:00
Vlad Zahorodnii 6139ea7874 Destroy xdg shell clients when surface is still alive
Destroy xdg shell clients when the aboutToBeDestroyed() signal has been
emitted in order to ensure that no NULL surface is going to be accessed.
2020-07-16 17:04:09 +03:00
Vlad Zahorodnii 036ad759e0 [wayland] Adapt to SurfaceInterface changes 2020-07-15 12:46:28 +00:00
Benjamin Port 84b8d866e6 Prevent move/resize event when handling a maximize event 2020-07-07 08:35:12 +00:00
Benjamin Port 2d13bc3aa8 Prevent move/resize event when handling set full screen event
BUG: 421232
2020-07-07 08:35:12 +00:00
Vlad Zahorodnii f7a67e0edc [wayland] Ignore decoration updates if initial state isn't committed yet
or else we might send an unexpected configure event.
2020-07-01 09:18:29 +00:00
Vlad Zahorodnii 1013ee1bd0 [wayland] Queue maximize and fullscreen requests if initial state isn't committed yet
In order to ensure that no configure events will be sent before the full
initial state is committed, we need to queue maximize and full screen
requests or else the client may receive an "unexpected" configure event
and we miss to call initialize().
2020-07-01 09:18:29 +00:00
David Edmundson c567d51749 Apply suggestion to xdgshellclient.cpp 2020-06-19 08:56:14 +00:00
David Edmundson 3f1fb873dd Apply suggestion to xdgshellclient.cpp 2020-06-19 08:56:14 +00:00
David Edmundson e02fe34e17 [wayland] Avoid debug recursion in XdgShellClients
QDebug& operator<<(QDebug& stream, TopLevel*)
calls TopLevel::debug(stream)

So our implementation has to provide something custom not call the base
class.

Debug here is loosely based on X11Client. It probably can be expanded on
in time, but at least it won't crash.
2020-06-19 08:56:14 +00:00
Vlad Zahorodnii cc3eb54b32 Introduce the client geometry in Toplevel
In most cases, we don't need to react to client geometry changes, but in
code that deals with server-side window decorations, we need to react to
client geometry changes. The problem is that frame and client geometry
updates are not correlated even though there is a connection between the
frame geometry and the client geometry.

This change introduces the client geometry in the Toplevel class in order
to allow monitoring client geometry updates from DecoratedClientImpl.
2020-06-18 07:40:58 +00:00
Benjamin Port 0c9e481577 Dock with windows go below will be on top of all windows and same layer of above windows 2020-06-02 15:51:29 +02:00
Vlad Zahorodnii df9e36ee68 [wayland] Destroy XdgToplevelClient and XdgPopupClient on unmap
There are several ways to handle unmapping of a wl_surface. The first
one is to destroy the associated AbstractClient instance. The second one
is to transition the AbstractClient in a special state.

The problem with the second approach is that it makes animations such as
fade out more difficult to handle since effects in kwin are geared more
towards the first approach (destroying AbstractClient).
2020-06-01 15:13:03 +03:00
Vlad Zahorodnii 31ea780d79 [wayland] Rework xdg-shell implementation
Summary:
This change splits the XdgShellClient class to better match existing
abstractions in the xdg-shell protocol and fix a few issues related to
sending configure events.

In the new client classes, configure events are handled differently.
Instead of blocking configure events, we try to send them as late as
possible. Delaying configure events will let us merge changeMaximize()
for X11 clients and Wayland clients and it also fixes the bug where
we don't send the final configure event when user has finished resizing
a window.

Given that configure events are not sent immediately, XdgSurfaceClient
keeps the last requested frame geometry and the last requested client
geometry.

This patch doesn't intend to fix all issues in kwin's implementation of
the xdg-shell protocol. For example, we still handle surface unmapping
very poorly.

Test Plan: Tests pass.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27861
2020-06-01 15:12:59 +03:00
Méven Car 797ccca48c Wayland: avoid binding disabled outputs to surfaces
We don't need to bind disabled outputs to surfaces that overlaps them.
This prevents error down the line and warnings about ignoring surface.enter events with Qt.

BUG: 419749
2020-05-26 15:14:13 +00:00
David Edmundson bc1991706c drop unused headers
Test Plan: N/A

Reviewers: apol

Reviewed By: apol

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29337
2020-05-01 16:13:33 +01:00
Aleix Pol 3a9d7a6e9d Port KWin to KWaylandServer
Summary: Away from KWayland::Server and KF5WaylandServer.

Test Plan: Builds, ran nested session

Reviewers: #kwin, #plasma, #frameworks, davidedmundson, zzag

Reviewed By: #kwin, #plasma, davidedmundson, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29278
2020-04-30 12:56:08 +02:00
Aleix Pol 6abd23ed02 Make it possible to have a separate cursor for the tablet
Summary:
As is KWin only had 1 Cursor which was a singleton. This made it impossible for
us to properly implement the tablet (as in drawing tablets) support and show where
we're drawing.
This patch makes it possible to have different Cursors in KWin, it makes all the
current code still follow the mouse but the tablet can still render a cursor.

Test Plan: Tests pass, been using it and works as well as before but with beautiful tablet cursors.

Reviewers: #kwin, cblack, davidedmundson

Reviewed By: #kwin, cblack, davidedmundson

Subscribers: davidedmundson, cblack, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28155
2020-04-03 01:16:45 +02:00
Aleix Pol c9c6fa818d Don't position plasma surfaces if a position wasn't requested
Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28429
2020-03-30 14:49:56 +02:00
Aleix Pol 27634d00c0 Prefer holding a reference to an object we're going to call
Summary: It's more correct and fixes a warning

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28430
2020-03-30 14:49:27 +02:00
Aleix Pol 5eb84af469 Remove overloads on virtual methods
Summary:
Prefer virtual methods that take QRect and QSize rather than multi-int versions.
Makes for clearer API and reduces the amount of code that was taking all of the
components and turn it into a class.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28283
2020-03-26 16:10:10 +01:00
Vlad Zahorodnii 29fa85eed1 Use SurfaceInterface::boundingRect()
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27831
2020-03-18 16:35:21 +02:00
Vlad Zahorodnii 4ae6c99c6b Introduce AbstractClient::createDecoration()
Summary:
We have duplicated code in InternalClient and XdgShellClient to create
decorations. In order to get rid of the code duplication, this change
introduces a method that AbstractClient subclasses can call to create
a window decoration.

Test Plan: Tests pass.

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27822
2020-03-05 10:25:36 +02:00
Vlad Zahorodnii be759b7d33 Use AbstractClient instead of XdgShellClient wherever possible
Summary:
Currently, we have only one shell client type - XdgShellClient. We use
it when we are dealing with Wayland clients. But it isn't really a good
idea because we may need to support shell surfaces other than xdg-shell
ones, for example input panel surfaces.

In order to make kwin more extensible, this change replaces all usages
of the XdgShellClient class with the AbstractClient class.

Test Plan: Existing tests pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27778
2020-03-04 09:57:13 +02:00
Vlad Zahorodnii 2b120e07ca [wayland] Honor xdg-toplevel size constraints
Summary:
This change ensures that we honor surface size constraints specified by
xdg-toplevel clients.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26830
2020-02-28 17:13:01 +02:00
Vlad Zahorodnii a75fb7f84e Refactor geometry constraints code
Summary:
Currently, there are a couple of issues with sizeForClientSize(). First
of all, we have a method called clientSizeToFrameSize() which does similar
thing except applying geometry constraints and checking window rules. The
other issue is that sizeForClientSize() is doing a bit too much, it checks
window rules, it applies a bunch of geometry constrains. Sometimes it
does not perform conversion between client sizes and frame sizes!

This change attempts to address those issues by replacing sizeForClientSize
with two similar methods and changing semantics of some methods of the
X11Client class.

The most significant difference between sizeForClientSize() and the new
methods is that neither constrainClientSize() nor constrainFrameSize()
check window rules. This is up to users of those methods. In many places,
we don't have to check window rules because we check isResizable(),
which returns false if the frame size is enforced by a window rule.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26828
2020-02-28 17:13:01 +02:00
David Edmundson ed5768181e Honour panelTakesFocus for other plasmashell types
Summary:
The semantics of a window taking focus on user interaction apply to more roles. See D25851.

Given it is used by `KWindowSystem::forceActivateWindow` in kwayland-integration, it makes sense to pass focus to the window once it gets this property set.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25968
2020-02-28 12:22:42 +00:00
Vlad Zahorodnii 5af81c1cd7 Make support for the maximized mode partially optional
Summary:
Not all Client classes have support for the maximized mode. Therefore,
it can be made opt-in to reduce the amount of plumbed methods.

Unfortunately, there a few places, which don't have any connection with
the maximized mode, where AbstractClient::geometryRestore() is used, so
it cannot be made 100% optional at the moment.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27169
2020-02-12 11:28:15 +02:00
Vlad Zahorodnii 15af09c70a Introduce Toplevel::frameGeometryChanged signal
Summary:
Currently we have two signals that are emitted when the Toplevel's geometry
changes - geometryShapeChanged() and geometryChanged(). The former signal
is used primarily to invalidate cached window quads and the latter is
sort of emitted when the frame geometry changes. But it's not that easy. We
have a bunch of connects that link those signals together...

The worst part about all of this is that the window quads cache gets
invalidated every time a geometry update occurs, for example when user
moves a window around on the screen.

This change introduces a new signal and deprecates the existing geometryChanged
signal. frameGeometryChanged is similar to geometryChanged except that it is
emitted when an _actual_ geometry change has occurred.

We do still emit geometryShapeChanged signal. However, in long term, we
need to get rid of this signal or come up with something that makes sense
and doesn't require us to waste computational resources.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26863
2020-02-12 10:52:26 +02:00
Vlad Zahorodnii 84f0d51f40 Rename popupPosition to popupRect
Summary: popupPosition implies that it is a QPoint, which is false.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27125
2020-02-03 14:53:06 +02:00
Vlad Zahorodnii 432787e036 Use Q_ASSERT in XdgShellClient::transientPlacement()
Summary: This simplifies CFG.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27124
2020-02-03 14:39:34 +02:00
Vlad Zahorodnii 85c099936e Use QRect::moveRight() and QRect::moveBottom() in XdgShellClient::transientPlacement()
Summary: It's more intuitive.

Test Plan: Relevant tests pass.

Reviewers: #kwin

Subscribers: davidedmundson, broulik, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27050
2020-02-03 14:07:48 +02:00
Vlad Zahorodnii 6dd6bdb57d [wayland] Implement resize_x/resize_y constraint adjustment
Summary:
Since we send the initial configure event after placing xdg-popups, we
can finally implement resize_x and resize_y constraint adjustments.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27049
2020-01-31 12:17:45 +02:00
Vlad Zahorodnii c43b25bd55 Fix minor issues in XdgShellClient::updateClientOutputs
Fix minor coding style issues and drop redundant qAsConst (const
containers don't detach).
2020-01-29 13:04:51 +02:00
Vlad Zahorodnii 07553d209d s/m_xdgShellSurface/m_xdgShellToplevel/g
Summary: m_xdgShellSurface represents an xdg-toplevel, not an xdg-surface.

Test Plan: Compiles.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26975
2020-01-29 12:58:54 +02:00
Vlad Zahorodnii 2cf832cf29 [wayland] Get rid of some duplicated code
Summary:
We duplicate ping code in a few places. This change introduces a dedicated
method for sending ping events to an xdg-toplevel. In long term, it can be
used for sending "test" ping messages at random interval.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26974
2020-01-29 12:58:54 +02:00
Vlad Zahorodnii d079f5daed [wayland] Keep the opposite corner still when resizing a window
Summary:
According to the xdg-shell spec, configure events carry the maximum
window geometry size. If a client wants to enforce aspect ratio, it
may attach a buffer with smaller size. We need to account for that
when determining frame geometry in the commit handler.

I'm targeting 5.18 branch.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26886
2020-01-24 01:05:40 +02:00
Vlad Zahorodnii 72ca9268ce [wayland] Provide correct input geometry for client-side decorated clients
Summary:
Currently, the input geometry for client-side decorated clients matches
the frame geometry, which makes it impossible for a user to resize such
clients by just dragging invisible area near window borders.

BUG: 416346

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: cblack, ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26716
2020-01-24 00:49:50 +02:00
Vlad Zahorodnii 55b4912004 Update my email address 2020-01-14 18:17:18 +02:00
David Edmundson 89024e2bcc Clamp XdgShellClient::clientSize to surface size, not m_windowGeometry
Summary:
It's perfectly legitimate to call setWindowSize before a buffer is
attached. This seems to have happen with plasma surfaces that commit
when attaching a shadow, but technically could happen anywhere.

By clamping to the applied surface here, we get the wrong window size
cached and not re-evaluated when a surface is eventually applied. This
leaves us thinking the windowsize is empty but with a massive margin
which actually holds the content.

We want all internal usages of xdgshellclient to use the window geometry
set. Only the wider kwin part needs to care about clamping it to the
surface.

This fixes popup placement in the plasma panel
BUG: 415317

As well as ghost notification popups with no background contrast that
you can't interact with.

Test Plan: Ran kwin

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26233
2020-01-06 15:10:50 +00:00
Kai Uwe Broulik a823474ec3 Honour panelTakesFocus for other plasmashell types
The semantics of a window taking focus on user interaction apply to more roles. See D25851.

Given it is used by KWindowSystem::forceActivateWindow in kwayland-integration,
it makes sense to pass focus to the window once it gets this property set.

Differential Revision: https://phabricator.kde.org/D25968
2019-12-23 13:04:59 +01:00
Vlad Zahorodnii d394855536 Rename Toplevel::geom to Toplevel::m_frameGeometry
Summary: The new name better reflects what Toplevel::geom is.

Test Plan: Compiles, tests still pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25738
2019-12-04 15:47:15 +02:00
Vlad Zahorodnii e2f82d793b Use better name for geometryBeforeUpdateBlocking
Summary:
Rename geometryBeforeUpdateBlocking in order to better reflect that it
corresponds to the last frame geometry.

Test Plan: Compiles.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24658
2019-11-27 14:12:30 +02:00