This commit is contained in:
IoI_xD 2026-03-24 23:44:30 -07:00
commit f4e2ec8fa9
3 changed files with 22 additions and 8 deletions

View file

@ -285,6 +285,7 @@ MwInline int wayland_load_funcs() {
#include "Wayland/xdg-decoration-client-protocol.h"
#include "Wayland/cursor-shape-client-protocol.h"
#include "Wayland/primary-selection-client-protocol.h"
#include "Wayland/pointer-constraints-client-protocol.h"
#include "Wayland/xdg-toplevel-icon-client-protocol.h"
#endif
@ -418,6 +419,9 @@ struct _MwLLWayland {
struct wp_viewport* vp;
struct zwp_pointer_constraints_v1* pointer_constraints;
struct zwp_locked_pointer_v1* locked_pointer;
/* clipboard related stuff.
* Note that unlike most interfaces, we don't keep zwp_primary_selection stuff in a wayland_protocol_t because we use wl_data_device as a fallback and want to have it share memory space.*/

View file

@ -42,6 +42,7 @@ if (grep(/^wayland$/, @backends)) {
scan_wayland_protocol("staging", "cursor-shape", "-v1");
scan_wayland_protocol("unstable", "xdg-decoration", "-unstable-v1");
scan_wayland_protocol("unstable", "primary-selection", "-unstable-v1");
scan_wayland_protocol("unstable", "pointer-constraints", "-unstable-v1");
$gl_libs = "-lGL -lGLU";
}

View file

@ -5,11 +5,6 @@
#include "../../external/stb_ds.h"
/* TODO:
* - MwLLMakePopupImpl
* - MwLLShowImpl
*/
/* TODO: find out what FreeBSD and such wants us to include */
#ifdef __FreeBSD__
/* XXX: Untested (nishi) */
@ -450,6 +445,17 @@ static void zwp_primary_selection_device_manager_v1_interface_destroy(struct _Mw
(void)data;
}
/* zwp_primary_selection_device_manager_v1 setup function */
static wayland_protocol_t* zwp_pointer_constraints_v1_setup(MwU32 name, struct _MwLLWayland* wayland) {
wayland->pointer_constraints = wl_registry_bind(wayland->registry, name, &zwp_pointer_constraints_v1_interface, 1);
return NULL;
}
static void zwp_pointer_constraints_v1_interface_destroy(struct _MwLLWayland* wayland, wayland_protocol_t* data) {
(void)wayland;
(void)data;
}
static struct wl_surface* curSurface;
/* `wl_pointer.enter` callback */
@ -1329,6 +1335,7 @@ static void setup_callbacks(struct _MwLLWayland* wayland) {
WL_INTERFACE(wl_output);
WL_INTERFACE(wl_data_device_manager);
WL_INTERFACE(zwp_primary_selection_device_manager_v1);
WL_INTERFACE(zwp_pointer_constraints_v1);
if(wayland->type == MWLL_WAYLAND_TOPLEVEL) {
WL_INTERFACE(xdg_wm_base);
WL_INTERFACE(wp_viewporter);
@ -2275,9 +2282,11 @@ static void MwLLFocusImpl(MwLL handle) {
}
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
(void)handle;
(void)toggle;
printf("[WARNING] MwLLGrabPointer not supported on Wayland\n");
if(handle->wayland.pointer_constraints) {
handle->wayland.locked_pointer = zwp_pointer_constraints_v1_lock_pointer(handle->wayland.pointer_constraints, handle->wayland.framebuffer.surface, handle->wayland.pointer, handle->wayland.region, ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
} else {
printf("[WARNING] MwLLGrabPointer not supported in Wayland session, zwp_pointer_constraints_v1 required.\n");
}
}
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {