diff --git a/src/backend/backend.h b/src/backend/backend.h index cf89b1a..52af54a 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -1748,6 +1748,9 @@ typedef struct WMBackend { int (*window_exists)(WNativeWindow win); void (*window_get_colormap)(WNativeWindow win, unsigned long *colormap_out); WNativeWindow (*pointer_query_window)(WNativeWindow root); + void (*dialog_paint_icon)(unsigned long drawable, void *back_color, + void *pixmap, WScreen *scr, + int x, int y, int width, int height); } WMBackend; diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 41adf2c..f33fd73 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -6269,6 +6269,8 @@ static void wl_noop_client_send_event(WNativeWindow win, void *d) { (void)win; ( static int wl_noop_window_exists(WNativeWindow win) { (void)win; return 1; } static void wl_noop_window_get_colormap(WNativeWindow win, unsigned long *c) { (void)win; (void)c; } static WNativeWindow wl_noop_pointer_query_window(WNativeWindow root) { (void)root; return WNATIVE_NONE; } +static void wl_noop_dialog_paint_icon(unsigned long d, void *b, void *p, WScreen *s, + int x, int y, int w, int h) { (void)d;(void)b;(void)p;(void)s;(void)x;(void)y;(void)w;(void)h; } /* ------------------------------------------------------------------ */ /* vtable */ @@ -6521,4 +6523,5 @@ const WMBackend wl_backend = { .window_exists = wl_noop_window_exists, .window_get_colormap = wl_noop_window_get_colormap, .pointer_query_window = wl_noop_pointer_query_window, + .dialog_paint_icon = wl_noop_dialog_paint_icon, }; diff --git a/src/backend/x11/x11_backend.c b/src/backend/x11/x11_backend.c index 9e3bd24..0020e80 100644 --- a/src/backend/x11/x11_backend.c +++ b/src/backend/x11/x11_backend.c @@ -3248,6 +3248,28 @@ static WNativeWindow x11_pointer_query_window(WNativeWindow root) return (WNativeWindow)win; return WNATIVE_NONE; } + +static void x11_dialog_paint_icon(unsigned long drawable, void *back_color, + void *pixmap_ptr, WScreen *scr, + int x, int y, int width, int height) +{ + Drawable d = (Drawable)drawable; + WMColor *back = (WMColor *)back_color; + WMPixmap *pixmap = (WMPixmap *)pixmap_ptr; + WMSize size; + GC gc = scr->draw_gc; + GC copygc = scr->copy_gc; + + XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height); + XSetClipMask(dpy, gc, None); + XDrawLine(dpy, d, WMColorGC(scr->white), x, y + height - 1, x + width, y + height - 1); + size = WMGetPixmapSize(pixmap); + XSetClipMask(dpy, copygc, WMGetPixmapMaskXID(pixmap)); + XSetClipOrigin(dpy, copygc, x + (width - size.width) / 2, y + 2); + XCopyArea(dpy, WMGetPixmapXID(pixmap), d, copygc, 0, 0, + size.width > 100 ? 100 : size.width, size.height > 64 ? 64 : size.height, + x + (width - size.width) / 2, y + 2); +} /* -------------------------------------------------------------------- */ /* Client operations (Phase 80) */ /* -------------------------------------------------------------------- */ @@ -4078,6 +4100,7 @@ const WMBackend x11_backend = { .window_exists = x11_window_exists, .window_get_colormap = x11_window_get_colormap, .pointer_query_window = x11_pointer_query_window, + .dialog_paint_icon = x11_dialog_paint_icon, }; /* diff --git a/src/dialog.c b/src/dialog.c index 9e2fc38..2d2db8c 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -80,9 +80,9 @@ int wMessageDialog(WScreen *scr, const char *title, const char *message, const c pwidth = WMWidgetWidth(panel->win); pheight = WMWidgetHeight(panel->win); - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0); + parent = (Window)wm_backend->fake_leader_create(scr); - XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); + wm_backend->client_reparent((WNativeWindow)WMWidgetXID(panel->win), (WNativeWindow)parent, 0, 0); center = getCenter(scr, pwidth, pheight); wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, pwidth, pheight); @@ -138,9 +138,9 @@ int wExitDialog(WScreen *scr, const char *title, const char *message, const char WMRealizeWidget(saveSessionBtn); WMMapWidget(saveSessionBtn); - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0); + parent = (Window)wm_backend->fake_leader_create(scr); - XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); + wm_backend->client_reparent((WNativeWindow)WMWidgetXID(panel->win), (WNativeWindow)parent, 0, 0); center = getCenter(scr, pwidth, pheight); wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, pwidth, pheight); @@ -358,7 +358,7 @@ static void handleHistoryKeyPress(WMEvent * event, void *clientData) WMInputPanelWithHistory *p = (WMInputPanelWithHistory *) clientData; KeySym ksym; - { XEvent *_xev = (XEvent *)event->_x11_raw; ksym = _xev ? XLookupKeysym(&_xev->xkey, 0) : NoSymbol; } + ksym = (KeySym)wm_backend->keysym_from_keycode(event->u.key.keycode, 0); switch (ksym) { case WM_KEY_UP: @@ -447,10 +447,10 @@ int wAdvancedInputDialog(WScreen *scr, const char *title, const char *message, c pwidth = WMWidgetWidth(p->panel->win); pheight = WMWidgetHeight(p->panel->win); - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0); + parent = (Window)wm_backend->fake_leader_create(scr); wm_backend->window_select_events((WNativeWindow)parent, KeyPressMask | KeyReleaseMask); - XReparentWindow(dpy, WMWidgetXID(p->panel->win), parent, 0, 0); + wm_backend->client_reparent((WNativeWindow)WMWidgetXID(p->panel->win), (WNativeWindow)parent, 0, 0); center = getCenter(scr, pwidth, pheight); wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, pwidth, pheight); @@ -503,10 +503,10 @@ int wInputDialog(WScreen *scr, const char *title, const char *message, char **te pwidth = WMWidgetWidth(panel->win); pheight = WMWidgetHeight(panel->win); - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0); + parent = (Window)wm_backend->fake_leader_create(scr); wm_backend->window_select_events((WNativeWindow)parent, KeyPressMask | KeyReleaseMask); - XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); + wm_backend->client_reparent((WNativeWindow)WMWidgetXID(panel->win), (WNativeWindow)parent, 0, 0); center = getCenter(scr, pwidth, pheight); wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, pwidth, pheight); @@ -773,19 +773,7 @@ static void drawIconProc(WMList * lPtr, int index, Drawable d, char *text, int s return; } - XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height); - - XSetClipMask(dpy, gc, None); - /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54); */ - XDrawLine(dpy, d, WMColorGC(scr->white), x, y + height - 1, x + width, y + height - 1); - - size = WMGetPixmapSize(pixmap); - - XSetClipMask(dpy, copygc, WMGetPixmapMaskXID(pixmap)); - XSetClipOrigin(dpy, copygc, x + (width - size.width) / 2, y + 2); - XCopyArea(dpy, WMGetPixmapXID(pixmap), d, copygc, 0, 0, - size.width > 100 ? 100 : size.width, size.height > 64 ? 64 : size.height, - x + (width - size.width) / 2, y + 2); + wm_backend->dialog_paint_icon(d, back, pixmap, scr, x, y, width, height); { int i, j; @@ -862,7 +850,7 @@ static void keyPressHandler(WMEvent * event, void *data) return; buffer[0] = 0; - { XEvent *_xev = (XEvent *)event->_x11_raw; if (_xev) XLookupString(&_xev->xkey, buffer, sizeof(buffer), &ksym, NULL); } + ksym = (KeySym)wm_backend->keysym_from_keycode(event->u.key.keycode, 0); iidx = WMGetListSelectedItemRow(panel->iconList); didx = WMGetListSelectedItemRow(panel->dirList); @@ -1033,9 +1021,9 @@ Bool wIconChooserDialog(WScreen *scr, char **file, const char *instance, const c WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0); + parent = (Window)wm_backend->fake_leader_create(scr); - XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); + wm_backend->client_reparent((WNativeWindow)WMWidgetXID(panel->win), (WNativeWindow)parent, 0, 0); { static const char *prefix = NULL; @@ -1485,9 +1473,9 @@ void wShowInfoPanel(WScreen *scr) WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0); + parent = (Window)wm_backend->fake_leader_create(scr); - XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); + wm_backend->client_reparent((WNativeWindow)WMWidgetXID(panel->win), (WNativeWindow)parent, 0, 0); WMMapWidget(panel->win); @@ -1592,8 +1580,8 @@ void wShowLegalPanel(WScreen *scr) WMMapSubwidgets(panel->win); WMMapSubwidgets(panel->frame); - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, pwidth, pheight, 0, 0, 0); - XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); + parent = (Window)wm_backend->fake_leader_create(scr); + wm_backend->client_reparent((WNativeWindow)WMWidgetXID(panel->win), (WNativeWindow)parent, 0, 0); center = getCenter(scr, pwidth, pheight); wwin = wManageInternalWindow(scr, parent, None, _("Legal"), center.x, center.y, pwidth, pheight); @@ -1800,7 +1788,7 @@ int wShowCrashingDialogPanel(int whatSig) WMMapWidget(panel->win); - XSetInputFocus(dpy, WMWidgetXID(panel->win), RevertToParent, CurrentTime); + wm_backend->focus_set((WNativeWindow)WMWidgetXID(panel->win), RevertToParent, CurrentTime); while (!panel->done) { WMEvent event;