82 Commits (00b211dcb149ea1e5466352657b0db283713b974)

Author SHA1 Message Date
Vlad Zahorodnii dee8a3b3a7 Clear decoration focus when window closes
If the window closes, we need to reset the focused decoration object.

BUG: 473244
1 year ago
Laurent Montel 86c6238cfa Don't use QtTest => use QTest + missing include 1 year ago
Vlad Zahorodnii 6b2f46ca1f autotests: Remove unused outputbackend.h includes 1 year ago
Xaver Hugl 6e9d5c2cc3 autotests: directly call setVirtualOutputs 1 year ago
Vlad Zahorodnii e0da725533 autotests: Fix Test::waitForWindowDestroyed
Before Deleted merge, it used to be equivalent to waiting until the
window is closed.

This fixes tests waiting until the window closing animation completes
and the Window object is destroyed.
1 year ago
Vlad Zahorodnii 70353d399d Drop Window::inputGeometry
It's been mostly superseded by Window::hitTest().
1 year ago
Vlad Zahorodnii e88a4e34a3 Remove some include_directories()
It seems we've settled on dir/dir/header.h includes, so let's use them
consistently.
2 years ago
Vlad Zahorodnii 8f21d444c6 Make Workspace::allClientList() return all windows
Currently windows are scattered in a few separate lists. If you need to
go through the windows, you have to do it piece by piece. On the other
hand, with the overhaul of window types, we've started converging
towards one universal type: Window. Keeping windows in the separate
buckets goes against this design.

Workspace::stackingOrder() already contains all windows. This change
repurposes Workspace::allClientList() from a list of "normal" windows to
all windows, i.e. Workspace::windows(), to be consistent.

There's one API change though. Scripting API will expose other window
types too. This is an intentional change so scripted effects could
operate with all windows. It also matches the current behavior observed
in libkwineffects, which exposes all windows as well.
2 years ago
Vlad Zahorodnii a2062090eb Rename interactive move resize lifecycle signals
Add the "interactive" word to be consistent and put "started",
"stepped", and "finished" at the end of signal names where they are more
expected.
2 years ago
Vlad Zahorodnii e0062f675d Port away from QRectF::contains()
QRectF::contains() considers right and bottom edges inside the
rectangle, but the relevant code has the opposite expectations.
2 years ago
Vlad Zahorodnii f71ee59a37 Port away from Cursor::setPos()
Use input device specific apis to change the position of the cursor. The
main reason to do so is to break the assumption that Cursor position is
the same as pointer position, which I would like to rely on later to
merge tablet and pointer cursors.
2 years ago
Xaver Hugl 3d1101d5ff autotests/integration: fix decoration input test 2 years ago
Vlad Zahorodnii 64a6a70b3e autotests: Use fewer Window::clientPos() 2 years ago
Vlad Zahorodnii 12acd9bb78 autotests: Port away from OutputBackend::setInitialWindowSize() 2 years ago
Vlad Zahorodnii b830d408af core: Rename Platform to OutputBackend 2 years ago
Vlad Zahorodnii 482741499d autotests: Reduce the number of "using namespace KWayland::Client"
KWayland::Client has ambiguous type names such as "Compositor" or
"Output". Use full types to improve code readability.
2 years ago
Vlad Zahorodnii 7fffe99328 build: Add -Wno-unused-parameter compiler option
Due to being a compositor, kwin has to conform to some certain
interfaces. It means a lot of virtual functions and function tables to
integrate with C APIs. Naturally, we not always want to use every
argument in such functions.

Since we get -Wunused-parameter from -Wall, we have to plumb those
unused arguments in order to suppress compiler warnings at the moment.

However, I don't think that extra work is worth it. We cannot change or
alter prototypes in any way to fix the warning the desired way. Q_UNUSED
and similar macros are not good indicators of whether an argument is
used too, we tend to overlook putting or removing those macros. I've
also noticed that Q_UNUSED are not used to guide us with the removal no
longer needed parameters.

