diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXButton.c | 20 | ||||
-rw-r--r-- | macosx/tkMacOSXCarbonEvents.c | 104 | ||||
-rw-r--r-- | macosx/tkMacOSXCursor.c | 6 | ||||
-rw-r--r-- | macosx/tkMacOSXDebug.c | 6 | ||||
-rw-r--r-- | macosx/tkMacOSXDebug.h | 14 | ||||
-rw-r--r-- | macosx/tkMacOSXDialog.c | 54 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.c | 140 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.h | 25 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 19 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 16 | ||||
-rw-r--r-- | macosx/tkMacOSXMenubutton.c | 22 | ||||
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 65 | ||||
-rw-r--r-- | macosx/tkMacOSXNotify.c | 16 | ||||
-rw-r--r-- | macosx/tkMacOSXScale.c | 16 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 9 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXXStubs.c | 10 |
18 files changed, 335 insertions, 215 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index b4cfc67..909e83e 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.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: tkMacOSXButton.c,v 1.2.2.10 2005/08/22 11:55:15 das Exp $ + * RCS: @(#) $Id: tkMacOSXButton.c,v 1.2.2.11 2005/09/10 14:54:17 das Exp $ */ #include "tkButton.h" @@ -833,12 +833,16 @@ TkMacOSXInitControl ( controlReference ); if (!mbPtr->userPane) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"Failed to create user pane control\n"); +#endif return 1; } if ((status = EmbedControl(mbPtr->userPane,rootControl)) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"Failed to embed user pane control %d\n", status); +#endif return 1; } @@ -857,12 +861,16 @@ TkMacOSXInitControl ( controlReference ); if (!mbPtr->control) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"failed to create control of type %d\n",procID); +#endif return 1; } if (EmbedControl(mbPtr->control,mbPtr->userPane) != noErr ) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"failed to embed control of type %d\n",procID); +#endif return 1; } @@ -985,7 +993,9 @@ TkMacOSXDrawControl( TkMacOSXInitControlFontStyle(font, &fontStyle); if (bcmp(&mbPtr->fontStyle, &fontStyle, sizeof(fontStyle)) ) { if (SetControlFontStyle(mbPtr->control, &fontStyle) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"SetControlFontStyle failed\n"); +#endif } bcopy(&fontStyle, &mbPtr->fontStyle, sizeof(fontStyle)); @@ -1113,7 +1123,9 @@ SetupBevelButton( if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"OpenCPicture failed\n"); +#endif } tkPictureIsOpen = 1; @@ -1142,8 +1154,10 @@ SetupBevelButton( kControlBevelButtonContentTag, sizeof(ControlButtonContentInfo), (char *) &mbPtr->bevelButtonContent)) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr, "SetControlData BevelButtonContent failed, %d\n", err ); +#endif } if (butPtr->anchor == TK_ANCHOR_N) { @@ -1170,8 +1184,10 @@ SetupBevelButton( kControlBevelButtonGraphicAlignTag, sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment)) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr, "SetControlData BevelButtonGraphicAlign failed, %d\n", err ); +#endif } if (butPtr->compound != COMPOUND_NONE) { @@ -1190,8 +1206,10 @@ SetupBevelButton( kControlBevelButtonTextPlaceTag, sizeof(ControlButtonTextPlacement), (char *) &thePlacement)) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr, "SetControlData BevelButtonTextPlace failed, %d\n", err ); +#endif } } } diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c index c0539d2..ddeec64 100644 --- a/macosx/tkMacOSXCarbonEvents.c +++ b/macosx/tkMacOSXCarbonEvents.c @@ -53,30 +53,32 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3.2.2 2005/08/09 07:39:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3.2.3 2005/09/10 14:54:17 das Exp $ */ #include "tkInt.h" #include "tkMacOSXInt.h" #include "tkMacOSXEvent.h" +#include "tkMacOSXDebug.h" -static EventHandlerRef ApplicationCarbonEventHandler; +/* +#ifdef TK_MAC_DEBUG +#define TK_MAC_DEBUG_CARBON_EVENTS +#endif +*/ -/* Definitions of functions used only in this file */ -static OSStatus AppEventHandlerProc ( +/* Declarations of functions used only in this file */ +static OSStatus CarbonEventHandlerProc ( EventHandlerCallRef callRef, EventRef inEvent, void *userData); - /* *---------------------------------------------------------------------- * - * AppEventHandlerProc -- + * CarbonEventHandlerProc -- * - * This procedure is the Application CarbonEvent - * handler. Currently, it handles the Hide & Show - * events. + * This procedure is the handler for all registered CarbonEvents. * * Results: * None. @@ -88,7 +90,7 @@ static OSStatus AppEventHandlerProc ( */ static OSStatus -AppEventHandlerProc ( +CarbonEventHandlerProc ( EventHandlerCallRef callRef, EventRef inEvent, void *inUserData) @@ -97,15 +99,27 @@ AppEventHandlerProc ( TkMacOSXEvent macEvent; MacEventStatus eventStatus; +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + char buf [256]; + CarbonEventToAscii(inEvent, buf); + fprintf(stderr, "CarbonEventHandlerProc started handling %s\n", buf); + _DebugPrintEvent(inEvent); +#endif /* TK_MAC_DEBUG_CARBON_EVENTS */ + macEvent.eventRef = inEvent; macEvent.eClass = GetEventClass(macEvent.eventRef); macEvent.eKind = GetEventKind(macEvent.eventRef); macEvent.interp = (Tcl_Interp *) inUserData; bzero(&eventStatus, sizeof(eventStatus)); TkMacOSXProcessEvent(&macEvent,&eventStatus); - if (!eventStatus.stopProcessing) { + if (eventStatus.stopProcessing) { result = noErr; } + +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + fprintf(stderr, "CarbonEventHandlerProc finished handling %s: %s handled\n", buf, + eventStatus.stopProcessing ? " " : "not"); +#endif /* TK_MAC_DEBUG_CARBON_EVENTS */ return result; } @@ -114,14 +128,13 @@ AppEventHandlerProc ( * * TkMacOSXInitCarbonEvents -- * - * This procedure initializes the Application CarbonEvent - * handler. + * This procedure initializes all CarbonEvent handlers. * * Results: * None. * * Side effects: - * A handler for Application targeted Carbon Events is registered. + * Handlers for Carbon Events are registered. * *---------------------------------------------------------------------- */ @@ -130,17 +143,60 @@ void TkMacOSXInitCarbonEvents ( Tcl_Interp *interp) { - const EventTypeSpec inAppEventTypes[] = { - {kEventClassApplication, kEventAppHidden}, - {kEventClassApplication, kEventAppShown}, - {kEventClassWindow, kEventWindowExpanded}, + const EventTypeSpec dispatcherEventTypes[] = { + {kEventClassMouse, kEventMouseDown}, + {kEventClassMouse, kEventMouseUp}, + {kEventClassMouse, kEventMouseMoved}, + {kEventClassMouse, kEventMouseDragged}, + {kEventClassMouse, kEventMouseWheelMoved}, + {kEventClassWindow, kEventWindowUpdate}, + {kEventClassWindow, kEventWindowActivated}, + {kEventClassWindow, kEventWindowDeactivated}, + {kEventClassKeyboard, kEventRawKeyDown}, + {kEventClassKeyboard, kEventRawKeyRepeat}, + {kEventClassKeyboard, kEventRawKeyUp}, + {kEventClassKeyboard, kEventRawKeyModifiersChanged}, + {kEventClassKeyboard, kEventRawKeyRepeat}, + {kEventClassApplication, kEventAppActivated}, + {kEventClassApplication, kEventAppDeactivated}, + {kEventClassApplication, kEventAppQuit}, + {kEventClassAppleEvent, kEventAppleEvent}, + }; + const EventTypeSpec applicationEventTypes[] = { + {kEventClassWindow, kEventWindowExpanded}, + {kEventClassApplication, kEventAppHidden}, + {kEventClassApplication, kEventAppShown}, }; + EventHandlerUPP handler = NewEventHandlerUPP(CarbonEventHandlerProc); + + InstallEventHandler(GetEventDispatcherTarget(), handler, + GetEventTypeCount(dispatcherEventTypes), dispatcherEventTypes, + (void *) interp, NULL); + InstallEventHandler(GetApplicationEventTarget(), handler, + GetEventTypeCount(applicationEventTypes), applicationEventTypes, + (void *) interp, NULL); - InstallEventHandler(GetApplicationEventTarget(), - NewEventHandlerUPP(AppEventHandlerProc), - GetEventTypeCount(inAppEventTypes), - inAppEventTypes, (void *) interp, - &ApplicationCarbonEventHandler); - +#ifdef TK_MAC_DEBUG_CARBON_EVENTS + _TraceEventByName(CFSTR("kEventMouseDown")); + _TraceEventByName(CFSTR("kEventMouseUp")); + _TraceEventByName(CFSTR("kEventMouseMoved")); + _TraceEventByName(CFSTR("kEventMouseDragged")); + _TraceEventByName(CFSTR("kEventMouseWheelMoved")); + _TraceEventByName(CFSTR("kEventWindowUpdate")); + _TraceEventByName(CFSTR("kEventWindowActivated")); + _TraceEventByName(CFSTR("kEventWindowDeactivated")); + _TraceEventByName(CFSTR("kEventRawKeyDown")); + _TraceEventByName(CFSTR("kEventRawKeyRepeat")); + _TraceEventByName(CFSTR("kEventRawKeyUp")); + _TraceEventByName(CFSTR("kEventRawKeyModifiersChanged")); + _TraceEventByName(CFSTR("kEventRawKeyRepeat")); + _TraceEventByName(CFSTR("kEventAppActivated")); + _TraceEventByName(CFSTR("kEventAppDeactivated")); + _TraceEventByName(CFSTR("kEventAppQuit")); + _TraceEventByName(CFSTR("kEventAppleEvent")); + _TraceEventByName(CFSTR("kEventWindowExpanded")); + _TraceEventByName(CFSTR("kEventAppHidden")); + _TraceEventByName(CFSTR("kEventAppShown")); +#endif /* TK_MAC_DEBUG_CARBON_EVENTS */ } diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c index 1db2ff9..d023d4a 100644 --- a/macosx/tkMacOSXCursor.c +++ b/macosx/tkMacOSXCursor.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.4.2.1 2004/07/15 05:24:39 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.4.2.2 2005/09/10 14:54:17 das Exp $ */ #include "tkPort.h" @@ -370,9 +370,9 @@ TkMacOSXInstallCursor( if (cursor) { SetCursor(*cursor); } else { - /* +#ifdef TK_MAC_DEBUG fprintf(stderr,"Resize cursor failed, %d\n", ResError()); - */ +#endif } } else if (macCursorPtr == NULL) { SetThemeCursor(kThemeArrowCursor); diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c index 7dac4c8..8651bc9 100644 --- a/macosx/tkMacOSXDebug.c +++ b/macosx/tkMacOSXDebug.c @@ -50,11 +50,13 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.2.2.2 2005/08/09 07:39:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.2.2.3 2005/09/10 14:54:17 das Exp $ */ #include "tkMacOSXDebug.h" +#ifdef TK_MAC_DEBUG + typedef struct { EventKind kind; char * name; @@ -439,3 +441,5 @@ char * MouseTrackingResultToAscii(MouseTrackingResult r, char * buf) sprintf(buf, "Unknown mouse tracking result : %d", r); return buf; } + +#endif /* TK_MAC_DEBUG */ diff --git a/macosx/tkMacOSXDebug.h b/macosx/tkMacOSXDebug.h index abcc62f..bb3aa32 100644 --- a/macosx/tkMacOSXDebug.h +++ b/macosx/tkMacOSXDebug.h @@ -50,13 +50,18 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.2.2.1 2005/08/09 07:39:54 das Exp $ + * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.2.2.2 2005/09/10 14:54:17 das Exp $ */ #ifndef _TKMACDEBUG #define _TKMACDEBUG #include <Carbon/Carbon.h> +/* The following define enables printing of debug messages to stderr: */ +/* #define TK_MAC_DEBUG 1 */ + +#ifdef TK_MAC_DEBUG + char * CarbonEventToAscii(EventRef eventRef, char * buf ); char * ClassicEventToAscii(EventRecord * eventPtr, char * buf ); @@ -68,4 +73,11 @@ void printWindowTitle(char * tag, WindowRef window ); char * TkMacOSXMenuMessageToAscii(int msg, char * s); char * MouseTrackingResultToAscii(MouseTrackingResult r, char * buf ); + +/* Declare Carbon-internal debugging routines (c.f. Technote 2124): */ +void _DebugPrintEvent(EventRef inEvent); +void _TraceEventByName(CFStringRef eventName); + +#endif + #endif diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index bc7b3c8..37d07f6 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.4.2.7 2005/08/23 22:08:27 hobbs Exp $ + * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.4.2.8 2005/09/10 14:54:17 das Exp $ */ #include <Carbon/Carbon.h> @@ -19,10 +19,10 @@ #include "tkFileFilter.h" #ifndef StrLength -#define StrLength(s) (*((unsigned char *) (s))) +#define StrLength(s) (*((unsigned char *) (s))) #endif #ifndef StrBody -#define StrBody(s) ((char *) (s) + 1) +#define StrBody(s) ((char *) (s) + 1) #endif /* @@ -47,14 +47,12 @@ * information about the file dialog and the file filters. */ typedef struct _OpenFileData { - FileFilterList fl; /* List of file filters. */ - SInt16 curType; /* The filetype currently being - * listed. */ - short popupItem; /* Item number of the popup in the - * dialog. */ - int usePopup; /* True if we show the popup menu (this - * is an open operation and the - * -filetypes option is set). */ + FileFilterList fl; /* List of file filters. */ + SInt16 curType; /* The filetype currently being listed. */ + short popupItem; /* Item number of the popup in the dialog. */ + int usePopup; /* True if we show the popup menu (this is + * an open operation and the -filetypes + * option is set). */ } OpenFileData; @@ -755,24 +753,24 @@ NavServicesGetFile( diagOptions.optionFlags += kNavAllowMultipleFiles; } diagOptions.modality = kWindowModalityAppModal; - + if (ofdPtr != NULL && ofdPtr->usePopup) { FileFilter *filterPtr; - + filterPtr = ofdPtr->fl.filters; if (filterPtr == NULL) { ofdPtr->usePopup = 0; } } - - if (ofdPtr != NULL && ofdPtr->usePopup) { + + if (ofdPtr != NULL && ofdPtr->usePopup) { FileFilter *filterPtr; int index = 0; ofdPtr->curType = 0; - + menuItemNames = (CFStringRef *)ckalloc(ofdPtr->fl.numFilters * sizeof(CFStringRef)); - + for (filterPtr = ofdPtr->fl.filters; filterPtr != NULL; filterPtr = filterPtr->next, index++) { menuItemNames[index] = CFStringCreateWithCString(NULL, @@ -780,7 +778,7 @@ NavServicesGetFile( } diagOptions.popupExtension = CFArrayCreate(NULL, (const void **) menuItemNames, ofdPtr->fl.numFilters, NULL); - } else { + } else { diagOptions.optionFlags += kNavNoTypePopup; diagOptions.popupExtension = NULL; } @@ -820,21 +818,27 @@ NavServicesGetFile( ofdPtr, &dialogRef); if (err != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"NavCreateGetFileDialog failed, %d\n", err ); +#endif dialogRef = NULL; } } else if (isOpen == SAVE_FILE) { err = NavCreatePutFileDialog(&diagOptions, 'TEXT', 'WIsH', openFileEventUPP, NULL, &dialogRef); if (err!=noErr){ +#ifdef TK_MAC_DEBUG fprintf(stderr,"NavCreatePutFileDialog failed, %d\n", err ); +#endif dialogRef = NULL; } } else if (isOpen == CHOOSE_FOLDER) { err = NavCreateChooseFolderDialog(&diagOptions, openFileEventUPP, openFileFilterUPP, NULL, &dialogRef); if (err!=noErr){ +#ifdef TK_MAC_DEBUG fprintf(stderr,"NavCreateChooseFolderDialog failed, %d\n", err ); +#endif dialogRef = NULL; } } @@ -849,10 +853,14 @@ NavServicesGetFile( } if ((err = NavDialogRun(dialogRef)) != noErr ){ +#ifdef TK_MAC_DEBUG fprintf(stderr,"NavDialogRun failed, %d\n", err ); +#endif } else { if ((err = NavDialogGetReply(dialogRef, &theReply)) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"NavGetReply failed, %d\n", err ); +#endif } } } @@ -887,10 +895,14 @@ NavServicesGetFile( if (err == noErr) { if ((err = AEGetDescData(&resultDesc, &fsRef, sizeof(fsRef))) != noErr ) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"AEGetDescData failed %d\n", err ); +#endif } else { if ((err = FSRefMakePath(&fsRef, (unsigned char*) pathPtr, 1024))) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"FSRefMakePath failed, %d\n", err ); +#endif } else { if (isOpen == SAVE_FILE) { CFStringRef saveNameRef; @@ -903,13 +915,19 @@ NavServicesGetFile( strcat(pathPtr, saveName); pathValid = 1; } else { +#ifdef TK_MAC_DEBUG fprintf(stderr, "Path name too long\n"); +#endif } } else { +#ifdef TK_MAC_DEBUG fprintf(stderr, "CFStringGetCString failed\n"); +#endif } } else { +#ifdef TK_MAC_DEBUG fprintf(stderr, "NavDialogGetSaveFileName failed\n"); +#endif } } else { pathValid = 1; diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 46e563f..3315310 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.2 2005/08/09 07:39:55 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.3 2005/09/10 14:54:17 das Exp $ */ #include <stdio.h> @@ -18,32 +18,17 @@ #include "tkMacOSXEvent.h" #include "tkMacOSXDebug.h" -/* - * Enable this define to get debug printing for events not handled. - */ - - /*#define TK_MAC_DEBUG 1 */ - /* * Forward declarations of procedures used in this file. */ static int TkMacOSXProcessAppleEvent( TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr); - -static int ReceiveAndProcessEvent (void); - -/* - * Global data used in this file. - */ - -static EventTargetRef targetRef; - /* *---------------------------------------------------------------------- * - * tkMacOSXFlushWindows -- + * TkMacOSXFlushWindows -- * * This routine flushes all the Carbon windows of the application. It * is called by the setup procedure for the Tcl/Carbon event source. @@ -58,7 +43,7 @@ static EventTargetRef targetRef; */ void -tkMacOSXFlushWindows () +TkMacOSXFlushWindows () { WindowRef wRef = GetWindowList(); @@ -70,53 +55,7 @@ tkMacOSXFlushWindows () wRef = GetNextWindow(wRef); } } - - - -int -XSync (Display *display, Bool flag) -{ - tkMacOSXFlushWindows(); - display->request++; - return 0; -} - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXCountAndProcessMacEvents -- - * - * This routine receives any Carbon events that are in the queue and - * converts them to Tk events. It is called by the event set-up and - * check routines - * - * Results: - * The number of events in the queue. - * - * Side effects: - * Tells the Window Manager to deliver events to the event queue of the - * current thread. Receives any Carbon events on the queue and converts - * them to Tk events. - * - *---------------------------------------------------------------------- - */ - -int -TkMacOSXCountAndProcessMacEvents() -{ - EventQueueRef qPtr; - int eventCount; - qPtr = GetMainEventQueue(); - eventCount = GetNumEventsInQueue(qPtr); - if (eventCount) { - int n, err; - for (n = 0, err = 0;n<eventCount && !err;n++) { - err = ReceiveAndProcessEvent(); - } - } - return eventCount; -} - + /* *---------------------------------------------------------------------- * @@ -143,17 +82,21 @@ TkMacOSXProcessAppleEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) &eventRecord )) { err = TkMacOSXDoHLEvent(&eventRecord); if (err != noErr) { +#ifdef TK_MAC_DEBUG char buf1 [ 256 ]; char buf2 [ 256 ]; fprintf(stderr, "TkMacOSXDoHLEvent failed : %s,%s,%d\n", CarbonEventToAscii(eventPtr->eventRef, buf1), ClassicEventToAscii(&eventRecord,buf2), err); +#endif statusPtr->err = 1; } } else { - statusPtr->err = 1; +#ifdef TK_MAC_DEBUG fprintf(stderr,"ConvertEventRefToEventRecord failed\n"); +#endif + statusPtr->err = 1; } return 0; } @@ -201,14 +144,10 @@ TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) case kEventClassAppleEvent: TkMacOSXProcessAppleEvent(eventPtr, statusPtr); break; - case kEventClassWish: - statusPtr->stopProcessing = 1; - break; default: #ifdef TK_MAC_DEBUG - if (0) { - char buf [ 256 ]; + char buf [256]; fprintf(stderr, "Unrecognised event : %s\n", CarbonEventToAscii(eventPtr->eventRef, buf)); @@ -222,7 +161,7 @@ TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) /* *---------------------------------------------------------------------- * - * ReceiveAndProcessEvent -- + * TkMacOSXReceiveAndProcessEvent -- * * This receives a carbon event and converts it to a Tk event * @@ -237,46 +176,35 @@ TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) *---------------------------------------------------------------------- */ -static int -ReceiveAndProcessEvent() +OSStatus +TkMacOSXReceiveAndProcessEvent() { - TkMacOSXEvent macEvent; - MacEventStatus eventStatus; - int err; - char buf [ 256 ]; + static EventTargetRef targetRef = NULL; + EventRef eventRef; + OSStatus err; /* * This is a poll, since we have already counted the events coming * into this routine, and are guaranteed to have one waiting. */ - err = ReceiveNextEvent(0, NULL, kEventDurationNoWait, - true, &macEvent.eventRef); - if (err != noErr) { - return err; - } else { - macEvent.eClass = GetEventClass(macEvent.eventRef); - macEvent.eKind = GetEventKind(macEvent.eventRef); - macEvent.interp = NULL; - bzero(&eventStatus, sizeof(eventStatus)); - TkMacOSXProcessEvent(&macEvent,&eventStatus); - if (!eventStatus.stopProcessing) { - if (!targetRef) { - targetRef = GetEventDispatcherTarget(); - } - - err = SendEventToEventTarget(macEvent.eventRef,targetRef); - if (err != noErr -#if !TK_MAC_DEBUG - && err != eventNotHandledErr + err = ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &eventRef); + if (err == noErr) { + if (!targetRef) { + targetRef = GetEventDispatcherTarget(); + } + err = SendEventToEventTarget(eventRef,targetRef); +#ifdef TK_MAC_DEBUG + if (err != noErr && err != eventLoopTimedOutErr + && err != eventNotHandledErr + ) { + char buf [256]; + fprintf(stderr, + "RCNE SendEventToEventTarget (%s) failed, %d\n", + CarbonEventToAscii(eventRef, buf), (int)err); + } #endif - ) { - fprintf(stderr, - "RCNE SendEventToEventTarget (%s) failed, %d\n", - CarbonEventToAscii(macEvent.eventRef, buf),err); - } - } - ReleaseEvent(macEvent.eventRef); - return 0; - } + ReleaseEvent(eventRef); + } + return err; } diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h index 5764b92..1300e91 100644 --- a/macosx/tkMacOSXEvent.h +++ b/macosx/tkMacOSXEvent.h @@ -50,7 +50,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.3.2.1 2005/08/09 07:39:55 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.3.2.2 2005/09/10 14:54:17 das Exp $ */ #ifndef _TKMACEVENT @@ -59,10 +59,6 @@ #include <Carbon/Carbon.h> #include <tcl.h> -enum { - kEventClassWish = 'WiSH' -}; - typedef struct { int stopProcessing; int err; @@ -79,13 +75,18 @@ typedef struct { Tcl_Interp *interp; /* Interp to handle events in */ } TkMacOSXEvent; -int TkMacOSXCountAndProcessMacEvents _ANSI_ARGS_(()); -void tkMacOSXFlushWindows _ANSI_ARGS_(()); -int TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr); -int TkMacOSXProcessMouseEvent(TkMacOSXEvent * e, MacEventStatus * statusPtr); -int TkMacOSXProcessWindowEvent(TkMacOSXEvent * e, MacEventStatus * statusPtr); -int TkMacOSXProcessKeyboardEvent(TkMacOSXEvent * e, MacEventStatus * statusPtr); -int TkMacOSXProcessApplicationEvent(TkMacOSXEvent * e, MacEventStatus * statusPtr); +OSStatus TkMacOSXReceiveAndProcessEvent(); +void TkMacOSXFlushWindows(); +int TkMacOSXProcessEvent(TkMacOSXEvent *eventPtr, + MacEventStatus *statusPtr); +int TkMacOSXProcessMouseEvent(TkMacOSXEvent *e, + MacEventStatus *statusPtr); +int TkMacOSXProcessWindowEvent(TkMacOSXEvent *e, + MacEventStatus *statusPtr); +int TkMacOSXProcessKeyboardEvent(TkMacOSXEvent *e, + MacEventStatus *statusPtr); +int TkMacOSXProcessApplicationEvent(TkMacOSXEvent *e, + MacEventStatus *statusPtr); int TkMacOSXKeycodeToUnicode( UniChar * uniChars, int maxChars, diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 0902388..7498514 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.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: tkMacOSXInit.c,v 1.3.2.9 2005/08/09 07:40:00 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.10 2005/09/10 14:54:17 das Exp $ */ #include "tkInt.h" @@ -207,7 +207,9 @@ TkpInit(interp) err = FSPathMakeRef(fileName, &ref, NULL); if (err != noErr) break; err = FSOpenResourceFile(&ref, 0, NULL, fsRdPerm, &refNum); +#ifdef TK_MAC_DEBUG if (err != noErr) fprintf(stderr,"FSOpenResourceFile error %ld\n",err); +#endif break; } if (fd != -1) { diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 0429cb2..10b430e 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -50,7 +50,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.6.2.4 2005/08/09 07:40:00 das Exp $ + * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.6.2.5 2005/09/10 14:54:17 das Exp $ */ #include "tkMacOSXInt.h" @@ -135,7 +135,8 @@ static int KeycodeToUnicodeViaKCHRResource( *---------------------------------------------------------------------- */ -int TkMacOSXProcessKeyboardEvent( +int +TkMacOSXProcessKeyboardEvent( TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) { @@ -201,7 +202,9 @@ int TkMacOSXProcessKeyboardEvent( sizeof(keyEventData.ch), NULL, &keyEventData.ch); if (status != noErr) { +#ifdef TK_MAC_DEBUG fprintf (stderr, "Failed to retrieve KeyMacCharCodes\n"); +#endif statusPtr->err = 1; return false; } @@ -211,7 +214,9 @@ int TkMacOSXProcessKeyboardEvent( sizeof(keyEventData.keyCode), NULL, &keyEventData.keyCode); if (status != noErr) { +#ifdef TK_MAC_DEBUG fprintf (stderr, "Failed to retrieve KeyCode\n"); +#endif statusPtr->err = 1; return false; } @@ -221,7 +226,9 @@ int TkMacOSXProcessKeyboardEvent( sizeof(keyEventData.keyModifiers), NULL, &keyEventData.keyModifiers); if (status != noErr) { +#ifdef TK_MAC_DEBUG fprintf (stderr, "Failed to retrieve KeyModifiers\n"); +#endif statusPtr->err = 1; return false; } @@ -398,9 +405,11 @@ GenerateKeyEvent( Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); break; default: +#ifdef TK_MAC_DEBUG fprintf (stderr, "GenerateKeyEvent(): Invalid parameter eKind %d\n", (int) eKind); +#endif return -1; } } @@ -950,10 +959,12 @@ KeycodeToUnicodeViaUnicodeResource( action = kUCKeyActionAutoKey; break; default: +#ifdef TK_MAC_DEBUG fprintf (stderr, "KeycodeToUnicodeViaUnicodeResource(): " "Invalid parameter eKind %d\n", (int) eKind); +#endif return 0; } @@ -978,7 +989,9 @@ KeycodeToUnicodeViaUnicodeResource( *deadKeyStatePtr = 0; if (noErr != status) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"UCKeyTranslate failed: %d", (int) status); +#endif actuallength = 0; } @@ -1101,8 +1114,10 @@ KeycodeToUnicodeViaKCHRResource( cfString = CFStringCreateWithCStringNoCopy( NULL, macStr, encoding, kCFAllocatorNull); if (cfString == NULL) { +#ifdef TK_MAC_DEBUG fprintf(stderr, "CFString: Can't convert with encoding %d\n", (int) encoding); +#endif return 0; } diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index f4ed585..2b4914e 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.6.2.9 2005/08/09 07:40:00 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.6.2.10 2005/09/10 14:54:17 das Exp $ */ #include "tkMacOSXInt.h" #include "tkMenubutton.h" @@ -576,7 +576,9 @@ TkpNewMenu( menuDefSpec.defType = kMenuDefProcPtr; menuDefSpec.u.defProc = MenuDefProc; if ((err = SetMenuDefinition(macMenuHdl, &menuDefSpec)) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr, "SetMenuDefinition failed %d\n", err ); +#endif } } menuPtr->platformData = (TkMenuPlatformData) ckalloc(sizeof(MacMenu)); @@ -3458,7 +3460,9 @@ DrawMenuEntryLabel( GetThemeFont (kThemeMenuItemFont, smSystemScript, fontName, &fontSize, &fontStyle); if ((err = ATSUCreateStyle(&style)) != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"ATSUCreateStyle failed, %d\n", err); +#endif return; } fixedSize = fontSize<<16; @@ -3467,7 +3471,9 @@ DrawMenuEntryLabel( valuePtr = &fixedSize; err = ATSUSetAttributes(style, 1, &tag, &valueSize, &valuePtr); if (err != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"ATSUSetAttributes failed,%d\n", err ); +#endif } GetFNum(fontName, &iFONDNumber); @@ -3477,7 +3483,9 @@ DrawMenuEntryLabel( valuePtr = &fontID; err = ATSUSetAttributes(style, 1, &tag, &valueSize, &valuePtr); if (err != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"ATSUSetAttributes failed,%d\n", err ); +#endif } #endif @@ -3489,13 +3497,17 @@ DrawMenuEntryLabel( stringRef = CFStringCreateWithCString(NULL, Tcl_DStringValue(&itemTextDString), kCFStringEncodingUTF8); if (!stringRef) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"CFStringCreateWithCString failed\n"); +#endif } err = ATSUCreateTextLayoutWithTextPtr(CFStringGetCharactersPtr(stringRef), 0, length, length, 1, &runLengths, &style, &textLayout) if (err != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"ATSUCreateTextLayoutWithTextPtr failed, %d\n", err); +#endif return; } #endif @@ -4050,7 +4062,9 @@ HandleMenuHiliteMsg (MenuRef menu, err = GetMenuTrackingData(menu, mtdPtr); if (err !=noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"GetMenuTrackingData failed : %d\n", err ); +#endif return; } diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 4721b45..67d84ca 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.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: tkMacOSXMenubutton.c,v 1.2.2.2 2005/05/14 20:53:31 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.2.2.3 2005/09/10 14:54:17 das Exp $ */ #include <Carbon/Carbon.h> @@ -214,7 +214,9 @@ TkpDisplayMenuButton( } if (!mbPtr->userPane) { if (MenuButtonInitControl(mbPtr,&paneRect,&cntrRect ) ) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"Init Control failed\n" ); +#endif return; } } @@ -248,7 +250,9 @@ TkpDisplayMenuButton( if (hasImageOrBitmap) { err = SetControlFontStyle(mbPtr->control,&titleParams.style); if (err !=noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"SetControlFontStyle failed %d\n", err); +#endif return; } } @@ -268,7 +272,9 @@ TkpDisplayMenuButton( /* Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */ tkPictureIsOpen = 1; if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"OpenCPicture failed\n"); +#endif } /* * TO DO - There is one case where XCopyPlane calls CopyDeepMask, @@ -290,7 +296,9 @@ TkpDisplayMenuButton( sizeof(ControlButtonContentInfo), (char *) &mbPtr->bevelButtonContent); if (err != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"SetControlData BevelButtonContent failed, %d\n", err ); +#endif } switch (butPtr->anchor) { case TK_ANCHOR_N: @@ -327,7 +335,9 @@ TkpDisplayMenuButton( sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment); if (err != noErr ) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"SetControlData BevelButtonGraphicAlign failed, %d\n", err ); +#endif } } if (butPtr->flags & GOT_FOCUS) { @@ -628,12 +638,16 @@ MenuButtonInitControl ( procID, controlReference ); if (!mbPtr->userPane) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"Failed to create user pane control\n"); +#endif return 1; } status = EmbedControl(mbPtr->userPane,rootControl); if (status != noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"Failed to embed user pane control %d\n", status); +#endif return 1; } SetUserPaneSetUpSpecialBackgroundProc(mbPtr->userPane, @@ -652,12 +666,16 @@ MenuButtonInitControl ( mbPtr->params.procID, controlReference ); if (!mbPtr->control) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"failed to create control of type %d : line %d\n",mbPtr->params.procID, __LINE__); +#endif return 1; } err = EmbedControl(mbPtr->control,mbPtr->userPane); if (err != noErr ) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"failed to embed control of type %d,%d\n",procID, err); +#endif return 1; } if (mbPtr->params.isBevel) { @@ -669,7 +687,9 @@ MenuButtonInitControl ( if (mbPtr->titleParams.len) { err = SetControlFontStyle(mbPtr->control,&mbPtr->titleParams.style); if (err !=noErr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"SetControlFontStyle failed %d\n", err); +#endif return 1; } } diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 3f911d7..1c63fdf 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -50,7 +50,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.7 2005/08/09 07:40:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.8 2005/09/10 14:54:17 das Exp $ */ #include "tkInt.h" @@ -82,7 +82,7 @@ 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 _ANSI_ARGS_((WindowRef wRef)); +static void BringWindowForward(WindowRef wRef, Boolean isFrontProcess); static int GeneratePollingEvents(MouseEventData * medPtr); static int GenerateMouseWheelEvent(MouseEventData * medPtr); static int GenerateButtonEvent(MouseEventData * medPtr); @@ -201,8 +201,10 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) typeLongInteger, NULL, sizeof(long), NULL, &medPtr->delta); if (status != noErr ) { +#ifdef TK_MAC_DEBUG fprintf (stderr, - "Failed to retrieve mouse wheel delta, %d\n", (int)status); + "Failed to retrieve mouse wheel delta, %d\n", (int) status); +#endif statusPtr->err = 1; return false; } @@ -231,9 +233,18 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) * the corresponding mouse-up to be reported to the application * or else it will mess up some Tk scripts. */ - + + ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess}; + Boolean isFrontProcess = true; + + status = GetFrontProcess(&frontPsn); + if (status == noErr) { + SameProcess(&frontPsn, &ourPsn, &isFrontProcess); + } + if (!(TkpIsWindowFloating(medPtr->whichWin)) - && (medPtr->whichWin != medPtr->activeNonFloating)) { + && (medPtr->whichWin != medPtr->activeNonFloating + || !isFrontProcess)) { Tk_Window grabWin = TkMacOSXGetCapture(); if ((grabWin == NULL)) { int grabState = TkGrabState((TkWindow*)tkwin); @@ -241,7 +252,9 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) /* Now we want to set the focus to the local grabWin */ TkMacOSXSetEatButtonUp(true); grabWin = (Tk_Window) (((TkWindow*)tkwin)->dispPtr->grabWinPtr); - BringWindowForward(GetWindowFromPort(TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window))); + BringWindowForward(GetWindowFromPort( + TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)), + isFrontProcess); statusPtr->stopProcessing = 1; return false; } @@ -252,7 +265,9 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) grb = (TkWindow *)grabWin; /* Now we want to set the focus to the global grabWin */ TkMacOSXSetEatButtonUp(true); - BringWindowForward(GetWindowFromPort(TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window))); + BringWindowForward(GetWindowFromPort( + TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)), + isFrontProcess); statusPtr->stopProcessing = 1; return false; } @@ -265,13 +280,12 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) return result; } else { TkMacOSXSetEatButtonUp(true); - BringWindowForward(medPtr->whichWin); + BringWindowForward(medPtr->whichWin, isFrontProcess); return false; } } } - if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) { return result; } @@ -488,32 +502,17 @@ GeneratePollingEvents(MouseEventData * medPtr) */ static void -BringWindowForward(WindowRef wRef) +BringWindowForward(WindowRef wRef, Boolean isFrontProcess) { - do { - ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess}; - Boolean flag; - int err; - - err = GetFrontProcess(&frontPsn); - if (err != noErr) { - fprintf(stderr, "GetFrontProcess failed, %d\n", err); - break; + if (!isFrontProcess) { + ProcessSerialNumber ourPsn = {0, kCurrentProcess}; + OSStatus status = SetFrontProcess(&ourPsn); + if (status != noErr) { +#ifdef TK_MAC_DEBUG + fprintf(stderr,"SetFrontProcess failed, %d\n", (int) status); +#endif } - err = SameProcess(&frontPsn, &ourPsn, &flag); - if (err != noErr) { - fprintf(stderr, "SameProcess failed, %d\n", err); - break; - } else { - if (!flag) { - err = SetFrontProcess(&ourPsn); - if (err != noErr) { - fprintf(stderr,"SetFrontProcess failed,%d\n", err); - break; - } - } - } - } while (0); + } if (!TkpIsWindowFloating(wRef)) { if (IsValidWindowPtr(wRef)) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 0ecccd2..78f159b 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.5.2.5 2005/05/29 07:00:47 das Exp $ + * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.5.2.6 2005/09/10 14:54:18 das Exp $ */ #include "tclInt.h" @@ -170,11 +170,21 @@ CarbonEventsCheckProc(clientData, flags) ClientData clientData; int flags; { + int numFound; + OSStatus err = noErr; + if (!(flags & TCL_WINDOW_EVENTS)) { return; } - if (GetNumEventsInQueue((EventQueueRef)clientData)) { - TkMacOSXCountAndProcessMacEvents(); + numFound = GetNumEventsInQueue((EventQueueRef)clientData); + + /* Avoid starving other event sources: */ + if (numFound > 4) { + numFound = 4; + } + while (numFound > 0 && err == noErr) { + err = TkMacOSXReceiveAndProcessEvent(); + numFound--; } } diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index 709b3e4..7a5c4a2 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.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: tkMacOSXScale.c,v 1.2.2.2 2005/08/09 07:40:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXScale.c,v 1.2.2.3 2005/09/10 14:54:18 das Exp $ */ #include "tkScale.h" @@ -153,7 +153,9 @@ TkpDisplayScale(clientData) UInt16 numTicks; +#ifdef TK_MAC_DEBUG fprintf(stderr,"TkpDisplayScale\n"); +#endif scalePtr->flags &= ~REDRAW_PENDING; if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) { goto done; @@ -244,7 +246,9 @@ TkpDisplayScale(clientData) if (macScalePtr->scaleHandle == NULL) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"Initialising scale\n"); +#endif initialValue = scalePtr->value; if (scalePtr->orient == ORIENT_HORIZONTAL) { @@ -323,7 +327,9 @@ TkpScaleElement(scalePtr, x, y) CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; +#ifdef TK_MAC_DEBUG fprintf(stderr,"TkpScaleElement\n"); +#endif destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scalePtr->tkwin)); GetGWorld(&saveWorld, &saveDevice); @@ -341,7 +347,9 @@ TkpScaleElement(scalePtr, x, y) SetGWorld(saveWorld, saveDevice); +#ifdef TK_MAC_DEBUG fprintf (stderr,"ScalePart %d, pos ( %d %d )\n", part, where.h, where.v ); +#endif switch (part) { case inSlider: @@ -396,7 +404,9 @@ MacScaleEventProc(clientData, eventPtr) GWorldPtr destPort; Window dummyWin; +#ifdef TK_MAC_DEBUG fprintf(stderr,"MacScaleEventProc\n" ); +#endif /* * To call Macintosh control routines we must have the port * set to the window containing the control. We will then test @@ -410,7 +420,9 @@ MacScaleEventProc(clientData, eventPtr) TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds); where.h = eventPtr->xbutton.x + bounds.left; where.v = eventPtr->xbutton.y + bounds.top; +#ifdef TK_MAC_DEBUG fprintf(stderr,"calling TestControl\n"); +#endif part = TestControl(macScalePtr->scaleHandle, where); if (part == 0) { return; @@ -461,7 +473,9 @@ ScaleActionProc( int value; TkScale *scalePtr = (TkScale *) GetControlReference(theControl); +#ifdef TK_MAC_DEBUG fprintf(stderr,"ScaleActionProc\n"); +#endif value = GetControlValue(theControl); TkScaleSetValue(scalePtr, value, 1, 1); Tcl_Preserve((ClientData) scalePtr); diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 366c1c8..c960f10 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -50,7 +50,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.3 2005/08/09 07:40:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.4 2005/09/10 14:54:18 das Exp $ */ #include "tkMacOSXInt.h" @@ -122,10 +122,7 @@ TkMacOSXProcessApplicationEvent( HideFloatingWindows(); break; case kEventAppQuit: - case kEventAppLaunchNotification: - case kEventAppLaunched: - case kEventAppTerminated: - case kEventAppFrontSwitched: + statusPtr->stopProcessing = 1; break; case kEventAppHidden: /* @@ -202,7 +199,9 @@ TkMacOSXProcessWindowEvent( sizeof(whichWindow), NULL, &whichWindow); if (status != noErr) { +#ifdef TK_MAC_DEBUG fprintf ( stderr, "TkMacOSXHandleWindowEvent:Failed to retrieve window" ); +#endif return 0; } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index f3087fb..9c1c6db 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.12 2005/08/09 07:40:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.13 2005/09/10 14:54:18 das Exp $ */ #include <Carbon/Carbon.h> @@ -5180,8 +5180,10 @@ TkMacOSXUnregisterMacWindow( } entryPtr = Tcl_FindHashEntry(&windowTable,(char *) macWinPtr); if (!entryPtr) { +#ifdef TK_MAC_DEBUG fprintf(stderr,"Unregister:failed to find window %08x\n", (int) macWinPtr ); +#endif } else { Tcl_DeleteHashEntry(entryPtr); diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 8da13aa..7942c9e 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.2.2.7 2005/08/09 07:40:02 das Exp $ + * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.2.2.8 2005/09/10 14:54:18 das Exp $ */ #include "tkInt.h" @@ -707,6 +707,14 @@ Tk_FreeXId ( { /* no-op function needed for stubs implementation. */ } + +int +XSync (Display *display, Bool flag) +{ + TkMacOSXFlushWindows(); + display->request++; + return 0; +} /* *---------------------------------------------------------------------- |