Commit graph

34 commits

Author SHA1 Message Date
Vlad Zahorodnii
0489d4a2f6 Merge Workspace::stackingOrder() and Workspace::xStackingOrder()
The Workspace has two stacks - one with managed windows and deleted
windows, the other includes windows from the first stack + override
redirect windows.

This change merges both stacks. It has several benefits - we will be
able to move window elevation stuff to Workspace and streamline the
scene stuff, for example it will be possible to have a root item.
Another advantage is that unmanaged windows will have
Window::stackingOrder() property set, which can be useful in the future
in qml effects or (qtquick scene if we push harder in that front).
Another advantage is that kwin will make less X11 calls when restacking
managed windows.
2022-05-12 14:59:55 +00:00
Vlad Zahorodnii
175037d9d1 Prefer the term "window" over "client" in Workspace 2022-04-25 11:33:55 +00:00
Vlad Zahorodnii
a21aa839b1 Rename X11Client to X11Window
The word "client" means different things in wayland and kwin. Use a
better word to refer to windows.
2022-04-23 07:55:51 +00:00
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.
2022-04-23 07:55:51 +00:00
Nils Fenner
b491aeb9ae Rename AbstractClient to Window 2022-04-22 17:39:12 +00:00
Vlad Zahorodnii
506863f97e Remove AbstractClient plumbing casts in src/layers.cpp 2022-04-18 11:47:56 +03:00
Nils Fenner
aaa429ee0a Merge Toplevel into AbstractClient
References issue #81
2022-04-18 07:42:11 +00:00
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.
2022-04-15 17:49:49 +03:00
Nils Fenner
d146a3d1dd Use Toplevel::isClient() to resolve AbstractClient type. 2022-04-14 13:50:12 +00:00
David Edmundson
6d33612967 Move session management to SessionManagement class
Right now Workspace and SessionManagement were entangled with
SessionManager being a dumb class that just signalled to Workspace to do
the work.

The code, however, lived in sm.cpp despite being part of workspace.

This commit is an initial cleanup to strip some X11 specific features
from Workspace and move towards having the right code in the right
files. It should hopefully help get us in the right direction we get
some wayland session management.

Behaviour should be unchanged.
2022-04-05 09:37:53 +00:00
Vlad Zahorodnii
e293972eaa Run clang-tidy with -checks=readability-braces-around-statements fixit
This fixes style issues in old code.
2022-03-28 10:54:11 +00:00
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
2022-03-25 13:25:15 +02:00
Vlad Zahorodnii
e2a393ce2d Move utils.h file to utils directory 2022-01-25 16:56:33 +00:00
Vlad Zahorodnii
f1e96676ef Remove boolean trap in AbstractClient::isShown()
Check shaded state where needed.
2021-11-24 08:11:35 +00:00
Vlad Zahorodnii
6d0cca5c7f Move all dirty region scene repaint scheduling to Scene
The Compositor contains nothing that can potentially get dirty and need
repainting.

As is, the advantages of this move aren't really noticeable, but it
makes sense with multiple scenes.

Backend parts are far from ideal, they can be improved later on as we
progress with the scene redesign.
2021-11-11 11:33:04 +02:00
Xaver Hugl
6ff4de2e05 port everything away from Q_FOREACH 2021-11-08 14:19:05 +00:00
Andy Gebauer
f7bd6ef6c1 Update layers.cpp to compile with clang + libcxx 2021-11-03 06:29:57 +00:00
Vlad Zahorodnii
507c5140b7 Port Workspace::topClientOnDesktop() to AbstractOutput 2021-08-29 21:55:07 +00:00
Vlad Zahorodnii
95e5f5fc1a Introduce Toplevel::output()
This is a little helper that can be very convenient with our transition
from int-based screen ids to AbstractOutput.

As is, the main issue with int screen ids is that they are extremely
dynamic.
2021-08-29 21:55:07 +00:00
Vlad Zahorodnii
212090d990 Add Toplevel.stackingOrder property
This primarily targets QML scripts.
2021-08-19 06:30:55 +00:00
Vlad Zahorodnii
42f2afd80d Port Workspace::findDesktop() to VirtualDesktop 2021-08-17 06:23:52 +00:00
Vlad Zahorodnii
b75f089981 Port Workspace::topClientOnDesktop() to VirtualDesktop
This patch has one behavioral change - raiseOrLowerClient() will not
work if the client is not on the current virtual desktop.

