Adapt to the API change in QPlatformWindow::setWindowState

Change-Id: Ic6655f239ea449baf862934608feda182799c42d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Olivier Goffart 2017-02-09 08:43:59 +01:00 committed by Paul Olav Tvete
parent a74c82edb4
commit 15b3e52c18
2 changed files with 24 additions and 29 deletions

View File

@ -195,7 +195,7 @@ void QWaylandWindow::initWindow()
else else
setGeometry_helper(window()->geometry()); setGeometry_helper(window()->geometry());
setMask(window()->mask()); setMask(window()->mask());
setWindowStateInternal(window()->windowState()); setWindowStateInternal(window()->windowStates());
handleContentOrientationChange(window()->contentOrientation()); handleContentOrientationChange(window()->contentOrientation());
mFlags = window()->flags(); mFlags = window()->flags();
} }
@ -571,7 +571,7 @@ void QWaylandWindow::setOrientationMask(Qt::ScreenOrientations mask)
mShellSurface->setContentOrientationMask(mask); mShellSurface->setContentOrientationMask(mask);
} }
void QWaylandWindow::setWindowState(Qt::WindowState state) void QWaylandWindow::setWindowState(Qt::WindowStates state)
{ {
if (setWindowStateInternal(state)) if (setWindowStateInternal(state))
QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged QWindowSystemInterface::flushWindowSystemEvents(); // Required for oldState to work on WindowStateChanged
@ -589,16 +589,16 @@ void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
bool QWaylandWindow::createDecoration() bool QWaylandWindow::createDecoration()
{ {
// so far only xdg-shell support this "unminimize" trick, may be moved elsewhere // so far only xdg-shell support this "unminimize" trick, may be moved elsewhere
if (mState == Qt::WindowMinimized) { if (mState & Qt::WindowMinimized) {
QWaylandXdgSurface *xdgSurface = qobject_cast<QWaylandXdgSurface *>(mShellSurface); QWaylandXdgSurface *xdgSurface = qobject_cast<QWaylandXdgSurface *>(mShellSurface);
if ( xdgSurface ) { if ( xdgSurface ) {
if (xdgSurface->isFullscreen()) { Qt::WindowStates states;
setWindowStateInternal(Qt::WindowFullScreen); if (xdgSurface->isFullscreen())
} else if (xdgSurface->isMaximized()) { states |= Qt::WindowFullScreen;
setWindowStateInternal(Qt::WindowMaximized); if (xdgSurface->isMaximized())
} else { states |= Qt::WindowMaximized;
setWindowStateInternal(Qt::WindowNoState);
} setWindowStateInternal(states);
} }
} }
@ -849,7 +849,7 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
return true; return true;
} }
bool QWaylandWindow::setWindowStateInternal(Qt::WindowState state) bool QWaylandWindow::setWindowStateInternal(Qt::WindowStates state)
{ {
if (mState == state) { if (mState == state) {
return false; return false;
@ -862,20 +862,15 @@ bool QWaylandWindow::setWindowStateInternal(Qt::WindowState state)
if (mShellSurface) { if (mShellSurface) {
createDecoration(); createDecoration();
switch (state) { if (state & Qt::WindowMaximized)
case Qt::WindowFullScreen:
mShellSurface->setFullscreen();
break;
case Qt::WindowMaximized:
mShellSurface->setMaximized(); mShellSurface->setMaximized();
break; if (state & Qt::WindowFullScreen)
case Qt::WindowMinimized: mShellSurface->setFullscreen();
if (state & Qt::WindowMinimized)
mShellSurface->setMinimized(); mShellSurface->setMinimized();
break; if (!state)
default:
mShellSurface->setNormal(); mShellSurface->setNormal();
} }
}
QWindowSystemInterface::handleWindowStateChanged(window(), mState); QWindowSystemInterface::handleWindowStateChanged(window(), mState);
return true; return true;

View File

@ -148,7 +148,7 @@ public:
void handleContentOrientationChange(Qt::ScreenOrientation orientation) override; void handleContentOrientationChange(Qt::ScreenOrientation orientation) override;
void setOrientationMask(Qt::ScreenOrientations mask); void setOrientationMask(Qt::ScreenOrientations mask);
void setWindowState(Qt::WindowState state); // ### Change to WindowStates once qtbase change is in void setWindowState(Qt::WindowStates state) override;
void setWindowFlags(Qt::WindowFlags flags) override; void setWindowFlags(Qt::WindowFlags flags) override;
void raise() override; void raise() override;
@ -173,8 +173,8 @@ public:
bool createDecoration(); bool createDecoration();
inline bool isMaximized() const { return mState == Qt::WindowMaximized; } inline bool isMaximized() const { return mState & Qt::WindowMaximized; }
inline bool isFullscreen() const { return mState == Qt::WindowFullScreen; } inline bool isFullscreen() const { return mState & Qt::WindowFullScreen; }
#if QT_CONFIG(cursor) #if QT_CONFIG(cursor)
void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor); void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor);
@ -238,14 +238,14 @@ protected:
QIcon mWindowIcon; QIcon mWindowIcon;
Qt::WindowState mState; Qt::WindowStates mState;
Qt::WindowFlags mFlags; Qt::WindowFlags mFlags;
QRegion mMask; QRegion mMask;
QWaylandShmBackingStore *mBackingStore; QWaylandShmBackingStore *mBackingStore;
private: private:
bool setWindowStateInternal(Qt::WindowState flags); bool setWindowStateInternal(Qt::WindowStates flags);
void setGeometry_helper(const QRect &rect); void setGeometry_helper(const QRect &rect);
void initWindow(); void initWindow();
bool shouldCreateShellSurface() const; bool shouldCreateShellSurface() const;