8#include <QtWaylandCompositor/QWaylandCompositor>
9#include <QtWaylandCompositor/QWaylandSurface>
11#include <QtWaylandCompositor/QWaylandResource>
13#if QT_CONFIG(wayland_compositor_quick)
17#include <QtWaylandCompositor/QWaylandResource>
21#include <QtWaylandCompositor/private/qwaylandutils_p.h>
66 for (
int i = 0;
i <
d->m_chromes.size(); ++
i) {
67 if (
d->m_chromes.at(
i) == chrome) {
70 d->m_chromes.move(
i, 0);
84 if (moveChromeToFront(chrome))
89 d->m_chromes.prepend(chrome);
92 if (currentActive !=
nullptr)
104 int index =
d->m_chromes.indexOf(chrome);
106 d->m_chromes.removeAt(
index);
107 if (
index == 0 &&
d->m_chromes.size() > 0)
108 d->m_chromes.at(0)->activate();
112void QWaylandQtShell::chromeActivated()
116 moveChromeToFront(
c);
120void QWaylandQtShell::chromeDeactivated()
124 if (
d->m_chromes.size() > 1 &&
d->m_chromes.at(0) ==
c) {
125 d->m_chromes.move(0, 1);
126 d->m_chromes.at(0)->activate();
127 }
else if (
d->m_chromes.size() == 1) {
128 d->m_chromes.at(0)->activate();
139 qWarning() <<
"Failed to find QWaylandCompositor when initializing QWaylandQtShell";
148 return QWaylandQtShellPrivate::interface();
156 return QWaylandQtShellPrivate::interfaceName();
192 QWaylandResource qtShellSurfaceResource(wl_resource_create(resource->client(), &zqt_shell_surface_v1_interface,
193 wl_resource_get_version(resource->handle),
id));
195 emit q->qtShellSurfaceRequested(surface, qtShellSurfaceResource);
202 emit q->qtShellSurfaceCreated(qtShellSurface);
271 d->m_qtShell = qtShell;
309 return d->m_windowGeometry.topLeft();
318 d->send_configure(UINT32_MAX);
320 d->m_windowGeometry.moveTopLeft(
position);
321 d->m_positionSet =
true;
334 return d->m_windowGeometry;
345 return d->m_minimumSize;
356 return d->m_maximumSize;
379 qWarning() <<
"Failed to find QWaylandCompositor when configuring QWaylandQtShell";
384 m_pendingConfigures[serial] =
qMakePair(windowState, newGeometry);
386 send_set_position(serial, newGeometry.
x(), newGeometry.
y());
387 send_resize(serial, newGeometry.
width(), newGeometry.
height());
389 send_configure(serial);
395 if (
d->m_frameMargins == margins)
398 d->m_frameMargins = margins;
399 d->updateFrameMargins();
412 if (
d->m_frameMargins.left() ==
left)
415 d->m_frameMargins.setLeft(
left);
416 d->updateFrameMargins();
424 return d->m_frameMargins.left();
435 if (
d->m_frameMargins.right() ==
right)
438 d->m_frameMargins.setRight(
right);
439 d->updateFrameMargins();
447 return d->m_frameMargins.right();
459 if (
d->m_frameMargins.top() ==
top)
461 d->m_frameMargins.setTop(
top);
462 d->updateFrameMargins();
470 return d->m_frameMargins.top();
481 if (
d->m_frameMargins.bottom() ==
bottom)
483 d->m_frameMargins.setBottom(
bottom);
484 d->updateFrameMargins();
492 return !
d->m_positionSet;
498 return d->m_frameMargins.bottom();
509 return d->m_windowFlags;
531 return d->m_windowTitle;
593 return d->m_capabilities;
607 return d->m_windowState;
610void QWaylandQtShellSurface::surfaceCommitted()
613 if (
d->m_lastAckedConfigure < UINT32_MAX) {
614 QRect targetRect =
d->m_windowGeometry;
616 for (
auto it =
d->m_pendingConfigures.begin();
it !=
d->m_pendingConfigures.end(); ) {
617 if (
it.key() ==
d->m_lastAckedConfigure) {
618 targetRect =
it.value().second;
622 if (
it.key() <=
d->m_lastAckedConfigure)
623 it =
d->m_pendingConfigures.erase(
it);
633 if (
d->m_windowGeometry != targetRect) {
634 d->m_windowGeometry = targetRect;
635 d->m_positionSet =
true;
640 d->m_lastAckedConfigure = UINT32_MAX;
641 d->m_pendingPosition =
QPoint{};
642 d->m_pendingPositionValid =
false;
643 d->m_pendingSize =
QSize{};
645 QRect oldRect =
d->m_windowGeometry;
646 if (
d->m_pendingPositionValid) {
647 d->m_windowGeometry.moveTopLeft(
d->m_pendingPosition);
648 d->m_pendingPosition =
QPoint{};
649 d->m_pendingPositionValid =
false;
650 d->m_positionSet =
true;
654 if (
d->m_pendingSize.isValid()) {
655 d->m_windowGeometry.setSize(
d->m_pendingSize);
656 d->m_pendingSize =
QSize{};
659 if (
d->m_windowGeometry != oldRect)
669 return QWaylandQtShellSurfacePrivate::interface();
674 return QWaylandQtShellSurfacePrivate::interfaceName();
682 return &QWaylandQtShellSurfacePrivate::s_role;
690 if (
auto p = QtWayland::fromResource<QWaylandQtShellSurfacePrivate *>(resource))
695#if QT_CONFIG(wayland_compositor_quick)
718 if (serial < UINT32_MAX)
719 m_lastAckedConfigure = serial;
723 q->surfaceCommitted();
731 m_pendingPositionValid =
true;
732 m_lastAckedConfigure = UINT32_MAX;
740 m_lastAckedConfigure = UINT32_MAX;
748 emit q->minimumSizeChanged();
756 emit q->maximumSizeChanged();
769 wl_resource_destroy(resource->handle);
776 m_windowFlags =
flags;
777 emit q->windowFlagsChanged();
784 uint oldWindowState = m_windowState;
785 m_windowState =
state &
~Qt::WindowActive;
787 if (oldWindowState != m_windowState)
788 emit q->windowStateChanged();
796 emit q->startResize(Qt::Edges(edge));
812 m_windowTitle =
title;
813 emit q->windowTitleChanged();
826 send_set_frame_margins(m_frameMargins.
left(), m_frameMargins.
right(),
827 m_frameMargins.
top(), m_frameMargins.
bottom());
835 emit q->raiseRequested();
842 emit q->lowerRequested();
847#include "moc_qwaylandqtshell.cpp"
constexpr int bottom() const noexcept
Returns the bottom margin.
constexpr int left() const noexcept
Returns the left margin.
constexpr int right() const noexcept
Returns the right margin.
constexpr int top() const noexcept
Returns the top margin.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
\macro QT_RESTRICTED_CAST_FROM_ASCII
\inmodule QtWaylandCompositor
void setExtensionContainer(QWaylandObject *container)
Sets the extension container for this QWaylandCompositorExtension to container.
virtual void initialize()
Initializes the QWaylandCompositorExtension.
QWaylandObject * extensionContainer() const
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
void deactivate()
\qmlmethod void QtShellChrome::deactivate()
void activate()
\qmlmethod void QtShellChrome::activate()
void unregisterQtShellSurface(QWaylandQtShellSurface *qtShellSurface)
QWaylandQtShellPrivate()
\qmlsignal void QtShell::qtShellSurfaceRequested(WaylandSurface surface, WaylandResource resource)
static QWaylandQtShellPrivate * get(QWaylandQtShell *qtShell)
void zqt_shell_v1_surface_create(Resource *resource, wl_resource *surface, uint32_t id) override
void zqt_shell_surface_v1_raise(Resource *resource) override
void zqt_shell_surface_v1_start_system_move(Resource *resource, uint32_t serial) override
void updateFrameMargins()
void zqt_shell_surface_v1_request_activate(Resource *resource) override
void zqt_shell_surface_v1_start_system_resize(Resource *resource, uint32_t serial, uint32_t edge) override
void zqt_shell_surface_v1_ack_configure(Resource *resource, uint32_t serial) override
QWaylandQtShellSurfacePrivate()
void zqt_shell_surface_v1_set_window_flags(Resource *resource, uint32_t flags) override
void zqt_shell_surface_v1_set_size(Resource *resource, int32_t width, int32_t height) override
void zqt_shell_surface_v1_reposition(Resource *resource, int32_t x, int32_t y) override
void zqt_shell_surface_v1_change_window_state(Resource *resource, uint32_t state) override
void configure(uint windowState, const QRect &newGeometry)
void zqt_shell_surface_v1_destroy(Resource *resource) override
void zqt_shell_surface_v1_set_maximum_size(Resource *resource, int32_t width, int32_t height) override
void zqt_shell_surface_v1_destroy_resource(Resource *resource) override
void zqt_shell_surface_v1_set_window_title(Resource *resource, const QString &title) override
void zqt_shell_surface_v1_lower(Resource *resource) override
void zqt_shell_surface_v1_set_minimum_size(Resource *resource, int32_t width, int32_t height) override
void capabilitiesChanged()
Q_INVOKABLE void requestWindowGeometry(uint windowState, const QRect &windowGeometry)
\qmlmethod void QtShellSurface::requestWindowGeometry(int windowState, rect windowGeometry)
QWaylandSurface * surface
void windowGeometryChanged()
static const wl_interface * interface()
Returns the Wayland interface for the QWaylandQtShellSurface.
void positionAutomaticChanged()
static QByteArray interfaceName()
void setFrameMargins(const QMargins &margins)
static QWaylandSurfaceRole * role()
Returns the surface role for the QWaylandQtShellSurface.
void setCapabilities(CapabilityFlags capabilities)
\qmlproperty enum QtShellSurface::capabilities
void setActive(bool active)
\qmlproperty bool QtShellSurface::active
void frameMarginChanged()
void windowStateChanged()
QWaylandQtShellSurface()
\qmltype QtShellSurface \instantiates QWaylandQtShellSurface \inqmlmodule QtWayland....
CapabilityFlags capabilities
void initialize() override
void setFrameMarginLeft(int left)
\qmlproperty int QtShellSurface::frameMarginLeft
static QWaylandQtShellSurface * fromResource(::wl_resource *resource)
Returns the QWaylandQtShellSurface corresponding to the resource.
Q_INVOKABLE void sendClose()
\qmlmethod void QtShellSurface::sendClose()
void setFrameMarginBottom(int bottom)
\qmlproperty int QtShellSurface::frameMarginBottom
void setFrameMarginRight(int right)
\qmlproperty int QtShellSurface::frameMarginRight
void setFrameMarginTop(int top)
\qmlproperty int QtShellSurface::frameMarginTop
void setWindowPosition(const QPoint &position)
static const struct wl_interface * interface()
void initialize() override
Initializes the QWaylandCompositorExtension.
void registerChrome(QWaylandQtShellChrome *chrome)
static QByteArray interfaceName()
void unregisterChrome(QWaylandQtShellChrome *chrome)
QWaylandQtShell()
\qmltype QtShell \instantiates QWaylandQtShell \inqmlmodule QtWayland.Compositor.QtShell
\inmodule QtWaylandCompositor
\qmltype ShellSurfaceItem \instantiates QWaylandQuickShellSurfaceItem \inherits WaylandQuickItem \inq...
\inmodule QtWaylandCompositor
wl_resource * resource() const
\qmltype WaylandSeat \instantiates QWaylandSeat \inqmlmodule QtWayland.Compositor
bool setKeyboardFocus(QWaylandSurface *surface)
Sets the current keyboard focus to surface.
\inmodule QtWaylandCompositor
\inmodule QtWaylandCompositor
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
static QWaylandSurface * fromResource(::wl_resource *resource)
Returns the QWaylandSurface corresponding to the Wayland resource resource.
QWaylandCompositor * compositor() const
Returns the compositor for this QWaylandSurface.
bool setRole(QWaylandSurfaceRole *role, wl_resource *errorResource, uint32_t errorCode)
Sets a role on the surface.
void damaged(const QRegion &rect)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QOpenGLCompositor * compositor
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble GLdouble GLdouble q
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)