From 02ea92ad2884ce989e34d149a11341275c126936 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 22 Dec 2012 15:01:55 +0100 Subject: [PATCH] Qt5: X11: Fixed moving windows to virtual desktops Moving windows to virtual desktops upon restoring session. --- src/lib/app/qupzilla.cpp | 19 ++++++++++--------- src/lib/app/qupzilla.h | 2 +- src/lib/lib.pro | 2 +- src/lib/tools/globalfunctions.cpp | 14 ++++++++++++++ src/lib/tools/globalfunctions.h | 4 ++++ 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index f73824c5d..edc57ce77 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -83,12 +83,12 @@ #if QT_VERSION < 0x050000 #include "qwebkitversion.h" +#endif + #ifdef QZ_WS_X11 -#include #include #include -#endif // QZ_WS_X11 -#endif // QT_VERSION +#endif const QString QupZilla::VERSION = "1.3.5"; const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; @@ -1913,7 +1913,7 @@ bool QupZilla::quitApp() QByteArray QupZilla::saveState(int version) const { -#if defined(QZ_WS_X11) && QT_VERSION < 0x050000 +#ifdef QZ_WS_X11 QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); @@ -1928,7 +1928,7 @@ QByteArray QupZilla::saveState(int version) const bool QupZilla::restoreState(const QByteArray &state, int version) { -#if defined(QZ_WS_X11) && QT_VERSION < 0x050000 +#ifdef QZ_WS_X11 QByteArray windowState; int desktopId = -1; @@ -1944,10 +1944,10 @@ bool QupZilla::restoreState(const QByteArray &state, int version) #endif } -#if defined(QZ_WS_X11) && QT_VERSION < 0x050000 +#ifdef QZ_WS_X11 int QupZilla::getCurrentVirtualDesktop() const { - Display* display = QX11Info::display(); + Display* display = static_cast(qz_X11Display(this)); Atom actual_type; int actual_format; unsigned long nitems; @@ -1980,7 +1980,7 @@ void QupZilla::moveToVirtualDesktop(int desktopId) return; } - Display* display = QX11Info::display(); + Display* display = static_cast(qz_X11Display(this)); Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False); if (net_wm_desktop == None) { @@ -1988,7 +1988,8 @@ void QupZilla::moveToVirtualDesktop(int desktopId) } // Fixes issue when the property wasn't set on some X servers - setVisible(true); + // hmmm does it? + //setVisible(true); XChangeProperty(display, winId(), net_wm_desktop, XA_CARDINAL, 32, PropModeReplace, (unsigned char*) &desktopId, 1L); diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index 91b9cebfe..3cc8cbadd 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -214,7 +214,7 @@ private: bool eventFilter(QObject* object, QEvent* event); #endif -#if defined(QZ_WS_X11) && QT_VERSION < 0x050000 +#ifdef QZ_WS_X11 int getCurrentVirtualDesktop() const; void moveToVirtualDesktop(int desktopId); #endif diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 095b1aafa..8586d6605 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -1,5 +1,5 @@ isEqual(QT_MAJOR_VERSION, 5) { - QT += webkitwidgets network widgets printsupport sql script + QT += webkitwidgets network widgets printsupport sql script gui-private } else { QT += core gui webkit sql network script } diff --git a/src/lib/tools/globalfunctions.cpp b/src/lib/tools/globalfunctions.cpp index 4867b269e..d9cd51805 100644 --- a/src/lib/tools/globalfunctions.cpp +++ b/src/lib/tools/globalfunctions.cpp @@ -34,6 +34,9 @@ #if QT_VERSION >= 0x050000 #include +#include +#else +#include #endif QByteArray qz_pixmapToByteArray(const QPixmap &pix) @@ -379,6 +382,17 @@ QString QT_QUPZILLA_EXPORT qz_escape(const QString &string) #endif } +void QT_QUPZILLA_EXPORT* qz_X11Display(const QWidget* widget) +{ + Q_UNUSED(widget) + +#if QT_VERSION >= 0x050000 + return qApp->platformNativeInterface()->nativeResourceForWindow("display", widget->windowHandle()); +#else + return QX11Info::display(); +#endif +} + QString qz_buildSystem() { #ifdef Q_OS_LINUX diff --git a/src/lib/tools/globalfunctions.h b/src/lib/tools/globalfunctions.h index 0a1e5fab6..cefd2c654 100644 --- a/src/lib/tools/globalfunctions.h +++ b/src/lib/tools/globalfunctions.h @@ -61,6 +61,10 @@ QString QT_QUPZILLA_EXPORT qz_buildSystem(); bool QT_QUPZILLA_EXPORT qz_isCertificateValid(const QSslCertificate &cert); QString QT_QUPZILLA_EXPORT qz_escape(const QString &string); +#ifdef QZ_WS_X11 +void QT_QUPZILLA_EXPORT* qz_X11Display(const QWidget* widget); +#endif + template bool qz_listContainsIndex(const QList &list, int index) {