mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Revert "[QtWin] using of direct WinAPI call."
It has to be resolved at runtime to provide the same binary
compatibility with Windows versions older than Vista.
This reverts commit 2db89f50bf
.
This commit is contained in:
parent
aadf72b7df
commit
27cd8cce64
@ -13,10 +13,6 @@ unix: VERSION = 1.3.5
|
|||||||
win32-msvc* {
|
win32-msvc* {
|
||||||
DEFINES *= W7API
|
DEFINES *= W7API
|
||||||
LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.lib
|
LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.lib
|
||||||
# QSysInfo::WV_VISTA is 128
|
|
||||||
!lessThan(QMAKE_HOST.version, 128) {
|
|
||||||
LIBS += Dwmapi.lib
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for pkg-config availability
|
# Check for pkg-config availability
|
||||||
|
70
src/lib/3rdparty/qtwin.cpp
vendored
70
src/lib/3rdparty/qtwin.cpp
vendored
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -25,6 +25,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qtwin.h"
|
#include "qtwin.h"
|
||||||
|
#include <QLibrary>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@ -33,15 +34,37 @@
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
#if WINVER >= _WIN32_WINNT_VISTA
|
|
||||||
#include "Dwmapi.h"
|
|
||||||
const bool Vista_Or_Newer = true;
|
|
||||||
#else
|
|
||||||
const bool Vista_Or_Newer = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
// 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
|
#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;
|
||||||
|
|
||||||
QHash<QWidget*, bool> widgetsBlurState = QHash<QWidget*, bool>();
|
QHash<QWidget*, bool> widgetsBlurState = QHash<QWidget*, bool>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -70,7 +93,20 @@ public:
|
|||||||
private:
|
private:
|
||||||
QWidgetList widgets;
|
QWidgetList widgets;
|
||||||
};
|
};
|
||||||
#endif // Q_OS_WIN
|
|
||||||
|
static bool resolveLibs()
|
||||||
|
{
|
||||||
|
if (!pDwmIsCompositionEnabled) {
|
||||||
|
QLibrary dwmLib(QString::fromLatin1("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
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Chekcs and returns true if Windows version
|
* Chekcs and returns true if Windows version
|
||||||
@ -102,10 +138,10 @@ bool QtWin::isRunningWindows7()
|
|||||||
bool QtWin::isCompositionEnabled()
|
bool QtWin::isCompositionEnabled()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (Vista_Or_Newer) {
|
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;
|
||||||
}
|
}
|
||||||
@ -126,7 +162,7 @@ bool QtWin::enableBlurBehindWindow(QWidget* widget, bool enable)
|
|||||||
Q_ASSERT(widget);
|
Q_ASSERT(widget);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (Vista_Or_Newer) {
|
if (resolveLibs()) {
|
||||||
DWM_BLURBEHIND bb = {0};
|
DWM_BLURBEHIND bb = {0};
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
bb.fEnable = enable;
|
bb.fEnable = enable;
|
||||||
@ -138,7 +174,7 @@ bool QtWin::enableBlurBehindWindow(QWidget* widget, bool enable)
|
|||||||
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
||||||
widget->setWindowOpacity(1);
|
widget->setWindowOpacity(1);
|
||||||
|
|
||||||
hr = DwmEnableBlurBehindWindow(hwndOfWidget(widget) , &bb);
|
hr = pDwmEnableBlurBehindWindow(hwndOfWidget(widget) , &bb);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
result = true;
|
result = true;
|
||||||
windowNotifier()->addWidget(widget);
|
windowNotifier()->addWidget(widget);
|
||||||
@ -173,10 +209,11 @@ bool QtWin::extendFrameIntoClientArea(QWidget* widget, int left, int top, int ri
|
|||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (Vista_Or_Newer) {
|
if (resolveLibs()) {
|
||||||
|
QLibrary dwmLib(QString::fromLatin1("dwmapi"));
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
MARGINS m = {left, right, top, bottom};
|
MARGINS m = {left, right, top, bottom};
|
||||||
hr = DwmExtendFrameIntoClientArea(hwndOfWidget(widget), &m);
|
hr = pDwmExtendFrameIntoClientArea(hwndOfWidget(widget), &m);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
result = true;
|
result = true;
|
||||||
windowNotifier()->addWidget(widget);
|
windowNotifier()->addWidget(widget);
|
||||||
@ -200,11 +237,12 @@ QColor QtWin::colorizationColor()
|
|||||||
QColor resultColor = QApplication::palette().window().color();
|
QColor resultColor = QApplication::palette().window().color();
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (Vista_Or_Newer) {
|
if (resolveLibs()) {
|
||||||
DWORD color = 0;
|
DWORD color = 0;
|
||||||
BOOL opaque = FALSE;
|
BOOL opaque = FALSE;
|
||||||
|
QLibrary dwmLib(QString::fromLatin1("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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user