diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,11 @@ include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) +include(CheckIncludeFile) + +check_include_file("linux/input.h" HAVE_LINUX_INPUT_H) +configure_file(config-kwayland.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwayland.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # adjusting CMAKE_C_FLAGS to get wayland protocols to compile set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90") diff --git a/autotests/client/CMakeLists.txt b/autotests/client/CMakeLists.txt --- a/autotests/client/CMakeLists.txt +++ b/autotests/client/CMakeLists.txt @@ -69,13 +69,15 @@ ######################################################## # Test WaylandSeat ######################################################## -set( testWaylandSeat_SRCS - test_wayland_seat.cpp - ) -add_executable(testWaylandSeat ${testWaylandSeat_SRCS}) -target_link_libraries( testWaylandSeat Qt5::Test Qt5::Gui KF5::WaylandClient KF5::WaylandServer Wayland::Client Wayland::Server) -add_test(kwayland-testWaylandSeat testWaylandSeat) -ecm_mark_as_test(testWaylandSeat) +if (HAVE_LINUX_INPUT_H) + set( testWaylandSeat_SRCS + test_wayland_seat.cpp + ) + add_executable(testWaylandSeat ${testWaylandSeat_SRCS}) + target_link_libraries( testWaylandSeat Qt5::Test Qt5::Gui KF5::WaylandClient KF5::WaylandServer Wayland::Client Wayland::Server) + add_test(kwayland-testWaylandSeat testWaylandSeat) + ecm_mark_as_test(testWaylandSeat) +endif() ######################################################## # Test ShmPool @@ -279,24 +281,28 @@ ######################################################## # Test FakeInput ######################################################## -set( testFakeInput_SRCS - test_fake_input.cpp - ) -add_executable(testFakeInput ${testFakeInput_SRCS}) -target_link_libraries( testFakeInput Qt5::Test Qt5::Gui KF5::WaylandClient KF5::WaylandServer) -add_test(kwayland-testFakeInput testFakeInput) -ecm_mark_as_test(testFakeInput) +if (HAVE_LINUX_INPUT_H) + set( testFakeInput_SRCS + test_fake_input.cpp + ) + add_executable(testFakeInput ${testFakeInput_SRCS}) + target_link_libraries( testFakeInput Qt5::Test Qt5::Gui KF5::WaylandClient KF5::WaylandServer) + add_test(kwayland-testFakeInput testFakeInput) + ecm_mark_as_test(testFakeInput) +endif() ######################################################## # Test PlasmaWindowModel ######################################################## -set( testPlasmaWindowModel_SRCS - test_plasma_window_model.cpp - ) -add_executable(testPlasmaWindowModel ${testPlasmaWindowModel_SRCS}) -target_link_libraries( testPlasmaWindowModel Qt5::Test Qt5::Gui KF5::WaylandClient KF5::WaylandServer) -add_test(kwayland-testPlasmaWindowModel testPlasmaWindowModel) -ecm_mark_as_test(testPlasmaWindowModel) +if (HAVE_LINUX_INPUT_H) + set( testPlasmaWindowModel_SRCS + test_plasma_window_model.cpp + ) + add_executable(testPlasmaWindowModel ${testPlasmaWindowModel_SRCS}) + target_link_libraries( testPlasmaWindowModel Qt5::Test Qt5::Gui KF5::WaylandClient KF5::WaylandServer) + add_test(kwayland-testPlasmaWindowModel testPlasmaWindowModel) + ecm_mark_as_test(testPlasmaWindowModel) +endif() ######################################################## # Test TextInput diff --git a/config-kwayland.h.cmake b/config-kwayland.h.cmake new file mode 100644 --- /dev/null +++ b/config-kwayland.h.cmake @@ -0,0 +1 @@ +#cmakedefine01 HAVE_LINUX_INPUT_H diff --git a/src/client/fakeinput.cpp b/src/client/fakeinput.cpp --- a/src/client/fakeinput.cpp +++ b/src/client/fakeinput.cpp @@ -24,7 +24,10 @@ #include #include +#include +#if HAVE_LINUX_INPUT_H #include +#endif #include @@ -99,6 +102,7 @@ void FakeInput::Private::sendPointerButtonState(Qt::MouseButton button, quint32 state) { +#if HAVE_LINUX_INPUT_H Q_ASSERT(manager.isValid()); uint32_t b = 0; switch (button) { @@ -117,6 +121,7 @@ return; } org_kde_kwin_fake_input_button(manager, b, state); +#endif } void FakeInput::requestPointerButtonPress(Qt::MouseButton button) diff --git a/src/server/seat_interface.cpp b/src/server/seat_interface.cpp --- a/src/server/seat_interface.cpp +++ b/src/server/seat_interface.cpp @@ -33,7 +33,10 @@ #define WL_SEAT_NAME_SINCE_VERSION 2 #endif // linux +#include +#if HAVE_LINUX_INPUT_H #include +#endif namespace KWayland { @@ -682,6 +685,7 @@ namespace { static quint32 qtToWaylandButton(Qt::MouseButton button) { +#if HAVE_LINUX_INPUT_H static const QHash s_buttons({ {Qt::LeftButton, BTN_LEFT}, {Qt::RightButton, BTN_RIGHT}, @@ -702,6 +706,9 @@ // further mapping not possible, 0x120 is BTN_JOYSTICK }); return s_buttons.value(button, 0); +#else + return 0; +#endif } } @@ -1075,6 +1082,7 @@ if (d->touchInterface.focus.touch && d->touchInterface.focus.surface) { d->touchInterface.focus.touch->down(id, serial, globalPosition - d->touchInterface.focus.offset); } else if (id == 0 && focusedTouchSurface()) { +#if HAVE_LINUX_INPUT_H auto p = d->pointerForSurface(focusedTouchSurface()); if (!p) { return id; @@ -1087,6 +1095,7 @@ wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y())); wl_pointer_send_button(p->resource(), serial, timestamp(), BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); +#endif } d->touchInterface.ids << id; @@ -1117,13 +1126,15 @@ if (d->touchInterface.focus.touch && d->touchInterface.focus.surface) { d->touchInterface.focus.touch->up(id, display()->nextSerial()); } else if (id == 0 && focusedTouchSurface()) { +#if HAVE_LINUX_INPUT_H const quint32 serial = display()->nextSerial(); auto p = d->pointerForSurface(focusedTouchSurface()); if (!p) { return; } wl_pointer_send_button(p->resource(), serial, timestamp(), BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED); +#endif } d->touchInterface.ids.removeAll(id); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -30,32 +30,35 @@ ecm_mark_as_test(pasteClient) endif() -add_executable(touchClientTest touchclienttest.cpp) -target_link_libraries(touchClientTest KF5::WaylandClient) +if (HAVE_LINUX_INPUT_H) + add_executable(touchClientTest touchclienttest.cpp) + target_link_libraries(touchClientTest KF5::WaylandClient) -add_executable(panelTest paneltest.cpp) -target_link_libraries(panelTest KF5::WaylandClient) -ecm_mark_as_test(panelTest) + add_executable(panelTest paneltest.cpp) + target_link_libraries(panelTest KF5::WaylandClient) + ecm_mark_as_test(panelTest) + + add_executable(qtwayland-integration-test qtwaylandintegrationtest.cpp) + target_link_libraries(qtwayland-integration-test Qt5::Core Qt5::Gui KF5::WaylandClient) + ecm_mark_as_test(qtwayland-integration-test) + + add_executable(subsurface-test subsurfacetest.cpp) + target_link_libraries(subsurface-test Qt5::Core Qt5::Gui KF5::WaylandClient) + ecm_mark_as_test(subsurface-test) +endif() add_executable(shadowTest shadowtest.cpp) target_link_libraries(shadowTest KF5::WaylandClient) ecm_mark_as_test(shadowTest) -add_executable(qtwayland-integration-test qtwaylandintegrationtest.cpp) -target_link_libraries(qtwayland-integration-test Qt5::Core Qt5::Gui KF5::WaylandClient) -ecm_mark_as_test(qtwayland-integration-test) if (Qt5Widgets_FOUND) add_executable(dpmsTest dpmstest.cpp) target_link_libraries(dpmsTest KF5::WaylandClient Qt5::Widgets) ecm_mark_as_test(dpmsTest) endif() -add_executable(subsurface-test subsurfacetest.cpp) -target_link_libraries(subsurface-test Qt5::Core Qt5::Gui KF5::WaylandClient) -ecm_mark_as_test(subsurface-test) - add_executable(plasmasurface-test plasmasurfacetest.cpp) target_link_libraries(plasmasurface-test Qt5::Gui KF5::WaylandClient) ecm_mark_as_test(plasmasurface-test)