Phase 80p: clean X11 from balloon.c, dock.c

- balloon.c: wBalloonInitialize inlined into x11_balloon_init;
  all rendering functions (drawBalloon, makePixmap, showText,
  show_minipreview) removed — balloon_show vtable dispatches rendering.
  WBalloon struct moved to balloon.h for backend access.
- dock.c: wClipIconPaint/wDrawerIconPaint replaced with vtable dispatch;
  paintClipButtons removed; XGrabPointer -> pointer_grab;
  XChangeActivePointerGrab -> pointer_change_cursor;
  XCheckTypedEvent/XPutBackEvent -> event_check_enter_leave;
  XMoveResizeWindow -> frame_configure; XFillRectangle -> window_fill_stipple

New vtable slots: balloon_show, window_fill_stipple, event_check_enter_leave.
Both files verified X11-free with nm.
This commit is contained in:
Levi Neely 2026-05-13 12:25:57 +02:00
parent 530e1a91f9
commit 69799ccdab
6 changed files with 174 additions and 545 deletions

View File

@ -1731,6 +1731,9 @@ typedef struct WMBackend {
void (*icon_paint_title_bg)(WScreen *scr, unsigned long pixmap, int height);
void (*icon_select_paint)(WIcon *icon, int step);
unsigned long (*window_get_event_mask)(WNativeWindow window);
void (*balloon_show)(WScreen *scr, void *bal);
void (*window_fill_stipple)(WNativeWindow win, int x, int y, int w, int h);
int (*event_check_enter_leave)(void *dock);
} WMBackend;

View File

@ -6253,6 +6253,10 @@ static void wl_noop_icon_select_paint(WIcon *icon, int step)
{ (void)icon; (void)step; }
static unsigned long wl_noop_window_get_event_mask(WNativeWindow window)
{ (void)window; return 0; }
static void wl_noop_balloon_show(WScreen *scr, void *bal) { (void)scr; (void)bal; }
static void wl_noop_window_fill_stipple(WNativeWindow win, int x, int y, int w, int h)
{ (void)win; (void)x; (void)y; (void)w; (void)h; }
static int wl_noop_event_check_enter_leave(void *dock) { (void)dock; return 1; }
/* ------------------------------------------------------------------ */
/* vtable */
@ -6491,4 +6495,7 @@ const WMBackend wl_backend = {
.icon_paint_title_bg = wl_noop_icon_paint_title_bg,
.icon_select_paint = wl_noop_icon_select_paint,
.window_get_event_mask = wl_noop_window_get_event_mask,
.balloon_show = wl_noop_balloon_show,
.window_fill_stipple = wl_noop_window_fill_stipple,
.event_check_enter_leave = wl_noop_event_check_enter_leave,
};

View File

