Remove QWaylandWindow::shellManagesActiveState
If m_shellSurface was deleted, there was no way for QWaylandDisplay to know whether the shell handled window deactivation or not. The shell integration now always handles the window active state. The default implementation of QWaylandShellIntegration will make a window active on keyboard focus. Change-Id: I80cfce9976b1d3c57094fdd8980c9110b873f239 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
ff3c3ad9f6
commit
dfb256be36
@ -419,11 +419,7 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
|
||||
if (mLastKeyboardFocus == keyboardFocus)
|
||||
return;
|
||||
|
||||
if (keyboardFocus && !keyboardFocus->shellManagesActiveState())
|
||||
handleWindowActivated(keyboardFocus);
|
||||
|
||||
if (mLastKeyboardFocus && !mLastKeyboardFocus->shellManagesActiveState())
|
||||
handleWindowDeactivated(mLastKeyboardFocus);
|
||||
mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
|
||||
|
||||
mLastKeyboardFocus = keyboardFocus;
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ public:
|
||||
virtual void setContentOrientationMask(Qt::ScreenOrientations orientation) { Q_UNUSED(orientation) }
|
||||
|
||||
virtual void sendProperty(const QString &name, const QVariant &value);
|
||||
virtual bool shellManagesActiveState() const { return false; }
|
||||
|
||||
inline QWaylandWindow *window() { return m_window; }
|
||||
|
||||
|
@ -530,11 +530,6 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const
|
||||
return mSubSurfaceWindow;
|
||||
}
|
||||
|
||||
bool QWaylandWindow::shellManagesActiveState() const
|
||||
{
|
||||
return mShellSurface && mShellSurface->shellManagesActiveState();
|
||||
}
|
||||
|
||||
void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
|
||||
{
|
||||
if (mDisplay->compositorVersion() < 2)
|
||||
|
@ -143,8 +143,6 @@ public:
|
||||
QWaylandSubSurface *subSurfaceWindow() const;
|
||||
QWaylandScreen *screen() const { return mScreen; }
|
||||
|
||||
bool shellManagesActiveState() const;
|
||||
|
||||
void handleContentOrientationChange(Qt::ScreenOrientation orientation) Q_DECL_OVERRIDE;
|
||||
void setOrientationMask(Qt::ScreenOrientations mask);
|
||||
|
||||
|
@ -52,6 +52,12 @@ QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display)
|
||||
}
|
||||
}
|
||||
|
||||
bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display)
|
||||
{
|
||||
QWaylandShellIntegration::initialize(display);
|
||||
return m_wlShell != nullptr;
|
||||
};
|
||||
|
||||
QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window)
|
||||
{
|
||||
return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->object()), window);
|
||||
|
@ -58,7 +58,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellI
|
||||
{
|
||||
public:
|
||||
QWaylandWlShellIntegration(QWaylandDisplay* display);
|
||||
bool initialize(QWaylandDisplay *) Q_DECL_OVERRIDE { return m_wlShell != Q_NULLPTR; }
|
||||
bool initialize(QWaylandDisplay *) Q_DECL_OVERRIDE;
|
||||
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -54,6 +54,12 @@ QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *displa
|
||||
}
|
||||
}
|
||||
|
||||
bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
|
||||
{
|
||||
QWaylandShellIntegration::initialize(display);
|
||||
return m_xdgShell != nullptr;
|
||||
}
|
||||
|
||||
QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
|
||||
{
|
||||
if (window->window()->type() == Qt::WindowType::Popup)
|
||||
@ -62,6 +68,13 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
|
||||
return m_xdgShell->createXdgSurface(window);
|
||||
}
|
||||
|
||||
void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
|
||||
if (newFocus && qobject_cast<QWaylandXdgPopup *>(newFocus->shellSurface()))
|
||||
m_display->handleWindowActivated(newFocus);
|
||||
if (oldFocus && qobject_cast<QWaylandXdgPopup *>(oldFocus->shellSurface()))
|
||||
m_display->handleWindowDeactivated(oldFocus);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -59,8 +59,9 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShell
|
||||
{
|
||||
public:
|
||||
QWaylandXdgShellIntegration(QWaylandDisplay *display);
|
||||
bool initialize(QWaylandDisplay *) Q_DECL_OVERRIDE { return m_xdgShell != Q_NULLPTR; }
|
||||
bool initialize(QWaylandDisplay *display) Q_DECL_OVERRIDE;
|
||||
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) Q_DECL_OVERRIDE;
|
||||
void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QWaylandXdgShell *m_xdgShell;
|
||||
|
@ -96,8 +96,6 @@ public:
|
||||
void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE;
|
||||
void sendProperty(const QString &name, const QVariant &value) Q_DECL_OVERRIDE;
|
||||
|
||||
bool shellManagesActiveState() const Q_DECL_OVERRIDE { return true; }
|
||||
|
||||
bool isFullscreen() const { return m_fullscreen; }
|
||||
bool isMaximized() const { return m_maximized; }
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtWaylandClient/qwaylandclientexport.h>
|
||||
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -68,8 +69,20 @@ public:
|
||||
QWaylandShellIntegration() {}
|
||||
virtual ~QWaylandShellIntegration() {}
|
||||
|
||||
virtual bool initialize(QWaylandDisplay *display) = 0;
|
||||
virtual bool initialize(QWaylandDisplay *display) {
|
||||
m_display = display;
|
||||
return true;
|
||||
}
|
||||
virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
|
||||
virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
|
||||
if (newFocus)
|
||||
m_display->handleWindowActivated(newFocus);
|
||||
if (oldFocus)
|
||||
m_display->handleWindowDeactivated(oldFocus);
|
||||
}
|
||||
|
||||
protected:
|
||||
QWaylandDisplay *m_display;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user