Commit graph

13 commits

Author SHA1 Message Date
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.
2021-05-25 06:17:41 +00:00
Vlad Zahorodnii
9be862999e Remove explicit repaint in InternalClient::commitGeometry()
The associated window item will schedule a repaint if needed.
2021-05-19 09:14:02 +03:00
Vlad Zahorodnii
5ece6d55d6 Replace Toplevel::clientContentPos() with a better solution
The Toplevel::clientContentPos() function is needed to map the surface
local coordinates to the global coordinates. But its name is highly
confusing as there's already a function with a similar name. This change
introduces a helper with a better name to fix the readability issue.
2021-05-17 06:32:21 +00:00
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.
2021-05-16 13:50:25 +03:00
Vlad Zahorodnii
3c2e1a71c4 Unvirtualize Toplevel::bufferGeometry()
This makes the implementation of the buffer geometry consistent with the
frame geometry and the client geometry and removes a virtual method call
from a few hot paths.
2021-05-16 10:48:41 +00:00
Vlad Zahorodnii
4ba249eee5 wayland: Signal about finished move/resize in destroyClient()
We need to emit the clientFinishUserMovedResized signal to notify
effects such as translucency that the interactive move-resize is
finished. Otherwise, the set() animation won't be cancelled and the
window will get stuck frozen.

BUG: 409376
2021-05-16 10:46:57 +00:00
Vlad Zahorodnii
e5799a2131 Remove force geometry flags
With the client-side decoration changes, kwin will properly determine
whether the window needs to be configured even if the frame geometry has
not changed.

This change slightly changes the semantics of the setFrameGeometry()
method. Prior to this, it was possible to force a geometry, i.e. block
other geometry updates, however such a behavior is counter-intuitive and
it exponentially increases the complexity of code.

As far as I know, the force flag was needed to propagate geometry
changes if the frame geometry doesn't change, but the client geometry
does. With the client-side decoration changes, the force flag is not
needed, as kwin now takes into account the client geometry and the frame
geometry when determining whether to send a configure event.
2021-05-14 07:00:20 +00:00
Vlad Zahorodnii
0de2b73393 Introduce transient constraints api in Workspace
Currently, the Workspace has no any api to constrain one window above
another. This results in having hacks such as keepDeletedTransientAbove()

This change introduces a basic api to constrain a given window above
another. It can be used for ensuring that transient windows are placed
above their parents. It also can be used for stacking the outline window
below the move-resize window.

Internal windows may also have transient parents. Because of that, this
change makes the workspace add internal clients to the stacking order by
default. The good thing about it is that it allows us unify some input
related code for "external" windows and internal windows.
2021-05-12 11:50:38 +00:00
Vlad Zahorodnii
77091f7fcb Remove manual discardWindowPixmap() calls in InternalClient
SurfaceItemInternal will discard the current pixmap if the buffer size
changes. Also, one of the goal of the scene redesign is to keep things
such as this out of Toplevel subclasses.
2021-05-07 17:34:31 +00:00
Vlad Zahorodnii
47113e09b8 scene: Introduce window items
Currently, dealing with sub-surfaces is very difficult due to the scene
design being heavily influenced by X11 requirements.

The goal of this change is to re-work scene abstractions to make improving
the wayland support easier.

The Item class is based on the QQuickItem class. My hope is that one day
we will be able to transition to QtQuick for painting scene, but in
meanwhile it makes more sense to have a minimalistic internal item class.

The WindowItem class represents a window. The SurfaceItem class represents
the contents of either an X11, or a Wayland, or an internal surface. The
DecorationItem and the ShadowItem class represent the server-side deco and
drop-shadow, respectively.

At the moment, the SurfaceItem is bound to the scene window, but the long
term plan is to break that connection so we could re-use the SurfaceItem
for things such as software cursors and drag-and-drop additional icons.

One of the responsibilities of the Item is to schedule repaints as needed.
Ideally, there shouldn't be any addRepaint() calls in the core code. The
Item class schedules repaints on geometry updates. In the future, it also
has to request an update if its opacity or visibility changes.
2021-03-31 13:56:55 +00:00
Kevin Ottens
c812ffbe1d Move basic activities support from X11Client to AbstractClient
We're now sharing most of the X11Client activity behavior accross all
clients. This allows to cleanup some of the existing virtuals and remove
quite a bit of code overalls.

Has to introduce an extra platform specific hook since X11Client
serializes the activity information in an atom and we will probably need
to do something similar on the Wayland platform at some point.

This allows us to start interacting with the activities with kwin
wayland. They are not restored properly accross sessions though since
nothing is really persisted and the session management still seems to
be amiss.
2021-03-09 15:22:55 +00:00
Vlad Zahorodnii
8570b64384 Rename visibleRect to visibleGeometry
"rect"s have their origin at the top-left corner of the frame. However,
visibleRect() returns a QRect that's in the global coordinates.
2021-02-16 06:56:04 +00:00
Vlad Zahorodnii
93e0265e4e Move source code to src/ directory
Once in a while, we receive complaints from other fellow KDE developers
about the file organization of kwin. This change addresses some of those
complaints by moving all of source code in a separate directory, src/,
thus making the project structure more traditional. Things such as tests
are kept in their own toplevel directories.

This change may wreak havoc on merge requests that add new files to kwin,
but if a patch modifies an already existing file, git should be smart
enough to figure out that the file has been relocated.

We may potentially split the src/ directory further to make navigating
the source code easier, but hopefully this is good enough already.
2021-02-10 15:31:43 +00:00
Renamed from internal_client.cpp (Browse further)