157 lines
3.3 KiB
C
157 lines
3.3 KiB
C
/*
|
|
* wview_wl.c - Wayland view backend for WINGs
|
|
*
|
|
* Views are logical layout containers in Wayland mode.
|
|
* No X11 dependencies. Rendering is handled by frame_paint (pixman buffers).
|
|
*/
|
|
|
|
#include "WINGsP.h"
|
|
|
|
/* Synthetic window IDs for Wayland views (distinct from frame buffer IDs) */
|
|
#define WL_VIEW_ID_BASE 0x20000000
|
|
static unsigned int wl_view_next_id = WL_VIEW_ID_BASE;
|
|
|
|
static void *wl_screen_init(W_Screen *scr)
|
|
{
|
|
(void)scr;
|
|
return scr; /* use scr as token */
|
|
}
|
|
|
|
static void wl_screen_fini(void *vctx)
|
|
{
|
|
(void)vctx;
|
|
}
|
|
|
|
static void wl_create_root(void *vctx, W_View *view)
|
|
{
|
|
(void)vctx;
|
|
|
|
view->window = (Window)wl_view_next_id++;
|
|
/* Default screen size — the WM backend will update this */
|
|
view->size.width = 1920;
|
|
view->size.height = 1080;
|
|
}
|
|
|
|
static void wl_realize(void *vctx, W_View *view)
|
|
{
|
|
(void)vctx;
|
|
|
|
/* Assign a synthetic ID so W_DispatchMessage doesn't skip this view */
|
|
view->window = (Window)wl_view_next_id++;
|
|
}
|
|
|
|
static void wl_noop(void *vctx, W_View *view)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
}
|
|
|
|
static void wl_noop_subviews(void *vctx, W_View *view)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
}
|
|
|
|
static void wl_noop_move(void *vctx, W_View *view, int x, int y)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
(void)x;
|
|
(void)y;
|
|
}
|
|
|
|
static void wl_noop_resize(void *vctx, W_View *view, unsigned int w, unsigned int h)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
(void)w;
|
|
(void)h;
|
|
}
|
|
|
|
static void wl_noop_reparent(void *vctx, W_View *view, W_View *newParent, int x, int y)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
(void)newParent;
|
|
(void)x;
|
|
(void)y;
|
|
}
|
|
|
|
static void wl_destroy(void *vctx, W_View *view)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
/* Nothing to free — synthetic ID only */
|
|
}
|
|
|
|
static void wl_set_background_color(void *vctx, W_View *view, WMColor *color)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
(void)color;
|
|
/* Background is handled by pixman rendering in frame_paint */
|
|
}
|
|
|
|
static void wl_set_cursor(void *vctx, W_View *view, Cursor cursor)
|
|
{
|
|
(void)vctx;
|
|
(void)view;
|
|
(void)cursor;
|
|
/* Cursor is managed by wlroots seat */
|
|
}
|
|
|
|
static void wl_redisplay(void *vctx, W_View *view)
|
|
{
|
|
WMEvent ev;
|
|
|
|
(void)vctx;
|
|
|
|
if (!view->flags.mapped)
|
|
return;
|
|
|
|
memset(&ev, 0, sizeof(ev));
|
|
ev.type = WME_EXPOSE;
|
|
ev.window = (WNativeWindow)view->window;
|
|
ev.u.expose.window = (WNativeWindow)view->window;
|
|
ev.u.expose.count = 0;
|
|
ev._x11_raw = NULL;
|
|
|
|
WMHandleEvent(&ev);
|
|
}
|
|
|
|
static WMPoint wl_get_screen_position(void *vctx, W_View *view)
|
|
{
|
|
W_Screen *scr = (W_Screen *)vctx;
|
|
int x = 0, y = 0;
|
|
W_View *v;
|
|
|
|
/* Walk up the view tree accumulating positions */
|
|
for (v = view; v && v != scr->rootView; v = v->parent) {
|
|
x += v->pos.x;
|
|
y += v->pos.y;
|
|
}
|
|
|
|
return wmkpoint(x, y);
|
|
}
|
|
|
|
const W_ViewBackend W_ViewBackendWL = {
|
|
.screen_init = wl_screen_init,
|
|
.screen_fini = wl_screen_fini,
|
|
.create_root = wl_create_root,
|
|
.realize = wl_realize,
|
|
.map = wl_noop,
|
|
.unmap = wl_noop,
|
|
.map_subviews = wl_noop_subviews,
|
|
.unmap_subviews = wl_noop_subviews,
|
|
.move = wl_noop_move,
|
|
.resize = wl_noop_resize,
|
|
.raise = wl_noop,
|
|
.lower = wl_noop,
|
|
.reparent = wl_noop_reparent,
|
|
.destroy = wl_destroy,
|
|
.set_background_color = wl_set_background_color,
|
|
.set_cursor = wl_set_cursor,
|
|
.redisplay = wl_redisplay,
|
|
.get_screen_position = wl_get_screen_position,
|
|
};
|