diff --git a/WINGs/WINGs/Makefile.am b/WINGs/WINGs/Makefile.am index 43b7029..3f02610 100644 --- a/WINGs/WINGs/Makefile.am +++ b/WINGs/WINGs/Makefile.am @@ -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 diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index 42f1d99..ede3f32 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -26,7 +26,6 @@ #include #include #include -#include #define WINGS_H_VERSION 20230226 diff --git a/WINGs/WINGs/WINGsP.h.in b/WINGs/WINGs/WINGsP.h.in index 51ce826..f22bb26 100644 --- a/WINGs/WINGs/WINGsP.h.in +++ b/WINGs/WINGs/WINGsP.h.in @@ -2,9 +2,6 @@ #define _WINGSP_H_ -#include -#include - @USE_PANGO@#include #include @@ -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 . 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); diff --git a/WINGs/WINGs/WINGsX11.h b/WINGs/WINGs/WINGsX11.h new file mode 100644 index 0000000..1a5386a --- /dev/null +++ b/WINGs/WINGs/WINGsX11.h @@ -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 // 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 + +/* 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_ */ diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h index ae26afc..6d0e6d7 100644 --- a/WINGs/WINGs/WUtil.h +++ b/WINGs/WINGs/WUtil.h @@ -23,7 +23,6 @@ #define _WUTIL_H_ #include -#include #include #include diff --git a/WINGs/WINGs/wnative.h b/WINGs/WINGs/wnative.h index 0bc2d69..e21b148 100644 --- a/WINGs/WINGs/wnative.h +++ b/WINGs/WINGs/wnative.h @@ -40,12 +40,60 @@ typedef unsigned long WMNativeColormap; * code that explicitly wants to step away from 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 . WINGs + * uses these types extensively in its public API. Define them here so + * WUtil.h / WINGs.h can stop including . 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 . They */ +/* refer to Display *, GC, and a handful of other X11 types only */ +/* through these forward declarations. When an X11 backend file does */ +/* #include , 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/... */ diff --git a/WINGs/dragcommon_x11.c b/WINGs/dragcommon_x11.c index f2de058..891da4f 100644 --- a/WINGs/dragcommon_x11.c +++ b/WINGs/dragcommon_x11.c @@ -7,6 +7,7 @@ #include "wconfig.h" #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include @@ -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; diff --git a/WINGs/dragdestination_x11.c b/WINGs/dragdestination_x11.c index 76acbd9..48fc1e7 100644 --- a/WINGs/dragdestination_x11.c +++ b/WINGs/dragdestination_x11.c @@ -1,5 +1,6 @@ #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include #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 diff --git a/WINGs/dragsource_x11.c b/WINGs/dragsource_x11.c index b1ba6e6..7f54a45 100644 --- a/WINGs/dragsource_x11.c +++ b/WINGs/dragsource_x11.c @@ -1,6 +1,7 @@ #include "wconfig.h" #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include #include @@ -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 diff --git a/WINGs/selection_x11.c b/WINGs/selection_x11.c index 1ca517a..6507730 100644 --- a/WINGs/selection_x11.c +++ b/WINGs/selection_x11.c @@ -4,6 +4,7 @@ #include #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) { diff --git a/WINGs/wappresource_x11.c b/WINGs/wappresource_x11.c index cd0b037..d5a9932 100644 --- a/WINGs/wappresource_x11.c +++ b/WINGs/wappresource_x11.c @@ -2,6 +2,7 @@ #include #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include diff --git a/WINGs/wballoon_x11.c b/WINGs/wballoon_x11.c index c30bb41..e91f181 100644 --- a/WINGs/wballoon_x11.c +++ b/WINGs/wballoon_x11.c @@ -1,6 +1,7 @@ #include "wconfig.h" #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #ifdef USE_XSHAPE #include diff --git a/WINGs/wclient_wl.c b/WINGs/wclient_wl.c index b50e6f8..1793930 100644 --- a/WINGs/wclient_wl.c +++ b/WINGs/wclient_wl.c @@ -1,3 +1,5 @@ +#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */ + /* * wclient_wl.c — Wayland *client* backend for WINGs. * diff --git a/WINGs/wcolor_wl.c b/WINGs/wcolor_wl.c index eeb82ca..499dcac 100644 --- a/WINGs/wcolor_wl.c +++ b/WINGs/wcolor_wl.c @@ -1,3 +1,5 @@ +#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */ + /* * wcolor_wl.c - Wayland color backend for WINGs * diff --git a/WINGs/wcolor_x11.c b/WINGs/wcolor_x11.c index 7c5fce0..2694c92 100644 --- a/WINGs/wcolor_x11.c +++ b/WINGs/wcolor_x11.c @@ -5,6 +5,7 @@ */ #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include 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; diff --git a/WINGs/wcolorpanel_x11.c b/WINGs/wcolorpanel_x11.c index 0b387b3..5adbce3 100644 --- a/WINGs/wcolorpanel_x11.c +++ b/WINGs/wcolorpanel_x11.c @@ -25,6 +25,7 @@ #include "wconfig.h" #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include "rgb.h" #include diff --git a/WINGs/wevent_wl.c b/WINGs/wevent_wl.c index 4c18d77..f45ad05 100644 --- a/WINGs/wevent_wl.c +++ b/WINGs/wevent_wl.c @@ -1,3 +1,5 @@ +#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */ + /* * wevent_wl.c — Wayland event backend for WINGs. * diff --git a/WINGs/wevent_x11.c b/WINGs/wevent_x11.c index 174b151..11354a2 100644 --- a/WINGs/wevent_x11.c +++ b/WINGs/wevent_x11.c @@ -7,6 +7,7 @@ #include "wconfig.h" #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include #include diff --git a/WINGs/wfont_wl.c b/WINGs/wfont_wl.c index dfa2e98..af1ed3b 100644 --- a/WINGs/wfont_wl.c +++ b/WINGs/wfont_wl.c @@ -1,3 +1,5 @@ +#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */ + /* * wfont_wl.c — Wayland/PangoFT2 + pixman font backend for WINGs. * diff --git a/WINGs/wfont_x11.c b/WINGs/wfont_x11.c index 8c1d6b3..911949c 100644 --- a/WINGs/wfont_x11.c +++ b/WINGs/wfont_x11.c @@ -7,6 +7,7 @@ #include "wconfig.h" #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include #include diff --git a/WINGs/widgets_x11.c b/WINGs/widgets_x11.c index f944714..76f228a 100644 --- a/WINGs/widgets_x11.c +++ b/WINGs/widgets_x11.c @@ -11,6 +11,7 @@ */ #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include "wconfig.h" #include diff --git a/WINGs/winputmethod_x11.c b/WINGs/winputmethod_x11.c index 65c0447..0127657 100644 --- a/WINGs/winputmethod_x11.c +++ b/WINGs/winputmethod_x11.c @@ -4,6 +4,7 @@ #include "wconfig.h" #include "WINGsP.h" +#include "WINGs/WINGsX11.h" typedef struct W_IMContext { XIM xim; diff --git a/WINGs/wrender_wl.c b/WINGs/wrender_wl.c index 7555cad..5406de8 100644 --- a/WINGs/wrender_wl.c +++ b/WINGs/wrender_wl.c @@ -1,3 +1,5 @@ +#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */ + #include "WINGsP.h" #include @@ -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; diff --git a/WINGs/wrender_x11.c b/WINGs/wrender_x11.c index 6c6bf51..8879455 100644 --- a/WINGs/wrender_x11.c +++ b/WINGs/wrender_x11.c @@ -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); diff --git a/WINGs/wview.c b/WINGs/wview.c index 8e8a12c..1d0f82f 100644 --- a/WINGs/wview.c +++ b/WINGs/wview.c @@ -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 */ - 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 */ -}; +/* 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; 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; diff --git a/WINGs/wview_wl.c b/WINGs/wview_wl.c index 296ab74..218ec5e 100644 --- a/WINGs/wview_wl.c +++ b/WINGs/wview_wl.c @@ -1,3 +1,5 @@ +#define WRASTER_NO_XLIB /* Wayland-only file: no libX11 deps */ + /* * wview_wl.c - Wayland view backend for WINGs * diff --git a/WINGs/wview_x11.c b/WINGs/wview_x11.c index 9243872..9e6dfcb 100644 --- a/WINGs/wview_x11.c +++ b/WINGs/wview_x11.c @@ -5,6 +5,7 @@ */ #include "WINGsP.h" +#include "WINGs/WINGsX11.h" #include "wwindow_p.h" #include #include @@ -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); } diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 04b476f..496fea6 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -22,6 +22,7 @@ #include "config.h" /* for HAVE_XCONVERTCASE */ #include "WPrefs.h" +#include #include #include diff --git a/WPrefs.app/MouseSettings.c b/WPrefs.app/MouseSettings.c index 249b3cc..1800c8f 100644 --- a/WPrefs.app/MouseSettings.c +++ b/WPrefs.app/MouseSettings.c @@ -121,6 +121,7 @@ typedef struct _Panel { /* need access to the double click variables */ #include +#include static char *modifierNames[8]; diff --git a/WPrefs.app/xmodifier.c b/WPrefs.app/xmodifier.c index d65c771..c291856 100644 --- a/WPrefs.app/xmodifier.c +++ b/WPrefs.app/xmodifier.c @@ -38,6 +38,7 @@ Perpetrator: Sudish Joseph , Sept. 1997. */ #include #include +#include #include "WPrefs.h" diff --git a/src/backend/x11/x11_backend.c b/src/backend/x11/x11_backend.c index 9289fe6..bce1992 100644 --- a/src/backend/x11/x11_backend.c +++ b/src/backend/x11/x11_backend.c @@ -43,6 +43,7 @@ #include #include +#include #include "../../WindowMaker.h" /* dpy, w_global, wPreferences, wfatal */ #include "../../screen.h" /* WScreen fields */ diff --git a/util/wmiv.c b/util/wmiv.c index 0d33a53..3c60a57 100755 --- a/util/wmiv.c +++ b/util/wmiv.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/wrlib/wraster.h.in b/wrlib/wraster.h.in index 95d31c8..d8f80ec 100644 --- a/wrlib/wraster.h.in +++ b/wrlib/wraster.h.in @@ -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 #include @USE_XSHM@#include +#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;