Move wDrawBevel X11 rendering to backend via draw_bevel vtable slot
texture.c now dispatches through wm_backend->draw_bevel(). X11 backend contains the XDrawSegments implementation. texture.o verified X11-free with nm.
This commit is contained in:
parent
d87a7f9941
commit
b8899b4cb8
|
|
@ -48,6 +48,7 @@ typedef struct WProtocols WProtocols;
|
|||
typedef struct WShortKey WShortKey;
|
||||
typedef struct MWMHints MWMHints;
|
||||
typedef struct WMenu WMenu;
|
||||
typedef struct WTexSolid WTexSolid;
|
||||
|
||||
/*
|
||||
* WMBackend -- vtable for all display-system operations.
|
||||
|
|
@ -1675,6 +1676,13 @@ typedef struct WMBackend {
|
|||
void (*menu_draw_frame)(WScreen *scr, WNativeWindow win,
|
||||
int y, int w, int h, int type);
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Bevel drawing (Phase 80c) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
void (*draw_bevel)(WNativeWindow d, unsigned int width, unsigned int height,
|
||||
WTexSolid *texture, int relief);
|
||||
|
||||
} WMBackend;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -6180,6 +6180,10 @@ static void wl_noop_menu_paint_entry(WMenu *menu, int index, int selected)
|
|||
static void wl_noop_menu_draw_frame(WScreen *scr, WNativeWindow win, int y, int w, int h, int type)
|
||||
{ (void)scr; (void)win; (void)y; (void)w; (void)h; (void)type; }
|
||||
|
||||
static void wl_noop_draw_bevel(WNativeWindow d, unsigned int width, unsigned int height,
|
||||
WTexSolid *texture, int relief)
|
||||
{ (void)d; (void)width; (void)height; (void)texture; (void)relief; }
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* vtable */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
|
@ -6389,4 +6393,5 @@ const WMBackend wl_backend = {
|
|||
.do_kaboom = wl_noop_do_kaboom,
|
||||
.menu_paint_entry = wl_noop_menu_paint_entry,
|
||||
.menu_draw_frame = wl_noop_menu_draw_frame,
|
||||
.draw_bevel = wl_noop_draw_bevel,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2936,6 +2936,64 @@ static void x11_do_kaboom(WScreen *scr, WNativeWindow win, int x, int y) { DoKab
|
|||
static void x11_menu_paint_entry(WMenu *menu, int index, int selected) { wMenuPaintEntry(menu, index, selected); }
|
||||
static void x11_menu_draw_frame(WScreen *scr, WNativeWindow win, int y, int w, int h, int type) { wMenuDrawFrame(scr, (Window)win, y, w, h, type); }
|
||||
|
||||
static void x11_draw_bevel(WNativeWindow d, unsigned int width, unsigned int height,
|
||||
WTexSolid *texture, int relief)
|
||||
{
|
||||
GC light, dim, dark;
|
||||
XSegment segs[4];
|
||||
|
||||
light = texture->light_gc;
|
||||
dim = texture->dim_gc;
|
||||
dark = texture->dark_gc;
|
||||
switch (relief) {
|
||||
case WREL_RAISED:
|
||||
case WREL_MENUENTRY:
|
||||
case WREL_ICON:
|
||||
segs[0].x1 = 1;
|
||||
segs[0].x2 = width - 2;
|
||||
segs[0].y2 = segs[0].y1 = height - 2;
|
||||
segs[1].x1 = width - 2;
|
||||
segs[1].y1 = 1;
|
||||
segs[1].x2 = width - 2;
|
||||
segs[1].y2 = height - 2;
|
||||
if (wPreferences.new_style == TS_NEXT)
|
||||
XDrawSegments(dpy, (Drawable)d, dark, segs, 2);
|
||||
else
|
||||
XDrawSegments(dpy, (Drawable)d, dim, segs, 2);
|
||||
|
||||
segs[0].x1 = 0;
|
||||
segs[0].x2 = width - 1;
|
||||
segs[0].y2 = segs[0].y1 = height - 1;
|
||||
segs[1].x1 = segs[1].x2 = width - 1;
|
||||
segs[1].y1 = 0;
|
||||
segs[1].y2 = height - 1;
|
||||
if (wPreferences.new_style == TS_NEXT)
|
||||
XDrawSegments(dpy, (Drawable)d, light, segs, 2);
|
||||
else
|
||||
XDrawSegments(dpy, (Drawable)d, dark, segs, 2);
|
||||
|
||||
segs[0].x1 = segs[0].y1 = segs[0].y2 = 0;
|
||||
segs[0].x2 = width - 2;
|
||||
segs[1].x1 = segs[1].y1 = 0;
|
||||
segs[1].x2 = 0;
|
||||
segs[1].y2 = height - 2;
|
||||
if (wPreferences.new_style == TS_NEXT)
|
||||
XDrawSegments(dpy, (Drawable)d, dark, segs, 2);
|
||||
else
|
||||
XDrawSegments(dpy, (Drawable)d, light, segs, 2);
|
||||
|
||||
if (relief == WREL_ICON) {
|
||||
segs[0].x1 = segs[0].y1 = segs[0].y2 = 1;
|
||||
segs[0].x2 = width - 2;
|
||||
segs[1].x1 = segs[1].y1 = 1;
|
||||
segs[1].x2 = 1;
|
||||
segs[1].y2 = height - 2;
|
||||
XDrawSegments(dpy, (Drawable)d, light, segs, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Backend vtable instance and active-backend pointer */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
@ -3124,6 +3182,7 @@ const WMBackend x11_backend = {
|
|||
.do_kaboom = x11_do_kaboom,
|
||||
.menu_paint_entry = x11_menu_paint_entry,
|
||||
.menu_draw_frame = x11_menu_draw_frame,
|
||||
.draw_bevel = x11_draw_bevel,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -485,68 +485,10 @@ static void bevelImage(RImage * image, int relief)
|
|||
|
||||
void wDrawBevel(Drawable d, unsigned width, unsigned height, WTexSolid * texture, int relief)
|
||||
{
|
||||
GC light, dim, dark;
|
||||
XSegment segs[4];
|
||||
|
||||
if (relief == WREL_FLAT)
|
||||
return;
|
||||
|
||||
/* Wayland backend handles bevel drawing in frame_paint */
|
||||
if (wm_backend->is_wayland)
|
||||
return;
|
||||
/* Drawable 0 (WNATIVE_NONE) means the Wayland backend owns this frame;
|
||||
* skip to avoid BadDrawable errors on XWayland connection. */
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
light = texture->light_gc;
|
||||
dim = texture->dim_gc;
|
||||
dark = texture->dark_gc;
|
||||
switch (relief) {
|
||||
case WREL_MENUENTRY:
|
||||
case WREL_RAISED:
|
||||
case WREL_ICON:
|
||||
segs[0].x1 = 1;
|
||||
segs[0].x2 = width - 2;
|
||||
segs[0].y2 = segs[0].y1 = height - 2;
|
||||
segs[1].x1 = width - 2;
|
||||
segs[1].y1 = 1;
|
||||
segs[1].x2 = width - 2;
|
||||
segs[1].y2 = height - 2;
|
||||
if (wPreferences.new_style == TS_NEXT) {
|
||||
XDrawSegments(dpy, d, dark, segs, 2);
|
||||
} else {
|
||||
XDrawSegments(dpy, d, dim, segs, 2);
|
||||
}
|
||||
segs[0].x1 = 0;
|
||||
segs[0].x2 = width - 1;
|
||||
segs[0].y2 = segs[0].y1 = height - 1;
|
||||
segs[1].x1 = segs[1].x2 = width - 1;
|
||||
segs[1].y1 = 0;
|
||||
segs[1].y2 = height - 1;
|
||||
if (wPreferences.new_style == TS_NEXT) {
|
||||
XDrawSegments(dpy, d, light, segs, 2);
|
||||
} else {
|
||||
XDrawSegments(dpy, d, dark, segs, 2);
|
||||
}
|
||||
segs[0].x1 = segs[0].y1 = segs[0].y2 = 0;
|
||||
segs[0].x2 = width - 2;
|
||||
segs[1].x1 = segs[1].y1 = 0;
|
||||
segs[1].x2 = 0;
|
||||
segs[1].y2 = height - 2;
|
||||
if (wPreferences.new_style == TS_NEXT) {
|
||||
XDrawSegments(dpy, d, dark, segs, 2);
|
||||
} else {
|
||||
XDrawSegments(dpy, d, light, segs, 2);
|
||||
}
|
||||
if (relief == WREL_ICON) {
|
||||
segs[0].x1 = segs[0].y1 = segs[0].y2 = 1;
|
||||
segs[0].x2 = width - 2;
|
||||
segs[1].x1 = segs[1].y1 = 1;
|
||||
segs[1].x2 = 1;
|
||||
segs[1].y2 = height - 2;
|
||||
XDrawSegments(dpy, d, light, segs, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
wm_backend->draw_bevel((WNativeWindow)d, width, height, texture, relief);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue