Commit Graph

244 Commits (master)

Author SHA1 Message Date
Tiago Corrêa 2e93829259 [scripting] Make client.activities writable 2020-09-18 15:57:39 +00:00
Vlad Zahorodnii d3cca65d39 Implement the layer-shell v1 protocol
The layer-shell protocol allows wayland clients to create surfaces that
can be used for building desktop environment components such as panels,
notifications, etc.

The support for the plasma-shell protocol will be dropped once plasma in
all its entirety is ported to the layer-shell protocol.
2020-09-03 18:11:44 +00:00
Vlad Zahorodnii 085284921a Introduce a property to indicate if client is placeable
The new property indicates if the client can be placed. It can be used
by input-panel or layer-shell clients to opt out from window placement.
2020-09-03 18:11:44 +00:00
Vlad Zahorodnii a9fd5ac19f Move struts logic to AbstractClient 2020-09-03 18:11:44 +00:00
Marco Martin 97f4712f29 Fix size restore upon keyboard close in XdgSurfaceClient
in XdgSurfaceClient setFrameGeometry is async,
so we can't rely on it having the final value immediately.
make setVirtualKeyboardGeometry a virtual.
in the implementation on setVirtualKeyboardGeometry
use requestedFrameGeometry() instead of frameGeometry()
2020-09-01 08:58:46 +00:00
Vlad Zahorodnii d97f12c1c6 wayland: Expose tiled state to xdg-shell clients
A client-side decorated window could use this information to improve
management of edges, for example by providing inset resize handles, etc.
2020-08-24 20:49:40 +03:00
Vlad Zahorodnii 3e9b722f8c Explicitly indicate support for window rules
This way it's more difficult to overlook the case where a new client
type unexpectedly advertises that it supports window rules.
2020-08-20 16:18:59 +00:00
Vlad Zahorodnii 9a04442781 Add default handler for screen edge based activation
This change adds a default handle for screen edge based activation in
order to reduce the amount of boilerplate in client sub-classes that do
not support features such as auto-hiding, e.g. popups.
2020-08-20 12:49:59 +03:00
Vlad Zahorodnii b36b3c67d1 Provide default implementation for noborder functionality
This change adds a default implementation for no border functionality
in order to reduce the amount of boilerplate code in client sub-classes
that have no support for server-side decorations.
2020-08-20 12:49:57 +03:00
Vlad Zahorodnii 74da0bb701 Provide default implementation for AbstractClient::updateDecoration()
Not all client types support server-side decorations, for example it's
typically the case for popup windows. This change provides a default
implementation for the updateDecoration() method in order to reduce the
amount of boilerplate code in client types that have no support for ssd.
2020-08-20 12:48:00 +03:00
Vlad Zahorodnii 9e74199e27 Refactor color scheme related code
Currently, we have two functions that update the color scheme for a
client - updateColorScheme(QString) and updateColorScheme(). Even though
they both share the same name, they do different things. The first one
sets the specified color scheme, while the other determines the color
scheme preferred by the client and assigns it.

This change refactors the color scheme initialization code so we no
longer need those two methods. The setColorScheme() method sets the
specified color scheme, and the preferredColorScheme() method returns
the color scheme preferred by the client. Sub-classes of AbstractClient
can override the preferredColorScheme() method in order to add support
for platform-specific color scheme protocols.

The end result: color scheme related code is a bit more comprehensible.
2020-08-19 15:18:50 +00:00
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
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 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 cae9828471 Don't perform MouseActivateRaiseAndPassClick for topmost windows
Do nothing if the active window is already most recently raised one.
2020-07-15 12:17:46 +03: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
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
Vlad Zahorodnii 079f9890ad [scripting] Introduce writable frameGeometry property
Summary:
The geometry property has been deprecated for quite some time and its
usage in scripts is highly discouraged. Since AbstractClient overrides
the geometry property to make it writable, the same thing must be done
for the frameGeometry property.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29666
2020-05-12 08:35:18 +03:00
Vlad Zahorodnii 44143ef7ae Move core shade code to AbstractClient
Summary:
In order to allow shading wayland clients, this change moves core shade
code from X11Client to AbstractClient.

Test Plan: Shading still works on X11.

Reviewers: #kwin, cblack

Reviewed By: cblack

Subscribers: cblack, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29512
2020-05-07 22:03:31 +03: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
Benjamin Port 750dd068e5 [Wayland] Send stacking order event through plasma window management protocol
Summary: Depends on: D29054

