feat: Wave 2 — eliminate direct Xlib calls and #ifdef guards

- R.5: usermenu.c: XStringToKeysym→xkb_keysym_from_name, XSendEvent guarded
- B.1: appicon.c: XClearArea→wm_backend->window_clear
- A4.1: workspace.c: remove 5 USE_XINERAMA guards, unified backend-neutral
- R.7: window.c: remove 4 USE_XSHAPE guards, vtable dispatch
This commit is contained in:
Window Maker 2026-05-17 20:26:43 +02:00
parent 6628d74d38
commit 0950b228af
4 changed files with 22 additions and 44 deletions

View File

@ -368,7 +368,7 @@ static void updateDockNumbers(WScreen *scr)
snprintf(ws_numbers, sizeof(ws_numbers), "%i [ %i ]", scr->current_workspace + 1, ((scr->current_workspace / 10) + 1));
length = strlen(ws_numbers);
XClearArea(dpy, dicon->icon->core->window, 2, 2, 50, WMFontHeight(scr->icon_title_font) + 1, False);
wm_backend->window_clear(dicon->icon->core->window);
WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->black,
scr->icon_title_font, 4, 3, ws_numbers, length);

View File

@ -71,6 +71,7 @@
#include "keybind.h"
#include "xmodifier.h"
#include "misc.h"
#include <xkbcommon/xkbcommon.h>
#include "framewin.h"
@ -109,11 +110,13 @@ static void notifyClient(WMenu *menu, WMenuEntry *entry)
event.xkey.state = data->key[i].modifier;
event.xkey.same_screen = True;
event.xkey.time = CurrentTime;
if (dpy) {
if (XSendEvent(dpy, window, False, KeyPressMask, &event)) {
event.xkey.type = KeyRelease;
event.xkey.time = CurrentTime;
XSendEvent(dpy, window, True, KeyReleaseMask, &event);
}
}
}
}
@ -169,7 +172,7 @@ static WUserMenuData *convertShortcuts(WScreen *scr, WMPropList *shortcut)
b = k + 1;
}
ksym = XStringToKeysym(b);
ksym = xkb_keysym_from_name(b, XKB_KEYSYM_NO_FLAGS);
if (ksym == NoSymbol)
continue;

View File

@ -651,13 +651,11 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window)
wm_backend->context_save(window, WM_CTX_CLIENT_WIN, &wwin->client_descriptor);
#ifdef USE_XSHAPE
{
int b_shaped = 0;
wm_backend->client_query_shaped(window, &b_shaped);
wwin->flags.shaped = b_shaped;
}
#endif
/* Get hints and other information in properties */
PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance);
@ -2009,10 +2007,8 @@ void wWindowConfigure(WWindow *wwin, int req_x, int req_y, int req_width, int re
wwin->client.x += wwin->screen_ptr->frame_border_width;
wwin->client.y += wwin->screen_ptr->frame_border_width;
}
#ifdef USE_XSHAPE
if (wwin->flags.shaped && resize)
wm_backend->window_shape_set(wwin);
#endif
if (synth_notify)
wWindowSynthConfigureNotify(wwin);
@ -2233,10 +2229,8 @@ void wWindowConfigureBorders(WWindow *wwin)
if (flags != 0)
wFrameWindowHideButton(wwin->frame, flags);
#ifdef USE_XSHAPE
if (w_global.xext.shape.supported && wwin->flags.shaped)
if (wwin->flags.shaped)
wWindowSetShape(wwin);
#endif
}
}
@ -2298,7 +2292,6 @@ static int getSavedState(WNativeWindow window, WSavedState ** state)
return 1;
}
#ifdef USE_XSHAPE
void wWindowClearShape(WWindow * wwin)
{
wm_backend->window_shape_clear(wwin);
@ -2308,7 +2301,6 @@ void wWindowSetShape(WWindow * wwin)
{
wm_backend->window_shape_set(wwin);
}
#endif /* USE_XSHAPE */
/* ====================================================================== */

View File

@ -249,11 +249,9 @@ static void showWorkspaceName(WScreen * scr, int workspace)
int px, py;
char *name = scr->workspaces[workspace]->name;
int len = strlen(name);
#ifdef USE_XINERAMA
int head;
WMRect rect;
int xx, yy;
#endif
if (wPreferences.workspace_name_display_position == WD_NONE || scr->workspace_count < 2)
return;
@ -277,35 +275,25 @@ static void showWorkspaceName(WScreen * scr, int workspace)
w = WMWidthOfString(scr->workspace_name_font, name, len);
h = WMFontHeight(scr->workspace_name_font);
#ifdef USE_XINERAMA
head = wGetHeadForPointerLocation(scr);
rect = wGetRectForHead(scr, head);
if (scr->head_count) {
xx = rect.pos.x + (scr->heads[head].width - (w + 4)) / 2;
yy = rect.pos.y + (scr->heads[head].height - (h + 4)) / 2;
}
else {
xx = (scr->scr_width - (w + 4)) / 2;
yy = (scr->scr_height - (h + 4)) / 2;
}
#endif
head = wGetHeadForPointerLocation(scr);
rect = wGetRectForHead(scr, head);
if (scr->head_count) {
xx = rect.pos.x + (scr->heads[head].width - (w + 4)) / 2;
yy = rect.pos.y + (scr->heads[head].height - (h + 4)) / 2;
}
else {
xx = (scr->scr_width - (w + 4)) / 2;
yy = (scr->scr_height - (h + 4)) / 2;
}
switch (wPreferences.workspace_name_display_position) {
case WD_TOP:
#ifdef USE_XINERAMA
px = xx;
#else
px = (scr->scr_width - (w + 4)) / 2;
#endif
py = WORKSPACE_NAME_DISPLAY_PADDING;
px = xx;
py = WORKSPACE_NAME_DISPLAY_PADDING;
break;
case WD_BOTTOM:
#ifdef USE_XINERAMA
px = xx;
#else
px = (scr->scr_width - (w + 4)) / 2;
#endif
py = scr->scr_height - (h + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
px = xx;
py = scr->scr_height - (h + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
break;
case WD_TOPLEFT:
px = WORKSPACE_NAME_DISPLAY_PADDING;
@ -325,13 +313,8 @@ static void showWorkspaceName(WScreen * scr, int workspace)
break;
case WD_CENTER:
default:
#ifdef USE_XINERAMA
px = xx;
py = yy;
#else
px = (scr->scr_width - (w + 4)) / 2;
py = (scr->scr_height - (h + 4)) / 2;
#endif
px = xx;
py = yy;
break;
}
wm_backend->window_resize(scr->workspace_name, w + 4, h + 4);