diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-06-15 14:59:26 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-06-19 06:19:13 +0000 |
commit | cf86659c874fcb1d3f88a784cd88a51942e5926b (patch) | |
tree | 07933efbc88a58420f6248111ac6018bf6f547e7 /src/plugins/shellintegration | |
parent | 9b3260164da42b5edabc6cf6d73b7a35ab38e93d (diff) |
Client: Get rid of QWaylandShellSurface::setType
This shouldn't change any behavior, but lets the shell integrations choose
if they want to use the extremely hacky QWaylandWindow::transientParent().
Hint: Not all shells need the hacks, and not all shells need them in all cases,
and some shells may need even more hacks.
Change-Id: Id105e4feb83cc9c14dcf07dcca55fcd5e63d4a2b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/plugins/shellintegration')
12 files changed, 39 insertions, 67 deletions
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp index 871709cdf..10d308ba4 100644 --- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp +++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface.cpp @@ -75,13 +75,6 @@ QWaylandIviSurface::~QWaylandIviSurface() delete m_extendedWindow; } -void QWaylandIviSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent) -{ - - Q_UNUSED(type) - Q_UNUSED(transientParent) -} - void QWaylandIviSurface::applyConfigure() { m_window->resizeFromApplyConfigure(m_pendingSize); diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h index 6ec28e758..f207f0584 100644 --- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h +++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h @@ -62,7 +62,6 @@ public: struct ::ivi_controller_surface *iviControllerSurface); ~QWaylandIviSurface() override; - void setType(Qt::WindowType type, QWaylandWindow *transientParent) override; void applyConfigure() override; private: diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp index 9f2bcc00c..d9bc83059 100644 --- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp +++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp @@ -59,6 +59,15 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_ { if (window->display()->windowExtension()) m_extendedWindow = new QWaylandExtendedSurface(window); + + Qt::WindowType type = window->window()->type(); + auto *transientParent = window->transientParent(); + if (type == Qt::Popup && transientParent && transientParent->object()) + setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial()); + else if (transientParent && transientParent->object()) + updateTransientParent(transientParent->window()); + else + setTopLevel(); } QWaylandWlShellSurface::~QWaylandWlShellSurface() @@ -250,16 +259,6 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic transientPos.x(), transientPos.y(), 0); } -void QWaylandWlShellSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent) -{ - if (type == Qt::Popup && transientParent && transientParent->object()) - setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial()); - else if (transientParent && transientParent->object()) - updateTransientParent(transientParent->window()); - else - setTopLevel(); -} - void QWaylandWlShellSurface::shell_surface_ping(uint32_t serial) { pong(serial); diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h index ca81dd685..57e06525a 100644 --- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h +++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h @@ -92,7 +92,6 @@ public: void setWindowFlags(Qt::WindowFlags flags) override; void sendProperty(const QString &name, const QVariant &value) override; - void setType(Qt::WindowType type, QWaylandWindow *transientParent) override; void applyConfigure() override; bool wantsDecorations() const override; diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp index 542b1628d..539abcac7 100644 --- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp +++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp @@ -62,12 +62,6 @@ QWaylandXdgPopupV5::~QWaylandXdgPopupV5() delete m_extendedWindow; } -void QWaylandXdgPopupV5::setType(Qt::WindowType type, QWaylandWindow *transientParent) -{ - Q_UNUSED(type); - Q_UNUSED(transientParent); -} - void QWaylandXdgPopupV5::xdg_popup_popup_done() { m_window->window()->close(); diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h index 638b71534..cb748c5cc 100644 --- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h +++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h @@ -75,8 +75,6 @@ public: QWaylandXdgPopupV5(struct ::xdg_popup *popup, QWaylandWindow *window); ~QWaylandXdgPopupV5() override; - void setType(Qt::WindowType type, QWaylandWindow *transientParent) override; - protected: void xdg_popup_popup_done() override; diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp index 315dc6231..6d43a66be 100644 --- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp +++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp @@ -60,6 +60,8 @@ QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *shell, QWaylandWi { if (window->display()->windowExtension()) m_extendedWindow = new QWaylandExtendedSurface(window); + + updateTransientParent(window->transientParent()); } QWaylandXdgSurfaceV5::~QWaylandXdgSurfaceV5() @@ -141,13 +143,6 @@ void QWaylandXdgSurfaceV5::sendProperty(const QString &name, const QVariant &val m_extendedWindow->updateGenericProperty(name, value); } -void QWaylandXdgSurfaceV5::setType(Qt::WindowType type, QWaylandWindow *transientParent) -{ - Q_UNUSED(type) - if (transientParent) - updateTransientParent(transientParent); -} - void QWaylandXdgSurfaceV5::applyConfigure() { if (m_pending.isResizing) diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h index 928395779..e69433248 100644 --- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h +++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h @@ -97,7 +97,6 @@ public: void setWindowFlags(Qt::WindowFlags flags) override; void sendProperty(const QString &name, const QVariant &value) override; - void setType(Qt::WindowType type, QWaylandWindow *transientParent) override; void applyConfigure() override; void requestWindowStates(Qt::WindowStates states) override; bool wantsDecorations() const override; diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp index 36a82fe98..ef400a8d4 100644 --- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp +++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp @@ -172,6 +172,20 @@ QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_sur , m_shell(shell) , m_window(window) { + QWaylandDisplay *display = window->display(); + Qt::WindowType type = window->window()->type(); + auto *transientParent = window->transientParent(); + + if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) { + setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup); + } else { + setToplevel(); + if (transientParent) { + auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface()); + if (parentXdgSurface) + m_toplevel->set_parent(parentXdgSurface->m_toplevel->object()); + } + } } QWaylandXdgSurfaceV6::~QWaylandXdgSurfaceV6() @@ -217,21 +231,6 @@ void QWaylandXdgSurfaceV6::setAppId(const QString &appId) m_toplevel->set_app_id(appId); } -void QWaylandXdgSurfaceV6::setType(Qt::WindowType type, QWaylandWindow *transientParent) -{ - QWaylandDisplay *display = m_window->display(); - if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) { - setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup); - } else { - setToplevel(); - if (transientParent) { - auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface()); - if (parentXdgSurface) - m_toplevel->set_parent(parentXdgSurface->m_toplevel->object()); - } - } -} - bool QWaylandXdgSurfaceV6::handleExpose(const QRegion ®ion) { if (!m_configured && !region.isEmpty()) { diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h index c1d8564ac..8168ae565 100644 --- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h +++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h @@ -85,7 +85,6 @@ public: void setTitle(const QString &title) override; void setAppId(const QString &appId) override; - void setType(Qt::WindowType type, QWaylandWindow *transientParent) override; bool isExposed() const override { return m_configured; } bool handleExpose(const QRegion &) override; bool handlesActiveState() const { return m_toplevel; } diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 9fdfb3e16..19530cb3d 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -172,6 +172,20 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s , m_shell(shell) , m_window(window) { + QWaylandDisplay *display = window->display(); + Qt::WindowType type = window->window()->type(); + auto *transientParent = window->transientParent(); + + if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) { + setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup); + } else { + setToplevel(); + if (transientParent) { + auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(transientParent->shellSurface()); + if (parentXdgSurface) + m_toplevel->set_parent(parentXdgSurface->m_toplevel->object()); + } + } } QWaylandXdgSurface::~QWaylandXdgSurface() @@ -217,21 +231,6 @@ void QWaylandXdgSurface::setAppId(const QString &appId) m_toplevel->set_app_id(appId); } -void QWaylandXdgSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent) -{ - QWaylandDisplay *display = m_window->display(); - if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) { - setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup); - } else { - setToplevel(); - if (transientParent) { - auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(transientParent->shellSurface()); - if (parentXdgSurface) - m_toplevel->set_parent(parentXdgSurface->m_toplevel->object()); - } - } -} - bool QWaylandXdgSurface::handleExpose(const QRegion ®ion) { if (!m_configured && !region.isEmpty()) { diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h index 3dfe16242..7fb851315 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h @@ -85,7 +85,6 @@ public: void setTitle(const QString &title) override; void setAppId(const QString &appId) override; - void setType(Qt::WindowType type, QWaylandWindow *transientParent) override; bool isExposed() const override { return m_configured; } bool handleExpose(const QRegion &) override; bool handlesActiveState() const { return m_toplevel; } |