From 55091eb14914c24bbae66062f600e2ec17b3352b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 2 Jan 2023 15:58:57 +0000 Subject: Use more X11 macro's, in stead of accessing fields directly. Mostly backported from 8.7 --- generic/tkPointer.c | 6 +- macosx/tkMacOSXColor.c | 2 +- macosx/tkMacOSXDraw.c | 41 +++++------ macosx/tkMacOSXImage.c | 8 +-- macosx/tkMacOSXPort.h | 4 +- macosx/tkMacOSXSubwindows.c | 20 +++--- macosx/tkMacOSXXStubs.c | 58 ++++++++-------- win/stubs.c | 6 +- win/tkWinDialog.c | 12 ++-- win/tkWinDraw.c | 12 ++-- win/tkWinFont.c | 6 +- win/tkWinImage.c | 4 +- win/tkWinMenu.c | 2 +- win/tkWinPixmap.c | 16 +++-- win/tkWinPointer.c | 6 +- win/tkWinWindow.c | 30 ++++---- win/tkWinWm.c | 104 ++++++++++++++-------------- win/tkWinX.c | 165 ++++++++++++++++++++++---------------------- xlib/xutil.c | 8 +-- 19 files changed, 259 insertions(+), 251 deletions(-) diff --git a/generic/tkPointer.c b/generic/tkPointer.c index 7753c36..1227215 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -428,7 +428,7 @@ XGrabPointer( ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - display->request++; + LastKnownRequestProcessed(display)++; tsdPtr->grabWinPtr = (TkWindow *) Tk_IdToWindow(display, grab_window); tsdPtr->restrictWinPtr = NULL; TkpSetCapture(tsdPtr->grabWinPtr); @@ -463,7 +463,7 @@ XUngrabPointer( ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - display->request++; + LastKnownRequestProcessed(display)++; tsdPtr->grabWinPtr = NULL; tsdPtr->restrictWinPtr = NULL; TkpSetCapture(NULL); @@ -590,7 +590,7 @@ XDefineCursor( if (tsdPtr->cursorWinPtr == winPtr) { UpdateCursor(winPtr); } - display->request++; + LastKnownRequestProcessed(display)++; return Success; } diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 2037dfbd..1991466 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -795,7 +795,7 @@ XAllocColor( TCL_UNUSED(Colormap), /* Not used. */ XColor *colorPtr) /* XColor struct to modify. */ { - display->request++; + LastKnownRequestProcessed(display)++; colorPtr->pixel = TkpGetPixel(colorPtr); return 1; } diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 874d3cc..5698a44 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -419,7 +419,7 @@ XDrawLines( return BadValue; } - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -487,7 +487,7 @@ XDrawSegments( TkMacOSXDrawingContext dc; int i, lw = gc->line_width; - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -539,7 +539,7 @@ XFillPolygon( TkMacOSXDrawingContext dc; int i; - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -603,7 +603,7 @@ XDrawRectangle( return BadDrawable; } - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -658,7 +658,7 @@ XDrawRectangles( XRectangle * rectPtr; int i, lw = gc->line_width; - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -711,7 +711,7 @@ XFillRectangles( XRectangle * rectPtr; int i; - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -816,7 +816,7 @@ XDrawArc( return BadDrawable; } - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -887,7 +887,7 @@ XDrawArcs( XArc *arcPtr; int i, lw = gc->line_width; - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -969,7 +969,7 @@ XFillArc( return BadDrawable; } - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -1043,7 +1043,7 @@ XFillArcs( XArc * arcPtr; int i, lw = gc->line_width; - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } @@ -1340,15 +1340,6 @@ TkMacOSXSetupDrawingContext( * Finish configuring the drawing context. */ - drawingHeight = view ? [view bounds].size.height : - CGContextGetClipBoundingBox(dc.context).size.height; - CGAffineTransform t = { - .a = 1, .b = 0, - .c = 0, .d = -1, - .tx = 0, - .ty = drawingHeight - }; - #ifdef TK_MAC_DEBUG_CG fprintf(stderr, "TkMacOSXSetupDrawingContext: pushing GState for %s\n", macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None"); @@ -1356,7 +1347,17 @@ TkMacOSXSetupDrawingContext( CGContextSaveGState(dc.context); CGContextSetTextDrawingMode(dc.context, kCGTextFill); - CGContextConcatCTM(dc.context, t); + { /* Restricted scope for t needed for C++ */ + drawingHeight = view ? [view bounds].size.height : + CGContextGetClipBoundingBox(dc.context).size.height; + CGAffineTransform t = { + .a = 1, .b = 0, + .c = 0, .d = -1, + .tx = 0, + .ty = drawingHeight + }; + CGContextConcatCTM(dc.context, t); + } if (dc.clipRgn) { #ifdef TK_MAC_DEBUG_DRAWING diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index fc0ffdf..ea08dc5 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -400,7 +400,7 @@ XCreateImage( { XImage *ximage; - display->request++; + LastKnownRequestProcessed(display)++; ximage = (XImage *)ckalloc(sizeof(XImage)); ximage->height = height; @@ -503,7 +503,7 @@ TkMacOSXPutImage( TkMacOSXDrawingContext dc; MacDrawable *macDraw = (MacDrawable *)drawable; int result = Success; - display->request++; + LastKnownRequestProcessed(display)++; if (!TkMacOSXSetupDrawingContext(drawable, gc, &dc)) { return BadDrawable; } @@ -858,7 +858,7 @@ XCopyArea( CGImageRef img = NULL; CGRect bounds, srcRect, dstRect; - display->request++; + LastKnownRequestProcessed(display)++; if (!width || !height) { return BadDrawable; } @@ -932,7 +932,7 @@ XCopyPlane( MacDrawable *srcDraw = (MacDrawable *)src; MacDrawable *dstDraw = (MacDrawable *)dst; CGRect bounds, srcRect, dstRect; - display->request++; + LastKnownRequestProcessed(display)++; if (!width || !height) { /* TkMacOSXDbgMsg("Drawing of empty area requested"); */ return BadDrawable; diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index dbc9e2b..ab843f9 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -129,11 +129,11 @@ #undef XGrabServer #define XGrabServer(display) (0) #undef XNoOp -#define XNoOp(display) (display->request++,0) +#define XNoOp(display) (LastKnownRequestProcessed(display)++,0) #undef XUngrabServer #define XUngrabServer(display) (0) #undef XSynchronize -#define XSynchronize(display, onoff) (display->request++,NULL) +#define XSynchronize(display, onoff) (LastKnownRequestProcessed(display)++,NULL) #undef XVisualIDFromVisual #define XVisualIDFromVisual(visual) (visual->visualid) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 5d61981..6b5afe0 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -163,7 +163,7 @@ XMapWindow( TkMacOSXMakeRealWindowExist(macWin->toplevel->winPtr); } - display->request++; + LastKnownRequestProcessed(display)++; if (Tk_IsTopLevel(winPtr)) { if (!Tk_IsEmbedded(winPtr)) { TKContentView *view = [win contentView]; @@ -312,7 +312,7 @@ XUnmapWindow( if (!window) { return BadWindow; } - display->request++; + LastKnownRequestProcessed(display)++; if (Tk_IsTopLevel(winPtr)) { if (!Tk_IsEmbedded(winPtr) && winPtr->wmInfoPtr->hints.initial_state!=IconicState) { @@ -397,7 +397,7 @@ XResizeWindow( { MacDrawable *macWin = (MacDrawable *)window; - display->request++; + LastKnownRequestProcessed(display)++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TKWindow *w = (TKWindow *)macWin->winPtr->wmInfoPtr->window; @@ -446,7 +446,7 @@ XMoveResizeWindow( { MacDrawable *macWin = (MacDrawable *)window; - display->request++; + LastKnownRequestProcessed(display)++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; @@ -499,7 +499,7 @@ XMoveWindow( { MacDrawable *macWin = (MacDrawable *)window; - display->request++; + LastKnownRequestProcessed(display)++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; @@ -642,7 +642,7 @@ XRaiseWindow( { MacDrawable *macWin = (MacDrawable *)window; - display->request++; + LastKnownRequestProcessed(display)++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TkWmRestackToplevel(macWin->winPtr, Above, NULL); } else { @@ -676,7 +676,7 @@ XLowerWindow( { MacDrawable *macWin = (MacDrawable *)window; - display->request++; + LastKnownRequestProcessed(display)++; if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TkWmRestackToplevel(macWin->winPtr, Below, NULL); } else { @@ -715,7 +715,7 @@ XConfigureWindow( MacDrawable *macWin = (MacDrawable *)w; TkWindow *winPtr = macWin->winPtr; - display->request++; + LastKnownRequestProcessed(display)++; /* * Change the shape and/or position of the window. @@ -1464,7 +1464,7 @@ Tk_GetPixmap( MacDrawable *macPix; if (display != NULL) { - display->request++; + LastKnownRequestProcessed(display)++; } macPix = (MacDrawable *)ckalloc(sizeof(MacDrawable)); macPix->winPtr = NULL; @@ -1506,7 +1506,7 @@ Tk_FreePixmap( { MacDrawable *macPix = (MacDrawable *)pixmap; - display->request++; + LastKnownRequestProcessed(display)++; if (macPix->context) { char *data = (char *)CGBitmapContextGetData(macPix->context); diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index a860bda..9a317b6 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -90,11 +90,11 @@ TkMacOSXDisplayChanged( NSRect bounds = [s frame]; NSRect maxBounds = NSZeroRect; - screen->root_depth = NSBitsPerPixelFromDepth([s depth]); - screen->width = bounds.size.width; - screen->height = bounds.size.height; - screen->mwidth = (bounds.size.width * 254 + 360) / 720; - screen->mheight = (bounds.size.height * 254 + 360) / 720; + DefaultDepthOfScreen(screen) = NSBitsPerPixelFromDepth([s depth]); + WidthOfScreen(screen) = bounds.size.width; + HeightOfScreen(screen) = bounds.size.height; + WidthMMOfScreen(screen) = (bounds.size.width * 254 + 360) / 720; + HeightMMOfScreen(screen) = (bounds.size.height * 254 + 360) / 720; for (s in nsScreens) { maxBounds = NSUnionRect(maxBounds, [s visibleFrame]); @@ -207,7 +207,7 @@ TkpOpenDisplay( bzero(screen, sizeof(Screen)); display->resource_alloc = MacXIdAlloc; - display->request = 0; + LastKnownRequestProcessed(display) = 0; display->qlen = 0; display->fd = fd; display->screens = screen; @@ -248,20 +248,20 @@ TkpOpenDisplay( /* * These screen bits never change */ - screen->root = ROOT_ID; - screen->display = display; - screen->black_pixel = 0x00000000; - screen->white_pixel = 0x00FFFFFF; + RootWindowOfScreen(screen) = ROOT_ID; + DisplayOfScreen(screen) = display; + BlackPixelOfScreen(screen) = 0x00000000; + WhitePixelOfScreen(screen) = 0x00FFFFFF; screen->ext_data = (XExtData *) &maxBounds; - screen->root_visual = (Visual *)ckalloc(sizeof(Visual)); - screen->root_visual->visualid = 0; - screen->root_visual->c_class = TrueColor; - screen->root_visual->red_mask = 0x00FF0000; - screen->root_visual->green_mask = 0x0000FF00; - screen->root_visual->blue_mask = 0x000000FF; - screen->root_visual->bits_per_rgb = 24; - screen->root_visual->map_entries = 256; + DefaultVisualOfScreen(screen) = (Visual *)ckalloc(sizeof(Visual)); + DefaultVisualOfScreen(screen)->visualid = 0; + DefaultVisualOfScreen(screen)->c_class = TrueColor; + DefaultVisualOfScreen(screen)->red_mask = 0x00FF0000; + DefaultVisualOfScreen(screen)->green_mask = 0x0000FF00; + DefaultVisualOfScreen(screen)->blue_mask = 0x000000FF; + DefaultVisualOfScreen(screen)->bits_per_rgb = 24; + DefaultVisualOfScreen(screen)->map_entries = 256; /* * Initialize screen bits that may change @@ -316,8 +316,8 @@ TkpCloseDisplay( gMacDisplay = NULL; if (display->screens != NULL) { - if (display->screens->root_visual != NULL) { - ckfree(display->screens->root_visual); + if (DefaultVisualOfScreen(display->screens) != NULL) { + ckfree(DefaultVisualOfScreen(display->screens)); } ckfree(display->screens); } @@ -434,7 +434,7 @@ XGetAtomName( Display *display, TCL_UNUSED(Atom)) { - display->request++; + LastKnownRequestProcessed(display)++; return NULL; } @@ -450,7 +450,7 @@ XRootWindow( Display *display, TCL_UNUSED(int)) { - display->request++; + LastKnownRequestProcessed(display)++; return ROOT_ID; } @@ -468,7 +468,7 @@ XGetGeometry( { TkWindow *winPtr = ((MacDrawable *)d)->winPtr; - display->request++; + LastKnownRequestProcessed(display)++; *root_return = ROOT_ID; if (winPtr) { *x_return = Tk_X(winPtr); @@ -645,7 +645,7 @@ XGetWindowProperty( unsigned long *bytes_after_return, TCL_UNUSED(unsigned char **)) { - display->request++; + LastKnownRequestProcessed(display)++; *actual_type_return = None; *actual_format_return = *bytes_after_return = 0; *nitems_return = 0; @@ -670,7 +670,7 @@ XSetIconName( /* * This is a no-op, no icon name for Macs. */ - display->request++; + LastKnownRequestProcessed(display)++; return Success; } @@ -685,7 +685,7 @@ XForceScreenSaver( * is! */ - display->request++; + LastKnownRequestProcessed(display)++; return Success; } @@ -716,7 +716,7 @@ XSync( * [da5f2266df].) */ - display->request++; + LastKnownRequestProcessed(display)++; return 0; } @@ -905,7 +905,7 @@ XSynchronize( Display *display, TCL_UNUSED(Bool)) { - display->request++; + LastKnownRequestProcessed(display)++; return NULL; } @@ -922,7 +922,7 @@ int XNoOp( Display *display) { - display->request++; + LastKnownRequestProcessed(display)++; return 0; } diff --git a/win/stubs.c b/win/stubs.c index faeac08..93a086e 100644 --- a/win/stubs.c +++ b/win/stubs.c @@ -579,7 +579,7 @@ int XNoOp( Display *display) { - display->request++; + LastKnownRequestProcessed(display)++; return 0; } @@ -590,7 +590,7 @@ XSynchronize( { (void)onoff; - display->request++; + LastKnownRequestProcessed(display)++; return NULL; } @@ -601,7 +601,7 @@ XSync( { (void)discard; - display->request++; + LastKnownRequestProcessed(display)++; return 0; } diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index da13e48..cb765bb 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -1085,7 +1085,7 @@ ParseOFNOptions( case OFN_FILE_OPEN: options = openOptions; break; } - ZeroMemory(optsPtr, sizeof(*optsPtr)); + memset(optsPtr, 0, sizeof(*optsPtr)); /* optsPtr->forceXPStyle = 1; */ optsPtr->tkwin = (Tk_Window)clientData; optsPtr->confirmOverwrite = 1; /* By default we ask for confirmation */ @@ -1581,7 +1581,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - ZeroMemory(&ofnData, sizeof(OFNData)); + memset(&ofnData, 0, sizeof(OFNData)); Tcl_DStringInit(&utfFilterString); Tcl_DStringInit(&dirString); /* XXX - original code was missing this leaving dirString uninitialized for @@ -1595,7 +1595,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper Tk_MakeWindowExist(optsPtr->tkwin); hWnd = Tk_GetHWND(Tk_WindowId(optsPtr->tkwin)); - ZeroMemory(&ofn, sizeof(OPENFILENAME)); + memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; ofn.hInstance = TkWinGetHInstance(ofn.hwndOwner); @@ -2463,7 +2463,7 @@ Tk_ChooseDirectoryObjCmd( /* Older dialogs */ path[0] = '\0'; - ZeroMemory(&cdCBData, sizeof(ChooseDir)); + memset(&cdCBData, 0, sizeof(ChooseDir)); cdCBData.interp = interp; cdCBData.mustExist = ofnOpts.mustExist; @@ -3463,8 +3463,8 @@ FontchooserShowCmd( Tk_MakeWindowExist(parent); - ZeroMemory(&cf, sizeof(CHOOSEFONTW)); - ZeroMemory(&lf, sizeof(LOGFONTW)); + memset(&cf, 0, sizeof(CHOOSEFONTW)); + memset(&lf, 0, sizeof(LOGFONTW)); lf.lfCharSet = DEFAULT_CHARSET; cf.lStructSize = sizeof(CHOOSEFONTW); cf.hwndOwner = Tk_GetHWND(Tk_WindowId(parent)); diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 4ed8ab2..8fb6a84 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -369,7 +369,7 @@ XCopyPlane( HBRUSH bgBrush, fgBrush, oldBrush; TkpClipMask *clipPtr = (TkpClipMask*)gc->clip_mask; - display->request++; + LastKnownRequestProcessed(display)++; if (plane != 1) { Tcl_Panic("Unexpected plane specified for XCopyPlane"); @@ -520,7 +520,7 @@ TkPutImage( HBITMAP bitmap; char *data; - display->request++; + LastKnownRequestProcessed(display)++; dc = TkWinGetDrawableDC(display, d, &state); SetROP2(dc, tkpWinRopModes[gc->function]); @@ -1092,7 +1092,7 @@ XDrawArc( unsigned int width, unsigned int height, int start, int extent) { - display->request++; + LastKnownRequestProcessed(display)++; return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 0); } @@ -1107,7 +1107,7 @@ XDrawArcs( { int ret = Success; - display->request++; + LastKnownRequestProcessed(display)++; while (narcs-- > 0) { ret = DrawOrFillArc(display, d, gc, arcs[0].x, arcs[0].y, @@ -1146,7 +1146,7 @@ XFillArc( unsigned int width, unsigned int height, int start, int extent) { - display->request++; + LastKnownRequestProcessed(display)++; return DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 1); } @@ -1161,7 +1161,7 @@ XFillArcs( { int ret = Success; - display->request++; + LastKnownRequestProcessed(display)++; while (narcs-- > 0) { ret = DrawOrFillArc(display, d, gc, arcs[0].x, arcs[0].y, diff --git a/win/tkWinFont.c b/win/tkWinFont.c index c24cd5f..c6da8ee 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -405,7 +405,7 @@ TkWinSetupSystemFonts( * (i.e. WINVER=0x0600 and running on XP). */ - ZeroMemory(&ncMetrics, sizeof(ncMetrics)); + memset(&ncMetrics, 0, sizeof(ncMetrics)); ncMetrics.cbSize = sizeof(ncMetrics); if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(ncMetrics), &ncMetrics, 0)) { @@ -1081,7 +1081,7 @@ Tk_DrawChars( TkWinDCState state; fontPtr = (WinFont *) gc->font; - display->request++; + LastKnownRequestProcessed(display)++; if (drawable == None) { return; @@ -1229,7 +1229,7 @@ TkDrawAngledChars( TkWinDCState state; fontPtr = (WinFont *) gc->font; - display->request++; + LastKnownRequestProcessed(display)++; if (drawable == None) { return; diff --git a/win/tkWinImage.c b/win/tkWinImage.c index e1660a9..e4fb487 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -585,7 +585,7 @@ XGetImage( XImage *imagePtr; HDC dc; - display->request++; + LastKnownRequestProcessed(display)++; if (twdPtr == NULL) { /* @@ -615,7 +615,7 @@ XGetImage( width, height, 32, 0); size = imagePtr->bytes_per_line * imagePtr->height; imagePtr->data = ckalloc(size); - ZeroMemory(imagePtr->data, size); + memset(imagePtr->data, 0, size); for (yy = 0; yy < height; yy++) { for (xx = 0; xx < width; xx++) { diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index b030a0f..1d2af7e 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -3171,7 +3171,7 @@ MenuSelectEvent( memset(&event, 0, sizeof(event)); event.virt.type = VirtualEvent; - event.virt.serial = menuPtr->display->request; + event.virt.serial = LastKnownRequestProcessed(menuPtr->display); event.virt.send_event = 0; event.virt.display = menuPtr->display; Tk_MakeWindowExist(menuPtr->tkwin); diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index e28f348..51ff88c 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -40,9 +40,9 @@ Tk_GetPixmap( int planes; Screen *screen; - display->request++; + LastKnownRequestProcessed(display)++; - newTwdPtr = ckalloc(sizeof(TkWinDrawable)); + newTwdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable)); newTwdPtr->type = TWD_BITMAP; newTwdPtr->bitmap.depth = depth; twdPtr = (TkWinDrawable *) d; @@ -56,9 +56,9 @@ Tk_GetPixmap( } else { newTwdPtr->bitmap.colormap = twdPtr->bitmap.colormap; } - screen = &display->screens[0]; + screen = ScreenOfDisplay(display, 0); planes = 1; - if (depth == screen->root_depth) { + if (depth == DefaultDepthOfScreen(screen)) { planes = PTR2INT(screen->ext_data); depth /= planes; } @@ -144,7 +144,7 @@ Tk_FreePixmap( { TkWinDrawable *twdPtr = (TkWinDrawable *) pixmap; - display->request++; + LastKnownRequestProcessed(display)++; if (twdPtr != NULL) { DeleteObject(twdPtr->bitmap.handle); ckfree(twdPtr); @@ -208,6 +208,12 @@ XGetGeometry( unsigned int *depth_return) { TkWinDrawable *twdPtr = (TkWinDrawable *)d; + (void)display; + (void)root_return; + (void)x_return; + (void)y_return; + (void)border_width_return; + (void)depth_return; if (twdPtr->type == TWD_BITMAP) { HDC dc; diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index 0ce9b37..d01c4b6 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -322,7 +322,7 @@ XQueryPointer( int *win_y_return, unsigned int *mask_return) { - display->request++; + LastKnownRequestProcessed(display)++; TkGetPointerCoords(NULL, root_x_return, root_y_return); *mask_return = TkWinGetModifierState(); return True; @@ -453,7 +453,7 @@ XGetInputFocus( *focus_return = tkwin ? Tk_WindowId(tkwin) : None; *revert_to_return = RevertToParent; - display->request++; + LastKnownRequestProcessed(display)++; return Success; } @@ -481,7 +481,7 @@ XSetInputFocus( int revert_to, Time time) { - display->request++; + LastKnownRequestProcessed(display)++; if (focus != None) { SetFocus(Tk_GetHWND(focus)); } diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index e5990e5..3478b08 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -305,7 +305,7 @@ XDestroyWindow( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - display->request++; + LastKnownRequestProcessed(display)++; /* * Remove references to the window in the pointer module then release the @@ -357,7 +357,7 @@ XMapWindow( TkWindow *parentPtr; TkWindow *winPtr = TkWinGetWinPtr(w); - display->request++; + LastKnownRequestProcessed(display)++; ShowWindow(Tk_GetHWND(w), SW_SHOWNORMAL); winPtr->flags |= TK_MAPPED; @@ -380,7 +380,7 @@ XMapWindow( } } else { event.type = MapNotify; - event.xmap.serial = display->request; + event.xmap.serial = LastKnownRequestProcessed(display); event.xmap.send_event = False; event.xmap.display = display; event.xmap.event = winPtr->window; @@ -395,7 +395,7 @@ XMapWindow( */ event.type = VisibilityNotify; - event.xvisibility.serial = display->request; + event.xvisibility.serial = LastKnownRequestProcessed(display); event.xvisibility.send_event = False; event.xvisibility.display = display; event.xvisibility.window = winPtr->window; @@ -465,7 +465,7 @@ XUnmapWindow( XEvent event; TkWindow *winPtr = TkWinGetWinPtr(w); - display->request++; + LastKnownRequestProcessed(display)++; /* * Bug fix: Don't short circuit this routine based on TK_MAPPED because it @@ -477,7 +477,7 @@ XUnmapWindow( if (winPtr->flags & TK_WIN_MANAGED) { event.type = UnmapNotify; - event.xunmap.serial = display->request; + event.xunmap.serial = LastKnownRequestProcessed(display); event.xunmap.send_event = False; event.xunmap.display = display; event.xunmap.event = winPtr->window; @@ -511,7 +511,7 @@ XMoveResizeWindow( int x, int y, /* Position relative to parent. */ unsigned int width, unsigned int height) { - display->request++; + LastKnownRequestProcessed(display)++; MoveWindow(Tk_GetHWND(w), x, y, (int) width, (int) height, TRUE); return Success; } @@ -540,7 +540,7 @@ XMoveWindow( { TkWindow *winPtr = TkWinGetWinPtr(w); - display->request++; + LastKnownRequestProcessed(display)++; MoveWindow(Tk_GetHWND(w), x, y, winPtr->changes.width, winPtr->changes.height, TRUE); @@ -571,7 +571,7 @@ XResizeWindow( { TkWindow *winPtr = TkWinGetWinPtr(w); - display->request++; + LastKnownRequestProcessed(display)++; MoveWindow(Tk_GetHWND(w), winPtr->changes.x, winPtr->changes.y, (int)width, (int)height, TRUE); @@ -601,7 +601,7 @@ XRaiseWindow( { HWND window = Tk_GetHWND(w); - display->request++; + LastKnownRequestProcessed(display)++; SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); return Success; } @@ -613,7 +613,7 @@ XLowerWindow( { HWND window = Tk_GetHWND(w); - display->request++; + LastKnownRequestProcessed(display)++; SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); return Success; } @@ -647,7 +647,7 @@ XConfigureWindow( TkWindow *winPtr = TkWinGetWinPtr(w); HWND hwnd = Tk_GetHWND(w); - display->request++; + LastKnownRequestProcessed(display)++; /* * Change the shape and/or position of the window. @@ -703,10 +703,10 @@ XClearWindow( HWND hwnd = Tk_GetHWND(w); HDC dc = GetDC(hwnd); - palette = TkWinGetPalette(display->screens[0].cmap); + palette = TkWinGetPalette(DefaultColormapOfScreen(display->screens)); oldPalette = SelectPalette(dc, palette, FALSE); - display->request++; + LastKnownRequestProcessed(display)++; winPtr = TkWinGetWinPtr(w); brush = CreateSolidBrush(winPtr->atts.background_pixel); @@ -858,7 +858,7 @@ TkpShowBusyWindow( window = Tk_WindowId(busyPtr->tkBusy); display = Tk_Display(busyPtr->tkBusy); hWnd = Tk_GetHWND(window); - display->request++; + LastKnownRequestProcessed(display)++; SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } diff --git a/win/tkWinWm.c b/win/tkWinWm.c index f27a965..7b2b0cf 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -871,7 +871,7 @@ InitWindowClass( initialized = 1; - ZeroMemory(&windowClass, sizeof(WNDCLASSW)); + memset(&windowClass, 0, sizeof(WNDCLASSW)); windowClass.style = CS_HREDRAW | CS_VREDRAW; windowClass.hInstance = Tk_GetHINSTANCE(); @@ -1269,7 +1269,7 @@ ReadIconFromFile( Tcl_DStringFree(&ds2); return NULL; } - ZeroMemory(lpIR, size); + memset(lpIR, 0, size); lpIR->nNumImages = ((res != 0) ? 2 : 1); lpIR->IconImages[0].Width = 16; @@ -1911,7 +1911,7 @@ TkWmNewWindow( * Initialize full structure, then set what isn't NULL */ - ZeroMemory(wmPtr, sizeof(WmInfo)); + memset(wmPtr, 0, sizeof(WmInfo)); winPtr->wmInfoPtr = wmPtr; wmPtr->winPtr = winPtr; wmPtr->hints.flags = InputHint | StateHint; @@ -2740,7 +2740,7 @@ TkWmDeadWindow( void TkWmSetClass( - TCL_UNUSED(TkWindow *)) /* Newly-created top-level window. */ + TCL_UNUSED(TkWindow *)) /* Newly-created top-level window. */ { /* Do nothing */ return; @@ -2832,8 +2832,8 @@ Tk_WmObjCmd( return TCL_OK; } - if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, - sizeof(char *), "option", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, + "option", 0, &index) != TCL_OK) { return TCL_ERROR; } @@ -2944,7 +2944,7 @@ Tk_WmObjCmd( static int WmAspectCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3477,7 +3477,7 @@ WmColormapwindowsCmd( static int WmCommandCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3546,7 +3546,7 @@ WmCommandCmd( static int WmDeiconifyCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3598,7 +3598,7 @@ WmDeiconifyCmd( static int WmFocusmodelCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3623,8 +3623,8 @@ WmFocusmodelCmd( return TCL_OK; } - if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings, - sizeof(char *), "argument", 0,&index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, + "argument", 0,&index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_ACTIVE) { @@ -3654,10 +3654,10 @@ WmFocusmodelCmd( static int WmForgetCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ - TCL_UNUSED(int), /* Number of arguments. */ + TCL_UNUSED(int), /* Number of arguments. */ TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */ { Tk_Window frameWin = (Tk_Window) winPtr; @@ -3702,7 +3702,7 @@ WmForgetCmd( static int WmFrameCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3747,7 +3747,7 @@ WmFrameCmd( static int WmGeometryCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3815,7 +3815,7 @@ WmGeometryCmd( static int WmGridCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3976,7 +3976,7 @@ WmGroupCmd( static int WmIconbitmapCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4112,7 +4112,7 @@ WmIconbitmapCmd( static int WmIconifyCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4236,7 +4236,7 @@ WmIconmaskCmd( static int WmIconnameCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4287,7 +4287,7 @@ WmIconnameCmd( static int WmIconphotoCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4346,7 +4346,7 @@ WmIconphotoCmd( if (lpIR == NULL) { return TCL_ERROR; } - ZeroMemory(lpIR, size); + memset(lpIR, 0, size); lpIR->nNumImages = objc - startObj; @@ -4362,14 +4362,14 @@ WmIconphotoCmd( * converts them as required. Initialise icon info structure. */ - ZeroMemory(&iconInfo, sizeof(iconInfo)); + memset(&iconInfo, 0, sizeof(iconInfo)); iconInfo.fIcon = TRUE; /* * Create device-independent color bitmap. */ - ZeroMemory(&bmInfo, sizeof bmInfo); + memset(&bmInfo, 0, sizeof(bmInfo)); bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmInfo.bmiHeader.biWidth = width; bmInfo.bmiHeader.biHeight = -height; @@ -4420,7 +4420,7 @@ WmIconphotoCmd( return TCL_ERROR; } - ZeroMemory(bgraMask.ptr, width*height/8); + memset(bgraMask.ptr, 0, width*height/8); /* * Create an icon from the bitmaps. @@ -4646,11 +4646,11 @@ WmIconwindowCmd( static int WmManageCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ - TCL_UNUSED(int), /* Number of arguments. */ - TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */ + TCL_UNUSED(int), /* Number of arguments. */ + TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */ { Tk_Window frameWin = (Tk_Window) winPtr; WmInfo *wmPtr = winPtr->wmInfoPtr; @@ -4700,7 +4700,7 @@ WmManageCmd( static int WmMaxsizeCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4751,7 +4751,7 @@ WmMaxsizeCmd( static int WmMinsizeCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4802,7 +4802,7 @@ WmMinsizeCmd( static int WmOverrideredirectCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4874,7 +4874,7 @@ WmOverrideredirectCmd( static int WmPositionfromCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4907,8 +4907,8 @@ WmPositionfromCmd( if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USPosition|PPosition); } else { - if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings, - sizeof(char *), "argument", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, + "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_USER) { @@ -4942,7 +4942,7 @@ WmPositionfromCmd( static int WmProtocolCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -5038,7 +5038,7 @@ WmProtocolCmd( static int WmResizableCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -5100,7 +5100,7 @@ WmResizableCmd( static int WmSizefromCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -5134,8 +5134,8 @@ WmSizefromCmd( if (*Tcl_GetString(objv[3]) == '\0') { wmPtr->sizeHintsFlags &= ~(USSize|PSize); } else { - if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings, - sizeof(char *), "argument", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, + "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_USER) { @@ -5264,8 +5264,8 @@ WmStackorderCmd( ckfree(windows); - if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings, - sizeof(char *), "argument", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, + "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } if (index == OPT_ISABOVE) { @@ -5324,8 +5324,8 @@ WmStateCmd( Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL); return TCL_ERROR; } - if (Tcl_GetIndexFromObjStruct(interp, objv[3], optionStrings, - sizeof(char *), "argument", 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, + "argument", 0, &index) != TCL_OK) { return TCL_ERROR; } @@ -5437,7 +5437,7 @@ WmStateCmd( static int WmTitleCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -5642,7 +5642,7 @@ WmTransientCmd( static int WmWithdrawCmd( - TCL_UNUSED(Tk_Window), /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -6508,7 +6508,7 @@ Tk_CoordsToWindow( void Tk_GetVRootGeometry( - TCL_UNUSED(Tk_Window), /* Window whose virtual root is to be + TCL_UNUSED(Tk_Window),/* Window whose virtual root is to be * queried. */ int *xPtr, int *yPtr, /* Store x and y offsets of virtual root * here. */ @@ -7334,7 +7334,7 @@ GenerateConfigureNotify( */ event.type = ConfigureNotify; - event.xconfigure.serial = winPtr->display->request; + event.xconfigure.serial = LastKnownRequestProcessed(winPtr->display); event.xconfigure.send_event = False; event.xconfigure.display = winPtr->display; event.xconfigure.event = winPtr->window; @@ -7910,7 +7910,7 @@ WmProc( winPtr = GetTopLevel(hwnd); if (winPtr) { Screen *screen = Tk_Screen(winPtr); - if (screen->root_depth != (int) wParam) { + if (DefaultDepthOfScreen(screen) != (int) wParam) { /* * Color resolution changed, so do extensive rebuild of * display parameters. This will affect the display for all Tk @@ -7923,11 +7923,11 @@ WmProc( } else { HDC dc = GetDC(NULL); - screen->width = LOWORD(lParam); /* horizontal res */ - screen->height = HIWORD(lParam); /* vertical res */ - screen->mwidth = MulDiv(screen->width, 254, + WidthOfScreen(screen) = LOWORD(lParam); /* horizontal res */ + HeightOfScreen(screen) = HIWORD(lParam); /* vertical res */ + WidthMMOfScreen(screen) = MulDiv(WidthOfScreen(screen), 254, GetDeviceCaps(dc, LOGPIXELSX) * 10); - screen->mheight = MulDiv(screen->height, 254, + HeightMMOfScreen(screen) = MulDiv(HeightOfScreen(screen), 254, GetDeviceCaps(dc, LOGPIXELSY) * 10); ReleaseDC(NULL, dc); } diff --git a/win/tkWinX.c b/win/tkWinX.c index df8c004..1a9bc2a 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -11,6 +11,7 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ +#define XLIB_ILLEGAL_ACCESS #include "tkWinInt.h" /* @@ -130,7 +131,7 @@ void TkGetServerInfo( Tcl_Interp *interp, /* The server information is returned in this * interpreter's result. */ - Tk_Window tkwin) /* Token for window; this selects a particular + TCL_UNUSED(Tk_Window)) /* Token for window; this selects a particular * display and server. */ { static char buffer[32]; /* Empty string means not initialized yet. */ @@ -269,7 +270,7 @@ TkWinXInit( if (GetLocaleInfoW(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (LPWSTR) &lpCP, sizeof(lpCP)/sizeof(WCHAR)) - && TranslateCharsetInfo(INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) { + && TranslateCharsetInfo((DWORD *)INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) { UpdateInputLanguage((int) lpCs.ciCharset); } @@ -277,7 +278,7 @@ TkWinXInit( * Make sure we cleanup on finalize. */ - TkCreateExitHandler(TkWinXCleanup, (ClientData) hInstance); + TkCreateExitHandler(TkWinXCleanup, hInstance); } /* @@ -300,7 +301,7 @@ void TkWinXCleanup( ClientData clientData) { - HINSTANCE hInstance = (HINSTANCE) clientData; + HINSTANCE hInstance = (HINSTANCE)clientData; /* * Clean up our own class. @@ -430,7 +431,7 @@ TkWinGetPlatformId(void) const char * TkGetDefaultScreenName( - Tcl_Interp *interp, /* Not used. */ + TCL_UNUSED(Tcl_Interp *), const char *screenName) /* If NULL, use default string. */ { if ((screenName == NULL) || (screenName[0] == '\0')) { @@ -463,17 +464,17 @@ TkWinDisplayChanged( HDC dc; Screen *screen; - if (display == NULL || display->screens == NULL) { + if (display == NULL || ScreenOfDisplay(display, 0) == NULL) { return; } - screen = display->screens; + screen = ScreenOfDisplay(display, 0); dc = GetDC(NULL); - screen->width = GetDeviceCaps(dc, HORZRES); - screen->height = GetDeviceCaps(dc, VERTRES); - screen->mwidth = MulDiv(screen->width, 254, + WidthOfScreen(screen) = GetDeviceCaps(dc, HORZRES); + HeightOfScreen(screen) = GetDeviceCaps(dc, VERTRES); + WidthMMOfScreen(screen) = MulDiv(WidthOfScreen(screen), 254, GetDeviceCaps(dc, LOGPIXELSX) * 10); - screen->mheight = MulDiv(screen->height, 254, + HeightMMOfScreen(screen) = MulDiv(HeightOfScreen(screen), 254, GetDeviceCaps(dc, LOGPIXELSY) * 10); /* @@ -485,52 +486,52 @@ TkWinDisplayChanged( * the HWND and we'll just get blank spots copied onto the screen. */ - screen->ext_data = INT2PTR(GetDeviceCaps(dc, PLANES)); - screen->root_depth = GetDeviceCaps(dc, BITSPIXEL) * PTR2INT(screen->ext_data); + screen->ext_data = (XExtData *)INT2PTR(GetDeviceCaps(dc, PLANES)); + DefaultDepthOfScreen(screen) = GetDeviceCaps(dc, BITSPIXEL) * PTR2INT(screen->ext_data); - if (screen->root_visual != NULL) { - ckfree(screen->root_visual); + if (DefaultVisualOfScreen(screen) != NULL) { + ckfree(DefaultVisualOfScreen(screen)); } - screen->root_visual = ckalloc(sizeof(Visual)); - screen->root_visual->visualid = 0; + DefaultVisualOfScreen(screen) = (Visual *)ckalloc(sizeof(Visual)); + DefaultVisualOfScreen(screen)->visualid = 0; if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE) { - screen->root_visual->map_entries = GetDeviceCaps(dc, SIZEPALETTE); - screen->root_visual->c_class = PseudoColor; - screen->root_visual->red_mask = 0x0; - screen->root_visual->green_mask = 0x0; - screen->root_visual->blue_mask = 0x0; - } else if (screen->root_depth == 4) { - screen->root_visual->c_class = StaticColor; - screen->root_visual->map_entries = 16; - } else if (screen->root_depth == 8) { - screen->root_visual->c_class = StaticColor; - screen->root_visual->map_entries = 256; - } else if (screen->root_depth == 12) { - screen->root_visual->c_class = TrueColor; - screen->root_visual->map_entries = 32; - screen->root_visual->red_mask = 0xf0; - screen->root_visual->green_mask = 0xf000; - screen->root_visual->blue_mask = 0xf00000; - } else if (screen->root_depth == 16) { - screen->root_visual->c_class = TrueColor; - screen->root_visual->map_entries = 64; - screen->root_visual->red_mask = 0xf8; - screen->root_visual->green_mask = 0xfc00; - screen->root_visual->blue_mask = 0xf80000; - } else if (screen->root_depth >= 24) { - screen->root_visual->c_class = TrueColor; - screen->root_visual->map_entries = 256; - screen->root_visual->red_mask = 0xff; - screen->root_visual->green_mask = 0xff00; - screen->root_visual->blue_mask = 0xff0000; + DefaultVisualOfScreen(screen)->map_entries = GetDeviceCaps(dc, SIZEPALETTE); + DefaultVisualOfScreen(screen)->c_class = PseudoColor; + DefaultVisualOfScreen(screen)->red_mask = 0x0; + DefaultVisualOfScreen(screen)->green_mask = 0x0; + DefaultVisualOfScreen(screen)->blue_mask = 0x0; + } else if (DefaultDepthOfScreen(screen) == 4) { + DefaultVisualOfScreen(screen)->c_class = StaticColor; + DefaultVisualOfScreen(screen)->map_entries = 16; + } else if (DefaultDepthOfScreen(screen) == 8) { + DefaultVisualOfScreen(screen)->c_class = StaticColor; + DefaultVisualOfScreen(screen)->map_entries = 256; + } else if (DefaultDepthOfScreen(screen) == 12) { + DefaultVisualOfScreen(screen)->c_class = TrueColor; + DefaultVisualOfScreen(screen)->map_entries = 32; + DefaultVisualOfScreen(screen)->red_mask = 0xf0; + DefaultVisualOfScreen(screen)->green_mask = 0xf000; + DefaultVisualOfScreen(screen)->blue_mask = 0xf00000; + } else if (DefaultDepthOfScreen(screen) == 16) { + DefaultVisualOfScreen(screen)->c_class = TrueColor; + DefaultVisualOfScreen(screen)->map_entries = 64; + DefaultVisualOfScreen(screen)->red_mask = 0xf8; + DefaultVisualOfScreen(screen)->green_mask = 0xfc00; + DefaultVisualOfScreen(screen)->blue_mask = 0xf80000; + } else if (DefaultDepthOfScreen(screen) >= 24) { + DefaultVisualOfScreen(screen)->c_class = TrueColor; + DefaultVisualOfScreen(screen)->map_entries = 256; + DefaultVisualOfScreen(screen)->red_mask = 0xff; + DefaultVisualOfScreen(screen)->green_mask = 0xff00; + DefaultVisualOfScreen(screen)->blue_mask = 0xff0000; } - screen->root_visual->bits_per_rgb = screen->root_depth; + DefaultVisualOfScreen(screen)->bits_per_rgb = DefaultDepthOfScreen(screen); ReleaseDC(NULL, dc); - if (screen->cmap != None) { - XFreeColormap(display, screen->cmap); + if (DefaultColormapOfScreen(screen) != None) { + XFreeColormap(display, DefaultColormapOfScreen(screen)); } - screen->cmap = XCreateColormap(display, None, screen->root_visual, + DefaultColormapOfScreen(screen) = XCreateColormap(display, None, DefaultVisualOfScreen(screen), AllocNone); } @@ -555,10 +556,10 @@ TkDisplay * TkpOpenDisplay( const char *display_name) { + Display *display; Screen *screen; TkWinDrawable *twdPtr; - Display *display; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); DWORD initialWheelTick; @@ -571,19 +572,19 @@ TkpOpenDisplay( } display = ckalloc(sizeof(Display)); - ZeroMemory(display, sizeof(Display)); + memset(display, 0, sizeof(Display)); display->display_name = ckalloc(strlen(display_name) + 1); strcpy(display->display_name, display_name); display->cursor_font = 1; display->nscreens = 1; - display->request = 1; + LastKnownRequestProcessed(display) = 1; display->qlen = 0; screen = ckalloc(sizeof(Screen)); - ZeroMemory(screen, sizeof(Screen)); - screen->display = display; + memset(screen, 0, sizeof(Screen)); + DisplayOfScreen(screen) = display; /* * Set up the root window. @@ -596,15 +597,15 @@ TkpOpenDisplay( twdPtr->type = TWD_WINDOW; twdPtr->window.winPtr = NULL; twdPtr->window.handle = NULL; - screen->root = (Window)twdPtr; + RootWindowOfScreen(screen) = (Window)twdPtr; /* * Note that these pixel values are not palette relative. */ - screen->white_pixel = RGB(255, 255, 255); - screen->black_pixel = RGB(0, 0, 0); - screen->cmap = None; + WhitePixelOfScreen(screen) = RGB(255, 255, 255); + BlackPixelOfScreen(screen) = RGB(0, 0, 0); + DefaultColormapOfScreen(screen) = None; display->screens = screen; display->nscreens = 1; @@ -613,7 +614,7 @@ TkpOpenDisplay( TkWinDisplayChanged(display); tsdPtr->winDisplay = ckalloc(sizeof(TkDisplay)); - ZeroMemory(tsdPtr->winDisplay, sizeof(TkDisplay)); + memset(tsdPtr->winDisplay, 0, sizeof(TkDisplay)); tsdPtr->winDisplay->display = display; tsdPtr->updatingClipboard = FALSE; initialWheelTick = GetTickCount(); @@ -665,17 +666,17 @@ TkpCloseDisplay( if (display->display_name != NULL) { ckfree(display->display_name); } - if (display->screens != NULL) { - if (display->screens->root_visual != NULL) { - ckfree(display->screens->root_visual); + if (ScreenOfDisplay(display, 0) != NULL) { + if (DefaultVisualOfScreen(ScreenOfDisplay(display, 0)) != NULL) { + ckfree(DefaultVisualOfScreen(ScreenOfDisplay(display, 0))); } - if (display->screens->root != None) { - ckfree(display->screens->root); + if (RootWindowOfScreen(ScreenOfDisplay(display, 0)) != None) { + ckfree(RootWindowOfScreen(ScreenOfDisplay(display, 0))); } - if (display->screens->cmap != None) { - XFreeColormap(display, display->screens->cmap); + if (DefaultColormapOfScreen(ScreenOfDisplay(display, 0)) != None) { + XFreeColormap(display, DefaultColormapOfScreen(ScreenOfDisplay(display, 0))); } - ckfree(display->screens); + ckfree(ScreenOfDisplay(display, 0)); } ckfree(display); } @@ -710,7 +711,7 @@ TkClipCleanup( dispPtr->windowAtom); Tk_DestroyWindow(dispPtr->clipWindow); - Tcl_Release((ClientData) dispPtr->clipWindow); + Tcl_Release(dispPtr->clipWindow); dispPtr->clipWindow = NULL; } } @@ -733,8 +734,8 @@ TkClipCleanup( int XBell( - Display *display, - int percent) + TCL_UNUSED(Display *), + TCL_UNUSED(int)) { MessageBeep(MB_OK); return Success; @@ -1021,7 +1022,7 @@ GenerateXEvent( } memset(&event.x, 0, sizeof(XEvent)); - event.x.xany.serial = winPtr->display->request++; + event.x.xany.serial = LastKnownRequestProcessed(winPtr->display)++; event.x.xany.send_event = False; event.x.xany.display = winPtr->display; event.x.xany.window = winPtr->window; @@ -1454,7 +1455,7 @@ GetTranslatedKey( xkey->nbytes = 0; - while ((xkey->nbytes < XMaxTransChars) + while ((xkey->nbytes < sizeof(xkey->trans_chars)) && (PeekMessageA(&msg, NULL, type, type, PM_NOREMOVE) != 0)) { if (msg.message != type) { break; @@ -1520,7 +1521,7 @@ UpdateInputLanguage( if (keyInputCharset == charset) { return; } - if (TranslateCharsetInfo(INT2PTR(charset), &charsetInfo, + if (TranslateCharsetInfo((DWORD*)INT2PTR(charset), &charsetInfo, TCI_SRCCHARSET) == 0) { /* * Some mysterious failure. @@ -1676,7 +1677,7 @@ HandleIMEComposition( winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd); memset(&event, 0, sizeof(XEvent)); - event.xkey.serial = winPtr->display->request++; + event.xkey.serial = LastKnownRequestProcessed(winPtr->display)++; event.xkey.send_event = -3; event.xkey.display = winPtr->display; event.xkey.window = winPtr->window; @@ -1979,8 +1980,8 @@ Tk_SetCaretPos( * Return the number of milliseconds the user was inactive. * * Results: - * Milliseconds of user inactive time or -1 if the user32.dll doesn't - * have the symbol GetLastInputInfo or GetLastInputInfo returns an error. + * Milliseconds of user inactive time or -1 if GetLastInputInfo + * returns an error. * * Side effects: * None. @@ -1990,12 +1991,12 @@ Tk_SetCaretPos( long Tk_GetUserInactiveTime( - Display *dpy) /* Ignored on Windows */ + TCL_UNUSED(Display *)) { LASTINPUTINFO li; li.cbSize = sizeof(li); - if (!(BOOL)GetLastInputInfo(&li)) { + if (!GetLastInputInfo(&li)) { return -1; } @@ -2017,7 +2018,7 @@ Tk_GetUserInactiveTime( * none * * Side effects: - * The user inactivity timer of the underlaying windowing system is reset + * The user inactivity timer of the underlying windowing system is reset * to zero. * *---------------------------------------------------------------------- @@ -2025,7 +2026,7 @@ Tk_GetUserInactiveTime( void Tk_ResetUserInactiveTime( - Display *dpy) + TCL_UNUSED(Display *)) { INPUT inp; diff --git a/xlib/xutil.c b/xlib/xutil.c index d80b742..3654fcd 100644 --- a/xlib/xutil.c +++ b/xlib/xutil.c @@ -32,12 +32,12 @@ Atom XInternAtom( Display *display, - _Xconst char *atom_name, - Bool only_if_exists) + TCL_UNUSED(_Xconst char *), + TCL_UNUSED(Bool)) { static Atom atom = XA_LAST_PREDEFINED; - display->request++; + LastKnownRequestProcessed(display)++; return ++atom; } @@ -64,7 +64,7 @@ XGetVisualInfo( XVisualInfo *vinfo_template, int *nitems_return) { - XVisualInfo *info = ckalloc(sizeof(XVisualInfo)); + XVisualInfo *info = (XVisualInfo *)ckalloc(sizeof(XVisualInfo)); info->visual = DefaultVisual(display, 0); info->visualid = info->visual->visualid; -- cgit v0.12