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:
parent
6628d74d38
commit
0950b228af
|
|
@ -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));
|
snprintf(ws_numbers, sizeof(ws_numbers), "%i [ %i ]", scr->current_workspace + 1, ((scr->current_workspace / 10) + 1));
|
||||||
length = strlen(ws_numbers);
|
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,
|
WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->black,
|
||||||
scr->icon_title_font, 4, 3, ws_numbers, length);
|
scr->icon_title_font, 4, 3, ws_numbers, length);
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@
|
||||||
#include "keybind.h"
|
#include "keybind.h"
|
||||||
#include "xmodifier.h"
|
#include "xmodifier.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
|
||||||
#include "framewin.h"
|
#include "framewin.h"
|
||||||
|
|
||||||
|
|
@ -109,12 +110,14 @@ static void notifyClient(WMenu *menu, WMenuEntry *entry)
|
||||||
event.xkey.state = data->key[i].modifier;
|
event.xkey.state = data->key[i].modifier;
|
||||||
event.xkey.same_screen = True;
|
event.xkey.same_screen = True;
|
||||||
event.xkey.time = CurrentTime;
|
event.xkey.time = CurrentTime;
|
||||||
|
if (dpy) {
|
||||||
if (XSendEvent(dpy, window, False, KeyPressMask, &event)) {
|
if (XSendEvent(dpy, window, False, KeyPressMask, &event)) {
|
||||||
event.xkey.type = KeyRelease;
|
event.xkey.type = KeyRelease;
|
||||||
event.xkey.time = CurrentTime;
|
event.xkey.time = CurrentTime;
|
||||||
XSendEvent(dpy, window, True, KeyReleaseMask, &event);
|
XSendEvent(dpy, window, True, KeyReleaseMask, &event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removeUserMenudata(void *menudata)
|
static void removeUserMenudata(void *menudata)
|
||||||
|
|
@ -169,7 +172,7 @@ static WUserMenuData *convertShortcuts(WScreen *scr, WMPropList *shortcut)
|
||||||
b = k + 1;
|
b = k + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ksym = XStringToKeysym(b);
|
ksym = xkb_keysym_from_name(b, XKB_KEYSYM_NO_FLAGS);
|
||||||
if (ksym == NoSymbol)
|
if (ksym == NoSymbol)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
10
src/window.c
10
src/window.c
|
|
@ -651,13 +651,11 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window)
|
||||||
|
|
||||||
wm_backend->context_save(window, WM_CTX_CLIENT_WIN, &wwin->client_descriptor);
|
wm_backend->context_save(window, WM_CTX_CLIENT_WIN, &wwin->client_descriptor);
|
||||||
|
|
||||||
#ifdef USE_XSHAPE
|
|
||||||
{
|
{
|
||||||
int b_shaped = 0;
|
int b_shaped = 0;
|
||||||
wm_backend->client_query_shaped(window, &b_shaped);
|
wm_backend->client_query_shaped(window, &b_shaped);
|
||||||
wwin->flags.shaped = b_shaped;
|
wwin->flags.shaped = b_shaped;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get hints and other information in properties */
|
/* Get hints and other information in properties */
|
||||||
PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance);
|
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.x += wwin->screen_ptr->frame_border_width;
|
||||||
wwin->client.y += wwin->screen_ptr->frame_border_width;
|
wwin->client.y += wwin->screen_ptr->frame_border_width;
|
||||||
}
|
}
|
||||||
#ifdef USE_XSHAPE
|
|
||||||
if (wwin->flags.shaped && resize)
|
if (wwin->flags.shaped && resize)
|
||||||
wm_backend->window_shape_set(wwin);
|
wm_backend->window_shape_set(wwin);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (synth_notify)
|
if (synth_notify)
|
||||||
wWindowSynthConfigureNotify(wwin);
|
wWindowSynthConfigureNotify(wwin);
|
||||||
|
|
@ -2233,10 +2229,8 @@ void wWindowConfigureBorders(WWindow *wwin)
|
||||||
if (flags != 0)
|
if (flags != 0)
|
||||||
wFrameWindowHideButton(wwin->frame, flags);
|
wFrameWindowHideButton(wwin->frame, flags);
|
||||||
|
|
||||||
#ifdef USE_XSHAPE
|
if (wwin->flags.shaped)
|
||||||
if (w_global.xext.shape.supported && wwin->flags.shaped)
|
|
||||||
wWindowSetShape(wwin);
|
wWindowSetShape(wwin);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2298,7 +2292,6 @@ static int getSavedState(WNativeWindow window, WSavedState ** state)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_XSHAPE
|
|
||||||
void wWindowClearShape(WWindow * wwin)
|
void wWindowClearShape(WWindow * wwin)
|
||||||
{
|
{
|
||||||
wm_backend->window_shape_clear(wwin);
|
wm_backend->window_shape_clear(wwin);
|
||||||
|
|
@ -2308,7 +2301,6 @@ void wWindowSetShape(WWindow * wwin)
|
||||||
{
|
{
|
||||||
wm_backend->window_shape_set(wwin);
|
wm_backend->window_shape_set(wwin);
|
||||||
}
|
}
|
||||||
#endif /* USE_XSHAPE */
|
|
||||||
|
|
||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -249,11 +249,9 @@ static void showWorkspaceName(WScreen * scr, int workspace)
|
||||||
int px, py;
|
int px, py;
|
||||||
char *name = scr->workspaces[workspace]->name;
|
char *name = scr->workspaces[workspace]->name;
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
#ifdef USE_XINERAMA
|
|
||||||
int head;
|
int head;
|
||||||
WMRect rect;
|
WMRect rect;
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (wPreferences.workspace_name_display_position == WD_NONE || scr->workspace_count < 2)
|
if (wPreferences.workspace_name_display_position == WD_NONE || scr->workspace_count < 2)
|
||||||
return;
|
return;
|
||||||
|
|
@ -277,7 +275,6 @@ static void showWorkspaceName(WScreen * scr, int workspace)
|
||||||
w = WMWidthOfString(scr->workspace_name_font, name, len);
|
w = WMWidthOfString(scr->workspace_name_font, name, len);
|
||||||
h = WMFontHeight(scr->workspace_name_font);
|
h = WMFontHeight(scr->workspace_name_font);
|
||||||
|
|
||||||
#ifdef USE_XINERAMA
|
|
||||||
head = wGetHeadForPointerLocation(scr);
|
head = wGetHeadForPointerLocation(scr);
|
||||||
rect = wGetRectForHead(scr, head);
|
rect = wGetRectForHead(scr, head);
|
||||||
if (scr->head_count) {
|
if (scr->head_count) {
|
||||||
|
|
@ -288,23 +285,14 @@ static void showWorkspaceName(WScreen * scr, int workspace)
|
||||||
xx = (scr->scr_width - (w + 4)) / 2;
|
xx = (scr->scr_width - (w + 4)) / 2;
|
||||||
yy = (scr->scr_height - (h + 4)) / 2;
|
yy = (scr->scr_height - (h + 4)) / 2;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (wPreferences.workspace_name_display_position) {
|
switch (wPreferences.workspace_name_display_position) {
|
||||||
case WD_TOP:
|
case WD_TOP:
|
||||||
#ifdef USE_XINERAMA
|
|
||||||
px = xx;
|
px = xx;
|
||||||
#else
|
|
||||||
px = (scr->scr_width - (w + 4)) / 2;
|
|
||||||
#endif
|
|
||||||
py = WORKSPACE_NAME_DISPLAY_PADDING;
|
py = WORKSPACE_NAME_DISPLAY_PADDING;
|
||||||
break;
|
break;
|
||||||
case WD_BOTTOM:
|
case WD_BOTTOM:
|
||||||
#ifdef USE_XINERAMA
|
|
||||||
px = xx;
|
px = xx;
|
||||||
#else
|
|
||||||
px = (scr->scr_width - (w + 4)) / 2;
|
|
||||||
#endif
|
|
||||||
py = scr->scr_height - (h + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
|
py = scr->scr_height - (h + 4 + WORKSPACE_NAME_DISPLAY_PADDING);
|
||||||
break;
|
break;
|
||||||
case WD_TOPLEFT:
|
case WD_TOPLEFT:
|
||||||
|
|
@ -325,13 +313,8 @@ static void showWorkspaceName(WScreen * scr, int workspace)
|
||||||
break;
|
break;
|
||||||
case WD_CENTER:
|
case WD_CENTER:
|
||||||
default:
|
default:
|
||||||
#ifdef USE_XINERAMA
|
|
||||||
px = xx;
|
px = xx;
|
||||||
py = yy;
|
py = yy;
|
||||||
#else
|
|
||||||
px = (scr->scr_width - (w + 4)) / 2;
|
|
||||||
py = (scr->scr_height - (h + 4)) / 2;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wm_backend->window_resize(scr->workspace_name, w + 4, h + 4);
|
wm_backend->window_resize(scr->workspace_name, w + 4, h + 4);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue