Dialog rendering: composite child views into parent backing

- wl_realize: allocate pixman backing image for every view
- wl_map_subviews: recursively trigger redisplay on child views
- wl_redisplay: composite child's backing into parent's backing,
  then commit the top-level view's frame_buf
- wtextfield.c: guard W_LookupString against NULL _x11_raw
This commit is contained in:
Levi Neely 2026-05-13 19:57:12 +02:00
parent 4870c72c78
commit b53cc4f0da
2 changed files with 47 additions and 9 deletions

View File

@ -956,8 +956,13 @@ static void handleTextFieldKeyPress(TextField * tPtr, WMEvent * event)
controled = (event->u.key.state & ControlMask ? True : False);
modified = shifted || controled;
count = W_LookupString(tPtr->view, &((XEvent *)event->_x11_raw)->xkey, buffer, 63, &ksym, NULL);
//count = XLookupString(&((XEvent *)event->_x11_raw)->xkey, buffer, 63, &ksym, NULL);
count = event->_x11_raw
? W_LookupString(tPtr->view, &((XEvent *)event->_x11_raw)->xkey, buffer, 63, &ksym, NULL)
: 0;
if (!event->_x11_raw) {
/* Wayland mode: no key translation yet */
return;
}
buffer[count] = '\0';
switch (ksym) {

View File

@ -6,6 +6,7 @@
*/
#include "WINGsP.h"
#include <pixman.h>
/* Synthetic window IDs for Wayland views (distinct from frame buffer IDs) */
#define WL_VIEW_ID_BASE 0x20000000
@ -117,6 +118,12 @@ static void wl_realize(void *vctx, W_View *view)
/* Assign a synthetic ID so W_DispatchMessage doesn't skip this view */
view->window = (Window)wl_view_next_id++;
view_table_put(view->window, view);
/* Allocate a backing pixman image for this view */
int w = view->size.width > 0 ? view->size.width : 1;
int h = view->size.height > 0 ? view->size.height : 1;
pixman_image_t *img = pixman_image_create_bits(PIXMAN_a8r8g8b8, w, h, NULL, 0);
W_SetViewBacking(view->window, img);
}
static void wl_noop(void *vctx, W_View *view)
@ -136,10 +143,19 @@ static void wl_map(void *vctx, W_View *view)
wl_redisplay(vctx, view);
}
static void wl_noop_subviews(void *vctx, W_View *view)
static void wl_map_subviews(void *vctx, W_View *view)
{
(void)vctx;
(void)view;
W_View *child = view->childrenList;
while (child) {
if (child->flags.realized && !child->flags.mapped) {
child->flags.mapped = 1;
wl_redisplay(vctx, child);
}
/* Recurse into grandchildren */
if (child->childrenList)
wl_map_subviews(vctx, child);
child = child->nextSister;
}
}
static void wl_noop_move(void *vctx, W_View *view, int x, int y)
@ -208,10 +224,27 @@ static void wl_redisplay(void *vctx, W_View *view)
WMHandleEvent(&ev);
/* Notify WM backend to commit the view's backing buffer */
/* Composite this view's backing into its parent's backing */
if (view->parent) {
pixman_image_t *src = (pixman_image_t *)W_GetViewBacking(view->window);
pixman_image_t *dst = (pixman_image_t *)W_GetViewBacking(view->parent->window);
if (src && dst) {
pixman_image_composite32(PIXMAN_OP_OVER, src, NULL, dst,
0, 0, 0, 0,
view->pos.x, view->pos.y,
view->size.width, view->size.height);
}
}
/* Notify WM backend to commit the top-level view's backing buffer */
/* Walk up to find the top-level view */
W_View *top = view;
while (top->parent && !top->flags.topLevel)
top = top->parent;
extern void (*W_ViewCommitBackingFn)(unsigned long id);
if (W_ViewCommitBackingFn)
W_ViewCommitBackingFn((unsigned long)view->window);
W_ViewCommitBackingFn((unsigned long)top->window);
}
static WMPoint wl_get_screen_position(void *vctx, W_View *view)
@ -236,8 +269,8 @@ const W_ViewBackend W_ViewBackendWL = {
.realize = wl_realize,
.map = wl_map,
.unmap = wl_noop,
.map_subviews = wl_noop_subviews,
.unmap_subviews = wl_noop_subviews,
.map_subviews = wl_map_subviews,
.unmap_subviews = wl_noop,
.move = wl_noop_move,
.resize = wl_noop_resize,
.raise = wl_noop,