Therefore, I think it's worth adding -Wno-unused-parameter compiler
option to stop the compiler producing warnings about unused parameters.
It changes nothing except that we don't need to put Q_UNUSED anymore,
which can be really cumbersome sometimes. Note that it doesn't affect
unused variables, you'll still get a -Wunused-variable compiler warning
if a variable is unused.
2 years ago
Vlad Zahorodnii 6d3f00e82c autotests: Remove QVERIFY(signalSpy.isValid())
We use the PMF syntax so the isValid() check is unnecessary as the
compiler will notify about wrong signal at compile time. It makes
writing autotests feel less boilerplaty.
2 years ago
Vlad Zahorodnii d2fb4147fc Move multi-purpose code in its own directory
Things such as Output, InputDevice and so on are made to be
multi-purpose. In order to make this separation more clear, this change
moves that code in the core directory. Some things still link to the
abstraction level above (kwin), they can be tackled in future refactors.
Ideally code in core/ should depend either on other code in core/ or
system libs.
2 years ago
Xaver Hugl cdf777663d autotests/integration: use std::unique_ptr for wayland surfaces 2 years ago
Vlad Zahorodnii e24ee60bb2 autotests: Remove Test::initWaylandWorkspace()
It reduces the amount of boilerplate code and makes startup sequence in
autotests similar to the one in kwin_wayland.
2 years ago
Xaver Hugl b6cf576efa move DecorationBridge singleton into Workspace 2 years ago
Vlad Zahorodnii 4bfb0acc17 Make Workspace track managed outputs
This change adjusts the window management abstractions in kwin for the
drm backend providing more than just "desktop" outputs.

Besides that, it has other potential benefits - for example, the
Workspace could start managing allocation of the placeholder output by
itself, thus leading to some simplifications in the drm backend. Another
is that it lets us move wayland code from the drm backend.
2 years ago
David Edmundson 7292af3d04 Use floating geometry throughout
With fractional scaling integer based logical geometry may not match
device pixels. Once we have a floating point base we can fix that. This
also is
important for our X11 scale override, with a scale of 2 we could
get logical sizes with halves.

We already have all input being floating point, this doubles down on it
for all remaining geometry.

- Outputs remain integer to ensure that any screen on the right remains
aligned.
 - Placement also remains integer based for now.
