mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Return changes in qtwin to work even at Windows XP
This commit is contained in:
parent
6857d46d3b
commit
871edfd20c
70
src/3rdparty/qtwin.cpp
vendored
70
src/3rdparty/qtwin.cpp
vendored
@ -35,6 +35,40 @@
|
|||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
|
|
||||||
|
// Blur behind data structures
|
||||||
|
#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified
|
||||||
|
#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified
|
||||||
|
#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified
|
||||||
|
#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message
|
||||||
|
|
||||||
|
typedef struct _DWM_BLURBEHIND
|
||||||
|
{
|
||||||
|
DWORD dwFlags;
|
||||||
|
BOOL fEnable;
|
||||||
|
HRGN hRgnBlur;
|
||||||
|
BOOL fTransitionOnMaximized;
|
||||||
|
} DWM_BLURBEHIND, *PDWM_BLURBEHIND;
|
||||||
|
|
||||||
|
typedef struct _MARGINS
|
||||||
|
{
|
||||||
|
int cxLeftWidth;
|
||||||
|
int cxRightWidth;
|
||||||
|
int cyTopHeight;
|
||||||
|
int cyBottomHeight;
|
||||||
|
} MARGINS, *PMARGINS;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled);
|
||||||
|
typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset);
|
||||||
|
typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind);
|
||||||
|
typedef HRESULT (WINAPI *PtrDwmGetColorizationColor)(DWORD *pcrColorization, BOOL *pfOpaqueBlend);
|
||||||
|
|
||||||
|
static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled= 0;
|
||||||
|
static PtrDwmEnableBlurBehindWindow pDwmEnableBlurBehindWindow = 0;
|
||||||
|
static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0;
|
||||||
|
static PtrDwmGetColorizationColor pDwmGetColorizationColor = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal helper class that notifies windows if the
|
* Internal helper class that notifies windows if the
|
||||||
* DWM compositing state changes and updates the widget
|
* DWM compositing state changes and updates the widget
|
||||||
@ -52,10 +86,22 @@ private:
|
|||||||
QWidgetList widgets;
|
QWidgetList widgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool resolveLibs()
|
||||||
|
{
|
||||||
|
if (!pDwmIsCompositionEnabled) {
|
||||||
|
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||||
|
pDwmIsCompositionEnabled =(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
|
||||||
|
pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
|
||||||
|
pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow");
|
||||||
|
pDwmGetColorizationColor = (PtrDwmGetColorizationColor)dwmLib.resolve("DwmGetColorizationColor");
|
||||||
|
}
|
||||||
|
return pDwmIsCompositionEnabled != 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Checks and returns true if Windows version
|
* Chekcs and returns true if Windows version
|
||||||
* currently running is Windows 7
|
* currently running is Windows 7
|
||||||
*
|
*
|
||||||
* This function is useful when you are using
|
* This function is useful when you are using
|
||||||
@ -83,11 +129,13 @@ bool QtWin::isRunningWindows7()
|
|||||||
bool QtWin::isCompositionEnabled()
|
bool QtWin::isCompositionEnabled()
|
||||||
{
|
{
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
if (resolveLibs()) {
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
BOOL isEnabled = false;
|
BOOL isEnabled = false;
|
||||||
hr = DwmIsCompositionEnabled(&isEnabled);
|
hr = pDwmIsCompositionEnabled(&isEnabled);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
return isEnabled;
|
return isEnabled;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -104,6 +152,7 @@ bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable)
|
|||||||
Q_ASSERT(widget);
|
Q_ASSERT(widget);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
if (resolveLibs()) {
|
||||||
DWM_BLURBEHIND bb = {0};
|
DWM_BLURBEHIND bb = {0};
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
bb.fEnable = enable;
|
bb.fEnable = enable;
|
||||||
@ -111,11 +160,12 @@ bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable)
|
|||||||
bb.hRgnBlur = NULL;
|
bb.hRgnBlur = NULL;
|
||||||
widget->setAttribute(Qt::WA_TranslucentBackground, enable);
|
widget->setAttribute(Qt::WA_TranslucentBackground, enable);
|
||||||
widget->setAttribute(Qt::WA_NoSystemBackground, enable);
|
widget->setAttribute(Qt::WA_NoSystemBackground, enable);
|
||||||
hr = DwmEnableBlurBehindWindow(widget->winId(), &bb);
|
hr = pDwmEnableBlurBehindWindow(widget->winId(), &bb);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
result = true;
|
result = true;
|
||||||
windowNotifier()->addWidget(widget);
|
windowNotifier()->addWidget(widget);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -134,6 +184,7 @@ bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable)
|
|||||||
*/
|
*/
|
||||||
bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int right, int bottom)
|
bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int right, int bottom)
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_ASSERT(widget);
|
Q_ASSERT(widget);
|
||||||
Q_UNUSED(left);
|
Q_UNUSED(left);
|
||||||
Q_UNUSED(top);
|
Q_UNUSED(top);
|
||||||
@ -143,14 +194,17 @@ bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int ri
|
|||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
if (resolveLibs()) {
|
||||||
|
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
MARGINS m = {left, top, right, bottom};
|
MARGINS m = {left, top, right, bottom};
|
||||||
hr = DwmExtendFrameIntoClientArea(widget->winId(), &m);
|
hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
result = true;
|
result = true;
|
||||||
windowNotifier()->addWidget(widget);
|
windowNotifier()->addWidget(widget);
|
||||||
}
|
}
|
||||||
widget->setAttribute(Qt::WA_TranslucentBackground, result);
|
widget->setAttribute(Qt::WA_TranslucentBackground, result);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -163,18 +217,22 @@ bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int ri
|
|||||||
QColor QtWin::colorizationColor()
|
QColor QtWin::colorizationColor()
|
||||||
{
|
{
|
||||||
QColor resultColor = QApplication::palette().window().color();
|
QColor resultColor = QApplication::palette().window().color();
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
if (resolveLibs()) {
|
||||||
DWORD color = 0;
|
DWORD color = 0;
|
||||||
BOOL opaque = FALSE;
|
BOOL opaque = FALSE;
|
||||||
|
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
hr = DwmGetColorizationColor(&color, &opaque);
|
hr = pDwmGetColorizationColor(&color, &opaque);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
resultColor = QColor(color);
|
resultColor = QColor(color);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return resultColor;
|
return resultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef W7API
|
#ifdef Q_WS_WIN
|
||||||
WindowNotifier *QtWin::windowNotifier()
|
WindowNotifier *QtWin::windowNotifier()
|
||||||
{
|
{
|
||||||
static WindowNotifier *windowNotifierInstance = 0;
|
static WindowNotifier *windowNotifierInstance = 0;
|
||||||
|
1
src/3rdparty/qtwin.h
vendored
1
src/3rdparty/qtwin.h
vendored
@ -39,7 +39,6 @@
|
|||||||
#include <ShlObj.h>
|
#include <ShlObj.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <Propvarutil.h>
|
#include <Propvarutil.h>
|
||||||
#include <dwmapi.h>
|
|
||||||
|
|
||||||
DEFINE_PROPERTYKEY(PKEY_Title, 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 2);
|
DEFINE_PROPERTYKEY(PKEY_Title, 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 2);
|
||||||
DEFINE_PROPERTYKEY(PKEY_AppUserModel_IsDestListSeparator, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 6);
|
DEFINE_PROPERTYKEY(PKEY_AppUserModel_IsDestListSeparator, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 6);
|
||||||
|
@ -79,6 +79,7 @@ SOURCES += main.cpp\
|
|||||||
plugins/plugins.cpp \
|
plugins/plugins.cpp \
|
||||||
preferences/pluginslist.cpp \
|
preferences/pluginslist.cpp \
|
||||||
plugins/pluginproxy.cpp \
|
plugins/pluginproxy.cpp \
|
||||||
|
app/appui.cpp \
|
||||||
tools/clickablelabel.cpp \
|
tools/clickablelabel.cpp \
|
||||||
downloads/downloadoptionsdialog.cpp \
|
downloads/downloadoptionsdialog.cpp \
|
||||||
tools/treewidget.cpp \
|
tools/treewidget.cpp \
|
||||||
@ -116,8 +117,7 @@ SOURCES += main.cpp\
|
|||||||
desktopnotifications/desktopnotificationsfactory.cpp \
|
desktopnotifications/desktopnotificationsfactory.cpp \
|
||||||
tools/progressbar.cpp \
|
tools/progressbar.cpp \
|
||||||
tools/iconprovider.cpp \
|
tools/iconprovider.cpp \
|
||||||
network/networkproxyfactory.cpp \
|
network/networkproxyfactory.cpp
|
||||||
tools/closedtabsmanager.cpp
|
|
||||||
|
|
||||||
HEADERS += 3rdparty/squeezelabel.h \
|
HEADERS += 3rdparty/squeezelabel.h \
|
||||||
3rdparty/qtwin.h \
|
3rdparty/qtwin.h \
|
||||||
@ -193,8 +193,7 @@ HEADERS += 3rdparty/squeezelabel.h \
|
|||||||
desktopnotifications/desktopnotificationsfactory.h \
|
desktopnotifications/desktopnotificationsfactory.h \
|
||||||
tools/progressbar.h \
|
tools/progressbar.h \
|
||||||
tools/iconprovider.h \
|
tools/iconprovider.h \
|
||||||
network/networkproxyfactory.h \
|
network/networkproxyfactory.h
|
||||||
tools/closedtabsmanager.h
|
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
@ -236,4 +235,4 @@ include(3rdparty/qtsingleapplication.pri)
|
|||||||
unix:QT += dbus
|
unix:QT += dbus
|
||||||
win32:DEFINES += W7API
|
win32:DEFINES += W7API
|
||||||
win32:RC_FILE = appicon.rc
|
win32:RC_FILE = appicon.rc
|
||||||
win32:LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.lib DwmApi.lib
|
win32:LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.lib
|
||||||
|
Loading…
Reference in New Issue
Block a user