From d3135d4c1e5500429c7bbeb413954764c1e95b20 Mon Sep 17 00:00:00 2001 From: IoIxD Date: Sun, 26 Apr 2026 21:16:32 -0700 Subject: [PATCH] wayland: fix clipboard --- CMakeLists.txt | 62 ++++++++++++++++++++++++++++++++----------- src/backend/wayland.c | 5 ++++ 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6f823d..33722b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,17 +131,18 @@ if(MW_USE_STB_TRUETYPE) endif() if(MW_USE_FREETYPE2) - target_compile_definitions( + find_package(Freetype) + if(Freetype_FOUND) + target_compile_definitions( Mw PRIVATE USE_FREETYPE2 ) - find_package(PkgConfig) - pkg_check_modules(FT2 REQUIRED freetype2) - list(APPEND INCLUDE_DIRS ${FT2_INCLUDE_DIRS}) - list(APPEND LIBRARY_DIRS ${FT2_LIBRARY_DIRS}) - list(APPEND LIBRARIES ${FT2_LIBRARIES}) + list(APPEND INCLUDE_DIRS ${FT2_INCLUDE_DIRS}) + list(APPEND LIBRARY_DIRS ${FT2_LIBRARY_DIRS}) + list(APPEND LIBRARIES ${FT2_LIBRARIES}) + endif() endif() if(MW_USE_WAYLAND) @@ -197,6 +198,8 @@ if(MW_USE_WAYLAND) ) endfunction() + + check_include_files(wayland-client.h HAVE_WL_H) check_include_files(xkbcommon/xkbcommon.h HAVE_XKBCOMMON_H) check_include_files(cairo/cairo.h HAVE_CAIRO_H) @@ -318,27 +321,54 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Retro") ) else() find_package(PkgConfig) - pkg_check_modules(X11 REQUIRED x11) - pkg_check_modules(XRENDER REQUIRED xrender) + find_package(X11) + pkg_check_modules(DBUS dbus-1) target_sources( Mw PRIVATE src/backend/x11.c ) - target_compile_definitions( - Mw - PRIVATE - USE_X11 - ) - list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS} ${XRENDER_INCLUDE_DIRS}) - list(APPEND LIBRARY_DIRS ${X11_LIBRARY_DIRS} ${XRENDER_LIBRARY_DIRS}) - list(APPEND LIBRARIES ${X11_LIBRARIES} ${XRENDER_LIBRARIES} m) + + if(${X11_FOUND}) + list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS}) + list(APPEND LIBRARY_DIRS ${X11_LIBRARY_DIRS}) + list(APPEND LIBRARIES ${X11_LIBRARIES} m) + target_compile_definitions( + Mw + PRIVATE + USE_X11 + ) + endif() + if(${X11_Xrender_FOUND}) + list(APPEND INCLUDE_DIRS ${XRENDER_INCLUDE_DIRS}) + list(APPEND LIBRARY_DIRS ${XRENDER_LIBRARY_DIRS}) + list(APPEND LIBRARIES ${XRENDER_LIBRARIES} m) + target_compile_definitions( + Mw + PRIVATE + USE_XRENDER + ) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") list(APPEND LIBRARIES dl) endif() endif() +find_package(DBus1) + +if(${DBus1_FOUND}) + list(APPEND INCLUDE_DIRS ${DBUS_INCLUDE_DIRS}) + list(APPEND LIBRARY_DIRS ${DBUS_LIBRARY_DIRS}) + list(APPEND LIBRARIES ${DBUS_LIBRARIES}) + target_compile_definitions( + Mw + PRIVATE + USE_DBUS + ) +endif() + target_include_directories( Mw PRIVATE diff --git a/src/backend/wayland.c b/src/backend/wayland.c index 715a988..c3f5cbe 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -979,6 +979,11 @@ static void wl_seat_capabilities(void* data, struct wl_seat* wl_seat, wl_pointer_add_listener(self->wayland.pointer, &pointer_listener, data); } WAYLAND_EVENT_OP_END(self); + + if(self->wayland.clipboard_manager.wl) + setup_clipboard(self, self->wayland.pointer_seat); + if(self->wayland.clipboard_manager.zwp) + setup_zwp_clipboard(self, self->wayland.pointer_seat); }; static void output_geometry(void* data,