KWin
Loading...
Searching...
No Matches
effectwindow.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
3 SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com>
4 SPDX-FileCopyrightText: 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
5 SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "kwin_export.h"
13
14#include <NETWM>
15
16#include <QObject>
17
18class QWindow;
19
20namespace KDecoration2
21{
22class Decoration;
23}
24
25namespace KWin
26{
27
28class EffectWindowGroup;
29class EffectWindowVisibleRef;
30class Group;
31class Output;
32class SurfaceInterface;
33class VirtualDesktop;
34class Window;
35class WindowItem;
36
43class KWIN_EXPORT EffectWindow : public QObject
44{
45 Q_OBJECT
46 Q_PROPERTY(QRectF geometry READ frameGeometry)
47 Q_PROPERTY(QRectF expandedGeometry READ expandedGeometry)
48 Q_PROPERTY(qreal height READ height)
49 Q_PROPERTY(qreal opacity READ opacity)
50 Q_PROPERTY(QPointF pos READ pos)
51 Q_PROPERTY(KWin::Output *screen READ screen)
52 Q_PROPERTY(QSizeF size READ size)
53 Q_PROPERTY(qreal width READ width)
54 Q_PROPERTY(qreal x READ x)
55 Q_PROPERTY(qreal y READ y)
56 Q_PROPERTY(QList<KWin::VirtualDesktop *> desktops READ desktops)
57 Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops)
58 Q_PROPERTY(bool onCurrentDesktop READ isOnCurrentDesktop)
59 Q_PROPERTY(QRectF rect READ rect)
60 Q_PROPERTY(QString windowClass READ windowClass)
61 Q_PROPERTY(QString windowRole READ windowRole)
66 Q_PROPERTY(bool desktopWindow READ isDesktop)
71 Q_PROPERTY(bool dock READ isDock)
76 Q_PROPERTY(bool toolbar READ isToolbar)
81 Q_PROPERTY(bool menu READ isMenu)
87 Q_PROPERTY(bool normalWindow READ isNormalWindow)
92 Q_PROPERTY(bool dialog READ isDialog)
98 Q_PROPERTY(bool splash READ isSplash)
103 Q_PROPERTY(bool utility READ isUtility)
109 Q_PROPERTY(bool dropdownMenu READ isDropdownMenu)
114 Q_PROPERTY(bool popupMenu READ isPopupMenu)
119 Q_PROPERTY(bool tooltip READ isTooltip)
124 Q_PROPERTY(bool notification READ isNotification)
129 Q_PROPERTY(bool criticalNotification READ isCriticalNotification)
134 Q_PROPERTY(bool onScreenDisplay READ isOnScreenDisplay)
139 Q_PROPERTY(bool comboBox READ isComboBox)
144 Q_PROPERTY(bool dndIcon READ isDNDIcon)
149 Q_PROPERTY(int windowType READ windowType)
154 Q_PROPERTY(bool managed READ isManaged)
158 Q_PROPERTY(bool deleted READ isDeleted)
162 Q_PROPERTY(QString caption READ caption)
166 Q_PROPERTY(bool keepAbove READ keepAbove)
170 Q_PROPERTY(bool keepBelow READ keepBelow)
174 Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized)
178 Q_PROPERTY(bool modal READ isModal)
184 Q_PROPERTY(bool moveable READ isMovable)
189 Q_PROPERTY(bool moveableAcrossScreens READ isMovableAcrossScreens)
194 Q_PROPERTY(QSizeF basicUnit READ basicUnit)
198 Q_PROPERTY(bool move READ isUserMove)
202 Q_PROPERTY(bool resize READ isUserResize)
207 Q_PROPERTY(QRectF iconGeometry READ iconGeometry)
213 Q_PROPERTY(bool specialWindow READ isSpecialWindow)
214 Q_PROPERTY(QIcon icon READ icon)
218 Q_PROPERTY(bool skipSwitcher READ isSkipSwitcher)
222 Q_PROPERTY(QRectF contentsRect READ contentsRect)
227 Q_PROPERTY(QRectF decorationInnerRect READ decorationInnerRect)
228 Q_PROPERTY(bool hasDecoration READ hasDecoration)
229 Q_PROPERTY(QStringList activities READ activities)
230 Q_PROPERTY(bool onCurrentActivity READ isOnCurrentActivity)
231 Q_PROPERTY(bool onAllActivities READ isOnAllActivities)
236 Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha)
246 Q_PROPERTY(bool visible READ isVisible)
253 Q_PROPERTY(bool skipsCloseAnimation READ skipsCloseAnimation)
254
259 Q_PROPERTY(bool fullScreen READ isFullScreen)
260
269 Q_PROPERTY(bool unresponsive READ isUnresponsive)
270
275 Q_PROPERTY(bool waylandClient READ isWaylandClient CONSTANT)
276
281 Q_PROPERTY(bool x11Client READ isX11Client CONSTANT)
282
291 Q_PROPERTY(bool popupWindow READ isPopupWindow CONSTANT)
292
299 Q_PROPERTY(QWindow *internalWindow READ internalWindow CONSTANT)
300
308 Q_PROPERTY(bool outline READ isOutline CONSTANT)
309
315 Q_PROPERTY(pid_t pid READ pid CONSTANT)
316
322 Q_PROPERTY(bool lockScreen READ isLockScreen CONSTANT)
323
327 Q_PROPERTY(bool hiddenByShowDesktop READ isHiddenByShowDesktop)
328
329public:
331 enum {
333 PAINT_DISABLED = 1 << 0,
335 PAINT_DISABLED_BY_DESKTOP = 1 << 1,
337 PAINT_DISABLED_BY_MINIMIZE = 1 << 2,
339 PAINT_DISABLED_BY_ACTIVITY = 1 << 3,
340 };
341
342 explicit EffectWindow(WindowItem *windowItem);
343 ~EffectWindow() override;
344
345 Q_SCRIPTABLE void addRepaint(const QRect &r);
346 Q_SCRIPTABLE void addRepaint(int x, int y, int w, int h);
347 Q_SCRIPTABLE void addRepaintFull();
348 Q_SCRIPTABLE void addLayerRepaint(const QRect &r);
349 Q_SCRIPTABLE void addLayerRepaint(int x, int y, int w, int h);
350
351 void refWindow();
352 void unrefWindow();
353
354 bool isDeleted() const;
355 bool isHidden() const;
357
358 bool isMinimized() const;
359 double opacity() const;
360
361 bool isOnCurrentActivity() const;
362 Q_SCRIPTABLE bool isOnActivity(const QString &id) const;
363 bool isOnAllActivities() const;
364 QStringList activities() const;
365
366 Q_SCRIPTABLE bool isOnDesktop(KWin::VirtualDesktop *desktop) const;
367 bool isOnCurrentDesktop() const;
368 bool isOnAllDesktops() const;
374 QList<KWin::VirtualDesktop *> desktops() const;
375
376 qreal x() const;
377 qreal y() const;
378 qreal width() const;
379 qreal height() const;
384 QSizeF basicUnit() const;
391 QRectF frameGeometry() const;
402 QRectF bufferGeometry() const;
403 QRectF clientGeometry() const;
409 QRectF expandedGeometry() const;
410 Output *screen() const;
411 QPointF pos() const;
412 QSizeF size() const;
413 QRectF rect() const;
414 bool isMovable() const;
416 bool isUserMove() const;
417 bool isUserResize() const;
418 QRectF iconGeometry() const;
419
423 QRectF contentsRect() const;
429 QRectF decorationInnerRect() const;
430 bool hasDecoration() const;
431 bool decorationHasAlpha() const;
436 KDecoration2::Decoration *decoration() const;
437 QByteArray readProperty(long atom, long type, int format) const;
438 void deleteProperty(long atom) const;
439
440 QString caption() const;
441 QIcon icon() const;
442 QString windowClass() const;
443 QString windowRole() const;
444 const EffectWindowGroup *group() const;
445
450 bool isDesktop() const;
455 bool isDock() const;
460 bool isToolbar() const;
465 bool isMenu() const;
471 bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
477 bool isSpecialWindow() const;
482 bool isDialog() const;
488 bool isSplash() const;
493 bool isUtility() const;
499 bool isDropdownMenu() const;
504 bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
509 bool isTooltip() const;
514 bool isNotification() const;
523 bool isAppletPopup() const;
528 bool isOnScreenDisplay() const;
533 bool isComboBox() const;
538 bool isDNDIcon() const;
543 NET::WindowType windowType() const;
548 bool isManaged() const; // whether it's managed or override-redirect
552 bool acceptsFocus() const;
556 bool keepAbove() const;
560 bool keepBelow() const;
561
562 bool isModal() const;
563 Q_SCRIPTABLE KWin::EffectWindow *findModal();
564 Q_SCRIPTABLE KWin::EffectWindow *transientFor();
565 Q_SCRIPTABLE QList<KWin::EffectWindow *> mainWindows() const;
566
571 bool isSkipSwitcher() const;
572
573 void setMinimized(bool minimize);
574 void minimize();
575 void unminimize();
576 Q_SCRIPTABLE void closeWindow();
577
581 bool isVisible() const;
582
587
592
596 bool isFullScreen() const;
597
601 bool isUnresponsive() const;
602
606 bool isWaylandClient() const;
607
611 bool isX11Client() const;
612
616 bool isPopupWindow() const;
617
621 QWindow *internalWindow() const;
622
626 bool isOutline() const;
627
631 bool isLockScreen() const;
632
636 pid_t pid() const;
637
641 qlonglong windowId() const;
650 QUuid internalId() const;
651
655 bool isInputMethod() const;
656
663 Q_SCRIPTABLE void setData(int role, const QVariant &data);
664 Q_SCRIPTABLE QVariant data(int role) const;
665
666 Window *window() const;
667 WindowItem *windowItem() const;
668 void elevate(bool elevate);
669
670Q_SIGNALS:
701 void windowStepUserMovedResized(KWin::EffectWindow *w, const QRectF &geometry);
709
721 void windowMaximizedStateChanged(KWin::EffectWindow *w, bool horizontal, bool vertical);
722
737 void windowMaximizedStateAboutToChange(KWin::EffectWindow *w, bool horizontal, bool vertical);
738
744 void windowFrameGeometryChanged(KWin::EffectWindow *window, const QRectF &oldGeometry);
745
753
760 void windowOpacityChanged(KWin::EffectWindow *w, qreal oldOpacity, qreal newOpacity);
784
791
798
805
812
817
822
831
843
844protected:
846 void refVisible(const EffectWindowVisibleRef *holder);
847 void unrefVisible(const EffectWindowVisibleRef *holder);
848
849private:
850 class Private;
851 std::unique_ptr<Private> d;
852};
853
858class KWIN_EXPORT EffectWindowDeletedRef
859{
860public:
862 : m_window(nullptr)
863 {
864 }
865
867 : m_window(window)
868 {
869 m_window->refWindow();
870 }
871
873 : m_window(other.m_window)
874 {
875 if (m_window) {
876 m_window->refWindow();
877 }
878 }
879
881 {
882 if (m_window) {
883 m_window->unrefWindow();
884 }
885 }
886
888 {
889 if (other.m_window) {
890 other.m_window->refWindow();
891 }
892 if (m_window) {
893 m_window->unrefWindow();
894 }
895 m_window = other.m_window;
896 return *this;
897 }
898
899 bool isNull() const
900 {
901 return m_window == nullptr;
902 }
903
904private:
905 EffectWindow *m_window;
906};
907
912class KWIN_EXPORT EffectWindowVisibleRef
913{
914public:
916 : m_window(nullptr)
917 , m_reason(0)
918 {
919 }
920
921 explicit EffectWindowVisibleRef(EffectWindow *window, int reason)
922 : m_window(window)
923 , m_reason(reason)
924 {
925 m_window->refVisible(this);
926 }
927
929 : m_window(other.m_window)
930 , m_reason(other.m_reason)
931 {
932 if (m_window) {
933 m_window->refVisible(this);
934 }
935 }
936
938 {
939 if (m_window) {
940 m_window->unrefVisible(this);
941 }
942 }
943
944 int reason() const
945 {
946 return m_reason;
947 }
948
950 {
951 if (other.m_window) {
952 other.m_window->refVisible(&other);
953 }
954 if (m_window) {
955 m_window->unrefVisible(this);
956 }
957 m_window = other.m_window;
958 m_reason = other.m_reason;
959 return *this;
960 }
961
962 bool isNull() const
963 {
964 return m_window == nullptr;
965 }
966
967private:
968 EffectWindow *m_window;
969 int m_reason;
970};
971
972class KWIN_EXPORT EffectWindowGroup
973{
974public:
975 explicit EffectWindowGroup(Group *group);
976 virtual ~EffectWindowGroup();
977
978 QList<EffectWindow *> members() const;
979
980private:
981 Group *m_group;
982};
983
984inline void EffectWindow::addRepaint(int x, int y, int w, int h)
985{
986 addRepaint(QRect(x, y, w, h));
987}
988
989inline void EffectWindow::addLayerRepaint(int x, int y, int w, int h)
990{
991 addLayerRepaint(QRect(x, y, w, h));
992}
993
994} // namespace KWin
EffectWindowDeletedRef(const EffectWindowDeletedRef &other)
EffectWindowDeletedRef & operator=(const EffectWindowDeletedRef &other)
EffectWindowDeletedRef(EffectWindow *window)
Representation of a window used by/for Effect classes.
bool isSkipSwitcher() const
QRectF expandedGeometry() const
void windowStartUserMovedResized(KWin::EffectWindow *w)
Q_SCRIPTABLE void addRepaint(const QRect &r)
QRectF clientGeometry() const
void windowDamaged(KWin::EffectWindow *w)
qreal height() const
bool isOnScreenDisplay() const
QString windowRole() const
bool isUtility() const
QSizeF size() const
bool acceptsFocus() const
Q_SCRIPTABLE void addLayerRepaint(const QRect &r)
bool isMinimized() const
void windowHidden(KWin::EffectWindow *w)
void windowDesktopsChanged(KWin::EffectWindow *window)
bool isOutline() const
void windowExpandedGeometryChanged(KWin::EffectWindow *window)
void windowKeepAboveChanged(KWin::EffectWindow *w)
void minimizedChanged(KWin::EffectWindow *w)
bool isUserResize() const
bool isDropdownMenu() const
void windowKeepBelowChanged(KWin::EffectWindow *w)
bool isAppletPopup() const
bool isNormalWindow() const
QRectF rect() const
bool isUnresponsive() const
void windowStepUserMovedResized(KWin::EffectWindow *w, const QRectF &geometry)
bool isSpecialWindow() const
pid_t pid() const
void windowDecorationChanged(KWin::EffectWindow *window)
QRectF iconGeometry() const
QPointF pos() const
QUuid internalId() const
QStringList activities() const
void windowFrameGeometryChanged(KWin::EffectWindow *window, const QRectF &oldGeometry)
bool isDock() const
bool isToolbar() const
bool decorationHasAlpha() const
bool keepAbove() const
QRectF bufferGeometry() const
bool isFullScreen() const
bool isPopupMenu() const
bool isDNDIcon() const
bool isDialog() const
void windowModalityChanged(KWin::EffectWindow *w)
void refVisible(const EffectWindowVisibleRef *holder)
bool isNotification() const
qreal x() const
bool isMovable() const
double opacity() const
qreal y() const
bool isMovableAcrossScreens() const
bool isTooltip() const
bool isInputMethod() const
bool isMenu() const
bool isSplash() const
bool isComboBox() const
SurfaceInterface * surface() const
void windowMaximizedStateAboutToChange(KWin::EffectWindow *w, bool horizontal, bool vertical)
bool isPopupWindow() const
QIcon icon() const
bool isHidden() const
bool isDesktop() const
bool isUserMove() const
bool skipsCloseAnimation() const
void windowOpacityChanged(KWin::EffectWindow *w, qreal oldOpacity, qreal newOpacity)
void windowUnresponsiveChanged(KWin::EffectWindow *w, bool unresponsive)
bool keepBelow() const
qreal width() const
friend EffectWindowVisibleRef
void windowFullScreenChanged(KWin::EffectWindow *w)
bool isCriticalNotification() const
void windowShown(KWin::EffectWindow *w)
bool isLockScreen() const
void windowFinishUserMovedResized(KWin::EffectWindow *w)
void windowMaximizedStateChanged(KWin::EffectWindow *w, bool horizontal, bool vertical)
bool isHiddenByShowDesktop() const
void windowFrameGeometryAboutToChange(KWin::EffectWindow *window)
QString caption() const
QRectF frameGeometry() const
QList< KWin::VirtualDesktop * > desktops() const
bool isModal() const
bool isDeleted() const
EffectWindowVisibleRef(const EffectWindowVisibleRef &other)
EffectWindowVisibleRef & operator=(const EffectWindowVisibleRef &other)
EffectWindowVisibleRef(EffectWindow *window, int reason)
Resource representing a wl_surface.
Definition surface.h:80