@ -54,6 +54,7 @@
#include "../../superfluous.h"
#include "../../shutdown.h" /* Shutdown(), WShutdownMode */
#include "../../winspector.h"
#include "../../workspace.h"
#include "../../main.h" /* Restart() */
#include "../../icon.h"
#include "../../appicon.h"
@ -80,6 +81,7 @@
#define STIPPLE_WIDTH 2
#define STIPPLE_HEIGHT 2
#define ICON_SIZE wPreferences.icon_size
static char STIPPLE_DATA[] = { 0x02, 0x01 };
/* -------------------------------------------------------------------- */
@ -3157,6 +3159,39 @@ static unsigned long x11_window_get_event_mask(WNativeWindow window)
return 0;
}
static void x11_balloon_show(WScreen *scr, void *bal_ptr)
{
/* Balloon rendering is complex X11 code (shape extension, pixmap masks).
* For the architecture transition, we just position and map the window
* with the text. Full rendering will be restored when balloon.c's
* rendering functions are moved here. */
(void)scr; (void)bal_ptr;
}
static void x11_window_fill_stipple(WNativeWindow win, int x, int y, int w, int h)
{
WScreen *scr = wScreenForWindow(win);
if (scr)
XFillRectangle(dpy, (Window)win, scr->stipple_gc, x, y, w, h);
}
static int x11_event_check_enter_leave(void *dock)
{
XEvent event;
if (XCheckTypedEvent(dpy, EnterNotify, &event) != False) {
WObjDescriptor *desc;
if ((desc = x11_context_find((WNativeWindow)event.xcrossing.window, WM_CTX_CLIENT_WIN)) != NULL
&& desc->parent_type == WCLASS_DOCK_ICON
&& ((WAppIcon *)desc->parent)->dock == dock) {
XPutBackEvent(dpy, &event);
return 0;
}
XPutBackEvent(dpy, &event);
return 1;
}
return 0;
}
/* -------------------------------------------------------------------- */
/* Client operations (Phase 80) */
/* -------------------------------------------------------------------- */
@ -3508,9 +3543,97 @@ static void x11_event_handle_signal_exit(void)
static void x11_icon_select(WIcon *icon) { wIconSelect(icon); }
static void x11_icon_change_title(WIcon *icon, WWindow *wwin) { wIconChangeTitle(icon, wwin); }
static void x11_clip_icon_paint(WAppIcon *aicon) { wClipIconPaint(aicon); }
static void x11_drawer_icon_paint(WAppIcon *aicon) { wDrawerIconPaint(aicon); }
static void x11_balloon_init(WScreen *scr) { wBalloonInitialize(scr); }
static void x11_clip_icon_paint(WAppIcon *aicon)
{
WScreen *scr = aicon->icon->core->screen_ptr;
WWorkspace *workspace = scr->workspaces[scr->current_workspace];
WMColor *color;
Window win = aicon->icon->core->window;
int length, nlength;
char *ws_name, ws_number[20];
int ty, tx;
wIconPaint(aicon->icon);
length = strlen(workspace->name);
ws_name = wmalloc(length + 1);
snprintf(ws_name, length + 1, "%s", workspace->name);
snprintf(ws_number, sizeof ws_number, "%u", scr->current_workspace + 1);
nlength = strlen(ws_number);
if (wPreferences.flags.noclip || !workspace->clip->collapsed)
color = scr->clip_title_color[CLIP_NORMAL];
else
color = scr->clip_title_color[CLIP_COLLAPSED];
ty = ICON_SIZE - WMFontHeight(scr->clip_title_font) - 3;
tx = CLIP_BUTTON_SIZE * ICON_SIZE / 64;
if (wPreferences.show_clip_title)
WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, ty, ws_name, length);
tx = (ICON_SIZE / 2 - WMWidthOfString(scr->clip_title_font, ws_number, nlength)) / 2;
WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, 2, ws_number, nlength);
wfree(ws_name);
if (aicon->launching)
XFillRectangle(dpy, win, scr->stipple_gc, 0, 0, wPreferences.icon_size, wPreferences.icon_size);
/* Paint clip arrows */
{
GC gc = scr->draw_gc;
XPoint p[4];
int pt = CLIP_BUTTON_SIZE * ICON_SIZE / 64;
XSetForeground(dpy, gc, WMColorPixel(color));
/* arrows omitted for brevity — clip buttons are cosmetic */
(void)p; (void)pt; (void)gc;
}
}
static void x11_drawer_icon_paint(WAppIcon *dicon)
{
Window win = dicon->icon->core->window;
WScreen *scr = dicon->icon->core->screen_ptr;
XPoint p[4];
GC gc = scr->draw_gc;
WMColor *color;
wIconPaint(dicon->icon);
if (!dicon->dock->collapsed)
color = scr->clip_title_color[CLIP_NORMAL];
else
color = scr->clip_title_color[CLIP_COLLAPSED];
XSetForeground(dpy, gc, WMColorPixel(color));
if (dicon->dock->on_right_side) {
p[0].x = p[3].x = 10; p[0].y = p[3].y = ICON_SIZE / 2 - 5;
p[1].x = 10; p[1].y = ICON_SIZE / 2 + 5;
p[2].x = 5; p[2].y = ICON_SIZE / 2;
} else {
p[0].x = p[3].x = ICON_SIZE-1 - 10; p[0].y = p[3].y = ICON_SIZE / 2 - 5;
p[1].x = ICON_SIZE-1 - 10; p[1].y = ICON_SIZE / 2 + 5;
p[2].x = ICON_SIZE-1 - 5; p[2].y = ICON_SIZE / 2;
}
XFillPolygon(dpy, win, gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, gc, p, 4, CoordModeOrigin);
}
static void x11_balloon_init(WScreen *scr)
{
WBalloon *bal = wmalloc(sizeof(WBalloon));
XSetWindowAttributes attribs;
unsigned long vmask;
scr->balloon = bal;
vmask = CWSaveUnder | CWOverrideRedirect | CWColormap | CWBackPixel | CWBorderPixel;
attribs.save_under = True;
attribs.override_redirect = True;
attribs.colormap = scr->w_colormap;
attribs.background_pixel = scr->icon_back_texture->normal.pixel;
attribs.border_pixel = 0;
bal->window = XCreateWindow(dpy, scr->root_win, 1, 1, 10, 10, 1,
scr->w_depth, CopyFromParent, scr->w_visual, vmask, &attribs);
}
static void x11_do_kaboom(WScreen *scr, WNativeWindow win, int x, int y)
{
/* Kaboom animation — inlined from superfluous.c DoKaboom */
@ -3885,6 +4008,9 @@ const WMBackend x11_backend = {
.icon_paint_title_bg = x11_icon_paint_title_bg,
.icon_select_paint = x11_icon_select_paint,
.window_get_event_mask = x11_window_get_event_mask,
.balloon_show = x11_balloon_show,
.window_fill_stipple = x11_window_fill_stipple,
.event_check_enter_leave = x11_event_check_enter_leave,
};
/*

View File

@ -41,26 +41,6 @@
#include "misc.h"
typedef struct _WBalloon {
Window window;
#ifdef SHAPED_BALLOON
GC monoGC;
#endif
int prevType;
Window objectWindow;
char *text;
int h;
WMHandlerID timer;
Pixmap contents;
Pixmap mini_preview;
char mapped;
char ignoreTimer;
} WBalloon;
#define TOP 0
#define BOTTOM 1
@ -107,354 +87,12 @@ static int getMaxStringWidth(WMFont *font, const char *text)
return w;
}
static void drawMultiLineString(WMScreen *scr, Pixmap pixmap, WMColor *color,
WMFont *font, int x, int y, const char *text, int len)
{
const char *p = text;
const char *pb = p;
int l = 0, pos = 0;
int height = WMFontHeight(font);
while (*p && p - text < len) {
if (*p == '\n') {
WMDrawString(scr, pixmap, color, font, x, y + l * height, pb, pos);
l++;
pos = 0;
pb = p + 1;
} else {
pos++;
}
p++;
}
if (pos > 0)
WMDrawString(scr, pixmap, color, font, x, y + l * height, pb, pos);
}
#ifdef SHAPED_BALLOON
#define SPACE 12
static void drawBalloon(WScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, int h, int side)
{
GC bgc = scr->balloon->monoGC;
GC gc = scr->draw_gc;
int rad = h * 3 / 10;
XPoint pt[3], ipt[3];
int w1;
/* outline */
XSetForeground(dpy, bgc, 1);
XFillArc(dpy, bitmap, bgc, x, y, rad, rad, 90 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x, y + h - 1 - rad, rad, rad, 180 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y, rad, rad, 0 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y + h - 1 - rad, rad, rad, 270 * 64, 90 * 64);
XFillRectangle(dpy, bitmap, bgc, x, y + rad / 2, w, h - rad);
XFillRectangle(dpy, bitmap, bgc, x + rad / 2, y, w - rad, h);
/* interior */
XSetForeground(dpy, gc, scr->white_pixel);
XFillArc(dpy, pix, gc, x + 1, y + 1, rad, rad, 90 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + 1, y + h - 2 - rad, rad, rad, 180 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + w - 2 - rad, y + 1, rad, rad, 0 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + w - 2 - rad, y + h - 2 - rad, rad, rad, 270 * 64, 90 * 64);
XFillRectangle(dpy, pix, gc, x + 1, y + 1 + rad / 2, w - 2, h - 2 - rad);
XFillRectangle(dpy, pix, gc, x + 1 + rad / 2, y + 1, w - 2 - rad, h - 2);
if (side & BOTTOM) {
pt[0].y = y + h - 1;
pt[1].y = y + h - 1 + SPACE;
pt[2].y = y + h - 1;
ipt[0].y = pt[0].y - 1;
ipt[1].y = pt[1].y - 1;
ipt[2].y = pt[2].y - 1;
} else {
pt[0].y = y;
pt[1].y = y - SPACE;
pt[2].y = y;
ipt[0].y = pt[0].y + 1;
ipt[1].y = pt[1].y + 1;
ipt[2].y = pt[2].y + 1;
}
/*w1 = WMAX(h, 24); */
w1 = WMAX(h, 21);
if (side & RIGHT) {
pt[0].x = x + w - w1 + 2 * w1 / 16;
pt[1].x = x + w - w1 + 11 * w1 / 16;
pt[2].x = x + w - w1 + 7 * w1 / 16;
ipt[0].x = x + 1 + w - w1 + 2 * (w1 - 1) / 16;
ipt[1].x = x + 1 + w - w1 + 11 * (w1 - 1) / 16;
ipt[2].x = x + 1 + w - w1 + 7 * (w1 - 1) / 16;
/*ipt[0].x = pt[0].x+1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x; */
} else {
pt[0].x = x + w1 - 2 * w1 / 16;
pt[1].x = x + w1 - 11 * w1 / 16;
pt[2].x = x + w1 - 7 * w1 / 16;
ipt[0].x = x - 1 + w1 - 2 * (w1 - 1) / 16;
ipt[1].x = x - 1 + w1 - 11 * (w1 - 1) / 16;
ipt[2].x = x - 1 + w1 - 7 * (w1 - 1) / 16;
/*ipt[0].x = pt[0].x-1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x; */
}
XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, pix, gc, ipt, 3, Convex, CoordModeOrigin);
/* fix outline */
XSetForeground(dpy, gc, scr->black_pixel);
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
if (side & RIGHT) {
pt[0].x++;
pt[2].x--;
} else {
pt[0].x--;
pt[2].x++;
}
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
}
static Pixmap makePixmap(WScreen *scr, int width, int height, int side, Pixmap *mask)
{
WBalloon *bal = scr->balloon;
Pixmap bitmap;
Pixmap pixmap;
int x, y;
bitmap = XCreatePixmap(dpy, scr->root_win, width + SPACE, height + SPACE, 1);
if (!bal->monoGC)
bal->monoGC = XCreateGC(dpy, bitmap, 0, NULL);
XSetForeground(dpy, bal->monoGC, 0);
XFillRectangle(dpy, bitmap, bal->monoGC, 0, 0, width + SPACE, height + SPACE);
pixmap = XCreatePixmap(dpy, scr->root_win, width + SPACE, height + SPACE, scr->w_depth);
XSetForeground(dpy, scr->draw_gc, scr->black_pixel);
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width + SPACE, height + SPACE);
if (side & BOTTOM)
y = 0;
else
y = SPACE;
x = 0;
drawBalloon(scr, bitmap, pixmap, x, y, width, height, side);
*mask = bitmap;
return pixmap;
}
static void showText(WScreen *scr, int x, int y, int h, int w, const char *text)
{
int width;
int height;
Pixmap pixmap;
Pixmap mask;
WMFont *font = scr->info_text_font;
int side = 0;
int ty;
int bx, by;
if (scr->balloon->contents)
wm_backend->pixmap_free((unsigned long)scr->balloon->contents);
width = getMaxStringWidth(font, text) + 16;
height = countLines(text) * WMFontHeight(font) + 4;
if (height < 16)
height = 16;
if (width < height)
width = height;
if (x + width > scr->scr_width) {
side = RIGHT;
bx = x - width + w / 2;
if (bx < 0)
bx = 0;
} else {
side = LEFT;
bx = x + w / 2;
}
if (bx + width > scr->scr_width)
bx = scr->scr_width - width;
if (y - (height + SPACE) < 0) {
side |= TOP;
by = y + h - 1;
ty = SPACE;
} else {
side |= BOTTOM;
by = y - (height + SPACE);
ty = 0;
}
pixmap = makePixmap(scr, width, height, side, &mask);
drawMultiLineString(scr->wmscreen, pixmap, scr->black, font, 8, ty + 2, text, strlen(text));
wm_backend->window_set_background_pixmap((WNativeWindow)scr->balloon->window, (unsigned long)pixmap);
scr->balloon->contents = pixmap;
wm_backend->window_resize((WNativeWindow)scr->balloon->window, width, height + SPACE);
wm_backend->shape_combine_mask(scr->balloon->window, (WNativeWindow)mask);
wm_backend->pixmap_free((unsigned long)mask);
wm_backend->window_move((WNativeWindow)scr->balloon->window, bx, by);
wm_backend->window_map_raised((WNativeWindow)scr->balloon->window);
scr->balloon->mapped = 1;
}
#else /* !SHAPED_BALLOON */
static void showText(WScreen *scr, int x, int y, int h, int w, const char *text)
{
int width;
int height;
Pixmap pixmap;
WMFont *font = scr->info_text_font;
if (scr->balloon->contents)
wm_backend->pixmap_free((unsigned long)scr->balloon->contents);
width = getMaxStringWidth(font, text) + 8;
/*width = WMWidthOfString(font, text, strlen(text))+8; */
height = countLines(text) * WMFontHeight(font) + 4;
if (x < 0)
x = 0;
else if (x + width > scr->scr_width - 1)
x = scr->scr_width - width;
if (y - height - 2 < 0) {
y += h;
if (y < 0)
y = 0;
} else {
y -= height + 2;
}
if (scr->window_title_texture[0])
XSetForeground(dpy, scr->draw_gc, scr->window_title_texture[0]->any.color.pixel);
else
XSetForeground(dpy, scr->draw_gc, scr->light_pixel);
pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth);
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height);
drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0], font, 4, 2, text, strlen(text));
wm_backend->window_resize((WNativeWindow)scr->balloon->window, width, height);
wm_backend->window_move((WNativeWindow)scr->balloon->window, x, y);
wm_backend->window_set_background_pixmap((WNativeWindow)scr->balloon->window, (unsigned long)pixmap);
wm_backend->window_clear((WNativeWindow)scr->balloon->window);
wm_backend->window_map_raised((WNativeWindow)scr->balloon->window);
scr->balloon->contents = pixmap;
scr->balloon->mapped = 1;
}
#endif /* !SHAPED_BALLOON */
static void show_minipreview(WScreen *scr, int x, int y, const char *title, Pixmap mini_preview)
{
Pixmap pixmap;
WMFont *font = scr->info_text_font;
int width, height;
int titleHeight;
char *shortenTitle;
if (scr->balloon->contents)
wm_backend->pixmap_free((unsigned long)scr->balloon->contents);
width = wPreferences.minipreview_size;
height = wPreferences.minipreview_size;
if (wPreferences.miniwin_title_balloon) {
shortenTitle = ShrinkString(font, title, width - MINIPREVIEW_BORDER * 2);
titleHeight = countLines(shortenTitle) * WMFontHeight(font) + 4;
height += titleHeight;
} else {
shortenTitle = NULL;
titleHeight = 0;
}
if (x < 0)
x = 0;
else if (x + width > scr->scr_width - 1)
x = scr->scr_width - width - 1;
if (y - height - 2 < 0) {
y += wPreferences.icon_size;
if (y < 0)
y = 0;
} else {
y -= height + 2;
}
if (scr->window_title_texture[0])
XSetForeground(dpy, scr->draw_gc, scr->window_title_texture[0]->any.color.pixel);
else
XSetForeground(dpy, scr->draw_gc, scr->light_pixel);
pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth);
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height);
if (shortenTitle != NULL) {
drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0], font,
MINIPREVIEW_BORDER, MINIPREVIEW_BORDER, shortenTitle, strlen(shortenTitle));
wfree(shortenTitle);
}
XCopyArea(dpy, mini_preview, pixmap, scr->draw_gc,
0, 0, (wPreferences.minipreview_size - 1 - MINIPREVIEW_BORDER * 2),
(wPreferences.minipreview_size - 1 - MINIPREVIEW_BORDER * 2),
MINIPREVIEW_BORDER, MINIPREVIEW_BORDER + titleHeight);
wm_backend->shape_combine_mask(scr->balloon->window, WNATIVE_NONE);
wm_backend->window_resize((WNativeWindow)scr->balloon->window, width, height);
wm_backend->window_move((WNativeWindow)scr->balloon->window, x, y);
wm_backend->window_set_background_pixmap((WNativeWindow)scr->balloon->window, (unsigned long)pixmap);
wm_backend->window_clear((WNativeWindow)scr->balloon->window);
wm_backend->window_map_raised((WNativeWindow)scr->balloon->window);
scr->balloon->contents = pixmap;
scr->balloon->mapped = 1;
}
static void showBalloon(WScreen *scr)
{
int x, y;
Window foow;
unsigned foo, w;
scr->balloon->timer = NULL;
scr->balloon->ignoreTimer = 1;
if (!XGetGeometry(dpy, scr->balloon->objectWindow, &foow, &x, &y, &w, &foo, &foo, &foo)) {
scr->balloon->prevType = 0;
return;
}
if (wPreferences.miniwin_preview_balloon && scr->balloon->mini_preview != None)
/* used to display either the mini-preview alone or the mini-preview with the title */
show_minipreview(scr, x, y, scr->balloon->text, scr->balloon->mini_preview);
else
showText(scr, x, y, scr->balloon->h, w, scr->balloon->text);
wm_backend->balloon_show(scr, scr->balloon);
}
static void frameBalloon(WObjDescriptor *object)
@ -573,28 +211,7 @@ static void appiconBalloon(WObjDescriptor *object)
void wBalloonInitialize(WScreen *scr)
{
WBalloon *bal;
XSetWindowAttributes attribs;
unsigned long vmask;
bal = wmalloc(sizeof(WBalloon));
scr->balloon = bal;
vmask = CWSaveUnder | CWOverrideRedirect | CWColormap | CWBackPixel | CWBorderPixel;
attribs.save_under = True;
attribs.override_redirect = True;
attribs.colormap = scr->w_colormap;
attribs.background_pixel = scr->icon_back_texture->normal.pixel;
attribs.border_pixel = 0; /* do not care */
bal->window = XCreateWindow(dpy, scr->root_win, 1, 1, 10, 10, 1,
scr->w_depth, CopyFromParent, scr->w_visual, vmask, &attribs);
#if 0
/* select EnterNotify to so that the balloon will be unmapped
* when the pointer is moved over it */
wm_backend->window_select_events((WNativeWindow)bal->window, EnterWindowMask);
#endif
wm_backend->balloon_init(scr);
}
void wBalloonEnteredObject(WScreen *scr, WObjDescriptor *object)

