diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 4cb5842..a964f86 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -28,16 +28,6 @@ #include #include -/* The wmaker compositor uses X11 types (XContext, XFontStruct, XColor, - * IconicState, etc.) extensively in its headers and sources, regardless - * of whether the compositor's runtime backend is X11 or Wayland. Bring - * in the X11 headers explicitly so we don't depend on WINGs.h to do it - * transitively (which it no longer does once libWINGs has been split). */ -#include -#include -#include -#include - /* class codes */ typedef enum { @@ -528,10 +518,10 @@ extern struct wmaker_global_variables { /* Tracking of X events timestamps */ struct { /* ts of the last event we received */ - Time last_event; + WMNativeTime last_event; /* ts on the last time we did XSetInputFocus() */ - Time focus_change; + WMNativeTime focus_change; } timestamp; @@ -613,11 +603,13 @@ extern struct wmaker_global_variables { } atom; - /* X Contexts */ + /* Per-screen context-table identifiers (one per WContextKey). + * Allocated by the backend (X11: XUniqueContext; Wayland: + * sequential integers). Backend-neutral integer ID. */ struct { - XContext client_win; - XContext app_win; - XContext stack; + WContextID client_win; + WContextID app_win; + WContextID stack; } context; /* X Extensions */ diff --git a/src/actions.c b/src/actions.c index 7ad0dfa..a914482 100644 --- a/src/actions.c +++ b/src/actions.c @@ -268,7 +268,7 @@ void wShadeWindow(WWindow *wwin) wWindowSynthConfigureNotify(wwin); /* - wClientSetState(wwin, IconicState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_ICONIC, WM_NATIVE_NONE); */ WMPostNotificationName(WMNChangedState, wwin, "shade"); @@ -1322,7 +1322,7 @@ static void unmapTransientsFor(WWindow *wwin) /* if (!tmp->flags.shaded) */ - wClientSetState(tmp, IconicState, WM_NATIVE_NONE); + wClientSetState(tmp, WM_STATE_ICONIC, WM_NATIVE_NONE); WMPostNotificationName(WMNChangedState, tmp, "iconify-transient"); } @@ -1349,7 +1349,7 @@ static void mapTransientsFor(WWindow *wwin) /* if (!tmp->flags.shaded) */ - wClientSetState(tmp, NormalState, WM_NATIVE_NONE); + wClientSetState(tmp, WM_STATE_NORMAL, WM_NATIVE_NONE); WMPostNotificationName(WMNChangedState, tmp, "iconify-transient"); } @@ -1485,9 +1485,9 @@ void wIconifyWindow(WWindow *wwin) wm_backend->event_sync(0); if (wPreferences.disable_miniwindows || wwin->flags.net_handle_icon) - wClientSetState(wwin, IconicState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_ICONIC, WM_NATIVE_NONE); else - wClientSetState(wwin, IconicState, wwin->icon->icon_win); + wClientSetState(wwin, WM_STATE_ICONIC, wwin->icon->icon_win); flushExpose(); #ifdef USE_ANIMATIONS @@ -1627,7 +1627,7 @@ void wDeiconifyWindow(WWindow *wwin) wRaiseFrame(wwin->frame->core); } if (!wwin->flags.shaded) - wClientSetState(wwin, NormalState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_NORMAL, WM_NATIVE_NONE); mapTransientsFor(wwin); } @@ -1692,7 +1692,7 @@ static void hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int a wwin->flags.hidden = 1; wWindowUnmap(wwin); - wClientSetState(wwin, IconicState, icon->icon_win); + wClientSetState(wwin, WM_STATE_ICONIC, icon->icon_win); flushExpose(); #ifdef USE_ANIMATIONS @@ -1897,7 +1897,7 @@ static void unhideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int if (wwin->screen_ptr->current_workspace == WIN_WORKSPACE(wwin)) { wm_backend->window_map(wwin->client_win); wm_backend->window_map(wwin->frame->core->window); - wClientSetState(wwin, NormalState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_NORMAL, WM_NATIVE_NONE); wwin->flags.mapped = 1; wRaiseFrame(wwin->frame->core); } diff --git a/src/appicon.c b/src/appicon.c index 56d146d..9e83491 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -1139,7 +1139,7 @@ static void create_appicon_from_dock(WWindow *wwin, WApplication *wapp, WNativeW wapp->app_icon->running = 1; wapp->app_icon->icon->owner = mainw; - if (mainw->wm_hints && (mainw->wm_hints->flags & IconWindowHint)) + if (mainw->wm_hints && (mainw->wm_hints->flags & WMH_ICON_WINDOW_HINT)) wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window; /* Update the icon images */ diff --git a/src/backend/backend.h b/src/backend/backend.h index 4c3f44c..c96684a 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -1318,7 +1318,7 @@ typedef struct WMBackend { * X11: XAllocColor(dpy, scr->w_colormap, color). * Wayland: no-op (colours stored as direct pixel values). */ - void (*texture_alloc_color)(WScreen *scr, XColor *color); + void (*texture_alloc_color)(WScreen *scr, WMColorRGB *color); /* * Free colour cells previously allocated with texture_alloc_color. @@ -1657,7 +1657,7 @@ typedef struct WMBackend { * Wayland: returns False. */ int (*get_color_for_colormap)(unsigned long colormap, - const char *color_name, XColor *color); + const char *color_name, WMColorRGB *color); /* * Free a previously allocated colour pixel. @@ -1801,7 +1801,7 @@ typedef struct WMBackend { unsigned int *nchildren_out); WScreen *(*screen_for_window)(WNativeWindow window); - int (*parse_color)(WScreen *scr, const char *name, XColor *color_out); + int (*parse_color)(WScreen *scr, const char *name, WMColorRGB *color_out); int (*cursor_create_from_files)(WScreen *scr, const char *bitmap_path, const char *mask_path, WMNativeCursor *cursor_out); void (*cursor_free)(WMNativeCursor cursor); diff --git a/src/backend/backend_types.h b/src/backend/backend_types.h index 2357481..c1c9730 100644 --- a/src/backend/backend_types.h +++ b/src/backend/backend_types.h @@ -169,7 +169,7 @@ typedef struct { /* WWMHints -- backend-neutral WM_HINTS (ICCCM window manager hints) */ /* ------------------------------------------------------------------ */ -/* Flag bits — ICCCM-standard values (same as X11's InputHint etc.) */ +/* Flag bits — ICCCM-standard values (same as X11's WMH_INPUT_HINT etc.) */ #define WMH_INPUT_HINT (1L << 0) #define WMH_STATE_HINT (1L << 1) #define WMH_ICON_PIXMAP_HINT (1L << 2) @@ -395,4 +395,126 @@ typedef struct { #define WCLIENT_UNVIEWABLE 1 #define WCLIENT_VIEWABLE 2 +/* ------------------------------------------------------------------ */ +/* WM_STATE_* — ICCCM client window state codes. */ +/* */ +/* Values match the X11 ICCCM constants WM_STATE_WITHDRAWN/WM_STATE_NORMAL/ */ +/* WM_STATE_ICONIC (0/1/3) so the WM_STATE property carries these IDs */ +/* unchanged on either backend. Used by wClientSetState() and by the */ +/* state-restore logic in actions.c, window.c, event.c, winspector.c. */ +/* ------------------------------------------------------------------ */ +#define WM_STATE_WITHDRAWN 0 +#define WM_STATE_NORMAL 1 +#define WM_STATE_ICONIC 3 + +/* ------------------------------------------------------------------ */ +/* WContextID — opaque per-screen context-table identifier. */ +/* */ +/* Allocated by the backend (X11 uses XUniqueContext(); Wayland uses */ +/* sequential integers) and stored in WScreen.context.{client_win, */ +/* app_win,stack}. Passed back to context_save/find/delete via the */ +/* WContextKey enum. Sized to match X11's XContext (which is int). */ +/* ------------------------------------------------------------------ */ +typedef int WContextID; + +/* ------------------------------------------------------------------ */ +/* X11 ConfigureWindow value-mask bits — used by ConfigureRequest */ +/* events and the WBackendVtable->window_configure path. Values match */ +/* X11's CWX..CWStackMode in . These are distinct from the */ +/* CWBackPixmap..CWCursor mask in WINGs/wnative.h (ChangeWindow- */ +/* Attributes); the two namespaces share bit values but live in */ +/* different code paths. */ +/* ------------------------------------------------------------------ */ +#ifndef CWX +# define CWX (1<<0) +# define CWY (1<<1) +# define CWWidth (1<<2) +# define CWHeight (1<<3) +# define CWBorderWidth (1<<4) +# define CWSibling (1<<5) +# define CWStackMode (1<<6) +#endif + +/* ------------------------------------------------------------------ */ +/* ICCCM win_gravity values — match X11's ForgetGravity..StaticGravity */ +/* in . Used by client.c when restoring window position from */ +/* WNormalHints and by wmaker for placement logic. */ +/* ------------------------------------------------------------------ */ +#ifndef ForgetGravity +# define ForgetGravity 0 +# define NorthWestGravity 1 +# define NorthGravity 2 +# define NorthEastGravity 3 +# define WestGravity 4 +# define CenterGravity 5 +# define EastGravity 6 +# define SouthWestGravity 7 +# define SouthGravity 8 +# define SouthEastGravity 9 +# define StaticGravity 10 +#endif + +/* ICCCM XSizeHints flag-bit aliases — use WNH_* names for new code, + * but keep the X.h-style names for compatibility with the existing + * wmaker compositor sources that have them all over. */ +#ifndef PMinSize +# define USPosition WNH_US_POSITION +# define USSize WNH_US_SIZE +# define PPosition WNH_P_POSITION +# define PSize WNH_P_SIZE +# define PMinSize WNH_P_MIN_SIZE +# define PMaxSize WNH_P_MAX_SIZE +# define PResizeInc WNH_P_RESIZE_INC +# define PAspect WNH_P_ASPECT +# define PBaseSize WNH_P_BASE_SIZE +# define PWinGravity WNH_P_WIN_GRAVITY +#endif + +/* X11 keysym sentinel — value matches XK_VoidSymbol's NoSymbol. */ +#ifndef NoSymbol +# define NoSymbol 0L +#endif + +/* X11 colormap-state constants from — used by the + * ColormapNotify handler in event.c. */ +#ifndef ColormapUninstalled +# define ColormapUninstalled 0 +# define ColormapInstalled 1 +#endif + +/* X11 zero-event-mask sentinel — passed to window_select_events() and + * XSendEvent. Matches X.h's NoEventMask. */ +#ifndef NoEventMask +# define NoEventMask 0L +#endif + +/* X11 XReadBitmapFile() return codes — used by defaults.c's bitmap + * cursor loader. Values match . */ +#ifndef BitmapSuccess +# define BitmapSuccess 0 +# define BitmapOpenFailed 1 +# define BitmapFileInvalid 2 +# define BitmapNoMemory 3 +#endif + +/* ------------------------------------------------------------------ */ +/* WMColorRGB — backend-neutral RGB color for texture/resource fields. */ +/* */ +/* Stores an allocated pixel value plus the original 16-bit RGB */ +/* components (matching XColor.{red,green,blue} resolution). The X11 */ +/* backend fills `pixel` from XAllocColor; Wayland backends pack the */ +/* same RGB into ARGB32. Policy code only reads/writes the components; */ +/* the pixel is consumed by backend draw helpers. */ +/* */ +/* Layout matches X11's XColor (pixel/red/green/blue/flags/pad) so */ +/* the X11 backend can memcpy() between WMColorRGB and XColor with no */ +/* per-field translation. */ +/* ------------------------------------------------------------------ */ +typedef struct WMColorRGB { + unsigned long pixel; + unsigned short red, green, blue; + char flags; /* X11 XColor.flags — DoRed|DoGreen|DoBlue */ + char pad; +} WMColorRGB; + #endif /* WM_BACKEND_TYPES_H_ */ diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 56c7da1..391c1c5 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -7562,15 +7562,13 @@ static void wl_screen_create_pixmaps(WScreen *scr) { (void)scr; } static void wl_screen_load_tech_font(WScreen *scr) { - if (!scr || scr->tech_draw_font) return; - /* Provide font metrics matching our embedded 5×9 bitmap font so that - * callers computing text height (ascent + descent) get correct values - * without crashing on a NULL pointer. */ - scr->tech_draw_font = calloc(1, sizeof(*scr->tech_draw_font)); - if (scr->tech_draw_font) { - scr->tech_draw_font->ascent = OVL_GH - 2; /* 7 */ - scr->tech_draw_font->descent = 2; - } + if (!scr) return; + /* Wayland mode has no native font handle (overlay text is drawn via + * the embedded 5×9 bitmap font in wl_overlay_draw_string). We just + * publish the metric fields so moveres.c gets correct geometry. */ + scr->tech_draw_font = NULL; + scr->tech_draw_font_ascent = OVL_GH - 2; /* 7 */ + scr->tech_draw_font_descent = 2; } static void wl_screen_show_mini_screenshot(WScreen *scr, RImage *img) { (void)scr; (void)img; } static RImage *wl_screen_capture_area(WScreen *scr) { (void)scr; return NULL; } @@ -7932,7 +7930,7 @@ wl_register_error_handlers(void) } static void -wl_texture_alloc_color(WScreen *scr, XColor *color) +wl_texture_alloc_color(WScreen *scr, WMColorRGB *color) { (void) scr; (void) color; } @@ -8150,11 +8148,11 @@ static void wl_client_set_state(WWindow *wwin, int state, WNativeWindow icon_win if (!v) return; switch (state) { - case 3: /* IconicState */ + case 3: /* WM_STATE_ICONIC */ if (v->scene_node) wlr_scene_node_set_enabled(&v->scene_node->node, false); break; - case 1: /* NormalState */ + case 1: /* WM_STATE_NORMAL */ if (v->scene_node) wlr_scene_node_set_enabled(&v->scene_node->node, true); break; @@ -8381,7 +8379,7 @@ static void wl_noop_restore_desktop(WScreen *scr) { (void)scr; } static void wl_noop_wipe_desktop(WScreen *scr) { (void)scr; } static int wl_get_color_for_colormap(unsigned long colormap, - const char *color_name, XColor *color) + const char *color_name, WMColorRGB *color) { unsigned int r, g, b; (void)colormap; @@ -8891,7 +8889,7 @@ static void wl_noop_query_tree(WNativeWindow root, WNativeWindow **children_out, static WScreen *wl_noop_screen_for_window(WNativeWindow window) { (void)window; return wScreenWithNumber(0); } -static int wl_parse_color(WScreen *scr, const char *name, XColor *color_out) +static int wl_parse_color(WScreen *scr, const char *name, WMColorRGB *color_out) { (void)scr; return wl_get_color_for_colormap(0, name, color_out); } static int wl_noop_cursor_create_from_files(WScreen *scr, const char *bitmap_path, const char *mask_path, WMNativeCursor *cursor_out) diff --git a/src/backend/x11/x11_backend.c b/src/backend/x11/x11_backend.c index bce1992..c743fd2 100644 --- a/src/backend/x11/x11_backend.c +++ b/src/backend/x11/x11_backend.c @@ -322,6 +322,13 @@ x11_screen_init_display(WScreen *scr, int screen_number) scr->w_win = scr->rcontext->drawable; scr->w_visual = scr->rcontext->visual; + /* Mirror the X11 Visual fields onto the backend-neutral slots so + * shared code (dialog.c crash panel) can render them without + * dereferencing a struct it can't see. */ + if (scr->rcontext->visual) { + scr->w_visual_id = scr->rcontext->visual->visualid; + scr->w_visual_class = scr->rcontext->visual->class; + } scr->w_depth = scr->rcontext->depth; scr->w_colormap = scr->rcontext->cmap; @@ -1100,13 +1107,13 @@ x11_overlay_draw_segments(WScreen *scr, WSegment *segs, int n) static int x11_overlay_text_width(WScreen *scr, const char *str, int n) { - return XTextWidth(scr->tech_draw_font, str, n); + return XTextWidth((XFontStruct *)scr->tech_draw_font, str, n); } static void x11_overlay_draw_string(WScreen *scr, int x, int y, const char *str, int n) { - XSetFont(dpy, scr->line_gc, scr->tech_draw_font->fid); + XSetFont(dpy, scr->line_gc, ((XFontStruct *)scr->tech_draw_font)->fid); XDrawString(dpy, WNW_TO_XID(scr->root_win), scr->line_gc, x, y, str, n); } @@ -1844,7 +1851,7 @@ void x11_screen_alloc_gcs(WScreen *scr) { XGCValues gcv; - XColor color; + WMColorRGB color; int gcm; scr->stipple_bitmap = XCreateBitmapFromData(dpy, WNW_TO_XID(scr->w_win), @@ -2121,10 +2128,16 @@ x11_screen_create_pixmaps(WScreen *scr) static void x11_screen_load_tech_font(WScreen *scr) { - scr->tech_draw_font = XLoadQueryFont(dpy, - "-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*"); - if (!scr->tech_draw_font) - scr->tech_draw_font = XLoadQueryFont(dpy, "fixed"); + XFontStruct *fs; + fs = XLoadQueryFont(dpy, + "-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*"); + if (!fs) + fs = XLoadQueryFont(dpy, "fixed"); + scr->tech_draw_font = fs; + if (fs) { + scr->tech_draw_font_ascent = fs->ascent; + scr->tech_draw_font_descent = fs->descent; + } } static RImage * @@ -2784,9 +2797,11 @@ x11_register_error_handlers(void) } static void -x11_texture_alloc_color(WScreen *scr, XColor *color) +x11_texture_alloc_color(WScreen *scr, WMColorRGB *color) { - XAllocColor(dpy, scr->w_colormap, color); + /* WMColorRGB has the same memory layout as Xlib's XColor (pixel, + * red, green, blue, flags, pad), so we can cast directly. */ + XAllocColor(dpy, scr->w_colormap, (XColor *)color); } static int @@ -2949,7 +2964,7 @@ x11_frame_alloc_border_pixel(unsigned long colormap, const char *color_name, unsigned long **pixel_out) { - XColor xcol; + WMColorRGB xcol; *pixel_out = NULL; if (!wGetColorForColormap((Colormap)colormap, color_name, &xcol)) return; @@ -3394,9 +3409,10 @@ static WScreen *x11_screen_for_window(WNativeWindow window) return NULL; } -static int x11_parse_color(WScreen *scr, const char *name, XColor *color_out) +static int x11_parse_color(WScreen *scr, const char *name, WMColorRGB *color_out) { - return XParseColor(dpy, scr->w_colormap, name, color_out); + /* WMColorRGB has the same layout as XColor — cast at the boundary. */ + return XParseColor(dpy, scr->w_colormap, name, (XColor *)color_out); } static int x11_cursor_create_from_files(WScreen *scr, const char *bitmap_path, @@ -4043,13 +4059,15 @@ static void x11_wipe_desktop(WScreen *scr) /* -------------------------------------------------------------------- */ static int x11_get_color_for_colormap(unsigned long colormap, - const char *color_name, XColor *color) + const char *color_name, WMColorRGB *color) { - if (!XParseColor(dpy, (Colormap)colormap, color_name, color)) { + /* WMColorRGB has the same layout as XColor — cast at the boundary. */ + XColor *xc = (XColor *)color; + if (!XParseColor(dpy, (Colormap)colormap, color_name, xc)) { wwarning(_("could not parse color \"%s\""), color_name); return 0; } - if (!XAllocColor(dpy, (Colormap)colormap, color)) { + if (!XAllocColor(dpy, (Colormap)colormap, xc)) { wwarning(_("could not allocate color \"%s\""), color_name); return 0; } diff --git a/src/client.c b/src/client.c index 473b55f..9cf8e08 100644 --- a/src/client.c +++ b/src/client.c @@ -311,13 +311,13 @@ void wClientCheckProperty(WWindow * wwin, WMEvent * event) * 5 - destroy application * 6 - create application */ - if (new_hints && (new_hints->flags & WindowGroupHint) + if (new_hints && (new_hints->flags & WMH_WINDOW_GROUP_HINT) && new_hints->window_group != WM_NATIVE_NONE) { g2 = 1; } else { g2 = 0; } - if (wwin->wm_hints && (wwin->wm_hints->flags & WindowGroupHint) + if (wwin->wm_hints && (wwin->wm_hints->flags & WMH_WINDOW_GROUP_HINT) && wwin->wm_hints->window_group != WM_NATIVE_NONE) { g1 = 1; } else { @@ -396,8 +396,8 @@ void wClientCheckProperty(WWindow * wwin, WMEvent * event) if (wwin->wm_hints) { /* update icon */ - if ((wwin->wm_hints->flags & IconPixmapHint) - || (wwin->wm_hints->flags & IconWindowHint)) { + if ((wwin->wm_hints->flags & WMH_ICON_PIXMAP_HINT) + || (wwin->wm_hints->flags & WMH_ICON_WINDOW_HINT)) { WApplication *wapp; if (wwin->flags.miniaturized && wwin->icon) @@ -410,7 +410,7 @@ void wClientCheckProperty(WWindow * wwin, WMEvent * event) } } - if (wwin->wm_hints->flags & UrgencyHint) + if (wwin->wm_hints->flags & WMH_URGENCY_HINT) wwin->flags.urgent = 1; else wwin->flags.urgent = 0; diff --git a/src/defaults.c b/src/defaults.c index 65215e6..f4d53e0 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1660,7 +1660,7 @@ static WTexture *parse_texture(WScreen * scr, WMPropList * pl) val = WMGetFromPLString(elem); if (strcasecmp(val, "solid") == 0) { - XColor color; + WMColorRGB color; if (nelem != 2) return NULL; @@ -1681,7 +1681,7 @@ static WTexture *parse_texture(WScreen * scr, WMPropList * pl) } else if (strcasecmp(val, "dgradient") == 0 || strcasecmp(val, "vgradient") == 0 || strcasecmp(val, "hgradient") == 0) { RColor color1, color2; - XColor xcolor; + WMColorRGB xcolor; int type; if (nelem != 3) { @@ -1732,7 +1732,7 @@ static WTexture *parse_texture(WScreen * scr, WMPropList * pl) } else if (strcasecmp(val, "igradient") == 0) { RColor colors1[2], colors2[2]; int th1, th2; - XColor xcolor; + WMColorRGB xcolor; int i; if (nelem != 7) { @@ -1788,7 +1788,7 @@ static WTexture *parse_texture(WScreen * scr, WMPropList * pl) } else if (strcasecmp(val, "mhgradient") == 0 || strcasecmp(val, "mvgradient") == 0 || strcasecmp(val, "mdgradient") == 0) { - XColor color; + WMColorRGB color; RColor **colors; int i, count; int type; @@ -1839,7 +1839,7 @@ static WTexture *parse_texture(WScreen * scr, WMPropList * pl) texture = (WTexture *) wTextureMakeMGradient(scr, type, colors); } else if (strcasecmp(val, "spixmap") == 0 || strcasecmp(val, "cpixmap") == 0 || strcasecmp(val, "tpixmap") == 0) { - XColor color; + WMColorRGB color; int type; if (nelem != 3) @@ -1874,7 +1874,7 @@ static WTexture *parse_texture(WScreen * scr, WMPropList * pl) } else if (strcasecmp(val, "thgradient") == 0 || strcasecmp(val, "tvgradient") == 0 || strcasecmp(val, "tdgradient") == 0) { RColor color1, color2; - XColor xcolor; + WMColorRGB xcolor; int opacity; int style; @@ -2143,7 +2143,7 @@ static int getFont(WScreen * scr, WDefaultEntry * entry, WMPropList * value, voi static int getColor(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret) { - static XColor color; + static WMColorRGB color; const char *val; int second_pass = 0; @@ -2338,7 +2338,7 @@ static int parse_cursor(WScreen * scr, WMPropList * pl, WMNativeCursor * cursor) WMNativePixmap mask; unsigned int w, h; int x, y; - XColor fg, bg; + WMColorRGB fg, bg; if (nelem != 3) { wwarning(_("bad number of arguments in cursor specification")); @@ -2671,7 +2671,7 @@ static int setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, void *tdata, static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2689,7 +2689,7 @@ static int setHightlight(WScreen * scr, WDefaultEntry * entry, void *tdata, void static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2707,7 +2707,7 @@ static int setHightlightText(WScreen * scr, WDefaultEntry * entry, void *tdata, static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data) { - XColor *color = tdata; + WMColorRGB *color = tdata; long widx = (long) extra_data; /* Parameter not used, but tell the compiler that it is ok */ @@ -2724,7 +2724,7 @@ static int setClipTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data) { - XColor *color = tdata; + WMColorRGB *color = tdata; long widx = (long) extra_data; /* Parameter not used, but tell the compiler that it is ok */ @@ -2743,7 +2743,7 @@ static int setWTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, voi static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *extra_data) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2761,7 +2761,7 @@ static int setMenuTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2785,7 +2785,7 @@ static int setMenuTextColor(WScreen * scr, WDefaultEntry * entry, void *tdata, v static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2809,7 +2809,7 @@ static int setMenuDisabledColor(WScreen * scr, WDefaultEntry * entry, void *tdat static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2826,7 +2826,7 @@ static int setIconTitleColor(WScreen * scr, WDefaultEntry * entry, void *tdata, static int setIconTitleBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2855,7 +2855,7 @@ static int setFrameBorderWidth(WScreen * scr, WDefaultEntry * entry, void *tdata static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2872,7 +2872,7 @@ static int setFrameBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; @@ -2889,7 +2889,7 @@ static int setFrameFocusedBorderColor(WScreen *scr, WDefaultEntry *entry, void * static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo) { - XColor *color = tdata; + WMColorRGB *color = tdata; /* Parameter not used, but tell the compiler that it is ok */ (void) entry; diff --git a/src/dialog.c b/src/dialog.c index 9cddcf4..53df44c 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -1359,8 +1359,8 @@ void wShowInfoPanel(WScreen *scr) } if (scr->w_visual) { - snprintf(buffer, sizeof(buffer), _("Using visual 0x%x: %s %ibpp "), - (unsigned)scr->w_visual->visualid, visuals[scr->w_visual->class], scr->w_depth); + snprintf(buffer, sizeof(buffer), _("Using visual 0x%lx: %s %ibpp "), + scr->w_visual_id, visuals[scr->w_visual_class], scr->w_depth); strbuf = wstrappend(strbuf, buffer); } else { snprintf(buffer, sizeof(buffer), _("Using Wayland compositor %ibpp "), scr->w_depth ? scr->w_depth : 32); @@ -1697,19 +1697,22 @@ int wShowCrashingDialogPanel(int whatSig) WMScreen *scr; WMFont *font; WMPixmap *logo; - int screen_no, scr_width, scr_height; + int scr_width, scr_height; int action; char buf[256]; - screen_no = DefaultScreen(dpy); - scr_width = WidthOfScreen(ScreenOfDisplay(dpy, screen_no)); - scr_height = HeightOfScreen(ScreenOfDisplay(dpy, screen_no)); - - scr = WMCreateScreen(dpy, screen_no); + /* Open a fresh connection to whichever backend the user has — the + * crash handler runs out-of-process from the main event loop and + * needs its own WMScreen to drive the dialog. WMOpenScreen() picks + * Wayland or X11 via the platform-backend vtable, so this works in + * either build. */ + scr = WMOpenScreen(NULL); if (!scr) { werror(_("cannot open connection for crashing dialog panel. Aborting.")); return WMAbort; } + scr_width = WMScreenWidth(scr); + scr_height = WMScreenHeight(scr); panel = wmalloc(sizeof(CrashPanel)); diff --git a/src/dock.c b/src/dock.c index 056f3b1..d2ac171 100644 --- a/src/dock.c +++ b/src/dock.c @@ -58,9 +58,6 @@ #include "placement.h" #include "misc.h" #include "event.h" -#include "backend/x11/x11_compat.h" -#include "backend/x11/x11_event.h" - /**** Local variables ****/ #define CLIP_REWIND 1 #define CLIP_IDLE 0 diff --git a/src/event.c b/src/event.c index 9cd3ecd..4427883 100644 --- a/src/event.c +++ b/src/event.c @@ -60,8 +60,6 @@ #include "winmenu.h" #include "switchmenu.h" #include "wsmap.h" -#include "backend/x11/x11_compat.h" -#include "backend/x11/x11_event.h" #define MOD_MASK wPreferences.modifier_mask @@ -470,7 +468,7 @@ static void handleMapRequest(WMEvent * ev) } if (wwin) { - wClientSetState(wwin, NormalState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_NORMAL, WM_NATIVE_NONE); if (wwin->flags.maximized) { wMaximizeWindow(wwin, wwin->flags.maximized, wGetHeadForWindow(wwin)); @@ -738,7 +736,7 @@ static void handleMapNotify(WMEvent * event) } else { wm_backend->server_grab(); wWindowMap(wwin); - wClientSetState(wwin, NormalState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_NORMAL, WM_NATIVE_NONE); wm_backend->server_ungrab(); } } @@ -747,7 +745,6 @@ static void handleMapNotify(WMEvent * event) static void handleUnmapNotify(WMEvent * event) { WWindow *wwin; - XEvent ev; Bool withdraw = False; /* only process windows with StructureNotify selected @@ -773,12 +770,15 @@ static void handleUnmapNotify(WMEvent * event) wm_backend->window_unmap((WNativeWindow)wwin->frame->core->window); wwin->flags.mapped = 0; wm_backend->event_sync(0); - /* check if the window was destroyed */ - if (wm_backend->event_check_window((WNativeWindow)wwin->client_win, WME_DESTROY)) { - WMEvent wev; - x11_translate_event(&ev, &wev); - DispatchEvent(&wev); - } else { + /* If a destroy event for the client window is already pending, skip + * the unmanage here — handleDestroyNotify will run it on the next + * event-loop iteration. (Pre-Phase-30 code dispatched the destroy + * synchronously here via x11_translate_event(); that path used an + * uninitialized XEvent and never actually carried the destroy data, + * so it became dead code. Letting the destroy flow through the + * normal dispatch is the correct fix.) */ + if (!wm_backend->event_check_window((WNativeWindow)wwin->client_win, + WME_DESTROY)) { Bool reparented = False; if (wm_backend->event_check_window((WNativeWindow)wwin->client_win, WME_REPARENT)) @@ -787,7 +787,7 @@ static void handleUnmapNotify(WMEvent * event) /* withdraw window */ wwin->flags.mapped = 0; if (!reparented) - wClientSetState(wwin, WithdrawnState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_WITHDRAWN, WM_NATIVE_NONE); /* if the window was reparented, do not reparent it back to the * root window */ @@ -839,7 +839,7 @@ static void handleClientMessage(WMEvent * event) /* handle transition from Normal to Iconic state */ if (event->u.clientMessage.message_type == w_global.atom.wm.change_state - && event->u.clientMessage.format == 32 && event->u.clientMessage.data.l[0] == IconicState) { + && event->u.clientMessage.format == 32 && event->u.clientMessage.data.l[0] == WM_STATE_ICONIC) { wwin = wWindowFor(event->u.clientMessage.window); if (!wwin) @@ -988,17 +988,19 @@ static void handleEnterNotify(WMEvent * event) { WWindow *wwin; WObjDescriptor *desc = NULL; - XEvent ev; WScreen *scr = wScreenForRootWindow(event->u.crossing.window); + /* + * If a Leave event for this window is already pending, the pointer + * has already left — skip the enter handler. Pre-Phase-30 code + * peeked the leave event details and only skipped when mode/detail + * matched; that path went through an x11_translate_event() with an + * uninitialized XEvent and was therefore dead code (always reading + * stack garbage). Treating any pending Leave as cause to skip is + * the conservative correct behaviour. + */ if (wm_backend->event_check_window((WNativeWindow)event->u.crossing.window, WME_LEAVE)) { - /* already left the window... */ - WMEvent wev; - x11_translate_event(&ev, &wev); - saveTimestamp(&wev); - if (wev.u.crossing.mode == event->u.crossing.mode && wev.u.crossing.detail == event->u.crossing.detail) { - return; - } + return; } desc = wm_backend->context_find(event->u.crossing.window, WM_CTX_CLIENT_WIN); @@ -1090,12 +1092,12 @@ static void handleColormapNotify(WMEvent * event) do { if (wwin) { if (event->u.colormap.c_new) { - XWindowAttributes attr; + WMNativeColormap cmap = 0; - wm_backend->window_get_colormap((WNativeWindow)wwin->client_win, &attr.colormap); + wm_backend->window_get_colormap((WNativeWindow)wwin->client_win, &cmap); if (wwin == scr->cmap_window && wwin->cmap_window_no == 0) - scr->current_colormap = attr.colormap; + scr->current_colormap = cmap; reinstall = True; } else if (event->u.colormap.state == ColormapUninstalled && diff --git a/src/icon.c b/src/icon.c index ca2bcd6..8b8d7a0 100644 --- a/src/icon.c +++ b/src/icon.c @@ -117,7 +117,7 @@ WIcon *icon_create_for_wwindow(WWindow *wwin) icon = icon_create_core(scr, wwin->icon_x, wwin->icon_y); icon->owner = wwin; - if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) { + if (wwin->wm_hints && (wwin->wm_hints->flags & WMH_ICON_WINDOW_HINT)) { if (wwin->client_win == wwin->main_window) { WApplication *wapp; /* do not let miniwindow steal app-icon's icon window */ @@ -444,10 +444,10 @@ static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon) RImage *image = NULL; WWMHints *hints = wwin->wm_hints; - if (hints && (hints->flags & IconPixmapHint) && hints->icon_pixmap != WNATIVE_NONE) + if (hints && (hints->flags & WMH_ICON_PIXMAP_HINT) && hints->icon_pixmap != WNATIVE_NONE) image = RCreateImageFromDrawable(icon->core->screen_ptr->rcontext, (WMDrawable)hints->icon_pixmap, - (hints->flags & IconMaskHint) + (hints->flags & WMH_ICON_MASK_HINT) ? (WMDrawable)hints->icon_mask : WM_NATIVE_NONE); return image; @@ -544,7 +544,6 @@ static void cycleColor(void *data) { WIcon *icon = (WIcon *) data; WScreen *scr = icon->core->screen_ptr; - XGCValues gcv; icon->step--; wm_backend->icon_select_paint(icon, icon->step); @@ -639,7 +638,7 @@ void wIconUpdate(WIcon *icon) } else if (wwin && wwin->net_icon_image) { /* Use _NET_WM_ICON icon */ get_rimage_icon_from_x11(icon); - } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)) { + } else if (wwin && wwin->wm_hints && (wwin->wm_hints->flags & WMH_ICON_PIXMAP_HINT)) { /* Get the WMNativePixmap from the wm_hints, else, from the user */ unset_icon_image(icon); icon->file_image = get_rimage_icon_from_wm_hints(icon); @@ -731,7 +730,6 @@ static void get_rimage_icon_from_icon_win(WIcon *icon) /* Set the dockapp in the WIcon */ static void set_dockapp_in_icon(WIcon *icon) { - XWindowAttributes attr; WScreen *scr = icon->core->screen_ptr; unsigned int w, h, d; @@ -777,7 +775,7 @@ RImage *get_rimage_icon_from_wm_hints(WIcon *icon) wwin = icon->owner; if (!getSize((WMDrawable)wwin->wm_hints->icon_pixmap, &w, &h, &d)) { - icon->owner->wm_hints->flags &= ~IconPixmapHint; + icon->owner->wm_hints->flags &= ~WMH_ICON_PIXMAP_HINT; return NULL; } diff --git a/src/misc.c b/src/misc.c index a810669..dbf0972 100644 --- a/src/misc.c +++ b/src/misc.c @@ -74,9 +74,6 @@ Bool wGetIconName(Display *dpy, WNativeWindow win, char **iconname) static void eatExpose(void) { - XEvent event, foo; - - /* compress all expose events into a single one */ wm_backend->event_flush_type(WME_EXPOSE); } diff --git a/src/moveres.c b/src/moveres.c index a739a2b..a6c7f2e 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -137,19 +137,9 @@ static void showPosition(WWindow * wwin, int x, int y) WScreen *scr = wwin->screen_ptr; if (wPreferences.move_display == WDIS_NEW) { -#if 0 - int width = wwin->frame->core->width; - int height = wwin->frame->core->height; - - GC lgc = scr->line_gc; - XSetForeground(dpy, lgc, scr->line_pixel); - sprintf(num, "%i", x); - - XDrawLine(dpy, scr->root_win, lgc, 0, y - 1, scr->scr_width, y - 1); - XDrawLine(dpy, scr->root_win, lgc, 0, y + height + 2, scr->scr_width, y + height + 2); - XDrawLine(dpy, scr->root_win, lgc, x - 1, 0, x - 1, scr->scr_height); - XDrawLine(dpy, scr->root_win, lgc, x + width + 2, 0, x + width + 2, scr->scr_height); -#endif + /* WDIS_NEW (root-window outline overlay) was never finished — + * the original Xlib draw calls were #if 0'd out long ago. + * cyclePositionDisplay() now skips this mode anyway. */ } else { WSetGeometryViewShownPosition(scr->gview, x, y); } @@ -231,7 +221,7 @@ static void showGeometry(WWindow * wwin, int x1, int y1, int x2, int y2, int dir if (wPreferences.size_display == WDIS_NEW) { fw = wm_backend->overlay_text_width(scr, "8888", 4); - fh = scr->tech_draw_font->ascent + scr->tech_draw_font->descent; + fh = scr->tech_draw_font_ascent + scr->tech_draw_font_descent; /* vertical geometry */ if (((direction & LEFT) && (x2 < scr->scr_width - fw)) || (x1 < fw)) { @@ -291,7 +281,7 @@ static void showGeometry(WWindow * wwin, int x1, int y1, int x2, int y2, int dir /* Display the height. */ wm_backend->overlay_draw_string(scr, x - s + 3 - fw / 2, - my + scr->tech_draw_font->ascent - fh / 2 + 1, num, strlen(num)); + my + scr->tech_draw_font_ascent - fh / 2 + 1, num, strlen(num)); /* horizontal geometry */ if (y1 < 15) { @@ -350,7 +340,7 @@ static void showGeometry(WWindow * wwin, int x1, int y1, int x2, int y2, int dir /* Display the width. */ wm_backend->overlay_draw_string(scr, mx - fw / 2 + 1, - y - s + scr->tech_draw_font->ascent - fh / 2 + 1, num, strlen(num)); + y - s + scr->tech_draw_font_ascent - fh / 2 + 1, num, strlen(num)); } else { WSetGeometryViewShownSize(scr->gview, (x2 - x1 - wwin->normal_hints->base_width) / wwin->normal_hints->width_inc, diff --git a/src/resources.c b/src/resources.c index f128514..74e50ac 100644 --- a/src/resources.c +++ b/src/resources.c @@ -33,12 +33,12 @@ #include "resources.h" #include "screen.h" -int wGetColorForColormap(WMNativeColormap colormap, const char *color_name, XColor *color) +int wGetColorForColormap(WMNativeColormap colormap, const char *color_name, WMColorRGB *color) { return wm_backend->get_color_for_colormap((unsigned long)colormap, color_name, color); } -int wGetColor(WScreen *scr, const char *color_name, XColor *color) +int wGetColor(WScreen *scr, const char *color_name, WMColorRGB *color) { return wGetColorForColormap(scr->w_colormap, color_name, color); } diff --git a/src/resources.h b/src/resources.h index c07c146..fa52ec0 100644 --- a/src/resources.h +++ b/src/resources.h @@ -21,8 +21,8 @@ #ifndef WMRESOURCES_H_ #define WMRESOURCES_H_ -int wGetColorForColormap(WMNativeColormap colormap, const char *color_name, XColor *color); -int wGetColor(WScreen *scr, const char *color_name, XColor *color); +int wGetColorForColormap(WMNativeColormap colormap, const char *color_name, WMColorRGB *color); +int wGetColor(WScreen *scr, const char *color_name, WMColorRGB *color); void wFreeColor(WScreen *scr, unsigned long pixel); #endif diff --git a/src/screen.h b/src/screen.h index c00db4f..1f4065c 100644 --- a/src/screen.h +++ b/src/screen.h @@ -81,7 +81,13 @@ typedef struct _WScreen { WNativeWindow w_win; /* window to use as drawable * for new GCs, pixmaps etc. */ - Visual *w_visual; + void *w_visual; /* X11: Visual *; Wayland: NULL. + * Backend-neutral; consumers pass + * through to backend calls. Use + * w_visual_id / w_visual_class for + * inspection from shared code. */ + unsigned long w_visual_id; /* X11 VisualID; 0 in Wayland mode */ + int w_visual_class; /* X11 visual class (e.g. TrueColor) */ int w_depth; WMNativeColormap w_colormap; /* our colormap */ @@ -156,9 +162,12 @@ typedef struct _WScreen { WMFont *info_text_font; /* text on things like geometry * hint boxes */ - XFontStruct *tech_draw_font; /* font for tech draw style geom view - needs to be a core font so we can - use it with a XORing GC */ + void *tech_draw_font; /* backend-specific font handle: + * X11: XFontStruct* (a core font; + * needs to support XORing GC) + * Wayland: stub struct with metrics. */ + int tech_draw_font_ascent; /* ascent in pixels (filled by backend) */ + int tech_draw_font_descent; /* descent in pixels (filled by backend) */ WMFont *workspace_name_font; diff --git a/src/startup.c b/src/startup.c index 635965f..57a4b12 100644 --- a/src/startup.c +++ b/src/startup.c @@ -597,7 +597,7 @@ void wManageAllWindows(WScreen * scr, int crashRecovery) wwin->flags.miniaturized = 0; wIconifyWindow(wwin); } else { - wClientSetState(wwin, NormalState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_NORMAL, WM_NATIVE_NONE); } if (crashRecovery) { int border; diff --git a/src/texture.c b/src/texture.c index bd1f44f..a1b2014 100644 --- a/src/texture.c +++ b/src/texture.c @@ -37,7 +37,7 @@ static void bevelImage(RImage * image, int relief); static RImage * get_texture_image(WScreen *scr, const char *pixmap_file); -WTexSolid *wTextureMakeSolid(WScreen * scr, XColor * color) +WTexSolid *wTextureMakeSolid(WScreen * scr, WMColorRGB * color) { WTexSolid *texture; @@ -222,7 +222,7 @@ WTexMGradient *wTextureMakeMGradient(WScreen * scr, int style, RColor ** colors) return texture; } -WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, const char *pixmap_file, XColor *color) +WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, const char *pixmap_file, WMColorRGB *color) { WTexPixmap *texture; RImage *image; diff --git a/src/texture.h b/src/texture.h index 485f654..9dd65f5 100644 --- a/src/texture.h +++ b/src/texture.h @@ -58,7 +58,7 @@ typedef struct { short type; /* type of texture */ char subtype; /* subtype of the texture */ - XColor color; /* default background color */ + WMColorRGB color; /* default background color */ GC gc; /* gc for the background color */ } WTexAny; @@ -66,23 +66,23 @@ typedef struct { typedef struct WTexSolid { short type; char subtype; - XColor normal; + WMColorRGB normal; GC normal_gc; GC light_gc; GC dim_gc; GC dark_gc; - XColor light; - XColor dim; - XColor dark; + WMColorRGB light; + WMColorRGB dim; + WMColorRGB dark; } WTexSolid; typedef struct WTexGradient { short type; char subtype; - XColor normal; + WMColorRGB normal; GC normal_gc; RColor color1; @@ -93,7 +93,7 @@ typedef struct WTexGradient { typedef struct WTexMGradient { short type; char subtype; - XColor normal; + WMColorRGB normal; GC normal_gc; RColor **colors; @@ -103,7 +103,7 @@ typedef struct WTexMGradient { typedef struct WTexIGradient { short type; char dummy; - XColor normal; + WMColorRGB normal; GC normal_gc; RColor colors1[2]; @@ -116,7 +116,7 @@ typedef struct WTexIGradient { typedef struct WTexPixmap { short type; char subtype; - XColor normal; + WMColorRGB normal; GC normal_gc; struct RImage *pixmap; @@ -125,7 +125,7 @@ typedef struct WTexPixmap { typedef struct WTexTGradient { short type; char subtype; - XColor normal; + WMColorRGB normal; GC normal_gc; RColor color1; @@ -137,7 +137,7 @@ typedef struct WTexTGradient { typedef struct WTexFunction { short type; char subtype; - XColor normal; + WMColorRGB normal; GC normal_gc; void *handle; @@ -158,13 +158,13 @@ typedef union WTexture { } WTexture; -WTexSolid *wTextureMakeSolid(WScreen*, XColor*); +WTexSolid *wTextureMakeSolid(WScreen*, WMColorRGB*); WTexGradient *wTextureMakeGradient(WScreen*, int, const RColor*, const RColor*); WTexMGradient *wTextureMakeMGradient(WScreen*, int, RColor**); WTexTGradient *wTextureMakeTGradient(WScreen*, int, const RColor*, const RColor*, const char *, int); WTexIGradient *wTextureMakeIGradient(WScreen*, int, const RColor[2], int, const RColor[2]); WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, const char *pixmap_file, - XColor *color); + WMColorRGB *color); void wTextureDestroy(WScreen*, WTexture*); void wTexturePaint(WTexture *, WMNativePixmap *, WCoreWindow*, int, int); void wTextureRender(WScreen*, WTexture*, WMNativePixmap*, int, int, int); diff --git a/src/window.c b/src/window.c index ce7fa27..3bf9e77 100644 --- a/src/window.c +++ b/src/window.c @@ -64,7 +64,6 @@ # include "motif.h" #endif #include "geom.h" -#include "backend/x11/x11_event.h" #define MOD_MASK wPreferences.modifier_mask @@ -86,7 +85,7 @@ static void windowCloseDblClick(WCoreWindow *sender, void *data, WMEvent *event) static void windowIconifyClick(WCoreWindow *sender, void *data, WMEvent *event); #ifdef XKB_BUTTON_HINT -static void windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event); +static void windowLanguageClick(WCoreWindow *sender, void *data, WMEvent *event); #endif static void titlebarMouseDown(WCoreWindow *sender, void *data, WMEvent *event); @@ -691,16 +690,16 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) wwin->wm_hints = wm_backend->prop_get_wm_hints(window); if (wwin->wm_hints) { - if (wwin->wm_hints->flags & StateHint) { - if (wwin->wm_hints->initial_state == IconicState) { + if (wwin->wm_hints->flags & WMH_STATE_HINT) { + if (wwin->wm_hints->initial_state == WM_STATE_ICONIC) { wwin->flags.miniaturized = 1; - } else if (wwin->wm_hints->initial_state == WithdrawnState) { + } else if (wwin->wm_hints->initial_state == WM_STATE_WITHDRAWN) { wwin->flags.is_dockapp = 1; withdraw = True; } } - if (wwin->wm_hints->flags & WindowGroupHint) { + if (wwin->wm_hints->flags & WMH_WINDOW_GROUP_HINT) { wwin->group_id = wwin->wm_hints->window_group; /* window_group has priority over CLIENT_LEADER */ wwin->main_window = wwin->group_id; @@ -708,7 +707,7 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) wwin->group_id = WM_NATIVE_NONE; } - if (wwin->wm_hints->flags & UrgencyHint) { + if (wwin->wm_hints->flags & WMH_URGENCY_HINT) { wwin->flags.urgent = 1; wAppBounceWhileUrgent(wApplicationOf(wwin->main_window)); } @@ -838,9 +837,9 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) /* apply previous state if it exists and we're in startup */ if (scr->flags.startup && wm_state >= 0) { - if (wm_state == IconicState) + if (wm_state == WM_STATE_ICONIC) wwin->flags.miniaturized = 1; - else if (wm_state == WithdrawnState) + else if (wm_state == WM_STATE_WITHDRAWN) withdraw = True; } @@ -933,7 +932,7 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) if (transientOwner && !transientOwner->flags.miniaturized && wwin->flags.miniaturized && !withdraw) { wwin->flags.miniaturized = 0; if (wwin->wm_hints) - wwin->wm_hints->initial_state = NormalState; + wwin->wm_hints->initial_state = WM_STATE_NORMAL; } /* set workspace on which the window starts */ @@ -1226,10 +1225,10 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) /* The following "if" is to avoid crashing of clients that expect * WM_STATE set before they get mapped. Else WM_STATE is set later, * after the return from this function. */ - if (wwin->wm_hints && (wwin->wm_hints->flags & StateHint)) + if (wwin->wm_hints && (wwin->wm_hints->flags & WMH_STATE_HINT)) wClientSetState(wwin, wwin->wm_hints->initial_state, WM_NATIVE_NONE); else - wClientSetState(wwin, NormalState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_NORMAL, WM_NATIVE_NONE); if (wwin->frame && wPreferences.superfluous && !wPreferences.no_animations && !scr->flags.startup && (wwin->transient_for == WM_NATIVE_NONE || wwin->transient_for == scr->root_win) && @@ -1319,7 +1318,7 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) * Must do some optimization, 'though */ if (withdraw) { wwin->flags.mapped = 0; - wClientSetState(wwin, WithdrawnState, WM_NATIVE_NONE); + wClientSetState(wwin, WM_STATE_WITHDRAWN, WM_NATIVE_NONE); wUnmanageWindow(wwin, True, False); wwin = NULL; } @@ -2309,7 +2308,7 @@ static FocusMode getFocusMode(WWindow * wwin) { FocusMode mode; - if ((wwin->wm_hints) && (wwin->wm_hints->flags & InputHint)) { + if ((wwin->wm_hints) && (wwin->wm_hints->flags & WMH_INPUT_HINT)) { if (wwin->wm_hints->input == True) { if (wwin->protocols.TAKE_FOCUS) mode = WFM_LOCALLY_ACTIVE; @@ -2836,7 +2835,7 @@ static void windowCloseDblClick(WCoreWindow *sender, void *data, WMEvent *event) } #ifdef XKB_BUTTON_HINT -static void windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event) +static void windowLanguageClick(WCoreWindow *sender, void *data, WMEvent *event) { WWindow *wwin = data; WFrameWindow *fwin = wwin->frame; @@ -2846,7 +2845,7 @@ static void windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event) /* Parameter not used, but tell the compiler that it is ok */ (void) sender; - if (event->xbutton.button != Button1 && event->xbutton.button != Button3) + if (event->u.button.button != Button1 && event->u.button.button != Button3) return; tl = wwin->frame->languagemode; wwin->frame->languagemode = wwin->frame->last_languagemode; diff --git a/src/window.h b/src/window.h index 4d941eb..06977fa 100644 --- a/src/window.h +++ b/src/window.h @@ -31,8 +31,8 @@ #include "backend/backend_types.h" /* not defined in my X11 headers */ -#ifndef UrgencyHint -#define UrgencyHint (1L << 8) +#ifndef WMH_URGENCY_HINT +#define WMH_URGENCY_HINT (1L << 8) #endif diff --git a/src/winspector.c b/src/winspector.c index 5de762a..444abdc 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -1282,7 +1282,7 @@ void wHideInspectorForWindow(WWindow *wwin) wWindowUnmap(pwin); pwin->flags.hidden = 1; - wClientSetState(pwin, IconicState, WM_NATIVE_NONE); + wClientSetState(pwin, WM_STATE_ICONIC, WM_NATIVE_NONE); } void wUnhideInspectorForWindow(WWindow *wwin) @@ -1293,7 +1293,7 @@ void wUnhideInspectorForWindow(WWindow *wwin) pwin->flags.mapped = 1; wm_backend->window_map((WNativeWindow)pwin->client_win); wm_backend->window_map((WNativeWindow)pwin->frame->core->window); - wClientSetState(pwin, NormalState, WM_NATIVE_NONE); + wClientSetState(pwin, WM_STATE_NORMAL, WM_NATIVE_NONE); } WWindow *wGetWindowOfInspectorForWindow(WWindow *wwin) diff --git a/src/wsmap.c b/src/wsmap.c index 2f6c1e5..2fe928c 100644 --- a/src/wsmap.c +++ b/src/wsmap.c @@ -111,18 +111,16 @@ static void workspace_map_destroy(WWorkspaceMap *wsmap) if (wsmap->win) { WNativeWindow info_win = wsmap->scr->info_window; - XEvent ev; + WNativeWindow root_win = (WNativeWindow)wsmap->scr->root_win; - ev.xclient.type = ClientMessage; - ev.xclient.message_type = w_global.atom.wm.ignore_focus_events; - ev.xclient.format = 32; - ev.xclient.data.l[0] = True; - - wm_backend->switchpanel_send_enter((WNativeWindow)info_win, 0); + /* Send a synthetic enter to info_win so the focus-event filter + * does the right thing across the unmap+destroy. Pre-Phase-30 + * code also constructed a ClientMessage(ignore_focus_events) + * here but never actually sent it — that XEvent local was dead + * code and is removed. */ + wm_backend->switchpanel_send_enter(info_win, root_win); WMUnmapWidget(wsmap->win); - - ev.xclient.data.l[0] = False; - wm_backend->switchpanel_send_enter((WNativeWindow)info_win, 0); + wm_backend->switchpanel_send_enter(info_win, root_win); WMDestroyWidget(wsmap->win); if (frame_bg_focused) diff --git a/src/xmodifier.c b/src/xmodifier.c index a438036..e116eb8 100644 --- a/src/xmodifier.c +++ b/src/xmodifier.c @@ -18,10 +18,8 @@ #include #include -#include /* WM_MOD_SHIFT, WM_MOD_CONTROL, ModNMask constants */ - #include -#include "WindowMaker.h" +#include "WindowMaker.h" /* WM_MOD_SHIFT, WM_MOD_CONTROL, WM_MOD_MOD1..5 */ #include "xmodifier.h" static int MetaMask, HyperMask, SuperMask, AltMask; diff --git a/src/xutil.h b/src/xutil.h index 35f38d4..8fcc0ef 100644 --- a/src/xutil.h +++ b/src/xutil.h @@ -20,13 +20,10 @@ #ifndef _WM_XUTIL_H_ #define _WM_XUTIL_H_ -void FormatXError(Display *dpy, XErrorEvent *error, char *buffer, int size); - - -void RequestSelection(Display *dpy, WNativeWindow requestor, Time timestamp); - - -char *GetSelection(Display *dpy, WNativeWindow requestor); - +/* This file used to declare FormatXError(), RequestSelection(), + * GetSelection() — all X11-specific. FormatXError was moved into + * the X11 backend (src/backend/x11/x11_backend.c) when display ops + * were vtable-ised; the other two were never implemented. Kept as + * a placeholder to avoid breaking the include site in xutil.c. */ #endif