22
22
#include < QRect>
23
23
#include < QIcon>
24
24
#include " waylandbackend.h"
25
- #include " wlr-foreign-toplevel-management-unstable-v1-proto.h"
26
25
27
26
struct WaylandWindowPrivate {
28
- zwlr_foreign_toplevel_handle_v1* handle;
29
27
WaylandBackend* backend;
30
28
WaylandWindowEventListener* listener;
31
29
@@ -49,85 +47,13 @@ struct WaylandWindowEventListener {
49
47
WaylandWindowEventListener (WaylandWindow* parentWindow) {
50
48
this ->parent = parentWindow;
51
49
}
52
-
53
- void titleChanged (QString title) {
54
- this ->parent ->d ->title = title;
55
- emit this ->parent ->titleChanged ();
56
- }
57
-
58
- void applicationChanged (QString application) {
59
- ApplicationPointer newApp (new Application (application));
60
- if (newApp->isValid ()) {
61
- this ->parent ->d ->application = newApp;
62
- } else {
63
- this ->parent ->d ->application .clear ();
64
- }
65
-
66
- emit this ->parent ->applicationChanged ();
67
- emit this ->parent ->iconChanged ();
68
- }
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
-
89
- void closed () {
90
- this ->parent ->d ->backend ->signalToplevelClosed (this ->parent ->d ->handle );
91
- }
92
50
};
93
51
94
- WaylandWindow::WaylandWindow (zwlr_foreign_toplevel_handle_v1* handle, WaylandBackend* backend) : DesktopWmWindow() {
52
+ WaylandWindow::WaylandWindow (:: zwlr_foreign_toplevel_handle_v1* handle, WaylandBackend* backend) : DesktopWmWindow(), QtWayland::zwlr_foreign_toplevel_handle_v1(handle ) {
95
53
d = new WaylandWindowPrivate ();
96
- d->handle = handle;
97
54
d->backend = backend;
98
55
99
56
d->listener = new WaylandWindowEventListener (this );
100
-
101
- zwlr_foreign_toplevel_handle_v1_listener* listener = new zwlr_foreign_toplevel_handle_v1_listener ();
102
- listener->title = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1, const char * title) {
103
- Q_UNUSED (zwlr_foreign_toplevel_handle_v1)
104
- static_cast <WaylandWindowEventListener*>(data)->titleChanged (QString::fromLocal8Bit (title));
105
- };
106
- listener->app_id = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1, const char * app_id) {
107
- Q_UNUSED (zwlr_foreign_toplevel_handle_v1)
108
- static_cast <WaylandWindowEventListener*>(data)->applicationChanged (QString::fromLocal8Bit (app_id));
109
- };
110
- listener->output_enter = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1, struct wl_output * output) {
111
-
112
- };
113
- listener->output_leave = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1, struct wl_output * output) {
114
-
115
- };
116
- listener->state = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1, struct wl_array * state) {
117
- Q_UNUSED (zwlr_foreign_toplevel_handle_v1)
118
- static_cast <WaylandWindowEventListener*>(data)->stateChanged (state);
119
- };
120
- listener->done = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1) {
121
-
122
- };
123
- listener->closed = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1) {
124
- Q_UNUSED (zwlr_foreign_toplevel_handle_v1)
125
- static_cast <WaylandWindowEventListener*>(data)->closed ();
126
- };
127
- listener->parent = [](void * data, struct zwlr_foreign_toplevel_handle_v1 * zwlr_foreign_toplevel_handle_v1, struct zwlr_foreign_toplevel_handle_v1 * parent) {
128
-
129
- };
130
- zwlr_foreign_toplevel_handle_v1_add_listener (handle, listener, d->listener );
131
57
wl_display_roundtrip (backend->display ());
132
58
}
133
59
@@ -190,12 +116,54 @@ ApplicationPointer WaylandWindow::application() {
190
116
191
117
void WaylandWindow::activate () {
192
118
wl_seat* seat = d->backend ->seat ();
193
- zwlr_foreign_toplevel_handle_v1_activate (d-> handle , seat);
119
+ this -> QtWayland ::zwlr_foreign_toplevel_handle_v1::activate ( seat);
194
120
}
195
121
196
- void WaylandWindow::close () {
197
- zwlr_foreign_toplevel_handle_v1_close (d->handle );
122
+ void WaylandWindow::kill () {
198
123
}
199
124
200
- void WaylandWindow::kill () {
125
+
126
+ void WaylandWindow::zwlr_foreign_toplevel_handle_v1_title (const QString& title) {
127
+ d->title = title;
128
+ emit titleChanged ();
129
+ }
130
+
131
+ void WaylandWindow::zwlr_foreign_toplevel_handle_v1_app_id (const QString& app_id) {
132
+ ApplicationPointer newApp (new Application (app_id));
133
+ if (newApp->isValid ()) {
134
+ d->application = newApp;
135
+ } else {
136
+ d->application .clear ();
137
+ }
138
+
139
+ emit applicationChanged ();
140
+ emit iconChanged ();
141
+ }
142
+
143
+ void WaylandWindow::zwlr_foreign_toplevel_handle_v1_state (wl_array* state) {
144
+ WaylandWindowPrivate::WindowStateFlags windowState = WaylandWindowPrivate::NoState;
145
+ for (quint32* flag = static_cast <quint32*>(state->data ); reinterpret_cast <char *>(flag) < (static_cast <char *>(state->data ) + state->size ); flag++) {
146
+ if (*flag == ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED) {
147
+ windowState |= WaylandWindowPrivate::Activated;
148
+ }
149
+ if (*flag == ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED) {
150
+ windowState |= WaylandWindowPrivate::Maximised;
151
+ }
152
+ if (*flag == ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED) {
153
+ windowState |= WaylandWindowPrivate::Minimised;
154
+ }
155
+ }
156
+
157
+ d->state = windowState;
158
+ emit windowStateChanged ();
159
+ emit d->backend ->activeWindowChanged ();
160
+ }
161
+
162
+ void WaylandWindow::zwlr_foreign_toplevel_handle_v1_closed () {
163
+ d->backend ->signalToplevelClosed (this ->object ());
164
+ d->backend ->activeWindowChanged ();
165
+ }
166
+
167
+ void WaylandWindow::close () {
168
+ this ->QtWayland ::zwlr_foreign_toplevel_handle_v1::close ();
201
169
}
0 commit comments