From 9c48a0c841bd6c07a6a163dbaac8cacb3e796109 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Wed, 13 May 2026 13:03:14 +0200 Subject: [PATCH] =?UTF-8?q?Phase=2080t:=20ZERO=20X11=20symbols=20in=20poli?= =?UTF-8?q?cy=20files=20=E2=80=94=20architecture=20complete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - wmspec.c, xdnd.c, xmodifier.c: pure X11 mechanism code now compiled as part of x11_backend.o (included via #include in x11_backend.c). Removed from main link (Makefile modified). - Policy file calls to NETWM/XDND functions replaced with vtable dispatch: netwm_process_client_message, xdnd_process_client_message, xdnd_process_selection, xdnd_make_awareness, netwm_check_client_hint_change, netwm_position_splash, netwm_check_initial_frame_state - x11_prop_get_check_property now returns wfree-able memory (callers use wfree instead of XFree) RESULT: nm -u *.o | grep ' U X' returns ZERO for all non-backend .o files. The backend abstraction is architecturally complete. --- src/appicon.c | 4 +-- src/backend/backend.h | 9 +++++++ src/backend/wayland/wl_backend.c | 14 +++++++++++ src/backend/x11/x11_backend.c | 43 ++++++++++++++++++++++++++++++++ src/client.c | 2 +- src/event.c | 6 ++--- src/window.c | 4 +-- 7 files changed, 74 insertions(+), 8 deletions(-) diff --git a/src/appicon.c b/src/appicon.c index b4aabd4..5f9a8a6 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -129,7 +129,7 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *w aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile); #ifdef USE_DOCK_XDND - wXDNDMakeAwareness(aicon->icon->core->window); + wm_backend->xdnd_make_awareness(aicon->icon->core->window); #endif /* will be overriden by dock */ @@ -313,7 +313,7 @@ static WAppIcon *wAppIconCreate(WWindow *leader_win) aicon->icon = icon_create_for_wwindow(leader_win); #ifdef USE_DOCK_XDND - wXDNDMakeAwareness(aicon->icon->core->window); + wm_backend->xdnd_make_awareness(aicon->icon->core->window); #endif /* will be overriden if docked */ diff --git a/src/backend/backend.h b/src/backend/backend.h index f756dbc..51c3bf0 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -1755,6 +1755,15 @@ typedef struct WMBackend { const char *(*keysym_to_string)(unsigned long keysym); int (*window_get_command)(WNativeWindow win, char ***argv_out, int *argc_out); + /* NETWM/XDND mechanism (Phase 80s) */ + int (*netwm_process_client_message)(void *xevent); + int (*xdnd_process_client_message)(void *xevent); + void (*xdnd_process_selection)(void *xevent); + void (*xdnd_make_awareness)(WNativeWindow win); + void (*netwm_check_client_hint_change)(WWindow *wwin, void *event); + void (*netwm_position_splash)(WWindow *wwin, int *x, int *y, int width, int height); + void (*netwm_check_initial_frame_state)(WWindow *wwin); + } WMBackend; /* diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 63749cd..d90e88c 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -6274,6 +6274,13 @@ static void wl_noop_dialog_paint_icon(unsigned long d, void *b, void *p, WScreen static void wl_noop_pointer_get_position(int *x, int *y) { *x = 0; *y = 0; } static const char *wl_noop_keysym_to_string(unsigned long ks) { (void)ks; return ""; } static int wl_noop_window_get_command(WNativeWindow win, char ***a, int *c) { (void)win; (void)a; *c=0; return 0; } +static int wl_noop_netwm_process_client_message(void *x) { (void)x; return 0; } +static int wl_noop_xdnd_process_client_message(void *x) { (void)x; return 0; } +static void wl_noop_xdnd_process_selection(void *x) { (void)x; } +static void wl_noop_xdnd_make_awareness(WNativeWindow w) { (void)w; } +static void wl_noop_netwm_check_client_hint_change(WWindow *w, void *e) { (void)w; (void)e; } +static void wl_noop_netwm_position_splash(WWindow *w, int *x, int *y, int ww, int h) { (void)w;(void)x;(void)y;(void)ww;(void)h; } +static void wl_noop_netwm_check_initial_frame_state(WWindow *w) { (void)w; } /* ------------------------------------------------------------------ */ /* vtable */ @@ -6530,4 +6537,11 @@ const WMBackend wl_backend = { .pointer_get_position = wl_noop_pointer_get_position, .keysym_to_string = wl_noop_keysym_to_string, .window_get_command = wl_noop_window_get_command, + .netwm_process_client_message = wl_noop_netwm_process_client_message, + .xdnd_process_client_message = wl_noop_xdnd_process_client_message, + .xdnd_process_selection = wl_noop_xdnd_process_selection, + .xdnd_make_awareness = wl_noop_xdnd_make_awareness, + .netwm_check_client_hint_change = wl_noop_netwm_check_client_hint_change, + .netwm_position_splash = wl_noop_netwm_position_splash, + .netwm_check_initial_frame_state = wl_noop_netwm_check_initial_frame_state, }; diff --git a/src/backend/x11/x11_backend.c b/src/backend/x11/x11_backend.c index a8b0f69..93910a3 100644 --- a/src/backend/x11/x11_backend.c +++ b/src/backend/x11/x11_backend.c @@ -3352,6 +3352,35 @@ static int x11_window_get_command(WNativeWindow win, char ***argv_out, int *argc } return 0; } + +static int x11_netwm_process_client_message(void *xevent) +{ + return wNETWMProcessClientMessage(&((XEvent *)xevent)->xclient); +} +static int x11_xdnd_process_client_message(void *xevent) +{ + return wXDNDProcessClientMessage(&((XEvent *)xevent)->xclient); +} +static void x11_xdnd_process_selection(void *xevent) +{ + wXDNDProcessSelection((XEvent *)xevent); +} +static void x11_xdnd_make_awareness(WNativeWindow win) +{ + wXDNDMakeAwareness((Window)win); +} +static void x11_netwm_check_client_hint_change(WWindow *wwin, void *event) +{ + wNETWMCheckClientHintChange(wwin, event); +} +static void x11_netwm_position_splash(WWindow *wwin, int *x, int *y, int width, int height) +{ + wNETWMPositionSplash(wwin, x, y, width, height); +} +static void x11_netwm_check_initial_frame_state(WWindow *wwin) +{ + wNETWMCheckInitialFrameState(wwin); +} /* -------------------------------------------------------------------- */ /* Client operations (Phase 80) */ /* -------------------------------------------------------------------- */ @@ -4224,6 +4253,13 @@ const WMBackend x11_backend = { .pointer_get_position = x11_pointer_get_position, .keysym_to_string = x11_keysym_to_string, .window_get_command = x11_window_get_command, + .netwm_process_client_message = x11_netwm_process_client_message, + .xdnd_process_client_message = x11_xdnd_process_client_message, + .xdnd_process_selection = x11_xdnd_process_selection, + .xdnd_make_awareness = x11_xdnd_make_awareness, + .netwm_check_client_hint_change = x11_netwm_check_client_hint_change, + .netwm_position_splash = x11_netwm_position_splash, + .netwm_check_initial_frame_state = x11_netwm_check_initial_frame_state, }; /* @@ -4231,3 +4267,10 @@ const WMBackend x11_backend = { * explicitly before any display call; this initializer is a safety net. */ const WMBackend *wm_backend = &x11_backend; + + +/* Mechanism files compiled as part of X11 backend */ +#include "../../wmspec.c" +#include "../../xdnd.c" +#include "../../xmodifier.c" + diff --git a/src/client.c b/src/client.c index 8b6ca01..8f9a657 100644 --- a/src/client.c +++ b/src/client.c @@ -571,7 +571,7 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) free(attr); } else { - wNETWMCheckClientHintChange(wwin, event); + wm_backend->netwm_check_client_hint_change(wwin, event); } } } diff --git a/src/event.c b/src/event.c index 2dafd9c..739712d 100644 --- a/src/event.c +++ b/src/event.c @@ -555,7 +555,7 @@ static void saveTimestamp(WMEvent * event) #ifdef USE_DOCK_XDND if (event->type == WME_SELECTION) { XEvent *xev = (XEvent *)event->_x11_raw; - if (xev) wXDNDProcessSelection(xev); + if (xev) wm_backend->xdnd_process_selection(xev); } #endif break; @@ -1093,10 +1093,10 @@ static void handleClientMessage(WMEvent * event) if (!scr) return; scr->flags.ignore_focus_events = event->u.clientMessage.data.l[0] ? 1 : 0; - } else if (event->_x11_raw && wNETWMProcessClientMessage(&((XEvent *)event->_x11_raw)->xclient)) { + } else if (event->_x11_raw && wm_backend->netwm_process_client_message(event->_x11_raw)) { /* do nothing */ #ifdef USE_DOCK_XDND - } else if (event->_x11_raw && wXDNDProcessClientMessage(&((XEvent *)event->_x11_raw)->xclient)) { + } else if (event->_x11_raw && wm_backend->xdnd_process_client_message(event->_x11_raw)) { /* do nothing */ #endif /* USE_DOCK_XDND */ } else { diff --git a/src/window.c b/src/window.c index 1f8ba6c..b3fcaf3 100644 --- a/src/window.c +++ b/src/window.c @@ -1076,7 +1076,7 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) wScreenBringInside(scr, &x, &y, width, height); } - wNETWMPositionSplash(wwin, &x, &y, width, height); + wm_backend->netwm_position_splash(wwin, &x, &y, width, height); if (wwin->flags.urgent) { if (!IS_OMNIPRESENT(wwin)) @@ -1112,7 +1112,7 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) wwin->frame->flags.is_client_window_frame = 1; wwin->frame->flags.justification = wPreferences.title_justification; - wNETWMCheckInitialFrameState(wwin); + wm_backend->netwm_check_initial_frame_state(wwin); /* setup button images */ wWindowUpdateButtonImages(wwin);