Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav Isakov <yaroslav.isakov@gmail.com>2022-07-02 05:21:57 +0300
committerJonathan White <support@dmapps.us>2022-09-22 13:49:07 +0300
commit28328a708073ee7b26d0c21f33f4f6d285df91af (patch)
treef19a1b35a3a43602cbdd2f67261cb960f4751c82
parentfab76c04cc5858652a9df1af8b3e7ec34b7d08a5 (diff)
Allow KeePassXC to be built without X11
-rw-r--r--CMakeLists.txt12
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/gui/osutils/nixutils/NixUtils.cpp28
3 files changed, 46 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 717214c51..4ccff9149 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,6 +62,8 @@ if(UNIX AND NOT APPLE)
endif()
option(WITH_XC_DOCS "Enable building of documentation" ON)
+set(WITH_XC_X11 ON CACHE BOOL "Enable building with X11 deps")
+
if(APPLE)
# Perform the platform checks before applying the stricter compiler flags.
# Otherwise the kSecAccessControlTouchIDCurrentSet deprecation warning will result in an error.
@@ -110,6 +112,11 @@ if(NOT WITH_XC_NETWORKING AND WITH_XC_UPDATECHECK)
set(WITH_XC_UPDATECHECK OFF)
endif()
+if(UNIX AND NOT APPLE AND NOT WITH_XC_X11)
+ message(STATUS "Disabling WITH_XC_AUTOTYPE because WITH_XC_X11 is disabled")
+ set(WITH_XC_AUTOTYPE OFF)
+endif()
+
set(KEEPASSXC_VERSION_MAJOR "2")
set(KEEPASSXC_VERSION_MINOR "7")
set(KEEPASSXC_VERSION_PATCH "1")
@@ -466,7 +473,10 @@ include(CLangFormat)
set(QT_COMPONENTS Core Network Concurrent Gui Svg Widgets Test LinguistTools)
if(UNIX AND NOT APPLE)
- find_package(Qt5 COMPONENTS ${QT_COMPONENTS} DBus X11Extras REQUIRED)
+ if(WITH_XC_X11)
+ list(APPEND QT_COMPONENTS X11Extras)
+ endif()
+ find_package(Qt5 COMPONENTS ${QT_COMPONENTS} DBus REQUIRED)
elseif(APPLE)
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED HINTS
/usr/local/opt/qt/lib/cmake
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c3f83d54c..4cf802f30 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -206,8 +206,11 @@ if(UNIX AND NOT APPLE)
set(keepassx_SOURCES
${keepassx_SOURCES}
gui/osutils/nixutils/ScreenLockListenerDBus.cpp
- gui/osutils/nixutils/NixUtils.cpp
+ gui/osutils/nixutils/NixUtils.cpp)
+ if(WITH_XC_X11)
+ list(APPEND keepassx_SOURCES
gui/osutils/nixutils/X11Funcs.cpp)
+ endif()
qt5_add_dbus_adaptor(keepassx_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h
@@ -359,7 +362,10 @@ if(HAIKU)
target_link_libraries(keepassx_core network)
endif()
if(UNIX AND NOT APPLE)
- target_link_libraries(keepassx_core Qt5::DBus Qt5::X11Extras X11)
+ target_link_libraries(keepassx_core Qt5::DBus)
+ if(WITH_XC_X11)
+ target_link_libraries(keepassx_core Qt5::X11Extras X11)
+ endif()
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
if(WIN32)
diff --git a/src/gui/osutils/nixutils/NixUtils.cpp b/src/gui/osutils/nixutils/NixUtils.cpp
index ba44cd273..d96a19bef 100644
--- a/src/gui/osutils/nixutils/NixUtils.cpp
+++ b/src/gui/osutils/nixutils/NixUtils.cpp
@@ -24,6 +24,7 @@
#include <QStandardPaths>
#include <QStyle>
#include <QTextStream>
+#ifdef WITH_XC_AUTOTYPE
#include <QX11Info>
#include <qpa/qplatformnativeinterface.h>
@@ -44,6 +45,7 @@ namespace
return 1;
}
} // namespace
+#endif
QPointer<NixUtils> NixUtils::m_instance = nullptr;
@@ -59,8 +61,10 @@ NixUtils* NixUtils::instance()
NixUtils::NixUtils(QObject* parent)
: OSUtilsBase(parent)
{
+#ifdef WITH_XC_X11
dpy = QX11Info::display();
rootWindow = QX11Info::appRootWindow();
+#endif
// notify about system color scheme changes
QDBusConnection sessionBus = QDBusConnection::sessionBus();
@@ -157,6 +161,7 @@ void NixUtils::setLaunchAtStartup(bool enable)
bool NixUtils::isCapslockEnabled()
{
+#ifdef WITH_XC_X11
QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface();
auto* display = native->nativeResourceForWindow("display", nullptr);
if (!display) {
@@ -170,6 +175,7 @@ bool NixUtils::isCapslockEnabled()
return ((state & 1u) != 0);
}
}
+#endif
// TODO: Wayland
@@ -183,6 +189,7 @@ void NixUtils::registerNativeEventFilter()
bool NixUtils::nativeEventFilter(const QByteArray& eventType, void* message, long*)
{
+#ifdef WITH_XC_X11
if (eventType != QByteArrayLiteral("xcb_generic_event_t")) {
return false;
}
@@ -195,12 +202,16 @@ bool NixUtils::nativeEventFilter(const QByteArray& eventType, void* message, lon
auto modifierMask = ControlMask | ShiftMask | Mod1Mask | Mod4Mask;
return triggerGlobalShortcut(keyPressEvent->detail, keyPressEvent->state & modifierMask);
}
-
+#else
+ Q_UNUSED(eventType)
+ Q_UNUSED(message)
+#endif
return false;
}
bool NixUtils::triggerGlobalShortcut(uint keycode, uint modifiers)
{
+#ifdef WITH_XC_X11
QHashIterator<QString, QSharedPointer<globalShortcut>> i(m_globalShortcuts);
while (i.hasNext()) {
i.next();
@@ -209,11 +220,16 @@ bool NixUtils::triggerGlobalShortcut(uint keycode, uint modifiers)
return true;
}
}
+#else
+ Q_UNUSED(keycode)
+ Q_UNUSED(modifiers)
+#endif
return false;
}
bool NixUtils::registerGlobalShortcut(const QString& name, Qt::Key key, Qt::KeyboardModifiers modifiers, QString* error)
{
+#ifdef WITH_XC_X11
auto keycode = XKeysymToKeycode(dpy, qcharToNativeKeyCode(key));
auto modifierscode = qtToNativeModifiers(modifiers);
@@ -254,11 +270,18 @@ bool NixUtils::registerGlobalShortcut(const QString& name, Qt::Key key, Qt::Keyb
gs->nativeKeyCode = keycode;
gs->nativeModifiers = modifierscode;
m_globalShortcuts.insert(name, gs);
+#else
+ Q_UNUSED(name)
+ Q_UNUSED(key)
+ Q_UNUSED(modifiers)
+ Q_UNUSED(error)
+#endif
return true;
}
bool NixUtils::unregisterGlobalShortcut(const QString& name)
{
+#ifdef WITH_XC_X11
if (!m_globalShortcuts.contains(name)) {
return false;
}
@@ -270,6 +293,9 @@ bool NixUtils::unregisterGlobalShortcut(const QString& name)
XUngrabKey(dpy, gs->nativeKeyCode, gs->nativeModifiers | Mod2Mask | LockMask, rootWindow);
m_globalShortcuts.remove(name);
+#else
+ Q_UNUSED(name)
+#endif
return true;
}