Remove use of X11Extras and WinExtras
Modules are deprecated in Qt 6 See: QTBUG-83251
This commit is contained in:
@@ -551,23 +551,24 @@ if(HAVE_GLOBALSHORTCUTS)
|
||||
HEADERS globalshortcuts/globalshortcutsmanager.h globalshortcuts/globalshortcutsbackend.h globalshortcuts/globalshortcutgrabber.h settings/globalshortcutssettingspage.h
|
||||
UI globalshortcuts/globalshortcutgrabber.ui settings/globalshortcutssettingspage.ui
|
||||
)
|
||||
if(HAVE_X11EXTRAS OR WIN32)
|
||||
set(X11_OR_WIN ON)
|
||||
endif()
|
||||
optional_source(X11_OR_WIN
|
||||
SOURCES globalshortcuts/globalshortcutsbackend-system.cpp globalshortcuts/globalshortcut.cpp
|
||||
HEADERS globalshortcuts/globalshortcutsbackend-system.h globalshortcuts/globalshortcut.h
|
||||
)
|
||||
optional_source(HAVE_X11EXTRAS
|
||||
SOURCES globalshortcuts/globalshortcut-x11.cpp
|
||||
)
|
||||
optional_source(HAVE_DBUS
|
||||
SOURCES globalshortcuts/globalshortcutsbackend-gsd.cpp globalshortcuts/globalshortcutsbackend-kde.cpp
|
||||
HEADERS globalshortcuts/globalshortcutsbackend-gsd.h globalshortcuts/globalshortcutsbackend-kde.h
|
||||
)
|
||||
optional_source(WIN32
|
||||
SOURCES globalshortcuts/globalshortcut-win.cpp
|
||||
)
|
||||
# Native shortcuts for X11 and Windows
|
||||
if(HAVE_X11_GLOBALSHORTCUTS OR WIN32)
|
||||
SET(X11_OR_WIN ON)
|
||||
optional_source(X11_OR_WIN
|
||||
SOURCES globalshortcuts/globalshortcutsbackend-system.cpp globalshortcuts/globalshortcut.cpp
|
||||
HEADERS globalshortcuts/globalshortcutsbackend-system.h globalshortcuts/globalshortcut.h
|
||||
)
|
||||
optional_source(HAVE_X11_GLOBALSHORTCUTS
|
||||
SOURCES globalshortcuts/globalshortcut-x11.cpp
|
||||
)
|
||||
optional_source(WIN32
|
||||
SOURCES globalshortcuts/globalshortcut-win.cpp
|
||||
)
|
||||
endif()
|
||||
endif(HAVE_GLOBALSHORTCUTS)
|
||||
|
||||
# ALSA
|
||||
@@ -1250,7 +1251,7 @@ if(APPLE)
|
||||
endif(APPLE)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(strawberry_lib PRIVATE dsound)
|
||||
target_link_libraries(strawberry_lib PRIVATE dsound dwmapi)
|
||||
endif(WIN32)
|
||||
|
||||
if(X11_FOUND)
|
||||
@@ -1305,4 +1306,4 @@ endif()
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(strawberry PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/../dist/macos/Info.plist")
|
||||
endif (APPLE)
|
||||
endif(APPLE)
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
#cmakedefine INSTALL_TRANSLATIONS
|
||||
#define TRANSLATIONS_DIR "${CMAKE_INSTALL_PREFIX}/share/strawberry/translations"
|
||||
|
||||
#cmakedefine HAVE_X11EXTRAS
|
||||
#cmakedefine HAVE_WINEXTRAS
|
||||
#cmakedefine HAVE_QPA_QPLATFORMNATIVEINTERFACE_H
|
||||
|
||||
#cmakedefine ENABLE_WIN32_CONSOLE
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QtGlobal>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include <QWindow>
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include <QIODevice>
|
||||
@@ -51,6 +52,7 @@
|
||||
#include <QRegularExpressionMatch>
|
||||
#include <QSize>
|
||||
#include <QColor>
|
||||
#include <QRegion>
|
||||
#include <QMetaEnum>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QSettings>
|
||||
@@ -79,6 +81,7 @@
|
||||
# include <sys/statvfs.h>
|
||||
#elif defined(Q_OS_WIN)
|
||||
# include <windows.h>
|
||||
# include <dwmapi.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
@@ -952,6 +955,62 @@ QString MimeTypeFromData(const QByteArray &data) {
|
||||
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
HRGN qt_RectToHRGN(const QRect &rc);
|
||||
HRGN qt_RectToHRGN(const QRect &rc) {
|
||||
return CreateRectRgn(rc.left(), rc.top(), rc.right() + 1, rc.bottom() + 1);
|
||||
}
|
||||
|
||||
HRGN toHRGN(const QRegion ®ion);
|
||||
HRGN toHRGN(const QRegion ®ion) {
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
return region.toHRGN();
|
||||
#else
|
||||
|
||||
const int rect_count = region.rectCount();
|
||||
if (rect_count == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HRGN resultRgn = nullptr;
|
||||
QRegion::const_iterator rects = region.begin();
|
||||
resultRgn = qt_RectToHRGN(rects[0]);
|
||||
for (int i = 1 ; i < rect_count ; ++i) {
|
||||
HRGN tmpRgn = qt_RectToHRGN(rects[i]);
|
||||
const int res = CombineRgn(resultRgn, resultRgn, tmpRgn, RGN_OR);
|
||||
if (res == ERROR) qWarning("Error combining HRGNs.");
|
||||
DeleteObject(tmpRgn);
|
||||
}
|
||||
|
||||
return resultRgn;
|
||||
|
||||
#endif // Qt 6
|
||||
|
||||
}
|
||||
|
||||
void enableBlurBehindWindow(QWindow *window, const QRegion ®ion) {
|
||||
|
||||
DWM_BLURBEHIND dwmbb = {0, 0, nullptr, 0};
|
||||
dwmbb.dwFlags = DWM_BB_ENABLE;
|
||||
dwmbb.fEnable = TRUE;
|
||||
HRGN rgn = nullptr;
|
||||
if (!region.isNull()) {
|
||||
rgn = toHRGN(region);
|
||||
if (rgn) {
|
||||
dwmbb.hRgnBlur = rgn;
|
||||
dwmbb.dwFlags |= DWM_BB_BLURREGION;
|
||||
}
|
||||
}
|
||||
DwmEnableBlurBehindWindow(reinterpret_cast<HWND>(window->winId()), &dwmbb);
|
||||
if (rgn) {
|
||||
DeleteObject(rgn);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
} // namespace Utilities
|
||||
|
||||
ScopedWCharArray::ScopedWCharArray(const QString &str)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QWindow>
|
||||
#include <QByteArray>
|
||||
#include <QFile>
|
||||
#include <QSize>
|
||||
@@ -38,6 +39,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#include <QColor>
|
||||
#include <QRegion>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "core/song.h"
|
||||
@@ -146,6 +148,10 @@ bool IsColorDark(const QColor &color);
|
||||
QByteArray ReadDataFromFile(const QString &filename);
|
||||
QString MimeTypeFromData(const QByteArray &data);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
void enableBlurBehindWindow(QWindow *window, const QRegion ®ion);
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
class ScopedWCharArray {
|
||||
|
||||
@@ -54,7 +54,6 @@ bool GlobalShortcut::unregisterShortcut(quint32 native_key, quint32 native_mods)
|
||||
return UnregisterHotKey(0, native_mods ^ native_key);
|
||||
}
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
bool GlobalShortcut::nativeEventFilter(const QByteArray &eventtype, void *message, qintptr *result) {
|
||||
#else
|
||||
|
||||
@@ -20,13 +20,14 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QApplication>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QX11Info>
|
||||
#include <QKeySequence>
|
||||
#include <QFlags>
|
||||
#include <QScreen>
|
||||
|
||||
#include "globalshortcut.h"
|
||||
#include "keymapper_x11.h"
|
||||
@@ -36,8 +37,40 @@
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
const QVector<quint32> GlobalShortcut::mask_modifiers_ = QVector<quint32>() << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask);
|
||||
|
||||
namespace {
|
||||
|
||||
Display *X11Display() {
|
||||
|
||||
if (!qApp) return nullptr;
|
||||
|
||||
QPlatformNativeInterface *native = qApp->platformNativeInterface();
|
||||
if (!native) return nullptr;
|
||||
|
||||
void *display = native->nativeResourceForIntegration("display");
|
||||
return reinterpret_cast<Display*>(display);
|
||||
|
||||
}
|
||||
|
||||
quint32 AppRootWindow() {
|
||||
|
||||
if (!qApp) return 0;
|
||||
|
||||
QPlatformNativeInterface *native = qApp->platformNativeInterface();
|
||||
if (!native) return 0;
|
||||
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
if (!screen) return 0;
|
||||
|
||||
return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen("rootwindow", screen)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
quint32 GlobalShortcut::nativeModifiers(Qt::KeyboardModifiers qt_mods) {
|
||||
|
||||
quint32 native_mods = 0;
|
||||
@@ -51,7 +84,8 @@ quint32 GlobalShortcut::nativeModifiers(Qt::KeyboardModifiers qt_mods) {
|
||||
|
||||
quint32 GlobalShortcut::nativeKeycode(Qt::Key qt_key) {
|
||||
|
||||
if (!QX11Info::display()) return 0;
|
||||
Display *disp = X11Display();
|
||||
if (!disp) return false;
|
||||
|
||||
quint32 keysym = 0;
|
||||
if (KeyMapperX11::keymapper_x11_.contains(qt_key)) {
|
||||
@@ -61,25 +95,32 @@ quint32 GlobalShortcut::nativeKeycode(Qt::Key qt_key) {
|
||||
keysym = XStringToKeysym(QKeySequence(qt_key).toString().toLatin1().data());
|
||||
if (keysym == NoSymbol) return 0;
|
||||
}
|
||||
return XKeysymToKeycode(QX11Info::display(), keysym);
|
||||
return XKeysymToKeycode(disp, keysym);
|
||||
|
||||
}
|
||||
|
||||
bool GlobalShortcut::registerShortcut(quint32 native_key, quint32 native_mods) {
|
||||
if (!QX11Info::display()) return false;
|
||||
|
||||
Display *disp = X11Display();
|
||||
if (!disp) return false;
|
||||
|
||||
for (quint32 mask_mods : mask_modifiers_) {
|
||||
//xcb_grab_key(QX11Info::connection(), 1, QX11Info::appRootWindow(), (native_mods | mask_mods), native_key, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
XGrabKey(QX11Info::display(), native_key, (native_mods | mask_mods), QX11Info::appRootWindow(), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(disp, native_key, (native_mods | mask_mods), AppRootWindow(), True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool GlobalShortcut::unregisterShortcut(quint32 native_key, quint32 native_mods) {
|
||||
if (!QX11Info::display()) return false;
|
||||
|
||||
Display *disp = X11Display();
|
||||
if (!disp) return false;
|
||||
|
||||
for (quint32 mask_mods : mask_modifiers_) {
|
||||
XUngrabKey(QX11Info::display(), native_key, native_mods | mask_mods, QX11Info::appRootWindow());
|
||||
XUngrabKey(disp, native_key, native_mods | mask_mods, AppRootWindow());
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
@@ -32,9 +33,6 @@
|
||||
#ifdef HAVE_DBUS
|
||||
# include <QDBusConnectionInterface>
|
||||
#endif
|
||||
#ifdef HAVE_X11EXTRAS
|
||||
# include <QX11Info>
|
||||
#endif
|
||||
|
||||
#include "globalshortcutsmanager.h"
|
||||
#include "globalshortcutsbackend.h"
|
||||
@@ -43,7 +41,7 @@
|
||||
# include "globalshortcutsbackend-gsd.h"
|
||||
# include "globalshortcutsbackend-kde.h"
|
||||
#endif
|
||||
#if defined(HAVE_X11EXTRAS) || defined(Q_OS_WIN)
|
||||
#if (defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)) || defined(Q_OS_WIN)
|
||||
# include "globalshortcutsbackend-system.h"
|
||||
#endif
|
||||
#ifdef Q_OS_MACOS
|
||||
@@ -99,7 +97,7 @@ GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent)
|
||||
if (!system_backend_)
|
||||
system_backend_ = new GlobalShortcutsBackendSystem(this);
|
||||
#endif
|
||||
#if defined(HAVE_X11EXTRAS)
|
||||
#if defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
if (!system_backend_ && IsX11Available())
|
||||
system_backend_ = new GlobalShortcutsBackendSystem(this);
|
||||
#endif
|
||||
@@ -168,11 +166,7 @@ bool GlobalShortcutsManager::IsKdeAvailable() const {
|
||||
|
||||
bool GlobalShortcutsManager::IsX11Available() const {
|
||||
|
||||
#ifdef HAVE_X11EXTRAS
|
||||
return QX11Info::isPlatformX11();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return QApplication::platformName() == "xcb";
|
||||
|
||||
}
|
||||
|
||||
@@ -180,12 +174,12 @@ void GlobalShortcutsManager::Register() {
|
||||
|
||||
if (use_gsd_ && gsd_backend_ && gsd_backend_->Register()) return;
|
||||
if (use_kde_ && kde_backend_ && kde_backend_->Register()) return;
|
||||
#ifdef HAVE_X11EXTRAS // If this system has X11, only use the system backend if X11 is enabled in the global shortcut settings
|
||||
#if defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H) // If this system has X11, only use the system backend if X11 is enabled in the global shortcut settings
|
||||
if (use_x11_) {
|
||||
#endif
|
||||
if (system_backend_)
|
||||
system_backend_->Register();
|
||||
#ifdef HAVE_X11EXTRAS
|
||||
#if defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -53,14 +53,9 @@
|
||||
#include <QSettings>
|
||||
#include <QFlags>
|
||||
#include <QtEvents>
|
||||
#ifdef HAVE_X11EXTRAS
|
||||
# include <QX11Info>
|
||||
#elif defined(Q_OS_UNIX) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
#if defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
# include <qpa/qplatformnativeinterface.h>
|
||||
#endif
|
||||
#ifdef HAVE_WINEXTRAS
|
||||
# include <QtWin>
|
||||
#endif
|
||||
|
||||
#include "osdpretty.h"
|
||||
#include "ui_osdpretty.h"
|
||||
@@ -69,6 +64,8 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "core/utilities.h"
|
||||
|
||||
const char *OSDPretty::kSettingsGroup = "OSDPretty";
|
||||
|
||||
const int OSDPretty::kDropShadowSize = 13;
|
||||
@@ -213,21 +210,14 @@ void OSDPretty::ScreenRemoved(QScreen *screen) {
|
||||
|
||||
bool OSDPretty::IsTransparencyAvailable() {
|
||||
|
||||
#if defined(HAVE_X11EXTRAS)
|
||||
return QX11Info::isCompositingManagerRunning();
|
||||
#elif defined(Q_OS_UNIX) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
#if defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
if (qApp) {
|
||||
QPlatformNativeInterface *native = qApp->platformNativeInterface();
|
||||
if (native) {
|
||||
QScreen *screen = popup_screen_ == nullptr ? QGuiApplication::primaryScreen() : popup_screen_;
|
||||
if (screen) {
|
||||
return native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen);
|
||||
}
|
||||
else return false;
|
||||
QScreen *screen = popup_screen_ == nullptr ? QGuiApplication::primaryScreen() : popup_screen_;
|
||||
if (native && screen) {
|
||||
return native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen);
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
@@ -452,9 +442,9 @@ void OSDPretty::Reposition() {
|
||||
setMask(mask);
|
||||
}
|
||||
|
||||
#ifdef HAVE_WINEXTRAS
|
||||
// On windows, enable blurbehind on the masked area
|
||||
QtWin::enableBlurBehindWindow(this, QRegion(mask));
|
||||
#ifdef Q_OS_WIN
|
||||
Utilities::enableBlurBehindWindow(this->windowHandle(), QRegion(mask));
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -607,4 +597,3 @@ void OSDPretty::set_font(QFont font) {
|
||||
Reposition();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user