Compare commits

...

2 commits

Author SHA1 Message Date
c7d9a2e6cc Wayland: fix input region
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-04-26 21:22:27 -07:00
d3135d4c1e wayland: fix clipboard 2026-04-26 21:22:27 -07:00
2 changed files with 54 additions and 30 deletions

View file

@ -131,18 +131,19 @@ if(MW_USE_STB_TRUETYPE)
endif() endif()
if(MW_USE_FREETYPE2) if(MW_USE_FREETYPE2)
find_package(Freetype)
if(Freetype_FOUND)
target_compile_definitions( target_compile_definitions(
Mw Mw
PRIVATE PRIVATE
USE_FREETYPE2 USE_FREETYPE2
) )
find_package(PkgConfig)
pkg_check_modules(FT2 REQUIRED freetype2)
list(APPEND INCLUDE_DIRS ${FT2_INCLUDE_DIRS}) list(APPEND INCLUDE_DIRS ${FT2_INCLUDE_DIRS})
list(APPEND LIBRARY_DIRS ${FT2_LIBRARY_DIRS}) list(APPEND LIBRARY_DIRS ${FT2_LIBRARY_DIRS})
list(APPEND LIBRARIES ${FT2_LIBRARIES}) list(APPEND LIBRARIES ${FT2_LIBRARIES})
endif() endif()
endif()
if(MW_USE_WAYLAND) if(MW_USE_WAYLAND)
function(scan_wayland_protocol_core) function(scan_wayland_protocol_core)
@ -197,6 +198,8 @@ if(MW_USE_WAYLAND)
) )
endfunction() endfunction()
check_include_files(wayland-client.h HAVE_WL_H) check_include_files(wayland-client.h HAVE_WL_H)
check_include_files(xkbcommon/xkbcommon.h HAVE_XKBCOMMON_H) check_include_files(xkbcommon/xkbcommon.h HAVE_XKBCOMMON_H)
check_include_files(cairo/cairo.h HAVE_CAIRO_H) check_include_files(cairo/cairo.h HAVE_CAIRO_H)
@ -318,27 +321,54 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Retro")
) )
else() else()
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(X11 REQUIRED x11) find_package(X11)
pkg_check_modules(XRENDER REQUIRED xrender) pkg_check_modules(DBUS dbus-1)
target_sources( target_sources(
Mw Mw
PRIVATE PRIVATE
src/backend/x11.c src/backend/x11.c
) )
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( target_compile_definitions(
Mw Mw
PRIVATE PRIVATE
USE_X11 USE_X11
) )
list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS} ${XRENDER_INCLUDE_DIRS}) endif()
list(APPEND LIBRARY_DIRS ${X11_LIBRARY_DIRS} ${XRENDER_LIBRARY_DIRS}) if(${X11_Xrender_FOUND})
list(APPEND LIBRARIES ${X11_LIBRARIES} ${XRENDER_LIBRARIES} m) 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") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND LIBRARIES dl) list(APPEND LIBRARIES dl)
endif() endif()
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( target_include_directories(
Mw Mw
PRIVATE PRIVATE

View file

@ -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); wl_pointer_add_listener(self->wayland.pointer, &pointer_listener, data);
} }
WAYLAND_EVENT_OP_END(self); 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, static void output_geometry(void* data,
@ -1435,20 +1440,9 @@ static void region_setup(MwLL handle) {
if(handle->wayland.type == MwLL_WAYLAND_POPUP) { if(handle->wayland.type == MwLL_WAYLAND_POPUP) {
wl_region_add(handle->wayland.region, 0, 0, width + abs(handle->wayland.x), height + abs(handle->wayland.y)); wl_region_add(handle->wayland.region, 0, 0, width + abs(handle->wayland.x), height + abs(handle->wayland.y));
} else { } else {
if(parent) { wl_region_subtract(handle->wayland.region, 0, 0, width + abs(handle->wayland.x), height + abs(handle->wayland.y));
if(width - handle->wayland.x > parent->wayland.ww) { wl_region_add(handle->wayland.region, handle->wayland.clipping_rect.x, handle->wayland.clipping_rect.y, handle->wayland.clipping_rect.width, handle->wayland.clipping_rect.height);
width = parent->wayland.ww - handle->wayland.x; // wl_region_add(handle->wayland.region, 0, 0, width, height);
}
if(height - handle->wayland.y > parent->wayland.wh) {
height = parent->wayland.wh - handle->wayland.y;
}
} else {
if(!handle->wayland.has_decorations) {
width += CSD_BORDER_FRAME_LEFT + CSD_BORDER_FRAME_RIGHT;
height += CSD_BORDER_FRAME_TOP + CSD_BORDER_FRAME_BOTTOM;
}
}
wl_region_add(handle->wayland.region, 0, 0, width, height);
} }
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) { if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {