summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowscontext.cpp
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2013-09-18 11:49:05 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-21 07:45:44 +0200
commitac0bacc8afc2f0ed3e1e1a19bdb469f8a4ec557e (patch)
tree0bd9aa7905840d46b968dd08b9e59c1474c78157 /src/plugins/platforms/windows/qwindowscontext.cpp
parent2b65bba77d4705d49a01a25350de64d153808504 (diff)
Port of Qt 4's Windows session management
This patch aims to implement the session management for Windows. Based on the Qt 4 QApplication windows specific code Task-number: QTBUG-28228 Task-number: QTBUG-33032 Change-Id: I7059298ad9661aebd51e77a03f55a7a04f461479 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp70
1 files changed, 69 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 8dab1e2b1c..783d50a26a 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -49,7 +50,12 @@
#include "qwindowsinputcontext.h"
#include "qwindowstabletsupport.h"
#ifndef QT_NO_ACCESSIBILITY
-#include "accessible/qwindowsaccessibility.h"
+# include "accessible/qwindowsaccessibility.h"
+#endif
+#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+# include <private/qguiapplication_p.h>
+# include <private/qsessionmanager_p.h>
+# include "qwindowssessionmanager.h"
#endif
#include "qwindowsscreen.h"
#include "qwindowstheme.h"
@@ -151,6 +157,14 @@ static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
#endif
}
+#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+static inline QWindowsSessionManager *platformSessionManager() {
+ QGuiApplicationPrivate *guiPrivate = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(qApp));
+ QSessionManagerPrivate *managerPrivate = static_cast<QSessionManagerPrivate*>(QObjectPrivate::get(guiPrivate->session_manager));
+ return static_cast<QWindowsSessionManager *>(managerPrivate->platformSessionManager);
+}
+#endif
+
/*!
\class QWindowsUser32DLL
\brief Struct that contains dynamically resolved symbols of User32.dll.
@@ -828,7 +842,11 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::KeyEvent:
case QtWindows::InputMethodKeyEvent:
case QtWindows::InputMethodKeyDownEvent:
+#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+ return platformSessionManager()->isInterractionBlocked() ? true : d->m_keyMapper.translateKeyEvent(platformWindow->window(), hwnd, msg, result);
+#else
return d->m_keyMapper.translateKeyEvent(platformWindow->window(), hwnd, msg, result);
+#endif
case QtWindows::MoveEvent:
platformWindow->handleMoved();
return true;
@@ -848,7 +866,11 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return platformWindow->handleWmPaint(hwnd, message, wParam, lParam);
case QtWindows::NonClientMouseEvent:
if (platformWindow->frameStrutEventsEnabled())
+#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+ return platformSessionManager()->isInterractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
+#else
return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
+#endif
break;
/* the mouse tracking on windows already handles the reset of the cursor
* and does not like somebody else handling it.
@@ -864,9 +886,17 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::MouseWheelEvent:
case QtWindows::MouseEvent:
case QtWindows::LeaveEvent:
+#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+ return platformSessionManager()->isInterractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
+#else
return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
+#endif
case QtWindows::TouchEvent:
+#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+ return platformSessionManager()->isInterractionBlocked() ? true : d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
+#else
return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
+#endif
case QtWindows::FocusInEvent: // see QWindowsWindow::requestActivateWindow().
case QtWindows::FocusOutEvent:
handleFocusEvent(et, platformWindow);
@@ -910,6 +940,44 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return true;
#endif
} break;
+#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+ case QtWindows::QueryEndSessionApplicationEvent: {
+ QWindowsSessionManager *sessionManager = platformSessionManager();
+ if (sessionManager->isActive()) // bogus message from windows
+ return true;
+
+ sessionManager->setActive(true);
+ sessionManager->blocksInteraction();
+ sessionManager->clearCancellation();
+
+ QGuiApplicationPrivate *qGuiAppPriv = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(qApp));
+ qGuiAppPriv->commitData();
+
+ if (lParam & ENDSESSION_LOGOFF)
+ _flushall();
+
+ return !sessionManager->wasCanceled();
+ }
+ case QtWindows::EndSessionApplicationEvent: {
+ QWindowsSessionManager *sessionManager = platformSessionManager();
+
+ sessionManager->setActive(false);
+ sessionManager->allowsInteraction();
+ bool endsession = (bool) wParam;
+
+ // we receive the message for each toplevel window included internal hidden ones,
+ // but the aboutToQuit signal should be emitted only once.
+ QGuiApplicationPrivate *qGuiAppPriv = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(qApp));
+ if (endsession && !qGuiAppPriv->aboutToQuitEmitted) {
+ qGuiAppPriv->aboutToQuitEmitted = true;
+ int index = QGuiApplication::staticMetaObject.indexOfSignal("aboutToQuit()");
+ qApp->qt_metacall(QMetaObject::InvokeMetaMethod, index,0);
+ // since the process will be killed immediately quit() has no real effect
+ QGuiApplication::quit();
+ }
+ return true;
+ }
+#endif // !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
default:
break;
}