kwin/src/workspace.h

817 lines
26 KiB
C
Raw Normal View History

2020-08-02 22:22:19 +00:00
/*
KWin - the KDE window manager
This file is part of the KDE project.
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>
2020-08-02 22:22:19 +00:00
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_WORKSPACE_H
#define KWIN_WORKSPACE_H
// kwin
#include "options.h"
#include "sm.h"
2022-01-18 08:35:52 +00:00
#include "utils/common.h"
// Qt
2022-03-09 16:41:07 +00:00
#include <QStringList>
#include <QTimer>
#include <QVector>
// std
#include <functional>
2017-06-21 19:10:12 +00:00
#include <memory>
class KConfig;
class KConfigGroup;
class KStartupInfo;
class KStartupInfoData;
class KStartupInfoId;
namespace KWin
{
namespace Xcb
{
2017-06-21 19:10:12 +00:00
class Tree;
class Window;
}
2022-04-22 17:39:12 +00:00
class Window;
class Output;
class ColorMapper;
class Compositor;
class Deleted;
class Group;
class InternalWindow;
class KillWindow;
class ShortcutDialog;
class Unmanaged;
class UserActionsMenu;
class VirtualDesktop;
class X11Window;
class X11EventFilter;
enum class Predicate;
class KWIN_EXPORT Workspace : public QObject
2011-01-30 14:34:42 +00:00
{
Q_OBJECT
2011-01-30 14:34:42 +00:00
public:
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
static Workspace *self()
{
2011-01-30 14:34:42 +00:00
return _self;
}
bool workspaceEvent(xcb_generic_event_t *);
bool workspaceEvent(QEvent *);
2011-01-30 14:34:42 +00:00
bool hasWindow(const Window *);
2011-01-30 14:34:42 +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
* X11Window *client = findClient([w](const X11Window *c) -> bool {
* 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
* X11Window *client = findClient(Predicate::WindowMatch, w);
* @endcode
*
* @param func Unary function that accepts a X11Window *as argument and
* returns a value convertible to bool. The value returned indicates whether the
* X11Window *is considered a match in the context of this function.
* The function shall not modify its argument.
* This can either be a function pointer or a function object.
* @return KWin::X11Window *The found Client or @c null
* @see findClient(Predicate, xcb_window_t)
*/
X11Window *findClient(std::function<bool(const X11Window *)> 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;
/**
* @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
* @return KWin::X11Window *The found Client or @c null
* @see findClient(std::function<bool (const X11Window *)>)
*/
X11Window *findClient(Predicate predicate, xcb_window_t w) const;
void forEachClient(std::function<void(X11Window *)> func);
2022-04-22 17:39:12 +00:00
void forEachAbstractClient(std::function<void(Window *)> func);
Unmanaged *findUnmanaged(std::function<bool(const Unmanaged *)> func) const;
/**
* @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.
*/
Unmanaged *findUnmanaged(xcb_window_t w) const;
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);
2022-04-22 17:39:12 +00:00
Window *findToplevel(const QUuid &internalId) const;
/**
2022-04-22 17:39:12 +00:00
* @brief Finds a Window for the internal window @p w.
*
* Internal window means a window created by KWin itself. On X11 this is an Unmanaged
* and mapped by the window id, on Wayland a XdgShellClient mapped on the internal window id.
*
2022-04-22 17:39:12 +00:00
* @returns Window
*/
2022-04-22 17:39:12 +00:00
Window *findInternal(QWindow *w) const;
2011-01-30 14:34:42 +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
/**
* Returns the geometry of this Workspace, i.e. the bounding rectangle of all outputs.
*/
QRect geometry() const;
QRegion restrictedMoveArea(const VirtualDesktop *desktop, StrutAreas areas = StrutAreaAll) const;
2011-01-30 14:34:42 +00:00
bool initializing() const;
Output *activeOutput() const;
void setActiveOutput(Output *output);
void setActiveOutput(const QPoint &pos);
2011-01-30 14:34:42 +00:00
/**
* Returns the active window, i.e. the window that has the focus (or None
* if no window has the focus)
*/
Window *activeWindow() const;
2011-01-30 14:34:42 +00:00
/**
* Window that was activated, but it's not yet really activeWindow(), because
2011-01-30 14:34:42 +00:00
* we didn't process yet the matching FocusIn event. Used mostly in focus
* stealing prevention code.
*/
Window *mostRecentlyActivatedWindow() const;
2011-01-30 14:34:42 +00:00
Window *windowUnderMouse(Output *output) const;
void activateWindow(Window *window, bool force = false);
bool requestFocus(Window *window, bool force = false);
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)
bool takeActivity(Window *window, ActivityFlags flags);
bool allowWindowActivation(const Window *window, xcb_timestamp_t time = -1U, bool focus_in = false,
2011-01-30 14:34:42 +00:00
bool ignore_desktop = false);
bool restoreFocus();
void gotFocusIn(const Window *window);
void setShouldGetFocus(Window *window);
bool activateNextWindow(Window *window);
bool focusChangeEnabled()
{
2011-01-30 14:34:42 +00:00
return block_focus == 0;
}
/**
* Indicates that the given @a window is being moved or resized by the user.
*/
void setMoveResizeWindow(Window *window);
QRect adjustClientArea(Window *window, const QRect &area) const;
QPoint adjustWindowPosition(Window *window, QPoint pos, bool unrestricted, double snapAdjust = 1.0);
QRect adjustWindowSize(Window *window, QRect moveResizeGeom, Gravity gravity);
void raiseWindow(Window *window, bool nogroup = false);
void lowerWindow(Window *window, bool nogroup = false);
void raiseWindowRequest(Window *window, NET::RequestSource src = NET::FromApplication, xcb_timestamp_t timestamp = 0);
void lowerWindowRequest(X11Window *window, NET::RequestSource src, xcb_timestamp_t timestamp);
void lowerWindowRequest(Window *window);
void restackWindowUnderActive(Window *window);
void restack(Window *window, Window *under, bool force = false);
void raiseOrLowerWindow(Window *window);
2011-01-30 14:34:42 +00:00
void resetUpdateToolWindowsTimer();
void restoreSessionStackingOrder(X11Window *window);
void updateStackingOrder(bool propagate_new_windows = false);
2011-01-30 14:34:42 +00:00
void forceRestacking();
2022-04-22 17:39:12 +00:00
void constrain(Window *below, Window *above);
void unconstrain(Window *below, Window *above);
void windowHidden(Window *);
void windowAttentionChanged(Window *, bool set);
2011-01-30 14:34:42 +00:00
/**
* @return List of windows currently managed by Workspace
*/
const QList<X11Window *> &clientList() const
{
return m_x11Clients;
}
/**
* @return List of unmanaged "windows" currently registered in Workspace
*/
const QList<Unmanaged *> &unmanagedList() const
{
return m_unmanaged;
}
/**
* @return List of deleted "windows" currently managed by Workspace
*/
const QList<Deleted *> &deletedList() const
{
return deleted;
}
/**
* @returns List of all windows (either X11 or Wayland) currently managed by Workspace
*/
2022-04-22 17:39:12 +00:00
const QList<Window *> allClientList() const
{
return m_allClients;
}
/**
* @returns List of all internal windows currently managed by Workspace
*/
const QList<InternalWindow *> &internalWindows() const
{
return m_internalWindows;
}
void stackScreenEdgesUnderOverrideRedirect();
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;
2011-01-30 14:34:42 +00:00
private:
QTimer *m_quickTileCombineTimer;
QuickTileMode m_lastTilingMode;
2011-01-30 14:34:42 +00:00
//-------------------------------------------------
// Unsorted
public:
bool isOnCurrentHead();
// True when performing Workspace::updateClientArea().
// The calls below are valid only in that case.
bool inUpdateClientArea() const;
QRegion previousRestrictedMoveArea(const VirtualDesktop *desktop, StrutAreas areas = StrutAreaAll) const;
QHash<const Output *, QRect> previousScreenSizes() const;
int oldDisplayWidth() const;
int oldDisplayHeight() const;
2011-01-30 14:34:42 +00:00
/**
* Returns the list of windows sorted in stacking order, with topmost window
2011-01-30 14:34:42 +00:00
* at the last position
*/
2022-04-22 17:39:12 +00:00
const QList<Window *> &stackingOrder() const;
QList<Window *> xStackingOrder() const;
QList<Window *> unconstrainedStackingOrder() const;
QList<X11Window *> ensureStackingOrder(const QList<X11Window *> &windows) const;
QList<Window *> ensureStackingOrder(const QList<Window *> &windows) const;
2011-01-30 14:34:42 +00:00
Window *topWindowOnDesktop(VirtualDesktop *desktop, Output *output = nullptr, bool unconstrained = false,
bool only_normal = true) const;
2022-04-22 17:39:12 +00:00
Window *findDesktop(bool topmost, VirtualDesktop *desktop) const;
void sendWindowToDesktop(Window *window, int desktop, bool dont_activate);
void windowToPreviousDesktop(Window *window);
void windowToNextDesktop(Window *window);
void sendWindowToOutput(Window *window, Output *output);
2011-01-30 14:34:42 +00:00
void addManualOverlay(xcb_window_t id)
{
manual_overlays << id;
}
void removeManualOverlay(xcb_window_t id)
{
manual_overlays.removeOne(id);
}
2011-01-30 14:34:42 +00:00
/**
* Shows the menu operations menu for the window and makes it active if
2011-01-30 14:34:42 +00:00
* it's not already.
*/
2022-04-22 17:39:12 +00:00
void showWindowMenu(const QRect &pos, Window *cl);
const UserActionsMenu *userActionsMenu() const
{
return m_userActionsMenu;
}
2011-01-30 14:34:42 +00:00
void showApplicationMenu(const QRect &pos, Window *window, int actionId);
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
SessionInfo *takeSessionInfo(X11Window *);
2011-01-30 14:34:42 +00:00
// D-Bus interface
QString supportInformation() const;
2011-01-30 14:34:42 +00:00
Output *nextOutput(Output *reference) const;
Output *previousOutput(Output *reference) const;
void switchToOutput(Output *output);
2011-01-30 14:34: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;
void removeX11Window(X11Window *); // Only called from X11Window::destroyWindow() or X11Window::releaseWindow()
void setActiveWindow(Window *window);
Group *findGroup(xcb_window_t leader) const;
void addGroup(Group *group);
void removeGroup(Group *group);
Group *findClientLeaderGroup(const X11Window *c) const;
int unconstainedStackingOrderIndex(const X11Window *c) const;
2011-01-30 14:34:42 +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
bool checkStartupNotification(xcb_window_t w, KStartupInfoId &id, KStartupInfoData &data);
2011-01-30 14:34:42 +00:00
void focusToNull(); // SELI TODO: Public?
void windowShortcutUpdated(Window *window);
2022-04-22 17:39:12 +00:00
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;
int packPositionLeft(const Window *window, int oldX, bool leftEdge) const;
int packPositionRight(const Window *window, int oldX, bool rightEdge) const;
int packPositionUp(const Window *window, int oldY, bool topEdge) const;
int packPositionDown(const Window *window, 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 *);
/**
* 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)
*/
void updateFocusMousePosition(const QPoint &pos);
2011-01-30 14:34:42 +00:00
QPoint focusMousePosition() const;
/**
* Returns a window that is currently being moved or resized by the user.
*
* If none of windows is being moved or resized, @c null will be returned.
*/
Window *moveResizeWindow()
{
return m_moveResizeWindow;
}
2011-01-30 14:34:42 +00:00
2017-06-21 19:10:12 +00:00
void markXStackingOrderAsDirty();
void quickTileWindow(QuickTileMode mode);
enum Direction {
DirectionNorth,
DirectionEast,
DirectionSouth,
DirectionWest
};
void switchWindow(Direction direction);
ShortcutDialog *shortcutDialog() const
{
return m_windowKeysDialog;
}
void addInternalWindow(InternalWindow *window);
void removeInternalWindow(InternalWindow *window);
/**
* @internal
* Used by session management
*/
void setInitialDesktop(int desktop);
public Q_SLOTS:
void performWindowOperation(KWin::Window *window, Options::WindowOperation op);
2011-01-30 14:34:42 +00:00
// Keybindings
// void slotSwitchToWindow( int );
void slotWindowToDesktop(VirtualDesktop *desktop);
// void slotWindowToListPosition( int );
void slotSwitchToScreen();
void slotWindowToScreen();
2011-01-30 14:34:42 +00:00
void slotSwitchToNextScreen();
void slotWindowToNextScreen();
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();
void slotWindowCenter();
void slotWindowMoveLeft();
void slotWindowMoveRight();
void slotWindowMoveUp();
void slotWindowMoveDown();
void slotWindowExpandHorizontal();
void slotWindowExpandVertical();
2011-01-30 14:34:42 +00:00
void slotWindowShrinkHorizontal();
void slotWindowShrinkVertical();
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();
private Q_SLOTS:
2011-01-30 14:34:42 +00:00
void desktopResized();
void selectWmInputEventMask();
2011-01-30 14:34:42 +00:00
void slotUpdateToolWindows();
void delayFocus();
void slotReloadConfig();
void updateCurrentActivity(const QString &new_activity);
// virtual desktop handling
void slotCurrentDesktopChanged(uint oldDesktop, uint newDesktop);
void slotCurrentDesktopChanging(uint currentDesktop, QPointF delta);
void slotCurrentDesktopChangingCancelled();
void slotDesktopAdded(VirtualDesktop *desktop);
void slotDesktopRemoved(VirtualDesktop *desktop);
void slotOutputEnabled(Output *output);
void slotOutputDisabled(Output *output);
2011-01-30 14:34:42 +00:00
Q_SIGNALS:
/**
* Emitted after the Workspace has setup the complete initialization process.
* This can be used to connect to for performing post-workspace initialization.
*/
void workspaceInitialized();
void geometryChanged();
2011-01-30 14:34:42 +00:00
// Signals required for the scripting interface
2022-04-22 17:39:12 +00:00
void desktopPresenceChanged(KWin::Window *, int);
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
void currentDesktopChangingCancelled();
void windowAdded(KWin::Window *);
void windowRemoved(KWin::Window *);
void windowActivated(KWin::Window *);
void windowDemandsAttentionChanged(KWin::Window *, bool);
void windowMinimizedChanged(KWin::Window *);
void groupAdded(KWin::Group *);
void unmanagedAdded(KWin::Unmanaged *);
void unmanagedRemoved(KWin::Unmanaged *);
void deletedRemoved(KWin::Deleted *);
void configChanged();
void showingDesktopChanged(bool showing, bool animated);
/**
2020-11-05 14:52:46 +00:00
* This signal is emitted when the stacking order changed, i.e. a window is risen
* or lowered
*/
void stackingOrderChanged();
2011-01-30 14:34:42 +00:00
/**
* This signal is emitted whenever an internal window is created.
*/
void internalWindowAdded(KWin::InternalWindow *window);
/**
* This signal is emitted whenever an internal window gets removed.
*/
void internalWindowRemoved(KWin::InternalWindow *window);
2011-01-30 14:34:42 +00:00
private:
void init();
void initializeX11();
void cleanupX11();
2011-01-30 14:34:42 +00:00
void initShortcuts();
template<typename Slot>
void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut,
Slot slot, const QVariant &data = QVariant());
template<typename T, typename Slot>
void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, T *receiver, Slot slot, const QVariant &data = QVariant());
void setupWindowShortcut(Window *window);
bool switchWindow(Window *window, Direction direction, QPoint curPos, VirtualDesktop *desktop);
2011-01-30 14:34:42 +00:00
void propagateWindows(bool propagate_new_windows); // Called only from updateStackingOrder
2022-04-22 17:39:12 +00:00
QList<Window *> constrainedStackingOrder();
void raiseWindowWithinApplication(Window *window);
void lowerWindowWithinApplication(Window *window);
bool allowFullClientRaising(const Window *window, xcb_timestamp_t timestamp);
2011-01-30 14:34:42 +00:00
void blockStackingUpdates(bool block);
void updateToolWindows(bool also_hide);
void fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geom);
void saveOldScreenSizes();
void addToStack(Window *window);
2022-04-22 17:39:12 +00:00
void replaceInStack(Window *original, Deleted *deleted);
void removeFromStack(Window *window);
2011-01-30 14:34:42 +00:00
/// This is the right way to create a new X11 window
X11Window *createX11Window(xcb_window_t windowId, bool is_mapped);
void addX11Window(X11Window *c);
void setupWindowConnections(Window *window);
Unmanaged *createUnmanaged(xcb_window_t windowId);
void addUnmanaged(Unmanaged *c);
2011-01-30 14:34:42 +00:00
void addWaylandWindow(Window *window);
void removeWaylandWindow(Window *window);
2011-01-30 14:34:42 +00:00
//---------------------------------------------------------------------
void closeActivePopup();
void updateWindowVisibilityOnDesktopChange(VirtualDesktop *newDesktop);
void activateWindowOnNewDesktop(VirtualDesktop *desktop);
Window *findWindowToActivateOnDesktop(VirtualDesktop *desktop);
2022-04-22 17:39:12 +00:00
void removeAbstractClient(Window *client);
2011-01-30 14:34:42 +00:00
struct Constraint
{
2022-04-22 17:39:12 +00:00
Window *below;
Window *above;
// 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;
QWidget *active_popup;
Window *m_activePopupWindow;
2011-01-30 14:34:42 +00:00
int m_initialDesktop;
2017-06-21 19:10:12 +00:00
void updateXStackingOrder();
void updateTabbox();
Output *m_activeOutput = nullptr;
Window *m_activeWindow;
Window *m_lastActiveWindow;
Window *m_moveResizeWindow;
2011-01-30 14:34:42 +00:00
// Delay(ed) window focus timer and window
QTimer *delayFocusTimer;
Window *m_delayFocusWindow;
2011-01-30 14:34:42 +00:00
QPoint focusMousePos;
QList<X11Window *> m_x11Clients;
2022-04-22 17:39:12 +00:00
QList<Window *> m_allClients;
QList<Unmanaged *> m_unmanaged;
QList<Deleted *> deleted;
QList<InternalWindow *> m_internalWindows;
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
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;
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;
QList<Group *> groups;
2011-01-30 14:34:42 +00:00
bool was_user_interaction;
QScopedPointer<X11EventFilter> m_wasUserInteractionFilter;
2011-01-30 14:34:42 +00:00
int block_focus;
/**
* Holds the menu containing the user actions which is shown
* on e.g. right click the window decoration.
*/
UserActionsMenu *m_userActionsMenu;
2011-01-30 14:34:42 +00:00
void modalActionsSwitch(bool enabled);
ShortcutDialog *m_windowKeysDialog = nullptr;
Window *m_windowKeysWindow = nullptr;
bool m_globalShortcutsDisabledForWindow = false;
2011-01-30 14:34:42 +00:00
// Timer to collect requests for 'reconfigure'
QTimer reconfigureTimer;
QTimer updateToolWindowsTimer;
static Workspace *_self;
2011-01-30 14:34:42 +00:00
bool workspaceInit;
QScopedPointer<KStartupInfo> m_startup;
QScopedPointer<ColorMapper> m_colorMapper;
2011-01-30 14:34:42 +00:00
QHash<const VirtualDesktop *, QRect> m_workAreas;
QHash<const VirtualDesktop *, StrutRects> m_restrictedAreas;
QHash<const VirtualDesktop *, QHash<const Output *, QRect>> m_screenAreas;
QRect m_geometry;
QHash<const Output *, QRect> m_oldScreenGeometries;
QSize olddisplaysize; // previous sizes od displayWidth()/displayHeight()
QHash<const VirtualDesktop *, StrutRects> m_oldRestrictedAreas;
bool m_inUpdateClientArea = false;
2011-01-30 14:34:42 +00:00
int m_setActiveWindowRecursion = 0;
int m_blockStackingUpdates = 0; // When > 0, stacking updates are temporarily disabled
bool m_blockedPropagatingNewWindows; // Propagate also new windows after enabling stacking updates?
QScopedPointer<Xcb::Window> m_nullFocus;
2011-01-30 14:34:42 +00:00
friend class StackingUpdatesBlocker;
QScopedPointer<KillWindow> m_windowKiller;
QScopedPointer<X11EventFilter> m_movingClientFilter;
QScopedPointer<X11EventFilter> m_syncAlarmFilter;
SessionManager *m_sessionManager;
2011-01-30 14:34:42 +00:00
private:
friend bool performTransiencyCheck();
friend Workspace *workspace();
2011-01-30 14:34:42 +00:00
};
/**
* Helper for Workspace::blockStackingUpdates() being called in pairs (True/false)
*/
class StackingUpdatesBlocker
2011-01-30 14:34:42 +00:00
{
public:
explicit StackingUpdatesBlocker(Workspace *w)
: ws(w)
{
2011-01-30 14:34:42 +00:00
ws->blockStackingUpdates(true);
}
~StackingUpdatesBlocker()
{
2011-01-30 14:34:42 +00:00
ws->blockStackingUpdates(false);
}
private:
Workspace *ws;
2011-01-30 14:34:42 +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;
public Q_SLOTS:
void update();
private:
xcb_colormap_t m_default;
xcb_colormap_t m_installed;
};
//---------------------------------------------------------
// Unsorted
inline bool Workspace::initializing() const
2011-01-30 14:34:42 +00:00
{
return workspaceInit;
2011-01-30 14:34:42 +00:00
}
inline Window *Workspace::activeWindow() const
{
return m_activeWindow;
}
inline Window *Workspace::mostRecentlyActivatedWindow() const
{
return should_get_focus.count() > 0 ? should_get_focus.last() : m_activeWindow;
}
inline void Workspace::addGroup(Group *group)
2011-01-30 14:34:42 +00:00
{
Q_EMIT groupAdded(group);
2011-01-30 14:34:42 +00:00
groups.append(group);
}
inline void Workspace::removeGroup(Group *group)
2011-01-30 14:34:42 +00:00
{
groups.removeAll(group);
}
2022-04-22 17:39:12 +00:00
inline const QList<Window *> &Workspace::stackingOrder() const
2011-01-30 14:34:42 +00:00
{
// TODO: Q_ASSERT( block_stacking_updates == 0 );
return stacking_order;
2011-01-30 14:34:42 +00:00
}
inline bool Workspace::wasUserInteraction() const
2011-01-30 14:34:42 +00:00
{
return was_user_interaction;
2011-01-30 14:34:42 +00:00
}
inline SessionManager *Workspace::sessionManager() const
2011-01-30 14:34:42 +00:00
{
return m_sessionManager;
2011-01-30 14:34:42 +00:00
}
inline bool Workspace::showingDesktop() const
2011-01-30 14:34:42 +00:00
{
return showing_desktop;
2011-01-30 14:34:42 +00:00
}
inline bool Workspace::globalShortcutsDisabled() const
2011-01-30 14:34:42 +00:00
{
return m_globalShortcutsDisabledForWindow;
2011-01-30 14:34:42 +00:00
}
inline void Workspace::forceRestacking()
2011-01-30 14:34:42 +00:00
{
force_restacking = true;
StackingUpdatesBlocker blocker(this); // Do restacking if not blocked
2011-01-30 14:34:42 +00:00
}
inline void Workspace::updateFocusMousePosition(const QPoint &pos)
2011-01-30 14:34:42 +00:00
{
focusMousePos = pos;
2011-01-30 14:34:42 +00:00
}
inline QPoint Workspace::focusMousePosition() const
2011-01-30 14:34:42 +00:00
{
return focusMousePos;
2011-01-30 14:34:42 +00:00
}
inline void Workspace::forEachClient(std::function<void(X11Window *)> func)
{
std::for_each(m_x11Clients.constBegin(), m_x11Clients.constEnd(), func);
}
inline void Workspace::forEachUnmanaged(std::function<void(Unmanaged *)> func)
{
std::for_each(m_unmanaged.constBegin(), m_unmanaged.constEnd(), func);
}
inline Workspace *workspace()
{
return Workspace::_self;
}
} // namespace
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Workspace::ActivityFlags)
#endif