diff options
author | hobbs <hobbs> | 2001-10-13 01:25:10 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2001-10-13 01:25:10 (GMT) |
commit | 7aa6d1c3c6f75337aa66bac37572a2a8c41b8d34 (patch) | |
tree | dc4bbf10e41e907a281eb9afba82c31f09a32ce1 | |
parent | 841f9d3342a2a3f00db110a0d7e7a5d18e03f037 (diff) | |
download | tk-7aa6d1c3c6f75337aa66bac37572a2a8c41b8d34.zip tk-7aa6d1c3c6f75337aa66bac37572a2a8c41b8d34.tar.gz tk-7aa6d1c3c6f75337aa66bac37572a2a8c41b8d34.tar.bz2 |
* generic/tkBind.c (NameToWindow):
* generic/tkCmds.c (Tk_WinfoObjCmd):
* generic/tkInt.decls (TkpScanWindowId):
* generic/tkIntPlatDecls.h:
* generic/tkStubInit.c:
* mac/tkMacPort.h (TkpPrintWindowId,TkpScanWindowId):
* unix/tkUnixPort.h (TkpPrintWindowId,TkpScanWindowId):
* unix/tkUnixXId.c (TkpScanWindowId):
* win/tkWinWindow.c (TkpScanWindowId): Corrected definition of
TkpScanWindowId to handle situation where types Window and int
do not have the same number of bits. CONST-ified too.
-rw-r--r-- | generic/tkBind.c | 12 | ||||
-rw-r--r-- | generic/tkCmds.c | 7 | ||||
-rw-r--r-- | generic/tkInt.decls | 8 | ||||
-rw-r--r-- | generic/tkIntPlatDecls.h | 14 | ||||
-rw-r--r-- | generic/tkStubInit.c | 3 | ||||
-rw-r--r-- | mac/tkMacPort.h | 5 | ||||
-rw-r--r-- | unix/tkUnixPort.h | 12 | ||||
-rw-r--r-- | unix/tkUnixXId.c | 35 | ||||
-rw-r--r-- | win/tkWinWindow.c | 44 |
9 files changed, 98 insertions, 42 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c index 0e9cce5..20b135c 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkBind.c,v 1.13.2.1 2001/04/04 07:57:16 hobbs Exp $ + * RCS: @(#) $Id: tkBind.c,v 1.13.2.2 2001/10/13 01:25:10 hobbs Exp $ */ #include "tkPort.h" @@ -21,6 +21,10 @@ #include "tkWinInt.h" #endif +#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ +#include "tkUnixInt.h" +#endif + /* * File structure: * @@ -2295,7 +2299,7 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) /* Empty loop body. */ } if (string != before) { - Tcl_DStringAppend(dsPtr, before, string-before); + Tcl_DStringAppend(dsPtr, before, (int) (string-before)); before = string; } if (*before == 0) { @@ -3712,7 +3716,7 @@ NameToWindow(interp, mainWin, objPtr, tkwinPtr) { char *name; Tk_Window tkwin; - int id; + Window id; name = Tcl_GetStringFromObj(objPtr, NULL); if (name[0] == '.') { @@ -3728,7 +3732,7 @@ NameToWindow(interp, mainWin, objPtr, tkwinPtr) */ if ((TkpScanWindowId(NULL, name, &id) != TCL_OK) || - ((*tkwinPtr = Tk_IdToWindow(Tk_Display(mainWin), (Window) id)) + ((*tkwinPtr = Tk_IdToWindow(Tk_Display(mainWin), id)) == NULL)) { Tcl_AppendResult(interp, "bad window name/identifier \"", name, "\"", (char *) NULL); diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 9bbfba3..4cffb1c 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCmds.c,v 1.13 2000/04/19 23:11:23 ericm Exp $ + * RCS: @(#) $Id: tkCmds.c,v 1.13.2.1 2001/10/13 01:25:10 hobbs Exp $ */ #include "tkPort.h" @@ -1329,7 +1329,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) return result; } case WIN_PATHNAME: { - int id; + Window id; skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin); if (skip < 0) { @@ -1343,8 +1343,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) if (TkpScanWindowId(interp, string, &id) != TCL_OK) { return TCL_ERROR; } - winPtr = (TkWindow *) - Tk_IdToWindow(Tk_Display(tkwin), (Window) id); + winPtr = (TkWindow *) Tk_IdToWindow(Tk_Display(tkwin), id); if ((winPtr == NULL) || (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) { Tcl_AppendStringsToObj(resultPtr, "window id \"", string, diff --git a/generic/tkInt.decls b/generic/tkInt.decls index efa0066..bd68524 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tkInt.decls,v 1.17.2.1 2001/04/04 21:39:48 hobbs Exp $ +# RCS: @(#) $Id: tkInt.decls,v 1.17.2.2 2001/10/13 01:25:10 hobbs Exp $ library tk @@ -677,6 +677,10 @@ declare 7 unix { void TkUnixSetMenubar (Tk_Window tkwin, Tk_Window menubar) } +declare 8 unix { + int TkpScanWindowId (Tcl_Interp *interp, CONST char *string, Window *idPtr) +} + ############################ # Windows specific functions @@ -701,7 +705,7 @@ declare 5 win { } declare 6 win { - int TkpScanWindowId (Tcl_Interp *interp, char *string, int *idPtr) + int TkpScanWindowId (Tcl_Interp *interp, CONST char *string, Window *idPtr) } declare 7 win { diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index 0e086c6..475fa19 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -9,7 +9,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.7.2.1 2001/04/04 21:39:48 hobbs Exp $ + * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.7.2.2 2001/10/13 01:25:10 hobbs Exp $ */ #ifndef _TKINTPLATDECLS @@ -52,6 +52,9 @@ EXTERN int TkUnixDoOneXEvent _ANSI_ARGS_((Tcl_Time * timePtr)); /* 7 */ EXTERN void TkUnixSetMenubar _ANSI_ARGS_((Tk_Window tkwin, Tk_Window menubar)); +/* 8 */ +EXTERN int TkpScanWindowId _ANSI_ARGS_((Tcl_Interp * interp, + CONST char * string, Window * idPtr)); #endif /* UNIX */ #ifdef __WIN32__ /* 0 */ @@ -70,7 +73,7 @@ EXTERN void TkpPrintWindowId _ANSI_ARGS_((char * buf, Window window)); /* 6 */ EXTERN int TkpScanWindowId _ANSI_ARGS_((Tcl_Interp * interp, - char * string, int * idPtr)); + CONST char * string, Window * idPtr)); /* 7 */ EXTERN void TkpSetCapture _ANSI_ARGS_((TkWindow * winPtr)); /* 8 */ @@ -293,6 +296,7 @@ typedef struct TkIntPlatStubs { Window (*tkUnixContainerId) _ANSI_ARGS_((TkWindow * winPtr)); /* 5 */ int (*tkUnixDoOneXEvent) _ANSI_ARGS_((Tcl_Time * timePtr)); /* 6 */ void (*tkUnixSetMenubar) _ANSI_ARGS_((Tk_Window tkwin, Tk_Window menubar)); /* 7 */ + int (*tkpScanWindowId) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * string, Window * idPtr)); /* 8 */ #endif /* UNIX */ #ifdef __WIN32__ char * (*tkAlignImageData) _ANSI_ARGS_((XImage * image, int alignment, int bitOrder)); /* 0 */ @@ -301,7 +305,7 @@ typedef struct TkIntPlatStubs { unsigned long (*tkpGetMS) _ANSI_ARGS_((void)); /* 3 */ void (*tkPointerDeadWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 4 */ void (*tkpPrintWindowId) _ANSI_ARGS_((char * buf, Window window)); /* 5 */ - int (*tkpScanWindowId) _ANSI_ARGS_((Tcl_Interp * interp, char * string, int * idPtr)); /* 6 */ + int (*tkpScanWindowId) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * string, Window * idPtr)); /* 6 */ void (*tkpSetCapture) _ANSI_ARGS_((TkWindow * winPtr)); /* 7 */ void (*tkpSetCursor) _ANSI_ARGS_((TkpCursor cursor)); /* 8 */ void (*tkpWmSetState) _ANSI_ARGS_((TkWindow * winPtr, int state)); /* 9 */ @@ -448,6 +452,10 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkUnixSetMenubar \ (tkIntPlatStubsPtr->tkUnixSetMenubar) /* 7 */ #endif +#ifndef TkpScanWindowId +#define TkpScanWindowId \ + (tkIntPlatStubsPtr->tkpScanWindowId) /* 8 */ +#endif #endif /* UNIX */ #ifdef __WIN32__ #ifndef TkAlignImageData diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index eb683ef..75134a1 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubInit.c,v 1.22.2.2 2001/04/04 21:39:48 hobbs Exp $ + * RCS: @(#) $Id: tkStubInit.c,v 1.22.2.3 2001/10/13 01:25:10 hobbs Exp $ */ #include "tkInt.h" @@ -281,6 +281,7 @@ TkIntPlatStubs tkIntPlatStubs = { TkUnixContainerId, /* 5 */ TkUnixDoOneXEvent, /* 6 */ TkUnixSetMenubar, /* 7 */ + TkpScanWindowId, /* 8 */ #endif /* UNIX */ #ifdef __WIN32__ TkAlignImageData, /* 0 */ diff --git a/mac/tkMacPort.h b/mac/tkMacPort.h index c10c7e8..19b5a78 100644 --- a/mac/tkMacPort.h +++ b/mac/tkMacPort.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacPort.h,v 1.9.2.1 2001/04/04 21:39:49 hobbs Exp $ + * RCS: @(#) $Id: tkMacPort.h,v 1.9.2.2 2001/10/13 01:25:10 hobbs Exp $ */ #ifndef _TKMACPORT @@ -120,6 +120,7 @@ EXTERN int strncasecmp _ANSI_ARGS_((CONST char *s1, /* * This macro stores a representation of the window handle in a string. + * This should perhaps use the real size of an XID. */ #define TkpPrintWindowId(buf,w) \ @@ -130,7 +131,7 @@ EXTERN int strncasecmp _ANSI_ARGS_((CONST char *s1, */ #define TkpScanWindowId(i,s,wp) \ - Tcl_GetInt((i),(s),(wp)) + Tcl_GetInt((i),(s),(int *)(wp)) /* * Magic pixel values for dynamic (or active) colors. diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index 242d127..580450e 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixPort.h,v 1.5 1999/04/16 01:51:47 stanton Exp $ + * RCS: @(#) $Id: tkUnixPort.h,v 1.5.12.1 2001/10/13 01:25:10 hobbs Exp $ */ #ifndef _UNIXPORT @@ -200,17 +200,11 @@ extern int errno; /* * This macro stores a representation of the window handle in a string. + * This should perhaps use the real size of an XID. */ #define TkpPrintWindowId(buf,w) \ - sprintf((buf), "0x%x", (unsigned int) (w)) - -/* - * TkpScanWindowId is just an alias for Tcl_GetInt on Unix. - */ - -#define TkpScanWindowId(i,s,wp) \ - Tcl_GetInt((i),(s),(wp)) + sprintf((buf), "%#08lx", (unsigned long) (w)) /* * This macro indicates that entry and text widgets should display diff --git a/unix/tkUnixXId.c b/unix/tkUnixXId.c index 6312d3a..d818c87 100644 --- a/unix/tkUnixXId.c +++ b/unix/tkUnixXId.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixXId.c,v 1.5 1999/04/21 21:53:32 rjohnson Exp $ + * RCS: @(#) $Id: tkUnixXId.c,v 1.5.12.1 2001/10/13 01:25:10 hobbs Exp $ */ /* @@ -534,3 +534,36 @@ TkpWindowWasRecentlyDeleted(win, dispPtr) } return 0; } + +/* + *---------------------------------------------------------------------- + * + * TkpScanWindowId -- + * + * Given a string, produce the corresponding Window Id. + * + * Results: + * The return value is normally TCL_OK; in this case *idPtr + * will be set to the Window value equivalent to string. If + * string is improperly formed then TCL_ERROR is returned and + * an error message will be left in the interp's result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpScanWindowId(interp, string, idPtr) + Tcl_Interp *interp; + CONST char *string; + Window *idPtr; +{ + int value; + if (Tcl_GetInt(interp, string, &value) != TCL_OK) { + return TCL_ERROR; + } + *idPtr = (Window) value; + return TCL_OK; +} diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index bde96c6..0c18faf 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWindow.c,v 1.5.12.1 2001/04/04 07:57:18 hobbs Exp $ + * RCS: @(#) $Id: tkWinWindow.c,v 1.5.12.2 2001/10/13 01:25:10 hobbs Exp $ */ #include "tkWinInt.h" @@ -144,8 +144,7 @@ HWND Tk_GetHWND(window) Window window; { - TkWinDrawable *twdPtr = (TkWinDrawable *) window; - return twdPtr->window.handle; + return ((TkWinDrawable *) window)->window.handle; } /* @@ -173,7 +172,11 @@ TkpPrintWindowId(buf, window) Window window; /* Window to be printed into buffer. */ { HWND hwnd = (window) ? Tk_GetHWND(window) : 0; - sprintf(buf, "0x%x", (unsigned int) hwnd); + /* + * Use pointer representation, because Win64 is P64 (*not* LP64). + * Windows doesn't print the 0x for %p, so we do it. + */ + sprintf(buf, "0x%p", hwnd); } /* @@ -201,16 +204,25 @@ TkpPrintWindowId(buf, window) int TkpScanWindowId(interp, string, idPtr) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ - char *string; /* String containing a (possibly signed) + CONST char *string; /* String containing a (possibly signed) * integer in a form acceptable to strtol. */ - int *idPtr; /* Place to store converted result. */ + Window *idPtr; /* Place to store converted result. */ { - int number; Tk_Window tkwin; + Window number; - if (Tcl_GetInt(interp, string, &number) != TCL_OK) { + /* + * We want sscanf for the 64-bit check, but if that doesn't work, + * then Tcl_GetInt manages the error correctly. + */ + if ( +#ifdef _WIN64 + (sscanf(string, "0x%p", &number) != 1) && +#endif + Tcl_GetInt(interp, string, (int *)&number) != TCL_OK) { return TCL_ERROR; } + tkwin = Tk_HWNDToWindow((HWND)number); if (tkwin) { *idPtr = Tk_WindowId(tkwin); @@ -350,7 +362,7 @@ XMapWindow(display, w) display->request++; - ShowWindow(TkWinGetHWND(w), SW_SHOWNORMAL); + ShowWindow(Tk_GetHWND(w), SW_SHOWNORMAL); winPtr->flags |= TK_MAPPED; /* @@ -463,7 +475,7 @@ XUnmapWindow(display, w) * it will be cleared before XUnmapWindow is called. */ - ShowWindow(TkWinGetHWND(w), SW_HIDE); + ShowWindow(Tk_GetHWND(w), SW_HIDE); winPtr->flags &= ~TK_MAPPED; if (winPtr->flags & TK_TOP_LEVEL) { @@ -504,7 +516,7 @@ XMoveResizeWindow(display, w, x, y, width, height) unsigned int height; { display->request++; - MoveWindow(TkWinGetHWND(w), x, y, width, height, TRUE); + MoveWindow(Tk_GetHWND(w), x, y, width, height, TRUE); } /* @@ -534,7 +546,7 @@ XMoveWindow(display, w, x, y) display->request++; - MoveWindow(TkWinGetHWND(w), x, y, winPtr->changes.width, + MoveWindow(Tk_GetHWND(w), x, y, winPtr->changes.width, winPtr->changes.height, TRUE); } @@ -565,7 +577,7 @@ XResizeWindow(display, w, width, height) display->request++; - MoveWindow(TkWinGetHWND(w), winPtr->changes.x, winPtr->changes.y, width, + MoveWindow(Tk_GetHWND(w), winPtr->changes.x, winPtr->changes.y, width, height, TRUE); } @@ -590,7 +602,7 @@ XRaiseWindow(display, w) Display* display; Window w; { - HWND window = TkWinGetHWND(w); + HWND window = Tk_GetHWND(w); display->request++; SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, @@ -624,7 +636,7 @@ XConfigureWindow(display, w, value_mask, values) XWindowChanges* values; { TkWindow *winPtr = TkWinGetWinPtr(w); - HWND hwnd = TkWinGetHWND(w); + HWND hwnd = Tk_GetHWND(w); display->request++; @@ -677,7 +689,7 @@ XClearWindow(display, w) HBRUSH brush; HPALETTE oldPalette, palette; TkWindow *winPtr; - HWND hwnd = TkWinGetHWND(w); + HWND hwnd = Tk_GetHWND(w); HDC dc = GetDC(hwnd); palette = TkWinGetPalette(display->screens[0].cmap); |