- Repainting is untouched as we always expand outwards
 			   (QRectF::toAdjustedRect().
 - Decoration is untouched for now
 - Rules are integer in the config, but floating in the adjusting/API
This should also be fine.

At some point we'll add a method to snap to the device pixel
grid. Effectively `round(value * dpr)  / dpr` though right now things
mostly work.

This also gets rid of a lot of hacks for QRect right and bottom which
are very
confusing.

Parts to watch out in the port are:
 QRectF::contains now includes edges
QRectF::right and bottom are now sane so previous hacks have to be
removed
 QRectF(QPoint, QPoint) behaves differently for the same reason
 QRectF::center too

In test results some adjusted values which are the result of
QRect.center because using QRectF's center should behave the same to the
user.
2 years ago
Vlad Zahorodnii 79e0051b04 autotests: Port more tests from obsolete Screens 2 years ago
Vlad Zahorodnii 2fdb55b199 Rename InternalWindow::internalWindow() to InternalWindow::handle()
internalWindow->handle() reads better than internalWindow->internalWindow()
2 years ago
Vlad Zahorodnii 5ee044e6fc Some client/toplevel -> window 2 years ago
Vlad Zahorodnii 22e5c8a260 autotests: client -> window 2 years ago
Vlad Zahorodnii 175037d9d1 Prefer the term "window" over "client" in Workspace 2 years ago
Vlad Zahorodnii fb4607f5a6 Rename InternalClient to InternalWindow
The word "client" means different things in wayland and kwin. Use a
better word to refer to windows.
2 years ago
Nils Fenner b491aeb9ae Rename AbstractClient to Window 2 years ago
Vlad Zahorodnii 8e7a8c5a11 Rename AbstractOutput to Output
AbstractOutput is not so Abstract and it's common to avoid the word
"Abstract" in class names as it doesn't contribute any new information.
It also significantly reduces the line width in some places.
2 years ago
Vlad Zahorodnii 7096e3ead8 Run clang-format
The .clang-format file is based on the one in ECM except the following
style options:

 - AlwaysBreakBeforeMultilineStrings
 - BinPackArguments
 - BinPackParameters
 - ColumnLimit
 - BreakBeforeBraces
 - KeepEmptyLinesAtTheStartOfBlocks
3 years ago
Julius Zint 270a963350 Migrate all autotest input simulation functions
[5/6] Make autotests create fake input devices

Migrate all input simulation functions from kwinApp()->platform()->...
to the their counter part in the Test namespace.
3 years ago
Vlad Zahorodnii 6432f29e9f autotests: Remove unused screenedge.h include 3 years ago
Vlad Zahorodnii 5420e11bd4 Make AbstractClient::titlebarPosition() return Qt::Edge
Conceptually, it's an edge, the titlebar can't be in a window corner.
3 years ago
Vlad Zahorodnii acb0683e0d wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.

The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.

At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.

If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.

If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.

Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.

BUG: 445259
3 years ago
Vlad Zahorodnii 200223e06e autotests: Prepend KWayland::Client:: to Surface
With a "Surface" type in kwin, KWayland::Client::Surface without fully
specified namespace will conflict with kwin's Surface type.

In some way, it also improves readability as it's clear where Surface
comes from.
3 years ago
Vlad Zahorodnii 543145e76f autotests: Port common screen check preamble to AbstractOutput 3 years ago
Vlad Zahorodnii 7016da39c8 Move active output tracking to workspace
Active output is a window management concept. It indicates what output
new windows have to be placed on if they have no output hint. So
Workspace seems to be a better place for it than the Screens class, which
is obsolete.
3 years ago
Vlad Zahorodnii b08807cc36 autotests: current abstract output 3 years ago
Vlad Zahorodnii 1b2c7b248b Run clazy with qt-keywords fixit
In C++20, there will be emit() class member, which can conflict with the
emit keyword. Given that, there are plans to enable QT_NO_KEYWORDS by
default in the future.

See also
https://lists.qt-project.org/pipermail/development/2020-February/038812.html
3 years ago
Vlad Zahorodnii 9a7ab8a62e Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.

At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.

It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.

This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.

With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().

To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.

It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().

The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.

Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
3 years ago
Vlad Zahorodnii edb7867ee9 Prepend "Interactive" to interactive move resize methods
This is to improve code readability and make it easier to differentiate
between methods that are used during interactive move-resize and normal
move-resize methods in the future.
3 years ago
Vlad Zahorodnii 282e0d1c4d autotests: Port the tests to new xdg-shell helpers 3 years ago
Aleix Pol a3d32fa836 Ensure we start our tests with wayland already initialised
When debugging modifier_only_shortcut_test in _waylandonly mode I saw
that it was failing, among other things, because some aspects were not
initialised.

This changes every test we have to run the new
Test::initWaylandWorkspace() that calls waylandServer()->initWorkspace()
but also makes sure that WaylandServer::initialized is emitted before we
proceed.
3 years ago
Vlad Zahorodnii 3788a8285d Remove QPointer from function prototypes in some input code
As it was pointed out in 6acf35e4cc, it is
better to return raw pointers than qpointers because returning a qpointer
is equivalent to constructing a new one.
4 years ago
Vlad Zahorodnii 3cdc97a4e9 Avoid converting socket name between QString and QByteArray back and forth
It only contributes overhead.
4 years ago
David Edmundson 30f9e2a570 [autotests] Fix decoration input test
QTRY_COMPARE doesn't work well with how we do our wayland event
dispatching.

We know the client hasn't processed any events yet, so we can safely do
a normal wait.
4 years ago
Vlad Zahorodnii 3805f212ec autotests: Remove XdgShellSurfaceType enum
Currently, it has only one item - XdgShellStable.
4 years ago