fix submenus
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
IoIxD 2026-09-13 00:17:18 -07:00
commit d98d2e15ce
4 changed files with 66 additions and 75 deletions

View file

@ -239,8 +239,9 @@ struct _MwLLWaylandTopLevel {
}; };
struct _MwLLWaylandSublevel { struct _MwLLWaylandSublevel {
MwLL parent; MwLL parent;
struct wl_subcompositor* subcompositor;
struct wl_subsurface* subsurface;
struct xdg_surface* xdg_surface; struct xdg_surface* xdg_surface;
}; };

View file

@ -587,7 +587,7 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time
p.point = self->wayland.cur_mouse_pos; p.point = self->wayland.cur_mouse_pos;
MwLLDispatch(self, move, &p); MwLLDispatch(self, move, &p);
wl_pointer_set_cursor(self->wayland.pointer, self->wayland.pointer_serial, self->wayland.cursor.surface, 0, 0); wl_pointer_set_cursor(self->wayland.pointer, self->wayland.pointer_serial, self->wayland.cursor.surface, 0, 0);
}
for(i = 0; i < arrlen(currentlyHeldWidgets); i++) { for(i = 0; i < arrlen(currentlyHeldWidgets); i++) {
MwLL new_topmost = currentlyHeldWidgets[i]; MwLL new_topmost = currentlyHeldWidgets[i];
p.point = topmost_parent->wayland.cur_mouse_pos; p.point = topmost_parent->wayland.cur_mouse_pos;
@ -599,8 +599,8 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time
MwLLDispatch(currentlyHeldWidgets[i], move, &p); MwLLDispatch(currentlyHeldWidgets[i], move, &p);
} }
MwLLWaylandCascadeChildren(self); MwLLWaylandCascadeChildren(self);
}
WAYLAND_EVENT_OP_END(self); WAYLAND_EVENT_OP_END(self);
}; };
@ -704,6 +704,7 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
MwMouse p; MwMouse p;
MwLL topmost_parent = self; MwLL topmost_parent = self;
int i; int i;
MwBool inArea = MwFALSE;
(void)wl_pointer; (void)wl_pointer;
(void)serial; (void)serial;
@ -711,10 +712,19 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
WAYLAND_EVENT_OP_START(self); WAYLAND_EVENT_OP_START(self);
if(self->wayland.type != MwLL_WAYLAND_POPUP) {
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent; while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
}
p.point = self->wayland.cur_mouse_pos; p.point = self->wayland.cur_mouse_pos;
if(self->wayland.framebuffer.surface) {
inArea |= self->wayland.framebuffer.surface == curSurface;
}
if(self->wayland.backbuffer.surface) {
inArea |= self->wayland.backbuffer.surface == curSurface;
}
if(inArea) {
switch(button) { switch(button) {
case BTN_LEFT: case BTN_LEFT:
p.button = MwMOUSE_LEFT; p.button = MwMOUSE_LEFT;
@ -727,14 +737,14 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
break; break;
} }
self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED; self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED;
switch(state) { // switch(state) {
case WL_POINTER_BUTTON_STATE_PRESSED: // case WL_POINTER_BUTTON_STATE_PRESSED:
MwLLDispatch(self, down, &p); // MwLLDispatch(self, down, &p);
break; // break;
case WL_POINTER_BUTTON_STATE_RELEASED: // case WL_POINTER_BUTTON_STATE_RELEASED:
MwLLDispatch(self, up, &p); // MwLLDispatch(self, up, &p);
break; // break;
} // }
for(i = 0; i < arrlen(self->wayland.currentlyHeldWidgets); i++) { for(i = 0; i < arrlen(self->wayland.currentlyHeldWidgets); i++) {
arrdel(self->wayland.currentlyHeldWidgets, i); arrdel(self->wayland.currentlyHeldWidgets, i);
@ -749,7 +759,7 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
} }
MwLLForceRender(self); MwLLForceRender(self);
}
WAYLAND_EVENT_OP_END(self); WAYLAND_EVENT_OP_END(self);
}; };
@ -1169,7 +1179,7 @@ static wayland_protocol_t* wl_subcompositor_setup(MwU32 name, struct _MwLLWaylan
if(wayland->type == MwLL_WAYLAND_TOPLEVEL) { if(wayland->type == MwLL_WAYLAND_TOPLEVEL) {
wayland->toplevel->scompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1); wayland->toplevel->scompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1);
} else { } else {
// wayland->sublevel->subcompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1); wayland->sublevel->subcompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1);
} }
return NULL; return NULL;
@ -1180,7 +1190,7 @@ static void wl_subcompositor_interface_destroy(struct _MwLLWayland* wayland, way
if(wayland->type == MwLL_WAYLAND_TOPLEVEL) { if(wayland->type == MwLL_WAYLAND_TOPLEVEL) {
wl_subcompositor_destroy(wayland->toplevel->scompositor); wl_subcompositor_destroy(wayland->toplevel->scompositor);
} else { } else {
// wl_subcompositor_destroy(wayland->sublevel->subcompositor); wl_subcompositor_destroy(wayland->sublevel->subcompositor);
} }
} }
@ -1218,24 +1228,6 @@ static void wp_viewporter_interface_destroy(struct _MwLLWayland* wayland, waylan
(void)data; (void)data;
} }
/* wp_fifo_manager_v1 setup function */
static wayland_protocol_t* wp_fifo_manager_v1_setup(MwU32 name, struct _MwLLWayland* wayland, MwU32 version) {
wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t));
(void)version;
proto->listener = NULL;
proto->context = wl_registry_bind(wayland->registry, name, &wp_fifo_manager_v1_interface, 1);
return proto;
}
static void wp_fifo_manager_v1_interface_destroy(struct _MwLLWayland* wayland, wayland_protocol_t* data) {
(void)wayland;
if(data->context) {
wp_fifo_manager_v1_destroy(data->context);
}
free(data);
}
/* zxdg_decoration_manager_v1 setup function */ /* zxdg_decoration_manager_v1 setup function */
static wayland_protocol_t* zxdg_decoration_manager_v1_setup(MwU32 name, struct _MwLLWayland* wayland, MwU32 version) { static wayland_protocol_t* zxdg_decoration_manager_v1_setup(MwU32 name, struct _MwLLWayland* wayland, MwU32 version) {
wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t)); wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t));
@ -1338,7 +1330,6 @@ void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland) {
WL_INTERFACE(zwp_pointer_constraints_v1); WL_INTERFACE(zwp_pointer_constraints_v1);
WL_INTERFACE(zwp_relative_pointer_manager_v1); WL_INTERFACE(zwp_relative_pointer_manager_v1);
WL_INTERFACE(xdg_wm_base); WL_INTERFACE(xdg_wm_base);
WL_INTERFACE(wp_fifo_manager_v1);
WL_INTERFACE(zwlr_layer_shell_v1); /* Only used for layer surface, but we use it always if it's turned into a tool window */ WL_INTERFACE(zwlr_layer_shell_v1); /* Only used for layer surface, but we use it always if it's turned into a tool window */
if(wayland->type == MwLL_WAYLAND_TOPLEVEL) { if(wayland->type == MwLL_WAYLAND_TOPLEVEL) {
WL_INTERFACE(wp_viewporter); WL_INTERFACE(wp_viewporter);
@ -1352,7 +1343,6 @@ void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland) {
WL_INTERFACE(wp_viewporter); WL_INTERFACE(wp_viewporter);
WL_INTERFACE(wl_subcompositor); WL_INTERFACE(wl_subcompositor);
WL_INTERFACE(wl_seat); WL_INTERFACE(wl_seat);
WL_INTERFACE(wl_seat);
} else { } else {
WL_INTERFACE(wl_subcompositor); WL_INTERFACE(wl_subcompositor);
} }

View file

@ -417,8 +417,10 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) {
if(parent->wayland.type == MwLL_WAYLAND_TOPLEVEL) { if(parent->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
r->wayland.sublevel->xdg_surface = parent->wayland.toplevel->xdg_surface; r->wayland.sublevel->xdg_surface = parent->wayland.toplevel->xdg_surface;
} else { } else if(parent->wayland.type == MwLL_WAYLAND_SUBLEVEL) {
r->wayland.sublevel->xdg_surface = parent->wayland.sublevel->xdg_surface; r->wayland.sublevel->xdg_surface = parent->wayland.sublevel->xdg_surface;
} else if(parent->wayland.type == MwLL_WAYLAND_POPUP) {
r->wayland.sublevel->xdg_surface = parent->wayland.popup->xdg_surface;
} }
wl_registry_add_listener(r->wayland.registry, &r->wayland.registry_listener, r); wl_registry_add_listener(r->wayland.registry, &r->wayland.registry_listener, r);
@ -427,9 +429,7 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) {
raise(SIGTRAP); raise(SIGTRAP);
return; return;
} }
r->wayland.framebuffer.surface = wl_compositor_create_surface(compositor); r->wayland.framebuffer.surface = wl_compositor_create_surface(compositor);
MwLLWaylandFifoSurfaceSetup(&r->wayland, &r->wayland.framebuffer);
r->wayland.xkb_keymap = parent->wayland.xkb_keymap; r->wayland.xkb_keymap = parent->wayland.xkb_keymap;
r->wayland.xkb_state = parent->wayland.xkb_state; r->wayland.xkb_state = parent->wayland.xkb_state;
@ -542,10 +542,10 @@ static void setup_popup(MwLL r, int x, int y, MwLL parent) {
xdg_positioner_set_size(r->wayland.popup->xdg_positioner, r->wayland.ww, r->wayland.wh); xdg_positioner_set_size(r->wayland.popup->xdg_positioner, r->wayland.ww, r->wayland.wh);
xdg_positioner_set_anchor_rect( xdg_positioner_set_anchor_rect(
r->wayland.popup->xdg_positioner, r->wayland.popup->xdg_positioner,
r->wayland.x, r->wayland.y, r->wayland.ww, r->wayland.wh); topmost_parent->wayland.x, topmost_parent->wayland.y, r->wayland.ww, r->wayland.wh);
// xdg_positioner_set_offset( xdg_positioner_set_offset(
// r->wayland.popup->xdg_positioner, r->wayland.popup->xdg_positioner,
// r->wayland.x, r->wayland.y); r->wayland.x, r->wayland.y);
xdg_positioner_set_anchor(r->wayland.popup->xdg_positioner, XDG_POSITIONER_ANCHOR_NONE); xdg_positioner_set_anchor(r->wayland.popup->xdg_positioner, XDG_POSITIONER_ANCHOR_NONE);
xdg_positioner_set_gravity(r->wayland.popup->xdg_positioner, XDG_POSITIONER_GRAVITY_NONE); xdg_positioner_set_gravity(r->wayland.popup->xdg_positioner, XDG_POSITIONER_GRAVITY_NONE);