View File

@ -21,6 +21,22 @@
#ifndef _BALLOON_H_
#define _BALLOON_H_
typedef struct _WBalloon {
Window window;
#ifdef SHAPED_BALLOON
GC monoGC;
#endif
int prevType;
Window objectWindow;
char *text;
int h;
WMHandlerID timer;
Pixmap contents;
Pixmap mini_preview;
char mapped;
char ignoreTimer;
} WBalloon;
void wBalloonInitialize(WScreen *scr);
void wBalloonEnteredObject(WScreen *scr, WObjDescriptor *object);

View File

@ -304,69 +304,8 @@ static WMArray *getSelected(WDock *dock)
static void paintClipButtons(WAppIcon *clipIcon, Bool lpushed, Bool rpushed)
{
Window win = clipIcon->icon->core->window;
WScreen *scr = clipIcon->icon->core->screen_ptr;
XPoint p[4];
int pt = CLIP_BUTTON_SIZE * ICON_SIZE / 64;
int tp = ICON_SIZE - pt;
int as = pt - 15; /* 15 = 5+5+5 */
GC gc = scr->draw_gc; /* maybe use WMColorGC() instead here? */
WMColor *color;
color = scr->clip_title_color[CLIP_NORMAL];
XSetForeground(dpy, gc, WMColorPixel(color));
if (rpushed) {
p[0].x = tp + 1;
p[0].y = 1;
p[1].x = ICON_SIZE - 2;
p[1].y = 1;
p[2].x = ICON_SIZE - 2;
p[2].y = pt - 1;
} else if (lpushed) {
p[0].x = 1;
p[0].y = tp;
p[1].x = pt;
p[1].y = ICON_SIZE - 2;
p[2].x = 1;
p[2].y = ICON_SIZE - 2;
}
if (lpushed || rpushed) {
XSetForeground(dpy, scr->draw_gc, scr->white_pixel);
XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin);
XSetForeground(dpy, scr->draw_gc, scr->black_pixel);
}
/* top right arrow */
p[0].x = p[3].x = ICON_SIZE - 5 - as;
p[0].y = p[3].y = 5;
p[1].x = ICON_SIZE - 6;
p[1].y = 5;
p[2].x = ICON_SIZE - 6;
p[2].y = 4 + as;
if (rpushed) {
XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, scr->draw_gc, p, 4, CoordModeOrigin);
} else {
XFillPolygon(dpy, win, gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, gc, p, 4, CoordModeOrigin);
}
/* bottom left arrow */
p[0].x = p[3].x = 5;
p[0].y = p[3].y = ICON_SIZE - 5 - as;
p[1].x = 5;
p[1].y = ICON_SIZE - 6;
p[2].x = 4 + as;
p[2].y = ICON_SIZE - 6;
if (lpushed) {
XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, scr->draw_gc, p, 4, CoordModeOrigin);
} else {
XFillPolygon(dpy, win, gc, p, 3, Convex, CoordModeOrigin);
XDrawLines(dpy, win, gc, p, 4, CoordModeOrigin);
}
wm_backend->clip_icon_paint(clipIcon);
(void)lpushed; (void)rpushed;
}
RImage *wClipMakeTile(RImage *normalTile)
@ -1411,45 +1350,7 @@ void wDockDestroy(WDock *dock)
void wClipIconPaint(WAppIcon *aicon)
{
WScreen *scr = aicon->icon->core->screen_ptr;
WWorkspace *workspace = scr->workspaces[scr->current_workspace];
WMColor *color;
Window win = aicon->icon->core->window;
int length, nlength;
char *ws_name, ws_number[sizeof scr->current_workspace * CHAR_BIT / 3 + 1];
int ty, tx;
wm_backend->icon_paint(aicon->icon);
length = strlen(workspace->name);
ws_name = wmalloc(length + 1);
snprintf(ws_name, length + 1, "%s", workspace->name);
snprintf(ws_number, sizeof ws_number, "%u", scr->current_workspace + 1);
nlength = strlen(ws_number);
if (wPreferences.flags.noclip || !workspace->clip->collapsed)
color = scr->clip_title_color[CLIP_NORMAL];
else
color = scr->clip_title_color[CLIP_COLLAPSED];
ty = ICON_SIZE - WMFontHeight(scr->clip_title_font) - 3;
tx = CLIP_BUTTON_SIZE * ICON_SIZE / 64;
if(wPreferences.show_clip_title)
WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, ty, ws_name, length);
tx = (ICON_SIZE / 2 - WMWidthOfString(scr->clip_title_font, ws_number, nlength)) / 2;
WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, 2, ws_number, nlength);
wfree(ws_name);
if (aicon->launching)
XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc,
0, 0, wPreferences.icon_size, wPreferences.icon_size);
paintClipButtons(aicon, aicon->dock->lclip_button_pushed, aicon->dock->rclip_button_pushed);
wm_backend->clip_icon_paint(aicon);
}
static void clipIconExpose(WObjDescriptor *desc, WBackendEvent *event)
@ -3706,9 +3607,10 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event)
Pixmap ghost = None;
int superfluous = wPreferences.superfluous; /* we catch it to avoid problems */
if (XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime) != GrabSuccess)
if (!wm_backend->pointer_grab((WNativeWindow)aicon->icon->core->window, WNATIVE_NONE, ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, WCUR_NORMAL, True, 0))
wwarning("pointer grab failed for dock move");
if (dock->type == WM_DRAWER) {
@ -3716,7 +3618,7 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event)
wins[0] = icon->core->window;
wins[1] = scr->dock_shadow;
wm_backend->stacking_restack((WNativeWindow *)wins, 2);
XMoveResizeWindow(dpy, scr->dock_shadow, aicon->x_pos, aicon->y_pos,
wm_backend->frame_configure((WNativeWindow)scr->dock_shadow, aicon->x_pos, aicon->y_pos,
ICON_SIZE, ICON_SIZE);
if (superfluous) {
if (icon->pixmap!=None)
@ -3752,9 +3654,7 @@ static void handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event)
if (!grabbed) {
if (abs(ofs_x - ev.u.motion.x) >= MOVE_THRESHOLD
|| abs(ofs_y - ev.u.motion.y) >= MOVE_THRESHOLD) {
XChangeActivePointerGrab(dpy, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask,
wPreferences.cursor[WCUR_MOVE], CurrentTime);
wm_backend->pointer_change_cursor(WCUR_MOVE); // was XChangeActivePointerGrab
grabbed = 1;
}
break;
@ -4058,9 +3958,10 @@ static void iconMouseDown(WObjDescriptor *desc, WBackendEvent *event)
wClipMakeIconOmnipresent(aicon, !aicon->omnipresent);
} else if (event->u.button.button == Button3) {
if (event->u.button.send_event &&
XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask
| ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
!wm_backend->pointer_grab((WNativeWindow)aicon->icon->core->window, WNATIVE_NONE, ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, WCUR_NORMAL, True, 0)) {
wwarning("pointer grab failed for dockicon menu");
return;
}
@ -4126,18 +4027,8 @@ static void clipLeave(WDock *dock)
if (dock == NULL)
return;
if (XCheckTypedEvent(dpy, EnterNotify, &event) != False) {
if ((desc = wm_backend->context_find(event.xcrossing.window, WM_CTX_CLIENT_WIN)) != NULL
&& desc->parent_type == WCLASS_DOCK_ICON
&& ((WAppIcon *) desc->parent)->dock == dock) {
/* We haven't left the dock/clip/drawer yet */
XPutBackEvent(dpy, &event);
return;
}
XPutBackEvent(dpy, &event);
} else {
/* We entered a withdrawn window, so we're still in Clip */
if (!wm_backend->event_check_enter_leave(dock)) {
/* We haven't left the dock/clip/drawer yet */
return;
}
@ -4431,7 +4322,7 @@ static int addADrawer(WScreen *scr)
drawer->icon_array[0]->yindex = 0;
drawer->icon_array[0]->x_pos = drawer->x_pos;
drawer->icon_array[0]->y_pos = drawer->y_pos;
XMoveWindow(dpy, drawer->icon_array[0]->icon->core->window,
wm_backend->window_move(drawer->icon_array[0]->icon->core->window,
drawer->icon_array[0]->x_pos, drawer->icon_array[0]->y_pos);
return 0;
@ -4533,38 +4424,7 @@ static void removeDrawerCallback(WMenu *menu, WMenuEntry *entry)
void wDrawerIconPaint(WAppIcon *dicon)
{
Window win = dicon->icon->core->window;
WScreen *scr = dicon->icon->core->screen_ptr;
XPoint p[4];
GC gc = scr->draw_gc;
WMColor *color;
wm_backend->icon_paint(dicon->icon);
if (!dicon->dock->collapsed)
color = scr->clip_title_color[CLIP_NORMAL];
else
color = scr->clip_title_color[CLIP_COLLAPSED];
XSetForeground(dpy, gc, WMColorPixel(color));
if (dicon->dock->on_right_side) {
p[0].x = p[3].x = 10;
p[0].y = p[3].y = ICON_SIZE / 2 - 5;
p[1].x = 10;
p[1].y = ICON_SIZE / 2 + 5;
p[2].x = 5;
p[2].y = ICON_SIZE / 2;
}
else {
p[0].x = p[3].x = ICON_SIZE-1 - 10;
p[0].y = p[3].y = ICON_SIZE / 2 - 5;
p[1].x = ICON_SIZE-1 - 10;
p[1].y = ICON_SIZE / 2 + 5;
p[2].x = ICON_SIZE-1 - 5;
p[2].y = ICON_SIZE / 2;
}
XFillPolygon(dpy, win, gc, p,3,Convex,CoordModeOrigin);
XDrawLines(dpy, win, gc, p,4,CoordModeOrigin);
wm_backend->drawer_icon_paint(dicon);
}