Changeset View
Changeset View
Standalone View
Standalone View
src/server/xdgshell_v5_interface.cpp
1 | /**************************************************************************** | 1 | /**************************************************************************** | ||
---|---|---|---|---|---|
2 | Copyright 2016 Martin Gräßlin <mgraesslin@kde.org> | 2 | Copyright 2016 Martin Gräßlin <mgraesslin@kde.org> | ||
3 | Copyright 2019 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
3 | 4 | | |||
4 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) version 3, or any | 8 | version 2.1 of the License, or (at your option) version 3, or any | ||
8 | later version accepted by the membership of KDE e.V. (or its | 9 | later version accepted by the membership of KDE e.V. (or its | ||
9 | successor approved by the membership of KDE e.V.), which shall | 10 | successor approved by the membership of KDE e.V.), which shall | ||
10 | act as a proxy defined in Section 6 of version 3 of the license. | 11 | act as a proxy defined in Section 6 of version 3 of the license. | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
66 | }; | 67 | }; | ||
67 | 68 | | |||
68 | class XdgPopupV5Interface::Private : public XdgShellPopupInterface::Private | 69 | class XdgPopupV5Interface::Private : public XdgShellPopupInterface::Private | ||
69 | { | 70 | { | ||
70 | public: | 71 | public: | ||
71 | Private(XdgPopupV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource); | 72 | Private(XdgPopupV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource); | ||
72 | ~Private(); | 73 | ~Private(); | ||
73 | 74 | | |||
75 | QRect windowGeometry() const override; | ||||
76 | void commit() override; | ||||
74 | void popupDone() override; | 77 | void popupDone() override; | ||
75 | 78 | | |||
76 | XdgPopupV5Interface *q_func() { | 79 | XdgPopupV5Interface *q_func() { | ||
77 | return reinterpret_cast<XdgPopupV5Interface *>(q); | 80 | return reinterpret_cast<XdgPopupV5Interface *>(q); | ||
78 | } | 81 | } | ||
79 | 82 | | |||
80 | private: | 83 | private: | ||
81 | 84 | | |||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | |||||
238 | } | 241 | } | ||
239 | 242 | | |||
240 | class XdgSurfaceV5Interface::Private : public XdgShellSurfaceInterface::Private | 243 | class XdgSurfaceV5Interface::Private : public XdgShellSurfaceInterface::Private | ||
241 | { | 244 | { | ||
242 | public: | 245 | public: | ||
243 | Private(XdgSurfaceV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource); | 246 | Private(XdgSurfaceV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource); | ||
244 | ~Private(); | 247 | ~Private(); | ||
245 | 248 | | |||
249 | QRect windowGeometry() const override; | ||||
250 | QSize minimumSize() const override; | ||||
251 | QSize maximumSize() const override; | ||||
246 | void close() override; | 252 | void close() override; | ||
253 | void commit() override; | ||||
247 | quint32 configure(States states, const QSize &size) override; | 254 | quint32 configure(States states, const QSize &size) override; | ||
248 | 255 | | |||
249 | XdgSurfaceV5Interface *q_func() { | 256 | XdgSurfaceV5Interface *q_func() { | ||
250 | return reinterpret_cast<XdgSurfaceV5Interface *>(q); | 257 | return reinterpret_cast<XdgSurfaceV5Interface *>(q); | ||
251 | } | 258 | } | ||
252 | 259 | | |||
253 | private: | 260 | private: | ||
254 | static void setParentCallback(wl_client *client, wl_resource *resource, wl_resource * parent); | 261 | static void setParentCallback(wl_client *client, wl_resource *resource, wl_resource * parent); | ||
255 | static void showWindowMenuCallback(wl_client *client, wl_resource *resource, wl_resource * seat, uint32_t serial, int32_t x, int32_t y); | 262 | static void showWindowMenuCallback(wl_client *client, wl_resource *resource, wl_resource * seat, uint32_t serial, int32_t x, int32_t y); | ||
256 | static void ackConfigureCallback(wl_client *client, wl_resource *resource, uint32_t serial); | 263 | static void ackConfigureCallback(wl_client *client, wl_resource *resource, uint32_t serial); | ||
257 | static void setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); | 264 | static void setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); | ||
258 | static void setMaximizedCallback(wl_client *client, wl_resource *resource); | 265 | static void setMaximizedCallback(wl_client *client, wl_resource *resource); | ||
259 | static void unsetMaximizedCallback(wl_client *client, wl_resource *resource); | 266 | static void unsetMaximizedCallback(wl_client *client, wl_resource *resource); | ||
260 | static void setFullscreenCallback(wl_client *client, wl_resource *resource, wl_resource * output); | 267 | static void setFullscreenCallback(wl_client *client, wl_resource *resource, wl_resource * output); | ||
261 | static void unsetFullscreenCallback(wl_client *client, wl_resource *resource); | 268 | static void unsetFullscreenCallback(wl_client *client, wl_resource *resource); | ||
262 | static void setMinimizedCallback(wl_client *client, wl_resource *resource); | 269 | static void setMinimizedCallback(wl_client *client, wl_resource *resource); | ||
263 | 270 | | |||
264 | static const struct zxdg_surface_v5_interface s_interface; | 271 | static const struct zxdg_surface_v5_interface s_interface; | ||
272 | | ||||
273 | struct ShellSurfaceState | ||||
274 | { | ||||
275 | QRect windowGeometry; | ||||
276 | | ||||
277 | bool windowGeometryIsSet = false; | ||||
278 | }; | ||||
279 | | ||||
280 | ShellSurfaceState m_currentState; | ||||
281 | ShellSurfaceState m_pendingState; | ||||
265 | }; | 282 | }; | ||
266 | 283 | | |||
267 | namespace { | 284 | namespace { | ||
268 | template <> | 285 | template <> | ||
269 | Qt::Edges edgesToQtEdges(zxdg_surface_v5_resize_edge edges) | 286 | Qt::Edges edgesToQtEdges(zxdg_surface_v5_resize_edge edges) | ||
270 | { | 287 | { | ||
271 | Qt::Edges qtEdges; | 288 | Qt::Edges qtEdges; | ||
272 | switch (edges) { | 289 | switch (edges) { | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 369 | while (!s->configureSerials.isEmpty()) { | |||
355 | if (i == serial) { | 372 | if (i == serial) { | ||
356 | break; | 373 | break; | ||
357 | } | 374 | } | ||
358 | } | 375 | } | ||
359 | } | 376 | } | ||
360 | 377 | | |||
361 | void XdgSurfaceV5Interface::Private::setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) | 378 | void XdgSurfaceV5Interface::Private::setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) | ||
362 | { | 379 | { | ||
363 | // TODO: implement | 380 | if (width < 0 || height < 0) { | ||
364 | Q_UNUSED(client) | 381 | wl_resource_post_error(resource, -1, "Tried to set invalid xdg-surface geometry"); | ||
365 | Q_UNUSED(resource) | 382 | return; | ||
366 | Q_UNUSED(x) | 383 | } | ||
367 | Q_UNUSED(y) | 384 | auto s = cast<Private>(resource); | ||
368 | Q_UNUSED(width) | 385 | Q_ASSERT(client == *s->client); | ||
369 | Q_UNUSED(height) | 386 | s->m_pendingState.windowGeometry = QRect(x, y, width, height); | ||
387 | s->m_pendingState.windowGeometryIsSet = true; | ||||
370 | } | 388 | } | ||
371 | 389 | | |||
372 | void XdgSurfaceV5Interface::Private::setMaximizedCallback(wl_client *client, wl_resource *resource) | 390 | void XdgSurfaceV5Interface::Private::setMaximizedCallback(wl_client *client, wl_resource *resource) | ||
373 | { | 391 | { | ||
374 | auto s = cast<Private>(resource); | 392 | auto s = cast<Private>(resource); | ||
375 | Q_ASSERT(client == *s->client); | 393 | Q_ASSERT(client == *s->client); | ||
376 | s->q_func()->maximizedChanged(true); | 394 | s->q_func()->maximizedChanged(true); | ||
377 | } | 395 | } | ||
Show All 32 Lines | |||||
410 | 428 | | |||
411 | XdgSurfaceV5Interface::Private::Private(XdgSurfaceV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | 429 | XdgSurfaceV5Interface::Private::Private(XdgSurfaceV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | ||
412 | : XdgShellSurfaceInterface::Private(XdgShellInterfaceVersion::UnstableV5, q, c, surface, parentResource, &zxdg_surface_v5_interface, &s_interface) | 430 | : XdgShellSurfaceInterface::Private(XdgShellInterfaceVersion::UnstableV5, q, c, surface, parentResource, &zxdg_surface_v5_interface, &s_interface) | ||
413 | { | 431 | { | ||
414 | } | 432 | } | ||
415 | 433 | | |||
416 | XdgSurfaceV5Interface::Private::~Private() = default; | 434 | XdgSurfaceV5Interface::Private::~Private() = default; | ||
417 | 435 | | |||
436 | QRect XdgSurfaceV5Interface::Private::windowGeometry() const | ||||
437 | { | ||||
438 | return m_currentState.windowGeometry; | ||||
439 | } | ||||
440 | | ||||
441 | QSize XdgSurfaceV5Interface::Private::minimumSize() const | ||||
442 | { | ||||
443 | return QSize(0, 0); | ||||
444 | } | ||||
445 | | ||||
446 | QSize XdgSurfaceV5Interface::Private::maximumSize() const | ||||
447 | { | ||||
448 | return QSize(INT_MAX, INT_MAX); | ||||
449 | } | ||||
450 | | ||||
418 | void XdgSurfaceV5Interface::Private::close() | 451 | void XdgSurfaceV5Interface::Private::close() | ||
419 | { | 452 | { | ||
420 | zxdg_surface_v5_send_close(resource); | 453 | zxdg_surface_v5_send_close(resource); | ||
421 | client->flush(); | 454 | client->flush(); | ||
422 | } | 455 | } | ||
423 | 456 | | |||
457 | void XdgSurfaceV5Interface::Private::commit() | ||||
458 | { | ||||
459 | const bool windowGeometryChanged = m_pendingState.windowGeometryIsSet; | ||||
460 | | ||||
461 | if (windowGeometryChanged) { | ||||
462 | m_currentState.windowGeometry = m_pendingState.windowGeometry; | ||||
463 | } | ||||
464 | | ||||
465 | m_pendingState = ShellSurfaceState{}; | ||||
466 | | ||||
467 | if (windowGeometryChanged) { | ||||
468 | emit q_func()->windowGeometryChanged(m_currentState.windowGeometry); | ||||
469 | } | ||||
470 | } | ||||
471 | | ||||
424 | quint32 XdgSurfaceV5Interface::Private::configure(States states, const QSize &size) | 472 | quint32 XdgSurfaceV5Interface::Private::configure(States states, const QSize &size) | ||
425 | { | 473 | { | ||
426 | if (!resource) { | 474 | if (!resource) { | ||
427 | return 0; | 475 | return 0; | ||
428 | } | 476 | } | ||
429 | const quint32 serial = global->display()->nextSerial(); | 477 | const quint32 serial = global->display()->nextSerial(); | ||
430 | wl_array state; | 478 | wl_array state; | ||
431 | wl_array_init(&state); | 479 | wl_array_init(&state); | ||
Show All 29 Lines | |||||
461 | 509 | | |||
462 | XdgPopupV5Interface::Private::Private(XdgPopupV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | 510 | XdgPopupV5Interface::Private::Private(XdgPopupV5Interface *q, XdgShellV5Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | ||
463 | : XdgShellPopupInterface::Private(XdgShellInterfaceVersion::UnstableV5, q, c, surface, parentResource, &zxdg_popup_v5_interface, &s_interface) | 511 | : XdgShellPopupInterface::Private(XdgShellInterfaceVersion::UnstableV5, q, c, surface, parentResource, &zxdg_popup_v5_interface, &s_interface) | ||
464 | { | 512 | { | ||
465 | } | 513 | } | ||
466 | 514 | | |||
467 | XdgPopupV5Interface::Private::~Private() = default; | 515 | XdgPopupV5Interface::Private::~Private() = default; | ||
468 | 516 | | |||
517 | QRect XdgPopupV5Interface::Private::windowGeometry() const | ||||
518 | { | ||||
519 | return QRect(); | ||||
520 | } | ||||
521 | | ||||
522 | void XdgPopupV5Interface::Private::commit() | ||||
523 | { | ||||
524 | } | ||||
469 | 525 | | |||
470 | void XdgPopupV5Interface::Private::popupDone() | 526 | void XdgPopupV5Interface::Private::popupDone() | ||
471 | { | 527 | { | ||
472 | if (!resource) { | 528 | if (!resource) { | ||
473 | return; | 529 | return; | ||
474 | } | 530 | } | ||
475 | // TODO: dismiss all child popups | 531 | // TODO: dismiss all child popups | ||
476 | zxdg_popup_v5_send_popup_done(resource); | 532 | zxdg_popup_v5_send_popup_done(resource); | ||
Show All 32 Lines |