Reviewers: zzag, davidedmundson, meven

Reviewed By: davidedmundson, meven

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29055
2020-04-27 09:31:29 +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
Carson Black 394b5082c2 [wayland] Broadcast application menu events
Summary:
Broadcasts application menu events to
clients listening to the PlasmaWindow interface.
Needs D27464.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27818
2020-03-06 19:48:06 -05: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 861883895d Introduce AbstractClient::destroyClient()
Summary:
The new method provides a generic way for destructing clients. Notice
that we can't just delete clients because we may need to discard
temporary window rules, which is usually done in destroyClient().

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27821
2020-03-04 14:40:57 +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 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
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 34df058e54 Make support for the minimized state optional
Summary:
In long term, we want to split XdgShellClient into several classes. One
class for xdg-toplevel clients, and the other one for xdg-popup clients.

xdg-popup clients are much simpler than xdg-toplevel clients, they can't
be maximized or shown in full screen mode, they can't be interactively
moved on the screen, and so on. In the end, we will have to plumb many
pure virtual methods, which looks a bit ugly.

This change makes support for the minimized state in AbstractClient
optional so we don't have to add those no-op methods and keep code more
or less "clean."

Test Plan: Compiles.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27163
2020-02-12 11:28:15 +02:00
Vlad Zahorodnii 4ec24bc43f Make support for full screen mode optional
Summary:
In long term, we want to split XdgShellClient into several classes. One
class for xdg-toplevel clients, and the other one for xdg-popup clients.

xdg-popup clients are much simpler than xdg-toplevel clients, they can't
be maximized or shown in full screen mode, they can't be interactively
moved on the screen, and so on. In the end, we will have to plumb many
pure virtual methods, which looks a bit ugly.

This change makes support for full screen mode in AbstractClient optional
so we don't have to add those no-op methods and keep code more or less
"clean."

Test Plan: Compiles.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27162
2020-02-12 11:28:15 +02:00
Vlad Zahorodnii 624317a78d Don't pass any arguments to AbstractClient::doSetDesktop()
Summary: We don't use them anywhere.

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27121
2020-02-12 11:00:25 +02:00
Vlad Zahorodnii a281bece6a Introduce AbstractClient::doSetDemandsAttention()
Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27119
2020-02-12 11:00:25 +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 74e04949d7 Merge branch 'Plasma/5.18' 2020-01-29 13:11:32 +02:00
Vlad Zahorodnii 3399a7db8a Document AbstractClient::isResize() and AbstractClient::isMove() 2020-01-28 22:18:57 +02:00
Vlad Zahorodnii 4979afbf7c Fix doxygen style
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26827
2020-01-22 11:54:07 +02:00
Vlad Zahorodnii f57470d1fd Capitilize "mode" in Sizemode enum
Summary: Capitalize "mode" to improve readability.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26826
2020-01-22 11:53:49 +02:00
Vlad Zahorodnii 8af3eef9cd [x11] Apply "Block compositing" rule right away
Summary:
When the user changes "Block compositing" rule, apply it immediately.

BUG: 415903

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26708
2020-01-16 17:33:27 +02:00
Vlad Zahorodnii 55b4912004 Update my email address 2020-01-14 18:17:18 +02:00
Vlad Zahorodnii eb186a78a1 Delete class forward declarations in utils.h 2019-11-27 15:54:08 +02:00
Vlad Zahorodnii 84d75cb567 [x11] Add support for _GTK_FRAME_EXTENTS
Summary:
KDE is known for having a strong view on the client-side decorations vs
server-side decorations issue. The main argument raised against CSD is
that desktop will look less consistent when clients start drawing window
decorations by themselves, which is somewhat true. It all ties to how
well each toolkit is integrated with the desktop environment.

KDE doesn't control the desktop market on Linux. Another big "player"
is GNOME. Both KDE and GNOME have very polarized views on in which
direction desktop should move forward. The KDE community is pushing more
toward server-side decorations while the GNOME community is pushing
more toward client-side decorations. Both communities have developed
great applications and it's not rare to see a GNOME application being
used in KDE Plasma. The only problem is that these different views are
not left behind the curtain and our users pay the price. Resizing GTK
clients in Plasma became practically impossible due to resize borders
having small hit area.

