From f9626b8791b204e2abc39cfc211befbaa74d7202 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 7 Nov 2016 14:15:04 +0000 Subject: Add another few Xlib stubs for Win32. Cherry-picked from [http://www.androwish.org/index.html/info/862eb620a096fddc|AndroWish]. Thanks to Christian Werner. --- .fossil-settings/crlf-glob | 6 +++ generic/tkInt.decls | 70 +++++++++++++++++++++----- generic/tkIntXlibDecls.h | 121 ++++++++++++++++++++++++++++++++++++++++++--- generic/tkStubInit.c | 26 ++++++++++ macosx/tkMacOSXDraw.c | 5 +- win/tkWinDraw.c | 89 +++++++++++++++++++++++++++++++-- win/tkWinWindow.c | 41 ++++++++++++++- win/tkWinX.c | 5 +- xlib/X11/Xutil.h | 4 +- xlib/xgc.c | 15 +++--- 10 files changed, 346 insertions(+), 36 deletions(-) create mode 100644 .fossil-settings/crlf-glob diff --git a/.fossil-settings/crlf-glob b/.fossil-settings/crlf-glob new file mode 100644 index 0000000..7175730 --- /dev/null +++ b/.fossil-settings/crlf-glob @@ -0,0 +1,6 @@ +win/buildall.vc.bat +win/makefile.bc +win/makefile.vc +win/mkd.bat +win/rmd.bat +win/rules.vc diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 586b407..a13d8d7 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1422,28 +1422,76 @@ declare 106 win { # New in Tk 8.6 declare 107 win { - int XFlush(Display *display) + int XFlush(Display *display) } declare 108 win { - int XGrabServer(Display *display) + int XGrabServer(Display *display) } declare 109 win { - int XUngrabServer(Display *display) + int XUngrabServer(Display *display) } declare 110 win { - int XFree(void *data) + int XFree(void *data) } declare 111 win { - int XNoOp(Display *display) + int XNoOp(Display *display) } declare 112 win { - XAfterFunction XSynchronize(Display *display, Bool onoff) + XAfterFunction XSynchronize(Display *display, Bool onoff) } declare 113 win { - int XSync(Display *display, Bool discard) + int XSync(Display *display, Bool discard) } declare 114 win { - VisualID XVisualIDFromVisual(Visual *visual) + VisualID XVisualIDFromVisual(Visual *visual) +} + +# For tktreectrl +declare 120 win { + int XOffsetRegion(Region rgn, int dx, int dy) +} +declare 121 win { + int XUnionRegion(Region srca, Region srcb, Region dr_return) +} + +# For 3dcanvas +declare 122 win { + Window XCreateWindow(Display *display, Window parent, int x, int y, + unsigned int width, unsigned int height, + unsigned int border_width, int depth, unsigned int clazz, + Visual *visual, unsigned long value_mask, + XSetWindowAttributes *attributes) +} + +# Various, e.g. for stub-enabled BLT +declare 129 win { + int XLowerWindow(Display *d, Window w) +} +declare 130 win { + int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a, int n) +} +declare 131 win { + int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a, int n) +} +declare 132 win { + int XDrawRectangles(Display *d, Drawable dr, GC gc, XRectangle *r, int n) +} +declare 133 win { + int XDrawSegments(Display *d, Drawable dr, GC gc, XSegment *s, int n) +} +declare 134 win { + int XDrawPoint(Display *d, Drawable dr, GC gc, int x, int y) +} +declare 135 win { + int XDrawPoints(Display *d, Drawable dr, GC gc, XPoint *p, int n, int m) +} +declare 136 win { + int XReparentWindow(Display *d, Window w, Window p, int x, int y) +} +declare 137 win { + int XPutImage(Display *d, Drawable dr, GC gc, XImage *im, + int sx, int sy, int dx, int dy, + unsigned int w, unsigned int h) } ################################ @@ -1725,7 +1773,7 @@ declare 79 aqua { XTextProperty *text_prop_return) } declare 80 aqua { - void XDrawSegments(Display *display, Drawable d, GC gc, + int XDrawSegments(Display *display, Drawable d, GC gc, XSegment *segments, int nsegments) } declare 81 aqua { @@ -1743,10 +1791,10 @@ declare 84 aqua { void XClearWindow(Display *d, Window w) } declare 85 aqua { - void XDrawPoint(Display *display, Drawable d, GC gc, int x, int y) + int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y) } declare 86 aqua { - void XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, + int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode) } declare 87 aqua { diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 6ac7ccb..8e7d650 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -356,6 +356,57 @@ EXTERN XAfterFunction XSynchronize(Display *display, Bool onoff); EXTERN int XSync(Display *display, Bool discard); /* 114 */ EXTERN VisualID XVisualIDFromVisual(Visual *visual); +/* Slot 115 is reserved */ +/* Slot 116 is reserved */ +/* Slot 117 is reserved */ +/* Slot 118 is reserved */ +/* Slot 119 is reserved */ +/* 120 */ +EXTERN int XOffsetRegion(Region rgn, int dx, int dy); +/* 121 */ +EXTERN int XUnionRegion(Region srca, Region srcb, + Region dr_return); +/* 122 */ +EXTERN Window XCreateWindow(Display *display, Window parent, int x, + int y, unsigned int width, + unsigned int height, + unsigned int border_width, int depth, + unsigned int clazz, Visual *visual, + unsigned long value_mask, + XSetWindowAttributes *attributes); +/* Slot 123 is reserved */ +/* Slot 124 is reserved */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ +/* 129 */ +EXTERN int XLowerWindow(Display *d, Window w); +/* 130 */ +EXTERN int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a, + int n); +/* 131 */ +EXTERN int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a, + int n); +/* 132 */ +EXTERN int XDrawRectangles(Display *d, Drawable dr, GC gc, + XRectangle *r, int n); +/* 133 */ +EXTERN int XDrawSegments(Display *d, Drawable dr, GC gc, + XSegment *s, int n); +/* 134 */ +EXTERN int XDrawPoint(Display *d, Drawable dr, GC gc, int x, + int y); +/* 135 */ +EXTERN int XDrawPoints(Display *d, Drawable dr, GC gc, + XPoint *p, int n, int m); +/* 136 */ +EXTERN int XReparentWindow(Display *d, Window w, Window p, + int x, int y); +/* 137 */ +EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im, + int sx, int sy, int dx, int dy, + unsigned int w, unsigned int h); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ /* 0 */ @@ -584,7 +635,7 @@ EXTERN void XSetWMClientMachine(Display *display, Window w, EXTERN Status XStringListToTextProperty(char **list, int count, XTextProperty *text_prop_return); /* 80 */ -EXTERN void XDrawSegments(Display *display, Drawable d, GC gc, +EXTERN int XDrawSegments(Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 81 */ EXTERN void XForceScreenSaver(Display *display, int mode); @@ -598,10 +649,10 @@ EXTERN int XFillRectangle(Display *display, Drawable d, GC gc, /* 84 */ EXTERN void XClearWindow(Display *d, Window w); /* 85 */ -EXTERN void XDrawPoint(Display *display, Drawable d, GC gc, +EXTERN int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y); /* 86 */ -EXTERN void XDrawPoints(Display *display, Drawable d, GC gc, +EXTERN int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 87 */ EXTERN int XWarpPointer(Display *display, Window src_w, @@ -742,6 +793,29 @@ typedef struct TkIntXlibStubs { XAfterFunction (*xSynchronize) (Display *display, Bool onoff); /* 112 */ int (*xSync) (Display *display, Bool discard); /* 113 */ VisualID (*xVisualIDFromVisual) (Visual *visual); /* 114 */ + void (*reserved115)(void); + void (*reserved116)(void); + void (*reserved117)(void); + void (*reserved118)(void); + void (*reserved119)(void); + int (*xOffsetRegion) (Region rgn, int dx, int dy); /* 120 */ + int (*xUnionRegion) (Region srca, Region srcb, Region dr_return); /* 121 */ + Window (*xCreateWindow) (Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth, unsigned int clazz, Visual *visual, unsigned long value_mask, XSetWindowAttributes *attributes); /* 122 */ + void (*reserved123)(void); + void (*reserved124)(void); + void (*reserved125)(void); + void (*reserved126)(void); + void (*reserved127)(void); + void (*reserved128)(void); + int (*xLowerWindow) (Display *d, Window w); /* 129 */ + int (*xFillArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 130 */ + int (*xDrawArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 131 */ + int (*xDrawRectangles) (Display *d, Drawable dr, GC gc, XRectangle *r, int n); /* 132 */ + int (*xDrawSegments) (Display *d, Drawable dr, GC gc, XSegment *s, int n); /* 133 */ + int (*xDrawPoint) (Display *d, Drawable dr, GC gc, int x, int y); /* 134 */ + int (*xDrawPoints) (Display *d, Drawable dr, GC gc, XPoint *p, int n, int m); /* 135 */ + int (*xReparentWindow) (Display *d, Window w, Window p, int x, int y); /* 136 */ + int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ int (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */ @@ -824,13 +898,13 @@ typedef struct TkIntXlibStubs { XVisualInfo * (*xGetVisualInfo) (Display *display, long vinfo_mask, XVisualInfo *vinfo_template, int *nitems_return); /* 77 */ void (*xSetWMClientMachine) (Display *display, Window w, XTextProperty *text_prop); /* 78 */ Status (*xStringListToTextProperty) (char **list, int count, XTextProperty *text_prop_return); /* 79 */ - void (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */ + int (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */ void (*xForceScreenSaver) (Display *display, int mode); /* 81 */ int (*xDrawLine) (Display *d, Drawable dr, GC g, int x1, int y1, int x2, int y2); /* 82 */ int (*xFillRectangle) (Display *display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); /* 83 */ void (*xClearWindow) (Display *d, Window w); /* 84 */ - void (*xDrawPoint) (Display *display, Drawable d, GC gc, int x, int y); /* 85 */ - void (*xDrawPoints) (Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 86 */ + int (*xDrawPoint) (Display *display, Drawable d, GC gc, int x, int y); /* 85 */ + int (*xDrawPoints) (Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 86 */ int (*xWarpPointer) (Display *display, Window src_w, Window dest_w, int src_x, int src_y, unsigned int src_width, unsigned int src_height, int dest_x, int dest_y); /* 87 */ void (*xQueryColor) (Display *display, Colormap colormap, XColor *def_in_out); /* 88 */ void (*xQueryColors) (Display *display, Colormap colormap, XColor *defs_in_out, int ncolors); /* 89 */ @@ -1081,6 +1155,41 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; (tkIntXlibStubsPtr->xSync) /* 113 */ #define XVisualIDFromVisual \ (tkIntXlibStubsPtr->xVisualIDFromVisual) /* 114 */ +/* Slot 115 is reserved */ +/* Slot 116 is reserved */ +/* Slot 117 is reserved */ +/* Slot 118 is reserved */ +/* Slot 119 is reserved */ +#define XOffsetRegion \ + (tkIntXlibStubsPtr->xOffsetRegion) /* 120 */ +#define XUnionRegion \ + (tkIntXlibStubsPtr->xUnionRegion) /* 121 */ +#define XCreateWindow \ + (tkIntXlibStubsPtr->xCreateWindow) /* 122 */ +/* Slot 123 is reserved */ +/* Slot 124 is reserved */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ +#define XLowerWindow \ + (tkIntXlibStubsPtr->xLowerWindow) /* 129 */ +#define XFillArcs \ + (tkIntXlibStubsPtr->xFillArcs) /* 130 */ +#define XDrawArcs \ + (tkIntXlibStubsPtr->xDrawArcs) /* 131 */ +#define XDrawRectangles \ + (tkIntXlibStubsPtr->xDrawRectangles) /* 132 */ +#define XDrawSegments \ + (tkIntXlibStubsPtr->xDrawSegments) /* 133 */ +#define XDrawPoint \ + (tkIntXlibStubsPtr->xDrawPoint) /* 134 */ +#define XDrawPoints \ + (tkIntXlibStubsPtr->xDrawPoints) /* 135 */ +#define XReparentWindow \ + (tkIntXlibStubsPtr->xReparentWindow) /* 136 */ +#define XPutImage \ + (tkIntXlibStubsPtr->xPutImage) /* 137 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ #define XSetDashes \ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index f08d7f4..9411c26 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -62,6 +62,9 @@ TkCreateXEventSource(void) # define TkUnixContainerId 0 # define TkUnixDoOneXEvent 0 # define TkUnixSetMenubar 0 +# define XCreateWindow 0 +# define XOffsetRegion 0 +# define XUnionRegion 0 # define TkWmCleanup (void (*)(TkDisplay *)) TkpSync # define TkSendCleanup (void (*)(TkDisplay *)) TkpSync # define TkpTestsendCmd 0 @@ -698,6 +701,29 @@ static const TkIntXlibStubs tkIntXlibStubs = { XSynchronize, /* 112 */ XSync, /* 113 */ XVisualIDFromVisual, /* 114 */ + 0, /* 115 */ + 0, /* 116 */ + 0, /* 117 */ + 0, /* 118 */ + 0, /* 119 */ + XOffsetRegion, /* 120 */ + XUnionRegion, /* 121 */ + XCreateWindow, /* 122 */ + 0, /* 123 */ + 0, /* 124 */ + 0, /* 125 */ + 0, /* 126 */ + 0, /* 127 */ + 0, /* 128 */ + XLowerWindow, /* 129 */ + XFillArcs, /* 130 */ + XDrawArcs, /* 131 */ + XDrawRectangles, /* 132 */ + XDrawSegments, /* 133 */ + XDrawPoint, /* 134 */ + XDrawPoints, /* 135 */ + XReparentWindow, /* 136 */ + XPutImage, /* 137 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ XSetDashes, /* 0 */ diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f48538d..f85d6ac 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -880,7 +880,7 @@ XDrawLines( *---------------------------------------------------------------------- */ -void +int XDrawSegments( Display *display, Drawable d, @@ -894,7 +894,7 @@ XDrawSegments( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { double o = (lw % 2) ? .5 : 0; @@ -911,6 +911,7 @@ XDrawSegments( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } /* diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index ba4176c..bb903db 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -486,7 +486,7 @@ XCopyPlane( /* *---------------------------------------------------------------------- * - * TkPutImage -- + * TkPutImage, XPutImage -- * * Copies a subimage from an in-memory image to a rectangle of of the * specified drawable. @@ -599,6 +599,21 @@ TkPutImage( TkWinReleaseDrawableDC(d, dc, &state); return Success; } + +int +XPutImage( + Display *display, + Drawable d, /* Destination drawable. */ + GC gc, + XImage *image, /* Source image. */ + int src_x, int src_y, /* Offset of subimage. */ + int dest_x, int dest_y, /* Position of subimage origin in drawable. */ + unsigned int width, unsigned int height) + /* Dimensions of subimage. */ +{ + return TkPutImage(NULL, 0, display, d, gc, image, + src_x, src_y, dest_x, dest_y, width, height); +} /* *---------------------------------------------------------------------- @@ -940,7 +955,7 @@ XFillPolygon( /* *---------------------------------------------------------------------- * - * XDrawRectangle -- + * XDrawRectangle, XDrawRectangles -- * * Draws a rectangle. * @@ -985,11 +1000,31 @@ XDrawRectangle( TkWinReleaseDrawableDC(d, dc, &state); return Success; } + +int +XDrawRectangles( + Display *display, + Drawable d, + GC gc, + XRectangle rects[], + int nrects) +{ + int n, ret; + + for (n = 0; n < nrects; n++) { + ret = XDrawRectangle(display, d, gc, rects[n].x, rects[n].y, + rects[n].width, rects[n].height); + if (ret != Success) { + break; + } + } + return ret; +} /* *---------------------------------------------------------------------- * - * XDrawArc -- + * XDrawArc, XDrawArcs -- * * Draw an arc. * @@ -1015,11 +1050,34 @@ XDrawArc( return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 0); } + +int +XDrawArcs( + Display *display, + Drawable d, + GC gc, + XArc *arcs, + int narcs) +{ + int n, ret; + + display->request++; + + for (n = 0; n < narcs; n++) { + ret = DrawOrFillArc(display, d, gc, arcs[n].x, arcs[n].y, + arcs[n].width, arcs[n].height, + arcs[n].angle1, arcs[n].angle2, 0); + if (ret != Success) { + break; + } + } + return ret; +} /* *---------------------------------------------------------------------- * - * XFillArc -- + * XFillArc, XFillArcs -- * * Draw a filled arc. * @@ -1045,6 +1103,29 @@ XFillArc( return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 1); } + +int +XFillArcs( + Display *display, + Drawable d, + GC gc, + XArc *arcs, + int narcs) +{ + int n, ret; + + display->request++; + + for (n = 0; n < narcs; n++) { + ret = DrawOrFillArc(display, d, gc, arcs[n].x, arcs[n].y, + arcs[n].width, arcs[n].height, + arcs[n].angle1, arcs[n].angle2, 1); + if (ret != Success) { + break; + } + } + return ret; +} /* *---------------------------------------------------------------------- diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index ade15bc..385e72b 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -590,7 +590,7 @@ XResizeWindow( /* *---------------------------------------------------------------------- * - * XRaiseWindow -- + * XRaiseWindow, XLowerWindow -- * * Change the stacking order of a window. * @@ -614,6 +614,18 @@ XRaiseWindow( SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); return Success; } + +int +XLowerWindow( + Display *display, + Window w) +{ + HWND window = Tk_GetHWND(w); + + display->request++; + SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + return Success; +} /* *---------------------------------------------------------------------- @@ -753,6 +765,33 @@ XChangeWindowAttributes( /* *---------------------------------------------------------------------- * + * XReparentWindow -- + * + * TODO: currently placeholder to satisfy Xlib stubs. + * + * Results: + * None. + * + * Side effects: + * TODO. + * + *---------------------------------------------------------------------- + */ + +int +XReparentWindow( + Display *display, + Window w, + Window parent, + int x, + int y) +{ + return BadWindow; +} + +/* + *---------------------------------------------------------------------- + * * TkWinSetWindowPos -- * * Adjust the stacking order of a window relative to a second window (or diff --git a/win/tkWinX.c b/win/tkWinX.c index b2424ce..098fc6d 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -125,16 +125,13 @@ TkGetServerInfo( OSVERSIONINFOW os; if (!buffer[0]) { - HANDLE handle = LoadLibraryW(L"NTDLL"); + HANDLE handle = GetModuleHandle(TEXT("NTDLL")); int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion"); os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); if (!getversion || getversion(&os)) { GetVersionExW(&os); } - if (handle) { - FreeLibrary(handle); - } /* Write the first character last, preventing multi-thread issues. */ sprintf(buffer+1, "indows %d.%d %d %s", (int)os.dwMajorVersion, (int)os.dwMinorVersion, (int)os.dwBuildNumber, diff --git a/xlib/X11/Xutil.h b/xlib/X11/Xutil.h index 58124b0..bf372fb 100644 --- a/xlib/X11/Xutil.h +++ b/xlib/X11/Xutil.h @@ -535,7 +535,7 @@ extern Status XMatchVisualInfo( #endif ); -extern void XOffsetRegion( +extern int XOffsetRegion( #if NeedFunctionPrototypes Region /* r */, int /* dx */, @@ -814,7 +814,7 @@ extern void XUnionRectWithRegion( #endif ); -extern void XUnionRegion( +extern int XUnionRegion( #if NeedFunctionPrototypes Region /* sra */, Region /* srb */, diff --git a/xlib/xgc.c b/xlib/xgc.c index e097d2e..1e720fb 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -520,7 +520,7 @@ XDrawImageString( } #endif -void +int XDrawPoint( Display *display, Drawable d, @@ -528,10 +528,10 @@ XDrawPoint( int x, int y) { - XDrawLine(display, d, gc, x, y, x, y); + return XDrawLine(display, d, gc, x, y, x, y); } -void +int XDrawPoints( Display *display, Drawable d, @@ -541,15 +541,17 @@ XDrawPoints( int mode) { int i; + int result = Success; - for (i=0; i