summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-10-27 11:55:44 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-10-27 11:55:44 (GMT)
commit957201cb93aa79eb303379cbfd71c1d37f4772ab (patch)
treeef28b1355dbaebeb1a8e7476dd622f89bd35c406
parent1f5835f567b76c544877c30f2eb28456a0db5643 (diff)
downloadtk-957201cb93aa79eb303379cbfd71c1d37f4772ab.zip
tk-957201cb93aa79eb303379cbfd71c1d37f4772ab.tar.gz
tk-957201cb93aa79eb303379cbfd71c1d37f4772ab.tar.bz2
Code style improvements, especially including making code less deeply nested.
-rw-r--r--macosx/tkMacOSXClipboard.c5
-rw-r--r--macosx/tkMacOSXDebug.c417
-rw-r--r--macosx/tkMacOSXEvent.c213
-rw-r--r--macosx/tkMacOSXKeyEvent.c555
-rw-r--r--macosx/tkMacOSXKeyboard.c170
-rw-r--r--macosx/tkMacOSXMenu.c1013
-rw-r--r--macosx/tkMacOSXMouseEvent.c741
-rw-r--r--macosx/tkMacOSXPrivate.h164
-rw-r--r--macosx/tkMacOSXRegion.c74
-rw-r--r--macosx/tkMacOSXSubwindows.c602
10 files changed, 2014 insertions, 1940 deletions
diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c
index 7daffea..cf59f90 100644
--- a/macosx/tkMacOSXClipboard.c
+++ b/macosx/tkMacOSXClipboard.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: tkMacOSXClipboard.c,v 1.13 2008/10/05 21:26:11 dkf Exp $
+ * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.14 2008/10/27 11:55:44 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -130,8 +130,7 @@ TkSelGetSelection(
Tcl_ExternalToUtfDString(TkMacOSXCarbonEncoding, buf, length,
&encodedText);
- result = (*proc)(clientData, interp,
- Tcl_DStringValue(&encodedText));
+ result = proc(clientData, interp, Tcl_DStringValue(&encodedText));
Tcl_DStringFree(&encodedText);
ckfree(buf);
diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c
index 740922b..0065b68 100644
--- a/macosx/tkMacOSXDebug.c
+++ b/macosx/tkMacOSXDebug.c
@@ -1,8 +1,8 @@
/*
* tkMacOSXDebug.c --
*
- * Implementation of Macintosh specific functions for debugging MacOS events,
- * regions, etc...
+ * Implementation of Macintosh specific functions for debugging MacOS
+ * events, regions, etc...
*
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.20 2008/06/19 00:14:56 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.21 2008/10/27 11:55:44 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -73,180 +73,180 @@ typedef struct {
} MyEventNameList;
static MyEventName windowEventNames [] = {
- { kEventWindowUpdate,"Update"},
- { kEventWindowDrawContent,"DrawContent"},
- { kEventWindowActivated,"Activated"},
- { kEventWindowDeactivated,"Deactivated"},
- { kEventWindowGetClickActivation,"GetClickActivation"},
- { kEventWindowShowing,"Showing"},
- { kEventWindowHiding,"Hiding"},
- { kEventWindowShown,"Shown"},
- { kEventWindowHidden,"Hidden"},
- { kEventWindowBoundsChanging,"BoundsChanging"},
- { kEventWindowBoundsChanged,"BoundsChanged"},
- { kEventWindowResizeStarted,"ResizeStarted"},
- { kEventWindowResizeCompleted,"ResizeCompleted"},
- { kEventWindowDragStarted,"DragStarted"},
- { kEventWindowDragCompleted,"DragCompleted"},
- { kEventWindowClickDragRgn,"ClickDragRgn"},
- { kEventWindowClickResizeRgn,"ClickResizeRgn"},
- { kEventWindowClickCollapseRgn,"ClickCollapseRgn"},
- { kEventWindowClickCloseRgn,"ClickCloseRgn"},
- { kEventWindowClickZoomRgn,"ClickZoomRgn"},
- { kEventWindowClickContentRgn,"ClickContentRgn"},
- { kEventWindowClickProxyIconRgn,"ClickProxyIconRgn"},
- { kEventWindowCursorChange,"CursorChange" },
- { kEventWindowCollapse,"Collapse"},
- { kEventWindowCollapsed,"Collapsed"},
- { kEventWindowCollapseAll,"CollapseAll"},
- { kEventWindowExpand,"Expand"},
- { kEventWindowExpanded,"Expanded"},
- { kEventWindowExpandAll,"ExpandAll"},
- { kEventWindowCollapse,"Collapse"},
- { kEventWindowClose,"Close"},
- { kEventWindowClosed,"Closed"},
- { kEventWindowCloseAll,"CloseAll"},
- { kEventWindowZoom,"Zoom"},
- { kEventWindowZoomed,"Zoomed"},
- { kEventWindowZoomAll,"ZoomAll"},
- { kEventWindowContextualMenuSelect,"ContextualMenuSelect"},
- { kEventWindowPathSelect,"PathSelect"},
- { kEventWindowGetIdealSize,"GetIdealSize"},
- { kEventWindowGetMinimumSize,"GetMinimumSize"},
- { kEventWindowGetMaximumSize,"GetMaximumSize"},
- { kEventWindowConstrain,"Constrain"},
- { kEventWindowHandleContentClick,"HandleContentClick"},
- { kEventWindowProxyBeginDrag,"ProxyBeginDra}"},
- { kEventWindowProxyEndDrag,"ProxyEndDrag"},
- { kEventWindowFocusAcquired,"FocusAcquired"},
- { kEventWindowFocusRelinquish,"FocusRelinquish"},
- { kEventWindowDrawFrame,"DrawFrame"},
- { kEventWindowDrawPart,"DrawPart"},
- { kEventWindowGetRegion,"GetRegion"},
- { kEventWindowHitTest,"HitTest"},
- { kEventWindowInit,"Init"},
- { kEventWindowDispose,"Dispose"},
- { kEventWindowDragHilite,"DragHilite"},
- { kEventWindowModified,"Modified"},
- { kEventWindowSetupProxyDragImage,"SetupProxyDragImage"},
- { kEventWindowStateChanged,"StateChanged"},
- { kEventWindowMeasureTitle,"MeasureTitle"},
- { kEventWindowDrawGrowBox,"DrawGrowBox"},
- { kEventWindowGetGrowImageRegion,"GetGrowImageRegion"},
- { kEventWindowPaint,"Paint"},
- { 0, NULL },
+ { kEventWindowUpdate,"Update"},
+ { kEventWindowDrawContent,"DrawContent"},
+ { kEventWindowActivated,"Activated"},
+ { kEventWindowDeactivated,"Deactivated"},
+ { kEventWindowGetClickActivation,"GetClickActivation"},
+ { kEventWindowShowing,"Showing"},
+ { kEventWindowHiding,"Hiding"},
+ { kEventWindowShown,"Shown"},
+ { kEventWindowHidden,"Hidden"},
+ { kEventWindowBoundsChanging,"BoundsChanging"},
+ { kEventWindowBoundsChanged,"BoundsChanged"},
+ { kEventWindowResizeStarted,"ResizeStarted"},
+ { kEventWindowResizeCompleted,"ResizeCompleted"},
+ { kEventWindowDragStarted,"DragStarted"},
+ { kEventWindowDragCompleted,"DragCompleted"},
+ { kEventWindowClickDragRgn,"ClickDragRgn"},
+ { kEventWindowClickResizeRgn,"ClickResizeRgn"},
+ { kEventWindowClickCollapseRgn,"ClickCollapseRgn"},
+ { kEventWindowClickCloseRgn,"ClickCloseRgn"},
+ { kEventWindowClickZoomRgn,"ClickZoomRgn"},
+ { kEventWindowClickContentRgn,"ClickContentRgn"},
+ { kEventWindowClickProxyIconRgn,"ClickProxyIconRgn"},
+ { kEventWindowCursorChange,"CursorChange" },
+ { kEventWindowCollapse,"Collapse"},
+ { kEventWindowCollapsed,"Collapsed"},
+ { kEventWindowCollapseAll,"CollapseAll"},
+ { kEventWindowExpand,"Expand"},
+ { kEventWindowExpanded,"Expanded"},
+ { kEventWindowExpandAll,"ExpandAll"},
+ { kEventWindowCollapse,"Collapse"},
+ { kEventWindowClose,"Close"},
+ { kEventWindowClosed,"Closed"},
+ { kEventWindowCloseAll,"CloseAll"},
+ { kEventWindowZoom,"Zoom"},
+ { kEventWindowZoomed,"Zoomed"},
+ { kEventWindowZoomAll,"ZoomAll"},
+ { kEventWindowContextualMenuSelect,"ContextualMenuSelect"},
+ { kEventWindowPathSelect,"PathSelect"},
+ { kEventWindowGetIdealSize,"GetIdealSize"},
+ { kEventWindowGetMinimumSize,"GetMinimumSize"},
+ { kEventWindowGetMaximumSize,"GetMaximumSize"},
+ { kEventWindowConstrain,"Constrain"},
+ { kEventWindowHandleContentClick,"HandleContentClick"},
+ { kEventWindowProxyBeginDrag,"ProxyBeginDra}"},
+ { kEventWindowProxyEndDrag,"ProxyEndDrag"},
+ { kEventWindowFocusAcquired,"FocusAcquired"},
+ { kEventWindowFocusRelinquish,"FocusRelinquish"},
+ { kEventWindowDrawFrame,"DrawFrame"},
+ { kEventWindowDrawPart,"DrawPart"},
+ { kEventWindowGetRegion,"GetRegion"},
+ { kEventWindowHitTest,"HitTest"},
+ { kEventWindowInit,"Init"},
+ { kEventWindowDispose,"Dispose"},
+ { kEventWindowDragHilite,"DragHilite"},
+ { kEventWindowModified,"Modified"},
+ { kEventWindowSetupProxyDragImage,"SetupProxyDragImage"},
+ { kEventWindowStateChanged,"StateChanged"},
+ { kEventWindowMeasureTitle,"MeasureTitle"},
+ { kEventWindowDrawGrowBox,"DrawGrowBox"},
+ { kEventWindowGetGrowImageRegion,"GetGrowImageRegion"},
+ { kEventWindowPaint,"Paint"},
+ { 0, NULL },
};
static MyEventName mouseEventNames [] = {
- { kEventMouseMoved, "Moved"},
- { kEventMouseUp, "Up"},
- { kEventMouseDown, "Down"},
- { kEventMouseDragged, "Dragged"},
- { kEventMouseWheelMoved, "WheelMoved"},
- { 0, NULL}
+ { kEventMouseMoved, "Moved"},
+ { kEventMouseUp, "Up"},
+ { kEventMouseDown, "Down"},
+ { kEventMouseDragged, "Dragged"},
+ { kEventMouseWheelMoved, "WheelMoved"},
+ { 0, NULL}
};
static MyEventName keyboardEventNames [] = {
- { kEventRawKeyDown, "Down"},
- { kEventRawKeyRepeat, "Repeat"},
- { kEventRawKeyUp, "Up"},
- { kEventRawKeyModifiersChanged, "ModifiersChanged"},
- { kEventHotKeyPressed, "HotKeyPressed"},
- { kEventHotKeyReleased, "HotKeyReleased"},
- { 0, NULL}
+ { kEventRawKeyDown, "Down"},
+ { kEventRawKeyRepeat, "Repeat"},
+ { kEventRawKeyUp, "Up"},
+ { kEventRawKeyModifiersChanged, "ModifiersChanged"},
+ { kEventHotKeyPressed, "HotKeyPressed"},
+ { kEventHotKeyReleased, "HotKeyReleased"},
+ { 0, NULL}
};
static MyEventName appEventNames [] = {
- { kEventAppActivated, "Activated"},
- { kEventAppDeactivated, "Deactivated"},
- { kEventAppQuit, "Quit"},
- { kEventAppLaunchNotification, "LaunchNotification"},
- { kEventAppLaunched, "Launched"},
- { kEventAppTerminated, "Terminated"},
- { kEventAppFrontSwitched, "FrontSwitched"},
- { 0, NULL}
+ { kEventAppActivated, "Activated"},
+ { kEventAppDeactivated, "Deactivated"},
+ { kEventAppQuit, "Quit"},
+ { kEventAppLaunchNotification, "LaunchNotification"},
+ { kEventAppLaunched, "Launched"},
+ { kEventAppTerminated, "Terminated"},
+ { kEventAppFrontSwitched, "FrontSwitched"},
+ { 0, NULL}
};
static MyEventName menuEventNames [] = {
- { kEventMenuBeginTracking, "BeginTracking"},
- { kEventMenuEndTracking, "EndTracking"},
- { kEventMenuChangeTrackingMode, "ChangeTrackingMode"},
- { kEventMenuOpening, "Opening"},
- { kEventMenuClosed, "Closed"},
- { kEventMenuTargetItem, "TargetItem"},
- { kEventMenuMatchKey, "MatchKey"},
- { kEventMenuEnableItems, "EnableItems"},
- { kEventMenuDispose, "Dispose"},
- { 0, NULL }
+ { kEventMenuBeginTracking, "BeginTracking"},
+ { kEventMenuEndTracking, "EndTracking"},
+ { kEventMenuChangeTrackingMode, "ChangeTrackingMode"},
+ { kEventMenuOpening, "Opening"},
+ { kEventMenuClosed, "Closed"},
+ { kEventMenuTargetItem, "TargetItem"},
+ { kEventMenuMatchKey, "MatchKey"},
+ { kEventMenuEnableItems, "EnableItems"},
+ { kEventMenuDispose, "Dispose"},
+ { 0, NULL }
};
static MyEventName controlEventNames [] = {
- { kEventControlInitialize, "Initialize" },
- { kEventControlDispose, "Dispose" },
- { kEventControlGetOptimalBounds, "GetOptimalBounds" },
- { kEventControlHit, "Hit" },
- { kEventControlSimulateHit, "SimulateHit" },
- { kEventControlHitTest, "HitTest" },
- { kEventControlDraw, "Draw" },
- { kEventControlApplyBackground, "ApplyBackground" },
- { kEventControlApplyTextColor, "ApplyTextColor" },
- { kEventControlSetFocusPart, "SetFocusPart" },
- { kEventControlGetFocusPart, "GetFocusPart" },
- { kEventControlActivate, "Activate" },
- { kEventControlDeactivate, "Deactivate" },
- { kEventControlSetCursor, "SetCursor" },
- { kEventControlContextualMenuClick, "ContextualMenuClick" },
- { kEventControlClick, "Click" },
- { kEventControlTrack, "Track" },
- { kEventControlGetScrollToHereStartPoint, "GetScrollToHereStartPoint" },
- { kEventControlGetIndicatorDragConstraint, "GetIndicatorDragConstraint" },
- { kEventControlIndicatorMoved, "IndicatorMoved" },
- { kEventControlGhostingFinished, "GhostingFinished" },
- { kEventControlGetActionProcPart, "GetActionProcPart" },
- { kEventControlGetPartRegion, "GetPartRegion" },
- { kEventControlGetPartBounds, "GetPartBounds" },
- { kEventControlSetData, "SetData" },
- { kEventControlGetData, "GetData" },
- { kEventControlValueFieldChanged, "ValueFieldChanged" },
- { kEventControlAddedSubControl, "AddedSubControl" },
- { kEventControlRemovingSubControl, "RemovingSubControl" },
- { kEventControlBoundsChanged, "BoundsChanged" },
- { kEventControlOwningWindowChanged, "OwningWindowChanged" },
- { kEventControlArbitraryMessage, "ArbitraryMessage" },
- { 0, NULL }
+ { kEventControlInitialize, "Initialize" },
+ { kEventControlDispose, "Dispose" },
+ { kEventControlGetOptimalBounds, "GetOptimalBounds" },
+ { kEventControlHit, "Hit" },
+ { kEventControlSimulateHit, "SimulateHit" },
+ { kEventControlHitTest, "HitTest" },
+ { kEventControlDraw, "Draw" },
+ { kEventControlApplyBackground, "ApplyBackground" },
+ { kEventControlApplyTextColor, "ApplyTextColor" },
+ { kEventControlSetFocusPart, "SetFocusPart" },
+ { kEventControlGetFocusPart, "GetFocusPart" },
+ { kEventControlActivate, "Activate" },
+ { kEventControlDeactivate, "Deactivate" },
+ { kEventControlSetCursor, "SetCursor" },
+ { kEventControlContextualMenuClick, "ContextualMenuClick" },
+ { kEventControlClick, "Click" },
+ { kEventControlTrack, "Track" },
+ { kEventControlGetScrollToHereStartPoint, "GetScrollToHereStartPoint" },
+ { kEventControlGetIndicatorDragConstraint, "GetIndicatorDragConstraint" },
+ { kEventControlIndicatorMoved, "IndicatorMoved" },
+ { kEventControlGhostingFinished, "GhostingFinished" },
+ { kEventControlGetActionProcPart, "GetActionProcPart" },
+ { kEventControlGetPartRegion, "GetPartRegion" },
+ { kEventControlGetPartBounds, "GetPartBounds" },
+ { kEventControlSetData, "SetData" },
+ { kEventControlGetData, "GetData" },
+ { kEventControlValueFieldChanged, "ValueFieldChanged" },
+ { kEventControlAddedSubControl, "AddedSubControl" },
+ { kEventControlRemovingSubControl, "RemovingSubControl" },
+ { kEventControlBoundsChanged, "BoundsChanged" },
+ { kEventControlOwningWindowChanged, "OwningWindowChanged" },
+ { kEventControlArbitraryMessage, "ArbitraryMessage" },
+ { 0, NULL }
};
static MyEventName commandEventNames [] = {
- { kEventCommandProcess, "Process" },
- { kEventCommandUpdateStatus, "UpdateStatus" },
- { 0, NULL }
+ { kEventCommandProcess, "Process" },
+ { kEventCommandUpdateStatus, "UpdateStatus" },
+ { 0, NULL }
};
static MyEventNameList eventNameList [] = {
- { kEventClassWindow, windowEventNames },
- { kEventClassMouse, mouseEventNames },
- { kEventClassKeyboard, keyboardEventNames },
- { kEventClassApplication, appEventNames },
- { kEventClassMenu, menuEventNames },
- { kEventClassControl, controlEventNames },
- { kEventClassCommand, commandEventNames },
- { 0, NULL}
+ { kEventClassWindow, windowEventNames },
+ { kEventClassMouse, mouseEventNames },
+ { kEventClassKeyboard, keyboardEventNames },
+ { kEventClassApplication, appEventNames },
+ { kEventClassMenu, menuEventNames },
+ { kEventClassControl, controlEventNames },
+ { kEventClassCommand, commandEventNames },
+ { 0, NULL}
};
#ifdef TK_MACOSXDEBUG_UNUSED
static MyEventName classicEventNames [] = {
- { nullEvent,"nullEvent" },
- { mouseDown,"mouseDown" },
- { mouseUp,"mouseUp" },
- { keyDown,"keyDown" },
- { keyUp,"keyUp" },
- { autoKey,"autoKey" },
- { updateEvt,"updateEvt" },
- { diskEvt,"diskEvt" },
- { activateEvt,"activateEvt" },
- { osEvt,"osEvt" },
- { kHighLevelEvent,"kHighLevelEvent" },
- { 0, NULL }
+ { nullEvent,"nullEvent" },
+ { mouseDown,"mouseDown" },
+ { mouseUp,"mouseUp" },
+ { keyDown,"keyDown" },
+ { keyUp,"keyUp" },
+ { autoKey,"autoKey" },
+ { updateEvt,"updateEvt" },
+ { diskEvt,"diskEvt" },
+ { activateEvt,"activateEvt" },
+ { osEvt,"osEvt" },
+ { kHighLevelEvent,"kHighLevelEvent" },
+ { 0, NULL }
};
#endif /* TK_MACOSXDEBUG_UNUSED */
@@ -276,7 +276,7 @@ TkMacOSXCarbonEventToAscii(EventRef eventRef)
list++;
}
}
- while (names && names->name) {
+ while (names && names->name) {
if (eventKind == names->kind) {
snprintf(buf, 250, "%-20s", names->name);
break;
@@ -292,13 +292,14 @@ TkMacOSXCarbonEventToAscii(EventRef eventRef)
#ifdef TK_MACOSXDEBUG_UNUSED
MODULE_SCOPE char *
-TkMacOSXCarbonEventKindToAscii(EventRef eventRef, char * buf )
+TkMacOSXCarbonEventKindToAscii(EventRef eventRef, char *buf)
{
EventClass eventClass;
- EventKind eventKind;
- MyEventNameList * list = eventNameList;
- MyEventName * names = NULL;
- int found = 0;
+ EventKind eventKind;
+ MyEventNameList *list = eventNameList;
+ MyEventName *names = NULL;
+ int found = 0;
+
eventClass = GetEventClass(eventRef);
eventKind = GetEventKind(eventRef);
while (list->names && (!names) ) {
@@ -310,7 +311,7 @@ TkMacOSXCarbonEventKindToAscii(EventRef eventRef, char * buf )
}
if (names) {
found = 0;
- while ( names->name && !found ) {
+ while (names->name && !found) {
if (eventKind == names->kind) {
sprintf(buf,"%s",names->name);
found = 1;
@@ -320,59 +321,58 @@ TkMacOSXCarbonEventKindToAscii(EventRef eventRef, char * buf )
}
}
if (!found) {
- sprintf ( buf,"%d", eventKind );
- } else {
- sprintf ( buf,"%d", eventKind );
- }
- return buf;
+ sprintf(buf,"%d", eventKind);
+ } else {
+ sprintf(buf,"%d", eventKind);
+ }
+ return buf;
}
MODULE_SCOPE char *
-TkMacOSXClassicEventToAscii(EventRecord * eventPtr, char * buf )
+TkMacOSXClassicEventToAscii(EventRecord *eventPtr, char *buf)
{
- MyEventName * names = NULL;
+ MyEventName *names = NULL;
int found = 0;
names = classicEventNames;
- while ( names -> name && !found )
+ while (names -> name && !found) {
if (eventPtr->what == names->kind) {
- int * iPtr;
+ int *iPtr;
char cBuf[8];
- iPtr=(int *) &cBuf;
+
+ iPtr = (int *) &cBuf;
*iPtr = eventPtr->message;
cBuf[4] = 0;
sprintf(buf, "%-16s %08x %04x %s", names->name,
- (int) eventPtr->message,
- eventPtr->modifiers,
- cBuf);
+ (int) eventPtr->message, eventPtr->modifiers, cBuf);
found = 1;
} else {
- names++;
+ names++;
}
+ }
if (!found) {
- sprintf(buf,"%-16d %08x %08x, %s",
- eventPtr->what, (int) eventPtr->message,
- eventPtr->modifiers, buf);
+ sprintf(buf,"%-16d %08x %08x, %s", eventPtr->what,
+ (int) eventPtr->message, eventPtr->modifiers, buf);
}
return buf;
}
MODULE_SCOPE void
-TkMacOSXPrintPoint(char * tag, Point * p )
+TkMacOSXPrintPoint(char *tag, Point *p)
{
TkMacOSXDbgMsg("%s %4d %4d", tag,p->h,p->v );
}
MODULE_SCOPE void
-TkMacOSXPrintRect(char * tag, Rect * r )
+TkMacOSXPrintRect(char *tag, Rect *r)
{
TkMacOSXDbgMsg("%s %4d %4d %4d %4d (%dx%d)",
- tag, r->left, r->top, r->right, r->bottom,
- r->right - r->left + 1, r->bottom - r->top + 1);
+ tag, r->left, r->top, r->right, r->bottom,
+ r->right - r->left + 1, r->bottom - r->top + 1);
}
MODULE_SCOPE void
-TkMacOSXPrintRegion(char * tag, RgnHandle rgn )
+TkMacOSXPrintRegion(char *tag, RgnHandle rgn)
{
Rect r;
GetRegionBounds(rgn,&r);
@@ -380,17 +380,17 @@ TkMacOSXPrintRegion(char * tag, RgnHandle rgn )
}
MODULE_SCOPE void
-TkMacOSXPrintWindowTitle(char * tag, WindowRef window )
+TkMacOSXPrintWindowTitle(char *tag, WindowRef window)
{
Str255 title;
GetWTitle(window,title);
- title [title[0] + 1] = 0;
+ title[title[0] + 1] = 0;
TkMacOSXDbgMsg("%s %s", tag, title +1 );
}
typedef struct {
- int msg;
- char * name;
+ int msg;
+ char *name;
} MsgName;
static MsgName msgNames [] = {
@@ -408,9 +408,9 @@ static MsgName msgNames [] = {
};
MODULE_SCOPE char *
-TkMacOSXMenuMessageToAscii(int msg, char * s)
+TkMacOSXMenuMessageToAscii(int msg, char *s)
{
- MsgName * msgNamePtr;
+ MsgName *msgNamePtr;
for (msgNamePtr = msgNames;msgNamePtr->name;) {
if (msgNamePtr->msg == msg) {
strcpy(s,msgNamePtr->name);
@@ -419,7 +419,7 @@ TkMacOSXMenuMessageToAscii(int msg, char * s)
msgNamePtr++;
}
}
- sprintf(s,"unknown : %d", msg );
+ sprintf(s, "unknown : %d", msg);
return s;
}
@@ -436,9 +436,9 @@ static MsgName trackingNames [] = {
};
MODULE_SCOPE char *
-TkMacOSXMouseTrackingResultToAscii(MouseTrackingResult r, char * buf)
+TkMacOSXMouseTrackingResultToAscii(MouseTrackingResult r, char *buf)
{
- MsgName * namePtr;
+ MsgName *namePtr;
for (namePtr = trackingNames; namePtr->name; namePtr++) {
if (namePtr->msg == r) {
strcpy(buf, namePtr->name);
@@ -487,19 +487,17 @@ TkMacOSXDebugFlashRegion(
*
* TkMacOSXGetNamedDebugSymbol --
*
+ * Dynamically acquire address of a named symbol from a loaded dynamic
+ * library, so that we can use API that may not be available on all OS
+ * versions. For debugging purposes, if we cannot find the symbol with
+ * the usual dynamic library APIs, we manually walk the symbol table of
+ * the loaded library. This allows access to unexported symbols such as
+ * private_extern internal debugging functions. If module is NULL or the
+ * empty string, search all loaded libraries (could be very expensive and
+ * should be avoided).
*
- * Dynamically acquire address of a named symbol from a loaded
- * dynamic library, so that we can use API that may not be
- * available on all OS versions.
- * For debugging purposes, if we cannot find the symbol with the
- * usual dynamic library APIs, we manually walk the symbol table
- * of the loaded library. This allows access to unexported
- * symbols such as private_extern internal debugging functions.
- * If module is NULL or the empty string, search all loaded
- * libraries (could be very expensive and should be avoided).
- *
- * THIS FUCTION IS ONLY TO BE USED FOR DEBUGGING PURPOSES, IT MAY
- * BREAK UNEXPECTEDLY IN THE FUTURE !
+ * THIS FUCTION IS ONLY TO BE USED FOR DEBUGGING PURPOSES, IT MAY BREAK
+ * UNEXPECTEDLY IN THE FUTURE!
*
* Results:
* Address of given symbol or NULL if unavailable.
@@ -515,7 +513,7 @@ TkMacOSXGetNamedDebugSymbol(
const char* module,
const char* symbol)
{
- void* addr = TkMacOSXGetNamedSymbol(module, symbol);
+ void *addr = TkMacOSXGetNamedSymbol(module, symbol);
#ifndef __LP64__
if (!addr) {
const struct mach_header *mh = NULL;
@@ -574,7 +572,7 @@ TkMacOSXGetNamedDebugSymbol(
nsect += ns;
}
} else if (!st && lc->cmd == LC_SYMTAB) {
- st = (struct symtab_command*) lc;
+ st = (struct symtab_command *) lc;
break;
}
lc = (struct load_command *)((char *) lc + lc->cmdsize);
@@ -586,11 +584,14 @@ TkMacOSXGetNamedDebugSymbol(
uint32_t strsize = st->strsize;
int32_t strx;
- /* Offset file positions by difference to actual position
- in memory of last segment before symbol table: */
+ /*
+ * Offset file positions by difference to actual position
+ * in memory of last segment before symbol table:
+ */
+
base = (intptr_t) sg->vmaddr + slide - sg->fileoff;
- strings = (char*)(base + st->stroff);
- sym = (struct nlist*)(base + st->symoff);
+ strings = (char *) (base + st->stroff);
+ sym = (struct nlist *) (base + st->symoff);
m = st->nsyms;
for (j = 0; j < m; j++) {
/* Find symbol with given name in __text section */
diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c
index c3e3cea..11114c2 100644
--- a/macosx/tkMacOSXEvent.c
+++ b/macosx/tkMacOSXEvent.c
@@ -10,21 +10,20 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.23 2007/12/13 15:27:09 dgp Exp $
+ * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.24 2008/10/27 11:55:44 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
#include "tkMacOSXEvent.h"
#include "tkMacOSXDebug.h"
-
/*
*----------------------------------------------------------------------
*
* TkMacOSXFlushWindows --
*
- * This routine flushes all the Carbon windows of the application. It
- * is called by XSync().
+ * This routine flushes all the Carbon windows of the application. It is
+ * called by XSync().
*
* Results:
* None.
@@ -62,10 +61,10 @@ TkMacOSXFlushWindows(void)
* This dispatches a filtered Carbon event to the appropriate handler
*
* Note on MacEventStatus.stopProcessing: Please be conservative in the
- * individual handlers and don't assume the event is fully handled
- * unless you *really* need to ensure that other handlers don't see the
- * event anymore. Some OS manager or library might be interested in
- * events even after they are already handled on the Tk level.
+ * individual handlers and don't assume the event is fully handled unless
+ * you *really* need to ensure that other handlers don't see the event
+ * anymore. Some OS manager or library might be interested in events even
+ * after they are already handled on the Tk level.
*
* Results:
* 0 on success
@@ -83,32 +82,32 @@ TkMacOSXProcessEvent(
MacEventStatus *statusPtr)
{
switch (eventPtr->eClass) {
- case kEventClassMouse:
- TkMacOSXProcessMouseEvent(eventPtr, statusPtr);
- break;
- case kEventClassWindow:
- TkMacOSXProcessWindowEvent(eventPtr, statusPtr);
- break;
- case kEventClassKeyboard:
- TkMacOSXProcessKeyboardEvent(eventPtr, statusPtr);
- break;
- case kEventClassApplication:
- TkMacOSXProcessApplicationEvent(eventPtr, statusPtr);
- break;
- case kEventClassAppearance:
- TkMacOSXProcessAppearanceEvent(eventPtr, statusPtr);
- break;
- case kEventClassMenu:
- TkMacOSXProcessMenuEvent(eventPtr, statusPtr);
- break;
- case kEventClassCommand:
- TkMacOSXProcessCommandEvent(eventPtr, statusPtr);
- break;
- default: {
- TkMacOSXDbgMsg("Unrecognised event: %s",
- TkMacOSXCarbonEventToAscii(eventPtr->eventRef));
- break;
- }
+ case kEventClassMouse:
+ TkMacOSXProcessMouseEvent(eventPtr, statusPtr);
+ break;
+ case kEventClassWindow:
+ TkMacOSXProcessWindowEvent(eventPtr, statusPtr);
+ break;
+ case kEventClassKeyboard:
+ TkMacOSXProcessKeyboardEvent(eventPtr, statusPtr);
+ break;
+ case kEventClassApplication:
+ TkMacOSXProcessApplicationEvent(eventPtr, statusPtr);
+ break;
+ case kEventClassAppearance:
+ TkMacOSXProcessAppearanceEvent(eventPtr, statusPtr);
+ break;
+ case kEventClassMenu:
+ TkMacOSXProcessMenuEvent(eventPtr, statusPtr);
+ break;
+ case kEventClassCommand:
+ TkMacOSXProcessCommandEvent(eventPtr, statusPtr);
+ break;
+ default: {
+ TkMacOSXDbgMsg("Unrecognised event: %s",
+ TkMacOSXCarbonEventToAscii(eventPtr->eventRef));
+ break;
+ }
}
return 0;
}
@@ -118,8 +117,8 @@ TkMacOSXProcessEvent(
*
* TkMacOSXProcessMenuEvent --
*
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
+ * This routine processes the event in eventPtr, and generates the
+ * appropriate Tk events from it.
*
* Results:
* True if event(s) are generated - false otherwise.
@@ -137,61 +136,65 @@ TkMacOSXProcessMenuEvent(
{
int menuContext;
OSStatus err;
+ MenuRef menu;
+ MenuItemIndex index;
switch (eventPtr->eKind) {
- case kEventMenuBeginTracking:
- case kEventMenuEndTracking:
- case kEventMenuOpening:
- case kEventMenuTargetItem:
- break;
- default:
- return 0;
- break;
+ case kEventMenuBeginTracking:
+ case kEventMenuEndTracking:
+ case kEventMenuOpening:
+ case kEventMenuTargetItem:
+ break;
+ default:
+ return 0;
+ }
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamMenuContext, typeUInt32, NULL, sizeof(menuContext),
+ NULL, &menuContext);
+ if (err != noErr) {
+ return 0;
}
- err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamMenuContext,
- typeUInt32, NULL, sizeof(menuContext), NULL, &menuContext);
- if (err == noErr && ((menuContext & kMenuContextMenuBarTracking) ||
- (menuContext & kMenuContextPopUpTracking))) {
- switch (eventPtr->eKind) {
- MenuRef menu;
- case kEventMenuBeginTracking:
- TkMacOSXClearMenubarActive();
+ if ((menuContext & kMenuContextMenuBarTracking) ||
+ (menuContext & kMenuContextPopUpTracking)) {
+ switch (eventPtr->eKind) {
+ case kEventMenuBeginTracking:
+ TkMacOSXClearMenubarActive();
- /*
- * Handle -postcommand
- */
+ /*
+ * Handle -postcommand
+ */
- TkMacOSXPreprocessMenu();
- TkMacOSXTrackingLoop(1);
- break;
- case kEventMenuEndTracking:
- TkMacOSXTrackingLoop(0);
- break;
- case kEventMenuOpening:
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamDirectObject, typeMenuRef, NULL,
- sizeof(menu), NULL, &menu);
- if (err == noErr) {
- TkMacOSXClearActiveMenu(menu);
- return TkMacOSXGenerateParentMenuSelectEvent(menu);
- }
- break;
- case kEventMenuTargetItem:
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamDirectObject, typeMenuRef, NULL,
- sizeof(menu), NULL, &menu);
- if (err == noErr) {
- MenuItemIndex index;
+ TkMacOSXPreprocessMenu();
+ TkMacOSXTrackingLoop(1);
+ break;
+ case kEventMenuEndTracking:
+ TkMacOSXTrackingLoop(0);
+ break;
+ case kEventMenuOpening:
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamDirectObject, typeMenuRef, NULL, sizeof(menu),
+ NULL, &menu);
+ if (err != noErr) {
+ return 0;
+ }
+ TkMacOSXClearActiveMenu(menu);
+ return TkMacOSXGenerateParentMenuSelectEvent(menu);
+ case kEventMenuTargetItem:
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamDirectObject, typeMenuRef, NULL, sizeof(menu),
+ NULL, &menu);
+ if (err != noErr) {
+ return 0;
+ }
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMenuItemIndex, typeMenuItemIndex, NULL,
- sizeof(index), NULL, &index);
- if (err == noErr) {
- return TkMacOSXGenerateMenuSelectEvent(menu, index);
- }
- }
- break;
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamMenuItemIndex, typeMenuItemIndex, NULL,
+ sizeof(index), NULL, &index);
+ if (err != noErr) {
+ return 0;
+ }
+ return TkMacOSXGenerateMenuSelectEvent(menu, index);
}
}
return 0;
@@ -202,8 +205,8 @@ TkMacOSXProcessMenuEvent(
*
* TkMacOSXProcessCommandEvent --
*
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
+ * This routine processes the event in eventPtr, and generates the
+ * appropriate Tk events from it.
*
* Results:
* True if event(s) are generated - false otherwise.
@@ -217,29 +220,37 @@ TkMacOSXProcessMenuEvent(
MODULE_SCOPE int
TkMacOSXProcessCommandEvent(
TkMacOSXEvent *eventPtr,
- MacEventStatus * statusPtr)
+ MacEventStatus *statusPtr)
{
HICommand command;
int menuContext;
OSStatus err;
switch (eventPtr->eKind) {
- case kEventCommandProcess:
- case kEventCommandUpdateStatus:
- break;
- default:
- return 0;
- break;
+ case kEventCommandProcess:
+ case kEventCommandUpdateStatus:
+ break;
+ default:
+ return 0;
}
+
err = ChkErr(GetEventParameter, eventPtr->eventRef,
kEventParamDirectObject, typeHICommand, NULL, sizeof(command),
NULL, &command);
- if (err == noErr && (command.attributes & kHICommandFromMenu)) {
+ if (err != noErr) {
+ return 0;
+ }
+
+ if (command.attributes & kHICommandFromMenu) {
if (eventPtr->eKind == kEventCommandProcess) {
err = ChkErr(GetEventParameter, eventPtr->eventRef,
kEventParamMenuContext, typeUInt32, NULL,
sizeof(menuContext), NULL, &menuContext);
- if (err == noErr && (menuContext & kMenuContextMenuBar) &&
+ if (err != noErr) {
+ return 0;
+ }
+
+ if ((menuContext & kMenuContextMenuBar) &&
(menuContext & kMenuContextMenuBarTracking)) {
TkMacOSXHandleMenuSelect(GetMenuID(command.menu.menuRef),
command.menu.menuItemIndex,
@@ -248,7 +259,9 @@ TkMacOSXProcessCommandEvent(
}
} else {
Tcl_CmdInfo dummy;
- if (command.commandID == kHICommandPreferences && eventPtr->interp) {
+
+ if (command.commandID == kHICommandPreferences
+ && eventPtr->interp != NULL) {
if (Tcl_GetCommandInfo(eventPtr->interp,
"::tk::mac::ShowPreferences", &dummy)) {
if (!IsMenuItemEnabled(command.menu.menuRef,
@@ -270,3 +283,11 @@ TkMacOSXProcessCommandEvent(
}
return 0;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index fd52e7a..73165f9 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -1,8 +1,8 @@
/*
* tkMacOSXKeyEvent.c --
*
- * This file implements functions that decode & handle keyboard events
- * on MacOS X.
+ * This file implements functions that decode & handle keyboard events on
+ * MacOS X.
*
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
@@ -10,51 +10,45 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
- *
- * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.25 2008/09/02 16:10:55 das Exp $
+ * The following terms apply to all files originating from Apple Computer,
+ * Inc. ("Apple") and associated with the software unless explicitly
+ * disclaimed in individual files.
+ *
+ * Apple hereby grants permission to use, copy, modify, distribute, and
+ * license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that
+ * this notice is included verbatim in any distributions. No written
+ * agreement, license, or royalty fee is required for any of the
+ * authorized uses. Modifications to this software may be copyrighted by
+ * their authors and need not follow the licensing terms described here,
+ * provided that the new terms are clearly indicated on the first page of
+ * each file where they apply.
+ *
+ * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE SOFTWARE BE
+ * LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS
+ * DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF APPLE OR THE AUTHORS
+ * HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS
+ * AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
+ * A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED
+ * ON AN "AS IS" BASIS, AND APPLE,THE AUTHORS AND DISTRIBUTORS HAVE NO
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+ * MODIFICATIONS.
+ *
+ * GOVERNMENT USE: If you are acquiring this software on behalf of the
+ * U.S. government, the Government shall have only "Restricted Rights" in
+ * the software and related documentation as defined in the Federal
+ * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are
+ * acquiring the software on behalf of the Department of Defense, the
+ * software shall be classified as "Commercial Computer Software" and the
+ * Government shall have only "Restricted Rights" as defined in Clause
+ * 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+ * authors grant the U.S. Government and others acting in its behalf
+ * permission to use and distribute the software in accordance with the
+ * terms specified in this license.
+ *
+ * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.26 2008/10/27 11:55:44 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -92,28 +86,31 @@ static UInt32 deadKeyStateDown = 0;
* Declarations for functions used only in this file.
*/
-static int InitKeyData(KeyEventData *keyEventDataPtr);
-static int InitKeyEvent(XEvent *eventPtr, KeyEventData *e, UInt32 savedKeyCode,
- UInt32 savedModifiers);
-static int GenerateKeyEvent(UInt32 eKind, KeyEventData *e, UInt32 savedKeyCode,
- UInt32 savedModifiers, const UniChar *chars, int numChars);
-static int GetKeyboardLayout(Ptr *resourcePtr, TextEncoding *encodingPtr);
-static TextEncoding GetKCHREncoding(ScriptCode script, SInt32 layoutid);
-static int KeycodeToUnicodeViaUnicodeResource(UniChar *uniChars, int maxChars,
- Ptr uchr, EventKind eKind, UInt32 keycode, UInt32 modifiers,
- UInt32 *deadKeyStatePtr);
-static int KeycodeToUnicodeViaKCHRResource(UniChar *uniChars, int maxChars,
- Ptr kchr, TextEncoding encoding, EventKind eKind, UInt32 keycode,
- UInt32 modifiers, UInt32 *deadKeyStatePtr);
-
+static int GenerateKeyEvent(UInt32 eKind, KeyEventData *e,
+ UInt32 savedKeyCode, UInt32 savedModifiers,
+ const UniChar *chars, int numChars);
+static TextEncoding GetKCHREncoding(ScriptCode script, SInt32 layoutid);
+static int GetKeyboardLayout(Ptr *resourcePtr,
+ TextEncoding *encodingPtr);
+static int InitKeyData(KeyEventData *keyEventDataPtr);
+static int InitKeyEvent(XEvent *eventPtr, KeyEventData *e,
+ UInt32 savedKeyCode, UInt32 savedModifiers);
+static int KeycodeToUnicodeViaKCHRResource(UniChar *uniChars,
+ int maxChars, Ptr kchr, TextEncoding encoding,
+ EventKind eKind, UInt32 keycode, UInt32 modifiers,
+ UInt32 *deadKeyStatePtr);
+static int KeycodeToUnicodeViaUnicodeResource(UniChar *uniChars,
+ int maxChars, Ptr uchr, EventKind eKind,
+ UInt32 keycode, UInt32 modifiers,
+ UInt32 *deadKeyStatePtr);
/*
*----------------------------------------------------------------------
*
* TkMacOSXProcessKeyboardEvent --
*
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
+ * This routine processes the event in eventPtr, and generates the
+ * appropriate Tk events from it.
*
* Results:
* True if event(s) are generated - false otherwise.
@@ -150,18 +147,17 @@ TkMacOSXProcessKeyboardEvent(
* accelerators through IsMenuKeyEvent. Tk treats accelerators as mere
* decoration, and the user has to install bindings to get them to fire.
*
- * However, the only way to trigger the Hide & Hide Others functions
- * is by invoking the Menu command for Hide. So there is no nice way to
- * provide a Tk command to hide the app which would be available for a
- * binding. So I am going to hijack Command-H and Command-Shift-H
- * here, and run the menu commands. Since the HI Guidelines explicitly
- * reserve these for Hide, this isn't such a bad thing. Also, if you do
- * rebind Command-H to another menu item, Hide will lose its binding.
+ * However, the only way to trigger the Hide & Hide Others functions is by
+ * invoking the Menu command for Hide. So there is no nice way to provide a
+ * Tk command to hide the app which would be available for a binding. So I
+ * am going to hijack Command-H and Command-Shift-H here, and run the menu
+ * commands. Since the HI Guidelines explicitly reserve these for Hide,
+ * this isn't such a bad thing. Also, if you do rebind Command-H to another
+ * menu item, Hide will lose its binding.
*
- * Note that I don't really do anything at this point,
- * I just mark stopProcessing as 0 and return, and then the
- * RecieveAndProcessEvent code will dispatch the event to the default
- * handler.
+ * Note that I don't really do anything at this point, I just mark
+ * stopProcessing as 0 and return, and then the RecieveAndProcessEvent code
+ * will dispatch the event to the default handler.
*/
if ((eventPtr->eKind == kEventRawKeyDown
@@ -172,21 +168,20 @@ TkMacOSXProcessKeyboardEvent(
GetMenuItemCommandID (menuRef, menuItemIndex, &menuCmd);
switch (menuCmd) {
- case kHICommandHide:
- case kHICommandHideOthers:
- case kHICommandShowAll:
- case kHICommandPreferences:
- case kHICommandQuit:
- statusPtr->stopProcessing = 0;
-
- /*
- * TODO: may not be on event on queue.
- */
-
- return 0;
- break;
- default:
- break;
+ case kHICommandHide:
+ case kHICommandHideOthers:
+ case kHICommandShowAll:
+ case kHICommandPreferences:
+ case kHICommandQuit:
+ statusPtr->stopProcessing = 0;
+
+ /*
+ * TODO: may not be on event on queue.
+ */
+
+ return 0;
+ default:
+ break;
}
}
@@ -214,23 +209,23 @@ TkMacOSXProcessKeyboardEvent(
}
switch (eventPtr->eKind) {
- case kEventRawKeyUp:
- case kEventRawKeyDown:
- case kEventRawKeyRepeat: {
- UInt32 *deadKeyStatePtr;
-
- if (kEventRawKeyDown == eventPtr->eKind) {
- deadKeyStatePtr = &deadKeyStateDown;
- } else {
- deadKeyStatePtr = &deadKeyStateUp;
- }
+ case kEventRawKeyUp:
+ case kEventRawKeyDown:
+ case kEventRawKeyRepeat: {
+ UInt32 *deadKeyStatePtr;
- uniCharsLen = TkMacOSXKeycodeToUnicode(uniChars,
- sizeof(uniChars)/sizeof(*uniChars), eventPtr->eKind,
- keyEventData.keyCode, keyEventData.keyModifiers,
- deadKeyStatePtr);
- break;
+ if (kEventRawKeyDown == eventPtr->eKind) {
+ deadKeyStatePtr = &deadKeyStateDown;
+ } else {
+ deadKeyStatePtr = &deadKeyStateUp;
}
+
+ uniCharsLen = TkMacOSXKeycodeToUnicode(uniChars,
+ sizeof(uniChars)/sizeof(*uniChars), eventPtr->eKind,
+ keyEventData.keyCode, keyEventData.keyModifiers,
+ deadKeyStatePtr);
+ break;
+ }
}
if (kEventRawKeyUp == eventPtr->eKind) {
@@ -274,14 +269,14 @@ TkMacOSXProcessKeyboardEvent(
if (eventGenerated == 0) {
savedKeyCode = keyEventData.message;
return false;
- } else if (eventGenerated == -1) {
+ }
+ if (eventGenerated == -1) {
savedKeyCode = 0;
statusPtr->stopProcessing = 0;
return false;
- } else {
- savedKeyCode = 0;
- return true;
}
+ savedKeyCode = 0;
+ return true;
}
/*
@@ -289,15 +284,15 @@ TkMacOSXProcessKeyboardEvent(
*
* GenerateKeyEvent --
*
- * Given Macintosh keyUp, keyDown & autoKey events (in their "raw"
- * form) and a list of unicode characters this function generates the
+ * Given Macintosh keyUp, keyDown & autoKey events (in their "raw" form)
+ * and a list of unicode characters this function generates the
* appropriate X key events.
*
- * Parameter eKind is a raw keyboard event. e contains the data sent
- * with the event. savedKeyCode and savedModifiers contain the values
- * from the last event that came before (see
- * TkMacOSXProcessKeyboardEvent()). chars/numChars has the Unicode
- * characters for which we want to create events.
+ * Parameter eKind is a raw keyboard event. e contains the data sent with
+ * the event. savedKeyCode and savedModifiers contain the values from the
+ * last event that came before (see TkMacOSXProcessKeyboardEvent()).
+ * chars/numChars has the Unicode characters for which we want to create
+ * events.
*
* Results:
* 1 if an event was generated, -1 for any error.
@@ -332,9 +327,9 @@ GenerateKeyEvent(
}
/*
- * Use special '-1' to signify a special keycode to our
- * platform specific code in tkMacOSXKeyboard.c. This is
- * rather like what happens on Windows.
+ * Use special '-1' to signify a special keycode to our platform
+ * specific code in tkMacOSXKeyboard.c. This is rather like what
+ * happens on Windows.
*/
event.xany.send_event = -1;
@@ -345,43 +340,42 @@ GenerateKeyEvent(
event.xkey.keycode = (e->keyModifiers ^ savedModifiers);
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-
} else {
for (i = 0; i < numChars; ++i) {
/*
* Encode one char in the trans_chars array that was already
- * introduced for MS Windows. Don't encode the string, if it is
- * a control character but was not generated with a real control
+ * introduced for MS Windows. Don't encode the string, if it is a
+ * control character but was not generated with a real control
* modifier. Such control characters get generated by KeyTrans()
- * for special keys, but we rather want to identify those by
- * their KeySyms.
+ * for special keys, but we rather want to identify those by their
+ * KeySyms.
*/
event.xkey.trans_chars[0] = 0;
if ((controlKey & e->keyModifiers) || (chars[i] >= ' ')) {
- int done;
- done = Tcl_UniCharToUtf(chars[i],event.xkey.trans_chars);
+ int done = Tcl_UniCharToUtf(chars[i],event.xkey.trans_chars);
+
event.xkey.trans_chars[done] = 0;
}
switch(eKind) {
- case kEventRawKeyDown:
- event.xany.type = KeyPress;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- break;
- case kEventRawKeyUp:
- event.xany.type = KeyRelease;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- break;
- case kEventRawKeyRepeat:
- event.xany.type = KeyRelease;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- event.xany.type = KeyPress;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- break;
- default:
- TkMacOSXDbgMsg("Invalid parameter eKind %ld", eKind);
- return -1;
+ case kEventRawKeyDown:
+ event.xany.type = KeyPress;
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ break;
+ case kEventRawKeyUp:
+ event.xany.type = KeyRelease;
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ break;
+ case kEventRawKeyRepeat:
+ event.xany.type = KeyRelease;
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ event.xany.type = KeyPress;
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ break;
+ default:
+ TkMacOSXDbgMsg("Invalid parameter eKind %ld", eKind);
+ return -1;
}
}
}
@@ -394,12 +388,12 @@ GenerateKeyEvent(
*
* InitKeyData --
*
- * This routine initializes a KeyEventData structure by asking the OS
- * and Tk for all the global information needed here.
+ * This routine initializes a KeyEventData structure by asking the OS and
+ * Tk for all the global information needed here.
*
* Results:
- * True if the current front window can be found in Tk data structures
- * - false otherwise.
+ * True if the current front window can be found in Tk data structures,
+ * false otherwise.
*
* Side Effects:
* None
@@ -417,10 +411,10 @@ InitKeyData(
if (keyEventDataPtr->whichWindow == NULL) {
return false;
}
+
XQueryPointer(NULL, None, NULL, NULL, &keyEventDataPtr->global_x,
&keyEventDataPtr->global_y, &keyEventDataPtr->local_x,
&keyEventDataPtr->local_y, &keyEventDataPtr->state);
-
return true;
}
@@ -442,26 +436,26 @@ InitKeyData(
*/
/*
- * We have a general problem here. How do we handle 'Option-char'
- * keypresses? The problem is that we might want to bind to some of these
- * (e.g. Cmd-Opt-d is 'uncomment' in Alpha). OTOH Option-d actually produces
- * a real character on MacOS, namely a mathematical delta.
+ * We have a general problem here. How do we handle 'Option-char' keypresses?
+ * The problem is that we might want to bind to some of these (e.g. Cmd-Opt-d
+ * is 'uncomment' in Alpha). OTOH Option-d actually produces a real character
+ * on MacOS, namely a mathematical delta.
*
* The current behaviour is that a binding goes by the combinations of
- * modifiers and base keysym, that is Option-d. The string value of the
- * event is the mathematical delta character, so if no binding calls
- * [break], the text widget will insert that character.
+ * modifiers and base keysym, that is Option-d. The string value of the event
+ * is the mathematical delta character, so if no binding calls [break], the
+ * text widget will insert that character.
*
* Note that this is similar to control combinations on all platforms. They
* also generate events that have the base character as keysym and a real
- * control character as character value. So Ctrl+C gets us the keysym XK_C,
- * the modifier Control (so you can bind <Control-C>) and a string value as
+ * control character as character value. So Ctrl+C gets us the keysym XK_C, the
+ * modifier Control (so you can bind <Control-C>) and a string value as
* "\u0003".
*
* For a different solutions we may want for the event to contain keysyms for
- * *both* the 'Opt-d' side of things and the mathematical delta. Then a
- * binding on Opt-d will trigger, but a binding on mathematical delta would
- * also trigger. This would require changes in the core, though.
+ * *both* the 'Opt-d' side of things and the mathematical delta. Then a binding
+ * on Opt-d will trigger, but a binding on mathematical delta would also
+ * trigger. This would require changes in the core, though.
*/
static int
@@ -476,9 +470,8 @@ InitKeyEvent(
TkDisplay *dispPtr;
/*
- * The focus must be in the FrontWindow on the Macintosh.
- * We then query Tk to determine the exact Tk window
- * that owns the focus.
+ * The focus must be in the FrontWindow on the Macintosh. We then query Tk
+ * to determine the exact Tk window that owns the focus.
*/
window = TkMacOSXGetXWindow(e->whichWindow);
@@ -507,7 +500,7 @@ InitKeyEvent(
eventPtr->xkey.window = Tk_WindowId(tkwin);
eventPtr->xkey.display = Tk_Display(tkwin);
eventPtr->xkey.root = XRootWindow(Tk_Display(tkwin), 0);
- eventPtr->xkey.state = e->state;
+ eventPtr->xkey.state = e->state;
eventPtr->xkey.trans_chars[0] = 0;
Tk_TopCoordsToWindow(tkwin, e->local_x, e->local_y, &eventPtr->xkey.x,
@@ -515,7 +508,6 @@ InitKeyEvent(
eventPtr->xkey.keycode = e->ch | ((savedKeyCode & charCodeMask) << 8) |
((e->message&keyCodeMask) << 8);
-
return 1;
}
@@ -530,10 +522,10 @@ InitKeyEvent(
* Keyboard Layout Services, where available.
*
* Results:
- * 1 if there is returned a Unicode 'uchr' resource in *resourcePtr, 0
- * if it is a classic 'KCHR' resource. A pointer to the actual resource
- * data goes into *resourcePtr. If the resource is a 'KCHR' resource,
- * the corresponding Mac encoding goes into *encodingPtr.
+ * 1 if there is returned a Unicode 'uchr' resource in *resourcePtr, 0 if
+ * it is a classic 'KCHR' resource. A pointer to the actual resource data
+ * goes into *resourcePtr. If the resource is a 'KCHR' resource, the
+ * corresponding Mac encoding goes into *encodingPtr.
*
* Side effects:
* Sets some internal static variables.
@@ -565,7 +557,6 @@ GetKeyboardLayout(
KLGetCurrentKeyboardLayout(&currentLayout);
if (currentLayout != NULL) {
-
/*
* The layout pointer could in theory be the same for different
* layouts, only the id gives us the information that the
@@ -574,15 +565,13 @@ GetKeyboardLayout(
*/
KLGetKeyboardLayoutProperty(currentLayout, kKLIdentifier,
- (const void**)&currentLayoutId);
+ (const void **) &currentLayoutId);
if ((lastLayout != currentLayout)
|| (lastLayoutId != currentLayoutId)) {
-
#ifdef TK_MAC_DEBUG_KEYBOARD
TkMacOSXDbgMsg("Use KLS");
#endif
-
hasLayoutChanged = true;
/*
@@ -595,13 +584,11 @@ GetKeyboardLayout(
KCHR = NULL;
if ((KLGetKeyboardLayoutProperty(currentLayout,
- kKLuchrData, (const void**)&uchr)
- == noErr)
+ kKLuchrData, (const void **) &uchr) == noErr)
&& (uchr != NULL)) {
/* done */
} else if ((KLGetKeyboardLayoutProperty(currentLayout,
- kKLKCHRData, (const void**)&KCHR)
- == noErr)
+ kKLKCHRData, (const void**)&KCHR) == noErr)
&& (KCHR != NULL)) {
/* done */
}
@@ -627,9 +614,8 @@ GetKeyboardLayout(
* lastEncoding.
*
* If we didn't get a new 'KCHR' and if we have no 'uchr' either, get
- * some 'KCHR' from the OS cache and leave lastEncoding at its
- * current value. This should better not happen, it doesn't really
- * work.
+ * some 'KCHR' from the OS cache and leave lastEncoding at its current
+ * value. This should better not happen, it doesn't really work.
*/
if (KCHR) {
@@ -640,18 +626,17 @@ GetKeyboardLayout(
lastEncoding & ~0xFFFFL);
#endif
} else if (!uchr) {
- KCHR = (Ptr)(intptr_t)GetScriptManagerVariable(smKCHRCache);
+ KCHR = (Ptr)(intptr_t) GetScriptManagerVariable(smKCHRCache);
}
}
if (uchr) {
*resourcePtr = uchr;
return 1;
- } else {
- *resourcePtr = KCHR;
- *encodingPtr = lastEncoding;
- return 0;
}
+ *resourcePtr = KCHR;
+ *encodingPtr = lastEncoding;
+ return 0;
}
/*
@@ -698,13 +683,13 @@ GetKCHREncoding(
}
/*
- * GetTextEncodingFromScriptInfo() doesn't know about more exotic
- * layouts. This provides a fallback for good measure. In an ideal
- * world, exotic layouts would always provide a 'uchr' resource anyway,
- * so we wouldn't need this.
+ * GetTextEncodingFromScriptInfo() doesn't know about more exotic layouts.
+ * This provides a fallback for good measure. In an ideal world, exotic
+ * layouts would always provide a 'uchr' resource anyway, so we wouldn't
+ * need this.
*
- * We can add more keyboard layouts, if we get actual complaints. Farsi
- * or other Celtic/Gaelic layouts would be candidates.
+ * We can add more keyboard layouts, if we get actual complaints. Farsi or
+ * other Celtic/Gaelic layouts would be candidates.
*/
switch (layoutid) {
@@ -713,8 +698,8 @@ GetKCHREncoding(
* Iceland for legacy applications.
*/
- case 1800: case 1821:
- return kTextEncodingMacIcelandic;
+ case 1800: case 1821:
+ return kTextEncodingMacIcelandic;
/*
* Irish and Welsh. These layouts are mentioned in <Script.h>.
@@ -723,13 +708,13 @@ GetKCHREncoding(
* can't locate layouts of this type for testing.
*/
- case 581: case 779:
- return kTextEncodingMacCeltic;
+ case 581: case 779:
+ return kTextEncodingMacCeltic;
}
/*
- * The valid script codes are also the valid default encoding codes, so
- * if nothing else helps, fall back on those.
+ * The valid script codes are also the valid default encoding codes, so if
+ * nothing else helps, fall back on those.
*/
return script;
@@ -741,19 +726,18 @@ GetKCHREncoding(
* KeycodeToUnicodeViaUnicodeResource --
*
* Given MacOS key event data this function generates the Unicode
- * characters. It does this using a 'uchr' and the UCKeyTranslate
- * API.
+ * characters. It does this using a 'uchr' and the UCKeyTranslate API.
*
- * The parameter deadKeyStatePtr can be NULL, if no deadkey handling
- * is needed.
+ * The parameter deadKeyStatePtr can be NULL, if no deadkey handling is
+ * needed.
*
- * Tested and known to work with US, Hebrew, Greek and Russian layouts
- * as well as "Unicode Hex Input".
+ * Tested and known to work with US, Hebrew, Greek and Russian layouts as
+ * well as "Unicode Hex Input".
*
* Results:
* The number of characters generated if any, 0 if we are waiting for
- * another byte of a dead-key sequence. Fills in the uniChars array
- * with a Unicode string.
+ * another byte of a dead-key sequence. Fills in the uniChars array with a
+ * Unicode string.
*
* Side Effects:
* None
@@ -789,18 +773,18 @@ KeycodeToUnicodeViaUnicodeResource(
}
switch(eKind) {
- case kEventRawKeyDown:
- action = kUCKeyActionDown;
- break;
- case kEventRawKeyUp:
- action = kUCKeyActionUp;
- break;
- case kEventRawKeyRepeat:
- action = kUCKeyActionAutoKey;
- break;
- default:
- TkMacOSXDbgMsg("Invalid parameter eKind %d", eKind);
- return 0;
+ case kEventRawKeyDown:
+ action = kUCKeyActionDown;
+ break;
+ case kEventRawKeyUp:
+ action = kUCKeyActionUp;
+ break;
+ case kEventRawKeyRepeat:
+ action = kUCKeyActionAutoKey;
+ break;
+ default:
+ TkMacOSXDbgMsg("Invalid parameter eKind %d", eKind);
+ return 0;
}
err = ChkErr(UCKeyTranslate, (const UCKeyboardLayout *) uchr, keycode,
@@ -816,7 +800,7 @@ KeycodeToUnicodeViaUnicodeResource(
}
/*
- * some IMEs leave residue :-(
+ * Some IMEs leave residue. :-(
*/
*deadKeyStatePtr = 0;
@@ -836,13 +820,13 @@ KeycodeToUnicodeViaUnicodeResource(
* Given MacOS key event data this function generates the Unicode
* characters. It does this using a 'KCHR' and the KeyTranslate API.
*
- * The parameter deadKeyStatePtr can be NULL, if no deadkey handling
- * is needed.
+ * The parameter deadKeyStatePtr can be NULL, if no deadkey handling is
+ * needed.
*
* Results:
* The number of characters generated if any, 0 if we are waiting for
- * another byte of a dead-key sequence. Fills in the uniChars array
- * with a Unicode string.
+ * another byte of a dead-key sequence. Fills in the uniChars array with a
+ * Unicode string.
*
* Side Effects:
* None
@@ -864,8 +848,9 @@ KeycodeToUnicodeViaKCHRResource(
UInt32 result;
char macBuff[3];
char *macStr;
- int macStrLen;
+ int macStrLen, uniStrLen;
UInt32 dummy_state = 0;
+ CFStringRef cfString;
if (NULL == deadKeyStatePtr) {
deadKeyStatePtr = &dummy_state;
@@ -877,9 +862,9 @@ KeycodeToUnicodeViaKCHRResource(
if ((0 == result) && (0 != dummy_state)) {
/*
* 'dummy_state' gets only filled if the caller did not want deadkey
- * processing (deadKeyStatePtr was NULL originally), but we still
- * have a deadkey. We just push the keycode for the space bar to get
- * the real key value.
+ * processing (deadKeyStatePtr was NULL originally), but we still have
+ * a deadkey. We just push the keycode for the space bar to get the
+ * real key value.
*/
result = KeyTranslate(kchr, 0x31, deadKeyStatePtr);
@@ -895,26 +880,26 @@ KeycodeToUnicodeViaKCHRResource(
}
macBuff[0] = (char) (result >> 16);
- macBuff[1] = (char) result;
+ macBuff[1] = (char) result;
macBuff[2] = 0;
if (0 != macBuff[0]) {
/*
- * If the first byte is valid, the second is too
+ * If the first byte is valid, the second is too.
*/
macStr = macBuff;
macStrLen = 2;
} else if (0 != macBuff[1]) {
/*
- * Only the second is valid
+ * Only the second is valid.
*/
macStr = macBuff+1;
macStrLen = 1;
} else {
/*
- * No valid bytes at all -- shouldn't happen
+ * No valid bytes at all -- shouldn't happen.
*/
macStr = NULL;
@@ -923,42 +908,37 @@ KeycodeToUnicodeViaKCHRResource(
if (macStrLen <= 0) {
return 0;
- } else {
-
- /*
- * Use the CFString conversion routines. This is the easiest and
- * most compatible way to get from an 8-bit string and a MacOS script
- * code to a Unicode string.
- *
- * FIXME: The system ships with an Irish 'KCHR' but without the
- * corresponding macCeltic encoding, which triggers the error below.
- * Tcl doesn't have the macCeltic encoding either right now, so until
- * we get that, we can just as well stick to this code. The right
- * fix would be to use the Tcl encodings and add macCeltic and
- * probably others there. Suitable Unicode data files for the
- * missing encodings are available from www.evertype.com.
- */
-
- CFStringRef cfString;
- int uniStrLen;
+ }
- cfString = CFStringCreateWithCStringNoCopy(NULL, macStr, encoding,
- kCFAllocatorNull);
- if (cfString == NULL) {
- TkMacOSXDbgMsg("CFString: Can't convert with encoding %ld",
- encoding);
- return 0;
- }
+ /*
+ * Use the CFString conversion routines. This is the easiest and most
+ * compatible way to get from an 8-bit string and a MacOS script code to a
+ * Unicode string.
+ *
+ * FIXME: The system ships with an Irish 'KCHR' but without the
+ * corresponding macCeltic encoding, which triggers the error below. Tcl
+ * doesn't have the macCeltic encoding either right now, so until we get
+ * that, we can just as well stick to this code. The right fix would be to
+ * use the Tcl encodings and add macCeltic and probably others
+ * there. Suitable Unicode data files for the missing encodings are
+ * available from www.evertype.com.
+ */
- uniStrLen = CFStringGetLength(cfString);
- if (uniStrLen > maxChars) {
- uniStrLen = maxChars;
- }
- CFStringGetCharacters(cfString, CFRangeMake(0,uniStrLen), uniChars);
- CFRelease(cfString);
+ cfString = CFStringCreateWithCStringNoCopy(NULL, macStr, encoding,
+ kCFAllocatorNull);
+ if (cfString == NULL) {
+ TkMacOSXDbgMsg("CFString: Can't convert with encoding %ld", encoding);
+ return 0;
+ }
- return uniStrLen;
+ uniStrLen = CFStringGetLength(cfString);
+ if (uniStrLen > maxChars) {
+ uniStrLen = maxChars;
}
+ CFStringGetCharacters(cfString, CFRangeMake(0,uniStrLen), uniChars);
+ CFRelease(cfString);
+
+ return uniStrLen;
}
/*
@@ -969,16 +949,15 @@ KeycodeToUnicodeViaKCHRResource(
* Given MacOS key event data this function generates the Unicode
* characters. It does this using OS resources and APIs.
*
- * The parameter deadKeyStatePtr can be NULL, if no deadkey handling
- * is needed.
+ * The parameter deadKeyStatePtr can be NULL, if no deadkey handling is
+ * needed.
*
- * This function is called from XKeycodeToKeysym() in
- * tkMacOSKeyboard.c.
+ * This function is called from XKeycodeToKeysym() in tkMacOSKeyboard.c.
*
* Results:
* The number of characters generated if any, 0 if we are waiting for
- * another byte of a dead-key sequence. Fills in the uniChars array
- * with a Unicode string.
+ * another byte of a dead-key sequence. Fills in the uniChars array with a
+ * Unicode string.
*
* Side Effects:
* None
@@ -997,20 +976,14 @@ TkMacOSXKeycodeToUnicode(
{
Ptr resource = NULL;
TextEncoding encoding;
- int len;
-
- if (GetKeyboardLayout(&resource,&encoding)) {
- len = KeycodeToUnicodeViaUnicodeResource(
- uniChars, maxChars, resource, eKind,
- keycode, modifiers, deadKeyStatePtr);
+ if (GetKeyboardLayout(&resource, &encoding)) {
+ return KeycodeToUnicodeViaUnicodeResource(uniChars, maxChars,
+ resource, eKind, keycode, modifiers, deadKeyStatePtr);
} else {
- len = KeycodeToUnicodeViaKCHRResource(
- uniChars, maxChars, resource, encoding, eKind,
- keycode, modifiers, deadKeyStatePtr);
+ return KeycodeToUnicodeViaKCHRResource(uniChars, maxChars, resource,
+ encoding, eKind, keycode, modifiers, deadKeyStatePtr);
}
-
- return len;
}
/*
@@ -1039,6 +1012,7 @@ XGrabKeyboard(
Time time)
{
keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window);
+
return GrabSuccess;
}
@@ -1090,10 +1064,9 @@ TkMacOSXGetCapture(void)
*
* TkpSetCapture --
*
- * This function captures the mouse so that all future events
- * will be reported to this window, even if the mouse is outside
- * the window. If the specified window is NULL, then the mouse
- * is released.
+ * This function captures the mouse so that all future events will be
+ * reported to this window, even if the mouse is outside the window. If
+ * the specified window is NULL, then the mouse is released.
*
* Results:
* None.
@@ -1120,9 +1093,10 @@ TkpSetCapture(
w = winPtr;
m = kWindowModalityAppModal;
} else if (grabWinPtr) {
- w = (TkWindow*)grabWinPtr;
+ w = (TkWindow *) grabWinPtr;
m = kWindowModalityNone;
}
+
if (w && w->window != None && TkMacOSXHostToplevelExists(w)) {
ChkErr(SetWindowModality, TkMacOSXDrawableWindow(w->window), m,
NULL);
@@ -1137,9 +1111,9 @@ TkpSetCapture(
*
* Tk_SetCaretPos --
*
- * This enables correct placement of the XIM caret. This is called
- * by widgets to indicate their cursor placement, and the caret
- * location is used by TkpGetString to place the XIM caret.
+ * This enables correct placement of the XIM caret. This is called by
+ * widgets to indicate their cursor placement, and the caret location is
+ * used by TkpGetString to place the XIM caret.
*
* Results:
* None
@@ -1184,3 +1158,12 @@ TkMacOSXInitKeyboard(
GetKeyboardLayout(&resource, &encoding);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index a9d554f..f656b92 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.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: tkMacOSXKeyboard.c,v 1.23 2007/12/13 15:27:10 dgp Exp $
+ * RCS: @(#) $Id: tkMacOSXKeyboard.c,v 1.24 2008/10/27 11:55:44 dkf Exp $
*/
#include "tkMacOSXInt.h"
@@ -164,10 +164,10 @@ InitKeyMaps(void)
*
* InitLatin1Table --
*
- * Creates a simple table to be used for mapping from keysyms to
- * keycodes. Always needs to be called before using latin1Table,
- * because the keyboard layout may have changed, and than the table must
- * be re-computed.
+ * Creates a simple table to be used for mapping from keysyms to keycodes.
+ * Always needs to be called before using latin1Table, because the
+ * keyboard layout may have changed, and than the table must be
+ * re-computed.
*
* Results:
* None.
@@ -204,16 +204,15 @@ InitLatin1Table(
/*
* In the common X11 implementations, a keymap has four columns
- * "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We
- * don't use "Mode_switch", but we use "Option" instead. (This is
- * similar to Apple's X11 implementation, where "Mode_switch" is used
- * as an alias for "Option".)
+ * "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We don't
+ * use "Mode_switch", but we use "Option" instead. (This is similar to
+ * Apple's X11 implementation, where "Mode_switch" is used as an alias
+ * for "Option".)
*
* So here we go through all 4 columns of the keymap and find all
- * Latin-1 compatible keycodes. We go through the columns
- * back-to-front from the more exotic columns to the more simple, so
- * that simple keycode-modifier combinations are preferred in the
- * resulting table.
+ * Latin-1 compatible keycodes. We go through the columns back-to-front
+ * from the more exotic columns to the more simple, so that simple
+ * keycode-modifier combinations are preferred in the resulting table.
*/
for (state = 3; state >= 0; state--) {
@@ -269,10 +268,10 @@ XKeycodeToKeysym(
}
/*
- * When determining what keysym to produce we first check to see if the
- * key is a function key. We then check to see if the character is
- * another non-printing key. Finally, we return the key syms for all
- * ASCII and Latin-1 chars.
+ * When determining what keysym to produce we first check to see if the key
+ * is a function key. We then check to see if the character is another
+ * non-printing key. Finally, we return the key syms for all ASCII and
+ * Latin-1 chars.
*/
newKeycode = keycode >> 16;
@@ -300,13 +299,12 @@ XKeycodeToKeysym(
}
newChar = 0;
- TkMacOSXKeycodeToUnicode(
- &newChar, 1, kEventRawKeyDown,
- newKeycode & 0x00FF, newKeycode & 0xFF00, NULL);
+ TkMacOSXKeycodeToUnicode(&newChar, 1, kEventRawKeyDown,
+ newKeycode & 0x00FF, newKeycode & 0xFF00, NULL);
/*
- * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up
- * for other characters for now.
+ * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up for
+ * other characters for now.
*/
if ((newChar >= XK_space) && (newChar <= LATIN1_MAX)) {
@@ -363,15 +361,15 @@ TkpGetString(
XModifierKeymap *
XGetModifierMapping(
- Display* display)
+ Display *display)
{
- XModifierKeymap * modmap;
+ XModifierKeymap *modmap;
(void) display; /*unused*/
/*
- * MacOSX doesn't use the key codes for the modifiers for anything, and
- * we don't generate them either. So there is no modifier map.
+ * MacOSX doesn't use the key codes for the modifiers for anything, and we
+ * don't generate them either. So there is no modifier map.
*/
modmap = (XModifierKeymap *) ckalloc(sizeof(XModifierKeymap));
@@ -412,9 +410,9 @@ XFreeModifiermap(
* XKeysymToString, XStringToKeysym --
*
* These X window functions map keysyms to strings & strings to keysyms.
- * However, Tk already does this for the most common keysyms.
- * Therefore, these functions only need to support keysyms that will be
- * specific to the Macintosh. Currently, there are none.
+ * However, Tk already does this for the most common keysyms. Therefore,
+ * these functions only need to support keysyms that will be specific to
+ * the Macintosh. Currently, there are none.
*
* Results:
* None.
@@ -444,8 +442,8 @@ XStringToKeysym(
*
* XKeysymToMacKeycode --
*
- * An internal function like XKeysymToKeycode but only generating the
- * Mac specific keycode plus the modifiers Shift and Option.
+ * An internal function like XKeysymToKeycode but only generating the Mac
+ * specific keycode plus the modifiers Shift and Option.
*
* Results:
* A Mac keycode with the actual keycode in the low byte and Mac-style
@@ -462,8 +460,9 @@ XKeysymToMacKeycode(
Display *display,
KeySym keysym)
{
- if (keysym <= LATIN1_MAX) {
+ KeyInfo *kPtr;
+ if (keysym <= LATIN1_MAX) {
/*
* Handle keysyms in the Latin-1 range where keysym and Unicode
* character code point are the same.
@@ -471,36 +470,31 @@ XKeysymToMacKeycode(
InitLatin1Table(display);
return latin1Table[keysym];
+ }
- } else {
-
- /*
- * Handle special keys from our exception tables. Don't mind if this
- * is slow, neither the test suite nor [event generate] need to be
- * optimized (we hope).
- */
-
- KeyInfo *kPtr;
+ /*
+ * Handle special keys from our exception tables. Don't mind if this is
+ * slow, neither the test suite nor [event generate] need to be optimized
+ * (we hope).
+ */
- for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
- if (kPtr->keysym == keysym) {
- return kPtr->keycode;
- }
+ for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
+ if (kPtr->keysym == keysym) {
+ return kPtr->keycode;
}
- for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
- if (kPtr->keysym == keysym) {
- return kPtr->keycode;
- }
+ }
+ for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
+ if (kPtr->keysym == keysym) {
+ return kPtr->keycode;
}
+ }
- /*
- * For other keysyms (not Latin-1 and not special keys), we'd need a
- * generic keysym-to-unicode table. We don't have that, so we give
- * up here.
- */
+ /*
+ * For other keysyms (not Latin-1 and not special keys), we'd need a
+ * generic keysym-to-unicode table. We don't have that, so we give up here.
+ */
- return 0;
- }
+ return 0;
}
/*
@@ -508,9 +502,9 @@ XKeysymToMacKeycode(
*
* XKeysymToKeycode --
*
- * The function XKeysymToKeycode takes an X11 keysym and converts it
- * into a Mac keycode. It is in the stubs table for compatibility but
- * not used anywhere in the core.
+ * The function XKeysymToKeycode takes an X11 keysym and converts it into
+ * a Mac keycode. It is in the stubs table for compatibility but not used
+ * anywhere in the core.
*
* Results:
* A 32 bit keycode with the the mac keycode (without modifiers) in the
@@ -580,8 +574,8 @@ NB: Keep this commented code for a moment for reference.
*
* The function TkpSetKeycodeAndState takes a keysym and fills in the
* appropriate members of an XEvent. It is similar to XKeysymToKeycode,
- * but it also sets the modifier mask in the XEvent. It is used by
- * [event generate] and it is in the stubs table.
+ * but it also sets the modifier mask in the XEvent. It is used by [event
+ * generate] and it is in the stubs table.
*
* Results:
* Fills an XEvent, sets the member xkey.keycode with a keycode
@@ -626,8 +620,8 @@ TkpSetKeycodeAndState(
}
if (keysym <= LATIN1_MAX) {
- int done;
- done = Tcl_UniCharToUtf(keysym,eventPtr->xkey.trans_chars);
+ int done = Tcl_UniCharToUtf(keysym, eventPtr->xkey.trans_chars);
+
eventPtr->xkey.trans_chars[done] = 0;
} else {
eventPtr->xkey.trans_chars[0] = 0;
@@ -677,6 +671,7 @@ TkpGetKeySym(
if (eventPtr->xany.send_event == -1) {
int modifier = eventPtr->xkey.keycode;
+
if (modifier == cmdKey) {
return XK_Meta_L;
} else if (modifier == shiftKey) {
@@ -698,7 +693,6 @@ TkpGetKeySym(
} else if (modifier == rightControlKey) {
return XK_Control_R;
} else {
-
/*
* If we get here, we probably need to implement something new.
*/
@@ -708,10 +702,10 @@ TkpGetKeySym(
}
/*
- * Figure out which of the four slots in the keymap vector to use for
- * this key. Refer to Xlib documentation for more info on how this
- * computation works. (Note: We use "Option" in keymap columns 2 and 3
- * where other implementations have "Mode_switch".)
+ * Figure out which of the four slots in the keymap vector to use for this
+ * key. Refer to Xlib documentation for more info on how this computation
+ * works. (Note: We use "Option" in keymap columns 2 and 3 where other
+ * implementations have "Mode_switch".)
*/
index = 0;
@@ -729,7 +723,7 @@ TkpGetKeySym(
if ((eventPtr->xkey.state & ShiftMask)
|| (/* (dispPtr->lockUsage != LU_IGNORE)
- && */ (eventPtr->xkey.state & LockMask))) {
+ && */ (eventPtr->xkey.state & LockMask))) {
index |= 1;
}
@@ -741,17 +735,16 @@ TkpGetKeySym(
/*
* Special handling: If the key was shifted because of Lock, but lock is
- * only caps lock, not shift lock, and the shifted keysym isn't
- * upper-case alphabetic, then switch back to the unshifted keysym.
+ * only caps lock, not shift lock, and the shifted keysym isn't upper-case
+ * alphabetic, then switch back to the unshifted keysym.
*/
if ((index & 1) && !(eventPtr->xkey.state & ShiftMask)
/*&& (dispPtr->lockUsage == LU_CAPS)*/ ) {
-
/*
- * FIXME: Keysyms are only identical to Unicode for ASCII and
- * Latin-1, so we can't use Tcl_UniCharIsUpper() for keysyms outside
- * that range. This may be a serious problem here.
+ * FIXME: Keysyms are only identical to Unicode for ASCII and Latin-1,
+ * so we can't use Tcl_UniCharIsUpper() for keysyms outside that range.
+ * This may be a serious problem here.
*/
if ((sym == NoSymbol) || (sym > LATIN1_MAX)
@@ -779,9 +772,9 @@ TkpGetKeySym(
*
* TkpInitKeymapInfo --
*
- * This procedure is invoked to scan keymap information to recompute
- * stuff that's important for binding, such as the modifier key (if any)
- * that corresponds to the "Mode_switch" keysym.
+ * This procedure is invoked to scan keymap information to recompute stuff
+ * that's important for binding, such as the modifier key (if any) that
+ * corresponds to the "Mode_switch" keysym.
*
* Results:
* None.
@@ -801,8 +794,8 @@ TkpInitKeymapInfo(
/*
* Behaviours that are variable on X11 are defined constant on MacOSX.
- * lockUsage is only used above in TkpGetKeySym(), nowhere else
- * currently. There is no offical "Mode_switch" key.
+ * lockUsage is only used above in TkpGetKeySym(), nowhere else currently.
+ * There is no offical "Mode_switch" key.
*/
dispPtr->lockUsage = LU_CAPS;
@@ -826,10 +819,10 @@ TkpInitKeymapInfo(
/*
* MacOSX doesn't use the keycodes for the modifiers for anything, and we
- * don't generate them either (the keycodes actually given in the
- * simulated modifier events are bogus). So there is no modifier map.
- * If we ever want to simulate real modifier keycodes, the list will be
- * constant in the Carbon implementation.
+ * don't generate them either (the keycodes actually given in the simulated
+ * modifier events are bogus). So there is no modifier map. If we ever want
+ * to simulate real modifier keycodes, the list will be constant in the
+ * Carbon implementation.
*/
if (dispPtr->modKeyCodes != NULL) {
@@ -838,3 +831,12 @@ TkpInitKeymapInfo(
dispPtr->numModKeyCodes = 0;
dispPtr->modKeyCodes = NULL;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 98f7273..fbaa033 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -7,10 +7,10 @@
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.45 2007/12/13 15:27:10 dgp Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.46 2008/10/27 11:55:44 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -69,15 +69,14 @@ typedef struct MenuEntryUserData {
*/
typedef struct EntryGeometry {
- int accelTextStart; /* Offset into the accel string where
- * the text starts. Everything before
- * this is modifier key descriptions.
- */
+ int accelTextStart; /* Offset into the accel string where the text
+ * starts. Everything before this is modifier
+ * key descriptions. */
int modifierWidth; /* Width of modifier symbols. */
int accelTextWidth; /* Width of the text after the modifier
* keys. */
- int nonAccelMargin; /* The width of the margin for entries
- * without accelerators. */
+ int nonAccelMargin; /* The width of the margin for entries without
+ * accelerators. */
int modifierNum; /* Number of modifiers */
Tcl_UniChar modifierUniChars[MODIFIER_NUM];
/* Modifiers in unicode */
@@ -92,22 +91,21 @@ typedef struct TopLevelMenubarList {
struct TopLevelMenubarList *nextPtr;
/* The next window in the list. */
Tk_Window tkwin; /* The toplevel window. */
- TkMenu *menuPtr; /* The menu associated with this
- * toplevel. */
+ TkMenu *menuPtr; /* The menu associated with this toplevel. */
} TopLevelMenubarList;
/*
* Platform-specific flags for menus.
*
- * MENU_APPLE_MENU 0 indicates a custom Apple menu has
- * not been installed; 1 a custom Apple
- * menu has been installed.
- * MENU_HELP_MENU 0 indicates a custom Help menu has
- * not been installed; 1 a custom Help
- * menu has been installed.
- * MENU_RECONFIGURE_PENDING 1 indicates that an idle handler has
- * been scheduled to reconfigure the
- * Macintosh MenuHandle.
+ * MENU_APPLE_MENU 0 indicates a custom Apple menu has not been
+ * installed; 1 a custom Apple menu has been
+ * installed.
+ * MENU_HELP_MENU 0 indicates a custom Help menu has not been
+ * installed; 1 a custom Help menu has been
+ * installed.
+ * MENU_RECONFIGURE_PENDING 1 indicates that an idle handler has been
+ * scheduled to reconfigure the Macintosh
+ * MenuHandle.
*/
#define MENU_APPLE_MENU MENU_PLATFORM_FLAG1
@@ -118,33 +116,32 @@ typedef struct TopLevelMenubarList {
* menus. */
#define MENUBAR_REDRAW_PENDING 1
-static int gNoTkMenus = 0; /* This is used by Tk_MacOSXTurnOffMenus as the
- * flag that Tk is not to draw any menus. */
+static int gNoTkMenus = 0; /* This is used by Tk_MacOSXTurnOffMenus as
+ * the flag that Tk is not to draw any
+ * menus. */
static Tcl_HashTable commandTable;
- /* The list of menuInstancePtrs associated with
- * menu ids */
+ /* The list of menuInstancePtrs associated
+ * with menu ids. */
static short currentAppleMenuID;
/* The id of the current Apple menu. 0 for
* none. */
static short currentHelpMenuID; /* The id of the current Help menu. 0 for
* none. */
static Tcl_Interp *currentMenuBarInterp;
- /* The interpreter of the window that owns
- * the current menubar. */
+ /* The interpreter of the window that owns the
+ * current menubar. */
static char *currentMenuBarName;
/* Malloced. Name of current menu in menu bar.
* NULL if no menu set. TO DO: make this a
* DString. */
static Tk_Window currentMenuBarOwner;
/* Which window owns the current menu bar. */
-static int inPostMenu; /* We cannot be re-entrant like X
- * windows. */
-static short lastMenuID; /* To pass to NewMenu; need to figure out
- * a good way to do this. */
-static short lastCascadeID;
- /* Cascades have to have ids that are
- * less than 256. */
+static int inPostMenu; /* We cannot be re-entrant like X windows. */
+static short lastMenuID; /* To pass to NewMenu; need to figure out a
+ * good way to do this. */
+static short lastCascadeID; /* Cascades have to have ids that are less
+ * than 256. */
static int menuBarFlags; /* Used for whether the menu bar needs
* redrawing or not. */
@@ -160,6 +157,7 @@ static TopLevelMenubarList *windowListPtr;
* Array of unicode, charcode and utf representations of the most common
* special menu symbols.
*/
+
typedef struct MenuSymbol {
const Tcl_UniChar unicode;
const char charCode;
@@ -202,97 +200,117 @@ static SInt16 menuSeparatorHeight = 0;
* Forward declarations for procedures defined later in this file:
*/
-MODULE_SCOPE int TkMacOSXGetNewMenuID(Tcl_Interp *interp, TkMenu *menuInstPtr,
- int cascade, short *menuIDPtr);
-MODULE_SCOPE void TkMacOSXFreeMenuID(short menuID);
-
-static void CompleteIdlers(TkMenu *menuPtr);
-static void DrawMenuBarWhenIdle(ClientData clientData);
-static void DrawMenuEntryAccelerator(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
- Tk_3DBorder activeBorder, int x, int y, int width, int height,
- int drawArrow);
-static void DrawMenuEntryBackground(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, Tk_3DBorder activeBorder, Tk_3DBorder bgBorder, int x,
- int y, int width, int heigth);
-static void DrawMenuEntryIndicator(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, GC indicatorGC, Tk_Font tkfont,
- const Tk_FontMetrics *fmPtr, int x, int y, int width, int height);
-static void DrawMenuEntryLabel(TkMenu * menuPtr, TkMenuEntry *mePtr,
- Drawable d, GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x,
- int y, int width, int height);
-static void DrawMenuSeparator(TkMenu *menuPtr, TkMenuEntry *mePtr, Drawable d,
- GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x, int y,
- int width, int height);
-static void DrawTearoffEntry(TkMenu *menuPtr, TkMenuEntry *mePtr, Drawable d,
- GC gc, Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int x, int y,
- int width, int height);
-static void EventuallyInvokeMenu(ClientData data);
-static void GetEntryText(TkMenuEntry *mePtr, Tcl_DString *dStringPtr);
-static void GetMenuAccelGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *modWidthPtr,
- int *textWidthPtr, int *heightPtr);
-static void GetMenuLabelGeometry(TkMenuEntry *mePtr, Tk_Font tkfont,
- const Tk_FontMetrics *fmPtr, int *widthPtr, int *heightPtr);
-static void GetMenuIndicatorGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr);
-static void GetMenuSeparatorGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr);
-static TkMenuEntry* GetParentMenuEntry(TkMenu *menuPtr);
-static void GetTearoffEntryGeometry(TkMenu *menuPtr, TkMenuEntry *mePtr,
- Tk_Font tkfont, const Tk_FontMetrics *fmPtr, int *widthPtr,
- int *heightPtr);
-static char FindMarkCharacter(TkMenuEntry *mePtr);
-static int GetUtfMarkCharacter(char markChar, const char **markUtfPtr);
-static TkMenu* MenuPtrForMenuRef(MenuRef menu);
-static int ParseAccelerators(const char **accelStringPtr, int *modifierNumPtr,
- Tcl_UniChar *modifierUniChars, int *modifierWidth);
-static void MenuSelectEvent(TkMenu *menuPtr);
-static void ReconfigureIndividualMenu(TkMenu *menuPtr, MenuHandle macMenuHdl,
- int base);
-static void ReconfigureMacintoshMenu(ClientData clientData);
-static void RecursivelyClearActiveMenu(TkMenu *menuPtr);
-static void RecursivelyDeleteMenu(TkMenu *menuPtr);
-static void RecursivelyInsertMenu(TkMenu *menuPtr);
-static void SetDefaultMenubar(void);
-static int SetMenuCascade(TkMenu *menuPtr);
+MODULE_SCOPE int TkMacOSXGetNewMenuID(Tcl_Interp *interp,
+ TkMenu *menuInstPtr, int cascade,
+ short *menuIDPtr);
+MODULE_SCOPE void TkMacOSXFreeMenuID(short menuID);
+
+static void CompleteIdlers(TkMenu *menuPtr);
+static void DrawMenuBarWhenIdle(ClientData clientData);
+static void DrawMenuEntryAccelerator(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d, GC gc,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
+ Tk_3DBorder activeBorder, int x, int y, int width,
+ int height, int drawArrow);
+static void DrawMenuEntryBackground(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d,
+ Tk_3DBorder activeBorder, Tk_3DBorder bgBorder,
+ int x, int y, int width, int heigth);
+static void DrawMenuEntryIndicator(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Drawable d, GC gc,
+ GC indicatorGC, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int x, int y,
+ int width, int height);
+static void DrawMenuEntryLabel(TkMenu *menuPtr,TkMenuEntry *mePtr,
+ Drawable d, GC gc, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int x, int y,
+ int width, int height);
+static void DrawMenuSeparator(TkMenu *menuPtr, TkMenuEntry *mePtr,
+ Drawable d, GC gc, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int x, int y,
+ int width, int height);
+static void DrawTearoffEntry(TkMenu *menuPtr, TkMenuEntry *mePtr,
+ Drawable d, GC gc, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int x, int y,
+ int width, int height);
+static void EventuallyInvokeMenu(ClientData data);
+static void GetEntryText(TkMenuEntry *mePtr,
+ Tcl_DString *dStringPtr);
+static void GetMenuAccelGeometry(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int *modWidthPtr,
+ int *textWidthPtr, int *heightPtr);
+static void GetMenuLabelGeometry(TkMenuEntry *mePtr,
+ Tk_Font tkfont, const Tk_FontMetrics *fmPtr,
+ int *widthPtr, int *heightPtr);
+static void GetMenuIndicatorGeometry(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int *widthPtr,
+ int *heightPtr);
+static void GetMenuSeparatorGeometry(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int *widthPtr,
+ int *heightPtr);
+static TkMenuEntry * GetParentMenuEntry(TkMenu *menuPtr);
+static void GetTearoffEntryGeometry(TkMenu *menuPtr,
+ TkMenuEntry *mePtr, Tk_Font tkfont,
+ const Tk_FontMetrics *fmPtr, int *widthPtr,
+ int *heightPtr);
+static char FindMarkCharacter(TkMenuEntry *mePtr);
+static int GetUtfMarkCharacter(char markChar,
+ const char **markUtfPtr);
+static TkMenu * MenuPtrForMenuRef(MenuRef menu);
+static int ParseAccelerators(const char **accelStringPtr,
+ int *modifierNumPtr,
+ Tcl_UniChar *modifierUniChars,
+ int *modifierWidth);
+static void MenuSelectEvent(TkMenu *menuPtr);
+static void ReconfigureIndividualMenu(TkMenu *menuPtr,
+ MenuHandle macMenuHdl, int base);
+static void ReconfigureMacintoshMenu(ClientData clientData);
+static void RecursivelyClearActiveMenu(TkMenu *menuPtr);
+static void RecursivelyDeleteMenu(TkMenu *menuPtr);
+static void RecursivelyInsertMenu(TkMenu *menuPtr);
+static void SetDefaultMenubar(void);
+static int SetMenuCascade(TkMenu *menuPtr);
#ifdef USE_TK_MDEF
#define SCREEN_MARGIN 5
static MacDrawable macMDEFDrawable;
/* Drawable for use by MDEF code */
-static int MDEFScrollFlag = 0; /* Used so that popups don't scroll too soon.*/
+static int MDEFScrollFlag = 0; /* Used so that popups don't scroll too
+ * soon. */
static MenuItemDrawingUPP tkThemeMenuItemDrawingUPP;
- /* Points to the UPP for theme Item drawing. */
+ /* Points to the UPP for theme Item
+ * drawing. */
static Tcl_Obj *useMDEFVar;
-static void DrawMenuBackground(TkMenu *menuPtr, Rect *menuRectPtr,
- Drawable d);
-static void MenuDefProc(short message, MenuHandle menu, Rect *menuRectPtr,
- Point hitPt, short *whichItem );
-static void HandleMenuHiliteMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuDrawMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuFindItemMsg(MenuRef menu, Rect *menuRectPtr,
- Point hitPt, SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuPopUpMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void HandleMenuCalcItemMsg(MenuRef menu, Rect *menuRectPtr, Point hitPt,
- SInt16 *whichItem, TkMenu *menuPtr);
-static void AppearanceEntryDrawWrapper(TkMenuEntry *mePtr, Rect * menuRectPtr,
- MenuTrackingData *mtdPtr, Drawable d, Tk_FontMetrics *fmPtr,
- Tk_Font tkfont, int erase);
-static pascal void ThemeMenuItemDrawingProc(const Rect *inBounds,
- SInt16 inDepth, Boolean inIsColorDevice, SInt32 inUserData);
+static void DrawMenuBackground(TkMenu *menuPtr, Rect *menuRectPtr,
+ Drawable d);
+static void MenuDefProc(short message, MenuHandle menu,
+ Rect *menuRectPtr, Point hitPt, short *whichItem);
+static void HandleMenuHiliteMsg(MenuRef menu, Rect *menuRectPtr,
+ Point hitPt, SInt16 *whichItem, TkMenu *menuPtr);
+static void HandleMenuDrawMsg(MenuRef menu, Rect *menuRectPtr,
+ Point hitPt, SInt16 *whichItem, TkMenu *menuPtr);
+static void HandleMenuFindItemMsg(MenuRef menu, Rect *menuRectPtr,
+ Point hitPt, SInt16 *whichItem, TkMenu *menuPtr);
+static void HandleMenuPopUpMsg(MenuRef menu, Rect *menuRectPtr,
+ Point hitPt, SInt16 *whichItem, TkMenu *menuPtr);
+static void HandleMenuCalcItemMsg(MenuRef menu, Rect *menuRectPtr,
+ Point hitPt, SInt16 *whichItem, TkMenu *menuPtr);
+static void AppearanceEntryDrawWrapper(TkMenuEntry *mePtr,
+ Rect *menuRectPtr, MenuTrackingData *mtdPtr,
+ Drawable d, Tk_FontMetrics *fmPtr, Tk_Font tkfont,
+ int erase);
+static pascal void ThemeMenuItemDrawingProc(const Rect *inBounds,
+ SInt16 inDepth, Boolean inIsColorDevice,
+ SInt32 inUserData);
#else /* USE_TK_MDEF */
# define useMDEF 0
#endif /* USE_TK_MDEF */
#define IS_THEME_MENU_FONT(tkfont) (strcmp(Tk_NameOfFont(tkfont), "menu") == 0)
-
/*
*----------------------------------------------------------------------
@@ -332,6 +350,7 @@ DrawThemeText(
* first determine the baseline of the text and then adjust the bounds
* rect so the baseline aligns with the overall baseline of the menu item.
*/
+
if (font == kThemeMenuItemCmdKeyFont) {
Point size;
SInt16 cmdKeyBaseline;
@@ -374,7 +393,7 @@ MeasureThemeText(
Point pt;
ChkErr(GetThemeTextDimensions, string, font, kThemeStateActive, false, &pt,
- NULL);
+ NULL);
return pt.h;
}
@@ -388,12 +407,11 @@ MeasureThemeText(
* level. See TkMacOSXGetNewMenuID for more information.
*
* Results:
- * Returns TCL_OK if the id was not in use. Returns TCL_ERROR if the
- * id was in use.
+ * Returns TCL_OK if the id was not in use. Returns TCL_ERROR if the id
+ * was in use.
*
* Side effects:
- * A hash table entry in the command table is created with a NULL
- * value.
+ * A hash table entry in the command table is created with a NULL value.
*
*----------------------------------------------------------------------
*/
@@ -421,27 +439,27 @@ TkMacOSXUseMenuID(
*
* TkMacOSXGetNewMenuID --
*
- * Allocates a new menu id and marks it in use. Each menu on the
- * mac must be designated by a unique id, which is a short. In
- * addition, some ids are reserved by the system. Since Tk uses
- * mostly dynamic menus, we must allocate and free these ids on
- * the fly. We use the id as a key into a hash table; if there
- * is no hash entry, we know that we can use the id.
+ * Allocates a new menu id and marks it in use. Each menu on the mac must
+ * be designated by a unique id, which is a short. In addition, some ids
+ * are reserved by the system. Since Tk uses mostly dynamic menus, we
+ * must allocate and free these ids on the fly. We use the id as a key
+ * into a hash table; if there is no hash entry, we know that we can use
+ * the id.
*
- * Carbon allows a much larger number of menus than the old APIs.
- * I believe this is 32768, but am not sure. This code just uses
- * 2000 as the upper limit. Unfortunately tk leaks menus when
- * cloning, under some circumstances (see bug on sourceforge).
+ * Carbon allows a much larger number of menus than the old APIs. I
+ * believe this is 32768, but am not sure. This code just uses 2000 as
+ * the upper limit. Unfortunately tk leaks menus when cloning, under some
+ * circumstances (see bug on sourceforge).
*
* Results:
- * Returns TCL_OK if succesful; TCL_ERROR if there are no more
- * ids of the appropriate type to allocate. menuIDPtr contains
- * the new id if succesful.
+ * Returns TCL_OK if succesful; TCL_ERROR if there are no more ids of the
+ * appropriate type to allocate. menuIDPtr contains the new id if
+ * succesful.
*
* Side effects:
- * An entry is created for the menu in the command hash table,
- * and the hash entry is stored in the appropriate field in the
- * menu data structure.
+ * An entry is created for the menu in the command hash table, and the
+ * hash entry is stored in the appropriate field in the menu data
+ * structure.
*
*----------------------------------------------------------------------
*/
@@ -460,9 +478,9 @@ int
short returnID = *menuIDPtr;
/*
- * The following code relies on shorts and unsigned chars wrapping
- * when the highest value is incremented. Also, the values between
- * 236 and 255 inclusive are reserved for DA's by the Mac OS.
+ * The following code relies on shorts and unsigned chars wrapping when
+ * the highest value is incremented. Also, the values between 236 and 255
+ * inclusive are reserved for DA's by the Mac OS.
*/
if (!cascade) {
@@ -488,8 +506,8 @@ int
}
} else {
/*
- * Cascade ids must be between 0 and 235 only, so they must be
- * dealt with separately.
+ * Cascade ids must be between 0 and 235 only, so they must be dealt
+ * with separately.
*/
short curID = lastCascadeID + 1;
@@ -563,8 +581,8 @@ TkMacOSXFreeMenuID(
*
* MenuPtrForMenuRef --
*
- * Returns a pointer to the TkMenu corresponding to a given
- * Carbon MenuRef.
+ * Returns a pointer to the TkMenu corresponding to a given Carbon
+ * MenuRef.
*
* Results:
* Returns a pointer to a TkMenu or NULL.
@@ -575,17 +593,17 @@ TkMacOSXFreeMenuID(
*----------------------------------------------------------------------
*/
-TkMenu*
+TkMenu *
MenuPtrForMenuRef(
MenuRef menu)
{
TkMenu *menuPtr = NULL;
MenuID menuID = GetMenuID(menu);
- Tcl_HashEntry *commandEntryPtr = Tcl_FindHashEntry(&commandTable,
- (char*)(intptr_t)menuID);
+ Tcl_HashEntry *commandEntryPtr =
+ Tcl_FindHashEntry(&commandTable, (char*)(intptr_t)menuID);
if (commandEntryPtr) {
- menuPtr = (TkMenu *) Tcl_GetHashValue(commandEntryPtr);
+ menuPtr = Tcl_GetHashValue(commandEntryPtr);
}
return menuPtr;
}
@@ -637,8 +655,8 @@ GetParentMenuEntry(
* Returns a standard TCL error.
*
* Side effects:
- * Allocates a Macintosh menu handle and puts in the platformData
- * field of the menuPtr.
+ * Allocates a Macintosh menu handle and puts in the platformData field
+ * of the menuPtr.
*
*----------------------------------------------------------------------
*/
@@ -723,7 +741,7 @@ TkpNewMenu(
}
menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, menuPtr);
return TCL_OK;
}
@@ -750,7 +768,7 @@ TkpDestroyMenu(
MenuRef macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) {
- Tcl_CancelIdleCall(ReconfigureMacintoshMenu, (ClientData) menuPtr);
+ Tcl_CancelIdleCall(ReconfigureMacintoshMenu, menuPtr);
menuPtr->menuFlags &= ~MENU_RECONFIGURE_PENDING;
}
if (GetMenuID(macMenuHdl) == currentHelpMenuID) {
@@ -796,7 +814,7 @@ TkpDestroyMenu(
int
SetMenuCascade(
- TkMenu* menuPtr) /* The menu we are setting up to be a
+ TkMenu *menuPtr) /* The menu we are setting up to be a
* cascade. */
{
MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
@@ -839,7 +857,7 @@ TkpDestroyMenuEntry(
if ((menuPtr->platformData != NULL)
&& !(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) {
menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, menuPtr);
}
}
@@ -849,9 +867,9 @@ TkpDestroyMenuEntry(
* GetEntryText --
*
* Given a menu entry, gives back the text that should go in it.
- * Separators should be done by the caller, as they have to be
- * handled specially. This is primarily used to do a substitution
- * between "..." and the ellipsis character which looks nicer.
+ * Separators should be done by the caller, as they have to be handled
+ * specially. This is primarily used to do a substitution between "..."
+ * and the ellipsis character which looks nicer.
*
* Results:
* itemText points to the new text for the item.
@@ -915,9 +933,9 @@ GetEntryText(
*
* FindMarkCharacter --
*
- * Finds the Macintosh mark character based on the font of the
- * item. We calculate a good mark character based on the font
- * that this item is rendered in.
+ * Finds the Macintosh mark character based on the font of the item. We
+ * calculate a good mark character based on the font that this item is
+ * rendered in.
*
* Results:
* Mark char.
@@ -957,8 +975,8 @@ FindMarkCharacter(
*
* GetUtfMarkCharacter --
*
- * Get the utf8 string for the given mark character, taking into
- * account the special menu font char codes.
+ * Get the utf8 string for the given mark character, taking into account
+ * the special menu font char codes.
*
* Results:
* Length of returned utf8 string.
@@ -1081,29 +1099,27 @@ ParseAccelerators(
* Processes configurations for menu entries.
*
* Results:
- * Returns standard TCL result. If TCL_ERROR is returned, then
- * the interp's result contains an error message.
+ * Returns standard TCL result. If TCL_ERROR is returned, then the
+ * interp's result contains an error message.
*
* Side effects:
- * Configuration information get set for mePtr; old resources
- * get freed, if any need it.
+ * Configuration information get set for mePtr; old resources get freed,
+ * if any need it.
*
*----------------------------------------------------------------------
*/
int
TkpConfigureMenuEntry(
- TkMenuEntry *mePtr) /* Information about menu entry; may
- * or may not already have values for
- * some fields. */
+ TkMenuEntry *mePtr) /* Information about menu entry; may or may
+ * not already have values for some fields. */
{
TkMenu *menuPtr = mePtr->menuPtr;
EntryGeometry *geometryPtr = (EntryGeometry *) mePtr->platformEntryData;
/*
- * Cascade menus have to have menu IDs of less than 256. So
- * we need to change the child menu if this has been configured
- * for a cascade item.
+ * Cascade menus have to have menu IDs of less than 256. So we need to
+ * change the child menu if this has been configured for a cascade item.
*/
if (mePtr->type == CASCADE_ENTRY) {
@@ -1135,10 +1151,10 @@ TkpConfigureMenuEntry(
}
/*
- * We need to parse the accelerator string. If it has the strings
- * for Command, Control, Shift or Option, we need to flag it
- * so we can draw the symbols for it. We also need to precalcuate
- * the position of the first real character we are drawing.
+ * We need to parse the accelerator string. If it has the strings for
+ * Command, Control, Shift or Option, we need to flag it so we can draw
+ * the symbols for it. We also need to precalcuate the position of the
+ * first real character we are drawing.
*/
if (0 == mePtr->accelLength) {
@@ -1157,7 +1173,7 @@ TkpConfigureMenuEntry(
if (!(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) {
menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, menuPtr);
}
return TCL_OK;
@@ -1168,11 +1184,10 @@ TkpConfigureMenuEntry(
*
* ReconfigureIndividualMenu --
*
- * This routine redoes the guts of the menu. It works from
- * a base item and offset, so that a regular menu will
- * just have all of its items added, but the help menu will
- * have all of its items appended after the apple-defined
- * items.
+ * This routine redoes the guts of the menu. It works from a base item
+ * and offset, so that a regular menu will just have all of its items
+ * added, but the help menu will have all of its items appended after the
+ * apple-defined items.
*
* Results:
* None.
@@ -1186,14 +1201,12 @@ TkpConfigureMenuEntry(
void
ReconfigureIndividualMenu(
TkMenu *menuPtr, /* The menu we are affecting. */
- MenuHandle macMenuHdl, /* The macintosh menu we are affecting.
- * Will not necessarily be
- * menuPtr->platformData because this could
- * be the help menu. */
- int base) /* The last index that we do not want
- * touched. 0 for normal menus;
- * # of system help menu items
- * for help menus. */
+ MenuHandle macMenuHdl, /* The macintosh menu we are affecting. Will
+ * not necessarily be menuPtr->platformData
+ * because this could be the help menu. */
+ int base) /* The last index that we do not want touched.
+ * 0 for normal menus; # of system help menu
+ * items for help menus. */
{
int count;
int index;
@@ -1206,7 +1219,7 @@ ReconfigureIndividualMenu(
*/
TkMacOSXInitNamedDebugSymbol(HIToolbox, void, DebugPrintMenu,
- MenuRef menu);
+ MenuRef menu);
if (DebugPrintMenu) {
DebugPrintMenu(macMenuHdl);
}
@@ -1232,8 +1245,8 @@ ReconfigureIndividualMenu(
mePtr = menuPtr->entries[index - 1];
/*
- * We have to do separators separately because SetMenuItemText
- * does not parse meta-characters.
+ * We have to do separators separately because SetMenuItemText does
+ * not parse meta-characters.
*/
if (mePtr->type == SEPARATOR_ENTRY) {
@@ -1251,7 +1264,7 @@ ReconfigureIndividualMenu(
CFRelease(cfStr);
} else {
AppendMenuItemTextWithCFString(macMenuHdl, CFSTR ("<Error>"),
- 0, 0, NULL);
+ 0, 0, NULL);
}
Tcl_DStringFree(&itemTextDString);
@@ -1273,7 +1286,7 @@ ReconfigureIndividualMenu(
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
CheckMenuItem(macMenuHdl, base + index, (mePtr->entryFlags
- & ENTRY_SELECTED) && mePtr->indicatorOn);
+ & ENTRY_SELECTED) && mePtr->indicatorOn);
if (mePtr->indicatorOn
&& (mePtr->entryFlags & ENTRY_SELECTED)) {
SetItemMark(macMenuHdl, base + index,
@@ -1292,26 +1305,27 @@ ReconfigureIndividualMenu(
ChkErr(SetMenuItemHierarchicalID, macMenuHdl,
base + index, GetMenuID(childMenuHdl));
}
+
/*
* If we changed the highligthing of this menu, its
- * children all have to be reconfigured so that
- * their state will be reflected in the menubar.
+ * children all have to be reconfigured so that their
+ * state will be reflected in the menubar.
*/
if (!(mePtr->childMenuRefPtr->menuPtr->menuFlags
- & MENU_RECONFIGURE_PENDING)) {
+ & MENU_RECONFIGURE_PENDING)) {
mePtr->childMenuRefPtr->menuPtr->menuFlags
|= MENU_RECONFIGURE_PENDING;
Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) mePtr->childMenuRefPtr->menuPtr);
+ mePtr->childMenuRefPtr->menuPtr);
}
}
}
if ((mePtr->type != CASCADE_ENTRY) && (mePtr->accelPtr != NULL)) {
int accelLen, modifiers = 0, hasCmd = 0;
- EntryGeometry *geometryPtr =
- (EntryGeometry*)mePtr->platformEntryData;
+ EntryGeometry *geometryPtr = (EntryGeometry *)
+ mePtr->platformEntryData;
int offset = geometryPtr->accelTextStart;
char *accel = Tcl_GetStringFromObj(mePtr->accelPtr, &accelLen);
@@ -1341,6 +1355,7 @@ ReconfigureIndividualMenu(
/*
* Convert from accelerator names to Carbon menu glyphs.
*/
+
struct Glyph {
const char *name;
const size_t len;
@@ -1418,27 +1433,26 @@ ReconfigureIndividualMenu(
*
* ReconfigureMacintoshMenu --
*
- * Rebuilds the Macintosh MenuHandle items from the menu. Called
- * usually as an idle handler, but can be called synchronously
- * if the menu is about to be posted.
+ * Rebuilds the Macintosh MenuHandle items from the menu. Called usually
+ * as an idle handler, but can be called synchronously if the menu is
+ * about to be posted.
*
* Results:
* None.
*
* Side effects:
- * Configuration information get set for mePtr; old resources
- * get freed, if any need it.
+ * Configuration information get set for mePtr; old resources get freed,
+ * if any need it.
*
*----------------------------------------------------------------------
*/
void
ReconfigureMacintoshMenu(
- ClientData clientData) /* Information about menu entry; may
- * or may not already have values for
- * some fields. */
+ ClientData clientData) /* Information about menu entry; may or may
+ * not already have values for some fields. */
{
- TkMenu *menuPtr = (TkMenu *) clientData;
+ TkMenu *menuPtr = clientData;
MenuHandle macMenuHdl = ((MacMenu *) menuPtr->platformData)->menuHdl;
MenuHandle helpMenuHdl = NULL;
@@ -1452,6 +1466,7 @@ ReconfigureMacintoshMenu(
if (GetMenuID(macMenuHdl) == currentHelpMenuID) {
MenuItemIndex helpIndex;
+
HMGetHelpMenu(&helpMenuHdl,&helpIndex);
if (helpMenuHdl != NULL) {
ReconfigureIndividualMenu(menuPtr, helpMenuHdl, helpIndex - 1);
@@ -1471,8 +1486,8 @@ ReconfigureMacintoshMenu(
*
* CompleteIdlers --
*
- * Completes all idle handling so that the menus are in sync when
- * the user invokes them with the mouse.
+ * Completes all idle handling so that the menus are in sync when the
+ * user invokes them with the mouse.
*
* Results:
* None.
@@ -1490,8 +1505,8 @@ CompleteIdlers(
int i;
if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) {
- Tcl_CancelIdleCall(ReconfigureMacintoshMenu, (ClientData) menuPtr);
- ReconfigureMacintoshMenu((ClientData) menuPtr);
+ Tcl_CancelIdleCall(ReconfigureMacintoshMenu, menuPtr);
+ ReconfigureMacintoshMenu(menuPtr);
}
for (i = 0; i < menuPtr->numEntries; i++) {
@@ -1543,9 +1558,10 @@ TkpPostMenu(
inPostMenu++;
result = TkPreprocessMenu(menuPtr);
+
/*
- * The post commands could have deleted the menu, which means
- * we are dead and should go away.
+ * The post commands could have deleted the menu, which means we are
+ * dead and should go away.
*/
if (result != TCL_OK || !menuPtr->tkwin) {
@@ -1592,9 +1608,8 @@ endPostMenu:
* TkpMenuNewEntry --
*
* Adds a pointer to a new menu entry structure with the platform-
- * specific fields filled in. The Macintosh uses the
- * platformEntryData field of the TkMenuEntry record to store
- * geometry information.
+ * specific fields filled in. The Macintosh uses the platformEntryData
+ * field of the TkMenuEntry record to store geometry information.
*
* Results:
* Standard TCL error.
@@ -1610,8 +1625,8 @@ int
TkpMenuNewEntry(
TkMenuEntry *mePtr) /* The menu we are adding an entry to */
{
- EntryGeometry *geometryPtr =
- (EntryGeometry *) ckalloc(sizeof(EntryGeometry));
+ EntryGeometry *geometryPtr = (EntryGeometry *)
+ ckalloc(sizeof(EntryGeometry));
TkMenu *menuPtr = mePtr->menuPtr;
geometryPtr->accelTextStart = 0;
@@ -1623,7 +1638,7 @@ TkpMenuNewEntry(
mePtr->platformEntryData = (TkMenuPlatformEntryData) geometryPtr;
if (!(menuPtr->menuFlags & MENU_RECONFIGURE_PENDING)) {
menuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) menuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, menuPtr);
}
return TCL_OK;
}
@@ -1692,31 +1707,29 @@ DrawMenuBarWhenIdle(
if (currentAppleMenuID != 0) {
hashEntryPtr = Tcl_FindHashEntry(&commandTable,
(char*)(intptr_t)currentAppleMenuID);
- appleMenuPtr = (TkMenu *) Tcl_GetHashValue(hashEntryPtr);
+ appleMenuPtr = Tcl_GetHashValue(hashEntryPtr);
TkpDestroyMenu(appleMenuPtr);
TkpNewMenu(appleMenuPtr);
appleMenuPtr->menuFlags &= ~MENU_APPLE_MENU;
appleMenuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu, (ClientData) appleMenuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, appleMenuPtr);
}
if (currentHelpMenuID != 0) {
hashEntryPtr = Tcl_FindHashEntry(&commandTable,
(char*)(intptr_t)currentHelpMenuID);
- helpMenuPtr = (TkMenu *) Tcl_GetHashValue(hashEntryPtr);
+ helpMenuPtr = Tcl_GetHashValue(hashEntryPtr);
TkpDestroyMenu(helpMenuPtr);
TkpNewMenu(helpMenuPtr);
helpMenuPtr->menuFlags &= ~MENU_HELP_MENU;
helpMenuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) helpMenuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, helpMenuPtr);
}
/*
- * We need to find the clone of this menu that is the menubar.
- * Once we do that, for every cascade in the menu, we need to
- * insert the Mac menu in the Mac menubar. Finally, we need
- * to redraw the menubar.
+ * We need to find the clone of this menu that is the menubar. Once we do
+ * that, for every cascade in the menu, we need to insert the Mac menu in
+ * the Mac menubar. Finally, we need to redraw the menubar.
*/
menuRefPtr = NULL;
@@ -1809,16 +1822,15 @@ DrawMenuBarWhenIdle(
TkMacOSXGetNewMenuID(appleMenuPtr->interp, appleMenuPtr, 0,
&appleID);
macMenuHdl = NewMenu(appleID, "\p\024");
- appleMenuPtr->platformData =
- (TkMenuPlatformData) ckalloc(sizeof(MacMenu));
+ appleMenuPtr->platformData = (TkMenuPlatformData)
+ ckalloc(sizeof(MacMenu));
((MacMenu *)appleMenuPtr->platformData)->menuHdl
= macMenuHdl;
appleMenuPtr->menuFlags |= MENU_APPLE_MENU;
if (!(appleMenuPtr->menuFlags
& MENU_RECONFIGURE_PENDING)) {
appleMenuPtr->menuFlags |= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) appleMenuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, appleMenuPtr);
}
InsertMenu(macMenuHdl, 0);
RecursivelyInsertMenu(appleMenuPtr);
@@ -1853,8 +1865,7 @@ DrawMenuBarWhenIdle(
& MENU_RECONFIGURE_PENDING)) {
helpMenuPtr->menuFlags
|= MENU_RECONFIGURE_PENDING;
- Tcl_DoWhenIdle(ReconfigureMacintoshMenu,
- (ClientData) helpMenuPtr);
+ Tcl_DoWhenIdle(ReconfigureMacintoshMenu, helpMenuPtr);
}
macMenuHdl =
((MacMenu *) helpMenuPtr->platformData)->menuHdl;
@@ -1910,8 +1921,8 @@ DrawMenuBarWhenIdle(
void
RecursivelyInsertMenu(
- TkMenu *menuPtr) /* All of the cascade items in this menu
- * will be inserted into the mac menubar. */
+ TkMenu *menuPtr) /* All of the cascade items in this menu will
+ * be inserted into the mac menubar. */
{
int i;
TkMenu *cascadeMenuPtr;
@@ -1950,8 +1961,8 @@ RecursivelyInsertMenu(
void
RecursivelyDeleteMenu(
- TkMenu *menuPtr) /* All of the cascade items in this menu
- * will be deleted from the mac menubar. */
+ TkMenu *menuPtr) /* All of the cascade items in this menu will
+ * be deleted from the mac menubar. */
{
int i;
TkMenu *cascadeMenuPtr;
@@ -2010,8 +2021,8 @@ SetDefaultMenubar(void)
*
* TkpSetMainMenubar --
*
- * Puts the menu associated with a window into the menubar. Should
- * only be called when the window is in front.
+ * Puts the menu associated with a window into the menubar. Should only
+ * be called when the window is in front.
*
* Results:
* None.
@@ -2026,9 +2037,8 @@ void
TkpSetMainMenubar(
Tcl_Interp *interp, /* The interpreter of the application */
Tk_Window tkwin, /* The frame we are setting up */
- char *menuName) /* The name of the menu to put in front.
- * If NULL, use the default menu bar.
- */
+ char *menuName) /* The name of the menu to put in front. If
+ * NULL, use the default menu bar. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
WindowRef macWindowPtr;
@@ -2107,8 +2117,8 @@ TkpSetMainMenubar(
* None.
*
* Side effects:
- * On Windows and UNIX, associates the platform menu with the
- * platform window.
+ * On Windows and UNIX, associates the platform menu with the platform
+ * window.
*
*----------------------------------------------------------------------
*/
@@ -2155,8 +2165,8 @@ TkpSetWindowMenuBar(
*
* EventuallyInvokeMenu --
*
- * This IdleTime callback actually invokes the menu command
- * scheduled in TkMacOSXDispatchMenuEvent.
+ * This IdleTime callback actually invokes the menu command scheduled in
+ * TkMacOSXDispatchMenuEvent.
*
* Results:
* None.
@@ -2171,8 +2181,7 @@ void
EventuallyInvokeMenu (
ClientData data)
{
- struct MenuCommandHandlerData *realData =
- (struct MenuCommandHandlerData *) data;
+ struct MenuCommandHandlerData *realData = data;
int code;
code = TkInvokeMenu(realData->menuPtr->interp, realData->menuPtr,
@@ -2197,8 +2206,8 @@ EventuallyInvokeMenu (
*
* TkMacOSXDispatchMenuEvent --
*
- * Given a menu id and an item, dispatches the command associated
- * with it.
+ * Given a menu id and an item, dispatches the command associated with
+ * it.
*
* Results:
* None.
@@ -2249,21 +2258,21 @@ TkMacOSXDispatchMenuEvent(
&& (index > menuPtr->numEntries + 1)) {
/*
* We don't need to do anything here, the standard
- * Application event handler will open the built-in
- * Apple menu item for us.
+ * Application event handler will open the built-in Apple
+ * menu item for us.
*/
+
result = TCL_OK;
} else {
- struct MenuCommandHandlerData *data
- = (struct MenuCommandHandlerData *)
+ struct MenuCommandHandlerData *data =
+ (struct MenuCommandHandlerData *)
ckalloc(sizeof(struct MenuCommandHandlerData));
Tcl_Preserve(menuPtr->interp);
Tcl_Preserve(menuPtr);
data->menuPtr = menuPtr;
data->index = index - 1;
- Tcl_DoWhenIdle(EventuallyInvokeMenu,
- (ClientData) data);
+ Tcl_DoWhenIdle(EventuallyInvokeMenu, data);
/* result = TkInvokeMenu(menuPtr->interp, menuPtr, index - 1); */
}
} else {
@@ -2508,15 +2517,15 @@ DrawMenuEntryIndicator(
encoding = kTextEncodingMacKeyboardGlyphs;
}
switch (mePtr->state) {
- case ENTRY_ACTIVE:
- drawState = kThemeStatePressed;
- break;
- case ENTRY_DISABLED:
- drawState = kThemeStateInactive;
- break;
- default:
- drawState = kThemeStateActive;
- break;
+ case ENTRY_ACTIVE:
+ drawState = kThemeStatePressed;
+ break;
+ case ENTRY_DISABLED:
+ drawState = kThemeStateInactive;
+ break;
+ default:
+ drawState = kThemeStateActive;
+ break;
}
cfStr = CFStringCreateWithBytes(NULL, (UInt8*)&mark, 1,
encoding, false);
@@ -2549,15 +2558,15 @@ DrawMenuEntryIndicator(
* Nothing
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
+
void
DrawMenuBackground(
TkMenu *menuPtr,
- Rect *menuRectPtr, /* The menu rect */
+ Rect *menuRectPtr, /* The menu rect */
Drawable d) /* What we are drawing into */
{
Tk_3DBorder border;
@@ -2583,8 +2592,7 @@ DrawMenuBackground(
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
@@ -2616,15 +2624,15 @@ DrawMenuEntryAccelerator(
ThemeDrawState drawState;
switch (mePtr->state) {
- case ENTRY_ACTIVE:
- drawState = kThemeStatePressed;
- break;
- case ENTRY_DISABLED:
- drawState = kThemeStateInactive;
- break;
- default:
- drawState = kThemeStateActive;
- break;
+ case ENTRY_ACTIVE:
+ drawState = kThemeStatePressed;
+ break;
+ case ENTRY_DISABLED:
+ drawState = kThemeStateInactive;
+ break;
+ default:
+ drawState = kThemeStateActive;
+ break;
}
if ((mePtr->entryFlags & ENTRY_ACCEL_MASK) == 0) {
leftEdge -= geometryPtr->modifierWidth;
@@ -2677,8 +2685,7 @@ DrawMenuEntryAccelerator(
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
@@ -2715,8 +2722,8 @@ DrawMenuSeparator(
*
* AppearanceEntryDrawWrapper --
*
- * It routes to the Appearance Managers DrawThemeEntry, which will
- * then call us back after setting up the drawing context.
+ * It routes to the Appearance Managers DrawThemeEntry, which will then
+ * call us back after setting up the drawing context.
*
* Results:
* A menu entry is drawn
@@ -2726,6 +2733,7 @@ DrawMenuSeparator(
*
*----------------------------------------------------------------------
*/
+
void
AppearanceEntryDrawWrapper(
TkMenuEntry *mePtr,
@@ -2776,9 +2784,9 @@ AppearanceEntryDrawWrapper(
DrawMenuBackground(mePtr->menuPtr, &itemRect, d);
}
DrawThemeMenuItem(menuRectPtr, &itemRect,
- mtdPtr->virtualMenuTop, mtdPtr->virtualMenuBottom, theState,
- theType | kThemeMenuItemNoBackground, tkThemeMenuItemDrawingUPP,
- (unsigned long) &meData);
+ mtdPtr->virtualMenuTop, mtdPtr->virtualMenuBottom, theState,
+ theType | kThemeMenuItemNoBackground, tkThemeMenuItemDrawingUPP,
+ (unsigned long) &meData);
if (erase) {
EnableScreenUpdates();
}
@@ -2799,6 +2807,7 @@ AppearanceEntryDrawWrapper(
*
*----------------------------------------------------------------------
*/
+
pascal void
ThemeMenuItemDrawingProc(
const Rect *inBounds,
@@ -2820,8 +2829,8 @@ ThemeMenuItemDrawingProc(
*
* TkMacOSXHandleTearoffMenu() --
*
- * This routine sees if the MDEF has set a menu and a mouse position
- * for tearing off and makes a tearoff menu if it has.
+ * This routine sees if the MDEF has set a menu and a mouse position for
+ * tearing off and makes a tearoff menu if it has.
*
* Results:
* menuPtr->interp will have the result of the tearoff command.
@@ -2845,16 +2854,16 @@ TkMacOSXHandleTearoffMenu(void)
*
* TkpInitializeMenuBindings --
*
- * For every interp, initializes the bindings for Windows
- * menus. Does nothing on Mac or XWindows.
+ * For every interp, initializes the bindings for Windows menus. Does
+ * nothing on Mac or XWindows.
*
* Results:
* None.
*
* Side effects:
- * C-level bindings are setup for the interp which will
- * handle Alt-key sequences for menus without beeping
- * or interfering with user-defined Alt-key bindings.
+ * C-level bindings are setup for the interp which will handle Alt-key
+ * sequences for menus without beeping or interfering with user-defined
+ * Alt-key bindings.
*
*--------------------------------------------------------------
*/
@@ -2875,16 +2884,15 @@ TkpInitializeMenuBindings(
*
* TkpComputeMenubarGeometry --
*
- * This procedure is invoked to recompute the size and
- * layout of a menu that is a menubar clone.
+ * This procedure is invoked to recompute the size and layout of a menu
+ * that is a menubar clone.
*
* Results:
* None.
*
* Side effects:
- * Fields of menu entries are changed to reflect their
- * current positions, and the size of the menu window
- * itself may be changed.
+ * Fields of menu entries are changed to reflect their current positions,
+ * and the size of the menu window itself may be changed.
*
*--------------------------------------------------------------
*/
@@ -2907,8 +2915,7 @@ TkpComputeMenubarGeometry(
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
@@ -2958,12 +2965,11 @@ DrawTearoffEntry(
*
* TkMacOSXSetHelpMenuItemCount --
*
- * Has to be called after the first call to InsertMenu. Sets
- * up the global variable for the number of items in the
- * unmodified help menu.
- * NB. Nobody uses this any more, since you can get the number
- * of system help items from HMGetHelpMenu trivially.
- * But it is in the stubs table...
+ * Has to be called after the first call to InsertMenu. Sets up the
+ * global variable for the number of items in the unmodified help menu.
+ * NB. Nobody uses this any more, since you can get the number of system
+ * help items from HMGetHelpMenu trivially. But it is in the stubs
+ * table...
*
* Results:
* None.
@@ -3027,8 +3033,8 @@ TkMacOSXMenuClick(void)
*
* TkpDrawMenuEntry --
*
- * Draws the given menu entry at the given coordinates with the
- * given attributes.
+ * Draws the given menu entry at the given coordinates with the given
+ * attributes.
*
* Results:
* None.
@@ -3066,9 +3072,9 @@ TkpDrawMenuEntry(
int adjustedHeight = height - 2 * padY;
/*
- * Choose the gc for drawing the foreground part of the entry.
- * Under Appearance, we pass a null (appearanceGC) to tell
- * ourselves not to change whatever color the appearance manager has set.
+ * Choose the gc for drawing the foreground part of the entry. Under
+ * Appearance, we pass a null (appearanceGC) to tell ourselves not to
+ * change whatever color the appearance manager has set.
*/
if ((mePtr->state == ENTRY_ACTIVE) && !strictMotif) {
@@ -3119,9 +3125,9 @@ TkpDrawMenuEntry(
}
/*
- * Need to draw the entire background, including padding. On Unix,
- * for menubars, we have to draw the rest of the entry taking
- * into account the padding.
+ * Need to draw the entire background, including padding. On Unix, for
+ * menubars, we have to draw the rest of the entry taking into account the
+ * padding.
*/
DrawMenuEntryBackground(menuPtr, mePtr, d, activeBorder, bgBorder, x, y,
@@ -3150,16 +3156,15 @@ TkpDrawMenuEntry(
*
* TkpComputeStandardMenuGeometry --
*
- * This procedure is invoked to recompute the size and
- * layout of a menu that is not a menubar clone.
+ * This procedure is invoked to recompute the size and layout of a menu
+ * that is not a menubar clone.
*
* Results:
* None.
*
* Side effects:
- * Fields of menu entries are changed to reflect their
- * current positions, and the size of the menu window
- * itself may be changed.
+ * Fields of menu entries are changed to reflect their current positions,
+ * and the size of the menu window itself may be changed.
*
*--------------------------------------------------------------
*/
@@ -3195,14 +3200,13 @@ TkpComputeStandardMenuGeometry(
maxIndicatorSpace = 0;
/*
- * On the Mac especially, getting font metrics can be quite slow,
- * so we want to do it intelligently. We are going to precalculate
- * them and pass them down to all of the measuring and drawing
- * routines. We will measure the font metrics of the menu once.
- * If an entry does not have its own font set, then we give
- * the geometry/drawing routines the menu's font and metrics.
- * If an entry has its own font, we will measure that font and
- * give all of the geometry/drawing the entry's font and metrics.
+ * On the Mac especially, getting font metrics can be quite slow, so we
+ * want to do it intelligently. We are going to precalculate them and pass
+ * them down to all of the measuring and drawing routines. We will measure
+ * the font metrics of the menu once. If an entry does not have its own
+ * font set, then we give the geometry/drawing routines the menu's font
+ * and metrics. If an entry has its own font, we will measure that font
+ * and give all of the geometry/drawing the entry's font and metrics.
*/
menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
@@ -3273,13 +3277,12 @@ TkpComputeStandardMenuGeometry(
mePtr->height = height;
} else {
/*
- * For each entry, compute the height required by that
- * particular entry, plus three widths: the width of the
- * label, the width to allow for an indicator to be displayed
- * to the left of the label (if any), and the width of the
- * accelerator to be displayed to the right of the label
- * (if any). These sizes depend, of course, on the type
- * of the entry.
+ * For each entry, compute the height required by that particular
+ * entry, plus three widths: the width of the label, the width to
+ * allow for an indicator to be displayed to the left of the label
+ * (if any), and the width of the accelerator to be displayed to
+ * the right of the label (if any). These sizes depend, of course,
+ * on the type of the entry.
*/
GetMenuLabelGeometry(mePtr, tkfont, fmPtr, &labelWidth, &height);
@@ -3381,8 +3384,8 @@ TkpComputeStandardMenuGeometry(
windowHeight += borderWidth;
/*
- * The X server doesn't like zero dimensions, so round up to at least
- * 1 (a zero-sized menu should never really occur, anyway).
+ * The X server doesn't like zero dimensions, so round up to at least 1 (a
+ * zero-sized menu should never really occur, anyway).
*/
if (windowWidth <= 0) {
@@ -3406,8 +3409,7 @@ TkpComputeStandardMenuGeometry(
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
@@ -3468,47 +3470,47 @@ DrawMenuEntryLabel(
int fullWidth = (imageWidth > textWidth ? imageWidth : textWidth);
switch ((enum compound) mePtr->compound) {
- case COMPOUND_TOP:
- textXOffset = (fullWidth - textWidth)/2;
- textYOffset = imageHeight/2 + 2;
- imageXOffset = (fullWidth - imageWidth)/2;
- imageYOffset = -textHeight/2;
- break;
- case COMPOUND_BOTTOM:
- textXOffset = (fullWidth - textWidth)/2;
- textYOffset = -imageHeight/2;
- imageXOffset = (fullWidth - imageWidth)/2;
- imageYOffset = textHeight/2 + 2;
- break;
- case COMPOUND_LEFT:
- /*
- * Position image in the indicator space to the left of the
- * entries, unless this entry is a radio|check button because
- * then the indicator space will be used.
- */
-
- textXOffset = imageWidth + 2 - menuTextLeadingEdgeMargin;
- if ((mePtr->type != CHECK_BUTTON_ENTRY)
- && (mePtr->type != RADIO_BUTTON_ENTRY)) {
- textXOffset -= indicatorSpace;
- imageXOffset = -indicatorSpace;
- }
- if (textXOffset < 0) {
- textXOffset = 0;
- }
- break;
- case COMPOUND_RIGHT:
- imageXOffset = textWidth + 2 - menuTextTrailingEdgeMargin;
- break;
- case COMPOUND_CENTER:
- textXOffset = (fullWidth - textWidth)/2;
- imageXOffset = (fullWidth - imageWidth)/2;
- break;
- case COMPOUND_NONE:
- /*
- * Never reached.
- */
- break;
+ case COMPOUND_TOP:
+ textXOffset = (fullWidth - textWidth)/2;
+ textYOffset = imageHeight/2 + 2;
+ imageXOffset = (fullWidth - imageWidth)/2;
+ imageYOffset = -textHeight/2;
+ break;
+ case COMPOUND_BOTTOM:
+ textXOffset = (fullWidth - textWidth)/2;
+ textYOffset = -imageHeight/2;
+ imageXOffset = (fullWidth - imageWidth)/2;
+ imageYOffset = textHeight/2 + 2;
+ break;
+ case COMPOUND_LEFT:
+ /*
+ * Position image in the indicator space to the left of the
+ * entries, unless this entry is a radio|check button because then
+ * the indicator space will be used.
+ */
+
+ textXOffset = imageWidth + 2 - menuTextLeadingEdgeMargin;
+ if ((mePtr->type != CHECK_BUTTON_ENTRY)
+ && (mePtr->type != RADIO_BUTTON_ENTRY)) {
+ textXOffset -= indicatorSpace;
+ imageXOffset = -indicatorSpace;
+ }
+ if (textXOffset < 0) {
+ textXOffset = 0;
+ }
+ break;
+ case COMPOUND_RIGHT:
+ imageXOffset = textWidth + 2 - menuTextTrailingEdgeMargin;
+ break;
+ case COMPOUND_CENTER:
+ textXOffset = (fullWidth - textWidth)/2;
+ imageXOffset = (fullWidth - imageWidth)/2;
+ break;
+ case COMPOUND_NONE:
+ /*
+ * Never reached.
+ */
+ break;
}
}
@@ -3562,16 +3564,15 @@ DrawMenuEntryLabel(
*
* DrawMenuEntryBackground --
*
- * This procedure draws the background part of a menu entry.
- * Under Appearance, we only draw the background if the entry's
- * border is set, we DO NOT inherit it from the menu...
+ * This procedure draws the background part of a menu entry. Under
+ * Appearance, we only draw the background if the entry's border is set,
+ * we DO NOT inherit it from the menu...
*
* Results:
* None.
*
* Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
+ * Commands are output to X to display the menu in its current mode.
*
*----------------------------------------------------------------------
*/
@@ -3656,43 +3657,43 @@ GetMenuLabelGeometry(
switch ((enum compound) mePtr->compound) {
int margin;
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM:
- if (textWidth > *widthPtr) {
- *widthPtr = textWidth;
- }
- *heightPtr += textHeight + 2;
- break;
- case COMPOUND_LEFT:
- margin = *widthPtr + 2;
- if (margin > menuTextLeadingEdgeMargin) {
- margin = menuTextLeadingEdgeMargin;
- }
- *widthPtr += textWidth + 2 - margin;
- if (textHeight > *heightPtr) {
- *heightPtr = textHeight;
- }
- break;
- case COMPOUND_RIGHT:
- margin = menuTextTrailingEdgeMargin;
- *widthPtr += textWidth + 2 - margin;
- if (textHeight > *heightPtr) {
- *heightPtr = textHeight;
- }
- break;
- case COMPOUND_CENTER:
- if (textWidth > *widthPtr) {
- *widthPtr = textWidth;
- }
- if (textHeight > *heightPtr) {
- *heightPtr = textHeight;
- }
- break;
- case COMPOUND_NONE:
- /*
- * Never reached.
- */
- break;
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ if (textWidth > *widthPtr) {
+ *widthPtr = textWidth;
+ }
+ *heightPtr += textHeight + 2;
+ break;
+ case COMPOUND_LEFT:
+ margin = *widthPtr + 2;
+ if (margin > menuTextLeadingEdgeMargin) {
+ margin = menuTextLeadingEdgeMargin;
+ }
+ *widthPtr += textWidth + 2 - margin;
+ if (textHeight > *heightPtr) {
+ *heightPtr = textHeight;
+ }
+ break;
+ case COMPOUND_RIGHT:
+ margin = menuTextTrailingEdgeMargin;
+ *widthPtr += textWidth + 2 - margin;
+ if (textHeight > *heightPtr) {
+ *heightPtr = textHeight;
+ }
+ break;
+ case COMPOUND_CENTER:
+ if (textWidth > *widthPtr) {
+ *widthPtr = textWidth;
+ }
+ if (textHeight > *heightPtr) {
+ *heightPtr = textHeight;
+ }
+ break;
+ case COMPOUND_NONE:
+ /*
+ * Never reached.
+ */
+ break;
}
goto labelGeomDone;
}
@@ -3701,7 +3702,7 @@ GetMenuLabelGeometry(
*heightPtr = textHeight;
}
-labelGeomDone:
+ labelGeomDone:
*heightPtr += menuItemExtraHeight;
*widthPtr += menuItemExtraWidth;
}
@@ -3784,8 +3785,8 @@ TkMacOSXGenerateMenuSelectEvent(
*
* MenuSelectEvent --
*
- * Generates a "MenuSelect" virtual event. This can be used to
- * do context-sensitive menu help.
+ * Generates a "MenuSelect" virtual event. This can be used to do
+ * context-sensitive menu help.
*
* Results:
* None.
@@ -3925,8 +3926,8 @@ TkMacOSXClearMenubarActive(void)
* TkpMenuNotifyToplevelCreate --
*
* This routine reconfigures the menu and the clones indicated by
- * menuName becuase a toplevel has been created and any system
- * menus need to be created. Only applicable to Windows.
+ * menuName becuase a toplevel has been created and any system menus need
+ * to be created. Only applicable to Windows.
*
* Results:
* None.
@@ -4024,8 +4025,7 @@ TkpMenuInit(void)
*
* TkpMenuThreadInit --
*
- * Does platform-specific initialization of thread-specific
- * menu state.
+ * Does platform-specific initialization of thread-specific menu state.
*
* Results:
* None.
@@ -4070,7 +4070,7 @@ TkMacOSXPreprocessMenu(void)
if ((mbRefPtr != NULL) && (mbRefPtr->menuPtr != NULL)) {
int code;
- Tcl_Preserve((ClientData) currentMenuBarInterp);
+ Tcl_Preserve(currentMenuBarInterp);
code = TkPreprocessMenu(mbRefPtr->menuPtr->masterMenuPtr);
if ((code != TCL_OK) && (code != TCL_CONTINUE)
&& (code != TCL_BREAK)) {
@@ -4078,7 +4078,7 @@ TkMacOSXPreprocessMenu(void)
"\n (menu preprocess)");
Tcl_BackgroundError(currentMenuBarInterp);
}
- Tcl_Release((ClientData) currentMenuBarInterp);
+ Tcl_Release(currentMenuBarInterp);
}
}
}
@@ -4090,16 +4090,16 @@ TkMacOSXPreprocessMenu(void)
*
* MenuDefProc --
*
- * This routine is the MDEF handler for Tk. It receives all messages
- * for the menu and dispatches them.
+ * This routine is the MDEF handler for Tk. It receives all messages for
+ * the menu and dispatches them.
*
* Results:
* None.
*
* Side effects:
* This routine causes menus to be drawn and will certainly allocate
- * memory as a result. Also, the menu can scroll up and down, and
- * various other interface actions can take place.
+ * memory as a result. Also, the menu can scroll up and down, and various
+ * other interface actions can take place.
*
*----------------------------------------------------------------------
*/
@@ -4108,12 +4108,12 @@ void
MenuDefProc(
SInt16 message, /* What action are we taking? */
MenuRef menu, /* The menu we are working with */
- Rect *menuRectPtr, /* A pointer to the rect for the
- * whole menu. */
- Point hitPt, /* Where the mouse was clicked for
- * the appropriate messages. */
- SInt16 *whichItem) /* Output result. Which item was
- * hit by the user? */
+ Rect *menuRectPtr, /* A pointer to the rect for the whole
+ * menu. */
+ Point hitPt, /* Where the mouse was clicked for the
+ * appropriate messages. */
+ SInt16 *whichItem) /* Output result. Which item was hit by the
+ * user? */
{
TkMenu *menuPtr;
Tcl_HashEntry *commandEntryPtr;
@@ -4123,55 +4123,54 @@ MenuDefProc(
commandEntryPtr = Tcl_FindHashEntry(&commandTable, (char*)(intptr_t)menuID);
if (commandEntryPtr) {
- menuPtr = (TkMenu *) Tcl_GetHashValue(commandEntryPtr);
+ menuPtr = Tcl_GetHashValue(commandEntryPtr);
} else {
menuPtr = NULL;
}
switch (message) {
- case kMenuInitMsg:
- *whichItem = noErr;
- break;
- case kMenuDisposeMsg:
- break;
- case kMenuHiliteItemMsg:
- HandleMenuHiliteMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
- break;
- case kMenuCalcItemMsg:
- HandleMenuCalcItemMsg(menu, menuRectPtr, hitPt, whichItem,
- menuPtr);
- break;
- case kMenuDrawItemsMsg:
+ case kMenuInitMsg:
+ *whichItem = noErr;
+ break;
+ case kMenuDisposeMsg:
+ break;
+ case kMenuHiliteItemMsg:
+ HandleMenuHiliteMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
+ break;
+ case kMenuCalcItemMsg:
+ HandleMenuCalcItemMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
+ break;
+ case kMenuDrawItemsMsg:
#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: DrawItemsMsg");
+ TkMacOSXDbgMsg("MDEF: DrawItemsMsg");
#endif
- /*
- * We do nothing here, because we don't support the Menu Managers
- * dynamic item groups
- */
- break;
- case kMenuThemeSavvyMsg:
- *whichItem = kThemeSavvyMenuResponse;
- break;
- case kMenuSizeMsg:
+ /*
+ * We do nothing here, because we don't support the Menu Managers
+ * dynamic item groups
+ */
+
+ break;
+ case kMenuThemeSavvyMsg:
+ *whichItem = kThemeSavvyMenuResponse;
+ break;
+ case kMenuSizeMsg:
#ifdef TK_MAC_DEBUG_MENUS
- TkMacOSXDbgMsg("MDEF: SizeMsg %d, %d", hitPt.h, hitPt.v);
+ TkMacOSXDbgMsg("MDEF: SizeMsg %d, %d", hitPt.h, hitPt.v);
#endif
- SetMenuWidth(menu, hitPt.h < menuPtr->totalWidth ? hitPt.h :
- menuPtr->totalWidth);
- SetMenuHeight(menu, hitPt.v < menuPtr->totalHeight ? hitPt.v :
- menuPtr->totalHeight);
- break;
- case kMenuDrawMsg:
- HandleMenuDrawMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
- break;
- case kMenuFindItemMsg:
- HandleMenuFindItemMsg(menu, menuRectPtr, hitPt, whichItem,
- menuPtr);
- break;
- case kMenuPopUpMsg:
- HandleMenuPopUpMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
- break;
+ SetMenuWidth(menu, hitPt.h < menuPtr->totalWidth ? hitPt.h :
+ menuPtr->totalWidth);
+ SetMenuHeight(menu, hitPt.v < menuPtr->totalHeight ? hitPt.v :
+ menuPtr->totalHeight);
+ break;
+ case kMenuDrawMsg:
+ HandleMenuDrawMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
+ break;
+ case kMenuFindItemMsg:
+ HandleMenuFindItemMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
+ break;
+ case kMenuPopUpMsg:
+ HandleMenuPopUpMsg(menu, menuRectPtr, hitPt, whichItem, menuPtr);
+ break;
}
}
@@ -4202,7 +4201,7 @@ HandleMenuHiliteMsg(
OSStatus err;
Tk_Font tkfont;
Tk_FontMetrics fontMetrics;
- MDEFHiliteItemData *hidPtr = (MDEFHiliteItemData *)whichItem;
+ MDEFHiliteItemData *hidPtr = (MDEFHiliteItemData *) whichItem;
int oldItem = hidPtr->previousItem - 1;
int newItem = hidPtr->newItem - 1;
MenuTrackingData mtd, *mtdPtr = &mtd;
@@ -4260,9 +4259,9 @@ HandleMenuDrawMsg(
TkMenuEntry *mePtr;
int i;
Rect menuClipRect, bounds;
- MDEFDrawData *ddPtr = (MDEFDrawData*)whichItem;
+ MDEFDrawData *ddPtr = (MDEFDrawData *) whichItem;
MenuTrackingData *mtdPtr = &(ddPtr->trackingData);
- TkWindow *winPtr = (TkWindow*)menuPtr->tkwin;
+ TkWindow *winPtr = (TkWindow *) menuPtr->tkwin;
GetPort(&macMDEFDrawable.grafPtr);
GetPortBounds(macMDEFDrawable.grafPtr, &bounds);
@@ -4342,9 +4341,8 @@ HandleMenuDrawMsg(
}
/*
- * Now, actually draw the menu. Don't draw entries that
- * are higher than the top arrow, and don't draw entries
- * that are lower than the bottom.
+ * Now, actually draw the menu. Don't draw entries that are higher than
+ * the top arrow, and don't draw entries that are lower than the bottom.
*/
for (i = 0; i < menuPtr->numEntries; i++) {
@@ -4365,20 +4363,21 @@ HandleMenuDrawMsg(
*
* HandleMenuFindItemMsg --
*
- * Handles the MenuDefProc's FindItems message. We have to
- * respond by filling in the itemSelected, itemUnderMouse and
- * itemRect fields. This is also the time to scroll the menu if
- * it is too long to fit on the screen.
+ * Handles the MenuDefProc's FindItems message. We have to respond by
+ * filling in the itemSelected, itemUnderMouse and itemRect fields. This
+ * is also the time to scroll the menu if it is too long to fit on the
+ * screen.
*
* Results:
- * The Menu system is informed of the selected item & the item
- * under the mouse.
+ * The Menu system is informed of the selected item & the item under the
+ * mouse.
*
* Side effects:
* The menu might get scrolled.
*
*----------------------------------------------------------------------
*/
+
void
HandleMenuFindItemMsg(
MenuRef menu,
@@ -4402,6 +4401,7 @@ HandleMenuFindItemMsg(
#ifdef TK_MAC_DEBUG_MENUS
static Point lastHitPt = {0, 0};
+
if (hitPt.h != lastHitPt.h || hitPt.v != lastHitPt.v) {
lastHitPt = hitPt;
TkMacOSXDbgMsg("MDEF: FindItemMsg: %d, %d", hitPt.h, hitPt.v);
@@ -4450,8 +4450,8 @@ HandleMenuFindItemMsg(
}
if (scrollDirection == DONT_SCROLL) {
/*
- * Find out which item was hit. If it is the same as the old item,
- * we don't need to do anything.
+ * Find out which item was hit. If it is the same as the old item, we
+ * don't need to do anything.
*/
if (PtInRect(hitPt, menuRectPtr)) {
@@ -4599,8 +4599,8 @@ HandleMenuFindItemMsg(
*
* HandleMenuPopUpMsg --
*
- * Handles the MenuDefProc's PopUp message. The menu is
- * posted with the selected item at the point given in hitPt.
+ * Handles the MenuDefProc's PopUp message. The menu is posted with the
+ * selected item at the point given in hitPt.
*
* Results:
* A menu is posted.
@@ -4610,6 +4610,7 @@ HandleMenuFindItemMsg(
*
*----------------------------------------------------------------------
*/
+
void
HandleMenuPopUpMsg(
MenuRef menu,
@@ -4634,8 +4635,8 @@ HandleMenuPopUpMsg(
GetQDGlobalsScreenBits(&screenBits);
/*
- * Note that for some oddball reason, h and v are reversed in the
- * point given to us by the MDEF.
+ * Note that for some oddball reason, h and v are reversed in the point
+ * given to us by the MDEF.
*/
oldItem = *whichItem;
@@ -4691,14 +4692,13 @@ HandleMenuPopUpMsg(
*
* HandleMenuCalcItemMsg --
*
- * Handles the MenuDefProc's CalcItem message. It is supposed
- * to calculate the Rect of the menu entry in whichItem in the
- * menu, and put that in menuRectPtr. I assume this works, but I
- * have never seen the MenuManager send this message.
+ * Handles the MenuDefProc's CalcItem message. It is supposed to
+ * calculate the Rect of the menu entry in whichItem in the menu, and put
+ * that in menuRectPtr. I assume this works, but I have never seen the
+ * MenuManager send this message.
*
* Results:
- * The Menu Manager is informed of the bounding rect of a
- * menu rect.
+ * The Menu Manager is informed of the bounding rect of a menu rect.
*
* Side effects:
* None.
@@ -4743,3 +4743,10 @@ HandleMenuCalcItemMsg(
#endif
}
#endif /* USE_TK_MDEF */
+
+/*
+ * Local Variables:
+ * fill-column: 78
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 6220d32..04fa202 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -1,8 +1,8 @@
/*
* tkMacOSXMouseEvent.c --
*
- * This file implements functions that decode & handle mouse events
- * on MacOS X.
+ * This file implements functions that decode & handle mouse events on
+ * MacOS X.
*
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net>
@@ -11,50 +11,44 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* The following terms apply to all files originating from Apple
- * Computer, Inc. ("Apple") and associated with the software
- * unless explicitly disclaimed in individual files.
- *
- *
- * Apple hereby grants permission to use, copy, modify,
- * distribute, and license this software and its documentation
- * for any purpose, provided that existing copyright notices are
- * retained in all copies and that this notice is included
- * verbatim in any distributions. No written agreement, license,
- * or royalty fee is required for any of the authorized
- * uses. Modifications to this software may be copyrighted by
- * their authors and need not follow the licensing terms
- * described here, provided that the new terms are clearly
- * indicated on the first page of each file where they apply.
- *
- *
- * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE
- * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
- * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
- * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND
- * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS
- * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE
- * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
+ * Computer, Inc. ("Apple") and associated with the software unless
+ * explicitly disclaimed in individual files.
+ *
+ * Apple hereby grants permission to use, copy, modify, distribute, and
+ * license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that
+ * this notice is included verbatim in any distributions. No written
+ * agreement, license, or royalty fee is required for any of the
+ * authorized uses. Modifications to this software may be copyrighted by
+ * their authors and need not follow the licensing terms described here,
+ * provided that the new terms are clearly indicated on the first page of
+ * each file where they apply.
+ *
+ * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE SOFTWARE
+ * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS
+ * DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF APPLE OR THE
+ * AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. APPLE,
+ * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND
+ * APPLE,THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
- * GOVERNMENT USE: If you are acquiring this software on behalf
- * of the U.S. government, the Government shall have only
- * "Restricted Rights" in the software and related documentation
- * as defined in the Federal Acquisition Regulations (FARs) in
- * Clause 52.227.19 (c) (2). If you are acquiring the software
- * on behalf of the Department of Defense, the software shall be
- * classified as "Commercial Computer Software" and the
- * Government shall have only "Restricted Rights" as defined in
- * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others
- * acting in its behalf permission to use and distribute the
- * software in accordance with the terms specified in this
- * license.
- *
- * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.34 2007/12/13 15:27:10 dgp Exp $
+ * GOVERNMENT USE: If you are acquiring this software on behalf of the
+ * U.S. government, the Government shall have only "Restricted Rights" in
+ * the software and related documentation as defined in the Federal
+ * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are
+ * acquiring the software on behalf of the Department of Defense, the
+ * software shall be classified as "Commercial Computer Software" and the
+ * Government shall have only "Restricted Rights" as defined in Clause
+ * 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+ * authors grant the U.S. Government and others acting in its behalf
+ * permission to use and distribute the software in accordance with the
+ * terms specified in this license.
+ *
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.35 2008/10/27 11:55:45 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -63,47 +57,47 @@
#include "tkMacOSXDebug.h"
typedef struct {
- WindowRef whichWin;
- WindowRef activeNonFloating;
+ WindowRef whichWin;
+ WindowRef activeNonFloating;
WindowPartCode windowPart;
- unsigned int state;
- long delta;
- Window window;
- Point global;
- Point local;
+ unsigned int state;
+ long delta;
+ Window window;
+ Point global;
+ Point local;
} MouseEventData;
/*
* Declarations of static variables used in this file.
*/
-static int gEatButtonUp = 0; /* 1 if we need to eat the next up event */
+static int gEatButtonUp = 0; /* 1 if we need to eat the next up event. */
/*
* Declarations of functions used only in this file.
*/
-static void BringWindowForward(WindowRef wRef, int isFrontProcess,
- int frontWindowOnly);
-static int GeneratePollingEvents(MouseEventData * medPtr);
-static int GenerateMouseWheelEvent(MouseEventData * medPtr);
-static int GenerateButtonEvent(MouseEventData * medPtr);
-static int GenerateToolbarButtonEvent(MouseEventData * medPtr);
-static int HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin);
-static unsigned int ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers);
-static Tk_Window GetGrabWindowForWindow(Tk_Window tkwin);
-
-static int TkMacOSXGetEatButtonUp(void);
-static void TkMacOSXSetEatButtonUp(int f);
-
+static void BringWindowForward(WindowRef wRef, int isFrontProcess,
+ int frontWindowOnly);
+static int GeneratePollingEvents(MouseEventData *medPtr);
+static int GenerateMouseWheelEvent(MouseEventData *medPtr);
+static int GenerateButtonEvent(MouseEventData *medPtr);
+static int GenerateToolbarButtonEvent(MouseEventData *medPtr);
+static int HandleWindowTitlebarMouseDown(MouseEventData *medPtr,
+ Tk_Window tkwin);
+static unsigned int ButtonModifiers2State(UInt32 buttonState,
+ UInt32 keyModifiers);
+static Tk_Window GetGrabWindowForWindow(Tk_Window tkwin);
+static int TkMacOSXGetEatButtonUp(void);
+static void TkMacOSXSetEatButtonUp(int f);
/*
*----------------------------------------------------------------------
*
* TkMacOSXProcessMouseEvent --
*
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
+ * This routine processes the event in eventPtr, and generates the
+ * appropriate Tk events from it.
*
* Results:
* True if event(s) are generated - false otherwise.
@@ -115,46 +109,42 @@ static void TkMacOSXSetEatButtonUp(int f);
*/
MODULE_SCOPE int
-TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
+TkMacOSXProcessMouseEvent(
+ TkMacOSXEvent *eventPtr,
+ MacEventStatus *statusPtr)
{
Tk_Window tkwin;
Point where, where2;
int result;
- TkDisplay * dispPtr;
+ TkDisplay *dispPtr;
OSStatus err;
- MouseEventData mouseEventData, * medPtr = &mouseEventData;
+ MouseEventData mouseEventData, *medPtr = &mouseEventData;
int isFrontProcess;
switch (eventPtr->eKind) {
- case kEventMouseDown:
- case kEventMouseUp:
- case kEventMouseMoved:
- case kEventMouseDragged:
- case kEventMouseWheelMoved:
- break;
- default:
- return false;
- break;
+ case kEventMouseDown:
+ case kEventMouseUp:
+ case kEventMouseMoved:
+ case kEventMouseDragged:
+ case kEventMouseWheelMoved:
+ break;
+ default:
+ return false;
}
+
err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMouseLocation,
- typeQDPoint, NULL,
- sizeof(where), NULL,
+ kEventParamMouseLocation, typeQDPoint, NULL, sizeof(where), NULL,
&where);
if (err != noErr) {
GetGlobalMouse(&where);
}
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamWindowRef,
- typeWindowRef, NULL,
- sizeof(WindowRef), NULL,
- &medPtr->whichWin);
+
+ err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamWindowRef,
+ typeWindowRef, NULL, sizeof(WindowRef), NULL, &medPtr->whichWin);
if (err == noErr) {
err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamWindowPartCode,
- typeWindowPartCode, NULL,
- sizeof(WindowPartCode), NULL,
- &medPtr->windowPart);
+ kEventParamWindowPartCode, typeWindowPartCode, NULL,
+ sizeof(WindowPartCode), NULL, &medPtr->windowPart);
}
if (err != noErr) {
medPtr->windowPart = FindWindow(where, &medPtr->whichWin);
@@ -190,13 +180,12 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
}
medPtr->global = where;
err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamWindowMouseLocation,
- typeQDPoint, NULL,
- sizeof(Point), NULL,
- &medPtr->local);
+ kEventParamWindowMouseLocation, typeQDPoint, NULL,
+ sizeof(Point), NULL, &medPtr->local);
if (err == noErr) {
if (medPtr->whichWin) {
Rect widths;
+
GetWindowStructureWidths(medPtr->whichWin, &widths);
medPtr->local.h -= widths.left;
medPtr->local.v -= widths.top;
@@ -216,157 +205,157 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
int res = false;
switch (eventPtr->eKind) {
- case kEventMouseUp:
- /*
- * The window manager only needs to know about mouse down
- * events and sometimes we need to "eat" the mouse up.
- * Otherwise, we just pass the event to Tk.
- */
- if (TkMacOSXGetEatButtonUp()) {
- TkMacOSXSetEatButtonUp(false);
- } else {
- res = GenerateButtonEvent(medPtr);
- }
- break;
- case kEventMouseWheelMoved:
+ case kEventMouseUp:
+ /*
+ * The window manager only needs to know about mouse down events
+ * and sometimes we need to "eat" the mouse up. Otherwise, we just
+ * pass the event to Tk.
+ */
+
+ if (TkMacOSXGetEatButtonUp()) {
+ TkMacOSXSetEatButtonUp(false);
+ } else {
+ res = GenerateButtonEvent(medPtr);
+ }
+ break;
+ case kEventMouseWheelMoved:
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamMouseWheelDelta, typeLongInteger, NULL,
+ sizeof(long), NULL, &medPtr->delta);
+ if (err != noErr ) {
+ statusPtr->err = 1;
+ } else {
+ EventMouseWheelAxis axis;
+
err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMouseWheelDelta, typeLongInteger, NULL,
- sizeof(long), NULL, &medPtr->delta);
- if (err != noErr ) {
- statusPtr->err = 1;
- } else {
- EventMouseWheelAxis axis;
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamMouseWheelAxis, typeMouseWheelAxis,
- NULL, sizeof(EventMouseWheelAxis), NULL, &axis);
- if (err == noErr && axis == kEventMouseWheelAxisX) {
- medPtr->state |= ShiftMask;
- }
- res = GenerateMouseWheelEvent(medPtr);
+ kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL,
+ sizeof(EventMouseWheelAxis), NULL, &axis);
+ if (err == noErr && axis == kEventMouseWheelAxisX) {
+ medPtr->state |= ShiftMask;
}
- break;
- case kEventMouseMoved:
- case kEventMouseDragged:
- res = GeneratePollingEvents(medPtr);
- break;
- default:
- Tcl_Panic("Unknown mouse event !");
+ res = GenerateMouseWheelEvent(medPtr);
+ }
+ break;
+ case kEventMouseMoved:
+ case kEventMouseDragged:
+ res = GeneratePollingEvents(medPtr);
+ break;
+ default:
+ Tcl_Panic("Unknown mouse event !");
}
if (res) {
- statusPtr->stopProcessing = 1;
+ statusPtr->stopProcessing = 1;
}
return res;
}
+
TkMacOSXSetEatButtonUp(false);
- if (medPtr->whichWin) {
+ if (!medPtr->whichWin) {
+ return false;
+ }
+
+ /*
+ * We got a mouse down in a window, so see if this is the activate click.
+ * This click moves the window forward. We don't want the corresponding
+ * mouse-up to be reported to the application or else it will mess up some
+ * Tk scripts.
+ */
+
+ if (!(TkpIsWindowFloating(medPtr->whichWin))
+ && (medPtr->whichWin != medPtr->activeNonFloating
+ || !isFrontProcess)) {
+ int frontWindowOnly = 1;
+ int cmdDragGrow = ((medPtr->windowPart == inDrag ||
+ medPtr->windowPart == inGrow) && medPtr->state & Mod1Mask);
+
+ if (!cmdDragGrow) {
+ Tk_Window grabWin = GetGrabWindowForWindow(tkwin);
+
+ frontWindowOnly = !grabWin;
+ if (grabWin && grabWin != tkwin) {
+ TkMacOSXSetEatButtonUp(true);
+ BringWindowForward(TkMacOSXDrawableWindow(
+ ((TkWindow *) grabWin)->window), isFrontProcess,
+ frontWindowOnly);
+ return false;
+ }
+ }
+
/*
- * We got a mouse down in a window
- * See if this is the activate click
- * This click moves the window forward. We don't want
- * the corresponding mouse-up to be reported to the application
- * or else it will mess up some Tk scripts.
+ * Clicks in the titlebar widgets are handled without bringing the
+ * window forward.
*/
- if (!(TkpIsWindowFloating(medPtr->whichWin))
- && (medPtr->whichWin != medPtr->activeNonFloating
- || !isFrontProcess)) {
- int frontWindowOnly = 1;
- int cmdDragGrow = ((medPtr->windowPart == inDrag ||
- medPtr->windowPart == inGrow) && medPtr->state & Mod1Mask);
+ result = HandleWindowTitlebarMouseDown(medPtr, tkwin);
+ if (result != -1) {
+ statusPtr->stopProcessing = 1;
+ return result;
+ }
+
+ /*
+ * Only windows with the kWindowNoActivatesAttribute can receive mouse
+ * events in the background.
+ */
+
+ if (!(((TkWindow *)tkwin)->wmInfoPtr->attributes &
+ kWindowNoActivatesAttribute)) {
+ /*
+ * Allow background window dragging & growing with Command down.
+ */
if (!cmdDragGrow) {
- Tk_Window grabWin = GetGrabWindowForWindow(tkwin);
-
- frontWindowOnly = !grabWin;
- if (grabWin && grabWin != tkwin) {
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(TkMacOSXDrawableWindow(
- ((TkWindow*)grabWin)->window), isFrontProcess,
- frontWindowOnly);
- return false;
- }
+ TkMacOSXSetEatButtonUp(true);
+ BringWindowForward(medPtr->whichWin, isFrontProcess,
+ frontWindowOnly);
}
/*
- * Clicks in the titlebar widgets are handled without bringing the
- * window forward.
+ * Allow dragging & growing of windows that were/are in the
+ * background.
*/
- if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
- statusPtr->stopProcessing = 1;
- return result;
- } else {
- /*
- * Only windows with the kWindowNoActivatesAttribute can
- * receive mouse events in the background.
- */
- if (!(((TkWindow *)tkwin)->wmInfoPtr->attributes &
- kWindowNoActivatesAttribute)) {
- /*
- * Allow background window dragging & growing with Command
- * down.
- */
- if (!cmdDragGrow) {
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(medPtr->whichWin, isFrontProcess,
- frontWindowOnly);
- }
- /*
- * Allow dragging & growing of windows that were/are in the
- * background.
- */
- if (!(medPtr->windowPart == inDrag ||
- medPtr->windowPart == inGrow)) {
- return false;
- }
- }
- }
- } else {
- if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
- statusPtr->stopProcessing = 1;
- return result;
+
+ if (!(medPtr->windowPart == inDrag ||
+ medPtr->windowPart == inGrow)) {
+ return false;
}
}
- switch (medPtr->windowPart) {
- case inDrag: {
- WindowAttributes attributes;
-
- GetWindowAttributes(medPtr->whichWin, &attributes);
- if (!(attributes & kWindowAsyncDragAttribute)) {
- TkMacOSXTrackingLoop(1);
- DragWindow(medPtr->whichWin, where, NULL);
- TkMacOSXTrackingLoop(0);
- where2.h = where2.v = 0;
- QDLocalToGlobalPoint(GetWindowPort(medPtr->whichWin),
- &where2);
- if (EqualPt(where, where2)) {
- return false;
- }
- return true;
- }
- break;
- }
- case inGrow:
- /*
- * Generally the content region is the domain of Tk
- * sub-windows. However, one exception is the grow
- * region. A button down in this area will be handled
- * by the window manager. Note: this means that Tk
- * may not get button down events in this area!
- */
- if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) {
- statusPtr->stopProcessing = 1;
- return true;
- } else {
- return GenerateButtonEvent(medPtr);
- }
- break;
- case inContent:
- return GenerateButtonEvent(medPtr);
- break;
- default:
- return false;
- break;
+ } else {
+ result = HandleWindowTitlebarMouseDown(medPtr, tkwin);
+ if (result != -1) {
+ statusPtr->stopProcessing = 1;
+ return result;
+ }
+ }
+
+ switch (medPtr->windowPart) {
+ case inDrag: {
+ WindowAttributes attributes;
+
+ GetWindowAttributes(medPtr->whichWin, &attributes);
+ if (!(attributes & kWindowAsyncDragAttribute)) {
+ TkMacOSXTrackingLoop(1);
+ DragWindow(medPtr->whichWin, where, NULL);
+ TkMacOSXTrackingLoop(0);
+ where2.h = where2.v = 0;
+ QDLocalToGlobalPoint(GetWindowPort(medPtr->whichWin), &where2);
+ return (EqualPt(where, where2)) ? false : true;
}
+ break;
+ }
+ case inGrow:
+ /*
+ * Generally the content region is the domain of Tk sub-windows.
+ * However, one exception is the grow region. A button down in this
+ * area will be handled by the window manager. Note: this means that
+ * Tk may not get button down events in this area!
+ */
+
+ if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) {
+ statusPtr->stopProcessing = 1;
+ return true;
+ }
+ case inContent:
+ return GenerateButtonEvent(medPtr);
}
return false;
}
@@ -379,8 +368,8 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
* Handle clicks in window titlebar.
*
* Results:
- * 1 if event was handled, 0 if event was not handled,
- * -1 if MouseDown was not in window titlebar.
+ * 1 if event was handled, 0 if event was not handled, -1 if MouseDown
+ * was not in window titlebar.
*
* Side effects:
* Additional events may be place on the Tk event queue.
@@ -389,65 +378,67 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
*/
int
-HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin)
+HandleWindowTitlebarMouseDown(
+ MouseEventData *medPtr,
+ Tk_Window tkwin)
{
int result = INT_MAX;
switch (medPtr->windowPart) {
- case inGoAway:
- case inCollapseBox:
- case inZoomIn:
- case inZoomOut:
- case inToolbarButton:
- if (!IsWindowActive(medPtr->whichWin)) {
- WindowRef frontWindow = FrontNonFloatingWindow();
- WindowModality frontWindowModality = kWindowModalityNone;
-
- if (frontWindow && frontWindow != medPtr->whichWin) {
- ChkErr(GetWindowModality, frontWindow,
- &frontWindowModality, NULL);
- }
- if (frontWindowModality == kWindowModalityAppModal) {
- result = 0;
- }
+ case inGoAway:
+ case inCollapseBox:
+ case inZoomIn:
+ case inZoomOut:
+ case inToolbarButton:
+ if (!IsWindowActive(medPtr->whichWin)) {
+ WindowRef frontWindow = FrontNonFloatingWindow();
+ WindowModality frontWindowModality = kWindowModalityNone;
+
+ if (frontWindow && frontWindow != medPtr->whichWin) {
+ ChkErr(GetWindowModality, frontWindow,
+ &frontWindowModality, NULL);
}
- break;
- default:
- result = -1;
- break;
+ if (frontWindowModality == kWindowModalityAppModal) {
+ result = 0;
+ }
+ }
+ break;
+ default:
+ result = -1;
+ break;
}
if (result == INT_MAX) {
result = 0;
TkMacOSXTrackingLoop(1);
switch (medPtr->windowPart) {
- case inGoAway:
- if (TrackGoAway(medPtr->whichWin, medPtr->global) && tkwin) {
- TkGenWMDestroyEvent(tkwin);
- result = 1;
- }
- break;
- case inCollapseBox:
- if (TrackBox(medPtr->whichWin, medPtr->global,
- medPtr->windowPart) && tkwin) {
- TkpWmSetState((TkWindow *)tkwin, IconicState);
- result = 1;
- }
- break;
- case inZoomIn:
- case inZoomOut:
- if (TrackBox(medPtr->whichWin, medPtr->global,
- medPtr->windowPart)) {
- result = TkMacOSXZoomToplevel(medPtr->whichWin,
- medPtr->windowPart);
- }
- break;
- case inToolbarButton:
- if (TrackBox(medPtr->whichWin, medPtr->global,
- medPtr->windowPart)) {
- result = GenerateToolbarButtonEvent(medPtr);
- }
- break;
+ case inGoAway:
+ if (TrackGoAway(medPtr->whichWin, medPtr->global) && tkwin) {
+ TkGenWMDestroyEvent(tkwin);
+ result = 1;
+ }
+ break;
+ case inCollapseBox:
+ if (TrackBox(medPtr->whichWin, medPtr->global,
+ medPtr->windowPart) && tkwin) {
+ TkpWmSetState((TkWindow *) tkwin, IconicState);
+ result = 1;
+ }
+ break;
+ case inZoomIn:
+ case inZoomOut:
+ if (TrackBox(medPtr->whichWin, medPtr->global,
+ medPtr->windowPart)) {
+ result = TkMacOSXZoomToplevel(medPtr->whichWin,
+ medPtr->windowPart);
+ }
+ break;
+ case inToolbarButton:
+ if (TrackBox(medPtr->whichWin, medPtr->global,
+ medPtr->windowPart)) {
+ result = GenerateToolbarButtonEvent(medPtr);
+ }
+ break;
}
TkMacOSXTrackingLoop(0);
}
@@ -460,46 +451,45 @@ HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin)
*
* GeneratePollingEvents --
*
- * This function polls the mouse position and generates X Motion,
- * Enter & Leave events. The cursor is also updated at this
- * time.
+ * This function polls the mouse position and generates X Motion, Enter &
+ * Leave events. The cursor is also updated at this time.
*
* Results:
* True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * The cursor may be changed.
+ * Additional events may be place on the Tk event queue. The cursor may
+ * be changed.
*
*----------------------------------------------------------------------
*/
static int
-GeneratePollingEvents(MouseEventData * medPtr)
+GeneratePollingEvents(
+ MouseEventData *medPtr)
{
Tk_Window tkwin, rootwin, grabWin;
int local_x, local_y;
TkDisplay *dispPtr;
-
grabWin = TkMacOSXGetCapture();
if ((!TkpIsWindowFloating(medPtr->whichWin)
&& (medPtr->activeNonFloating != medPtr->whichWin))) {
/*
- * If the window for this event is not floating, and is not the
- * active non-floating window, don't generate polling events.
- * We don't send events to backgrounded windows. So either send
- * it to the grabWin, or NULL if there is no grabWin.
+ * If the window for this event is not floating, and is not the active
+ * non-floating window, don't generate polling events. We don't send
+ * events to backgrounded windows. So either send it to the grabWin,
+ * or NULL if there is no grabWin.
*/
tkwin = grabWin;
} else {
/*
- * First check whether the toplevel containing this mouse
- * event is the grab window. If not, then send the event
- * to the grab window. Otherwise, set tkWin to the subwindow
- * which most closely contains the mouse event.
+ * First check whether the toplevel containing this mouse event is the
+ * grab window. If not, then send the event to the grab window.
+ * Otherwise, set tkWin to the subwindow which most closely contains
+ * the mouse event.
*/
dispPtr = TkGetDisplayList();
@@ -508,20 +498,18 @@ GeneratePollingEvents(MouseEventData * medPtr)
|| ((grabWin != NULL) && (rootwin != grabWin))) {
tkwin = grabWin;
} else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
- &local_x, &local_y);
+ tkwin = Tk_TopCoordsToWindow(rootwin, medPtr->local.h,
+ medPtr->local.v, &local_x, &local_y);
}
}
/*
- * The following call will generate the appropiate X events and
- * adjust any state that Tk must remember.
+ * The following call will generate the appropiate X events and adjust any
+ * state that Tk must remember.
*/
Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v,
medPtr->state);
-
return true;
}
@@ -559,8 +547,8 @@ BringWindowForward(
if (window != None) {
TkDisplay *dispPtr = TkGetDisplayList();
- TkWindow * winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display,
- window);
+ TkWindow *winPtr = (TkWindow *)
+ Tk_IdToWindow(dispPtr->display, window);
if (winPtr && winPtr->wmInfoPtr &&
winPtr->wmInfoPtr->master != None) {
@@ -586,8 +574,8 @@ BringWindowForward(
if (!isFrontProcess) {
ProcessSerialNumber ourPsn = {0, kCurrentProcess};
- ChkErr(SetFrontProcessWithOptions, &ourPsn, frontWindowOnly ?
- kSetFrontProcessFrontWindowOnly : 0);
+ ChkErr(SetFrontProcessWithOptions, &ourPsn,
+ frontWindowOnly ? kSetFrontProcessFrontWindowOnly : 0);
}
}
@@ -596,8 +584,8 @@ BringWindowForward(
*
* TkMacOSXBringWindowForward --
*
- * Bring this window to the front in response to a mouse click. If
- * a grab is in effect, bring the grab window to the front instead.
+ * Bring this window to the front in response to a mouse click. If a grab
+ * is in effect, bring the grab window to the front instead.
*
* Results:
* None.
@@ -613,11 +601,12 @@ TkMacOSXBringWindowForward(
WindowRef wRef)
{
TkDisplay *dispPtr = TkGetDisplayList();
- Tk_Window tkwin = Tk_IdToWindow(dispPtr->display,TkMacOSXGetXWindow(wRef));
+ Tk_Window tkwin =
+ Tk_IdToWindow(dispPtr->display, TkMacOSXGetXWindow(wRef));
Tk_Window grabWin = GetGrabWindowForWindow(tkwin);
if (grabWin && grabWin != tkwin) {
- wRef = TkMacOSXDrawableWindow(((TkWindow*)grabWin)->window);
+ wRef = TkMacOSXDrawableWindow(((TkWindow *) grabWin)->window);
}
TkMacOSXSetEatButtonUp(true);
BringWindowForward(wRef, Tk_MacOSXIsAppInFront(), !grabWin);
@@ -646,10 +635,10 @@ GetGrabWindowForWindow(
Tk_Window grabWin = TkMacOSXGetCapture();
if (!grabWin) {
- int grabState = TkGrabState((TkWindow*)tkwin);
+ int grabState = TkGrabState((TkWindow *) tkwin);
if (grabState != TK_GRAB_NONE && grabState != TK_GRAB_IN_TREE) {
- grabWin = (Tk_Window) (((TkWindow*)tkwin)->dispPtr->grabWinPtr);
+ grabWin = (Tk_Window) (((TkWindow *) tkwin)->dispPtr->grabWinPtr);
}
}
@@ -673,11 +662,12 @@ GetGrabWindowForWindow(
*/
static int
-GenerateMouseWheelEvent(MouseEventData * medPtr)
+GenerateMouseWheelEvent(
+ MouseEventData *medPtr)
{
Tk_Window tkwin, rootwin;
TkDisplay *dispPtr;
- TkWindow *winPtr;
+ TkWindow *winPtr;
XEvent xEvent;
dispPtr = TkGetDisplayList();
@@ -685,14 +675,13 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
if (rootwin == NULL) {
tkwin = NULL;
} else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
- &xEvent.xbutton.x, &xEvent.xbutton.y);
+ tkwin = Tk_TopCoordsToWindow(rootwin, medPtr->local.h,
+ medPtr->local.v, &xEvent.xbutton.x, &xEvent.xbutton.y);
}
/*
- * The following call will generate the appropiate X events and
- * adjust any state that Tk must remember.
+ * The following call will generate the appropiate X events and adjust any
+ * state that Tk must remember.
*/
if (!tkwin) {
@@ -701,6 +690,7 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
if (!tkwin) {
return false;
}
+
winPtr = (TkWindow *) tkwin;
xEvent.type = MouseWheelEvent;
xEvent.xkey.keycode = medPtr->delta;
@@ -712,7 +702,6 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
xEvent.xany.display = winPtr->display;
xEvent.xany.window = Tk_WindowId(winPtr);
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
-
return true;
}
@@ -722,14 +711,14 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
* TkMacOSXGetEatButtonUp --
*
* Results:
- * Returns the flag indicating if we need to eat the
- * next mouse up event
+ * Return the flag indicating if we need to eat the next mouse up event.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
+
int
TkMacOSXGetEatButtonUp(void)
{
@@ -745,13 +734,14 @@ TkMacOSXGetEatButtonUp(void)
* None.
*
* Side effects:
- * Sets the flag indicating if we need to eat the
- * next mouse up event
+ * Sets the flag indicating if we need to eat the next mouse up event
*
*----------------------------------------------------------------------
*/
+
void
-TkMacOSXSetEatButtonUp(int f)
+TkMacOSXSetEatButtonUp(
+ int f)
{
gEatButtonUp = f;
}
@@ -781,7 +771,7 @@ TkMacOSXModifierState(void)
keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() :
GetCurrentKeyModifiers();
- return (EventModifiers)(keyModifiers & USHRT_MAX);
+ return (EventModifiers) (keyModifiers & USHRT_MAX);
}
/*
@@ -792,8 +782,8 @@ TkMacOSXModifierState(void)
* Returns the current state of the button & modifier keys.
*
* Results:
- * A bitwise inclusive OR of a subset of the following:
- * Button1Mask, ShiftMask, LockMask, ControlMask, Mod*Mask.
+ * A bitwise inclusive OR of a subset of the following: Button1Mask,
+ * ShiftMask, LockMask, ControlMask, Mod*Mask.
*
* Side effects:
* None.
@@ -835,11 +825,16 @@ TkMacOSXButtonKeyState(void)
*/
static unsigned int
-ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
+ButtonModifiers2State(
+ UInt32 buttonState,
+ UInt32 keyModifiers)
{
unsigned int state;
- /* Tk supports at most 5 buttons */
+ /*
+ * Tk supports at most 5 buttons.
+ */
+
state = (buttonState & ((1<<5) - 1)) << 8;
if (keyModifiers & alphaLock) {
@@ -873,12 +868,12 @@ ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
* XQueryPointer --
*
* Check the current state of the mouse. This is not a complete
- * implementation of this function. It only computes the root
- * coordinates and the current mask.
+ * implementation of this function. It only computes the root coordinates
+ * and the current mask.
*
* Results:
- * Sets root_x_return, root_y_return, and mask_return. Returns
- * true on success.
+ * Sets root_x_return, root_y_return, and mask_return. Returns true on
+ * success.
*
* Side effects:
* None.
@@ -888,15 +883,15 @@ ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
Bool
XQueryPointer(
- Display* display,
+ Display *display,
Window w,
- Window* root_return,
- Window* child_return,
- int* root_x_return,
- int* root_y_return,
- int* win_x_return,
- int* win_y_return,
- unsigned int* mask_return)
+ Window *root_return,
+ Window *child_return,
+ int *root_x_return,
+ int *root_y_return,
+ int *win_x_return,
+ int *win_y_return,
+ unsigned int *mask_return)
{
int getGlobal = (root_x_return && root_y_return);
int getLocal = (win_x_return && win_y_return);
@@ -923,6 +918,7 @@ XQueryPointer(
}
if (getLocal) {
WindowRef whichWin;
+
if (ev) {
err = ChkErr(GetEventParameter, ev, kEventParamWindowRef,
typeWindowRef, NULL, sizeof(WindowRef), NULL,
@@ -966,22 +962,22 @@ XQueryPointer(
*
* TkGenerateButtonEventForXPointer --
*
- * This procedure generates an X button event for the current
- * pointer state as reported by XQueryPointer().
+ * This procedure generates an X button event for the current pointer
+ * state as reported by XQueryPointer().
*
* Results:
* True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue. Grab state may
+ * also change.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE int
TkGenerateButtonEventForXPointer(
- Window window) /* X Window containing button event. */
+ Window window) /* X Window containing button event. */
{
MouseEventData med;
int global_x, global_y, local_x, local_y;
@@ -1004,26 +1000,26 @@ TkGenerateButtonEventForXPointer(
*
* TkGenerateButtonEvent --
*
- * Given a global x & y position and the button key status this
- * procedure generates the appropiate X button event. It also
- * handles the state changes needed to implement implicit grabs.
+ * Given a global x & y position and the button key status this procedure
+ * generates the appropiate X button event. It also handles the state
+ * changes needed to implement implicit grabs.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated, false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue. Grab state may
+ * also change.
*
*----------------------------------------------------------------------
*/
int
TkGenerateButtonEvent(
- int x, /* X location of mouse */
- int y, /* Y location of mouse */
- Window window, /* X Window containing button event. */
- unsigned int state) /* Button Key state suitable for X event */
+ int x, /* X location of mouse, */
+ int y, /* Y location of mouse. */
+ Window window, /* X Window containing button event. */
+ unsigned int state) /* Button Key state suitable for X event. */
{
MouseEventData med;
@@ -1045,21 +1041,22 @@ TkGenerateButtonEvent(
*
* GenerateButtonEvent --
*
- * Generate an X button event from a MouseEventData structure.
- * Handles the state changes needed to implement implicit grabs.
+ * Generate an X button event from a MouseEventData structure. Handles
+ * the state changes needed to implement implicit grabs.
*
* Results:
* True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue. Grab state may
+ * also change.
*
*----------------------------------------------------------------------
*/
static int
-GenerateButtonEvent(MouseEventData * medPtr)
+GenerateButtonEvent(
+ MouseEventData *medPtr)
{
Tk_Window tkwin;
int dummy;
@@ -1067,11 +1064,12 @@ GenerateButtonEvent(MouseEventData * medPtr)
#if UNUSED
/*
- * ButtonDown events will always occur in the front
- * window. ButtonUp events, however, may occur anywhere
- * on the screen. ButtonUp events should only be sent
- * to Tk if in the front window or during an implicit grab.
+ * ButtonDown events will always occur in the front window. ButtonUp
+ * events, however, may occur anywhere on the screen. ButtonUp events
+ * should only be sent to Tk if in the front window or during an implicit
+ * grab.
*/
+
if ((medPtr->activeNonFloating == NULL)
|| ((!(TkpIsWindowFloating(medPtr->whichWin))
&& (medPtr->activeNonFloating != medPtr->whichWin))
@@ -1089,7 +1087,6 @@ GenerateButtonEvent(MouseEventData * medPtr)
}
Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state);
-
return true;
}
@@ -1098,8 +1095,8 @@ GenerateButtonEvent(MouseEventData * medPtr)
*
* GenerateToolbarButtonEvent --
*
- * Generates a "ToolbarButton" virtual event.
- * This can be used to manage disappearing toolbars.
+ * Generates a "ToolbarButton" virtual event. This can be used to manage
+ * disappearing toolbars.
*
* Results:
* None.
@@ -1111,11 +1108,12 @@ GenerateButtonEvent(MouseEventData * medPtr)
*/
static int
-GenerateToolbarButtonEvent(MouseEventData * medPtr)
+GenerateToolbarButtonEvent(
+ MouseEventData *medPtr)
{
Tk_Window rootwin, tkwin = NULL;
TkDisplay *dispPtr;
- TkWindow *winPtr;
+ TkWindow *winPtr;
XVirtualEvent event;
dispPtr = TkGetDisplayList();
@@ -1127,7 +1125,7 @@ GenerateToolbarButtonEvent(MouseEventData * medPtr)
if (!tkwin) {
return true;
}
- winPtr = (TkWindow *)tkwin;
+ winPtr = (TkWindow *) tkwin;
bzero(&event, sizeof(XVirtualEvent));
event.type = VirtualEvent;
@@ -1147,3 +1145,12 @@ GenerateToolbarButtonEvent(MouseEventData * medPtr)
Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
return true;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 7f00cf2..5756b0c 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -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: tkMacOSXPrivate.h,v 1.8 2008/09/02 16:10:55 das Exp $
+ * RCS: @(#) $Id: tkMacOSXPrivate.h,v 1.9 2008/10/27 11:55:45 dkf Exp $
*/
#ifndef _TKMACPRIV
@@ -17,7 +17,7 @@
#ifndef _TKMACINT
#include "tkMacOSXInt.h"
#endif
-
+
/* Define constants only available on Mac OS X 10.3 or later */
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
#define kEventAppAvailableWindowBoundsChanged 110
@@ -172,7 +172,7 @@ MODULE_SCOPE float tkMacOSXToolboxVersionNumber;
#define tk_if_mac_os_x_10_5 tk_if_mac_os_x_no
#define tk_else_mac_os_x_10_5 tk_else_mac_os_x_no
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
-
+
/*
* Macros for DEBUG_ASSERT_MESSAGE et al from Debugging.h.
*/
@@ -190,23 +190,28 @@ MODULE_SCOPE float tkMacOSXToolboxVersionNumber;
/*
* Macro to do debug message output.
*/
-#define TkMacOSXDbgMsg(m, ...) do { \
- fprintf(stderr, "%s:%d: %s(): " m "\n", strrchr(__FILE__, '/')+1, \
- __LINE__, __func__, ##__VA_ARGS__); \
- } while (0)
+#define TkMacOSXDbgMsg(m, ...) \
+ do { \
+ fprintf(stderr, "%s:%d: %s(): " m "\n", strrchr(__FILE__, '/')+1, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ } while (0)
+
/*
* Macro to do debug API failure message output.
*/
#if !defined(DEBUGLEVEL) || !DEBUGLEVEL
-#define TkMacOSXDbgOSErr(f, err) do { \
- TkMacOSXDbgMsg("%s failed: %ld", #f, err); \
- } while (0)
+#define TkMacOSXDbgOSErr(f, err) \
+ do { \
+ TkMacOSXDbgMsg("%s failed: %ld", #f, err); \
+ } while (0)
#else
-#define TkMacOSXDbgOSErr(f, err) do { \
- DEBUG_ASSERT_MESSAGE(kComponentSignatureString, #f " failed:", \
- __func__, 0, strrchr(__FILE__, '/')+1, __LINE__, err); \
- } while (0)
+#define TkMacOSXDbgOSErr(f, err) \
+ do { \
+ DEBUG_ASSERT_MESSAGE(kComponentSignatureString, #f " failed:", \
+ __func__, 0, strrchr(__FILE__, '/')+1, __LINE__, err); \
+ } while (0)
#endif
+
/*
* Macro to do very common check for noErr return from given API and output
* debug message in case of failure.
@@ -217,14 +222,16 @@ MODULE_SCOPE float tkMacOSXToolboxVersionNumber;
TkMacOSXDbgOSErr(f, err); \
} \
err;})
+
/*
* Macro to check emptyness of shared QD tmp region before use in debug builds.
*/
-#define TkMacOSXCheckTmpQdRgnEmpty() do { \
- if (!EmptyRgn(tkMacOSXtmpQdRgn)) { \
- Tcl_Panic("tkMacOSXtmpQdRgn nonempty"); \
- } \
- } while(0)
+#define TkMacOSXCheckTmpQdRgnEmpty() \
+ do { \
+ if (!EmptyRgn(tkMacOSXtmpQdRgn)) { \
+ Tcl_Panic("tkMacOSXtmpQdRgn nonempty"); \
+ } \
+ } while(0)
#else /* TK_MAC_DEBUG */
#define TkMacOSXDbgMsg(m, ...)
#define TkMacOSXDbgOSErr(f, err)
@@ -242,9 +249,7 @@ MODULE_SCOPE float tkMacOSXToolboxVersionNumber;
symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \
STRINGIFY(_##symbol)); \
}
-MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module,
- const char* symbol);
-
+
/*
* Structure encapsulating current drawing environment.
*/
@@ -272,69 +277,78 @@ MODULE_SCOPE int tkMacOSXUseCGDrawing;
*/
#if 0
-MODULE_SCOPE void TkMacOSXEmtpyRegion(TkRegion r);
-MODULE_SCOPE int TkMacOSXIsEmptyRegion(TkRegion r);
+MODULE_SCOPE void TkMacOSXEmtpyRegion(TkRegion r);
+MODULE_SCOPE int TkMacOSXIsEmptyRegion(TkRegion r);
#endif
-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 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);
-MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape(
- HIMutableShapeRef inDestShape, HIShapeRef inSrcShape);
+ const CGRect *inRect);
+MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape(
+ HIMutableShapeRef inDestShape,
+ HIShapeRef inSrcShape);
#if 0
-MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithRect(HIMutableShapeRef inShape,
- const CGRect *inRect);
+MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithRect(HIMutableShapeRef inShape,
+ const CGRect *inRect);
#endif
-MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect(
- HIMutableShapeRef inShape, const CGRect *inRect);
-MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape,
- const CGRect *inRect);
-MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1,
- HIShapeRef inShape2, HIMutableShapeRef outResult);
+MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect(
+ HIMutableShapeRef inShape, const CGRect *inRect);
+MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape,
+ const CGRect *inRect);
+MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1,
+ HIShapeRef inShape2, HIMutableShapeRef outResult);
/*
* Prototypes of TkAqua internal procs.
*/
-MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display);
-MODULE_SCOPE void TkMacOSXInitScrollbarMetrics(void);
-MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable);
-MODULE_SCOPE void TkMacOSXInitCarbonEvents(Tcl_Interp *interp);
-MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable,
- int antiAlias);
-MODULE_SCOPE void TkMacOSXInitKeyboard(Tcl_Interp *interp);
-MODULE_SCOPE int TkMacOSXGenerateFocusEvent(Window window, int activeFlag);
-MODULE_SCOPE int TkMacOSXGenerateParentMenuSelectEvent(MenuRef menu);
-MODULE_SCOPE int TkMacOSXGenerateMenuSelectEvent(MenuRef menu,
- MenuItemIndex index);
-MODULE_SCOPE void TkMacOSXClearActiveMenu(MenuRef menu);
+MODULE_SCOPE void * TkMacOSXGetNamedSymbol(const char *module,
+ const char *symbol);
+MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display);
+MODULE_SCOPE void TkMacOSXInitScrollbarMetrics(void);
+MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp,
+ int enable);
+MODULE_SCOPE void TkMacOSXInitCarbonEvents(Tcl_Interp *interp);
+MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable,
+ int antiAlias);
+MODULE_SCOPE void TkMacOSXInitKeyboard(Tcl_Interp *interp);
+MODULE_SCOPE int TkMacOSXGenerateFocusEvent(Window window,
+ int activeFlag);
+MODULE_SCOPE int TkMacOSXGenerateParentMenuSelectEvent(MenuRef menu);
+MODULE_SCOPE int TkMacOSXGenerateMenuSelectEvent(MenuRef menu,
+ MenuItemIndex index);
+MODULE_SCOPE void TkMacOSXClearActiveMenu(MenuRef menu);
MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr);
-MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr);
-MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window);
+MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr);
+MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window);
MODULE_SCOPE EventModifiers TkMacOSXModifierState(void);
-MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, int useCG,
- TkMacOSXDrawingContext *dcPtr);
-MODULE_SCOPE void TkMacOSXRestoreDrawingContext(TkMacOSXDrawingContext *dcPtr);
-MODULE_SCOPE void TkMacOSXSetColorInPort(unsigned long pixel, int fg,
- PixPatHandle penPat, CGrafPtr port);
-MODULE_SCOPE void TkMacOSXSetColorInContext(unsigned long pixel,
- CGContextRef context);
-MODULE_SCOPE int TkMacOSXRunTclEventLoop(void);
-MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer(void);
-MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer(void);
-MODULE_SCOPE void TkMacOSXTrackingLoop(int tracking);
-MODULE_SCOPE OSStatus TkMacOSXReceiveAndDispatchEvent(void);
-MODULE_SCOPE void TkMacOSXInstallWindowCarbonEventHandler(Tcl_Interp *interp,
- WindowRef window);
-MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, WindowRef window,
- int fullscreen, Tcl_Interp *interp);
-MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, int active);
-MODULE_SCOPE void TkMacOSXBringWindowForward(WindowRef wRef);
-MODULE_SCOPE WindowRef TkMacOSXDrawableWindow(Drawable drawable);
-MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds);
-MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable);
-MODULE_SCOPE Tcl_Obj* TkMacOSXGetStringObjFromCFString(CFStringRef str);
+MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc,
+ int useCG, TkMacOSXDrawingContext *dcPtr);
+MODULE_SCOPE void TkMacOSXRestoreDrawingContext(
+ TkMacOSXDrawingContext *dcPtr);
+MODULE_SCOPE void TkMacOSXSetColorInPort(unsigned long pixel, int fg,
+ PixPatHandle penPat, CGrafPtr port);
+MODULE_SCOPE void TkMacOSXSetColorInContext(unsigned long pixel,
+ CGContextRef context);
+MODULE_SCOPE int TkMacOSXRunTclEventLoop(void);
+MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer(void);
+MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer(void);
+MODULE_SCOPE void TkMacOSXTrackingLoop(int tracking);
+MODULE_SCOPE OSStatus TkMacOSXReceiveAndDispatchEvent(void);
+MODULE_SCOPE void TkMacOSXInstallWindowCarbonEventHandler(
+ Tcl_Interp *interp, WindowRef window);
+MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr,
+ WindowRef window, int fullscreen,
+ Tcl_Interp *interp);
+MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr,
+ int active);
+MODULE_SCOPE void TkMacOSXBringWindowForward(WindowRef wRef);
+MODULE_SCOPE WindowRef TkMacOSXDrawableWindow(Drawable drawable);
+MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds);
+MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable);
+MODULE_SCOPE Tcl_Obj * TkMacOSXGetStringObjFromCFString(CFStringRef str);
#endif /* _TKMACPRIV */
diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c
index 28ec005..b52596f 100644
--- a/macosx/tkMacOSXRegion.c
+++ b/macosx/tkMacOSXRegion.c
@@ -7,10 +7,10 @@
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.11 2007/12/13 15:27:10 dgp Exp $
+ * RCS: @(#) $Id: tkMacOSXRegion.c,v 1.12 2008/10/27 11:55:45 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -21,8 +21,8 @@
*
* TkCreateRegion --
*
- * Implements the equivelent of the X window function
- * XCreateRegion. See X window documentation for more details.
+ * Implements the equivelent of the X window function XCreateRegion. See
+ * Xwindow documentation for more details.
*
* Results:
* Returns an allocated region handle.
@@ -44,8 +44,8 @@ TkCreateRegion(void)
*
* TkDestroyRegion --
*
- * Implements the equivelent of the X window function
- * XDestroyRegion. See X window documentation for more details.
+ * Implements the equivelent of the X window function XDestroyRegion. See
+ * Xwindow documentation for more details.
*
* Results:
* None.
@@ -70,8 +70,8 @@ TkDestroyRegion(
*
* TkIntersectRegion --
*
- * Implements the equivalent of the X window function
- * XIntersectRegion. See X window documentation for more details.
+ * Implements the equivalent of the X window function XIntersectRegion.
+ * See Xwindow documentation for more details.
*
* Results:
* None.
@@ -97,8 +97,8 @@ TkIntersectRegion(
*
* TkSubtractRegion --
*
- * Implements the equivalent of the X window function
- * XSubtractRegion. See X window documentation for more details.
+ * Implements the equivalent of the X window function XSubtractRegion.
+ * See X window documentation for more details.
*
* Results:
* None.
@@ -125,8 +125,7 @@ TkSubtractRegion(
* TkUnionRectWithRegion --
*
* Implements the equivelent of the X window function
- * XUnionRectWithRegion. See X window documentation for more
- * details.
+ * XUnionRectWithRegion. See Xwindow documentation for more details.
*
* Results:
* None.
@@ -163,8 +162,8 @@ TkUnionRectWithRegion(
*
* TkRectInRegion --
*
- * Implements the equivelent of the X window function
- * XRectInRegion. See X window documentation for more details.
+ * Implements the equivelent of the X window function XRectInRegion. See
+ * Xwindow documentation for more details.
*
* Results:
* Returns RectanglePart or RectangleOut. Note that this is not a
@@ -218,7 +217,7 @@ TkRectInRegion(
#endif
CFRelease(sectRgn);
CFRelease(rectRgn);
- ) TK_ENDIF
+ ) TK_ENDIF;
return result;
}
@@ -227,8 +226,8 @@ TkRectInRegion(
*
* TkClipBox --
*
- * Implements the equivelent of the X window function XClipBox.
- * See X window documentation for more details.
+ * Implements the equivelent of the X window function XClipBox. See
+ * Xwindow documentation for more details.
*
* Results:
* None.
@@ -258,8 +257,8 @@ TkClipBox(
*
* TkpBuildRegionFromAlphaData --
*
- * Set up a rectangle of the given region based on the supplied
- * alpha data.
+ * Set up a rectangle of the given region based on the supplied alpha
+ * data.
*
* Results:
* None
@@ -290,13 +289,20 @@ TkpBuildRegionFromAlphaData(
for (y1 = 0; y1 < height; y1++) {
lineDataPtr = dataPtr;
for (x1 = 0; x1 < width; x1 = end) {
- /* search for first non-transparent pixel */
+ /*
+ * Search for first non-transparent pixel.
+ */
+
while ((x1 < width) && !*lineDataPtr) {
x1++;
lineDataPtr += pixelStride;
}
end = x1;
- /* search for first transparent pixel */
+
+ /*
+ * Search for first transparent pixel.
+ */
+
while ((end < width) && *lineDataPtr) {
end++;
lineDataPtr += pixelStride;
@@ -509,7 +515,7 @@ TkMacOSXHIShapeCreateEmpty(void)
CFRelease(rgn);
}
result = HIShapeCreateCopy(emptyRgn);
- ) TK_ENDIF
+ ) TK_ENDIF;
return result;
}
@@ -527,7 +533,7 @@ TkMacOSXHIShapeCreateMutableWithRect(
result = HIShapeCreateMutableCopy(rgn);
CFRelease(rgn);
- ) TK_ENDIF
+ ) TK_ENDIF;
return result;
}
@@ -546,7 +552,7 @@ TkMacOSXHIShapeSetWithShape(
if (result == noErr) {
result = HIShapeDifference(inSrcShape, inDestShape, inDestShape);
}
- ) TK_ENDIF
+ ) TK_ENDIF;
return result;
}
@@ -595,7 +601,7 @@ TkMacOSHIShapeUnionWithRect(
result = TkMacOSHIShapeUnion(rgn, inShape, inShape);
CFRelease(rgn);
- ) TK_ENDIF
+ ) TK_ENDIF;
return result;
}
@@ -611,7 +617,10 @@ TkMacOSHIShapeUnion(
TK_IF_HI_TOOLBOX (4,
result = HIShapeUnion(inShape1, inShape2, outResult);
) TK_ELSE_HI_TOOLBOX (4,
- /* Workaround HIShapeUnion bug in 10.3 and earlier */
+ /*
+ * Workaround HIShapeUnion bug in 10.3 and earlier.
+ */
+
HIShapeRef rgn = HIShapeCreateCopy(outResult);
result = HIShapeUnion(inShape1, inShape2, (HIMutableShapeRef) rgn);
@@ -622,7 +631,16 @@ TkMacOSHIShapeUnion(
}
}
CFRelease(rgn);
- ) TK_ENDIF
+ ) TK_ENDIF;
return result;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 5aa4a8a..ca72bd5 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -7,10 +7,10 @@
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2006-2008 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.28 2008/06/19 00:14:10 das Exp $
+ * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.29 2008/10/27 11:55:45 dkf Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -27,11 +27,38 @@
* Prototypes for functions used only in this file.
*/
-static void MoveResizeWindow(MacDrawable *macWin);
-static void GenerateConfigureNotify(TkWindow *winPtr, int includeWin);
-static void UpdateOffsets(TkWindow *winPtr, int deltaX, int deltaY);
-static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr);
+static void MoveResizeWindow(MacDrawable *macWin);
+static void GenerateConfigureNotify(TkWindow *winPtr,
+ int includeWin);
+static void UpdateOffsets(TkWindow *winPtr, int deltaX,
+ int deltaY);
+static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr);
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * AllocGWorld --
+ * Simplifies the allocation of new drawable ports.
+ *
+ *----------------------------------------------------------------------
+ */
+static inline void
+AllocGWorld(
+ int width,
+ int height,
+ int mono,
+ CGrafPtr *grafPtrPtr)
+{
+ Rect bounds = {0, 0, height, width};
+
+#ifdef __LITTLE_ENDIAN__
+ ChkErr(NewGWorld, grafPtrPtr, mono ? 1 : 0, &bounds, NULL, NULL,
+ kNativeEndianPixMap);
+#else
+ ChkErr(NewGWorld, grafPtrPtr, mono ? 1 : 0, &bounds, NULL, NULL, 0);
+#endif
+}
/*
*----------------------------------------------------------------------
@@ -51,45 +78,24 @@ static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr);
void
XDestroyWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window) /* Window. */
{
MacDrawable *macWin = (MacDrawable *) window;
+ WindowRef winRef;
/*
- * Remove any dangling pointers that may exist if
- * the window we are deleting is being tracked by
- * the grab code.
+ * Remove any dangling pointers that may exist if the window we are
+ * deleting is being tracked by the grab code.
*/
TkPointerDeadWindow(macWin->winPtr);
macWin->toplevel->referenceCount--;
- if (Tk_IsTopLevel(macWin->winPtr)) {
- WindowRef winRef;
- /*
- * We are relying on the Activate Mac OS event to pass the
- * focus away from a window that is getting Destroyed to the
- * Front non-floating window. BUT we don't get activate events
- * when a floating window is destroyed - since the front non-floating
- * window doesn't in fact get activated... So maybe we can check here
- * and if we are destroying a floating window, we can pass the focus
- * back to the front non-floating window...
- */
-
- if (macWin->grafPtr != NULL) {
- TkWindow *focusPtr = TkGetFocusWin(macWin->winPtr);
- if (focusPtr == NULL || (focusPtr->mainPtr->winPtr == macWin->winPtr)) {
- winRef = TkMacOSXDrawableWindow(window);
- if (TkpIsWindowFloating (winRef)) {
- Window window;
-
- window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
- if (window != None) {
- TkMacOSXGenerateFocusEvent(window, 1);
- }
- }
- }
+ if (!Tk_IsTopLevel(macWin->winPtr)) {
+ TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
+ if (macWin->winPtr->parentPtr != NULL) {
+ TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
}
if (macWin->visRgn) {
CFRelease(macWin->visRgn);
@@ -98,98 +104,121 @@ XDestroyWindow(
CFRelease(macWin->aboveVisRgn);
}
- /*
- * Delete the Mac window and remove it from the windowTable.
- * The window could be NULL if the window was never mapped.
- * However, we don't do this for embedded windows, they don't
- * go in the window list, and they do not own their portPtr's.
- */
+ if (macWin->toplevel->referenceCount == 0) {
+ ckfree((char *) macWin->toplevel);
+ }
+ ckfree((char *) macWin);
+ return;
+ }
- if (!(Tk_IsEmbedded(macWin->winPtr))) {
- WindowRef winRef = TkMacOSXDrawableWindow(window);
-
- if (winRef) {
- TkMacOSXWindowList *listPtr, *prevPtr;
- WindowGroupRef group;
-
- if (GetWindowProperty(winRef, 'Tk ', 'TsGp', sizeof(group),
- NULL, &group) == noErr) {
- TkDisplay *dispPtr = TkGetDisplayList();
- ItemCount i = CountWindowGroupContents(group,
- kWindowGroupContentsReturnWindows);
-
- while (i > 0) {
- WindowRef macWin;
-
- ChkErr(GetIndexedWindow, group, i--, 0, &macWin);
- if (macWin) {
- WindowGroupRef newGroup = NULL;
- Window window = TkMacOSXGetXWindow(macWin);
-
- if (window != None) {
- TkWindow * winPtr = (TkWindow *)Tk_IdToWindow(
- dispPtr->display, window);
-
- if (winPtr && winPtr->wmInfoPtr) {
- newGroup = GetWindowGroupOfClass(
- winPtr->wmInfoPtr->macClass);
- }
- }
- if (!newGroup) {
- newGroup = GetWindowGroupOfClass(
- kDocumentWindowClass);
- }
- ChkErr(SetWindowGroup, macWin, newGroup);
- }
+ /*
+ * We are relying on the Activate Mac OS event to pass the focus away from
+ * a window that is getting Destroyed to the Front non-floating window. BUT
+ * we don't get activate events when a floating window is destroyed, since
+ * the front non-floating window doesn't in fact get activated... So maybe
+ * we can check here and if we are destroying a floating window, we can
+ * pass the focus back to the front non-floating window...
+ */
- }
- ChkErr(SetWindowGroupOwner, group, NULL);
- ChkErr(ReleaseWindowGroup, group);
+ if (macWin->grafPtr != NULL) {
+ TkWindow *focusPtr = TkGetFocusWin(macWin->winPtr);
+
+ if (focusPtr == NULL
+ || (focusPtr->mainPtr->winPtr == macWin->winPtr)) {
+ winRef = TkMacOSXDrawableWindow(window);
+ if (TkpIsWindowFloating (winRef)) {
+ Window window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
+
+ if (window != None) {
+ TkMacOSXGenerateFocusEvent(window, 1);
}
- TkMacOSXUnregisterMacWindow(winRef);
- DisposeWindow(winRef);
-
- for (listPtr = tkMacOSXWindowListPtr, prevPtr = NULL;
- tkMacOSXWindowListPtr != NULL;
- prevPtr = listPtr, listPtr = listPtr->nextPtr) {
- if (listPtr->winPtr == macWin->winPtr) {
- if (prevPtr == NULL) {
- tkMacOSXWindowListPtr = listPtr->nextPtr;
- } else {
- prevPtr->nextPtr = listPtr->nextPtr;
+ }
+ }
+ }
+ if (macWin->visRgn) {
+ CFRelease(macWin->visRgn);
+ }
+ if (macWin->aboveVisRgn) {
+ CFRelease(macWin->aboveVisRgn);
+ }
+
+ /*
+ * Delete the Mac window and remove it from the windowTable. The window
+ * could be NULL if the window was never mapped. However, we don't do this
+ * for embedded windows, they don't go in the window list, and they do not
+ * own their portPtr's.
+ */
+
+ if (!Tk_IsEmbedded(macWin->winPtr)) {
+ WindowRef winRef = TkMacOSXDrawableWindow(window);
+
+ if (winRef) {
+ TkMacOSXWindowList *listPtr, *prevPtr;
+ WindowGroupRef group;
+
+ if (GetWindowProperty(winRef, 'Tk ', 'TsGp', sizeof(group), NULL,
+ &group) == noErr) {
+ TkDisplay *dispPtr = TkGetDisplayList();
+ ItemCount i = CountWindowGroupContents(group,
+ kWindowGroupContentsReturnWindows);
+ WindowRef macWin;
+ WindowGroupRef newGroup;
+ Window window;
+
+ while (i > 0) {
+ ChkErr(GetIndexedWindow, group, i--, 0, &macWin);
+ if (!macWin) {
+ continue;
+ }
+
+ window = TkMacOSXGetXWindow(macWin);
+ newGroup = NULL;
+ if (window != None) {
+ TkWindow *winPtr = (TkWindow *)
+ Tk_IdToWindow(dispPtr->display, window);
+
+ if (winPtr && winPtr->wmInfoPtr) {
+ newGroup = GetWindowGroupOfClass(
+ winPtr->wmInfoPtr->macClass);
}
- ckfree((char *) listPtr);
- break;
}
+ if (!newGroup) {
+ newGroup =
+ GetWindowGroupOfClass(kDocumentWindowClass);
+ }
+ ChkErr(SetWindowGroup, macWin, newGroup);
+ }
+ ChkErr(SetWindowGroupOwner, group, NULL);
+ ChkErr(ReleaseWindowGroup, group);
+ }
+ TkMacOSXUnregisterMacWindow(winRef);
+ DisposeWindow(winRef);
+
+ for (listPtr=tkMacOSXWindowListPtr, prevPtr=NULL;
+ tkMacOSXWindowListPtr != NULL;
+ prevPtr=listPtr, listPtr=listPtr->nextPtr) {
+ if (listPtr->winPtr == macWin->winPtr) {
+ if (prevPtr == NULL) {
+ tkMacOSXWindowListPtr = listPtr->nextPtr;
+ } else {
+ prevPtr->nextPtr = listPtr->nextPtr;
+ }
+ ckfree((char *) listPtr);
+ break;
}
}
}
+ }
- macWin->grafPtr = NULL;
+ macWin->grafPtr = NULL;
- /*
- * Delay deletion of a toplevel data structure untill all
- * children have been deleted.
- */
- if (macWin->toplevel->referenceCount == 0) {
- ckfree((char *) macWin->toplevel);
- }
- } else {
- TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
- if (macWin->winPtr->parentPtr != NULL) {
- TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
- }
- if (macWin->visRgn) {
- CFRelease(macWin->visRgn);
- }
- if (macWin->aboveVisRgn) {
- CFRelease(macWin->aboveVisRgn);
- }
+ /*
+ * Delay deletion of a toplevel data structure untill all children have
+ * been deleted.
+ */
- if (macWin->toplevel->referenceCount == 0) {
- ckfree((char *) macWin->toplevel);
- }
- ckfree((char *) macWin);
+ if (macWin->toplevel->referenceCount == 0) {
+ ckfree((char *) macWin->toplevel);
}
}
@@ -198,8 +227,8 @@ XDestroyWindow(
*
* XMapWindow --
*
- * Map the given X Window to the screen. See X window documentation
- * for more details.
+ * Map the given X Window to the screen. See X window documentation for
+ * more details.
*
* Results:
* None.
@@ -212,19 +241,20 @@ XDestroyWindow(
void
XMapWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window) /* Window. */
{
MacDrawable *macWin = (MacDrawable *) window;
XEvent event;
/*
- * Under certain situations it's possible for this function to be
- * called before the toplevel window it's associated with has actually
- * been mapped. In that case we need to create the real Macintosh
- * window now as this function as well as other X functions assume that
- * the portPtr is valid.
+ * Under certain situations it's possible for this function to be called
+ * before the toplevel window it's associated with has actually been
+ * mapped. In that case we need to create the real Macintosh window now as
+ * this function as well as other X functions assume that the portPtr is
+ * valid.
*/
+
if (!TkMacOSXHostToplevelExists(macWin->toplevel->winPtr)) {
TkMacOSXMakeRealWindowExist(macWin->toplevel->winPtr);
}
@@ -237,6 +267,7 @@ XMapWindow(
* XXX This should be ShowSheetWindow for kSheetWindowClass
* XXX windows that have a wmPtr->master parent set.
*/
+
WindowRef wRef = TkMacOSXDrawableWindow(window);
if ((macWin->winPtr->wmInfoPtr->macClass == kSheetWindowClass)
@@ -250,8 +281,7 @@ XMapWindow(
TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr);
/*
- * We only need to send the MapNotify event
- * for toplevel windows.
+ * We only need to send the MapNotify event for toplevel windows.
*/
event.xany.serial = display->request;
@@ -265,7 +295,7 @@ XMapWindow(
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
} else {
/*
- * Generate damage for that area of the window
+ * Generate damage for that area of the window.
*/
TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
@@ -322,8 +352,8 @@ NotifyVisibility(
*
* XUnmapWindow --
*
- * Unmap the given X Window to the screen. See X window
- * documentation for more details.
+ * Unmap the given X Window to the screen. See X window documentation for
+ * more details.
*
* Results:
* None.
@@ -336,7 +366,7 @@ NotifyVisibility(
void
XUnmapWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window) /* Window. */
{
MacDrawable *macWin = (MacDrawable *) window;
@@ -345,12 +375,13 @@ XUnmapWindow(
display->request++;
macWin->winPtr->flags &= ~TK_MAPPED;
if (Tk_IsTopLevel(macWin->winPtr)) {
- if (!Tk_IsEmbedded(macWin->winPtr)
- && macWin->winPtr->wmInfoPtr->hints.initial_state != IconicState) {
+ if (!Tk_IsEmbedded(macWin->winPtr) &&
+ macWin->winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
/*
* XXX This should be HideSheetWindow for kSheetWindowClass
* XXX windows that have a wmPtr->master parent set.
*/
+
WindowRef wref = TkMacOSXDrawableWindow(window);
if ((macWin->winPtr->wmInfoPtr->macClass == kSheetWindowClass)
@@ -363,9 +394,9 @@ XUnmapWindow(
TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr);
/*
- * We only need to send the UnmapNotify event
- * for toplevel windows.
+ * We only need to send the UnmapNotify event for toplevel windows.
*/
+
event.xany.serial = display->request;
event.xany.send_event = False;
event.xany.display = display;
@@ -390,8 +421,8 @@ XUnmapWindow(
*
* XResizeWindow --
*
- * Resize a given X window. See X windows documentation for
- * further details.
+ * Resize a given X window. See X windows documentation for further
+ * details.
*
* Results:
* None.
@@ -404,7 +435,7 @@ XUnmapWindow(
void
XResizeWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window, /* Window. */
unsigned int width,
unsigned int height)
@@ -447,13 +478,13 @@ XResizeWindow(
void
XMoveResizeWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window, /* Window. */
int x, int y,
unsigned int width,
unsigned int height)
{
- MacDrawable * macWin = (MacDrawable *) window;
+ MacDrawable *macWin = (MacDrawable *) window;
display->request++;
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
@@ -492,10 +523,9 @@ XMoveResizeWindow(
void
XMoveWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window, /* Window. */
- int x,
- int y)
+ int x, int y)
{
MacDrawable *macWin = (MacDrawable *) window;
@@ -538,6 +568,7 @@ MoveResizeWindow(
/*
* Find the Parent window, for an embedded window it will be its container.
*/
+
if (Tk_IsEmbedded(macWin->winPtr)) {
TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr);
@@ -545,10 +576,10 @@ MoveResizeWindow(
macParent = contWinPtr->privatePtr;
} else {
/*
- * Here we should handle out of process embedding.
- * At this point, we are assuming that the changes.x,y is not
- * maintained, if you need the info get it from Tk_GetRootCoords,
- * and that the toplevel sits at 0,0 when it is drawn.
+ * Here we should handle out of process embedding. At this point,
+ * we are assuming that the changes.x,y is not maintained, if you
+ * need the info get it from Tk_GetRootCoords, and that the
+ * toplevel sits at 0,0 when it is drawn.
*/
}
} else {
@@ -559,6 +590,7 @@ MoveResizeWindow(
macParent = macWin->winPtr->parentPtr->privatePtr;
parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width;
}
+
if (macParent) {
deltaX = macParent->xOff + parentBorderwidth +
macWin->winPtr->changes.x - macWin->xOff;
@@ -583,10 +615,9 @@ MoveResizeWindow(
*
* GenerateConfigureNotify --
*
- * Generates ConfigureNotify events for all the child widgets
- * of the widget passed in the winPtr parameter. If includeWin
- * is true, also generates ConfigureNotify event for the
- * widget itself.
+ * Generates ConfigureNotify events for all the child widgets of the
+ * widget passed in the winPtr parameter. If includeWin is true, also
+ * generates ConfigureNotify event for the widget itself.
*
* Results:
* None.
@@ -598,12 +629,14 @@ MoveResizeWindow(
*/
static void
-GenerateConfigureNotify (TkWindow *winPtr, int includeWin)
+GenerateConfigureNotify(
+ TkWindow *winPtr,
+ int includeWin)
{
TkWindow *childPtr;
for (childPtr = winPtr->childList; childPtr != NULL;
- childPtr = childPtr->nextPtr) {
+ childPtr = childPtr->nextPtr) {
if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) {
continue;
}
@@ -632,7 +665,7 @@ GenerateConfigureNotify (TkWindow *winPtr, int includeWin)
void
XRaiseWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window) /* Window. */
{
MacDrawable *macWin = (MacDrawable *) window;
@@ -666,7 +699,7 @@ XRaiseWindow(
void
XLowerWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window window) /* Window. */
{
MacDrawable *macWin = (MacDrawable *) window;
@@ -687,26 +720,25 @@ XLowerWindow(
*
* XConfigureWindow --
*
- * Change the size, position, stacking, or border of the specified
- * window.
+ * Change the size, position, stacking, or border of the specified window.
*
* Results:
* None.
*
* Side effects:
- * Changes the attributes of the specified window. Note that we
- * ignore the passed in values and use the values stored in the
- * TkWindow data structure.
+ * Changes the attributes of the specified window. Note that we ignore the
+ * passed in values and use the values stored in the TkWindow data
+ * structure.
*
*----------------------------------------------------------------------
*/
void
XConfigureWindow(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Window w, /* Window. */
unsigned int value_mask,
- XWindowChanges* values)
+ XWindowChanges *values)
{
MacDrawable *macWin = (MacDrawable *) w;
TkWindow *winPtr = macWin->winPtr;
@@ -723,10 +755,10 @@ XConfigureWindow(
}
/*
- * Change the stacking order of the window. Tk actuall keeps all
- * the information we need for stacking order. All we need to do
- * is make sure the clipping regions get updated and generate damage
- * that will ensure things get drawn correctly.
+ * Change the stacking order of the window. Tk actually keeps all the
+ * information we need for stacking order. All we need to do is make sure
+ * the clipping regions get updated and generate damage that will ensure
+ * things get drawn correctly.
*/
if (value_mask & CWStackMode) {
@@ -749,10 +781,10 @@ XConfigureWindow(
*
* TkMacOSXUpdateClipRgn --
*
- * This function updates the cliping regions for a given window
- * and all of its children. Once updated the TK_CLIP_INVALID flag
- * in the subwindow data structure is unset. The TK_CLIP_INVALID
- * flag should always be unset before any drawing is attempted.
+ * This function updates the cliping regions for a given window and all of
+ * its children. Once updated the TK_CLIP_INVALID flag in the subwindow
+ * data structure is unset. The TK_CLIP_INVALID flag should always be
+ * unset before any drawing is attempted.
*
* Results:
* None.
@@ -789,24 +821,21 @@ TkMacOSXUpdateClipRgn(
rgn = TkMacOSXHIShapeCreateMutableWithRect(&bounds);
/*
- * Clip away the area of any windows that may obscure this
- * window.
+ * Clip away the area of any windows that may obscure this window.
* For a non-toplevel window, first, clip to the parents visible
- * clip region.
- * Second, clip away any siblings that are higher in the
- * stacking order.
- * For an embedded toplevel, just clip to the container's visible
- * clip region. Remember, we only allow one contained window
- * in a frame, and don't support any other widgets in the frame
- * either. This is not currently enforced, however.
+ * clip region. Second, clip away any siblings that are higher in
+ * the stacking order. For an embedded toplevel, just clip to the
+ * container's visible clip region. Remember, we only allow one
+ * contained window in a frame, and don't support any other widgets
+ * in the frame either. This is not currently enforced, however.
*/
if (!Tk_IsTopLevel(winPtr)) {
TkMacOSXUpdateClipRgn(winPtr->parentPtr);
if (winPtr->parentPtr) {
ChkErr(HIShapeIntersect,
- winPtr->parentPtr->privatePtr->aboveVisRgn, rgn,
- rgn);
+ winPtr->parentPtr->privatePtr->aboveVisRgn,
+ rgn, rgn);
}
win2Ptr = winPtr;
while ((win2Ptr = win2Ptr->nextPtr)) {
@@ -854,10 +883,10 @@ TkMacOSXUpdateClipRgn(
macWin->aboveVisRgn = HIShapeCreateCopy(rgn);
/*
- * The final clip region is the aboveVis region (or visible
- * region) minus all the children of this window.
- * If the window is a container, we must also subtract the region
- * of the embedded window.
+ * The final clip region is the aboveVis region (or visible region)
+ * minus all the children of this window. If the window is a
+ * container, we must also subtract the region of the embedded
+ * window.
*/
win2Ptr = winPtr->childList;
@@ -886,6 +915,7 @@ TkMacOSXUpdateClipRgn(
* TODO: Here we should handle out of process embedding.
*/
}
+
if (rgnChanged) {
HIShapeRef diffRgn = HIShapeCreateDifference(
macWin->aboveVisRgn, rgn);
@@ -929,8 +959,8 @@ TkMacOSXUpdateClipRgn(
*
* TkMacOSXVisableClipRgn --
*
- * This function returnd the Macintosh cliping region for the
- * given window. A NULL Rgn means the window is not visible.
+ * This function returnd the Macintosh cliping region for the given
+ * window. A NULL Rgn means the window is not visible.
*
* Results:
* The region.
@@ -962,8 +992,8 @@ TkMacOSXVisableClipRgn(
*
* TkMacOSXInvalidateWindow --
*
- * This function makes the window as invalid will generate damage
- * for the window.
+ * This function makes the window as invalid will generate damage for the
+ * window.
*
* Results:
* None.
@@ -1038,7 +1068,7 @@ TkMacOSXDrawableWindow(
* This function returns the Graphics Port for a given X drawable.
*
* Results:
- * A CGrafPort . Either an off screen pixmap or a Window.
+ * A CGrafPort. Either an off screen pixmap or a Window.
*
* Side effects:
* None.
@@ -1053,66 +1083,67 @@ TkMacOSXGetDrawablePort(
MacDrawable *macWin = (MacDrawable *) drawable;
CGrafPtr resultPort = NULL;
- if (macWin) {
- if (macWin->toplevel) {
- /*
- * If the Drawable is in an embedded window, use the Port of its
- * container.
- *
- * TRICKY POINT: we can have cases when a toplevel is being
- * destroyed where the winPtr for the toplevel has been freed, but
- * the children are not all the way destroyed. The children will
- * call this function as they are being destroyed, but
- * Tk_IsEmbedded will return garbage. So we check the copy of the
- * TK_EMBEDDED flag we put into the toplevel's macWin flags.
- */
+ if (!macWin) {
+ return NULL;
+ }
- if (macWin->toplevel->flags & TK_EMBEDDED) {
- TkWindow *contWinPtr;
+ /*
+ * Handle toplevel windows.
+ */
- contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+ if (macWin->toplevel) {
+ TkWindow *contWinPtr;
- if (contWinPtr != NULL) {
- resultPort = TkMacOSXGetDrawablePort(
- (Drawable) contWinPtr->privatePtr);
- } else if (tkMacOSXEmbedHandler != NULL) {
- resultPort = tkMacOSXEmbedHandler->getPortProc(
- (Tk_Window) macWin->winPtr);
- }
+ if (!(macWin->toplevel->flags & TK_EMBEDDED)) {
+ return macWin->toplevel->grafPtr;
+ }
- if (!resultPort) {
- /*
- * FIXME: So far as I can tell, the only time that this
- * happens is when we are tearing down an embedded child
- * interpreter, and most of the time, this is harmless...
- * However, we really need to find why the embedding loses.
- */
- TkMacOSXDbgMsg("Couldn't find container");
- }
+ /*
+ * If the Drawable is in an embedded window, use the Port of its
+ * container.
+ *
+ * TRICKY POINT: we can have cases when a toplevel is being destroyed
+ * where the winPtr for the toplevel has been freed, but the children
+ * are not all the way destroyed. The children will call this function
+ * as they are being destroyed, but Tk_IsEmbedded will return garbage.
+ * So we check the copy of the TK_EMBEDDED flag we put into the
+ * toplevel's macWin flags.
+ */
- /*
- * TODO: Here we should handle out of process embedding.
- */
- } else {
- resultPort = macWin->toplevel->grafPtr;
- }
- } else {
- if ((macWin->flags & TK_IS_PIXMAP) && !macWin->grafPtr) {
- Rect bounds = {0, 0, macWin->size.height, macWin->size.width};
+ contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
- ChkErr(NewGWorld, &macWin->grafPtr,
- (macWin->flags & TK_IS_BW_PIXMAP) ? 1 : 0,
- &bounds, NULL, NULL, 0
-#ifdef __LITTLE_ENDIAN__
- | kNativeEndianPixMap
-#endif
- );
- }
- resultPort = macWin->grafPtr;
+ resultPort = NULL;
+ if (contWinPtr != NULL) {
+ resultPort = TkMacOSXGetDrawablePort((Drawable)
+ contWinPtr->privatePtr);
+ } else if (tkMacOSXEmbedHandler != NULL) {
+ resultPort = tkMacOSXEmbedHandler->getPortProc((Tk_Window)
+ macWin->winPtr);
}
+
+ if (!resultPort) {
+ /*
+ * FIXME: So far as I can tell, the only time that this happens is
+ * when we are tearing down an embedded child interpreter, and most
+ * of the time, this is harmless... However, we really need to find
+ * why the embedding loses.
+ */
+
+ TkMacOSXDbgMsg("Couldn't find container");
+ }
+
+ /*
+ * TODO: Here we should handle out of process embedding.
+ */
+
+ return resultPort;
}
- return resultPort;
+ if ((macWin->flags & TK_IS_PIXMAP) && !macWin->grafPtr) {
+ AllocGWorld(macWin->size.width, macWin->size.height,
+ macWin->flags & TK_IS_BW_PIXMAP, &macWin->grafPtr);
+ }
+ return macWin->grafPtr;
}
/*
@@ -1138,27 +1169,24 @@ TkMacOSXGetRootControl(
/*
* will probably need to fix this up for embedding
*/
+
MacDrawable *macWin = (MacDrawable *) drawable;
- ControlRef result = NULL;
+ TkWindow *contWinPtr;
if (macWin == NULL) {
return NULL;
}
+
if (!(macWin->toplevel->flags & TK_EMBEDDED)) {
return macWin->toplevel->rootControl;
- } else {
- TkWindow *contWinPtr;
+ }
- contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+ contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+ if (contWinPtr == NULL) {
+ return NULL;
+ }
- if (contWinPtr != NULL) {
- result = TkMacOSXGetRootControl(
- (Drawable) contWinPtr->privatePtr);
- } else if (tkMacOSXEmbedHandler != NULL) {
- result = NULL;
- }
- }
- return result;
+ return TkMacOSXGetRootControl((Drawable) contWinPtr->privatePtr);
}
/*
@@ -1166,17 +1194,17 @@ TkMacOSXGetRootControl(
*
* TkMacOSXInvalClipRgns --
*
- * This function invalidates the clipping regions for a given
- * window and all of its children. This function should be
- * called whenever changes are made to subwindows that would
- * affect the size or position of windows.
+ * This function invalidates the clipping regions for a given window and
+ * all of its children. This function should be called whenever changes
+ * are made to subwindows that would affect the size or position of
+ * windows.
*
* Results:
* None.
*
* Side effects:
- * The cliping regions for the window and its children are
- * mark invalid. (Make sure they are valid before drawing.)
+ * The cliping regions for the window and its children are mark invalid.
+ * (Make sure they are valid before drawing.)
*
*----------------------------------------------------------------------
*/
@@ -1190,9 +1218,10 @@ TkMacOSXInvalClipRgns(
MacDrawable *macWin = winPtr->privatePtr;
/*
- * If already marked we can stop because all
- * decendants will also already be marked.
+ * If already marked we can stop because all descendants will also already
+ * be marked.
*/
+
if (!macWin || macWin->flags & TK_CLIP_INVALID) {
return;
}
@@ -1208,9 +1237,10 @@ TkMacOSXInvalClipRgns(
}
/*
- * Invalidate clip regions for all children &
- * their decendants - unless the child is a toplevel.
+ * Invalidate clip regions for all children & their descendants, unless the
+ * child is a toplevel.
*/
+
childPtr = winPtr->childList;
while (childPtr) {
if (!Tk_IsTopLevel(childPtr)) {
@@ -1220,7 +1250,7 @@ TkMacOSXInvalClipRgns(
}
/*
- * Also, if the window is a container, mark its embedded window
+ * Also, if the window is a container, mark its embedded window.
*/
if (Tk_IsContainer(winPtr)) {
@@ -1241,10 +1271,10 @@ TkMacOSXInvalClipRgns(
*
* TkMacOSXWinBounds --
*
- * Given a Tk window this function determines the windows
- * bounds in relation to the Macintosh window's coordinate
- * system. This is also the same coordinate system as the
- * Tk toplevel window in which this window is contained.
+ * Given a Tk window this function determines the windows bounds in
+ * relation to the Macintosh window's coordinate system. This is also the
+ * same coordinate system as the Tk toplevel window in which this window
+ * is contained.
*
* Results:
* None.
@@ -1271,10 +1301,10 @@ TkMacOSXWinBounds(
*
* TkMacOSXWinCGBounds --
*
- * Given a Tk window this function determines the windows
- * bounds in relation to the Macintosh window's coordinate
- * system. This is also the same coordinate system as the
- * Tk toplevel window in which this window is contained.
+ * Given a Tk window this function determines the windows bounds in
+ * relation to the Macintosh window's coordinate system. This is also the
+ * same coordinate system as the Tk toplevel window in which this window
+ * is contained.
*
* Results:
* None.
@@ -1301,15 +1331,15 @@ TkMacOSXWinCGBounds(
*
* UpdateOffsets --
*
- * Updates the X & Y offsets of the given TkWindow from the
- * TopLevel it is a decendant of.
+ * Updates the X & Y offsets of the given TkWindow from the TopLevel it is
+ * a decendant of.
*
* Results:
* None.
*
* Side effects:
- * The xOff & yOff fields for the Mac window datastructure
- * is updated to the proper offset.
+ * The xOff & yOff fields for the Mac window datastructure is updated to
+ * the proper offset.
*
*----------------------------------------------------------------------
*/
@@ -1324,11 +1354,12 @@ UpdateOffsets(
if (winPtr->privatePtr == NULL) {
/*
- * We haven't called Tk_MakeWindowExist for this window yet. The
- * offset information will be postponed and calulated at that
- * time. (This will usually only happen when a mapped parent is
- * being moved but has child windows that have yet to be mapped.)
+ * We haven't called Tk_MakeWindowExist for this window yet. The offset
+ * information will be postponed and calulated at that time. (This will
+ * usually only happen when a mapped parent is being moved but has
+ * child windows that have yet to be mapped.)
*/
+
return;
}
@@ -1397,16 +1428,7 @@ Tk_GetPixmap(
macPix->grafPtr = NULL;
macPix->context = NULL;
macPix->size = CGSizeMake(width, height);
- {
- Rect bounds = {0, 0, height, width};
-
- ChkErr(NewGWorld, &macPix->grafPtr, depth == 1 ? 1 : 0, &bounds, NULL,
- NULL, 0
-#ifdef __LITTLE_ENDIAN__
- | kNativeEndianPixMap
-#endif
- );
- }
+ AllocGWorld(width, height, depth==1, &macPix->grafPtr);
return (Pixmap) macPix;
}