diff --git a/CMakeLists.txt b/CMakeLists.txt index b0673cd50..9f2878436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,17 +161,22 @@ else() endif() set(QT_COMPONENTS Core Concurrent Widgets Network Sql) -if(X11_FOUND) - list(APPEND QT_COMPONENTS X11Extras) -endif() +unset(OPTIONAL_COMPONENTS) + if(DBUS_FOUND) list(APPEND QT_COMPONENTS DBus) endif() +if(X11_FOUND) + list(APPEND OPTIONAL_COMPONENTS X11Extras) +endif() if(WIN32) - list(APPEND QT_COMPONENTS WinExtras) + list(APPEND OPTIONAL_COMPONENTS WinExtras) endif() find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS ${QT_COMPONENTS}) +if(OPTIONAL_COMPONENTS) + find_package(Qt${QT_MAJOR_VERSION} OPTIONAL_COMPONENTS ${OPTIONAL_COMPONENTS}) +endif(OPTIONAL_COMPONENTS) set(QtCore_LIBRARIES Qt${QT_MAJOR_VERSION}::Core) set(QtConcurrent_LIBRARIES Qt${QT_MAJOR_VERSION}::Concurrent) @@ -187,10 +192,12 @@ endif() if(Qt${QT_MAJOR_VERSION}X11Extras_FOUND) set(QtX11Extras_LIBRARIES Qt${QT_MAJOR_VERSION}::X11Extras) list(APPEND QT_LIBRARIES Qt${QT_MAJOR_VERSION}::X11Extras) + set(HAVE_X11EXTRAS ON) endif() if(Qt${QT_MAJOR_VERSION}WinExtras_FOUND) set(QtWinExtras_LIBRARIES Qt${QT_MAJOR_VERSION}::WinExtras) list(APPEND QT_LIBRARIES Qt${QT_MAJOR_VERSION}::WinExtras) + set(HAVE_WINEXTRAS ON) endif() find_package(Qt${QT_MAJOR_VERSION} QUIET COMPONENTS LinguistTools CONFIG) @@ -213,6 +220,12 @@ if(X11_FOUND) endif() endif(X11_FOUND) +find_path(QPA_QPLATFORMNATIVEINTERFACE_H qpa/qplatformnativeinterface.h PATHS ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) +if(QPA_QPLATFORMNATIVEINTERFACE_H) + set(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H ON) + include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) +endif() + # TAGLIB option(USE_SYSTEM_TAGLIB "Use system taglib" OFF) if(USE_SYSTEM_TAGLIB) @@ -307,6 +320,10 @@ optional_component(GLOBALSHORTCUTS ON "Global shortcuts" DEPENDS "D-Bus, X11, Windows or macOS" HAVE_GLOBALSHORTCUTS_SUPPORT ) +optional_component(X11_GLOBALSHORTCUTS ON "X11 global shortcuts" + DEPENDS "X11Extras" Qt${QT_MAJOR_VERSION}X11Extras_FOUND +) + optional_component(AUDIOCD ON "Devices: Audio CD support" DEPENDS "libcdio" LIBCDIO_FOUND ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86e6c2b15..a8df847e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -548,14 +548,14 @@ if(HAVE_GLOBALSHORTCUTS) HEADERS globalshortcuts/globalshortcuts.h globalshortcuts/globalshortcutbackend.h globalshortcuts/globalshortcutgrabber.h settings/shortcutssettingspage.h UI globalshortcuts/globalshortcutgrabber.ui settings/shortcutssettingspage.ui ) - if (X11_FOUND OR WIN32) + if(HAVE_X11EXTRAS OR WIN32) set(X11_OR_WIN ON) endif() optional_source(X11_OR_WIN SOURCES globalshortcuts/globalshortcutbackend-system.cpp globalshortcuts/globalshortcut.cpp HEADERS globalshortcuts/globalshortcutbackend-system.h globalshortcuts/globalshortcut.h ) - optional_source(X11_FOUND + optional_source(HAVE_X11EXTRAS SOURCES globalshortcuts/globalshortcut-x11.cpp ) optional_source(HAVE_DBUS diff --git a/src/config.h.in b/src/config.h.in index 86cdafe7e..d0d6fecee 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -64,4 +64,8 @@ #cmakedefine INSTALL_TRANSLATIONS #define TRANSLATIONS_DIR "${CMAKE_INSTALL_PREFIX}/share/strawberry/translations" +#cmakedefine HAVE_X11EXTRAS +#cmakedefine HAVE_WINEXTRAS +#cmakedefine HAVE_QPA_QPLATFORMNATIVEINTERFACE_H + #endif // CONFIG_H_IN diff --git a/src/globalshortcuts/globalshortcuts.cpp b/src/globalshortcuts/globalshortcuts.cpp index f35e3cbf4..6eb34e10d 100644 --- a/src/globalshortcuts/globalshortcuts.cpp +++ b/src/globalshortcuts/globalshortcuts.cpp @@ -30,8 +30,8 @@ #ifdef HAVE_DBUS # include #endif -#ifdef HAVE_X11 -#include +#ifdef HAVE_X11EXTRAS +# include #endif #include "globalshortcuts.h" @@ -41,7 +41,7 @@ # include "globalshortcutbackend-gsd.h" # include "globalshortcutbackend-kde.h" #endif -#if defined(HAVE_X11) || defined(Q_OS_WIN) +#if defined(HAVE_X11EXTRAS) || defined(Q_OS_WIN) # include "globalshortcutbackend-system.h" #endif #ifdef Q_OS_MACOS @@ -97,7 +97,7 @@ GlobalShortcuts::GlobalShortcuts(QWidget *parent) if (!system_backend_) system_backend_ = new GlobalShortcutBackendSystem(this); #endif -#if defined(HAVE_X11) +#if defined(HAVE_X11EXTRAS) if (!system_backend_ && IsX11Available()) system_backend_ = new GlobalShortcutBackendSystem(this); #endif @@ -166,7 +166,7 @@ bool GlobalShortcuts::IsKdeAvailable() const { bool GlobalShortcuts::IsX11Available() const { -#ifdef HAVE_X11 +#ifdef HAVE_X11EXTRAS return QX11Info::isPlatformX11(); #else return false; @@ -178,12 +178,12 @@ void GlobalShortcuts::Register() { if (use_gsd_ && gsd_backend_ && gsd_backend_->Register()) return; if (use_kde_ && kde_backend_ && kde_backend_->Register()) return; -#ifdef HAVE_X11 // If this system has X11, only use the system backend if X11 is enabled in the global shortcut settings +#ifdef HAVE_X11EXTRAS // 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_X11 +#ifdef HAVE_X11EXTRAS } #endif diff --git a/src/osd/osdpretty.cpp b/src/osd/osdpretty.cpp index ff591f983..24b1088c1 100644 --- a/src/osd/osdpretty.cpp +++ b/src/osd/osdpretty.cpp @@ -53,10 +53,12 @@ #include #include #include -#ifdef HAVE_X11 +#ifdef HAVE_X11EXTRAS # include +#elif defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H) +# include #endif -#ifdef Q_OS_WIN +#ifdef HAVE_WINEXTRAS # include #endif @@ -214,10 +216,26 @@ void OSDPretty::ScreenRemoved(QScreen *screen) { } bool OSDPretty::IsTransparencyAvailable() { -#if defined(HAVE_X11) + +#if defined(HAVE_X11EXTRAS) return QX11Info::isCompositingManagerRunning(); +#elif 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; + } + else return false; + } + else return false; #endif + return true; + } void OSDPretty::Load() { @@ -433,10 +451,11 @@ void OSDPretty::Reposition() { setMask(mask); } -#ifdef Q_OS_WIN +#ifdef HAVE_WINEXTRAS // On windows, enable blurbehind on the masked area QtWin::enableBlurBehindWindow(this, QRegion(mask)); #endif + } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) diff --git a/src/osd/osdpretty.h b/src/osd/osdpretty.h index beceeecd8..c88123cf8 100644 --- a/src/osd/osdpretty.h +++ b/src/osd/osdpretty.h @@ -71,7 +71,7 @@ class OSDPretty : public QWidget { static const QRgb kPresetBlue; static const QRgb kPresetRed; - static bool IsTransparencyAvailable(); + bool IsTransparencyAvailable(); void SetMessage(const QString &summary, const QString& message, const QImage &image); void ShowMessage(const QString &summary, const QString& message, const QImage &image); diff --git a/src/settings/shortcutssettingspage.cpp b/src/settings/shortcutssettingspage.cpp index e4d323779..55901bbf4 100644 --- a/src/settings/shortcutssettingspage.cpp +++ b/src/settings/shortcutssettingspage.cpp @@ -77,7 +77,7 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog) connect(ui_->checkbox_kde, SIGNAL(clicked(bool)), SLOT(ShortcutOptionsChanged())); connect(ui_->button_gsd_open, SIGNAL(clicked()), SLOT(OpenGnomeKeybindingProperties())); # endif -# ifdef HAVE_X11 +# ifdef HAVE_X11EXTRAS connect(ui_->checkbox_x11, SIGNAL(clicked(bool)), SLOT(ShortcutOptionsChanged())); # endif #else