However, raiseOrLowerClient() can be called only in two cases:

* user triggers the raise or lower shortcut for the active client. Since
  the active client is on the current virtual desktop, it's not an issue

* an x11 window restacks itself. It makes no sense if an x11 window
  restacks itself while it's inactive or not on current virtual desktop.
  Also, the Opposite restack mode is rarely used, some window managers
  don't even bother implementing it. So, having such a constraint should
  not be a problem.

The main reason for not allowing raiseOrLowerClient() for windows that
are not on the current virtual desktop is that a window can be on
multiple virtual desktops. If a window is on A and B virtual desktops,
the only logical option is to toggle stacking position if the window is
on the current desktop. It's the only viable option as kwin does not
maintain per virtual desktop stacking order.
2021-08-17 06:23:52 +00:00
Vlad Zahorodnii
a13fd02ea8 Remove virtualdesktops.h include in toplevel.h
toplevel.h is included in many places. Changing virtualdesktops.h may
trigger rebuild of all kwin.

With this change, only cpp files that use virtualdesktops.h will need to
be recompiled.
2021-08-12 17:23:15 +00:00
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
2021-06-08 10:49:42 +03:00
Aleix Pol
ae01ed219c workspace: Unify client removal code
We have 2 equivalent code paths for x11 and wayland unnecessarily, unify
them under the same method.
Rename m_clients to m_x11Clients so that it's clear what the difference
is between m_clients and m_allClients.
2021-05-24 23:16:41 +00:00
Vlad Zahorodnii
7c0bb4180a Remove Workspace::updateClientLayer()
It's the same as calling AbstactClient::updateLayer()
2021-05-16 10:48:06 +00:00
Aleix Pol
035ea75ab7 Use qAsConst in fors when there's a risk for it to detach 2021-05-14 01:35:33 +02:00
Vlad Zahorodnii
e187e766b0 Only promote windows to upper layers if one of the group members is in fullscreen mode
We want panels to be behind fullscreen windows, but osd windows above
them. With the current layer promotion logic, the panel will be promoted
to the osd layer, which is undesirable. This change restores the old
behavior by allowing layer promotion only to ActiveLayer.

BUG: 436985
2021-05-12 17:02:04 +00:00
Vlad Zahorodnii
eef97904b6 Simplify Workspace::constrainedStackingOrder()
Workspace::constrainedStackingOrder() is a constant source of issues.
This change replaces the current logic that builds the stacking order to
hopefully make constrainedStackingOrder() less crashy.

With the new version, constrainedStackingOrder() doesn't perform layer
caching. On the other hand, it's quite rare to see apps in the wild that
have more than just 1 or 2 members in the window group.

