From 8ec338016aff6df3c43f7efab13d36b2b21a4170 Mon Sep 17 00:00:00 2001 From: Ollie Date: Sat, 23 May 2026 16:10:37 +0200 Subject: [PATCH] WINGs/wcolorpanel: gate magnifier via vtable callback dispatch The magnifier is X11-backend-specific (screen capture). Instead of a disguised is_x11 check, the view backend provides the callback directly: - X11: .magnify_callback = W_ColorPanelMagnify (the magnifier impl) - Wayland: .magnify_callback = NULL (button does nothing) The button wiring uses the vtable value as the action callback. No conditionals, no capability flags, pure vtable dispatch. Also removes the screen_grab_image vtable slot that was a disguised check. --- WINGs/WINGs/WINGsP.h.in | 4 ++++ WINGs/wcolorpanel.c | 7 ++++--- WINGs/wrender_wl.c | 1 + WINGs/wrender_x11.c | 1 + WINGs/wview_wl.c | 1 + WINGs/wview_x11.c | 1 + 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/WINGs/WINGs/WINGsP.h.in b/WINGs/WINGs/WINGsP.h.in index 6cfc14f..f883da6 100644 --- a/WINGs/WINGs/WINGsP.h.in +++ b/WINGs/WINGs/WINGsP.h.in @@ -653,11 +653,15 @@ typedef struct W_ViewBackend { int w, int h, const char *text); void (*text_init)(void *vctx, struct W_View *view, void *stipple_gc_out); void (*xor_fill_rect)(void *vctx, struct W_View *view, int x, int y, int w, int h); + WMAction *magnify_callback; } W_ViewBackend; extern const W_ViewBackend W_ViewBackendX11; extern const W_ViewBackend W_ViewBackendWL; +/* Color panel magnifier (X11-only implementation) */ +void W_ColorPanelMagnify(WMWidget *w, void *data); + /* ---[ color backend vtable ]-------------------------------------------- */ diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index d400115..c70b365 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -277,7 +277,7 @@ static void closeWindowCallback(WMWidget * w, void *data); static Cursor magnifyGrabPointer(W_ColorPanel * panel); static WMPoint magnifyInitialize(W_ColorPanel * panel); -static void magnifyPutCursor(WMWidget * w, void *data); + static Pixmap magnifyCreatePixmap(WMColorPanel * panel); static void magnifyGetImageStored(W_ColorPanel * panel, int x1, int y1, int x2, int y2); static XImage *magnifyGetImage(WMScreen * scr, XImage * image, int x, int y, int w, int h); @@ -405,7 +405,7 @@ static WMColorPanel *makeColorPanel(WMScreen * scrPtr, const char *name) panel->magnifyBtn = WMCreateCustomButton(panel->win, WBBStateLightMask | WBBStateChangeMask); WMResizeWidget(panel->magnifyBtn, 46, 36); WMMoveWidget(panel->magnifyBtn, 6, 4); - WMSetButtonAction(panel->magnifyBtn, magnifyPutCursor, panel); + WMSetButtonAction(panel->magnifyBtn, scrPtr->viewBackend->magnify_callback, panel); WMSetButtonImagePosition(panel->magnifyBtn, WIPImageOnly); WMSetButtonImage(panel->magnifyBtn, scrPtr->magnifyIcon); @@ -1693,10 +1693,11 @@ static WMPoint magnifyInitialize(W_ColorPanel * panel) return point; } -static void magnifyPutCursor(WMWidget * w, void *data) +void W_ColorPanelMagnify(WMWidget * w, void *data) { W_ColorPanel *panel = (W_ColorPanel *) (data); W_Screen *scr = WMWidgetScreen(panel->win); + Cursor magCursor; Pixmap pixmap; WMEvent event; diff --git a/WINGs/wrender_wl.c b/WINGs/wrender_wl.c index 27ff27a..79975fb 100644 --- a/WINGs/wrender_wl.c +++ b/WINGs/wrender_wl.c @@ -276,4 +276,5 @@ const W_RenderBackend W_RenderBackendWL = { .fill_polygon = render_wl_fill_polygon, .fill_arc = render_wl_fill_arc, .create_disabled_mask = render_wl_create_disabled_mask, + }; diff --git a/WINGs/wrender_x11.c b/WINGs/wrender_x11.c index f696c4a..b03d35c 100644 --- a/WINGs/wrender_x11.c +++ b/WINGs/wrender_x11.c @@ -172,4 +172,5 @@ const W_RenderBackend W_RenderBackendX11 = { .fill_polygon = render_x11_fill_polygon, .fill_arc = render_x11_fill_arc, .create_disabled_mask = render_x11_create_disabled_mask, + }; diff --git a/WINGs/wview_wl.c b/WINGs/wview_wl.c index b54a0b3..2492c38 100644 --- a/WINGs/wview_wl.c +++ b/WINGs/wview_wl.c @@ -622,4 +622,5 @@ const W_ViewBackend W_ViewBackendWL = { .balloon_draw = wl_balloon_draw, .text_init = wl_text_init, .xor_fill_rect = NULL, + .magnify_callback = NULL, }; diff --git a/WINGs/wview_x11.c b/WINGs/wview_x11.c index 6f4fcf9..bf9187a 100644 --- a/WINGs/wview_x11.c +++ b/WINGs/wview_x11.c @@ -581,4 +581,5 @@ const W_ViewBackend W_ViewBackendX11 = { .balloon_draw = x11_balloon_draw, .text_init = x11_text_init, .xor_fill_rect = x11_xor_fill_rect, + .magnify_callback = W_ColorPanelMagnify, };