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>
This commit is contained in:
parent
b40a7bd4b3
commit
6dfa35b7a2
@ -59,6 +59,15 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_
|
|||||||
{
|
{
|
||||||
if (window->display()->windowExtension())
|
if (window->display()->windowExtension())
|
||||||
m_extendedWindow = new QWaylandExtendedSurface(window);
|
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()
|
QWaylandWlShellSurface::~QWaylandWlShellSurface()
|
||||||
@ -250,16 +259,6 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic
|
|||||||
transientPos.x(), transientPos.y(), 0);
|
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)
|
void QWaylandWlShellSurface::shell_surface_ping(uint32_t serial)
|
||||||
{
|
{
|
||||||
pong(serial);
|
pong(serial);
|
||||||
|
@ -92,7 +92,6 @@ public:
|
|||||||
void setWindowFlags(Qt::WindowFlags flags) override;
|
void setWindowFlags(Qt::WindowFlags flags) override;
|
||||||
void sendProperty(const QString &name, const QVariant &value) override;
|
void sendProperty(const QString &name, const QVariant &value) override;
|
||||||
|
|
||||||
void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
|
|
||||||
void applyConfigure() override;
|
void applyConfigure() override;
|
||||||
bool wantsDecorations() const override;
|
bool wantsDecorations() const override;
|
||||||
|
|
||||||
|
@ -62,12 +62,6 @@ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
|
|||||||
delete m_extendedWindow;
|
delete m_extendedWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandXdgPopupV5::setType(Qt::WindowType type, QWaylandWindow *transientParent)
|
|
||||||
{
|
|
||||||
Q_UNUSED(type);
|
|
||||||
Q_UNUSED(transientParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QWaylandXdgPopupV5::xdg_popup_popup_done()
|
void QWaylandXdgPopupV5::xdg_popup_popup_done()
|
||||||
{
|
{
|
||||||
m_window->window()->close();
|
m_window->window()->close();
|
||||||
|
@ -75,8 +75,6 @@ public:
|
|||||||
QWaylandXdgPopupV5(struct ::xdg_popup *popup, QWaylandWindow *window);
|
QWaylandXdgPopupV5(struct ::xdg_popup *popup, QWaylandWindow *window);
|
||||||
~QWaylandXdgPopupV5() override;
|
~QWaylandXdgPopupV5() override;
|
||||||
|
|
||||||
void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void xdg_popup_popup_done() override;
|
void xdg_popup_popup_done() override;
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *shell, QWaylandWi
|
|||||||
{
|
{
|
||||||
if (window->display()->windowExtension())
|
if (window->display()->windowExtension())
|
||||||
m_extendedWindow = new QWaylandExtendedSurface(window);
|
m_extendedWindow = new QWaylandExtendedSurface(window);
|
||||||
|
|
||||||
|
updateTransientParent(window->transientParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandXdgSurfaceV5::~QWaylandXdgSurfaceV5()
|
QWaylandXdgSurfaceV5::~QWaylandXdgSurfaceV5()
|
||||||
@ -141,13 +143,6 @@ void QWaylandXdgSurfaceV5::sendProperty(const QString &name, const QVariant &val
|
|||||||
m_extendedWindow->updateGenericProperty(name, value);
|
m_extendedWindow->updateGenericProperty(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandXdgSurfaceV5::setType(Qt::WindowType type, QWaylandWindow *transientParent)
|
|
||||||
{
|
|
||||||
Q_UNUSED(type)
|
|
||||||
if (transientParent)
|
|
||||||
updateTransientParent(transientParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QWaylandXdgSurfaceV5::applyConfigure()
|
void QWaylandXdgSurfaceV5::applyConfigure()
|
||||||
{
|
{
|
||||||
if (m_pending.isResizing)
|
if (m_pending.isResizing)
|
||||||
|
@ -97,7 +97,6 @@ public:
|
|||||||
void setWindowFlags(Qt::WindowFlags flags) override;
|
void setWindowFlags(Qt::WindowFlags flags) override;
|
||||||
void sendProperty(const QString &name, const QVariant &value) override;
|
void sendProperty(const QString &name, const QVariant &value) override;
|
||||||
|
|
||||||
void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
|
|
||||||
void applyConfigure() override;
|
void applyConfigure() override;
|
||||||
void requestWindowStates(Qt::WindowStates states) override;
|
void requestWindowStates(Qt::WindowStates states) override;
|
||||||
bool wantsDecorations() const override;
|
bool wantsDecorations() const override;
|
||||||
|
@ -172,6 +172,20 @@ QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_sur
|
|||||||
, m_shell(shell)
|
, m_shell(shell)
|
||||||
, m_window(window)
|
, 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()
|
QWaylandXdgSurfaceV6::~QWaylandXdgSurfaceV6()
|
||||||
@ -217,21 +231,6 @@ void QWaylandXdgSurfaceV6::setAppId(const QString &appId)
|
|||||||
m_toplevel->set_app_id(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)
|
bool QWaylandXdgSurfaceV6::handleExpose(const QRegion ®ion)
|
||||||
{
|
{
|
||||||
if (!m_configured && !region.isEmpty()) {
|
if (!m_configured && !region.isEmpty()) {
|
||||||
|
@ -85,7 +85,6 @@ public:
|
|||||||
void setTitle(const QString &title) override;
|
void setTitle(const QString &title) override;
|
||||||
void setAppId(const QString &appId) override;
|
void setAppId(const QString &appId) override;
|
||||||
|
|
||||||
void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
|
|
||||||
bool isExposed() const override { return m_configured; }
|
bool isExposed() const override { return m_configured; }
|
||||||
bool handleExpose(const QRegion &) override;
|
bool handleExpose(const QRegion &) override;
|
||||||
bool handlesActiveState() const { return m_toplevel; }
|
bool handlesActiveState() const { return m_toplevel; }
|
||||||
|
@ -172,6 +172,20 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
|
|||||||
, m_shell(shell)
|
, m_shell(shell)
|
||||||
, m_window(window)
|
, 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()
|
QWaylandXdgSurface::~QWaylandXdgSurface()
|
||||||
@ -217,21 +231,6 @@ void QWaylandXdgSurface::setAppId(const QString &appId)
|
|||||||
m_toplevel->set_app_id(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)
|
bool QWaylandXdgSurface::handleExpose(const QRegion ®ion)
|
||||||
{
|
{
|
||||||
if (!m_configured && !region.isEmpty()) {
|
if (!m_configured && !region.isEmpty()) {
|
||||||
|
@ -85,7 +85,6 @@ public:
|
|||||||
void setTitle(const QString &title) override;
|
void setTitle(const QString &title) override;
|
||||||
void setAppId(const QString &appId) override;
|
void setAppId(const QString &appId) override;
|
||||||
|
|
||||||
void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
|
|
||||||
bool isExposed() const override { return m_configured; }
|
bool isExposed() const override { return m_configured; }
|
||||||
bool handleExpose(const QRegion &) override;
|
bool handleExpose(const QRegion &) override;
|
||||||
bool handlesActiveState() const { return m_toplevel; }
|
bool handlesActiveState() const { return m_toplevel; }
|
||||||
|
@ -95,7 +95,6 @@ public:
|
|||||||
|
|
||||||
inline QWaylandWindow *window() { return m_window; }
|
inline QWaylandWindow *window() { return m_window; }
|
||||||
|
|
||||||
virtual void setType(Qt::WindowType type, QWaylandWindow *transientParent) = 0;
|
|
||||||
virtual void applyConfigure() {}
|
virtual void applyConfigure() {}
|
||||||
virtual void requestWindowStates(Qt::WindowStates states) {Q_UNUSED(states);}
|
virtual void requestWindowStates(Qt::WindowStates states) {Q_UNUSED(states);}
|
||||||
virtual bool wantsDecorations() const { return false; }
|
virtual bool wantsDecorations() const { return false; }
|
||||||
|
@ -139,8 +139,6 @@ void QWaylandWindow::initWindow()
|
|||||||
|
|
||||||
mShellSurface = mDisplay->createShellSurface(this);
|
mShellSurface = mDisplay->createShellSurface(this);
|
||||||
if (mShellSurface) {
|
if (mShellSurface) {
|
||||||
mShellSurface->setType(window()->type(), transientParent());
|
|
||||||
|
|
||||||
// Set initial surface title
|
// Set initial surface title
|
||||||
setWindowTitle(window()->title());
|
setWindowTitle(window()->title());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user