WINGs Wayland: implement view ops (move, resize, unmap, raise, lower, reparent)

Replaces all no-ops in wview_wl.c with real implementations:
- move: updates pos, triggers parent redisplay
- resize: reallocates pixman buffer, triggers redisplay
- unmap/unmap_subviews: clears mapped flag, triggers parent redisplay
- raise: moves view to end of sibling list (drawn last = on top)
- lower: moves view to front of sibling list (drawn first = on bottom)
- reparent: moves between parent children lists
This commit is contained in:
Window Maker 2026-05-23 14:51:07 +02:00
parent 4c5f07f9ec
commit e7427f08db
1 changed files with 128 additions and 23 deletions

View File

@ -163,13 +163,84 @@ static void wl_realize(void *vctx, W_View *view)
W_SetViewBacking(view->window, img);
}
static void wl_noop(void *vctx, W_View *view)
static void wl_redisplay(void *vctx, W_View *view);
static void wl_unmap(void *vctx, W_View *view)
{
(void)vctx;
(void)view;
view->flags.mapped = 0;
if (view->parent && view->parent->flags.mapped)
wl_redisplay(vctx, view->parent);
}
static void wl_unmap_subviews(void *vctx, W_View *view)
{
W_View *child = view->childrenList;
while (child) {
child->flags.mapped = 0;
if (child->childrenList)
wl_unmap_subviews(vctx, child);
child = child->nextSister;
}
}
static void wl_raise(void *vctx, W_View *view)
{
(void)vctx;
W_View *parent = view->parent;
if (!parent) return;
/* Remove from list */
if (parent->childrenList == view) {
parent->childrenList = view->nextSister;
} else {
W_View *prev = parent->childrenList;
while (prev && prev->nextSister != view)
prev = prev->nextSister;
if (prev)
prev->nextSister = view->nextSister;
}
/* Append to end (drawn last = on top) */
view->nextSister = NULL;
if (!parent->childrenList) {
parent->childrenList = view;
} else {
W_View *last = parent->childrenList;
while (last->nextSister)
last = last->nextSister;
last->nextSister = view;
}
if (parent->flags.mapped)
wl_redisplay(vctx, parent);
}
static void wl_lower(void *vctx, W_View *view)
{
(void)vctx;
W_View *parent = view->parent;
if (!parent) return;
/* Remove from list */
if (parent->childrenList == view) {
parent->childrenList = view->nextSister;
} else {
W_View *prev = parent->childrenList;
while (prev && prev->nextSister != view)
prev = prev->nextSister;
if (prev)
prev->nextSister = view->nextSister;
}
/* Prepend to front (drawn first = on bottom) */
view->nextSister = parent->childrenList;
parent->childrenList = view;
if (parent->flags.mapped)
wl_redisplay(vctx, parent);
}
static void wl_redisplay(void *vctx, W_View *view);
static void wl_map_subviews(void *vctx, W_View *view);
static void wl_map(void *vctx, W_View *view)
@ -220,29 +291,63 @@ static void wl_map_subviews(void *vctx, W_View *view)
}
}
static void wl_noop_move(void *vctx, W_View *view, int x, int y)
static void wl_move(void *vctx, W_View *view, int x, int y)
{
(void)vctx;
(void)view;
(void)x;
(void)y;
view->pos.x = x;
view->pos.y = y;
if (view->parent && view->flags.mapped)
wl_redisplay(vctx, view->parent);
}
static void wl_noop_resize(void *vctx, W_View *view, unsigned int w, unsigned int h)
static void wl_resize(void *vctx, W_View *view, unsigned int w, unsigned int h)
{
(void)vctx;
(void)view;
(void)w;
(void)h;
view->size.width = w;
view->size.height = h;
/* Reallocate backing pixman buffer */
pixman_image_t *old = (pixman_image_t *)W_GetViewBacking(view->window);
if (old)
pixman_image_unref(old);
int bw = w > 0 ? (int)w : 1;
int bh = h > 0 ? (int)h : 1;
pixman_image_t *img = pixman_image_create_bits(PIXMAN_a8r8g8b8, bw, bh, NULL, 0);
W_SetViewBacking(view->window, img);
if (view->flags.mapped)
wl_redisplay(vctx, view);
}
static void wl_noop_reparent(void *vctx, W_View *view, W_View *newParent, int x, int y)
static void wl_reparent(void *vctx, W_View *view, W_View *newParent, int x, int y)
{
(void)vctx;
(void)view;
(void)newParent;
(void)x;
(void)y;
W_View *oldParent = view->parent;
/* Remove from old parent's children list */
if (oldParent) {
if (oldParent->childrenList == view) {
oldParent->childrenList = view->nextSister;
} else {
W_View *prev = oldParent->childrenList;
while (prev && prev->nextSister != view)
prev = prev->nextSister;
if (prev)
prev->nextSister = view->nextSister;
}
}
/* Insert into new parent's children list */
view->nextSister = newParent->childrenList;
newParent->childrenList = view;
view->parent = newParent;
view->pos.x = x;
view->pos.y = y;
if (oldParent && oldParent->flags.mapped)
wl_redisplay(vctx, oldParent);
if (view->flags.mapped)
wl_redisplay(vctx, newParent);
}
static void wl_destroy(void *vctx, W_View *view)
@ -385,14 +490,14 @@ const W_ViewBackend W_ViewBackendWL = {
.create_root = wl_create_root,
.realize = wl_realize,
.map = wl_map,
.unmap = wl_noop,
.unmap = wl_unmap,
.map_subviews = wl_map_subviews,
.unmap_subviews = wl_noop,
.move = wl_noop_move,
.resize = wl_noop_resize,
.raise = wl_noop,
.lower = wl_noop,
.reparent = wl_noop_reparent,
.unmap_subviews = wl_unmap_subviews,
.move = wl_move,
.resize = wl_resize,
.raise = wl_raise,
.lower = wl_lower,
.reparent = wl_reparent,
.destroy = wl_destroy,
.set_background_color = wl_set_background_color,
.set_cursor = wl_set_cursor,