Changeset View
Changeset View
Standalone View
Standalone View
abstract_client.h
Show All 17 Lines | |||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #ifndef KWIN_ABSTRACT_CLIENT_H | 20 | #ifndef KWIN_ABSTRACT_CLIENT_H | ||
21 | #define KWIN_ABSTRACT_CLIENT_H | 21 | #define KWIN_ABSTRACT_CLIENT_H | ||
22 | 22 | | |||
23 | #include "toplevel.h" | 23 | #include "toplevel.h" | ||
24 | #include "options.h" | 24 | #include "options.h" | ||
25 | #include "rules.h" | 25 | #include "rules.h" | ||
26 | #include "tabgroup.h" | | |||
27 | #include "cursor.h" | 26 | #include "cursor.h" | ||
28 | 27 | | |||
29 | #include <memory> | 28 | #include <memory> | ||
30 | 29 | | |||
31 | #include <QElapsedTimer> | 30 | #include <QElapsedTimer> | ||
32 | #include <QPointer> | 31 | #include <QPointer> | ||
33 | 32 | | |||
34 | namespace KWayland | 33 | namespace KWayland | ||
Show All 36 Lines | 61 | { | |||
71 | 70 | | |||
72 | /** | 71 | /** | ||
73 | * Whether the Client can be set to fullScreen. The property is evaluated each time it is invoked. | 72 | * Whether the Client can be set to fullScreen. The property is evaluated each time it is invoked. | ||
74 | * Because of that there is no notify signal. | 73 | * Because of that there is no notify signal. | ||
75 | */ | 74 | */ | ||
76 | Q_PROPERTY(bool fullScreenable READ isFullScreenable) | 75 | Q_PROPERTY(bool fullScreenable READ isFullScreenable) | ||
77 | 76 | | |||
78 | /** | 77 | /** | ||
79 | * Whether this Client is the currently visible Client in its Client Group (Window Tabs). | | |||
80 | * For change connect to the visibleChanged signal on the Client's Group. | | |||
81 | */ | | |||
82 | Q_PROPERTY(bool isCurrentTab READ isCurrentTab) | | |||
83 | | ||||
84 | /** | | |||
85 | * Whether this Client is active or not. Use Workspace::activateClient() to activate a Client. | 78 | * Whether this Client is active or not. Use Workspace::activateClient() to activate a Client. | ||
86 | * @see Workspace::activateClient | 79 | * @see Workspace::activateClient | ||
87 | */ | 80 | */ | ||
88 | Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) | 81 | Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) | ||
89 | 82 | | |||
90 | /** | 83 | /** | ||
91 | * The desktop this Client is on. If the Client is on all desktops the property has value -1. | 84 | * The desktop this Client is on. If the Client is on all desktops the property has value -1. | ||
92 | * This is a legacy property, use x11DesktopIds instead | 85 | * This is a legacy property, use x11DesktopIds instead | ||
▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Line(s) | |||||
314 | * Whether this client is unresponsive. | 307 | * Whether this client is unresponsive. | ||
315 | * | 308 | * | ||
316 | * When an application failed to react on a ping request in time, it is | 309 | * When an application failed to react on a ping request in time, it is | ||
317 | * considered unresponsive. This usually indicates that the application froze or crashed. | 310 | * considered unresponsive. This usually indicates that the application froze or crashed. | ||
318 | */ | 311 | */ | ||
319 | Q_PROPERTY(bool unresponsive READ unresponsive NOTIFY unresponsiveChanged) | 312 | Q_PROPERTY(bool unresponsive READ unresponsive NOTIFY unresponsiveChanged) | ||
320 | 313 | | |||
321 | /** | 314 | /** | ||
322 | * The "Window Tabs" Group this Client belongs to. | | |||
323 | */ | | |||
324 | Q_PROPERTY(KWin::TabGroup* tabGroup READ tabGroup NOTIFY tabGroupChanged SCRIPTABLE false) | | |||
325 | | ||||
326 | /** | | |||
327 | * The color scheme set on this client | 315 | * The color scheme set on this client | ||
328 | * Absolute file path, or name of palette in the user's config directory following KColorSchemes format. | 316 | * Absolute file path, or name of palette in the user's config directory following KColorSchemes format. | ||
329 | * An empty string indicates the default palette from kdeglobals is used. | 317 | * An empty string indicates the default palette from kdeglobals is used. | ||
330 | * @note this indicates the colour scheme requested, which might differ from the theme applied if the colorScheme cannot be found | 318 | * @note this indicates the colour scheme requested, which might differ from the theme applied if the colorScheme cannot be found | ||
331 | */ | 319 | */ | ||
332 | Q_PROPERTY(QString colorScheme READ colorScheme NOTIFY colorSchemeChanged) | 320 | Q_PROPERTY(QString colorScheme READ colorScheme NOTIFY colorSchemeChanged) | ||
333 | 321 | | |||
334 | public: | 322 | public: | ||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Line(s) | |||||
489 | * Minimizes this client plus its transients | 477 | * Minimizes this client plus its transients | ||
490 | */ | 478 | */ | ||
491 | void minimize(bool avoid_animation = false); | 479 | void minimize(bool avoid_animation = false); | ||
492 | void unminimize(bool avoid_animation = false); | 480 | void unminimize(bool avoid_animation = false); | ||
493 | bool isMinimized() const { | 481 | bool isMinimized() const { | ||
494 | return m_minimized; | 482 | return m_minimized; | ||
495 | } | 483 | } | ||
496 | virtual void setFullScreen(bool set, bool user = true) = 0; | 484 | virtual void setFullScreen(bool set, bool user = true) = 0; | ||
497 | // Tabbing functions | 485 | | ||
498 | Q_INVOKABLE inline bool tabBefore(AbstractClient *other, bool activate) { return tabTo(other, false, activate); } | | |||
499 | Q_INVOKABLE inline bool tabBehind(AbstractClient *other, bool activate) { return tabTo(other, true, activate); } | | |||
500 | /** | | |||
501 | * Syncs the *dynamic* @p property @p fromThisClient or the currentTab() to | | |||
502 | * all members of the tabGroup() (if there is one) | | |||
503 | * | | |||
504 | * eg. if you call: | | |||
505 | * @code | | |||
506 | * client->setProperty("kwin_tiling_floats", true); | | |||
507 | * client->syncTabGroupFor("kwin_tiling_floats", true) | | |||
508 | * @endcode | | |||
509 | * all clients in this tabGroup will have property("kwin_tiling_floats").toBool() == true | | |||
510 | * | | |||
511 | * WARNING: non dynamic properties are ignored - you're not supposed to alter/update such explicitly | | |||
512 | */ | | |||
513 | Q_INVOKABLE void syncTabGroupFor(QString property, bool fromThisClient = false); | | |||
514 | TabGroup *tabGroup() const; | | |||
515 | /** | | |||
516 | * Set tab group - this is to be invoked by TabGroup::add/remove(client) and NO ONE ELSE | | |||
517 | */ | | |||
518 | void setTabGroup(TabGroup* group); | | |||
519 | virtual void setClientShown(bool shown); | 486 | virtual void setClientShown(bool shown); | ||
520 | Q_INVOKABLE bool untab(const QRect &toGeometry = QRect(), bool clientRemoved = false); | 487 | | ||
521 | /** | | |||
522 | * When a click is done in the decoration and it calls the group | | |||
523 | * to change the visible client it starts to move-resize the new | | |||
524 | * client, this function stops it. | | |||
525 | */ | | |||
526 | bool isCurrentTab() const; | | |||
527 | virtual QRect geometryRestore() const = 0; | 488 | virtual QRect geometryRestore() const = 0; | ||
528 | /** | 489 | /** | ||
529 | * The currently applied maximize mode | 490 | * The currently applied maximize mode | ||
530 | */ | 491 | */ | ||
531 | virtual MaximizeMode maximizeMode() const = 0; | 492 | virtual MaximizeMode maximizeMode() const = 0; | ||
532 | /** | 493 | /** | ||
533 | * The maximise mode requested by the server. | 494 | * The maximise mode requested by the server. | ||
534 | * For X this always matches maximizeMode, for wayland clients it | 495 | * For X this always matches maximizeMode, for wayland clients it | ||
▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Line(s) | 840 | Q_SIGNALS: | |||
912 | void closeableChanged(bool); | 873 | void closeableChanged(bool); | ||
913 | void minimizeableChanged(bool); | 874 | void minimizeableChanged(bool); | ||
914 | void shadeableChanged(bool); | 875 | void shadeableChanged(bool); | ||
915 | void maximizeableChanged(bool); | 876 | void maximizeableChanged(bool); | ||
916 | void desktopFileNameChanged(); | 877 | void desktopFileNameChanged(); | ||
917 | void hasApplicationMenuChanged(bool); | 878 | void hasApplicationMenuChanged(bool); | ||
918 | void applicationMenuActiveChanged(bool); | 879 | void applicationMenuActiveChanged(bool); | ||
919 | void unresponsiveChanged(bool); | 880 | void unresponsiveChanged(bool); | ||
920 | /** | | |||
921 | * Emitted whenever the Client's TabGroup changed. That is whenever the Client is moved to | | |||
922 | * another group, but not when a Client gets added or removed to the Client's ClientGroup. | | |||
923 | */ | | |||
924 | void tabGroupChanged(); | | |||
925 | 881 | | |||
926 | protected: | 882 | protected: | ||
927 | AbstractClient(); | 883 | AbstractClient(); | ||
928 | void setFirstInTabBox(bool enable) { | 884 | void setFirstInTabBox(bool enable) { | ||
929 | m_firstInTabBox = enable; | 885 | m_firstInTabBox = enable; | ||
930 | } | 886 | } | ||
931 | void setIcon(const QIcon &icon); | 887 | void setIcon(const QIcon &icon); | ||
932 | void startAutoRaise(); | 888 | void startAutoRaise(); | ||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | |||||
1049 | /** | 1005 | /** | ||
1050 | * Schedules a repaint for the visibleRect before and after a | 1006 | * Schedules a repaint for the visibleRect before and after a | ||
1051 | * geometry update. The current visibleRect is stored for the | 1007 | * geometry update. The current visibleRect is stored for the | ||
1052 | * next time this method is called as the before geometry. | 1008 | * next time this method is called as the before geometry. | ||
1053 | */ | 1009 | */ | ||
1054 | void addRepaintDuringGeometryUpdates(); | 1010 | void addRepaintDuringGeometryUpdates(); | ||
1055 | 1011 | | |||
1056 | /** | 1012 | /** | ||
1057 | * Convenient method to update the TabGroup states if there is one present. | | |||
1058 | * Marked as virtual as TabGroup does not yet handle AbstractClient, but only | | |||
1059 | * subclasses of AbstractClient. Given that the default implementation does nothing. | | |||
1060 | */ | | |||
1061 | virtual void updateTabGroupStates(TabGroup::States states); | | |||
1062 | | ||||
1063 | /** | | |||
1064 | * @returns whether the Client is currently in move resize mode | 1013 | * @returns whether the Client is currently in move resize mode | ||
1065 | */ | 1014 | */ | ||
1066 | bool isMoveResize() const { | 1015 | bool isMoveResize() const { | ||
1067 | return m_moveResize.enabled; | 1016 | return m_moveResize.enabled; | ||
1068 | } | 1017 | } | ||
1069 | /** | 1018 | /** | ||
1070 | * Sets whether the Client is in move resize mode to @p enabled. | 1019 | * Sets whether the Client is in move resize mode to @p enabled. | ||
1071 | */ | 1020 | */ | ||
▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Line(s) | 1177 | private: | |||
1298 | QString m_applicationMenuServiceName; | 1247 | QString m_applicationMenuServiceName; | ||
1299 | QString m_applicationMenuObjectPath; | 1248 | QString m_applicationMenuObjectPath; | ||
1300 | 1249 | | |||
1301 | bool m_unresponsive = false; | 1250 | bool m_unresponsive = false; | ||
1302 | 1251 | | |||
1303 | QKeySequence _shortcut; | 1252 | QKeySequence _shortcut; | ||
1304 | 1253 | | |||
1305 | WindowRules m_rules; | 1254 | WindowRules m_rules; | ||
1306 | TabGroup* tab_group = nullptr; | | |||
1307 | 1255 | | |||
1308 | static bool s_haveResizeEffect; | 1256 | static bool s_haveResizeEffect; | ||
1309 | }; | 1257 | }; | ||
1310 | 1258 | | |||
1311 | /** | 1259 | /** | ||
1312 | * Helper for AbstractClient::blockGeometryUpdates() being called in pairs (true/false) | 1260 | * Helper for AbstractClient::blockGeometryUpdates() being called in pairs (true/false) | ||
1313 | */ | 1261 | */ | ||
1314 | class GeometryUpdatesBlocker | 1262 | class GeometryUpdatesBlocker | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 1313 | { | |||
1366 | return m_pendingGeometryUpdate; | 1314 | return m_pendingGeometryUpdate; | ||
1367 | } | 1315 | } | ||
1368 | 1316 | | |||
1369 | inline void AbstractClient::setPendingGeometryUpdate(PendingGeometry_t update) | 1317 | inline void AbstractClient::setPendingGeometryUpdate(PendingGeometry_t update) | ||
1370 | { | 1318 | { | ||
1371 | m_pendingGeometryUpdate = update; | 1319 | m_pendingGeometryUpdate = update; | ||
1372 | } | 1320 | } | ||
1373 | 1321 | | |||
1374 | inline TabGroup* AbstractClient::tabGroup() const | | |||
1375 | { | | |||
1376 | return tab_group; | | |||
1377 | } | | |||
1378 | | ||||
1379 | } | 1322 | } | ||
1380 | 1323 | | |||
1381 | Q_DECLARE_METATYPE(KWin::AbstractClient*) | 1324 | Q_DECLARE_METATYPE(KWin::AbstractClient*) | ||
1382 | Q_DECLARE_METATYPE(QList<KWin::AbstractClient*>) | 1325 | Q_DECLARE_METATYPE(QList<KWin::AbstractClient*>) | ||
1383 | Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractClient::SameApplicationChecks) | 1326 | Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractClient::SameApplicationChecks) | ||
1384 | 1327 | | |||
1385 | #endif | 1328 | #endif |