Make X11Extras and WinExtras optional

The initial release of Qt 6 does not have these.

These modules are not important.
X11Extras is only used for X11 global shortcuts, which in most cases is
overriden by KDE or Gnome shortcuts anyway.
It is also used in OSD Pretty to detect transparency, but this can be
done using private GUI headers instead.

WinExtras is only used in OSD Pretty to make it transparent.
This commit is contained in:
Jonas Kvinge 2020-11-29 07:41:30 +01:00
parent 0808db706f
commit fc02543f15
7 changed files with 59 additions and 19 deletions

View File

@ -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
)

View File

@ -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

View File

@ -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

View File

@ -30,8 +30,8 @@
#ifdef HAVE_DBUS
# include <QDBusConnectionInterface>
#endif
#ifdef HAVE_X11
#include <QX11Info>
#ifdef HAVE_X11EXTRAS
# include <QX11Info>
#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

View File

@ -53,10 +53,12 @@
#include <QSettings>
#include <QFlags>
#include <QtEvents>
#ifdef HAVE_X11
#ifdef HAVE_X11EXTRAS
# include <QX11Info>
#elif defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
# include <qpa/qplatformnativeinterface.h>
#endif
#ifdef Q_OS_WIN
#ifdef HAVE_WINEXTRAS
# include <QtWin>
#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)

View File

@ -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);

View File

@ -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