wings: phases δ + ε — drop X11/Xlib.h from public WINGs headers

Major architectural milestone: WINGs Wayland-only files now have ZERO
transitive X11 header dependency at the preprocessor level (verified by
gcc -E grep: 0 mentions of X11/Xlib.h after preprocessing).

Changes:

  1. WUtil.h, WINGs.h: stop including <X11/Xlib.h>.  wnative.h provides
     forward declarations for Display, GC, XftDraw, XftFont; opaque
     pointer-only typedefs that don't conflict with Xlib.h's actual
     definitions when the X11 backend later includes it.

  2. WINGsP.h.in: stop including <X11/Xlib.h>, <X11/Xutil.h>.  Drop or
     re-route every X11-typed prototype:
       - W_HandleDNDClientMessage / W_DragSourceStateHandler /
         W_DragDestinationStoreEnterMsgInfo / etc.
         → moved to new private header WINGs/WINGsX11.h
       - W_HandleSelectionEvent → moved
       - W_LookupString / W_KeycodeToKeysym → moved
       - W_DndState typedef → moved (renamed to W_X11DndState)
       - XClientMessageEvent / XEvent / XKeyPressedEvent in prototypes
         → use void * in shared protos, cast in WINGsX11.h

  3. W_View struct: replaces XSetWindowAttributes by-value field with a
     small backend-neutral 'attribs' struct holding only the fields
     wmaker/WPrefs actually use (background_pixmap, background_pixel,
     border_pixel, colormap, cursor, override_redirect, save_under,
     event_mask, do_not_propagate_mask).  The X11 view backend
     translates to XSetWindowAttributes when calling XCreateWindow.
     XIC xic field replaced with void *xic.

  4. W_Color struct: replaces XColor by-value with a same-layout
     anonymous struct (pixel/red/green/blue/flags/pad).  X11 backend
     uses memcpy to populate from XColor.

  5. WINGs/WINGsX11.h (new): private header for X11 backend.  Includes
     <X11/Xlib.h>, declares X11-typed internal prototypes used by drag*,
     selection, IME, x11_backend, KeyboardShortcuts.  Required by every
     *_x11.c file plus a handful of cross-component callers
     (KeyboardShortcuts.c, MouseSettings.c, xmodifier.c, wmiv.c,
     x11_backend.c).

  6. wraster.h.in: gain a WRASTER_NO_XLIB compile-time switch.  When
     defined the header skips <X11/Xlib.h> and provides forward decls
     for Display/Visual/XImage/GC/XftFont/etc.  All Wayland-only WINGs
     files (wclient_wl.c, w*_wl.c) define WRASTER_NO_XLIB on line 1.

  7. wfont.c: adds W_ParseXLFDToFcPattern (a hand-written XLFD parser)
     replacing XftXlfdParse.  Removes <X11/Xft/Xft.h> include from the
     shared font dispatcher (and from wfontpanel.c too).