When a client draws its window decoration, it's more likely that it also
draws the drop-shadow around the decoration. The compositor must know
the extents of the shadow so things like snapping and so on work as
expected. And here lies the problem... While the xdg-shell protocol has
a way to specify such things, the NetWM spec doesn't have anything like
that. There's _GTK_FRAME_EXTENTS in the wild, however the problem with
it is that it's a proprietary atom, which is specific only to GTK apps.

Due to that, _GTK_FRAME_EXTENTS wasn't implemented because implementing
anything like that would require major changes in how we think about
geometry.

Recent xdg-shell window geometry patches adjusted geometry abstractions
in kwin to such a degree that it's very easy to add support for client
side decorated clients on X11. We just have to make sure that the
X11Client class provides correct buffer geometry and frame geometry when
the gtk frame extents are set.

Even though the X11 code is feature frozen, I still think it's worth
to have _GTK_FRAME_EXTENTS support in kwin because it will fix the resize
issues. Also, because KWin/Wayland is unfortunately far from becoming
default, it will help us with testing some implementation bits of the
window geometry from xdg-shell.

BUG: 390550
FIXED-IN: 5.18.0

Test Plan:
Things like quick tiling, maximizing, tiling scripts and so on work as
expected with GTK clients.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: cblack, trmdi, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24660
2019-11-27 14:12:30 +02:00
Vlad Zahorodnii 4fbb777a30 Store buffer geometry during geometry updates
Summary:
The stored buffer geometry can be useful for detecting whether the
buffer geometry has been changed.

Test Plan: Compiles.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24659
2019-11-27 14:12:30 +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
Vlad Zahorodnii fb2d4c113f Adjust scene for client-side decorated clients
Summary:
Currently our Scene is quite naive about geometry. It assumes that the
window frame wraps the attached buffer/client. While this is true for X11
clients, such geometry model is not suitable for client-side decorated
clients, in our case for xdg-shell clients that set window geometry
other than the bounding rectangle of the main surface.

In general, the proposed solution doesn't make any concrete assumptions
about the order between frame and buffer geometry, however we may still
need to reconsider the design of Scene once it starts to generate quads
for sub-surfaces.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Maniphest Tasks: T10867

Differential Revision: https://phabricator.kde.org/D24462
2019-11-27 14:12:30 +02:00
Yuri Chornoivan a853e3370a Fix minor typos 2019-11-26 19:48:29 +02:00
Vlad Zahorodnii 7d4471eba6 Rename geometry property to frameGeometry
Summary:
In order to properly implement xdg_surface.set_window_geometry we need
two kinds of geometry - frame and buffer. The frame geometry specifies
visible bounds of the client on the screen, excluding client-side drop
shadows. The buffer geometry specifies rectangle on the screen that the
attached buffer or x11 pixmap occupies on the screen.

This change renames the geometry property to frameGeometry in order to
reflect the new meaning assigned to it as well to make it easier to
differentiate between frame geometry and buffer geometry in the future.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24334
2019-10-02 11:46:37 +03:00
Vlad Zahorodnii f93875535c Update my last name 2019-09-29 17:03:25 +03:00
Vlad Zagorodniy bebe81209c Port QPA away from Wayland
Summary:
So far wayland was used by internal clients to submit raster buffers
and position themselves on the screen. While we didn't have issues with
submitting raster buffers, there were some problems with positioning
task switchers. Mostly, because we had effectively two paths that may
alter geometry.

A better approach to deal with internal clients is to let our QPA use
kwin core api directly. This way we can eliminate unnecessary roundtrips
as well make geometry handling much easier and comprehensible.

The last missing piece is shadows. Both Plasma::Dialog and Breeze widget
style use platform-specific APIs to set and unset shadows. We need to
add shadows API to KWindowSystem. Even though some internal clients lack
drop-shadows at the moment, I don't consider it to be a blocker. We can
add shadows back later on.

CCBUG: 386304

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Maniphest Tasks: T9600

Differential Revision: https://phabricator.kde.org/D22810
2019-09-23 17:28:56 +03:00
Frederik Gladhorn b64e67ce7c Remove disabled TabGroup feature
Summary:
This has been commented out since 2014, I doubt it will come back.
This is a big amount of code, maintenance will be easier without it.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: romangg, graesslin, kwin

Tags: #kwin, #documentation

Differential Revision: https://phabricator.kde.org/D23069
2019-09-14 10:58:48 +02:00