diff --git a/include/Mw/LowLevel/Wayland.h b/include/Mw/LowLevel/Wayland.h index 5e43c34..234e3e8 100644 --- a/include/Mw/LowLevel/Wayland.h +++ b/include/Mw/LowLevel/Wayland.h @@ -239,8 +239,9 @@ struct _MwLLWaylandTopLevel { }; struct _MwLLWaylandSublevel { - - MwLL parent; + MwLL parent; + struct wl_subcompositor* subcompositor; + struct wl_subsurface* subsurface; struct xdg_surface* xdg_surface; }; diff --git a/pl/rules.pl b/pl/rules.pl index 0fe264c..afc9ef9 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -66,7 +66,7 @@ if (grep(/^wayland$/, @backends)) { scan_wayland_protocol("unstable", "primary-selection", "-unstable-v1"); scan_wayland_protocol("unstable", "pointer-constraints", "-unstable-v1"); scan_wayland_protocol("unstable", "relative-pointer", "-unstable-v1"); - scan_wayland_protocol("staging", "fifo", "-v1"); + scan_wayland_protocol("staging", "fifo", "-v1"); scan_wayland_protocol_from_file("wlr-layer-shell", "wlr-layer-shell-unstable-v1.xml"); diff --git a/src/backend/wayland/interfaces.c b/src/backend/wayland/interfaces.c index 9ce4261..a69ad1b 100644 --- a/src/backend/wayland/interfaces.c +++ b/src/backend/wayland/interfaces.c @@ -587,21 +587,21 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time p.point = self->wayland.cur_mouse_pos; MwLLDispatch(self, move, &p); wl_pointer_set_cursor(self->wayland.pointer, self->wayland.pointer_serial, self->wayland.cursor.surface, 0, 0); - } - for(i = 0; i < arrlen(currentlyHeldWidgets); i++) { - MwLL new_topmost = currentlyHeldWidgets[i]; - p.point = topmost_parent->wayland.cur_mouse_pos; - while(new_topmost->wayland.parent) { - p.point.x -= new_topmost->wayland.x; - p.point.y -= new_topmost->wayland.y; - new_topmost = new_topmost->wayland.parent; + + for(i = 0; i < arrlen(currentlyHeldWidgets); i++) { + MwLL new_topmost = currentlyHeldWidgets[i]; + p.point = topmost_parent->wayland.cur_mouse_pos; + while(new_topmost->wayland.parent) { + p.point.x -= new_topmost->wayland.x; + p.point.y -= new_topmost->wayland.y; + new_topmost = new_topmost->wayland.parent; + } + + MwLLDispatch(currentlyHeldWidgets[i], move, &p); } - - MwLLDispatch(currentlyHeldWidgets[i], move, &p); + MwLLWaylandCascadeChildren(self); } - MwLLWaylandCascadeChildren(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; MwLL topmost_parent = self; int i; + MwBool inArea = MwFALSE; (void)wl_pointer; (void)serial; @@ -711,45 +712,54 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri WAYLAND_EVENT_OP_START(self); - while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent; + if(self->wayland.type != MwLL_WAYLAND_POPUP) { + while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent; + } p.point = self->wayland.cur_mouse_pos; - switch(button) { - case BTN_LEFT: - p.button = MwMOUSE_LEFT; - break; - case BTN_MIDDLE: - p.button = MwMOUSE_MIDDLE; - break; - case BTN_RIGHT: - p.button = MwMOUSE_RIGHT; - break; + if(self->wayland.framebuffer.surface) { + inArea |= self->wayland.framebuffer.surface == curSurface; } - self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED; - switch(state) { - case WL_POINTER_BUTTON_STATE_PRESSED: - MwLLDispatch(self, down, &p); - break; - case WL_POINTER_BUTTON_STATE_RELEASED: - MwLLDispatch(self, up, &p); - break; + if(self->wayland.backbuffer.surface) { + inArea |= self->wayland.backbuffer.surface == curSurface; } + if(inArea) { + switch(button) { + case BTN_LEFT: + p.button = MwMOUSE_LEFT; + break; + case BTN_MIDDLE: + p.button = MwMOUSE_MIDDLE; + break; + case BTN_RIGHT: + p.button = MwMOUSE_RIGHT; + break; + } + self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED; + // switch(state) { + // case WL_POINTER_BUTTON_STATE_PRESSED: + // MwLLDispatch(self, down, &p); + // break; + // case WL_POINTER_BUTTON_STATE_RELEASED: + // MwLLDispatch(self, up, &p); + // break; + // } - for(i = 0; i < arrlen(self->wayland.currentlyHeldWidgets); i++) { - arrdel(self->wayland.currentlyHeldWidgets, i); + for(i = 0; i < arrlen(self->wayland.currentlyHeldWidgets); i++) { + arrdel(self->wayland.currentlyHeldWidgets, i); + } + mouse_dispatch(self, p, state); + + if(!self->wayland.has_decorations && self->wayland.do_csd) { + if(state != WL_POINTER_BUTTON_STATE_RELEASED) + xdg_borderless_step_mdown(self, p, serial); + else + xdg_borderless_step_mup(self, p, serial); + } + + MwLLForceRender(self); } - mouse_dispatch(self, p, state); - - if(!self->wayland.has_decorations && self->wayland.do_csd) { - if(state != WL_POINTER_BUTTON_STATE_RELEASED) - xdg_borderless_step_mdown(self, p, serial); - else - xdg_borderless_step_mup(self, p, serial); - } - - MwLLForceRender(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) { wayland->toplevel->scompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1); } 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; @@ -1180,7 +1190,7 @@ static void wl_subcompositor_interface_destroy(struct _MwLLWayland* wayland, way if(wayland->type == MwLL_WAYLAND_TOPLEVEL) { wl_subcompositor_destroy(wayland->toplevel->scompositor); } 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; } -/* 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 */ 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)); @@ -1338,7 +1330,6 @@ void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland) { WL_INTERFACE(zwp_pointer_constraints_v1); WL_INTERFACE(zwp_relative_pointer_manager_v1); 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 */ if(wayland->type == MwLL_WAYLAND_TOPLEVEL) { WL_INTERFACE(wp_viewporter); @@ -1352,7 +1343,6 @@ void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland) { WL_INTERFACE(wp_viewporter); WL_INTERFACE(wl_subcompositor); WL_INTERFACE(wl_seat); - WL_INTERFACE(wl_seat); } else { WL_INTERFACE(wl_subcompositor); } diff --git a/src/backend/wayland/wayland.c b/src/backend/wayland/wayland.c index 433001b..3c2d9bd 100644 --- a/src/backend/wayland/wayland.c +++ b/src/backend/wayland/wayland.c @@ -417,8 +417,10 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) { if(parent->wayland.type == MwLL_WAYLAND_TOPLEVEL) { 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; + } 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); @@ -427,9 +429,7 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) { raise(SIGTRAP); return; } - 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_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_anchor_rect( r->wayland.popup->xdg_positioner, - r->wayland.x, r->wayland.y, r->wayland.ww, r->wayland.wh); - // xdg_positioner_set_offset( - // r->wayland.popup->xdg_positioner, - // r->wayland.x, r->wayland.y); + topmost_parent->wayland.x, topmost_parent->wayland.y, r->wayland.ww, r->wayland.wh); + xdg_positioner_set_offset( + r->wayland.popup->xdg_positioner, + r->wayland.x, r->wayland.y); 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);