From 14ffbbfd3279791bcc99fd50066d6821e92cc5f9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 24 Sep 2019 11:49:30 +0000 Subject: Allow "wm frame" to return id's > 0xFFFFFFFF on 64-bit platforms (if the id really is that large). Backport the (internal) use of TCL_Z_MODIFIER from Tk 8.7. --- generic/tkInt.h | 10 ++++++++++ macosx/tkMacOSXWm.c | 4 +++- unix/tkUnixWm.c | 4 +++- win/tkWinWm.c | 6 ++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index cd27afc..e4e49cb 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -84,6 +84,16 @@ # endif #endif +#ifndef TCL_Z_MODIFIER +# if defined(_WIN64) +# define TCL_Z_MODIFIER "I" +# elif defined(__GNUC__) && !defined(_WIN32) +# define TCL_Z_MODIFIER "z" +# else +# define TCL_Z_MODIFIER "" +# endif +#endif /* !TCL_Z_MODIFIER */ + /* * Opaque type declarations: */ diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index ca19197..25966a6 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1984,6 +1984,7 @@ WmFrameCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; Window window; + char buf[TCL_INTEGER_SPACE]; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -1993,7 +1994,8 @@ WmFrameCmd( if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } - Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window)); + sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window); + Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 7b69713..f09b59c 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -1871,6 +1871,7 @@ WmFrameCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; Window window; + char buf[TCL_INTEGER_SPACE]; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -1880,7 +1881,8 @@ WmFrameCmd( if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } - Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window)); + sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window); + Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 8b3e449..dcafd68 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -3711,6 +3711,7 @@ WmFrameCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; HWND hwnd; + char buf[TCL_INTEGER_SPACE]; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -3723,7 +3724,8 @@ WmFrameCmd( if (hwnd == NULL) { hwnd = Tk_GetHWND(Tk_WindowId((Tk_Window) winPtr)); } - Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", PTR2INT(hwnd))); + sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd); + Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } @@ -5466,7 +5468,7 @@ WmTitleCmd( int size = 256; GetWindowTextW(wrapper, buf, size); - Tcl_WinTCharToUtf(buf, -1, &titleString); + Tcl_WinTCharToUtf((LPCTSTR)buf, -1, &titleString); Tcl_SetObjResult(interp, Tcl_NewStringObj( Tcl_DStringValue(&titleString), Tcl_DStringLength(&titleString))); -- cgit v0.12