Skip to content

Commit

Permalink
Made X11 dependency optional
Browse files Browse the repository at this point in the history
  • Loading branch information
houmaster committed Jan 4, 2021
1 parent dd44ec2 commit 971796e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ if(NOT WIN32)
src/linux/client/ipc.h
src/linux/client/main.cpp
)
target_link_libraries(keymapper X11)

option(ENABLE_X11 "Enable X11 context awareness" TRUE)
if(ENABLE_X11)
add_compile_definitions(ENABLE_X11)
target_link_libraries(keymapper X11)
endif()

add_executable(keymapperd
${SOURCES_RUNTIME}
Expand All @@ -50,7 +55,8 @@ if(NOT WIN32)
src/linux/server/uinput_keyboard.h
)
target_link_libraries(keymapperd usb-1.0 udev)
else(NOT WIN32)

else() # WIN32
option(ENABLE_INTERCEPTION "Enable Interception" TRUE)
if(ENABLE_INTERCEPTION)
add_compile_definitions(ENABLE_INTERCEPTION)
Expand All @@ -73,7 +79,7 @@ else(NOT WIN32)
src/win32/run_interception.cpp
src/win32/win.h
)
endif(NOT WIN32)
endif()

option(ENABLE_TEST "Enable tests")
if(ENABLE_TEST)
Expand All @@ -89,11 +95,11 @@ if(ENABLE_TEST)
src/test/test3_Stage.cpp
src/test/test4_Fuzz.cpp
)
endif(ENABLE_TEST)
endif()

if(NOT WIN32)
install(TARGETS keymapper DESTINATION "bin")
install(TARGETS keymapperd DESTINATION "bin")
else(NOT WIN32)
else()
install(TARGETS keymapper DESTINATION .)
endif(NOT WIN32)
endif()
37 changes: 32 additions & 5 deletions src/linux/client/FocusedWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@

#include "FocusedWindow.h"
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>

#if defined(ENABLE_X11)

# include <X11/X.h>
# include <X11/Xlib.h>
# include <X11/Xatom.h>
# include <X11/Xutil.h>
# include <X11/Xos.h>

class FocusedWindow {
public:
Expand Down Expand Up @@ -125,3 +128,27 @@ const std::string& get_class(const FocusedWindow& window) {
const std::string& get_title(const FocusedWindow& window) {
return window.get_title();
}

#else // !ENABLE_X11

void FreeFocusedWindow::operator()(FocusedWindow*) {
}

FocusedWindowPtr create_focused_window() {
return nullptr;
}

bool update_focused_window(FocusedWindow&) {
return false;
}

const std::string& get_class(const FocusedWindow&) {
static std::string empty;
return empty;
}

const std::string& get_title(const FocusedWindow& window) {
return get_class(window);
}

#endif // !ENABLE_X11

0 comments on commit 971796e

Please sign in to comment.