2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com>
|
|
|
|
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef KWIN_WORKSPACE_H
|
|
|
|
#define KWIN_WORKSPACE_H
|
|
|
|
|
2013-04-25 13:47:40 +00:00
|
|
|
// kwin
|
2014-12-02 09:39:38 +00:00
|
|
|
#include "options.h"
|
2019-07-29 19:24:43 +00:00
|
|
|
#include "sm.h"
|
2022-01-18 08:35:52 +00:00
|
|
|
#include "utils/common.h"
|
2013-04-25 13:47:40 +00:00
|
|
|
// Qt
|
2022-03-09 16:41:07 +00:00
|
|
|
#include <QStringList>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QVector>
|
2013-08-05 07:42:10 +00:00
|
|
|
// std
|
|
|
|
#include <functional>
|
2017-06-21 19:10:12 +00:00
|
|
|
#include <memory>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
class KConfig;
|
2013-08-06 08:27:49 +00:00
|
|
|
class KConfigGroup;
|
2007-04-29 17:35:43 +00:00
|
|
|
class KStartupInfo;
|
|
|
|
class KStartupInfoData;
|
2019-07-29 19:24:43 +00:00
|
|
|
class KStartupInfoId;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2013-04-30 11:06:46 +00:00
|
|
|
namespace Xcb
|
|
|
|
{
|
2017-06-21 19:10:12 +00:00
|
|
|
class Tree;
|
2013-04-30 11:06:46 +00:00
|
|
|
class Window;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
class Window;
|
2022-04-14 12:33:28 +00:00
|
|
|
class Output;
|
2020-07-20 08:07:08 +00:00
|
|
|
class ColorMapper;
|
2019-07-29 19:24:43 +00:00
|
|
|
class Compositor;
|
2019-10-31 13:20:42 +00:00
|
|
|
class Deleted;
|
|
|
|
class Group;
|
2022-04-22 17:45:19 +00:00
|
|
|
class InternalWindow;
|
2013-04-08 12:30:55 +00:00
|
|
|
class KillWindow;
|
2013-04-25 15:21:54 +00:00
|
|
|
class ShortcutDialog;
|
2019-10-31 13:20:42 +00:00
|
|
|
class Unmanaged;
|
2012-08-19 10:00:53 +00:00
|
|
|
class UserActionsMenu;
|
2021-08-13 08:41:57 +00:00
|
|
|
class VirtualDesktop;
|
2019-09-24 08:48:08 +00:00
|
|
|
class X11Client;
|
2014-09-02 16:46:07 +00:00
|
|
|
class X11EventFilter;
|
2014-03-20 08:19:53 +00:00
|
|
|
enum class Predicate;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-02-20 08:33:36 +00:00
|
|
|
class KWIN_EXPORT Workspace : public QObject
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2020-04-02 11:44:27 +00:00
|
|
|
explicit Workspace();
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~Workspace() override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
static Workspace *self()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return _self;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool workspaceEvent(xcb_generic_event_t *);
|
|
|
|
bool workspaceEvent(QEvent *);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
bool hasClient(const Window *);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-03-20 08:19:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Finds the first Client matching the condition expressed by passed in @p func.
|
|
|
|
*
|
|
|
|
* Internally findClient uses the std::find_if algorithm and that determines how the function
|
|
|
|
* needs to be implemented. An example usage for finding a Client with a matching windowId
|
|
|
|
* @code
|
|
|
|
* xcb_window_t w; // our test window
|
2019-09-24 08:48:08 +00:00
|
|
|
* X11Client *client = findClient([w](const X11Client *c) -> bool {
|
2014-03-20 08:19:53 +00:00
|
|
|
* return c->window() == w;
|
|
|
|
* });
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* For the standard cases of matching the window id with one of the Client's windows use
|
|
|
|
* the simplified overload method findClient(Predicate, xcb_window_t). Above example
|
|
|
|
* can be simplified to:
|
|
|
|
* @code
|
|
|
|
* xcb_window_t w; // our test window
|
2019-09-24 08:48:08 +00:00
|
|
|
* X11Client *client = findClient(Predicate::WindowMatch, w);
|
2014-03-20 08:19:53 +00:00
|
|
|
* @endcode
|
|
|
|
*
|
2019-09-24 08:48:08 +00:00
|
|
|
* @param func Unary function that accepts a X11Client *as argument and
|
2014-03-20 08:19:53 +00:00
|
|
|
* returns a value convertible to bool. The value returned indicates whether the
|
2019-09-24 08:48:08 +00:00
|
|
|
* X11Client *is considered a match in the context of this function.
|
2014-03-20 08:19:53 +00:00
|
|
|
* The function shall not modify its argument.
|
|
|
|
* This can either be a function pointer or a function object.
|
2019-09-24 08:48:08 +00:00
|
|
|
* @return KWin::X11Client *The found Client or @c null
|
2014-03-20 08:19:53 +00:00
|
|
|
* @see findClient(Predicate, xcb_window_t)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-03-23 10:13:38 +00:00
|
|
|
X11Client *findClient(std::function<bool(const X11Client *)> func) const;
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *findAbstractClient(std::function<bool(const Window *)> func) const;
|
|
|
|
Window *findAbstractClient(const QUuid &internalId) const;
|
2014-03-20 08:19:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Finds the Client matching the given match @p predicate for the given window.
|
|
|
|
*
|
|
|
|
* @param predicate Which window should be compared
|
|
|
|
* @param w The window id to test against
|
2019-09-24 08:48:08 +00:00
|
|
|
* @return KWin::X11Client *The found Client or @c null
|
|
|
|
* @see findClient(std::function<bool (const X11Client *)>)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *findClient(Predicate predicate, xcb_window_t w) const;
|
2022-03-23 10:13:38 +00:00
|
|
|
void forEachClient(std::function<void(X11Client *)> func);
|
2022-04-22 17:39:12 +00:00
|
|
|
void forEachAbstractClient(std::function<void(Window *)> func);
|
2022-03-23 10:13:38 +00:00
|
|
|
Unmanaged *findUnmanaged(std::function<bool(const Unmanaged *)> func) const;
|
2014-03-20 06:52:18 +00:00
|
|
|
/**
|
|
|
|
* @brief Finds the Unmanaged with the given window id.
|
|
|
|
*
|
|
|
|
* @param w The window id to search for
|
|
|
|
* @return KWin::Unmanaged* Found Unmanaged or @c null if there is no Unmanaged with given Id.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2014-03-20 06:52:18 +00:00
|
|
|
Unmanaged *findUnmanaged(xcb_window_t w) const;
|
2022-03-23 10:13:38 +00:00
|
|
|
void forEachUnmanaged(std::function<void(Unmanaged *)> func);
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *findToplevel(std::function<bool(const Window *)> func) const;
|
|
|
|
void forEachToplevel(std::function<void(Window *)> func);
|
2020-07-23 11:13:22 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *findToplevel(const QUuid &internalId) const;
|
2020-07-23 11:13:22 +00:00
|
|
|
|
2016-03-04 08:42:33 +00:00
|
|
|
/**
|
2022-04-22 17:39:12 +00:00
|
|
|
* @brief Finds a Window for the internal window @p w.
|
2016-03-04 08:42:33 +00:00
|
|
|
*
|
|
|
|
* Internal window means a window created by KWin itself. On X11 this is an Unmanaged
|
2019-08-30 21:36:58 +00:00
|
|
|
* and mapped by the window id, on Wayland a XdgShellClient mapped on the internal window id.
|
2016-03-04 08:42:33 +00:00
|
|
|
*
|
2022-04-22 17:39:12 +00:00
|
|
|
* @returns Window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *findInternal(QWindow *w) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
QRect clientArea(clientAreaOption, const Output *output, const VirtualDesktop *desktop) const;
|
2022-04-22 17:39:12 +00:00
|
|
|
QRect clientArea(clientAreaOption, const Window *window) const;
|
|
|
|
QRect clientArea(clientAreaOption, const Window *window, const Output *output) const;
|
|
|
|
QRect clientArea(clientAreaOption, const Window *window, const QPoint &pos) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2021-08-30 07:52:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the geometry of this Workspace, i.e. the bounding rectangle of all outputs.
|
|
|
|
*/
|
|
|
|
QRect geometry() const;
|
2021-08-21 17:46:51 +00:00
|
|
|
QRegion restrictedMoveArea(const VirtualDesktop *desktop, StrutAreas areas = StrutAreaAll) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
bool initializing() const;
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
Output *activeOutput() const;
|
|
|
|
void setActiveOutput(Output *output);
|
2021-08-28 18:58:29 +00:00
|
|
|
void setActiveOutput(const QPoint &pos);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Returns the active client, i.e. the client that has the focus (or None
|
|
|
|
* if no client has the focus)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *activeClient() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Client that was activated, but it's not yet really activeClient(), because
|
|
|
|
* we didn't process yet the matching FocusIn event. Used mostly in focus
|
|
|
|
* stealing prevention code.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *mostRecentlyActivatedClient() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *clientUnderMouse(Output *output) const;
|
2012-02-13 22:50:49 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void activateClient(Window *, bool force = false);
|
|
|
|
bool requestFocus(Window *c, bool force = false);
|
2014-03-20 12:39:00 +00:00
|
|
|
enum ActivityFlag {
|
|
|
|
ActivityFocus = 1 << 0, // focus the window
|
|
|
|
ActivityFocusForce = 1 << 1 | ActivityFocus, // focus even if Dock etc.
|
|
|
|
ActivityRaise = 1 << 2 // raise the window
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(ActivityFlags, ActivityFlag)
|
2022-04-22 17:39:12 +00:00
|
|
|
bool takeActivity(Window *c, ActivityFlags flags);
|
|
|
|
bool allowClientActivation(const Window *c, xcb_timestamp_t time = -1U, bool focus_in = false,
|
2011-01-30 14:34:42 +00:00
|
|
|
bool ignore_desktop = false);
|
2020-07-22 11:00:11 +00:00
|
|
|
bool restoreFocus();
|
2022-04-22 17:39:12 +00:00
|
|
|
void gotFocusIn(const Window *);
|
|
|
|
void setShouldGetFocus(Window *);
|
|
|
|
bool activateNextClient(Window *c);
|
2022-03-23 10:13:38 +00:00
|
|
|
bool focusChangeEnabled()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return block_focus == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-04-18 12:28:11 +00:00
|
|
|
* Indicates that the client c is being moved or resized by the user.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
void setMoveResizeClient(Window *c);
|
|
|
|
|
|
|
|
QRect adjustClientArea(Window *client, const QRect &area) const;
|
|
|
|
QPoint adjustClientPosition(Window *c, QPoint pos, bool unrestricted, double snapAdjust = 1.0);
|
|
|
|
QRect adjustClientSize(Window *c, QRect moveResizeGeom, Gravity gravity);
|
|
|
|
void raiseClient(Window *c, bool nogroup = false);
|
|
|
|
void lowerClient(Window *c, bool nogroup = false);
|
|
|
|
void raiseClientRequest(Window *c, NET::RequestSource src = NET::FromApplication, xcb_timestamp_t timestamp = 0);
|
2019-09-24 08:48:08 +00:00
|
|
|
void lowerClientRequest(X11Client *c, NET::RequestSource src, xcb_timestamp_t timestamp);
|
2022-04-22 17:39:12 +00:00
|
|
|
void lowerClientRequest(Window *c);
|
|
|
|
void restackClientUnderActive(Window *);
|
|
|
|
void restack(Window *c, Window *under, bool force = false);
|
|
|
|
void raiseOrLowerClient(Window *);
|
2011-01-30 14:34:42 +00:00
|
|
|
void resetUpdateToolWindowsTimer();
|
2019-09-24 08:48:08 +00:00
|
|
|
void restoreSessionStackingOrder(X11Client *c);
|
2011-01-30 14:34:42 +00:00
|
|
|
void updateStackingOrder(bool propagate_new_clients = false);
|
|
|
|
void forceRestacking();
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void constrain(Window *below, Window *above);
|
|
|
|
void unconstrain(Window *below, Window *above);
|
2021-05-09 15:07:36 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void clientHidden(Window *);
|
|
|
|
void clientAttentionChanged(Window *c, bool set);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2011-02-27 08:25:45 +00:00
|
|
|
/**
|
|
|
|
* @return List of clients currently managed by Workspace
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-03-23 10:13:38 +00:00
|
|
|
const QList<X11Client *> &clientList() const
|
|
|
|
{
|
2021-05-24 16:01:49 +00:00
|
|
|
return m_x11Clients;
|
2011-02-27 08:25:45 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return List of unmanaged "clients" currently registered in Workspace
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-03-23 10:13:38 +00:00
|
|
|
const QList<Unmanaged *> &unmanagedList() const
|
|
|
|
{
|
2020-10-09 15:49:32 +00:00
|
|
|
return m_unmanaged;
|
2011-02-27 08:25:45 +00:00
|
|
|
}
|
2011-08-21 19:50:23 +00:00
|
|
|
/**
|
|
|
|
* @return List of deleted "clients" currently managed by Workspace
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-03-23 10:13:38 +00:00
|
|
|
const QList<Deleted *> &deletedList() const
|
|
|
|
{
|
2011-08-21 19:50:23 +00:00
|
|
|
return deleted;
|
|
|
|
}
|
2015-09-18 11:44:54 +00:00
|
|
|
/**
|
|
|
|
* @returns List of all clients (either X11 or Wayland) currently managed by Workspace
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
const QList<Window *> allClientList() const
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
2015-09-18 11:44:54 +00:00
|
|
|
return m_allClients;
|
|
|
|
}
|
2011-02-27 08:25:45 +00:00
|
|
|
|
2019-08-26 07:44:04 +00:00
|
|
|
/**
|
|
|
|
* @returns List of all internal clients currently managed by Workspace
|
|
|
|
*/
|
2022-04-22 17:45:19 +00:00
|
|
|
const QList<InternalWindow *> &internalClients() const
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
2019-08-26 07:44:04 +00:00
|
|
|
return m_internalClients;
|
|
|
|
}
|
|
|
|
|
2013-02-08 19:59:35 +00:00
|
|
|
void stackScreenEdgesUnderOverrideRedirect();
|
|
|
|
|
2019-10-31 16:16:53 +00:00
|
|
|
SessionManager *sessionManager() const;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2022-04-22 17:39:12 +00:00
|
|
|
QPoint cascadeOffset(const Window *c) const;
|
2012-08-25 16:20:34 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
2020-06-12 13:50:24 +00:00
|
|
|
QTimer *m_quickTileCombineTimer;
|
|
|
|
QuickTileMode m_lastTilingMode;
|
2011-04-28 09:16:27 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
//-------------------------------------------------
|
|
|
|
// Unsorted
|
|
|
|
|
|
|
|
public:
|
2013-02-12 23:40:11 +00:00
|
|
|
bool isOnCurrentHead();
|
2011-09-30 11:22:39 +00:00
|
|
|
// True when performing Workspace::updateClientArea().
|
|
|
|
// The calls below are valid only in that case.
|
|
|
|
bool inUpdateClientArea() const;
|
2021-08-21 17:46:51 +00:00
|
|
|
QRegion previousRestrictedMoveArea(const VirtualDesktop *desktop, StrutAreas areas = StrutAreaAll) const;
|
2022-04-14 12:33:28 +00:00
|
|
|
QHash<const Output *, QRect> previousScreenSizes() const;
|
2011-09-30 12:50:18 +00:00
|
|
|
int oldDisplayWidth() const;
|
|
|
|
int oldDisplayHeight() const;
|
2011-09-30 11:22:39 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Returns the list of clients sorted in stacking order, with topmost client
|
|
|
|
* at the last position
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
const QList<Window *> &stackingOrder() const;
|
|
|
|
QList<Window *> xStackingOrder() const;
|
|
|
|
QList<Window *> unconstrainedStackingOrder() const;
|
Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example
QList<QWeakPointer<TabBoxClient>> TabBoxClientList
in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?
Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.
So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.
Test Plan: Compiles.
Reviewers: #kwin
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24950
2019-10-16 09:11:04 +00:00
|
|
|
QList<X11Client *> ensureStackingOrder(const QList<X11Client *> &clients) const;
|
2022-04-22 17:39:12 +00:00
|
|
|
QList<Window *> ensureStackingOrder(const QList<Window *> &clients) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *topClientOnDesktop(VirtualDesktop *desktop, Output *output = nullptr, bool unconstrained = false,
|
2021-08-13 08:41:57 +00:00
|
|
|
bool only_normal = true) const;
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *findDesktop(bool topmost, VirtualDesktop *desktop) const;
|
|
|
|
void sendClientToDesktop(Window *c, int desktop, bool dont_activate);
|
|
|
|
void windowToPreviousDesktop(Window *c);
|
|
|
|
void windowToNextDesktop(Window *c);
|
|
|
|
void sendClientToOutput(Window *client, Output *output);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void addManualOverlay(xcb_window_t id)
|
|
|
|
{
|
2018-08-24 21:10:48 +00:00
|
|
|
manual_overlays << id;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
void removeManualOverlay(xcb_window_t id)
|
|
|
|
{
|
2018-08-24 21:10:48 +00:00
|
|
|
manual_overlays.removeOne(id);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Shows the menu operations menu for the client and makes it active if
|
|
|
|
* it's not already.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
void showWindowMenu(const QRect &pos, Window *cl);
|
2022-03-23 10:13:38 +00:00
|
|
|
const UserActionsMenu *userActionsMenu() const
|
|
|
|
{
|
2012-08-19 10:00:53 +00:00
|
|
|
return m_userActionsMenu;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void showApplicationMenu(const QRect &pos, Window *c, int actionId);
|
2017-01-11 09:21:03 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void updateMinimizedOfTransients(Window *);
|
|
|
|
void updateOnAllDesktopsOfTransients(Window *);
|
2013-04-30 13:41:59 +00:00
|
|
|
void checkTransients(xcb_window_t w);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
SessionInfo *takeSessionInfo(X11Client *);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
// D-Bus interface
|
2012-03-04 14:13:22 +00:00
|
|
|
QString supportInformation() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
Output *nextOutput(Output *reference) const;
|
|
|
|
Output *previousOutput(Output *reference) const;
|
|
|
|
void switchToOutput(Output *output);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-02-04 14:11:42 +00:00
|
|
|
/**
|
|
|
|
* Set "Show Desktop" status
|
|
|
|
*
|
|
|
|
* @param showing @c true to show the desktop, @c false to restore the window positions
|
|
|
|
* @param animated @c true if the "Show Desktop Animation" should be played, otherwise @c false
|
|
|
|
*/
|
|
|
|
void setShowingDesktop(bool showing, bool animated = true);
|
2011-01-30 14:34:42 +00:00
|
|
|
bool showingDesktop() const;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void removeX11Client(X11Client *); // Only called from X11Client::destroyClient() or X11Client::releaseWindow()
|
2022-04-22 17:39:12 +00:00
|
|
|
void setActiveClient(Window *);
|
2022-03-23 10:13:38 +00:00
|
|
|
Group *findGroup(xcb_window_t leader) const;
|
|
|
|
void addGroup(Group *group);
|
|
|
|
void removeGroup(Group *group);
|
|
|
|
Group *findClientLeaderGroup(const X11Client *c) const;
|
2022-04-04 22:53:48 +00:00
|
|
|
int unconstainedStackingOrderIndex(const X11Client *c) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void removeUnmanaged(Unmanaged *); // Only called from Unmanaged::release()
|
|
|
|
void removeDeleted(Deleted *);
|
2022-04-22 17:39:12 +00:00
|
|
|
void addDeleted(Deleted *, Window *);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool checkStartupNotification(xcb_window_t w, KStartupInfoId &id, KStartupInfoData &data);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
void focusToNull(); // SELI TODO: Public?
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void clientShortcutUpdated(Window *c);
|
|
|
|
bool shortcutAvailable(const QKeySequence &cut, Window *ignore = nullptr) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
bool globalShortcutsDisabled() const;
|
|
|
|
void disableGlobalShortcutsForClient(bool disable);
|
|
|
|
|
|
|
|
void setWasUserInteraction();
|
|
|
|
bool wasUserInteraction() const;
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
int packPositionLeft(const Window *client, int oldX, bool leftEdge) const;
|
|
|
|
int packPositionRight(const Window *client, int oldX, bool rightEdge) const;
|
|
|
|
int packPositionUp(const Window *client, int oldY, bool topEdge) const;
|
|
|
|
int packPositionDown(const Window *client, int oldY, bool bottomEdge) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
void cancelDelayFocus();
|
2022-04-22 17:39:12 +00:00
|
|
|
void requestDelayFocus(Window *);
|
2015-01-28 23:14:47 +00:00
|
|
|
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* updates the mouse position to track whether a focus follow mouse focus change was caused by
|
|
|
|
* an actual mouse move
|
|
|
|
* is esp. called on enter/motion events of inactive windows
|
|
|
|
* since an active window doesn't receive mouse events, it must also be invoked if a (potentially)
|
|
|
|
* active window might be moved/resize away from the cursor (causing a leave event)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-03-23 10:13:38 +00:00
|
|
|
void updateFocusMousePosition(const QPoint &pos);
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint focusMousePosition() const;
|
|
|
|
|
2019-04-18 12:28:11 +00:00
|
|
|
/**
|
|
|
|
* Returns a client that is currently being moved or resized by the user.
|
|
|
|
*
|
|
|
|
* If none of clients is being moved or resized, @c null will be returned.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *moveResizeClient()
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
2011-06-23 10:09:17 +00:00
|
|
|
return movingClient;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2017-06-21 19:10:12 +00:00
|
|
|
void markXStackingOrderAsDirty();
|
|
|
|
|
2017-07-18 19:12:37 +00:00
|
|
|
void quickTileWindow(QuickTileMode mode);
|
|
|
|
|
2017-07-20 04:58:35 +00:00
|
|
|
enum Direction {
|
|
|
|
DirectionNorth,
|
|
|
|
DirectionEast,
|
|
|
|
DirectionSouth,
|
|
|
|
DirectionWest
|
|
|
|
};
|
|
|
|
void switchWindow(Direction direction);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
ShortcutDialog *shortcutDialog() const
|
|
|
|
{
|
2017-07-22 10:49:57 +00:00
|
|
|
return client_keys_dialog;
|
|
|
|
}
|
|
|
|
|
2019-08-26 07:44:04 +00:00
|
|
|
/**
|
|
|
|
* Adds the internal client to Workspace.
|
|
|
|
*
|
|
|
|
* This method will be called by InternalClient when it's mapped.
|
|
|
|
*
|
|
|
|
* @see internalClientAdded
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-04-22 17:45:19 +00:00
|
|
|
void addInternalClient(InternalWindow *client);
|
2019-08-26 07:44:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the internal client from Workspace.
|
|
|
|
*
|
|
|
|
* This method is meant to be called only by InternalClient.
|
|
|
|
*
|
|
|
|
* @see internalClientRemoved
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-04-22 17:45:19 +00:00
|
|
|
void removeInternalClient(InternalWindow *client);
|
2019-08-26 07:44:04 +00:00
|
|
|
|
2022-04-04 22:53:48 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Used by session management
|
|
|
|
*/
|
|
|
|
void setInitialDesktop(int desktop);
|
|
|
|
|
2013-07-22 14:07:39 +00:00
|
|
|
public Q_SLOTS:
|
2022-04-22 17:39:12 +00:00
|
|
|
void performWindowOperation(KWin::Window *c, Options::WindowOperation op);
|
2011-01-30 14:34:42 +00:00
|
|
|
// Keybindings
|
2022-03-23 10:13:38 +00:00
|
|
|
// void slotSwitchToWindow( int );
|
2021-08-17 07:19:46 +00:00
|
|
|
void slotWindowToDesktop(VirtualDesktop *desktop);
|
2011-02-16 18:23:54 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
// void slotWindowToListPosition( int );
|
2011-02-16 18:23:54 +00:00
|
|
|
void slotSwitchToScreen();
|
|
|
|
void slotWindowToScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
void slotSwitchToNextScreen();
|
|
|
|
void slotWindowToNextScreen();
|
2013-05-19 12:23:49 +00:00
|
|
|
void slotSwitchToPrevScreen();
|
|
|
|
void slotWindowToPrevScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
void slotToggleShowDesktop();
|
|
|
|
|
|
|
|
void slotWindowMaximize();
|
|
|
|
void slotWindowMaximizeVertical();
|
|
|
|
void slotWindowMaximizeHorizontal();
|
|
|
|
void slotWindowMinimize();
|
|
|
|
void slotWindowShade();
|
|
|
|
void slotWindowRaise();
|
|
|
|
void slotWindowLower();
|
|
|
|
void slotWindowRaiseOrLower();
|
|
|
|
void slotActivateAttentionWindow();
|
2021-09-20 13:14:24 +00:00
|
|
|
|
|
|
|
void slotWindowCenter();
|
|
|
|
|
2021-10-04 16:20:10 +00:00
|
|
|
void slotWindowMoveLeft();
|
|
|
|
void slotWindowMoveRight();
|
|
|
|
void slotWindowMoveUp();
|
|
|
|
void slotWindowMoveDown();
|
|
|
|
void slotWindowExpandHorizontal();
|
|
|
|
void slotWindowExpandVertical();
|
2011-01-30 14:34:42 +00:00
|
|
|
void slotWindowShrinkHorizontal();
|
|
|
|
void slotWindowShrinkVertical();
|
|
|
|
|
2011-08-19 19:53:30 +00:00
|
|
|
void slotIncreaseWindowOpacity();
|
|
|
|
void slotLowerWindowOpacity();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void slotWindowOperations();
|
|
|
|
void slotWindowClose();
|
|
|
|
void slotWindowMove();
|
|
|
|
void slotWindowResize();
|
|
|
|
void slotWindowAbove();
|
|
|
|
void slotWindowBelow();
|
|
|
|
void slotWindowOnAllDesktops();
|
|
|
|
void slotWindowFullScreen();
|
|
|
|
void slotWindowNoBorder();
|
|
|
|
|
|
|
|
void slotWindowToNextDesktop();
|
|
|
|
void slotWindowToPreviousDesktop();
|
|
|
|
void slotWindowToDesktopRight();
|
|
|
|
void slotWindowToDesktopLeft();
|
|
|
|
void slotWindowToDesktopUp();
|
|
|
|
void slotWindowToDesktopDown();
|
|
|
|
|
|
|
|
void reconfigure();
|
|
|
|
void slotReconfigure();
|
|
|
|
|
|
|
|
void slotKillWindow();
|
|
|
|
|
|
|
|
void slotSetupWindowShortcut();
|
|
|
|
void setupWindowShortcutDone(bool);
|
|
|
|
|
|
|
|
void updateClientArea();
|
|
|
|
|
2013-07-22 14:07:39 +00:00
|
|
|
private Q_SLOTS:
|
2011-01-30 14:34:42 +00:00
|
|
|
void desktopResized();
|
2014-06-15 12:07:44 +00:00
|
|
|
void selectWmInputEventMask();
|
2011-01-30 14:34:42 +00:00
|
|
|
void slotUpdateToolWindows();
|
|
|
|
void delayFocus();
|
|
|
|
void slotReloadConfig();
|
|
|
|
void updateCurrentActivity(const QString &new_activity);
|
2012-11-16 07:23:47 +00:00
|
|
|
// virtual desktop handling
|
|
|
|
void slotCurrentDesktopChanged(uint oldDesktop, uint newDesktop);
|
2022-03-22 22:34:52 +00:00
|
|
|
void slotCurrentDesktopChanging(uint currentDesktop, QPointF delta);
|
|
|
|
void slotCurrentDesktopChangingCancelled();
|
2021-08-21 17:46:51 +00:00
|
|
|
void slotDesktopAdded(VirtualDesktop *desktop);
|
|
|
|
void slotDesktopRemoved(VirtualDesktop *desktop);
|
2022-04-14 12:33:28 +00:00
|
|
|
void slotOutputEnabled(Output *output);
|
|
|
|
void slotOutputDisabled(Output *output);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2012-04-13 09:27:50 +00:00
|
|
|
/**
|
|
|
|
* Emitted after the Workspace has setup the complete initialization process.
|
|
|
|
* This can be used to connect to for performing post-workspace initialization.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-04-13 09:27:50 +00:00
|
|
|
void workspaceInitialized();
|
2021-11-09 10:38:17 +00:00
|
|
|
void geometryChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
// Signals required for the scripting interface
|
2022-04-22 17:39:12 +00:00
|
|
|
void desktopPresenceChanged(KWin::Window *, int);
|
2021-11-09 10:51:30 +00:00
|
|
|
void currentActivityChanged();
|
2022-04-22 17:39:12 +00:00
|
|
|
void currentDesktopChanged(int, KWin::Window *);
|
|
|
|
void currentDesktopChanging(uint currentDesktop, QPointF delta, KWin::Window *); // for realtime animations
|
2022-03-22 22:34:52 +00:00
|
|
|
void currentDesktopChangingCancelled();
|
2022-04-22 17:39:12 +00:00
|
|
|
void clientAdded(KWin::Window *);
|
|
|
|
void clientRemoved(KWin::Window *);
|
|
|
|
void clientActivated(KWin::Window *);
|
|
|
|
void clientDemandsAttentionChanged(KWin::Window *, bool);
|
|
|
|
void clientMinimizedChanged(KWin::Window *);
|
2022-03-23 10:13:38 +00:00
|
|
|
void groupAdded(KWin::Group *);
|
|
|
|
void unmanagedAdded(KWin::Unmanaged *);
|
|
|
|
void unmanagedRemoved(KWin::Unmanaged *);
|
|
|
|
void deletedRemoved(KWin::Deleted *);
|
2011-07-13 09:36:49 +00:00
|
|
|
void configChanged();
|
2022-02-04 14:11:42 +00:00
|
|
|
void showingDesktopChanged(bool showing, bool animated);
|
2013-01-01 00:47:16 +00:00
|
|
|
/**
|
2020-11-05 14:52:46 +00:00
|
|
|
* This signal is emitted when the stacking order changed, i.e. a window is risen
|
2013-01-01 00:47:16 +00:00
|
|
|
* or lowered
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-01-01 00:47:16 +00:00
|
|
|
void stackingOrderChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2019-08-26 07:44:04 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted whenever an internal client is created.
|
|
|
|
*/
|
2022-04-22 17:45:19 +00:00
|
|
|
void internalClientAdded(KWin::InternalWindow *client);
|
2019-08-26 07:44:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This signal is emitted whenever an internal client gets removed.
|
|
|
|
*/
|
2022-04-22 17:45:19 +00:00
|
|
|
void internalClientRemoved(KWin::InternalWindow *client);
|
2019-08-26 07:44:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
|
|
|
void init();
|
2020-07-20 08:07:08 +00:00
|
|
|
void initializeX11();
|
|
|
|
void cleanupX11();
|
2011-01-30 14:34:42 +00:00
|
|
|
void initShortcuts();
|
2022-03-23 10:13:38 +00:00
|
|
|
template<typename Slot>
|
2013-09-09 07:41:37 +00:00
|
|
|
void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut,
|
|
|
|
Slot slot, const QVariant &data = QVariant());
|
2022-03-23 10:13:38 +00:00
|
|
|
template<typename T, typename Slot>
|
2017-09-24 08:10:52 +00:00
|
|
|
void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, T *receiver, Slot slot, const QVariant &data = QVariant());
|
2022-04-22 17:39:12 +00:00
|
|
|
void setupWindowShortcut(Window *c);
|
|
|
|
bool switchWindow(Window *c, Direction direction, QPoint curPos, VirtualDesktop *desktop);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder
|
2022-04-22 17:39:12 +00:00
|
|
|
QList<Window *> constrainedStackingOrder();
|
|
|
|
void raiseClientWithinApplication(Window *c);
|
|
|
|
void lowerClientWithinApplication(Window *c);
|
|
|
|
bool allowFullClientRaising(const Window *c, xcb_timestamp_t timestamp);
|
2011-01-30 14:34:42 +00:00
|
|
|
void blockStackingUpdates(bool block);
|
|
|
|
void updateToolWindows(bool also_hide);
|
2012-03-26 15:30:34 +00:00
|
|
|
void fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geom);
|
2011-09-30 11:22:39 +00:00
|
|
|
void saveOldScreenSizes();
|
2022-04-22 17:39:12 +00:00
|
|
|
void addToStack(Window *toplevel);
|
|
|
|
void replaceInStack(Window *original, Deleted *deleted);
|
|
|
|
void removeFromStack(Window *toplevel);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
/// This is the right way to create a new client
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *createClient(xcb_window_t w, bool is_mapped);
|
2022-04-22 17:39:12 +00:00
|
|
|
void setupClientConnections(Window *client);
|
2019-09-24 08:48:08 +00:00
|
|
|
void addClient(X11Client *c);
|
2022-03-23 10:13:38 +00:00
|
|
|
Unmanaged *createUnmanaged(xcb_window_t w);
|
|
|
|
void addUnmanaged(Unmanaged *c);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void addShellClient(Window *client);
|
|
|
|
void removeShellClient(Window *client);
|
2020-03-04 07:55:26 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void closeActivePopup();
|
2021-08-16 12:07:43 +00:00
|
|
|
void updateClientVisibilityOnDesktopChange(VirtualDesktop *newDesktop);
|
|
|
|
void activateClientOnNewDesktop(VirtualDesktop *desktop);
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *findClientToActivateOnDesktop(VirtualDesktop *desktop);
|
|
|
|
void removeAbstractClient(Window *client);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2021-05-09 15:07:36 +00:00
|
|
|
struct Constraint
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *below;
|
|
|
|
Window *above;
|
2021-05-09 15:07:36 +00:00
|
|
|
// All constraints above our "below" window
|
|
|
|
QList<Constraint *> parents;
|
|
|
|
// All constraints below our "above" window
|
|
|
|
QList<Constraint *> children;
|
|
|
|
// Used to prevent cycles.
|
|
|
|
bool enqueued = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
QList<Constraint *> m_constraints;
|
2022-03-23 10:13:38 +00:00
|
|
|
QWidget *active_popup;
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *active_popup_client;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2015-05-01 14:55:15 +00:00
|
|
|
int m_initialDesktop;
|
2017-06-21 19:10:12 +00:00
|
|
|
void updateXStackingOrder();
|
2019-07-29 18:24:09 +00:00
|
|
|
void updateTabbox();
|
2017-06-21 04:56:53 +00:00
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
Output *m_activeOutput = nullptr;
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *active_client;
|
|
|
|
Window *last_active_client;
|
|
|
|
Window *movingClient;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
// Delay(ed) window focus timer and client
|
2022-03-23 10:13:38 +00:00
|
|
|
QTimer *delayFocusTimer;
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *delayfocus_client;
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint focusMousePos;
|
|
|
|
|
2021-05-24 16:01:49 +00:00
|
|
|
QList<X11Client *> m_x11Clients;
|
2022-04-22 17:39:12 +00:00
|
|
|
QList<Window *> m_allClients;
|
2020-10-09 15:49:32 +00:00
|
|
|
QList<Unmanaged *> m_unmanaged;
|
Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example
QList<QWeakPointer<TabBoxClient>> TabBoxClientList
in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?
Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.
So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.
Test Plan: Compiles.
Reviewers: #kwin
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24950
2019-10-16 09:11:04 +00:00
|
|
|
QList<Deleted *> deleted;
|
2022-04-22 17:45:19 +00:00
|
|
|
QList<InternalWindow *> m_internalClients;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
QList<Window *> unconstrained_stacking_order; // Topmost last
|
|
|
|
QList<Window *> stacking_order; // Topmost last
|
2022-03-23 10:13:38 +00:00
|
|
|
QVector<xcb_window_t> manual_overlays; // Topmost last
|
2011-01-30 14:34:42 +00:00
|
|
|
bool force_restacking;
|
2022-04-22 17:39:12 +00:00
|
|
|
QList<Window *> x_stacking; // From XQueryTree()
|
2017-06-21 19:10:12 +00:00
|
|
|
std::unique_ptr<Xcb::Tree> m_xStackingQueryTree;
|
2017-09-17 07:26:24 +00:00
|
|
|
bool m_xStackingDirty = false;
|
2022-04-22 17:39:12 +00:00
|
|
|
QList<Window *> should_get_focus; // Last is most recent
|
|
|
|
QList<Window *> attention_chain;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
bool showing_desktop;
|
|
|
|
|
Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example
QList<QWeakPointer<TabBoxClient>> TabBoxClientList
in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?
Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.
So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.
Test Plan: Compiles.
Reviewers: #kwin
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24950
2019-10-16 09:11:04 +00:00
|
|
|
QList<Group *> groups;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
bool was_user_interaction;
|
2017-08-17 17:10:45 +00:00
|
|
|
QScopedPointer<X11EventFilter> m_wasUserInteractionFilter;
|
2019-10-31 16:16:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int block_focus;
|
|
|
|
|
2012-08-19 10:00:53 +00:00
|
|
|
/**
|
|
|
|
* Holds the menu containing the user actions which is shown
|
|
|
|
* on e.g. right click the window decoration.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-08-19 10:00:53 +00:00
|
|
|
UserActionsMenu *m_userActionsMenu;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
void modalActionsSwitch(bool enabled);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
ShortcutDialog *client_keys_dialog;
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *client_keys_client;
|
2011-01-30 14:34:42 +00:00
|
|
|
bool global_shortcuts_disabled_for_client;
|
|
|
|
|
|
|
|
// Timer to collect requests for 'reconfigure'
|
|
|
|
QTimer reconfigureTimer;
|
|
|
|
|
|
|
|
QTimer updateToolWindowsTimer;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
static Workspace *_self;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
bool workspaceInit;
|
|
|
|
|
2020-07-20 08:07:08 +00:00
|
|
|
QScopedPointer<KStartupInfo> m_startup;
|
|
|
|
QScopedPointer<ColorMapper> m_colorMapper;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2021-08-21 17:46:51 +00:00
|
|
|
QHash<const VirtualDesktop *, QRect> m_workAreas;
|
|
|
|
QHash<const VirtualDesktop *, StrutRects> m_restrictedAreas;
|
2022-04-14 12:33:28 +00:00
|
|
|
QHash<const VirtualDesktop *, QHash<const Output *, QRect>> m_screenAreas;
|
2021-08-30 07:52:20 +00:00
|
|
|
QRect m_geometry;
|
2021-08-21 17:46:51 +00:00
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
QHash<const Output *, QRect> m_oldScreenGeometries;
|
2011-09-30 12:50:18 +00:00
|
|
|
QSize olddisplaysize; // previous sizes od displayWidth()/displayHeight()
|
2021-08-21 17:46:51 +00:00
|
|
|
QHash<const VirtualDesktop *, StrutRects> m_oldRestrictedAreas;
|
2021-10-30 10:43:08 +00:00
|
|
|
bool m_inUpdateClientArea = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
int set_active_client_recursion;
|
|
|
|
int block_stacking_updates; // When > 0, stacking updates are temporarily disabled
|
|
|
|
bool blocked_propagating_new_clients; // Propagate also new clients after enabling stacking updates?
|
2013-04-30 11:06:46 +00:00
|
|
|
QScopedPointer<Xcb::Window> m_nullFocus;
|
2011-01-30 14:34:42 +00:00
|
|
|
friend class StackingUpdatesBlocker;
|
|
|
|
|
2012-12-27 13:26:46 +00:00
|
|
|
QScopedPointer<KillWindow> m_windowKiller;
|
2017-08-17 19:12:28 +00:00
|
|
|
QScopedPointer<X11EventFilter> m_movingClientFilter;
|
2020-04-27 11:01:17 +00:00
|
|
|
QScopedPointer<X11EventFilter> m_syncAlarmFilter;
|
2014-09-02 16:46:07 +00:00
|
|
|
|
2019-10-31 16:16:53 +00:00
|
|
|
SessionManager *m_sessionManager;
|
2022-03-23 10:13:38 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
|
|
|
friend bool performTransiencyCheck();
|
2013-05-08 11:39:06 +00:00
|
|
|
friend Workspace *workspace();
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
/**
|
|
|
|
* Helper for Workspace::blockStackingUpdates() being called in pairs (True/false)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
class StackingUpdatesBlocker
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-03-23 10:13:38 +00:00
|
|
|
explicit StackingUpdatesBlocker(Workspace *w)
|
|
|
|
: ws(w)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
ws->blockStackingUpdates(true);
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
~StackingUpdatesBlocker()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
ws->blockStackingUpdates(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-03-23 10:13:38 +00:00
|
|
|
Workspace *ws;
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-04-30 12:55:06 +00:00
|
|
|
class ColorMapper : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ColorMapper(QObject *parent);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~ColorMapper() override;
|
2013-04-30 12:55:06 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
void update();
|
2022-03-23 10:13:38 +00:00
|
|
|
|
2013-04-30 12:55:06 +00:00
|
|
|
private:
|
|
|
|
xcb_colormap_t m_default;
|
|
|
|
xcb_colormap_t m_installed;
|
|
|
|
};
|
|
|
|
|
2009-02-14 15:40:52 +00:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Unsorted
|
|
|
|
|
|
|
|
inline bool Workspace::initializing() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-14 15:40:52 +00:00
|
|
|
return workspaceInit;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 09:46:12 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
inline Window *Workspace::activeClient() const
|
2015-03-12 11:11:42 +00:00
|
|
|
{
|
|
|
|
return active_client;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
inline Window *Workspace::mostRecentlyActivatedClient() const
|
2015-03-12 11:11:42 +00:00
|
|
|
{
|
|
|
|
return should_get_focus.count() > 0 ? should_get_focus.last() : active_client;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline void Workspace::addGroup(Group *group)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT groupAdded(group);
|
2011-01-30 14:34:42 +00:00
|
|
|
groups.append(group);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline void Workspace::removeGroup(Group *group)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
groups.removeAll(group);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
inline const QList<Window *> &Workspace::stackingOrder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-12-18 13:50:57 +00:00
|
|
|
// TODO: Q_ASSERT( block_stacking_updates == 0 );
|
2007-04-29 17:35:43 +00:00
|
|
|
return stacking_order;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
inline bool Workspace::wasUserInteraction() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return was_user_interaction;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-10-31 16:16:53 +00:00
|
|
|
inline SessionManager *Workspace::sessionManager() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-10-31 16:16:53 +00:00
|
|
|
return m_sessionManager;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
inline bool Workspace::showingDesktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return showing_desktop;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
inline bool Workspace::globalShortcutsDisabled() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-05-08 15:28:55 +00:00
|
|
|
return global_shortcuts_disabled_for_client;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
inline void Workspace::forceRestacking()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-07-04 09:51:10 +00:00
|
|
|
force_restacking = true;
|
2022-03-23 10:13:38 +00:00
|
|
|
StackingUpdatesBlocker blocker(this); // Do restacking if not blocked
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-04 09:51:10 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline void Workspace::updateFocusMousePosition(const QPoint &pos)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-08-24 09:46:56 +00:00
|
|
|
focusMousePos = pos;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-24 09:46:56 +00:00
|
|
|
|
2008-12-18 13:50:57 +00:00
|
|
|
inline QPoint Workspace::focusMousePosition() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-08-24 09:46:56 +00:00
|
|
|
return focusMousePos;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-24 09:46:56 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline void Workspace::forEachClient(std::function<void(X11Client *)> func)
|
2013-08-05 07:42:10 +00:00
|
|
|
{
|
2021-05-24 16:01:49 +00:00
|
|
|
std::for_each(m_x11Clients.constBegin(), m_x11Clients.constEnd(), func);
|
2013-08-05 07:42:10 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline void Workspace::forEachUnmanaged(std::function<void(Unmanaged *)> func)
|
2013-08-05 07:42:10 +00:00
|
|
|
{
|
2020-10-09 15:49:32 +00:00
|
|
|
std::for_each(m_unmanaged.constBegin(), m_unmanaged.constEnd(), func);
|
2013-08-05 07:42:10 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 11:39:06 +00:00
|
|
|
inline Workspace *workspace()
|
|
|
|
{
|
|
|
|
return Workspace::_self;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
2014-03-20 12:39:00 +00:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Workspace::ActivityFlags)
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#endif
|