Verification:

  $ for f in WINGs/.libs/{*_wl.o,wclient_wl.o}; do
        nm $f | awk '$1=="U"{print $2}' | grep -cE '^X[A-Z][a-z]'
    done
  0 for every Wayland file

  $ for f in WINGs/.libs/*.o; do
        case $f in *_x11.o|*_wl.o|wclient_wl.o) continue;; esac
        c=$(nm $f | awk '$1=="U"{print $2}' | grep -cE '^X[A-Z][a-z]')
        [ $c -gt 0 ] && echo "$c $f"
    done
  (empty — no shared file leaks an X11 symbol either)

  $ gcc -E ... wclient_wl.c | grep -c X11/Xlib.h
  0 (no transitive Xlib include)

The library still pulls libX11 through the *_x11.c files when those are
linked in.  A future configure flag --disable-x11-backend will exclude
*_x11.c entirely; at that point libWINGs will be a pure-Wayland library
with zero libX11 dependency.
This commit is contained in:
Window Maker 2026-05-24 11:37:18 +02:00
parent 70d8a068e6
commit ef06f5ad8e
33 changed files with 351 additions and 137 deletions

View File

@ -7,7 +7,7 @@ includedir = @includedir@/WINGs
BUILT_SOURCES = WINGsP.h
CLEANFILES = WINGsP.h
include_HEADERS = WINGs.h WUtil.h wnative.h WMEvent.h
include_HEADERS = WINGs.h WUtil.h wnative.h WMEvent.h WINGsX11.h
nodist_include_HEADERS = WINGsP.h
EXTRA_DIST = WINGsP.h.in

View File

@ -26,7 +26,6 @@
#include <WINGs/wnative.h>
#include <WINGs/WUtil.h>
#include <WINGs/WMEvent.h>
#include <X11/Xlib.h>
#define WINGS_H_VERSION 20230226

View File

@ -2,9 +2,6 @@
#define _WINGSP_H_
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@USE_PANGO@#include <pango/pango.h>
#include <WINGs/WMEvent.h>
@ -57,10 +54,10 @@ extern struct W_Application WMApplication;
typedef struct W_DraggingInfo {
unsigned char protocolVersion; /* version supported on the other side */
Time timestamp;
WMNativeTime timestamp;
Atom sourceAction;
Atom destinationAction;
WMNativeAtom sourceAction;
WMNativeAtom destinationAction;
struct W_DragSourceInfo* sourceInfo; /* infos needed by source */
struct W_DragDestinationInfo* destInfo; /* infos needed by destination */
@ -84,13 +81,13 @@ typedef struct W_Screen {
int screen;
int depth;
Colormap colormap;
WMNativeColormap colormap;
Visual *visual;
Time lastEventTime;
WMNativeTime lastEventTime;
Window rootWin;
WNativeWindow rootWin;
W_View *rootView;
@ -122,11 +119,11 @@ typedef struct W_Screen {
RImage *applicationIconImage; /* image (can have alpha channel) */
W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
Window applicationIconWindow;
WNativeWindow applicationIconWindow;
struct W_Window *windowList; /* list of windows in the app */
Window groupLeader; /* the leader of the application */
WNativeWindow groupLeader; /* the leader of the application */
/* also used for other things */
struct W_SelectionHandlers *selectionHandlerList;
@ -143,7 +140,7 @@ typedef struct W_Screen {
struct W_ColorPanel *sharedColorPanel;
Pixmap stipple;
WMNativePixmap stipple;
W_View *dragSourceView;
W_DraggingInfo dragInfo;
@ -234,58 +231,58 @@ typedef struct W_Screen {
W_Pixmap *defaultObjectIcon;
Cursor defaultCursor;
WMNativeCursor defaultCursor;
Cursor textCursor;
WMNativeCursor textCursor;
Cursor invisibleCursor;
WMNativeCursor invisibleCursor;
Atom attribsAtom; /* GNUstepWindowAttributes */
WMNativeAtom attribsAtom; /* GNUstepWindowAttributes */
Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
WMNativeAtom deleteWindowAtom; /* WM_DELETE_WINDOW */
Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
WMNativeAtom protocolsAtom; /* _XA_WM_PROTOCOLS */
Atom clipboardAtom; /* CLIPBOARD */
WMNativeAtom clipboardAtom; /* CLIPBOARD */
Atom xdndAwareAtom; /* XdndAware */
Atom xdndSelectionAtom;
Atom xdndEnterAtom;
Atom xdndLeaveAtom;
Atom xdndPositionAtom;
Atom xdndDropAtom;
Atom xdndFinishedAtom;
Atom xdndTypeListAtom;
Atom xdndActionListAtom;
Atom xdndActionDescriptionAtom;
Atom xdndStatusAtom;
WMNativeAtom xdndAwareAtom; /* XdndAware */
WMNativeAtom xdndSelectionAtom;
WMNativeAtom xdndEnterAtom;
WMNativeAtom xdndLeaveAtom;
WMNativeAtom xdndPositionAtom;
WMNativeAtom xdndDropAtom;
WMNativeAtom xdndFinishedAtom;
WMNativeAtom xdndTypeListAtom;
WMNativeAtom xdndActionListAtom;
WMNativeAtom xdndActionDescriptionAtom;
WMNativeAtom xdndStatusAtom;
Atom xdndActionCopy;
Atom xdndActionMove;
Atom xdndActionLink;
Atom xdndActionAsk;
Atom xdndActionPrivate;
WMNativeAtom xdndActionCopy;
WMNativeAtom xdndActionMove;
WMNativeAtom xdndActionLink;
WMNativeAtom xdndActionAsk;
WMNativeAtom xdndActionPrivate;
Atom wmIconDragOffsetAtom;
WMNativeAtom wmIconDragOffsetAtom;
Atom wmStateAtom; /* WM_STATE */
WMNativeAtom wmStateAtom; /* WM_STATE */
Atom utf8String;
WMNativeAtom utf8String;
Atom netwmName;
Atom netwmIconName;
Atom netwmIcon;
WMNativeAtom netwmName;
WMNativeAtom netwmIconName;
WMNativeAtom netwmIcon;
/* stuff for detecting double-clicks */
Time lastClickTime; /* time of last mousedown event */
Window lastClickWindow; /* window of the last mousedown */
WMNativeTime lastClickTime; /* time of last mousedown event */
WNativeWindow lastClickWindow; /* window of the last mousedown */
struct W_View *modalView;
unsigned modalLoop:1;
unsigned ignoreNextDoubleClick:1;
/*
* New stuff in Window Maker 0.95.7
* New stuff in WNativeWindow Maker 0.95.7
* Added at the end of the structure to avoid breaking binary compatibility
* with previous versions of the toolkit
*/
@ -310,27 +307,28 @@ typedef struct W_DragOperationItem {
char* text;
} W_DragOperationItem;
typedef void* W_DndState(WMView *destView, XClientMessageEvent *event,
WMDraggingInfo *info);
/* W_DndState (state machine fn for X11 XDND) is declared in WINGsX11.h
* to keep this shared header X11-clean. The void * here is a placeholder
* for *_x11.c files which include the real prototype. */
typedef struct W_DragSourceInfo {
WMView *sourceView;
Window destinationWindow;
W_DndState *state;
WNativeWindow destinationWindow;
void *state; /* W_X11DndState *, see WINGsX11.h */
WMSelectionProcs *selectionProcs;
Window icon;
WNativeWindow icon;
WMPoint imageLocation;
WMPoint mouseOffset; /* mouse pos in icon */
Cursor dragCursor;
WMNativeCursor dragCursor;
WMRect noPositionMessageZone;
Atom firstThreeTypes[3];
WMNativeAtom firstThreeTypes[3];
} W_DragSourceInfo;
typedef struct W_DragDestinationInfo {
WMView *destView;
WMView *xdndAwareView;
Window sourceWindow;
W_DndState *state;
WNativeWindow sourceWindow;
void *state; /* W_X11DndState *, see WINGsX11.h */
Bool sourceActionChanged;
WMArray *sourceTypes;
WMArray *requiredTypes;
@ -338,17 +336,17 @@ typedef struct W_DragDestinationInfo {
WMArray *dropDatas;
} W_DragDestinationInfo;
/* -- Functions -- */
/* -- Functions --
* X11-typed DnD/selection/IM prototypes live in WINGsX11.h.
* Backend-neutral helpers below. */
void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
WMNativeAtom W_OperationToAction(WMScreen *scr, WMDragOperationType operation);
Atom W_OperationToAction(WMScreen *scr, WMDragOperationType operation);
WMDragOperationType W_ActionToOperation(WMScreen *scr, Atom action);
WMDragOperationType W_ActionToOperation(WMScreen *scr, WMNativeAtom action);
void W_FreeDragOperationItem(void* item);
Bool W_SendDnDClientMessage(Display *dpy, Window win, Atom message,
Bool W_SendDnDClientMessage(Display *dpy, WNativeWindow win, WMNativeAtom message,
unsigned long data1, unsigned long data2,
unsigned long data3, unsigned long data4,
unsigned long data5);
@ -357,24 +355,12 @@ void W_DragSourceStartTimer(WMDraggingInfo *info);
void W_DragSourceStopTimer(void);
void W_DragSourceStateHandler(WMDraggingInfo *info, XClientMessageEvent *event);
void W_DragDestinationStartTimer(WMDraggingInfo *info);
void W_DragDestinationStopTimer(void);
void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info, WMView *toplevel,
XClientMessageEvent *event);
void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo *info,
WMView *toplevel,
XClientMessageEvent *event);
void W_DragDestinationCancelDropOnEnter(WMView *toplevel, WMDraggingInfo *info);
void W_DragDestinationStateHandler(WMDraggingInfo *info,
XClientMessageEvent *event);
void W_DragDestinationInfoClear(WMDraggingInfo *info);
void W_FreeViewXdndPart(WMView *view);
@ -402,7 +388,7 @@ void W_FlushIdleNotificationQueue(void);
/* ---[ selection.c ]----------------------------------------------------- */
void W_HandleSelectionEvent(XEvent *event);
/* W_HandleSelectionEvent (X11-typed XEvent) is declared in WINGsX11.h. */
/* ---[ wapplication.c ]-------------------------------------------------- */
@ -435,7 +421,17 @@ void W_BalloonHandleLeaveView(WMView *view);
struct W_Color {
struct W_Screen *screen;
XColor color;
/* Replaces XColor — same layout as XColor's pixel/red/green/blue/
* flags fields so wcolor_x11.c's XAllocColor results can be copied
* here field-by-field. Keeping the field names identical means
* existing W_PIXEL / color->color.red etc. accessors keep working
* unchanged. */
struct {
unsigned long pixel;
unsigned short red, green, blue;
char flags;
char pad;
} color;
unsigned short alpha;
short refCount;
GC gc;
@ -590,15 +586,17 @@ typedef struct W_RenderBackend {
void (*composite_pixmap)(void *rctx, WMDrawable dst, struct W_Pixmap *src,
int sx, int sy, unsigned int w, unsigned int h,
int dx, int dy);
/* Fill a convex polygon */
/* Fill a convex polygon — points use the X11-style {short x, short y}
* struct layout for binary compatibility with XPoint in the X11
* render backend. */
void (*fill_polygon)(void *rctx, WMDrawable d, WMColor *color,
XPoint *points, int npoints);
void *points /* XPoint[] */, int npoints);
/* Fill an arc (pie slice) */
void (*fill_arc)(void *rctx, WMDrawable d, WMColor *color,
int x, int y, unsigned int w, unsigned int h,
int angle1, int angle2);
/* Create a stippled disabled mask from a source mask pixmap */
Pixmap (*create_disabled_mask)(void *rctx, Pixmap src_mask,
WMNativePixmap (*create_disabled_mask)(void *rctx, WMNativePixmap src_mask,
unsigned int width, unsigned int height);
} W_RenderBackend;
@ -640,16 +638,16 @@ typedef struct W_ViewBackend {
/* Appearance */
void (*set_background_color)(void *vctx, struct W_View *view, WMColor *color);
void (*set_cursor)(void *vctx, struct W_View *view, Cursor cursor);
void (*set_cursor)(void *vctx, struct W_View *view, WMNativeCursor cursor);
/* Trigger redisplay */
void (*redisplay)(void *vctx, struct W_View *view);
/* Selection ownership */
Bool (*selection_acquire)(void *vctx, struct W_View *view, Atom selection, Time timestamp);
void (*selection_release)(void *vctx, struct W_View *view, Atom selection);
Bool (*selection_request)(void *vctx, struct W_View *view, Atom selection, Atom target, Time timestamp);
char *(*selection_fetch)(void *vctx, Atom selection, int *len_out);
Bool (*selection_acquire)(void *vctx, struct W_View *view, WMNativeAtom selection, WMNativeTime timestamp);
void (*selection_release)(void *vctx, struct W_View *view, WMNativeAtom selection);
Bool (*selection_request)(void *vctx, struct W_View *view, WMNativeAtom selection, WMNativeAtom target, WMNativeTime timestamp);
char *(*selection_fetch)(void *vctx, WMNativeAtom selection, int *len_out);
/* Platform-specific post-init (e.g. X11 atoms, IM setup) */
void (*platform_init)(struct W_Screen *scr);
@ -667,7 +665,7 @@ typedef struct W_ViewBackend {
/* Drag and drop */
void (*drag_begin)(void *vctx, struct W_View *view, WMEvent *event);
/* Window properties (ICCCM/EWMH) — X11 sets properties, Wayland no-ops */
/* WNativeWindow properties (ICCCM/EWMH) — X11 sets properties, Wayland no-ops */
void (*window_set_title)(void *vctx, struct W_View *view, const char *title);
void (*window_set_icon_title)(void *vctx, struct W_View *view, const char *title);
void (*window_set_icon_image)(void *vctx, struct W_View *view, RImage *image);
@ -775,10 +773,9 @@ void W_UnFocusIC(WMView *view);
void W_SetPreeditPositon(W_View *view, int x, int y);
int W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer,
int buflen, KeySym *keysym, Status *status);
KeySym W_KeycodeToKeysym(Display *display, KeyCode keycode, int index);
/* X11 IM helpers W_LookupString / W_KeycodeToKeysym (which take Status *,
* KeyCode, XKeyPressedEvent *) are declared in WINGsX11.h; they're used
* only by winputmethod_x11.c. */
/* ---[ wmisc.c ]--------------------------------------------------------- */
@ -796,7 +793,7 @@ void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
WMAlignment alignment, W_Pixmap *image,
WMImagePosition position, WMColor *backColor, int ofs);
void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
void W_PaintText(W_View *view, WMDrawable d, WMFont *font, int x, int y,
int width, WMAlignment alignment, WMColor *color,
int wrap, const char *text, int length);
@ -807,8 +804,8 @@ int W_GetTextHeight(WMFont *font, const char *text, int width, int wrap);
struct W_Pixmap {
struct W_Screen *screen;
Pixmap pixmap;
Pixmap mask;
WMNativePixmap pixmap;
WMNativePixmap mask;
unsigned short width;
unsigned short height;
short depth;
@ -834,7 +831,7 @@ struct W_View {
W_ViewDelegate *delegate;
Window window;
WNativeWindow window;
WMSize size;
@ -859,7 +856,24 @@ struct W_View {
WMArray *eventHandlers; /* event handlers for this window */
unsigned long attribFlags;
XSetWindowAttributes attribs;
/*
* W_ViewAttribs — backend-neutral view attributes. Used to be
* XSetWindowAttributes; replaced with a small struct so the shared
* private header doesn't need <X11/Xlib.h>. The X11 view backend
* copies these fields into XSetWindowAttributes when calling
* XCreateWindow; other backends use them directly.
*/
struct {
WMNativePixmap background_pixmap;
unsigned long background_pixel;
unsigned long border_pixel;
WMNativeColormap colormap;
WMNativeCursor cursor;
Bool override_redirect;
Bool save_under;
long event_mask;
long do_not_propagate_mask;
} attribs;
void *hangedData; /* data holder for user program */
@ -867,15 +881,18 @@ struct W_View {
WMPixmap *backImage;
Cursor cursor;
WMNativeCursor cursor;
Atom *droppableTypes;
WMNativeAtom *droppableTypes;
struct W_DragSourceProcs *dragSourceProcs;
struct W_DragDestinationProcs *dragDestinationProcs;
WMPixmap *dragImage;
int helpContext;
XIC xic;
/* X11 input context. Opaque pointer (struct _XIC *) — the typedef
* is reachable via Xlib.h in X11 backend files; here we use void *
* so non-X11 files can include this header without Xlib. */
void *xic;
struct {
unsigned int realized:1;
@ -916,7 +933,7 @@ struct W_View {
/* -- Functions -- */
W_View *W_GetViewForXWindow(Display *display, Window window);
W_View *W_GetViewForXWindow(Display *display, WNativeWindow window);
W_View *W_CreateView(W_View *parent);
@ -960,7 +977,7 @@ void W_SetViewBackgroundColor(W_View *view, WMColor *color);
void W_SetViewBackgroundPixmap(W_View *view, WMPixmap *pix);
void W_SetViewCursor(W_View *view, Cursor cursor);
void W_SetViewCursor(W_View *view, WMNativeCursor cursor);
void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);

67
WINGs/WINGs/WINGsX11.h Normal file
View File

@ -0,0 +1,67 @@
/*
* WINGsX11.h — Private header for X11 backend internals.
*
* This header is included only by WINGs/*_x11.c source files. It
* declares prototypes that take native X11 types (XEvent,
* XClientMessageEvent, XKeyPressedEvent, etc.) by pointer or value.
*
* Putting these here, rather than in WINGsP.h, lets the shared
* private header stay X11-free so non-X11 files (the *_wl.c family)
* can include WINGsP.h without dragging libX11 in.
*
* Every X11 backend file should:
* #include <X11/Xlib.h> // libX11 native types
* #include "WINGsP.h" // backend-neutral private API
* #include "WINGs/WINGsX11.h" // (this file)
*/
#ifndef _WINGS_X11_INTERNAL_H_
#define _WINGS_X11_INTERNAL_H_
#include <X11/Xlib.h>
/* Forward-declare the WINGs types referenced below. Files including
* WINGsX11.h are expected to also include WINGsP.h for the full
* definitions. Forward decls let WINGsX11.h be order-independent. */
struct W_View;
struct W_Screen;
struct W_DraggingInfo;
typedef struct W_View WMView;
typedef struct W_View W_View;
typedef struct W_DraggingInfo WMDraggingInfo;
/* ---[ DnD: dragsource_x11.c / dragdestination_x11.c ] ----------------- */
typedef void *(W_X11DndState)(WMView *destView, XClientMessageEvent *event,
WMDraggingInfo *info);
void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
void W_DragSourceStateHandler(WMDraggingInfo *info, XClientMessageEvent *event);
void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info, WMView *toplevel,
XClientMessageEvent *event);
void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo *info,
WMView *toplevel,
XClientMessageEvent *event);
void W_DragDestinationStateHandler(WMDraggingInfo *info,
XClientMessageEvent *event);
/* ---[ Selection: selection_x11.c ] ------------------------------------ */
void W_HandleSelectionEvent(XEvent *event);
/* ---[ Input methods: winputmethod_x11.c ] ----------------------------- */
int W_LookupString(W_View *view, XKeyPressedEvent *event,
char *buffer, int buflen,
WMNativeKeysym *keysym, Status *status);
WMNativeKeysym W_KeycodeToKeysym(Display *display, KeyCode keycode, int index);
#endif /* _WINGS_X11_INTERNAL_H_ */

View File

@ -23,7 +23,6 @@
#define _WUTIL_H_
#include <WINGs/wnative.h>
#include <X11/Xlib.h>
#include <limits.h>
#include <sys/types.h>

View File

@ -40,12 +40,60 @@ typedef unsigned long WMNativeColormap;
* code that explicitly wants to step away from <X11/Xlib.h> definitions. */
typedef int WMNativeBool;
/* WMShortPoint — a {short x, short y} pair. Layout matches X11's
* XPoint so the X11 render backend can pass an array of these directly
* to XFillPolygon via cast. */
typedef struct WMShortPoint {
short x, y;
} WMShortPoint;
/* Bool / True / False — historically supplied by <X11/Xlib.h>. WINGs
* uses these types extensively in its public API. Define them here so
* WUtil.h / WINGs.h can stop including <X11/Xlib.h>. Guard with
* standard X11 macros so we don't double-define when both headers end
* up included (Xlib's typedef is identical). */
#ifndef _XFUNCPROTO_H_ /* X11 ships this header alongside Bool */
#ifndef Bool
#ifndef _Bool_DEFINED_BY_WINGS
#define _Bool_DEFINED_BY_WINGS
typedef int Bool;
#endif
#endif
#ifndef True
#define True 1
#endif
#ifndef False
#define False 0
#endif
#endif
/* Sentinel for "no resource". */
#define WM_NATIVE_NONE ((unsigned long)0)
#ifndef WNATIVE_NONE
#define WNATIVE_NONE WM_NATIVE_NONE
#endif
/* ------------------------------------------------------------------ */
/* Forward declarations of X11 opaque struct tags. */
/* */
/* The intent is that public WINGs headers (WUtil.h, WINGs.h) and the */
/* shared private header WINGsP.h do NOT include <X11/Xlib.h>. They */
/* refer to Display *, GC, and a handful of other X11 types only */
/* through these forward declarations. When an X11 backend file does */
/* #include <X11/Xlib.h>, the real definitions take over without */
/* conflicting with these (typedef redeclaration of the same struct */
/* tag is permitted by C11). */
/* ------------------------------------------------------------------ */
#if !defined(_XLIB_H_) && !defined(_X11_XLIB_H_)
typedef struct _XDisplay Display;
typedef struct _XGC *GC;
struct _XftDraw;
typedef struct _XftDraw XftDraw;
struct _XftFont;
typedef struct _XftFont XftFont;
#endif
/* ------------------------------------------------------------------ */
/* Modifier mask bits — used in WMEKey.state, WMEButton.state, etc. */
/* Values match X11 WM_MOD_SHIFT/WM_MOD_LOCK/... */

View File

@ -7,6 +7,7 @@
#include "wconfig.h"
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include <X11/Xlib.h>
@ -151,7 +152,7 @@ static void handleLeaveMessage(WMDraggingInfo * info)
}
}
void W_HandleDNDClientMessage(WMView * toplevel, XClientMessageEvent * event)
void W_HandleDNDClientMessage(WMView * toplevel, XClientMessageEvent *event)
{
WMScreen *scr = W_VIEW_SCREEN(toplevel);
WMDraggingInfo *info = &scr->dragInfo;

View File

@ -1,5 +1,6 @@
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include <X11/Xatom.h>
#define XDND_SOURCE_RESPONSE_MAX_DELAY 3000
@ -298,7 +299,7 @@ static void initDestinationDragInfo(WMDraggingInfo * info, WMView * destView)
XDND_DROP_DATAS(info) = NULL;
}
void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo * info, WMView * toplevel, XClientMessageEvent * event)
void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo * info, WMView * toplevel, XClientMessageEvent *event)
{
WMScreen *scr = W_VIEW_SCREEN(toplevel);
@ -322,7 +323,7 @@ void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo * info, WMView * toplevel
XDND_TYPE_LIST_AVAILABLE(info) = (event->data.l[1] & 1);
}
void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo * info, WMView * toplevel, XClientMessageEvent * event)
void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo * info, WMView * toplevel, XClientMessageEvent *event)
{
int x = event->data.l[2] >> 16;
int y = event->data.l[2] & 0xffff;
@ -621,7 +622,7 @@ void W_DragDestinationStartTimer(WMDraggingInfo * info)
/* ----- Destination states ----- */
#ifdef XDND_DEBUG
static const char *stateName(W_DndState * state)
static const char *stateName(W_X11DndState * state)
{
if (state == NULL)
return "no state defined";
@ -794,10 +795,10 @@ static void *waitForDropDataState(WMView * destView, XClientMessageEvent * event
/* ----- End of Destination states ----- */
void W_DragDestinationStateHandler(WMDraggingInfo * info, XClientMessageEvent * event)
void W_DragDestinationStateHandler(WMDraggingInfo * info, XClientMessageEvent *event)
{
WMView *destView;
W_DndState *newState;
W_X11DndState *newState;
wassertr(XDND_DEST_INFO(info) != NULL);
wassertr(XDND_DEST_VIEW(info) != NULL);
@ -811,7 +812,7 @@ void W_DragDestinationStateHandler(WMDraggingInfo * info, XClientMessageEvent *
printf("current dest state: %s\n", stateName(XDND_DEST_STATE(info)));
#endif
newState = (W_DndState *) XDND_DEST_STATE(info) (destView, event, info);
newState = ((W_X11DndState *)XDND_DEST_STATE(info)) (destView, event, info);
#ifdef XDND_DEBUG

View File

@ -1,6 +1,7 @@
#include "wconfig.h"
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
@ -41,7 +42,7 @@ static void *dropAllowedState(WMView * srcView, XClientMessageEvent * event, WMD
static void *finishDropState(WMView * srcView, XClientMessageEvent * event, WMDraggingInfo * info);
#ifdef XDND_DEBUG
static const char *stateName(W_DndState * state)
static const char *stateName(W_X11DndState * state)
{
if (state == NULL)
return "no state defined";
@ -1104,10 +1105,10 @@ void W_DragSourceStartTimer(WMDraggingInfo * info)
/* ----- End of Destination timer ----- */
void W_DragSourceStateHandler(WMDraggingInfo * info, XClientMessageEvent * event)
void W_DragSourceStateHandler(WMDraggingInfo * info, XClientMessageEvent *event)
{
WMView *view;
W_DndState *newState;
W_X11DndState *newState;
if (XDND_SOURCE_VIEW_STORED(info)) {
if (XDND_SOURCE_STATE(info) != NULL) {
@ -1117,7 +1118,7 @@ void W_DragSourceStateHandler(WMDraggingInfo * info, XClientMessageEvent * event
printf("current source state: %s\n", stateName(XDND_SOURCE_STATE(info)));
#endif
newState = (W_DndState *) XDND_SOURCE_STATE(info) (view, event, info);
newState = ((W_X11DndState *)XDND_SOURCE_STATE(info)) (view, event, info);
#ifdef XDND_DEBUG

View File

@ -4,6 +4,7 @@
#include <X11/Xatom.h>
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#define MAX_PROPERTY_SIZE 8*1024
@ -304,7 +305,7 @@ static void handleNotifyEvent(XEvent * event)
WMFreeArray(copy);
}
void W_HandleSelectionEvent(XEvent * event)
void W_HandleSelectionEvent(XEvent *event)
{
/*//printf("%d received selection ", event->xany.window); */
/*//switch(event->type) {

View File

@ -2,6 +2,7 @@
#include <unistd.h>
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include <X11/Xutil.h>

View File

@ -1,6 +1,7 @@
#include "wconfig.h"
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#ifdef USE_XSHAPE
#include <X11/extensions/shape.h>

View File

@ -1,3 +1,5 @@
#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */
/*
* wclient_wl.c — Wayland *client* backend for WINGs.
*

View File

@ -1,3 +1,5 @@
#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */
/*
* wcolor_wl.c - Wayland color backend for WINGs
*

View File

@ -5,6 +5,7 @@
*/
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include <wraster.h>
static void *x11_screen_init(W_Screen *scr)
@ -35,7 +36,7 @@ static WMColor *x11_alloc_color(void *cctx, W_Screen *scr,
color = wmalloc(sizeof(WMColor));
color->screen = scr;
color->refCount = 1;
color->color = xcolor;
memcpy(&color->color, &xcolor, sizeof(xcolor));
color->alpha = a;
color->flags.exact = 1;
color->gc = NULL;
@ -66,7 +67,7 @@ static WMColor *x11_find_close_color(void *cctx, W_Screen *scr,
color = wmalloc(sizeof(WMColor));
color->screen = scr;
color->refCount = 1;
color->color = xcolor;
memcpy(&color->color, &xcolor, sizeof(xcolor));
color->alpha = a;
color->flags.exact = 0;
color->gc = NULL;

View File

@ -25,6 +25,7 @@
#include "wconfig.h"
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include "rgb.h"
#include <errno.h>

View File

@ -1,3 +1,5 @@
#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */
/*
* wevent_wl.c — Wayland event backend for WINGs.
*

View File

@ -7,6 +7,7 @@
#include "wconfig.h"
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include <string.h>
#include <X11/Xlib.h>

View File

@ -1,3 +1,5 @@
#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */
/*
* wfont_wl.c — Wayland/PangoFT2 + pixman font backend for WINGs.
*

View File

@ -7,6 +7,7 @@
#include "wconfig.h"
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include <X11/Xft/Xft.h>
#include <fontconfig/fontconfig.h>

View File

@ -11,6 +11,7 @@
*/
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include "wconfig.h"
#include <X11/Xutil.h>

View File

@ -4,6 +4,7 @@
#include "wconfig.h"
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
typedef struct W_IMContext {
XIM xim;

View File

@ -1,3 +1,5 @@
#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */
#include "WINGsP.h"
#include <pixman.h>
@ -169,8 +171,9 @@ render_wl_composite_pixmap(void *rctx, WMDrawable dst, W_Pixmap *src,
static void
render_wl_fill_polygon(void *rctx, WMDrawable d, WMColor *color,
XPoint *points, int npoints)
void *points_v, int npoints)
{
WMShortPoint *points = points_v;
(void)rctx;
if (npoints < 3) return;
pixman_image_t *dst = resolve_drawable(d); if (!dst) return;

View File

@ -1,5 +1,6 @@
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
typedef struct {
W_Screen *scr;
@ -106,8 +107,9 @@ render_x11_composite_pixmap(void *rctx, WMDrawable dst, W_Pixmap *src,
static void
render_x11_fill_polygon(void *rctx, WMDrawable d, WMColor *color,
XPoint *points, int npoints)
void *points_v, int npoints)
{
XPoint *points = points_v;
RenderCtxX11 *ctx = rctx;
XFillPolygon(ctx->scr->display, (Drawable)d, WMColorGC(color),
points, npoints, Convex, CoordModeOrigin);

View File

@ -53,26 +53,17 @@ static void adoptChildView(W_View * view, W_View * child)
child->parent = view;
}
static const XSetWindowAttributes defAtts = {
WM_NATIVE_NONE, /* background_pixmap */
0, /* background_pixel */
WM_NATIVE_NONE, /* border_pixmap */
0, /* border_pixel */
NorthWestGravity, /* bit_gravity */
NorthWestGravity, /* win_gravity */
NotUseful, /* backing_store */
(unsigned)~0, /* backing_planes */
0, /* backing_pixel */
False, /* save_under */
/* defAtts: previously an XSetWindowAttributes with the standard event-
* mask wmaker views care about. Now that W_View.attribs is a small
* backend-neutral struct, we assign field-by-field instead of copying
* an XSetWindowAttributes by value. The bit_gravity / backing_store /
* win_gravity fields the X11 backend used to read are left at zero;
* the wview_x11.c side fills them in from sensible defaults. */
static const long DEF_ATTS_EVENT_MASK =
WM_EVMASK_KEY_PRESS|WM_EVMASK_KEY_RELEASE|WM_EVMASK_BUTTON_PRESS|WM_EVMASK_BUTTON_RELEASE|
WM_EVMASK_ENTER_WINDOW|WM_EVMASK_LEAVE_WINDOW|WM_EVMASK_POINTER_MOTION|WM_EVMASK_EXPOSURE|
WM_EVMASK_VISIBILITY_CHANGE|WM_EVMASK_FOCUS_CHANGE|WM_EVMASK_PROPERTY_CHANGE|
WM_EVMASK_SUBSTRUCTURE_NOTIFY, /* event_mask */
0, /* do_not_propagate_mask */
False, /* override_redirect */
WM_NATIVE_NONE, /* colormap */
WM_NATIVE_NONE /* cursor */
};
WM_EVMASK_SUBSTRUCTURE_NOTIFY;
static W_View *createView(W_Screen * screen, W_View * parent)
{
@ -83,7 +74,12 @@ static W_View *createView(W_Screen * screen, W_View * parent)
if (parent != NULL) {
view->attribFlags = CWEventMask | CWBitGravity;
view->attribs = defAtts;
view->attribs.background_pixmap = WM_NATIVE_NONE;
view->attribs.colormap = WM_NATIVE_NONE;
view->attribs.cursor = WM_NATIVE_NONE;
view->attribs.event_mask = DEF_ATTS_EVENT_MASK;
view->attribs.override_redirect = False;
view->attribs.save_under = False;
view->attribFlags |= CWBackPixel | CWColormap | CWBorderPixel | CWBackPixmap;
view->attribs.background_pixmap = WM_NATIVE_NONE;

View File

@ -1,3 +1,5 @@
#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */
/*
* wview_wl.c - Wayland view backend for WINGs
*

View File

@ -5,6 +5,7 @@
*/
#include "WINGsP.h"
#include "WINGs/WINGsX11.h"
#include "wwindow_p.h"
#include <X11/Xresource.h>
#include <X11/Xatom.h>
@ -41,10 +42,28 @@ static void x11_realize(void *vctx, W_View *view)
Display *dpy = scr->display;
Window parentWID = view->parent->window;
/* Build XSetWindowAttributes from the backend-neutral W_View
* attribs. W_View.attribs no longer has the X11 layout (so the
* shared header can be Xlib-free); copy field-by-field here. */
XSetWindowAttributes xattribs;
memset(&xattribs, 0, sizeof(xattribs));
xattribs.background_pixmap = view->attribs.background_pixmap;
xattribs.background_pixel = view->attribs.background_pixel;
xattribs.border_pixel = view->attribs.border_pixel;
xattribs.colormap = view->attribs.colormap;
xattribs.cursor = view->attribs.cursor;
xattribs.override_redirect = view->attribs.override_redirect;
xattribs.save_under = view->attribs.save_under;
xattribs.event_mask = view->attribs.event_mask;
xattribs.do_not_propagate_mask = view->attribs.do_not_propagate_mask;
xattribs.bit_gravity = NorthWestGravity;
xattribs.win_gravity = NorthWestGravity;
xattribs.backing_store = NotUseful;
view->window = XCreateWindow(dpy, parentWID, view->pos.x, view->pos.y,
view->size.width, view->size.height, 0,
scr->depth, InputOutput,
scr->visual, view->attribFlags, &view->attribs);
scr->visual, view->attribFlags, &xattribs);
XSaveContext(dpy, view->window, ViewContext, (XPointer)view);
}

View File

@ -22,6 +22,7 @@
#include "config.h" /* for HAVE_XCONVERTCASE */
#include "WPrefs.h"
#include <WINGs/WINGsX11.h>
#include <ctype.h>
#include <X11/keysym.h>

View File

@ -121,6 +121,7 @@ typedef struct _Panel {
/* need access to the double click variables */
#include <WINGs/WINGsP.h>
#include <WINGs/WINGsX11.h>
static char *modifierNames[8];

View File

@ -38,6 +38,7 @@ Perpetrator: Sudish Joseph <sj@eng.mindspring.net>, Sept. 1997. */
#include <X11/XKBlib.h>
#include <WINGs/WUtil.h>
#include <WINGs/WINGsX11.h>
#include "WPrefs.h"

View File

@ -43,6 +43,7 @@
#include <wraster.h>
#include <WINGs/WINGsP.h>
#include <WINGs/WINGsX11.h>
#include "../../WindowMaker.h" /* dpy, w_global, wPreferences, wfatal */
#include "../../screen.h" /* WScreen fields */

View File

@ -25,6 +25,7 @@
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <WINGs/WINGsP.h>
#include <WINGs/WINGsX11.h>
#include <wraster.h>
#include <stdlib.h>
#include <stdio.h>

View File

@ -44,9 +44,44 @@
#define WRASTER_HEADER_VERSION 25
/* X11 types are used throughout the wraster public API for the X11
* conversion path (RConvertImage, RPutXImage, RCreateContext, etc.).
* To allow Wayland-only consumers (WINGs Wayland-client backend) to
* include this header without dragging in libX11, the X11 headers are
* skipped when WRASTER_NO_XLIB is defined; opaque forward declarations
* stand in for Display/Visual/GC/XImage so the prototypes still parse. */
#ifdef WRASTER_NO_XLIB
typedef struct _XDisplay Display;
typedef struct _XVisual Visual;
typedef struct _XImage XImage;
typedef struct _XGC *GC;
typedef struct _XftFont XftFont;
typedef unsigned long Pixmap;
typedef unsigned long Colormap;
typedef unsigned long Drawable;
typedef unsigned long VisualID;
typedef unsigned long XID;
typedef unsigned long Window;
typedef unsigned long Atom;
typedef unsigned long Cursor;
typedef unsigned long Time;
typedef unsigned long KeySym;
typedef int KeyCode;
typedef int Status;
struct _XColor;
typedef struct _XColor XColor;
struct _XStandardColormap;
typedef struct _XStandardColormap XStandardColormap;
struct _XShmSegmentInfo;
typedef struct _XShmSegmentInfo XShmSegmentInfo;
#ifndef Bool
typedef int Bool;
#endif
#else
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@USE_XSHM@#include <X11/extensions/XShm.h>
#endif
/*
@ -264,9 +299,11 @@ struct RImage {
typedef struct RXImage {
XImage *image;
#ifndef WRASTER_NO_XLIB
@USE_XSHM@ /* Private data. Do not access */
@USE_XSHM@ XShmSegmentInfo info;
@USE_XSHM@ char is_shared;
#endif
} RXImage;