wayland: fix popup positioning when CSD is active. fix CSD stride

This commit is contained in:
IoIxD 2026-07-13 14:00:32 -07:00
commit a4d095cabf
5 changed files with 28 additions and 13 deletions

View file

@ -428,6 +428,8 @@ struct _MwLLWayland {
MwBool dispatching_resize;
MwBool is_toplevel_menu;
struct _MwLLWaylandShmBuffer framebuffer;
struct _MwLLWaylandShmBuffer backbuffer;
struct _MwLLWaylandShmBuffer cursor;

View file

@ -119,6 +119,8 @@ struct _MwWidget {
int berserk;
long last_tick;
MwBool is_menu;
};
#endif

View file

@ -31,7 +31,7 @@ void MwLLWaylandBackbufferSetup(struct _MwLLWayland* wayland) {
}
MwLLWaylandBufferSetup(&wayland->backbuffer, w, h);
MwLLCairoBackSetup(&wayland->cairo, wayland->backbuffer.buf_back, wayland->ww, wayland->wh);
MwLLCairoBackSetup(&wayland->cairo, wayland->backbuffer.buf_back, w, h);
memset(wayland->backbuffer.buf_back, 255, wayland->backbuffer.buf_size);
if(wayland->configured)

View file

@ -451,7 +451,6 @@ static void popup_configure(void* data,
int32_t height) {
MwLL self = data;
(void)xdg_popup;
self->wayland.x = x;
self->wayland.y = y;
self->wayland.ww = width;
@ -483,18 +482,23 @@ struct xdg_popup_listener popup_listener = {
/* Popup setup function */
static void setup_popup(MwLL r, int x, int y, MwLL parent) {
MwLL topmost_parent = r->wayland.parent;
r->wayland.type = MwLL_WAYLAND_POPUP;
r->wayland.x = x;
r->wayland.y = y;
r->wayland.popup = malloc(sizeof(struct _MwLLWaylandPopup));
r->wayland.type = MwLL_WAYLAND_POPUP;
r->wayland.x = x;
r->wayland.y = y;
r->wayland.popup = malloc(sizeof(struct _MwLLWaylandPopup));
if(parent) {
MwWidget p = parent->common.user;
while(topmost_parent->wayland.parent) {
topmost_parent = topmost_parent->wayland.parent;
}
while(topmost_parent->wayland.type != MwLL_WAYLAND_TOPLEVEL && topmost_parent->wayland.type != MwLL_WAYLAND_LAYER_SURFACE) {
topmost_parent = topmost_parent->wayland.parent;
}
if(!topmost_parent->wayland.has_decorations && topmost_parent->wayland.do_csd) {
r->wayland.x += ceil((float)CSD_BORDER_FRAME_LEFT / 2.);
r->wayland.y += ceil((float)CSD_BORDER_FRAME_TOP / 2.);
if(!topmost_parent->wayland.has_decorations && topmost_parent->wayland.do_csd) {
if(p->is_menu) {
r->wayland.x += round((float)CSD_BORDER_FRAME_LEFT / 2.);
r->wayland.y += ceil((float)CSD_BORDER_FRAME_TOP / 2.);
}
}
}
MwLLWaylandSetupCallbacks(&r->wayland);
@ -525,7 +529,13 @@ 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);
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);
r->wayland.xkb_keymap = topmost_parent->wayland.xkb_keymap;
r->wayland.xkb_state = topmost_parent->wayland.xkb_state;

View file

@ -24,6 +24,7 @@ static int wcreate(MwWidget handle) {
m->wsub = NULL;
m->sub = NULL;
handle->internal = m;
handle->is_menu = MwTRUE;
MwSetDefault(handle);