@@ -31,6 +31,16 @@ struct WaylandWindowPrivate {
31
31
32
32
QString title;
33
33
ApplicationPointer application;
34
+
35
+ enum WindowState {
36
+ NoState = 0 ,
37
+ Activated = 1 ,
38
+ Maximised = 2 ,
39
+ Minimised = 4
40
+ };
41
+ typedef QFlags<WindowState> WindowStateFlags;
42
+
43
+ WindowStateFlags state = NoState;
34
44
};
35
45
36
46
struct WaylandWindowEventListener {
@@ -57,6 +67,25 @@ struct WaylandWindowEventListener {
57
67
emit this ->parent ->iconChanged ();
58
68
}
59
69
70
+ void stateChanged (wl_array* state) {
71
+ WaylandWindowPrivate::WindowStateFlags windowState = WaylandWindowPrivate::NoState;
72
+ for (quint32* flag = static_cast <quint32*>(state->data ); reinterpret_cast <char *>(flag) < (static_cast <char *>(state->data ) + state->size ); flag++) {
73
+ if (*flag == ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED) {
74
+ windowState |= WaylandWindowPrivate::Activated;
75
+ }
76
+ if (*flag == ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED) {
77
+ windowState |= WaylandWindowPrivate::Maximised;
78
+ }
79
+ if (*flag == ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED) {
80
+ windowState |= WaylandWindowPrivate::Minimised;
81
+ }
82
+ }
83
+
84
+ this ->parent ->d ->state = windowState;
85
+ emit this ->parent ->windowStateChanged ();
86
+ emit this ->parent ->d ->backend ->activeWindowChanged ();
87
+ }
88
+
60
89
void closed () {
61
90
this ->parent ->d ->backend ->signalToplevelClosed (this ->parent ->d ->handle );
62
91
}
@@ -85,7 +114,8 @@ WaylandWindow::WaylandWindow(zwlr_foreign_toplevel_handle_v1* handle, WaylandBac
85
114
86
115
};
87
116
listener->state = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1, struct wl_array * state) {
88
-
117
+ Q_UNUSED (zwlr_foreign_toplevel_handle_v1)
118
+ static_cast <WaylandWindowEventListener*>(data)->stateChanged (state);
89
119
};
90
120
listener->done = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1) {
91
121
@@ -106,6 +136,10 @@ WaylandWindow::~WaylandWindow() {
106
136
delete d;
107
137
}
108
138
139
+ bool WaylandWindow::isActive () {
140
+ return d->state & WaylandWindowPrivate::Activated;
141
+ }
142
+
109
143
QString WaylandWindow::title () {
110
144
return d->title ;
111
145
}
@@ -120,11 +154,11 @@ QIcon WaylandWindow::icon() {
120
154
}
121
155
122
156
bool WaylandWindow::isMinimized () {
123
- return false ;
157
+ return d-> state & WaylandWindowPrivate::Minimised ;
124
158
}
125
159
126
160
bool WaylandWindow::isMaximised () {
127
- return false ;
161
+ return d-> state & WaylandWindowPrivate::Maximised ;
128
162
}
129
163
130
164
bool WaylandWindow::isFullScreen () {
0 commit comments