Changeset View
Changeset View
Standalone View
Standalone View
src/server/xdgshell_v6_interface.cpp
1 | /**************************************************************************** | 1 | /**************************************************************************** | ||
---|---|---|---|---|---|
2 | Copyright 2017 David Edmundson <davidedmundson@kde.org> | 2 | Copyright 2017 David Edmundson <davidedmundson@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 58 Lines • ▼ Show 20 Line(s) | |||||
69 | }; | 70 | }; | ||
70 | 71 | | |||
71 | class XdgPopupV6Interface::Private : public XdgShellPopupInterface::Private | 72 | class XdgPopupV6Interface::Private : public XdgShellPopupInterface::Private | ||
72 | { | 73 | { | ||
73 | public: | 74 | public: | ||
74 | Private(XdgPopupV6Interface *q, XdgShellV6Interface *c, SurfaceInterface *surface, wl_resource *parentResource); | 75 | Private(XdgPopupV6Interface *q, XdgShellV6Interface *c, SurfaceInterface *surface, wl_resource *parentResource); | ||
75 | ~Private(); | 76 | ~Private(); | ||
76 | 77 | | |||
78 | QRect windowGeometry() const override; | ||||
79 | void commit() override; | ||||
80 | | ||||
77 | void ackConfigure(quint32 serial) { | 81 | void ackConfigure(quint32 serial) { | ||
78 | if (!configureSerials.contains(serial)) { | 82 | if (!configureSerials.contains(serial)) { | ||
79 | // TODO: send error? | 83 | // TODO: send error? | ||
80 | return; | 84 | return; | ||
81 | } | 85 | } | ||
82 | while (!configureSerials.isEmpty()) { | 86 | while (!configureSerials.isEmpty()) { | ||
83 | quint32 i = configureSerials.takeFirst(); | 87 | quint32 i = configureSerials.takeFirst(); | ||
84 | emit q_func()->configureAcknowledged(i); | 88 | emit q_func()->configureAcknowledged(i); | ||
85 | if (i == serial) { | 89 | if (i == serial) { | ||
86 | break; | 90 | break; | ||
87 | } | 91 | } | ||
88 | } | 92 | } | ||
89 | } | 93 | } | ||
90 | 94 | | |||
91 | void popupDone() override; | 95 | void popupDone() override; | ||
92 | quint32 configure(const QRect &rect) override; | 96 | quint32 configure(const QRect &rect) override; | ||
93 | 97 | | |||
94 | XdgPopupV6Interface *q_func() { | 98 | XdgPopupV6Interface *q_func() { | ||
95 | return reinterpret_cast<XdgPopupV6Interface *>(q); | 99 | return reinterpret_cast<XdgPopupV6Interface *>(q); | ||
96 | } | 100 | } | ||
97 | private: | 101 | private: | ||
102 | void setWindowGeometryCallback(const QRect &rect); | ||||
103 | | ||||
98 | static void grabCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial); | 104 | static void grabCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial); | ||
99 | 105 | | |||
100 | static const struct zxdg_popup_v6_interface s_interface; | 106 | static const struct zxdg_popup_v6_interface s_interface; | ||
107 | | ||||
108 | struct ShellSurfaceState | ||||
109 | { | ||||
110 | QRect windowGeometry; | ||||
111 | | ||||
112 | bool windowGeometryIsSet = false; | ||||
113 | }; | ||||
114 | | ||||
115 | ShellSurfaceState m_currentState; | ||||
116 | ShellSurfaceState m_pendingState; | ||||
117 | | ||||
118 | friend class XdgSurfaceV6Interface; | ||||
101 | }; | 119 | }; | ||
102 | 120 | | |||
103 | class XdgSurfaceV6Interface::Private : public KWayland::Server::Resource::Private | 121 | class XdgSurfaceV6Interface::Private : public KWayland::Server::Resource::Private | ||
104 | { | 122 | { | ||
105 | public: | 123 | public: | ||
106 | Private(XdgSurfaceV6Interface* q, XdgShellV6Interface* c, SurfaceInterface* surface, wl_resource* parentResource); | 124 | Private(XdgSurfaceV6Interface* q, XdgShellV6Interface* c, SurfaceInterface* surface, wl_resource* parentResource); | ||
107 | 125 | | |||
108 | ~Private(); | 126 | ~Private(); | ||
Show All 22 Lines | |||||
131 | }; | 149 | }; | ||
132 | 150 | | |||
133 | class XdgTopLevelV6Interface::Private : public XdgShellSurfaceInterface::Private | 151 | class XdgTopLevelV6Interface::Private : public XdgShellSurfaceInterface::Private | ||
134 | { | 152 | { | ||
135 | public: | 153 | public: | ||
136 | Private(XdgTopLevelV6Interface* q, XdgShellV6Interface* c, SurfaceInterface* surface, wl_resource* parentResource); | 154 | Private(XdgTopLevelV6Interface* q, XdgShellV6Interface* c, SurfaceInterface* surface, wl_resource* parentResource); | ||
137 | ~Private(); | 155 | ~Private(); | ||
138 | 156 | | |||
157 | QRect windowGeometry() const override; | ||||
158 | QSize minimumSize() const override; | ||||
159 | QSize maximumSize() const override; | ||||
139 | void close() override; | 160 | void close() override; | ||
161 | void commit() override; | ||||
140 | 162 | | |||
141 | void ackConfigure(quint32 serial) { | 163 | void ackConfigure(quint32 serial) { | ||
142 | if (!configureSerials.contains(serial)) { | 164 | if (!configureSerials.contains(serial)) { | ||
143 | // TODO: send error? | 165 | // TODO: send error? | ||
144 | return; | 166 | return; | ||
145 | } | 167 | } | ||
146 | while (!configureSerials.isEmpty()) { | 168 | while (!configureSerials.isEmpty()) { | ||
147 | quint32 i = configureSerials.takeFirst(); | 169 | quint32 i = configureSerials.takeFirst(); | ||
Show All 37 Lines | 177 | quint32 configure(States states, const QSize &size) override { | |||
185 | return serial; | 207 | return serial; | ||
186 | }; | 208 | }; | ||
187 | 209 | | |||
188 | XdgTopLevelV6Interface *q_func() { | 210 | XdgTopLevelV6Interface *q_func() { | ||
189 | return reinterpret_cast<XdgTopLevelV6Interface*>(q); | 211 | return reinterpret_cast<XdgTopLevelV6Interface*>(q); | ||
190 | } | 212 | } | ||
191 | 213 | | |||
192 | private: | 214 | private: | ||
215 | void setWindowGeometryCallback(const QRect &rect); | ||||
216 | | ||||
193 | static void destroyCallback(wl_client *client, wl_resource *resource); | 217 | static void destroyCallback(wl_client *client, wl_resource *resource); | ||
194 | static void setParentCallback(struct wl_client *client, struct wl_resource *resource, wl_resource *parent); | 218 | static void setParentCallback(struct wl_client *client, struct wl_resource *resource, wl_resource *parent); | ||
195 | static void showWindowMenuCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial, int32_t x, int32_t y); | 219 | static void showWindowMenuCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial, int32_t x, int32_t y); | ||
196 | static void setMaxSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height); | 220 | static void setMaxSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height); | ||
197 | static void setMinSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height); | 221 | static void setMinSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height); | ||
198 | static void setMaximizedCallback(wl_client *client, wl_resource *resource); | 222 | static void setMaximizedCallback(wl_client *client, wl_resource *resource); | ||
199 | static void unsetMaximizedCallback(wl_client *client, wl_resource *resource); | 223 | static void unsetMaximizedCallback(wl_client *client, wl_resource *resource); | ||
200 | static void setFullscreenCallback(wl_client *client, wl_resource *resource, wl_resource *output); | 224 | static void setFullscreenCallback(wl_client *client, wl_resource *resource, wl_resource *output); | ||
201 | static void unsetFullscreenCallback(wl_client *client, wl_resource *resource); | 225 | static void unsetFullscreenCallback(wl_client *client, wl_resource *resource); | ||
202 | static void setMinimizedCallback(wl_client *client, wl_resource *resource); | 226 | static void setMinimizedCallback(wl_client *client, wl_resource *resource); | ||
203 | 227 | | |||
204 | static const struct zxdg_toplevel_v6_interface s_interface; | 228 | static const struct zxdg_toplevel_v6_interface s_interface; | ||
229 | | ||||
230 | struct ShellSurfaceState | ||||
231 | { | ||||
232 | QRect windowGeometry; | ||||
233 | QSize minimumSize = QSize(0, 0); | ||||
234 | QSize maximiumSize = QSize(INT32_MAX, INT32_MAX); | ||||
235 | | ||||
236 | bool windowGeometryIsSet = false; | ||||
237 | bool minimumSizeIsSet = false; | ||||
238 | bool maximumSizeIsSet = false; | ||||
239 | }; | ||||
240 | | ||||
241 | ShellSurfaceState m_currentState; | ||||
242 | ShellSurfaceState m_pendingState; | ||||
243 | | ||||
244 | friend class XdgSurfaceV6Interface; | ||||
205 | }; | 245 | }; | ||
206 | 246 | | |||
207 | 247 | | |||
208 | const quint32 XdgShellV6Interface::Private::s_version = 1; | 248 | const quint32 XdgShellV6Interface::Private::s_version = 1; | ||
209 | 249 | | |||
210 | #ifndef DOXYGEN_SHOULD_SKIP_THIS | 250 | #ifndef DOXYGEN_SHOULD_SKIP_THIS | ||
211 | const struct zxdg_shell_v6_interface XdgShellV6Interface::Private::s_interface = { | 251 | const struct zxdg_shell_v6_interface XdgShellV6Interface::Private::s_interface = { | ||
212 | destroyCallback, | 252 | destroyCallback, | ||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Line(s) | |||||
436 | void XdgSurfaceV6Interface::Private::getTopLevelCallback(wl_client *client, wl_resource *resource, uint32_t id) | 476 | void XdgSurfaceV6Interface::Private::getTopLevelCallback(wl_client *client, wl_resource *resource, uint32_t id) | ||
437 | { | 477 | { | ||
438 | auto s = cast<XdgSurfaceV6Interface::Private>(resource); | 478 | auto s = cast<XdgSurfaceV6Interface::Private>(resource); | ||
439 | s->createTopLevel(client, wl_resource_get_version(resource), id, resource); | 479 | s->createTopLevel(client, wl_resource_get_version(resource), id, resource); | ||
440 | } | 480 | } | ||
441 | 481 | | |||
442 | void XdgSurfaceV6Interface::Private::createTopLevel(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource) | 482 | void XdgSurfaceV6Interface::Private::createTopLevel(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource) | ||
443 | { | 483 | { | ||
484 | // FIXME: That's incorrect! The client may have asked us to create an xdg-toplevel | ||||
485 | // for a pointer surface or a subsurface. We have to post an error in that case. | ||||
444 | if (m_topLevel) { | 486 | if (m_topLevel) { | ||
445 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Toplevel already created on this surface"); | 487 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Toplevel already created on this surface"); | ||
446 | return; | 488 | return; | ||
447 | } | 489 | } | ||
448 | if (m_popup) { | 490 | if (m_popup) { | ||
449 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Popup already created on this surface"); | 491 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Popup already created on this surface"); | ||
450 | return; | 492 | return; | ||
451 | } | 493 | } | ||
452 | m_topLevel = new XdgTopLevelV6Interface (m_shell, m_surface, parentResource); | 494 | m_topLevel = new XdgTopLevelV6Interface (m_shell, m_surface, parentResource); | ||
453 | m_topLevel->d->create(m_shell->display()->getConnection(client), version, id); | 495 | m_topLevel->d->create(m_shell->display()->getConnection(client), version, id); | ||
454 | 496 | | |||
455 | emit m_shell->surfaceCreated(m_topLevel); | 497 | emit m_shell->surfaceCreated(m_topLevel); | ||
456 | } | 498 | } | ||
457 | 499 | | |||
458 | 500 | | |||
459 | void XdgSurfaceV6Interface::Private::getPopupCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *parent, wl_resource *positioner) | 501 | void XdgSurfaceV6Interface::Private::getPopupCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *parent, wl_resource *positioner) | ||
460 | { | 502 | { | ||
461 | auto s = cast<XdgSurfaceV6Interface::Private>(resource); | 503 | auto s = cast<XdgSurfaceV6Interface::Private>(resource); | ||
462 | s->createPopup(client, wl_resource_get_version(resource), id, resource, parent, positioner); | 504 | s->createPopup(client, wl_resource_get_version(resource), id, resource, parent, positioner); | ||
463 | } | 505 | } | ||
464 | 506 | | |||
465 | void XdgSurfaceV6Interface::Private::createPopup(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource, wl_resource *parentSurface, wl_resource *positioner) | 507 | void XdgSurfaceV6Interface::Private::createPopup(wl_client *client, uint32_t version, uint32_t id, wl_resource *parentResource, wl_resource *parentSurface, wl_resource *positioner) | ||
466 | { | 508 | { | ||
467 | 509 | // FIXME: That's incorrect! The client may have asked us to create an xdg-popup | |||
510 | // for a pointer surface or a subsurface. We have to post an error in that case. | ||||
468 | if (m_topLevel) { | 511 | if (m_topLevel) { | ||
469 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Toplevel already created on this surface"); | 512 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Toplevel already created on this surface"); | ||
470 | return; | 513 | return; | ||
471 | } | 514 | } | ||
472 | if (m_popup) { | 515 | if (m_popup) { | ||
473 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Popup already created on this surface"); | 516 | wl_resource_post_error(parentResource, ZXDG_SHELL_V6_ERROR_ROLE, "Popup already created on this surface"); | ||
474 | return; | 517 | return; | ||
475 | } | 518 | } | ||
Show All 36 Lines | 554 | if (s->m_topLevel) { | |||
512 | s->m_topLevel->d_func()->ackConfigure(serial); | 555 | s->m_topLevel->d_func()->ackConfigure(serial); | ||
513 | } else if (s->m_popup) { | 556 | } else if (s->m_popup) { | ||
514 | s->m_popup->d_func()->ackConfigure(serial); | 557 | s->m_popup->d_func()->ackConfigure(serial); | ||
515 | } | 558 | } | ||
516 | } | 559 | } | ||
517 | 560 | | |||
518 | void XdgSurfaceV6Interface::Private::setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) | 561 | void XdgSurfaceV6Interface::Private::setWindowGeometryCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) | ||
519 | { | 562 | { | ||
520 | // TODO: implement - not done for v5 either | 563 | auto s = cast<Private>(resource); | ||
521 | Q_UNUSED(client) | 564 | Q_ASSERT(client == *s->client); | ||
522 | Q_UNUSED(resource) | 565 | | ||
523 | Q_UNUSED(x) | 566 | if (width < 0 || height < 0) { | ||
524 | Q_UNUSED(y) | 567 | wl_resource_post_error(resource, ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, "Tried to set invalid xdg-surface geometry"); | ||
525 | Q_UNUSED(width) | 568 | return; | ||
526 | Q_UNUSED(height) | 569 | } | ||
570 | | ||||
571 | if (s->m_topLevel) { | ||||
572 | s->m_topLevel->d_func()->setWindowGeometryCallback(QRect(x, y, width, height)); | ||||
573 | } else if (s->m_popup) { | ||||
574 | s->m_popup->d_func()->setWindowGeometryCallback(QRect(x, y, width, height)); | ||||
575 | } | ||||
527 | } | 576 | } | ||
528 | 577 | | |||
529 | XdgSurfaceV6Interface::Private::Private(XdgSurfaceV6Interface *q, XdgShellV6Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | 578 | XdgSurfaceV6Interface::Private::Private(XdgSurfaceV6Interface *q, XdgShellV6Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | ||
530 | : KWayland::Server::Resource::Private(q, c, parentResource, &zxdg_surface_v6_interface, &s_interface), | 579 | : KWayland::Server::Resource::Private(q, c, parentResource, &zxdg_surface_v6_interface, &s_interface), | ||
531 | m_shell(c), | 580 | m_shell(c), | ||
532 | m_surface(surface) | 581 | m_surface(surface) | ||
533 | { | 582 | { | ||
534 | } | 583 | } | ||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Line(s) | |||||
681 | 730 | | |||
682 | void XdgPositionerV6Interface::Private::setOffsetCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y) | 731 | void XdgPositionerV6Interface::Private::setOffsetCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y) | ||
683 | { | 732 | { | ||
684 | Q_UNUSED(client) | 733 | Q_UNUSED(client) | ||
685 | auto s = cast<Private>(resource); | 734 | auto s = cast<Private>(resource); | ||
686 | s->anchorOffset = QPoint(x,y); | 735 | s->anchorOffset = QPoint(x,y); | ||
687 | } | 736 | } | ||
688 | 737 | | |||
738 | QRect XdgTopLevelV6Interface::Private::windowGeometry() const | ||||
739 | { | ||||
740 | return m_currentState.windowGeometry; | ||||
741 | } | ||||
742 | | ||||
743 | QSize XdgTopLevelV6Interface::Private::minimumSize() const | ||||
744 | { | ||||
745 | return m_currentState.minimumSize; | ||||
746 | } | ||||
747 | | ||||
748 | QSize XdgTopLevelV6Interface::Private::maximumSize() const | ||||
749 | { | ||||
750 | return m_currentState.maximiumSize; | ||||
751 | } | ||||
752 | | ||||
689 | void XdgTopLevelV6Interface::Private::close() | 753 | void XdgTopLevelV6Interface::Private::close() | ||
690 | { | 754 | { | ||
691 | zxdg_toplevel_v6_send_close(resource); | 755 | zxdg_toplevel_v6_send_close(resource); | ||
692 | client->flush(); | 756 | client->flush(); | ||
693 | } | 757 | } | ||
694 | 758 | | |||
695 | void XdgTopLevelV6Interface::Private::setMaxSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height) | 759 | void XdgTopLevelV6Interface::Private::setMaxSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height) | ||
696 | { | 760 | { | ||
761 | if (width < 0 || height < 0) { | ||||
762 | wl_resource_post_error(resource, ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, "Tried to set invalid xdg-toplevel maximum size"); | ||||
763 | return; | ||||
764 | } | ||||
765 | if (width == 0) { | ||||
766 | width = INT32_MAX; | ||||
767 | } | ||||
768 | if (height == 0) { | ||||
769 | height = INT32_MAX; | ||||
770 | } | ||||
697 | auto s = cast<Private>(resource); | 771 | auto s = cast<Private>(resource); | ||
698 | Q_ASSERT(client == *s->client); | 772 | Q_ASSERT(client == *s->client); | ||
699 | s->q_func()->maxSizeChanged(QSize(width, height)); | 773 | s->m_pendingState.maximiumSize = QSize(width, height); | ||
774 | s->m_pendingState.maximumSizeIsSet = true; | ||||
700 | } | 775 | } | ||
701 | 776 | | |||
702 | void XdgTopLevelV6Interface::Private::setMinSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height) | 777 | void XdgTopLevelV6Interface::Private::setMinSizeCallback(wl_client *client, wl_resource *resource, int32_t width, int32_t height) | ||
703 | { | 778 | { | ||
779 | if (width < 0 || height < 0) { | ||||
780 | wl_resource_post_error(resource, ZXDG_SHELL_V6_ERROR_INVALID_SURFACE_STATE, "Tried to set invalid xdg-toplevel minimum size"); | ||||
781 | return; | ||||
782 | } | ||||
704 | auto s = cast<Private>(resource); | 783 | auto s = cast<Private>(resource); | ||
705 | Q_ASSERT(client == *s->client); | 784 | Q_ASSERT(client == *s->client); | ||
706 | s->q_func()->minSizeChanged(QSize(width, height)); | 785 | s->m_pendingState.minimumSize = QSize(width, height); | ||
786 | s->m_pendingState.minimumSizeIsSet = true; | ||||
787 | } | ||||
788 | | ||||
789 | void XdgTopLevelV6Interface::Private::setWindowGeometryCallback(const QRect &rect) | ||||
790 | { | ||||
791 | m_pendingState.windowGeometry = rect; | ||||
792 | m_pendingState.windowGeometryIsSet = true; | ||||
707 | } | 793 | } | ||
708 | 794 | | |||
709 | const struct zxdg_toplevel_v6_interface XdgTopLevelV6Interface::Private::s_interface = { | 795 | const struct zxdg_toplevel_v6_interface XdgTopLevelV6Interface::Private::s_interface = { | ||
710 | destroyCallback, | 796 | destroyCallback, | ||
711 | setParentCallback, | 797 | setParentCallback, | ||
712 | setTitleCallback, | 798 | setTitleCallback, | ||
713 | setAppIdCallback, | 799 | setAppIdCallback, | ||
714 | showWindowMenuCallback, | 800 | showWindowMenuCallback, | ||
Show All 38 Lines | 836 | { | |||
753 | emit s->q_func()->windowMenuRequested(SeatInterface::get(seat), serial, QPoint(x, y)); | 839 | emit s->q_func()->windowMenuRequested(SeatInterface::get(seat), serial, QPoint(x, y)); | ||
754 | } | 840 | } | ||
755 | 841 | | |||
756 | XdgTopLevelV6Interface::Private::Private(XdgTopLevelV6Interface *q, XdgShellV6Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | 842 | XdgTopLevelV6Interface::Private::Private(XdgTopLevelV6Interface *q, XdgShellV6Interface *c, SurfaceInterface *surface, wl_resource *parentResource) | ||
757 | : XdgShellSurfaceInterface::Private(XdgShellInterfaceVersion::UnstableV6, q, c, surface, parentResource, &zxdg_toplevel_v6_interface, &s_interface) | 843 | : XdgShellSurfaceInterface::Private(XdgShellInterfaceVersion::UnstableV6, q, c, surface, parentResource, &zxdg_toplevel_v6_interface, &s_interface) | ||
758 | { | 844 | { | ||
759 | } | 845 | } | ||
760 | 846 | | |||
847 | void XdgTopLevelV6Interface::Private::commit() | ||||
848 | { | ||||
849 | const bool windowGeometryChanged = m_pendingState.windowGeometryIsSet; | ||||
850 | const bool minimumSizeChanged = m_pendingState.minimumSizeIsSet; | ||||
851 | const bool maximumSizeChanged = m_pendingState.maximumSizeIsSet; | ||||
852 | | ||||
853 | if (windowGeometryChanged) { | ||||
854 | m_currentState.windowGeometry = m_pendingState.windowGeometry; | ||||
855 | } | ||||
856 | if (minimumSizeChanged) { | ||||
857 | m_currentState.minimumSize = m_pendingState.minimumSize; | ||||
858 | } | ||||
859 | if (maximumSizeChanged) { | ||||
860 | m_currentState.maximiumSize = m_pendingState.maximiumSize; | ||||
861 | } | ||||
862 | | ||||
863 | m_pendingState = ShellSurfaceState{}; | ||||
864 | | ||||
865 | if (windowGeometryChanged) { | ||||
866 | emit q_func()->windowGeometryChanged(m_currentState.windowGeometry); | ||||
867 | } | ||||
868 | if (minimumSizeChanged) { | ||||
869 | emit q_func()->minSizeChanged(m_currentState.minimumSize); | ||||
870 | } | ||||
871 | if (maximumSizeChanged) { | ||||
872 | emit q_func()->maxSizeChanged(m_currentState.maximiumSize); | ||||
873 | } | ||||
874 | } | ||||
875 | | ||||
761 | void XdgTopLevelV6Interface::Private::setMaximizedCallback(wl_client *client, wl_resource *resource) | 876 | void XdgTopLevelV6Interface::Private::setMaximizedCallback(wl_client *client, wl_resource *resource) | ||
762 | { | 877 | { | ||
763 | auto s = cast<Private>(resource); | 878 | auto s = cast<Private>(resource); | ||
764 | Q_ASSERT(client == *s->client); | 879 | Q_ASSERT(client == *s->client); | ||
765 | s->q_func()->maximizedChanged(true); | 880 | s->q_func()->maximizedChanged(true); | ||
766 | } | 881 | } | ||
767 | 882 | | |||
768 | void XdgTopLevelV6Interface::Private::unsetMaximizedCallback(wl_client *client, wl_resource *resource) | 883 | void XdgTopLevelV6Interface::Private::unsetMaximizedCallback(wl_client *client, wl_resource *resource) | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 930 | { | |||
816 | Q_UNUSED(client) | 931 | Q_UNUSED(client) | ||
817 | auto s = cast<Private>(resource); | 932 | auto s = cast<Private>(resource); | ||
818 | auto seatInterface = SeatInterface::get(seat); | 933 | auto seatInterface = SeatInterface::get(seat); | ||
819 | s->q_func()->grabRequested(seatInterface, serial); | 934 | s->q_func()->grabRequested(seatInterface, serial); | ||
820 | } | 935 | } | ||
821 | 936 | | |||
822 | XdgPopupV6Interface::Private::~Private() = default; | 937 | XdgPopupV6Interface::Private::~Private() = default; | ||
823 | 938 | | |||
939 | QRect XdgPopupV6Interface::Private::windowGeometry() const | ||||
940 | { | ||||
941 | return m_currentState.windowGeometry; | ||||
942 | } | ||||
943 | | ||||
944 | void XdgPopupV6Interface::Private::commit() | ||||
945 | { | ||||
946 | const bool windowGeometryChanged = m_pendingState.windowGeometryIsSet; | ||||
947 | | ||||
948 | if (windowGeometryChanged) { | ||||
949 | m_currentState.windowGeometry = m_pendingState.windowGeometry; | ||||
950 | } | ||||
951 | | ||||
952 | m_pendingState = ShellSurfaceState{}; | ||||
953 | | ||||
954 | if (windowGeometryChanged) { | ||||
955 | emit q_func()->windowGeometryChanged(m_currentState.windowGeometry); | ||||
956 | } | ||||
957 | } | ||||
958 | | ||||
959 | void XdgPopupV6Interface::Private::setWindowGeometryCallback(const QRect &rect) | ||||
960 | { | ||||
961 | m_pendingState.windowGeometry = rect; | ||||
962 | m_pendingState.windowGeometryIsSet = true; | ||||
963 | } | ||||
964 | | ||||
824 | quint32 XdgPopupV6Interface::Private::configure(const QRect &rect) | 965 | quint32 XdgPopupV6Interface::Private::configure(const QRect &rect) | ||
825 | { | 966 | { | ||
826 | if (!resource) { | 967 | if (!resource) { | ||
827 | return 0; | 968 | return 0; | ||
828 | } | 969 | } | ||
829 | const quint32 serial = global->display()->nextSerial(); | 970 | const quint32 serial = global->display()->nextSerial(); | ||
830 | configureSerials << serial; | 971 | configureSerials << serial; | ||
831 | zxdg_popup_v6_send_configure(resource, rect.x(), rect.y(), rect.width(), rect.height()); | 972 | zxdg_popup_v6_send_configure(resource, rect.x(), rect.y(), rect.width(), rect.height()); | ||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |