Changeset View
Changeset View
Standalone View
Standalone View
workspace.h
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org> | 5 | Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org> | ||
6 | Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> | 6 | Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> | ||
7 | Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com> | 7 | Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com> | ||
8 | Copyright (C) 2019 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
8 | 9 | | |||
9 | This program is free software; you can redistribute it and/or modify | 10 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | 11 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation; either version 2 of the License, or | 12 | the Free Software Foundation; either version 2 of the License, or | ||
12 | (at your option) any later version. | 13 | (at your option) any later version. | ||
13 | 14 | | |||
14 | This program is distributed in the hope that it will be useful, | 15 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 32 Lines | |||||
48 | { | 49 | { | ||
49 | class Tree; | 50 | class Tree; | ||
50 | class Window; | 51 | class Window; | ||
51 | } | 52 | } | ||
52 | 53 | | |||
53 | class AbstractClient; | 54 | class AbstractClient; | ||
54 | class Client; | 55 | class Client; | ||
55 | class Compositor; | 56 | class Compositor; | ||
57 | class InternalClient; | ||||
56 | class KillWindow; | 58 | class KillWindow; | ||
57 | class ShortcutDialog; | 59 | class ShortcutDialog; | ||
58 | class UserActionsMenu; | 60 | class UserActionsMenu; | ||
59 | class X11EventFilter; | 61 | class X11EventFilter; | ||
60 | enum class Predicate; | 62 | enum class Predicate; | ||
61 | 63 | | |||
62 | class KWIN_EXPORT Workspace : public QObject | 64 | class KWIN_EXPORT Workspace : public QObject | ||
63 | { | 65 | { | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 67 | public: | |||
123 | * | 125 | * | ||
124 | * @param w The window id to search for | 126 | * @param w The window id to search for | ||
125 | * @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. | ||
126 | */ | 128 | */ | ||
127 | Unmanaged *findUnmanaged(xcb_window_t w) const; | 129 | Unmanaged *findUnmanaged(xcb_window_t w) const; | ||
128 | void forEachUnmanaged(std::function<void (Unmanaged*)> func); | 130 | void forEachUnmanaged(std::function<void (Unmanaged*)> func); | ||
129 | Toplevel *findToplevel(std::function<bool (const Toplevel*)> func) const; | 131 | Toplevel *findToplevel(std::function<bool (const Toplevel*)> func) const; | ||
130 | /** | 132 | /** | ||
131 | * Finds the Toplevel for the KWin internal window @p w. | | |||
132 | * On Wayland this is normally a ShellClient. For X11 an Unmanaged. | | |||
133 | */ | | |||
134 | Toplevel *findToplevel(QWindow *w) const; | | |||
135 | /** | | |||
136 | * @brief Finds a Toplevel for the internal window @p w. | 133 | * @brief Finds a Toplevel for the internal window @p w. | ||
137 | * | 134 | * | ||
138 | * Internal window means a window created by KWin itself. On X11 this is an Unmanaged | 135 | * Internal window means a window created by KWin itself. On X11 this is an Unmanaged | ||
139 | * and mapped by the window id, on Wayland a ShellClient mapped on the internal window id. | 136 | * and mapped by the window id, on Wayland a ShellClient mapped on the internal window id. | ||
140 | * | 137 | * | ||
141 | * @returns Toplevel | 138 | * @returns Toplevel | ||
142 | */ | 139 | */ | ||
143 | Toplevel *findInternal(QWindow *w) const; | 140 | Toplevel *findInternal(QWindow *w) const; | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
233 | } | 230 | } | ||
234 | /** | 231 | /** | ||
235 | * @returns List of all clients (either X11 or Wayland) currently managed by Workspace | 232 | * @returns List of all clients (either X11 or Wayland) currently managed by Workspace | ||
236 | */ | 233 | */ | ||
237 | const QList<AbstractClient*> allClientList() const { | 234 | const QList<AbstractClient*> allClientList() const { | ||
238 | return m_allClients; | 235 | return m_allClients; | ||
239 | } | 236 | } | ||
240 | 237 | | |||
238 | /** | ||||
239 | * @returns List of all internal clients currently managed by Workspace | ||||
240 | */ | ||||
241 | const QList<InternalClient *> &internalClients() const { | ||||
242 | return m_internalClients; | ||||
243 | } | ||||
244 | | ||||
241 | void stackScreenEdgesUnderOverrideRedirect(); | 245 | void stackScreenEdgesUnderOverrideRedirect(); | ||
242 | 246 | | |||
243 | public: | 247 | public: | ||
244 | QPoint cascadeOffset(const AbstractClient *c) const; | 248 | QPoint cascadeOffset(const AbstractClient *c) const; | ||
245 | 249 | | |||
246 | private: | 250 | private: | ||
247 | Compositor *m_compositor; | 251 | Compositor *m_compositor; | ||
248 | 252 | | |||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 387 | enum Direction { | |||
387 | DirectionWest | 391 | DirectionWest | ||
388 | }; | 392 | }; | ||
389 | void switchWindow(Direction direction); | 393 | void switchWindow(Direction direction); | ||
390 | 394 | | |||
391 | ShortcutDialog *shortcutDialog() const { | 395 | ShortcutDialog *shortcutDialog() const { | ||
392 | return client_keys_dialog; | 396 | return client_keys_dialog; | ||
393 | } | 397 | } | ||
394 | 398 | | |||
399 | /** | ||||
400 | * Adds the internal client to Workspace. | ||||
401 | * | ||||
402 | * This method will be called by InternalClient when it's mapped. | ||||
403 | * | ||||
404 | * @see internalClientAdded | ||||
405 | * @internal | ||||
406 | */ | ||||
407 | void addInternalClient(InternalClient *client); | ||||
408 | | ||||
409 | /** | ||||
410 | * Removes the internal client from Workspace. | ||||
411 | * | ||||
412 | * This method is meant to be called only by InternalClient. | ||||
413 | * | ||||
414 | * @see internalClientRemoved | ||||
415 | * @internal | ||||
416 | */ | ||||
417 | void removeInternalClient(InternalClient *client); | ||||
418 | | ||||
395 | public Q_SLOTS: | 419 | public Q_SLOTS: | ||
396 | void performWindowOperation(KWin::AbstractClient* c, Options::WindowOperation op); | 420 | void performWindowOperation(KWin::AbstractClient* c, Options::WindowOperation op); | ||
397 | // Keybindings | 421 | // Keybindings | ||
398 | //void slotSwitchToWindow( int ); | 422 | //void slotSwitchToWindow( int ); | ||
399 | void slotWindowToDesktop(uint i); | 423 | void slotWindowToDesktop(uint i); | ||
400 | 424 | | |||
401 | //void slotWindowToListPosition( int ); | 425 | //void slotWindowToListPosition( int ); | ||
402 | void slotSwitchToScreen(); | 426 | void slotSwitchToScreen(); | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 497 | Q_SIGNALS: | |||
492 | void configChanged(); | 516 | void configChanged(); | ||
493 | void showingDesktopChanged(bool showing); | 517 | void showingDesktopChanged(bool showing); | ||
494 | /** | 518 | /** | ||
495 | * This signels is emitted when ever the stacking order is change, ie. a window is risen | 519 | * This signels is emitted when ever the stacking order is change, ie. a window is risen | ||
496 | * or lowered | 520 | * or lowered | ||
497 | */ | 521 | */ | ||
498 | void stackingOrderChanged(); | 522 | void stackingOrderChanged(); | ||
499 | 523 | | |||
524 | /** | ||||
525 | * This signal is emitted whenever an internal client is created. | ||||
526 | */ | ||||
527 | void internalClientAdded(KWin::InternalClient *client); | ||||
528 | | ||||
529 | /** | ||||
530 | * This signal is emitted whenever an internal client gets removed. | ||||
531 | */ | ||||
532 | void internalClientRemoved(KWin::InternalClient *client); | ||||
533 | | ||||
500 | private: | 534 | private: | ||
501 | void init(); | 535 | void init(); | ||
502 | void initWithX11(); | 536 | void initWithX11(); | ||
503 | void initShortcuts(); | 537 | void initShortcuts(); | ||
504 | template <typename Slot> | 538 | template <typename Slot> | ||
505 | void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, | 539 | void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, | ||
506 | Slot slot, const QVariant &data = QVariant()); | 540 | Slot slot, const QVariant &data = QVariant()); | ||
507 | template <typename T, typename Slot> | 541 | template <typename T, typename Slot> | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
559 | AbstractClient* delayfocus_client; | 593 | AbstractClient* delayfocus_client; | ||
560 | QPoint focusMousePos; | 594 | QPoint focusMousePos; | ||
561 | 595 | | |||
562 | ClientList clients; | 596 | ClientList clients; | ||
563 | QList<AbstractClient*> m_allClients; | 597 | QList<AbstractClient*> m_allClients; | ||
564 | ClientList desktops; | 598 | ClientList desktops; | ||
565 | UnmanagedList unmanaged; | 599 | UnmanagedList unmanaged; | ||
566 | DeletedList deleted; | 600 | DeletedList deleted; | ||
601 | QList<InternalClient *> m_internalClients; | ||||
567 | 602 | | |||
568 | ToplevelList unconstrained_stacking_order; // Topmost last | 603 | ToplevelList unconstrained_stacking_order; // Topmost last | ||
569 | ToplevelList stacking_order; // Topmost last | 604 | ToplevelList stacking_order; // Topmost last | ||
570 | QVector<xcb_window_t> manual_overlays; //Topmost last | 605 | QVector<xcb_window_t> manual_overlays; //Topmost last | ||
571 | bool force_restacking; | 606 | bool force_restacking; | ||
572 | ToplevelList x_stacking; // From XQueryTree() | 607 | ToplevelList x_stacking; // From XQueryTree() | ||
573 | std::unique_ptr<Xcb::Tree> m_xStackingQueryTree; | 608 | std::unique_ptr<Xcb::Tree> m_xStackingQueryTree; | ||
574 | bool m_xStackingDirty = false; | 609 | bool m_xStackingDirty = false; | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
626 | friend class StackingUpdatesBlocker; | 661 | friend class StackingUpdatesBlocker; | ||
627 | 662 | | |||
628 | QScopedPointer<KillWindow> m_windowKiller; | 663 | QScopedPointer<KillWindow> m_windowKiller; | ||
629 | 664 | | |||
630 | QList<X11EventFilter *> m_eventFilters; | 665 | QList<X11EventFilter *> m_eventFilters; | ||
631 | QList<X11EventFilter *> m_genericEventFilters; | 666 | QList<X11EventFilter *> m_genericEventFilters; | ||
632 | QScopedPointer<X11EventFilter> m_movingClientFilter; | 667 | QScopedPointer<X11EventFilter> m_movingClientFilter; | ||
633 | 668 | | |||
634 | private: | 669 | private: | ||
romangg: Is this really necessary? | |||||
I don't see any good reason to keep addInternalClient and removeInternalClient public. zzag: I don't see any good reason to keep addInternalClient and removeInternalClient public. | |||||
If it's really that important to keep Workspace class friend-free, I can make those two methods public. However, it'll pollute public interface of Workspace class. zzag: If it's really that important to keep Workspace class `friend`-free, I can make those two… | |||||
For example, X11EventFilter does something similar to what InternalClient does. It registers itself in a constructor and unregisters itself in the destructor. void registerEventFilter(X11EventFilter *filter); implies that one create X11EventFilter object on the heap, initialize it, and after that call registerEventFilter method. However, that's absolutely not true. Such implementation details have to be hidden. friend keyword is not a good thing, I don't deny it. However, in some cases it's a necessary measure to keep public stuff clean. zzag: For example, X11EventFilter does something similar to what InternalClient does. It registers… | |||||
635 | friend bool performTransiencyCheck(); | 670 | friend bool performTransiencyCheck(); | ||
636 | friend Workspace *workspace(); | 671 | friend Workspace *workspace(); | ||
637 | }; | 672 | }; | ||
638 | 673 | | |||
639 | /** | 674 | /** | ||
640 | * Helper for Workspace::blockStackingUpdates() being called in pairs (True/false) | 675 | * Helper for Workspace::blockStackingUpdates() being called in pairs (True/false) | ||
641 | */ | 676 | */ | ||
642 | class StackingUpdatesBlocker | 677 | class StackingUpdatesBlocker | ||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |
Is this really necessary?