Changeset View
Changeset View
Standalone View
Standalone View
workspace.h
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | 47 | | |||
48 | namespace Xcb | 48 | namespace Xcb | ||
49 | { | 49 | { | ||
50 | class Tree; | 50 | class Tree; | ||
51 | class Window; | 51 | class Window; | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | class AbstractClient; | 54 | class AbstractClient; | ||
55 | class Client; | | |||
56 | class Compositor; | 55 | class Compositor; | ||
57 | class InternalClient; | 56 | class InternalClient; | ||
58 | class KillWindow; | 57 | class KillWindow; | ||
59 | class ShortcutDialog; | 58 | class ShortcutDialog; | ||
60 | class UserActionsMenu; | 59 | class UserActionsMenu; | ||
60 | class X11Client; | ||||
61 | class X11EventFilter; | 61 | class X11EventFilter; | ||
62 | enum class Predicate; | 62 | enum class Predicate; | ||
63 | 63 | | |||
64 | class KWIN_EXPORT Workspace : public QObject | 64 | class KWIN_EXPORT Workspace : public QObject | ||
65 | { | 65 | { | ||
66 | Q_OBJECT | 66 | Q_OBJECT | ||
67 | public: | 67 | public: | ||
68 | explicit Workspace(const QString &sessionKey = QString()); | 68 | explicit Workspace(const QString &sessionKey = QString()); | ||
69 | ~Workspace() override; | 69 | ~Workspace() override; | ||
70 | 70 | | |||
71 | static Workspace* self() { | 71 | static Workspace* self() { | ||
72 | return _self; | 72 | return _self; | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | bool workspaceEvent(xcb_generic_event_t*); | 75 | bool workspaceEvent(xcb_generic_event_t*); | ||
76 | bool workspaceEvent(QEvent*); | 76 | bool workspaceEvent(QEvent*); | ||
77 | 77 | | |||
78 | bool hasClient(const Client*); | 78 | bool hasClient(const X11Client *); | ||
79 | bool hasClient(const AbstractClient*); | 79 | bool hasClient(const AbstractClient*); | ||
80 | 80 | | |||
81 | /** | 81 | /** | ||
82 | * @brief Finds the first Client matching the condition expressed by passed in @p func. | 82 | * @brief Finds the first Client matching the condition expressed by passed in @p func. | ||
83 | * | 83 | * | ||
84 | * Internally findClient uses the std::find_if algorithm and that determines how the function | 84 | * Internally findClient uses the std::find_if algorithm and that determines how the function | ||
85 | * needs to be implemented. An example usage for finding a Client with a matching windowId | 85 | * needs to be implemented. An example usage for finding a Client with a matching windowId | ||
86 | * @code | 86 | * @code | ||
87 | * xcb_window_t w; // our test window | 87 | * xcb_window_t w; // our test window | ||
88 | * Client *client = findClient([w](const Client *c) -> bool { | 88 | * X11Client *client = findClient([w](const X11Client *c) -> bool { | ||
89 | * return c->window() == w; | 89 | * return c->window() == w; | ||
90 | * }); | 90 | * }); | ||
91 | * @endcode | 91 | * @endcode | ||
92 | * | 92 | * | ||
93 | * For the standard cases of matching the window id with one of the Client's windows use | 93 | * For the standard cases of matching the window id with one of the Client's windows use | ||
94 | * the simplified overload method findClient(Predicate, xcb_window_t). Above example | 94 | * the simplified overload method findClient(Predicate, xcb_window_t). Above example | ||
95 | * can be simplified to: | 95 | * can be simplified to: | ||
96 | * @code | 96 | * @code | ||
97 | * xcb_window_t w; // our test window | 97 | * xcb_window_t w; // our test window | ||
98 | * Client *client = findClient(Predicate::WindowMatch, w); | 98 | * X11Client *client = findClient(Predicate::WindowMatch, w); | ||
99 | * @endcode | 99 | * @endcode | ||
100 | * | 100 | * | ||
101 | * @param func Unary function that accepts a Client* as argument and | 101 | * @param func Unary function that accepts a X11Client *as argument and | ||
102 | * returns a value convertible to bool. The value returned indicates whether the | 102 | * returns a value convertible to bool. The value returned indicates whether the | ||
103 | * Client* is considered a match in the context of this function. | 103 | * X11Client *is considered a match in the context of this function. | ||
104 | * The function shall not modify its argument. | 104 | * The function shall not modify its argument. | ||
105 | * This can either be a function pointer or a function object. | 105 | * This can either be a function pointer or a function object. | ||
106 | * @return KWin::Client* The found Client or @c null | 106 | * @return KWin::X11Client *The found Client or @c null | ||
107 | * @see findClient(Predicate, xcb_window_t) | 107 | * @see findClient(Predicate, xcb_window_t) | ||
108 | */ | 108 | */ | ||
109 | Client *findClient(std::function<bool (const Client*)> func) const; | 109 | X11Client *findClient(std::function<bool (const X11Client *)> func) const; | ||
110 | AbstractClient *findAbstractClient(std::function<bool (const AbstractClient*)> func) const; | 110 | AbstractClient *findAbstractClient(std::function<bool (const AbstractClient*)> func) const; | ||
111 | /** | 111 | /** | ||
112 | * @brief Finds the Client matching the given match @p predicate for the given window. | 112 | * @brief Finds the Client matching the given match @p predicate for the given window. | ||
113 | * | 113 | * | ||
114 | * @param predicate Which window should be compared | 114 | * @param predicate Which window should be compared | ||
115 | * @param w The window id to test against | 115 | * @param w The window id to test against | ||
116 | * @return KWin::Client* The found Client or @c null | 116 | * @return KWin::X11Client *The found Client or @c null | ||
117 | * @see findClient(std::function<bool (const Client*)>) | 117 | * @see findClient(std::function<bool (const X11Client *)>) | ||
118 | */ | 118 | */ | ||
119 | Client *findClient(Predicate predicate, xcb_window_t w) const; | 119 | X11Client *findClient(Predicate predicate, xcb_window_t w) const; | ||
120 | void forEachClient(std::function<void (Client*)> func); | 120 | void forEachClient(std::function<void (X11Client *)> func); | ||
121 | void forEachAbstractClient(std::function<void (AbstractClient*)> func); | 121 | void forEachAbstractClient(std::function<void (AbstractClient*)> func); | ||
122 | Unmanaged *findUnmanaged(std::function<bool (const Unmanaged*)> func) const; | 122 | Unmanaged *findUnmanaged(std::function<bool (const Unmanaged*)> func) const; | ||
123 | /** | 123 | /** | ||
124 | * @brief Finds the Unmanaged with the given window id. | 124 | * @brief Finds the Unmanaged with the given window id. | ||
125 | * | 125 | * | ||
126 | * @param w The window id to search for | 126 | * @param w The window id to search for | ||
127 | * @return KWin::Unmanaged* Found Unmanaged or @c null if there is no Unmanaged with given Id. | 127 | * @return KWin::Unmanaged* Found Unmanaged or @c null if there is no Unmanaged with given Id. | ||
128 | */ | 128 | */ | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
185 | */ | 185 | */ | ||
186 | void setMoveResizeClient(AbstractClient* c); | 186 | void setMoveResizeClient(AbstractClient* c); | ||
187 | 187 | | |||
188 | QPoint adjustClientPosition(AbstractClient* c, QPoint pos, bool unrestricted, double snapAdjust = 1.0); | 188 | QPoint adjustClientPosition(AbstractClient* c, QPoint pos, bool unrestricted, double snapAdjust = 1.0); | ||
189 | QRect adjustClientSize(AbstractClient* c, QRect moveResizeGeom, int mode); | 189 | QRect adjustClientSize(AbstractClient* c, QRect moveResizeGeom, int mode); | ||
190 | void raiseClient(AbstractClient* c, bool nogroup = false); | 190 | void raiseClient(AbstractClient* c, bool nogroup = false); | ||
191 | void lowerClient(AbstractClient* c, bool nogroup = false); | 191 | void lowerClient(AbstractClient* c, bool nogroup = false); | ||
192 | void raiseClientRequest(AbstractClient* c, NET::RequestSource src = NET::FromApplication, xcb_timestamp_t timestamp = 0); | 192 | void raiseClientRequest(AbstractClient* c, NET::RequestSource src = NET::FromApplication, xcb_timestamp_t timestamp = 0); | ||
193 | void lowerClientRequest(Client* c, NET::RequestSource src, xcb_timestamp_t timestamp); | 193 | void lowerClientRequest(X11Client *c, NET::RequestSource src, xcb_timestamp_t timestamp); | ||
194 | void lowerClientRequest(AbstractClient* c); | 194 | void lowerClientRequest(AbstractClient* c); | ||
195 | void restackClientUnderActive(AbstractClient*); | 195 | void restackClientUnderActive(AbstractClient*); | ||
196 | void restack(AbstractClient *c, AbstractClient *under, bool force = false); | 196 | void restack(AbstractClient *c, AbstractClient *under, bool force = false); | ||
197 | void updateClientLayer(AbstractClient* c); | 197 | void updateClientLayer(AbstractClient* c); | ||
198 | void raiseOrLowerClient(AbstractClient*); | 198 | void raiseOrLowerClient(AbstractClient*); | ||
199 | void resetUpdateToolWindowsTimer(); | 199 | void resetUpdateToolWindowsTimer(); | ||
200 | void restoreSessionStackingOrder(Client* c); | 200 | void restoreSessionStackingOrder(X11Client *c); | ||
201 | void updateStackingOrder(bool propagate_new_clients = false); | 201 | void updateStackingOrder(bool propagate_new_clients = false); | ||
202 | void forceRestacking(); | 202 | void forceRestacking(); | ||
203 | 203 | | |||
204 | void clientHidden(AbstractClient*); | 204 | void clientHidden(AbstractClient*); | ||
205 | void clientAttentionChanged(AbstractClient* c, bool set); | 205 | void clientAttentionChanged(AbstractClient* c, bool set); | ||
206 | 206 | | |||
207 | /** | 207 | /** | ||
208 | * @return List of clients currently managed by Workspace | 208 | * @return List of clients currently managed by Workspace | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 256 | public: | |||
298 | 298 | | |||
299 | void showApplicationMenu(const QRect &pos, AbstractClient *c, int actionId); | 299 | void showApplicationMenu(const QRect &pos, AbstractClient *c, int actionId); | ||
300 | 300 | | |||
301 | void updateMinimizedOfTransients(AbstractClient*); | 301 | void updateMinimizedOfTransients(AbstractClient*); | ||
302 | void updateOnAllDesktopsOfTransients(AbstractClient*); | 302 | void updateOnAllDesktopsOfTransients(AbstractClient*); | ||
303 | void checkTransients(xcb_window_t w); | 303 | void checkTransients(xcb_window_t w); | ||
304 | 304 | | |||
305 | void storeSession(KConfig* config, SMSavePhase phase); | 305 | void storeSession(KConfig* config, SMSavePhase phase); | ||
306 | void storeClient(KConfigGroup &cg, int num, Client *c); | 306 | void storeClient(KConfigGroup &cg, int num, X11Client *c); | ||
307 | void storeSubSession(const QString &name, QSet<QByteArray> sessionIds); | 307 | void storeSubSession(const QString &name, QSet<QByteArray> sessionIds); | ||
308 | void loadSubSessionInfo(const QString &name); | 308 | void loadSubSessionInfo(const QString &name); | ||
309 | 309 | | |||
310 | SessionInfo* takeSessionInfo(Client*); | 310 | SessionInfo* takeSessionInfo(X11Client *); | ||
311 | 311 | | |||
312 | // D-Bus interface | 312 | // D-Bus interface | ||
313 | QString supportInformation() const; | 313 | QString supportInformation() const; | ||
314 | 314 | | |||
315 | void setCurrentScreen(int new_screen); | 315 | void setCurrentScreen(int new_screen); | ||
316 | 316 | | |||
317 | void setShowingDesktop(bool showing); | 317 | void setShowingDesktop(bool showing); | ||
318 | bool showingDesktop() const; | 318 | bool showingDesktop() const; | ||
319 | 319 | | |||
320 | void sendPingToWindow(xcb_window_t w, xcb_timestamp_t timestamp); // Called from Client::pingWindow() | 320 | void sendPingToWindow(xcb_window_t w, xcb_timestamp_t timestamp); // Called from X11Client::pingWindow() | ||
321 | 321 | | |||
322 | void removeClient(Client*); // Only called from Client::destroyClient() or Client::releaseWindow() | 322 | void removeClient(X11Client *); // Only called from X11Client::destroyClient() or X11Client::releaseWindow() | ||
323 | void setActiveClient(AbstractClient*); | 323 | void setActiveClient(AbstractClient*); | ||
324 | Group* findGroup(xcb_window_t leader) const; | 324 | Group* findGroup(xcb_window_t leader) const; | ||
325 | void addGroup(Group* group); | 325 | void addGroup(Group* group); | ||
326 | void removeGroup(Group* group); | 326 | void removeGroup(Group* group); | ||
327 | Group* findClientLeaderGroup(const Client* c) const; | 327 | Group* findClientLeaderGroup(const X11Client *c) const; | ||
328 | 328 | | |||
329 | void removeUnmanaged(Unmanaged*); // Only called from Unmanaged::release() | 329 | void removeUnmanaged(Unmanaged*); // Only called from Unmanaged::release() | ||
330 | void removeDeleted(Deleted*); | 330 | void removeDeleted(Deleted*); | ||
331 | void addDeleted(Deleted*, Toplevel*); | 331 | void addDeleted(Deleted*, Toplevel*); | ||
332 | 332 | | |||
333 | bool checkStartupNotification(xcb_window_t w, KStartupInfoId& id, KStartupInfoData& data); | 333 | bool checkStartupNotification(xcb_window_t w, KStartupInfoId& id, KStartupInfoData& data); | ||
334 | 334 | | |||
335 | void focusToNull(); // SELI TODO: Public? | 335 | void focusToNull(); // SELI TODO: Public? | ||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 497 | Q_SIGNALS: | |||
499 | * Emitted after the Workspace has setup the complete initialization process. | 499 | * Emitted after the Workspace has setup the complete initialization process. | ||
500 | * This can be used to connect to for performing post-workspace initialization. | 500 | * This can be used to connect to for performing post-workspace initialization. | ||
501 | */ | 501 | */ | ||
502 | void workspaceInitialized(); | 502 | void workspaceInitialized(); | ||
503 | 503 | | |||
504 | //Signals required for the scripting interface | 504 | //Signals required for the scripting interface | ||
505 | void desktopPresenceChanged(KWin::AbstractClient*, int); | 505 | void desktopPresenceChanged(KWin::AbstractClient*, int); | ||
506 | void currentDesktopChanged(int, KWin::AbstractClient*); | 506 | void currentDesktopChanged(int, KWin::AbstractClient*); | ||
507 | void clientAdded(KWin::Client*); | 507 | void clientAdded(KWin::X11Client *); | ||
508 | void clientRemoved(KWin::AbstractClient*); | 508 | void clientRemoved(KWin::AbstractClient*); | ||
509 | void clientActivated(KWin::AbstractClient*); | 509 | void clientActivated(KWin::AbstractClient*); | ||
510 | void clientDemandsAttentionChanged(KWin::AbstractClient*, bool); | 510 | void clientDemandsAttentionChanged(KWin::AbstractClient*, bool); | ||
511 | void clientMinimizedChanged(KWin::AbstractClient*); | 511 | void clientMinimizedChanged(KWin::AbstractClient*); | ||
512 | void groupAdded(KWin::Group*); | 512 | void groupAdded(KWin::Group*); | ||
513 | void unmanagedAdded(KWin::Unmanaged*); | 513 | void unmanagedAdded(KWin::Unmanaged*); | ||
514 | void unmanagedRemoved(KWin::Unmanaged*); | 514 | void unmanagedRemoved(KWin::Unmanaged*); | ||
515 | void deletedRemoved(KWin::Deleted*); | 515 | void deletedRemoved(KWin::Deleted*); | ||
Show All 35 Lines | 534 | private: | |||
551 | bool keepTransientAbove(const AbstractClient* mainwindow, const AbstractClient* transient); | 551 | bool keepTransientAbove(const AbstractClient* mainwindow, const AbstractClient* transient); | ||
552 | bool keepDeletedTransientAbove(const Toplevel *mainWindow, const Deleted *transient) const; | 552 | bool keepDeletedTransientAbove(const Toplevel *mainWindow, const Deleted *transient) const; | ||
553 | void blockStackingUpdates(bool block); | 553 | void blockStackingUpdates(bool block); | ||
554 | void updateToolWindows(bool also_hide); | 554 | void updateToolWindows(bool also_hide); | ||
555 | void fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geom); | 555 | void fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geom); | ||
556 | void saveOldScreenSizes(); | 556 | void saveOldScreenSizes(); | ||
557 | 557 | | |||
558 | /// This is the right way to create a new client | 558 | /// This is the right way to create a new client | ||
559 | Client* createClient(xcb_window_t w, bool is_mapped); | 559 | X11Client *createClient(xcb_window_t w, bool is_mapped); | ||
560 | void setupClientConnections(AbstractClient *client); | 560 | void setupClientConnections(AbstractClient *client); | ||
561 | void addClient(Client* c); | 561 | void addClient(X11Client *c); | ||
562 | Unmanaged* createUnmanaged(xcb_window_t w); | 562 | Unmanaged* createUnmanaged(xcb_window_t w); | ||
563 | void addUnmanaged(Unmanaged* c); | 563 | void addUnmanaged(Unmanaged* c); | ||
564 | 564 | | |||
565 | //--------------------------------------------------------------------- | 565 | //--------------------------------------------------------------------- | ||
566 | 566 | | |||
567 | void closeActivePopup(); | 567 | void closeActivePopup(); | ||
568 | void updateClientArea(bool force); | 568 | void updateClientArea(bool force); | ||
569 | void resetClientAreas(uint desktopCount); | 569 | void resetClientAreas(uint desktopCount); | ||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Line(s) | |||||
774 | } | 774 | } | ||
775 | 775 | | |||
776 | inline QPoint Workspace::focusMousePosition() const | 776 | inline QPoint Workspace::focusMousePosition() const | ||
777 | { | 777 | { | ||
778 | return focusMousePos; | 778 | return focusMousePos; | ||
779 | } | 779 | } | ||
780 | 780 | | |||
781 | inline | 781 | inline | ||
782 | void Workspace::forEachClient(std::function< void (Client*) > func) | 782 | void Workspace::forEachClient(std::function< void (X11Client *) > func) | ||
783 | { | 783 | { | ||
784 | std::for_each(clients.constBegin(), clients.constEnd(), func); | 784 | std::for_each(clients.constBegin(), clients.constEnd(), func); | ||
785 | std::for_each(desktops.constBegin(), desktops.constEnd(), func); | 785 | std::for_each(desktops.constBegin(), desktops.constEnd(), func); | ||
786 | } | 786 | } | ||
787 | 787 | | |||
788 | inline | 788 | inline | ||
789 | void Workspace::forEachUnmanaged(std::function< void (Unmanaged*) > func) | 789 | void Workspace::forEachUnmanaged(std::function< void (Unmanaged*) > func) | ||
790 | { | 790 | { | ||
791 | std::for_each(unmanaged.constBegin(), unmanaged.constEnd(), func); | 791 | std::for_each(unmanaged.constBegin(), unmanaged.constEnd(), func); | ||
792 | } | 792 | } | ||
793 | 793 | | |||
794 | inline bool Workspace::hasClient(const Client* c) | 794 | inline bool Workspace::hasClient(const X11Client *c) | ||
795 | { | 795 | { | ||
796 | return findClient([c](const Client *test) { | 796 | return findClient([c](const X11Client *test) { | ||
797 | return test == c; | 797 | return test == c; | ||
798 | }); | 798 | }); | ||
799 | } | 799 | } | ||
800 | 800 | | |||
801 | inline Workspace *workspace() | 801 | inline Workspace *workspace() | ||
802 | { | 802 | { | ||
803 | return Workspace::_self; | 803 | return Workspace::_self; | ||
804 | } | 804 | } | ||
805 | 805 | | |||
806 | } // namespace | 806 | } // namespace | ||
807 | Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Workspace::ActivityFlags) | 807 | Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Workspace::ActivityFlags) | ||
808 | 808 | | |||
809 | #endif | 809 | #endif |