BUG: 436095
2021-05-12 11:50:38 +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
9577423dfa Remove most_recently_raised micro optimization
This micro optimization is simply not worth having. raiseOrLowerClient()
is not in any hot path, besides that raiseClient() is not the only place
where a window can be raised above other windows. In addition to that,
the most_recently_raised check in raiseOrLowerClient() doesn't take into
account whether the cached window is on the current activity.
2021-05-10 19:49:34 +00:00
Harald Sitter
385ea10bef SCM_SILENT typo-- 2021-04-26 12:39:44 +02:00
Aleix Pol
618c330ca8 Do not attempt to compare iterators of potentially different containers
I got this crash after leaving my system unattended:
```
0  std::__atomic_base<int>::load(std::memory_order) const (this=0x0, __m=std::memory_order_relaxed) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/bits/atomic_base.h:426
1  QAtomicOps<int>::loadRelaxed<int>(std::atomic<int> const&) (_q_value=...) at /home/apol/devel/kde5/include/QtCore/qatomic_cxx11.h:239
2  QBasicAtomicInteger<int>::loadRelaxed() const (this=0x0) at /home/apol/devel/kde5/include/QtCore/qbasicatomic.h:107
3  QtPrivate::RefCount::isShared() const (this=0x0) at /home/apol/devel/kde5/include/QtCore/qrefcount.h:101
4  QMap<KWin::Group*, KWin::Layer>::detach() (this=0x7f1b577b7870 <qt_array+48>) at /home/apol/devel/kde5/include/QtCore/qmap.h:357
5  QMap<KWin::Group*, KWin::Layer>::find(KWin::Group* const&) (this=0x7f1b577b7870 <qt_array+48>, akey=<optimized out>) at /home/apol/devel/kde5/include/QtCore/qmap.h:861
6  KWin::Workspace::constrainedStackingOrder() (this=this@entry=0x564b368c6290) at /home/apol/devel/frameworks/kwin/src/layers.cpp:502
7  0x00007f1b5708d027 in KWin::Workspace::updateStackingOrder(bool) (this=0x564b368c6290, propagate_new_clients=false) at /home/apol/devel/frameworks/kwin/src/layers.cpp:110
8  0x00007f1b571629be in KWin::X11Client::setFrameGeometry(QRect const&, KWin::AbstractClient::ForceGeometry_t) (this=0x564b374b4e60, rect=<optimized out>, force=<optimized out>) at /home/apol/devel/frameworks/kwin/src/x11client.cpp:4193
9  0x00007f1b57003fbf in KWin::AbstractClient::blockGeometryUpdates(bool) (this=this@entry=0x564b374b4e60, block=<optimized out>) at /home/apol/devel/frameworks/kwin/src/abstract_client.cpp:871
10 0x00007f1b570054f1 in KWin::GeometryUpdatesBlocker::~GeometryUpdatesBlocker() (this=<optimized out>) at /home/apol/devel/frameworks/kwin/src/abstract_client.h:1334
11 KWin::AbstractClient::checkWorkspacePosition(QRect, int, QRect) (this=0x564b374b4e60, oldGeometry=..., oldDesktop=1, oldClientGeometry=...) at /home/apol/devel/frameworks/kwin/src/abstract_client.cpp:3189
12 0x00007f1b571409e0 in KWin::Workspace::updateClientArea(bool) (this=<optimized out>, this@entry=0x564b368c6290, force=false) at /home/apol/devel/frameworks/kwin/src/workspace.cpp:2234
13 0x00007f1b57138fc6 in KWin::Workspace::updateClientArea() (this=0x564b368c6290) at /home/apol/devel/frameworks/kwin/src/workspace.cpp:2243
14 KWin::Workspace::desktopResized() (this=0x564b368c6290) at /home/apol/devel/frameworks/kwin/src/workspace.cpp:1980
15 0x00007f1b57707806 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff671a2e50, r=0x564b368c6290, this=0x564b372f1860) at ../../include/QtCore/../../../../../devel/frameworks/qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:398
16 doActivate<false>(QObject*, int, void**) (sender=0x564b368a0fe0, signal_index=4, argv=0x7fff671a2e50) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qobject.cpp:3886
17 0x00007f1b57707806 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff671a2f30, r=0x564b368a0fe0, this=0x564b368a10f0) at ../../include/QtCore/../../../../../devel/frameworks/qt5/qtbase/src/corelib/kernel/qobjectdefs_impl.h:398
18 doActivate<false>(QObject*, int, void**) (sender=0x564b36775640, signal_index=3, argv=0x7fff671a2f30) at /home/apol/devel/frameworks/qt5/qtbase/src/corelib/kernel/qobject.cpp:3886
19 0x00007f1b4ee2f9c3 in KWin::DrmBackend::updateOutputs() (this=this@entry=0x564b36775640) at /home/apol/devel/frameworks/kwin/src/plugins/platforms/drm/drm_backend.cpp:374
20 0x00007f1b4ee31d54 in KWin::DrmBackend::openDrm()::$_2::operator()() const (this=<optimized out>) at /home/apol/devel/frameworks/kwin/src/plugins/platforms/drm/drm_backend.cpp:328
```
2021-03-01 15:11:52 +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 layers.cpp (Browse further)