From 850b602c7a72635eb37a998089ee085d5d505c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 13 May 2011 11:51:41 +0200 Subject: Initial QPlatformWindow window state setting API and xcb implementation. --- src/widgets/kernel/qwidget_qpa.cpp | 50 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src/widgets/kernel/qwidget_qpa.cpp') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index f6833915ec..b7b502a35f 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -443,7 +443,7 @@ void QWidgetPrivate::setFullScreenSize_helper() data.in_set_window_state = old_state; } -static Qt::WindowStates effectiveState(Qt::WindowStates state) +static Qt::WindowState effectiveState(Qt::WindowStates state) { if (state & Qt::WindowMinimized) return Qt::WindowMinimized; @@ -466,8 +466,8 @@ void QWidget::setWindowState(Qt::WindowStates newstate) data->window_state = newstate; data->in_set_window_state = 1; bool needShow = false; - Qt::WindowStates newEffectiveState = effectiveState(newstate); - Qt::WindowStates oldEffectiveState = effectiveState(oldstate); + Qt::WindowState newEffectiveState = effectiveState(newstate); + Qt::WindowState oldEffectiveState = effectiveState(oldstate); if (isWindow() && newEffectiveState != oldEffectiveState) { d->createTLExtra(); if (oldEffectiveState == Qt::WindowNoState) { //normal @@ -479,24 +479,32 @@ void QWidget::setWindowState(Qt::WindowStates newstate) needShow = true; } - if (newEffectiveState == Qt::WindowMinimized) { - //### not ideal... - hide(); - needShow = false; - } else if (newEffectiveState == Qt::WindowFullScreen) { - d->topData()->savedFlags = windowFlags(); - setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint)); - d->setFullScreenSize_helper(); - raise(); - needShow = true; - } else if (newEffectiveState == Qt::WindowMaximized) { - createWinId(); - d->setMaxWindowState_helper(); - } else { //normal - QRect r = d->topData()->normalGeometry; - if (r.width() >= 0) { - d->topData()->normalGeometry = QRect(0,0,-1,-1); - setGeometry(r); + Q_ASSERT(windowHandle()); + windowHandle()->setWindowState(newEffectiveState); + bool supported = windowHandle()->windowState() == newEffectiveState; + + if (!supported) { + // emulate the window state + if (newEffectiveState == Qt::WindowMinimized) { + //### not ideal... + hide(); + needShow = false; + } else if (newEffectiveState == Qt::WindowFullScreen) { + d->topData()->savedFlags = windowFlags(); + setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint)); + d->setFullScreenSize_helper(); + raise(); + needShow = true; + } else if (newEffectiveState == Qt::WindowMaximized) { + createWinId(); + d->setMaxWindowState_helper(); + } else if (newEffectiveState == Qt::WindowNoState) { + // reset old geometry + QRect r = d->topData()->normalGeometry; + if (r.width() >= 0) { + d->topData()->normalGeometry = QRect(0,0,-1,-1); + setGeometry(r); + } } } } -- cgit v1.2.3