diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-08-13 07:50:29 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-08-13 07:50:29 (GMT) |
commit | 4b979e70ec779c946337aa243a35c1e46abb4a8b (patch) | |
tree | 0c1a2d8c062c3f8acbfebae14ba8a2d08869533a /macosx | |
parent | 589d0dde98f21d4046bf3fa2fb4112c90863b8ad (diff) | |
parent | f558e5ec4e15ff534f53df5f46c85c6f80a552c6 (diff) | |
download | tk-4b979e70ec779c946337aa243a35c1e46abb4a8b.zip tk-4b979e70ec779c946337aa243a35c1e46abb4a8b.tar.gz tk-4b979e70ec779c946337aa243a35c1e46abb4a8b.tar.bz2 |
Add XOffsetRegion and XkbKeycodeToKeysym to (internal X11) stub table. More use of TCL_UNUSED macro
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXDraw.c | 36 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 79 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyboard.c | 40 | ||||
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 5 | ||||
-rw-r--r-- | macosx/tkMacOSXRegion.c | 13 |
5 files changed, 96 insertions, 77 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 645b72b..a31819a 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -70,7 +70,7 @@ static void ClipToGC(Drawable d, GC gc, HIShapeRef *clipRgnPtr); MODULE_SCOPE int TkMacOSXInitCGDrawing( Tcl_Interp *interp, - int enable, + TCL_UNUSED(int), int limit) { static Boolean initialized = FALSE; @@ -604,7 +604,7 @@ TkMacOSXGetCGContextForDrawable( bytesPerRow = ((size_t) macDraw->size.width * bitsPerPixel + 127) >> 3 & ~15; len = macDraw->size.height * bytesPerRow; - data = ckalloc(len); + data = (char *)ckalloc(len); bzero(data, len); macDraw->context = CGBitmapContextCreate(data, macDraw->size.width, macDraw->size.height, bitsPerComponent, bytesPerRow, @@ -865,7 +865,7 @@ XFillPolygon( GC gc, /* Use this GC. */ XPoint *points, /* Array of points. */ int npoints, /* Number of points. */ - int shape, /* Shape to draw. */ + TCL_UNUSED(int), /* Shape to draw. */ int mode) /* Drawing mode. */ { MacDrawable *macWin = (MacDrawable *) d; @@ -976,7 +976,7 @@ XDrawRectangle( *---------------------------------------------------------------------- */ -void +int XDrawRectangles( Display *display, Drawable drawable, @@ -990,8 +990,8 @@ XDrawRectangles( int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { + return BadDrawable; } if (dc.context) { CGRect rect; @@ -1009,6 +1009,7 @@ XDrawRectangles( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } #endif @@ -1360,7 +1361,7 @@ XFillArc( *---------------------------------------------------------------------- */ -void +int XFillArcs( Display *display, Drawable d, @@ -1375,7 +1376,7 @@ XFillArcs( display->request++; if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { - return; + return BadDrawable; } if (dc.context) { CGRect rect; @@ -1423,6 +1424,7 @@ XFillArcs( } } TkMacOSXRestoreDrawingContext(&dc); + return Success; } #endif @@ -1464,7 +1466,7 @@ XMaxRequestSize( int TkScrollWindow( Tk_Window tkwin, /* The window to be scrolled. */ - GC gc, /* GC for window to be scrolled. */ + TCL_UNUSED(GC), /* GC for window to be scrolled. */ int x, int y, /* Position rectangle to be scrolled. */ int width, int height, int dx, int dy, /* Distance rectangle should be moved. */ @@ -1560,8 +1562,8 @@ TkScrollWindow( void TkMacOSXSetUpGraphicsPort( - GC gc, /* GC to apply to current port. */ - void *destPort) + TCL_UNUSED(GC), /* GC to apply to current port. */ + TCL_UNUSED(void *)) { Tcl_Panic("TkMacOSXSetUpGraphicsPort: Obsolete, no more QD!"); } @@ -1589,7 +1591,7 @@ Bool TkMacOSXSetupDrawingContext( Drawable d, GC gc, - int useCG, /* advisory only ! */ + TCL_UNUSED(int), TkMacOSXDrawingContext *dcPtr) { MacDrawable *macDraw = (MacDrawable *) d; @@ -1928,7 +1930,7 @@ TkMacOSXSetUpClippingRgn( void TkpClipDrawableToRect( - Display *display, + TCL_UNUSED(Display *), Drawable d, int x, int y, int width, int height) @@ -1986,7 +1988,7 @@ ClipToGC( int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin; HIShapeRef clipRgn = *clipRgnPtr, gcClipRgn; - TkMacOSXOffsetRegion(gcClip, xOffset, yOffset); + XOffsetRegion(gcClip, xOffset, yOffset); gcClipRgn = TkMacOSXGetNativeRegion(gcClip); if (clipRgn) { *clipRgnPtr = HIShapeCreateIntersection(gcClipRgn, clipRgn); @@ -1995,7 +1997,7 @@ ClipToGC( *clipRgnPtr = HIShapeCreateCopy(gcClipRgn); } CFRelease(gcClipRgn); - TkMacOSXOffsetRegion(gcClip, -xOffset, -yOffset); + XOffsetRegion(gcClip, -xOffset, -yOffset); } } @@ -2019,8 +2021,8 @@ ClipToGC( void * TkMacOSXMakeStippleMap( - Drawable drawable, /* Window to apply stipple. */ - Drawable stipple) /* The stipple pattern. */ + TCL_UNUSED(Drawable), /* Window to apply stipple. */ + TCL_UNUSED(Drawable)) /* The stipple pattern. */ { return NULL; } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index d3c4a0c..ab2400c 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -28,6 +28,13 @@ static char tkLibPath[PATH_MAX + 1] = ""; static char scriptPath[PATH_MAX + 1] = ""; +/* + * Forward declarations... + */ + +static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip, + int objc, Tcl_Obj *const objv[]); + #pragma mark TKApplication(TKInit) @implementation TKApplication @@ -86,6 +93,7 @@ static char scriptPath[PATH_MAX + 1] = ""; -(void)applicationWillFinishLaunching:(NSNotification *)aNotification { + (void)aNotification; /* * Initialize notifications. @@ -117,6 +125,8 @@ static char scriptPath[PATH_MAX + 1] = ""; -(void)applicationDidFinishLaunching:(NSNotification *)notification { + (void)notification; + /* * It is not safe to force activation of the NSApp until this method is * called. Activating too early can cause the menu bar to be unresponsive. @@ -421,7 +431,8 @@ TkpInit( TkMacOSXStandardAboutPanelObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); - Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath, NULL, NULL); + Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", + TkMacOSXGetAppPathCmd, NULL, NULL); return TCL_OK; } @@ -461,11 +472,11 @@ TkpGetAppName( } Tcl_DStringAppend(namePtr, name, -1); } - + /* *---------------------------------------------------------------------- * - * TkMacOSXGetAppPath -- + * TkMacOSXGetAppPathCmd -- * * Returns the path of the Wish application bundle. * @@ -477,42 +488,39 @@ TkpGetAppName( * *---------------------------------------------------------------------- */ -int TkMacOSXGetAppPath( - ClientData cd, - Tcl_Interp *ip, - int objc, - Tcl_Obj *const objv[]) -{ - - CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle()); - - - /* - * Convert the URL reference into a string reference. - */ - - CFStringRef appPath = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle); - /* - * Get the system encoding method. - */ - - CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); +static int +TkMacOSXGetAppPathCmd( + TCL_UNUSED(ClientData), + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) +{ + if (objc != 1) { + Tcl_WrongNumArgs(interp, 1, objv, NULL); + return TCL_ERROR; + } - /* - * Convert the string reference into a C string. - */ + /* + * Get the application path URL and convert it to a string path reference. + */ - char *path = (char *) CFStringGetCStringPtr(appPath, encodingMethod); + CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFStringRef appPath = + CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle); - Tcl_SetResult(ip, path, NULL); + /* + * Convert (and copy) the string reference into a Tcl result. + */ - CFRelease(mainBundleURL); - CFRelease(appPath); - return TCL_OK; + Tcl_SetObjResult(interp, Tcl_NewStringObj( + CFStringGetCStringPtr(appPath, CFStringGetSystemEncoding()), -1)); + CFRelease(mainBundleURL); + CFRelease(appPath); + return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -579,7 +587,7 @@ TkMacOSXDefaultStartupScript(void) CFURLRef scriptFldrURL; char startupScript[PATH_MAX + 1]; - if (CFURLGetFileSystemRepresentation (appMainURL, true, + if (CFURLGetFileSystemRepresentation(appMainURL, true, (unsigned char *) startupScript, PATH_MAX)) { Tcl_SetStartupScript(Tcl_NewStringObj(startupScript,-1), NULL); scriptFldrURL = CFURLCreateCopyDeletingLastPathComponent(NULL, @@ -616,10 +624,11 @@ TkMacOSXDefaultStartupScript(void) MODULE_SCOPE void* TkMacOSXGetNamedSymbol( - const char* module, - const char* symbol) + TCL_UNUSED(const char *), + const char *symbol) { void *addr = dlsym(RTLD_NEXT, symbol); + if (!addr) { (void) dlerror(); /* Clear dlfcn error state */ } diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index 8381aa7..378c30e 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -153,6 +153,8 @@ static int KeyDataToUnicode(UniChar *uniChars, int maxChars, { #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); +#else + (void)notification; #endif keyboardChanged = YES; UpdateKeymaps(); @@ -401,14 +403,14 @@ KeyDataToUnicode( */ KeySym -XKeycodeToKeysym( - Display* display, - KeyCode keycode, +XkbKeycodeToKeysym( + TCL_UNUSED(Display *), + unsigned int keycode, + TCL_UNUSED(int), int index) { Tcl_HashEntry *hPtr; MacKeycode macKC; - (void) display; /*unused*/ int modifiers, result; UniChar keychar = 0; @@ -459,6 +461,15 @@ XKeycodeToKeysym( } return NoSymbol; } + +KeySym +XKeycodeToKeysym( + TCL_UNUSED(Display *), + KeyCode keycode, + int index) +{ + return XkbKeycodeToKeysym(NULL, keycode, 0, index); +} /* *---------------------------------------------------------------------- @@ -479,13 +490,12 @@ XKeycodeToKeysym( const char * TkpGetString( - TkWindow *winPtr, /* Window where event occurred: Needed to get + TCL_UNUSED(TkWindow *), /* Window where event occurred: Needed to get * input context. */ XEvent *eventPtr, /* X keyboard event. */ Tcl_DString *dsPtr) /* Uninitialized or empty string to hold * result. */ { - (void) winPtr; /*unused*/ MacKeycode macKC; char utfChars[8]; int length = 0; @@ -519,11 +529,11 @@ TkpGetString( XModifierKeymap * XGetModifierMapping( - Display *display) + TCL_UNUSED(Display *)) { XModifierKeymap *modmap; - modmap = ckalloc(sizeof(XModifierKeymap)); + modmap = (XModifierKeymap *)ckalloc(sizeof(XModifierKeymap)); modmap->max_keypermod = 0; modmap->modifiermap = NULL; return modmap; @@ -578,14 +588,14 @@ XFreeModifiermap( char * XKeysymToString( - KeySym keysym) + TCL_UNUSED(KeySym)) { return NULL; } KeySym XStringToKeysym( - const char* string) + TCL_UNUSED(const char *)) { return NoSymbol; } @@ -613,7 +623,7 @@ XStringToKeysym( KeyCode XKeysymToKeycode( - Display *display, + TCL_UNUSED(Display *), KeySym keysym) { Tcl_HashEntry *hPtr; @@ -681,7 +691,7 @@ XKeysymToKeycode( */ void TkpSetKeycodeAndState( - Tk_Window tkwin, + TCL_UNUSED(Tk_Window), KeySym keysym, XEvent *eventPtr) { @@ -813,7 +823,7 @@ TkpGetKeySym( * First do the straightforward lookup. */ - sym = XKeycodeToKeysym(dispPtr->display, macKC.uint, index); + sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0, index); /* * Special handling: If the key was shifted because of Lock, which is only @@ -823,7 +833,7 @@ TkpGetKeySym( if ((index & INDEX_SHIFT) && !(eventPtr->xkey.state & ShiftMask)) { if ((sym == NoSymbol) || !Tcl_UniCharIsUpper(sym)) { - sym = XKeycodeToKeysym(dispPtr->display, macKC.uint, + sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0, index & ~INDEX_SHIFT); } } @@ -834,7 +844,7 @@ TkpGetKeySym( */ if ((index & INDEX_SHIFT) && (sym == NoSymbol)) { - sym = XKeycodeToKeysym(dispPtr->display, macKC.uint, + sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0, index & ~INDEX_SHIFT); } return sym; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 6109024..a6b988e 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -218,7 +218,6 @@ MODULE_SCOPE long tkMacOSXMacOSXVersion; MODULE_SCOPE HIShapeRef TkMacOSXGetNativeRegion(TkRegion r); MODULE_SCOPE void TkMacOSXSetWithNativeRegion(TkRegion r, HIShapeRef rgn); -MODULE_SCOPE void TkMacOSXOffsetRegion(TkRegion r, short dx, short dy); MODULE_SCOPE HIShapeRef TkMacOSXHIShapeCreateEmpty(void); MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect( const CGRect *inRect); @@ -557,9 +556,7 @@ VISIBILITY_HIDDEN @end #endif /* _TKMACPRIV */ - -int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *const objv[]); - + /* * Local Variables: * mode: objc diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index db19c94..4baa3e8 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -436,7 +436,7 @@ TkMacOSXSetWithNativeRegion( /* *---------------------------------------------------------------------- * - * TkMacOSXOffsetRegion -- + * XOffsetRegion -- * * Offsets region by given distances. * @@ -449,13 +449,14 @@ TkMacOSXSetWithNativeRegion( *---------------------------------------------------------------------- */ -void -TkMacOSXOffsetRegion( - TkRegion r, - short dx, - short dy) +int +XOffsetRegion( + void *r, + int dx, + int dy) { ChkErr(HIShapeOffset, (HIMutableShapeRef) r, dx, dy); + return Success; } /* |