summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog56
-rw-r--r--library/listbox.tcl27
-rw-r--r--library/scrlbar.tcl16
-rw-r--r--library/text.tcl47
-rw-r--r--macosx/tkMacOSXButton.c20
-rw-r--r--macosx/tkMacOSXCarbonEvents.c104
-rw-r--r--macosx/tkMacOSXCursor.c6
-rw-r--r--macosx/tkMacOSXDebug.c6
-rw-r--r--macosx/tkMacOSXDebug.h14
-rw-r--r--macosx/tkMacOSXDialog.c34
-rw-r--r--macosx/tkMacOSXEvent.c144
-rw-r--r--macosx/tkMacOSXEvent.h27
-rw-r--r--macosx/tkMacOSXInit.c4
-rw-r--r--macosx/tkMacOSXKeyEvent.c21
-rw-r--r--macosx/tkMacOSXMenu.c16
-rw-r--r--macosx/tkMacOSXMenubutton.c22
-rw-r--r--macosx/tkMacOSXMouseEvent.c67
-rw-r--r--macosx/tkMacOSXNotify.c16
-rw-r--r--macosx/tkMacOSXScale.c16
-rw-r--r--macosx/tkMacOSXWindowEvent.c13
-rw-r--r--macosx/tkMacOSXWm.c4
-rw-r--r--macosx/tkMacOSXXStubs.c10
-rwxr-xr-xunix/configure7
-rw-r--r--unix/configure.in5
-rw-r--r--unix/tkConfig.h.in13
-rw-r--r--xlib/xcolors.c4
26 files changed, 467 insertions, 252 deletions
diff --git a/ChangeLog b/ChangeLog
index c7ed199..ecedca4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,59 @@
+2005-09-11 Daniel Steffen <das@users.sourceforge.net>
+
+ * macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent): check if
+ process is in front on MouseDown, otherwise request process activation
+ from BringWindowForward() via new isFrontProcess param.
+
+ * macosx/tkMacOSXCarbonEvents.c (TkMacOSXInitCarbonEvents): register our
+ event handler on the dispatcher target for all carbon events of interest
+ to TkAqua; this replaces event processing directly from the event queue
+ and thus allows to capture events that are syntesized by Carbon and sent
+ directly to the dispatcher and not to the event queue.
+
+ * macosx/tkMacOSXEvent.c: remove TkMacOSXCountAndProcessMacEvents(),
+ rename ReceiveAndProcessEvent() to TkMacOSXReceiveAndProcessEvent().
+ (TkMacOSXReceiveAndProcessEvent): remove tk event processing before
+ sending events to the dispatcher, all events of interest are now
+ processed in our dispatcher target event handler.
+
+ * macosx/tkMacOSXNotify.c (CarbonEventsCheckProc): dispatch events
+ directly via TkMacOSXReceiveAndProcessEvent(), but dispatch no more than
+ four carbon events at one time to avoid starving other event sources.
+
+ * macosx/tkMacOSXEvent.c: formatting cleanup, move XSync() to XStubs,
+ * macosx/tkMacOSXEvent.h: removed obsolete kEventClassWish handling.
+ * macosx/tkMacOSXXStubs.c
+
+ * macosx/tkMacOSXEvent.h: declare macosx internal procs as MODULE_SCOPE.
+ * macosx/tkMacOSXEvent.c:
+ * macosx/tkMacOSXKeyEvent.c:
+ * macosx/tkMacOSXMouseEvent.c:
+ * macosx/tkMacOSXWindowEvent.c:
+
+ * macosx/tkMacOSXButton.c: conditionalize all debug message printing to
+ * macosx/tkMacOSXCursor.c: stderr via TK_MAC_DEBUG define.
+ * macosx/tkMacOSXDebug.c:
+ * macosx/tkMacOSXDebug.h:
+ * macosx/tkMacOSXDialog.c:
+ * macosx/tkMacOSXEvent.c:
+ * macosx/tkMacOSXInit.c:
+ * macosx/tkMacOSXKeyEvent.c:
+ * macosx/tkMacOSXMenu.c:
+ * macosx/tkMacOSXMenubutton.c:
+ * macosx/tkMacOSXScale.c:
+ * macosx/tkMacOSXWindowEvent.c:
+ * macosx/tkMacOSXWm.c:
+
+ * unix/configure.in: define TK_MAC_DEBUG on aqua when symbols enabled.
+ * unix/configure: autoconf-2.59
+ * unix/tkConfig.h.in: autoheader-2.59
+
+ * library/listbox.tcl: synced aqua MouseWheel bindings with
+ * library/scrlbar.tcl: core-8-4-branch.
+ * library/text.tcl:
+
+ * xlib/xcolors.c: fixed warning
+
2005-08-25 Daniel Steffen <das@users.sourceforge.net>
* unix/Makefile.in (html): reverted/amended changes of 2005-08-23
diff --git a/library/listbox.tcl b/library/listbox.tcl
index 9143f22..27cb114 100644
--- a/library/listbox.tcl
+++ b/library/listbox.tcl
@@ -3,7 +3,7 @@
# This file defines the default bindings for Tk listbox widgets
# and provides procedures that help in implementing those bindings.
#
-# RCS: @(#) $Id: listbox.tcl,v 1.14 2005/07/25 09:06:00 dkf Exp $
+# RCS: @(#) $Id: listbox.tcl,v 1.15 2005/09/10 14:53:20 das Exp $
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994-1995 Sun Microsystems, Inc.
@@ -175,12 +175,27 @@ bind Listbox <B2-Motion> {
%W scan dragto %x %y
}
-# The MouseWheel will typically only fire on Windows. However,
-# someone could use the "event generate" command to produce one
-# on other platforms.
+# The MouseWheel will typically only fire on Windows and Mac OS X.
+# However, someone could use the "event generate" command to produce
+# one on other platforms.
-bind Listbox <MouseWheel> {
- %W yview scroll [expr {- (%D / 120) * 4}] units
+if {[tk windowingsystem] eq "aqua"} {
+ bind Listbox <MouseWheel> {
+ %W yview scroll [expr {- (%D)}] units
+ }
+ bind Listbox <Option-MouseWheel> {
+ %W yview scroll [expr {-10 * (%D)}] units
+ }
+ bind Listbox <Shift-MouseWheel> {
+ %W xview scroll [expr {- (%D)}] units
+ }
+ bind Listbox <Shift-Option-MouseWheel> {
+ %W xview scroll [expr {-10 * (%D)}] units
+ }
+} else {
+ bind Listbox <MouseWheel> {
+ %W yview scroll [expr {- (%D / 120) * 4}] units
+ }
}
if {"x11" eq [tk windowingsystem]} {
diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl
index 6be187b..57275f2 100644
--- a/library/scrlbar.tcl
+++ b/library/scrlbar.tcl
@@ -3,7 +3,7 @@
# This file defines the default bindings for Tk scrollbar widgets.
# It also provides procedures that help in implementing the bindings.
#
-# RCS: @(#) $Id: scrlbar.tcl,v 1.11 2005/07/25 09:06:00 dkf Exp $
+# RCS: @(#) $Id: scrlbar.tcl,v 1.12 2005/09/10 14:53:20 das Exp $
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -130,6 +130,20 @@ bind Scrollbar <End> {
tk::ScrollToPos %W 1
}
}
+if {[tk windowingsystem] eq "aqua"} {
+ bind Scrollbar <MouseWheel> {
+ tk::ScrollByUnits %W v [expr {- (%D)}]
+ }
+ bind Scrollbar <Option-MouseWheel> {
+ tk::ScrollByUnits %W v [expr {-10 * (%D)}]
+ }
+ bind Scrollbar <Shift-MouseWheel> {
+ tk::ScrollByUnits %W h [expr {- (%D)}]
+ }
+ bind Scrollbar <Shift-Option-MouseWheel> {
+ tk::ScrollByUnits %W h [expr {-10 * (%D)}]
+ }
+}
# tk::ScrollButtonDown --
# This procedure is invoked when a button is pressed in a scrollbar.
# It changes the way the scrollbar is displayed and takes actions
diff --git a/library/text.tcl b/library/text.tcl
index 051f9b8..22d96d7 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -3,7 +3,7 @@
# This file defines the default bindings for Tk text widgets and provides
# procedures that help in implementing the bindings.
#
-# RCS: @(#) $Id: text.tcl,v 1.39 2005/07/26 12:38:19 dkf Exp $
+# RCS: @(#) $Id: text.tcl,v 1.40 2005/09/10 14:53:20 das Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
@@ -452,26 +452,33 @@ set ::tk::Priv(prevPos) {}
# on other platforms. We must be careful not to round -ve values of %D
# down to zero.
-# We must make sure that positive and negative movements are rounded
-# equally to integers, avoiding the problem that
-# (int)1/3 = 0,
-# but
-# (int)-1/3 = -1
-# The following code ensure equal +/- behaviour.
-bind Text <MouseWheel> {
- if {%D >= 0} {
- %W yview scroll [expr {-%D/3}] pixels
- } else {
- %W yview scroll [expr {(2-%D)/3}] pixels
- }
-}
if {[tk windowingsystem] eq "aqua"} {
-bind Text <Option-MouseWheel> {
- %W yview scroll [expr {-150 * %D}] pixels
-}
-bind Text <MouseWheel> {
- %W yview scroll [expr {-15 * %D}] pixels
-}
+ bind Text <MouseWheel> {
+ %W yview scroll [expr {-15 * (%D)}] pixels
+ }
+ bind Text <Option-MouseWheel> {
+ %W yview scroll [expr {-150 * (%D)}] pixels
+ }
+ bind Text <Shift-MouseWheel> {
+ %W xview scroll [expr {-15 * (%D)}] pixels
+ }
+ bind Text <Shift-Option-MouseWheel> {
+ %W xview scroll [expr {-150 * (%D)}] pixels
+ }
+} else {
+ # We must make sure that positive and negative movements are rounded
+ # equally to integers, avoiding the problem that
+ # (int)1/3 = 0,
+ # but
+ # (int)-1/3 = -1
+ # The following code ensure equal +/- behaviour.
+ bind Text <MouseWheel> {
+ if {%D >= 0} {
+ %W yview scroll [expr {-%D/3}] pixels
+ } else {
+ %W yview scroll [expr {(2-%D)/3}] pixels
+ }
+ }
}
if {"x11" eq [tk windowingsystem]} {
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index bac175e..a89088f 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.14 2005/08/22 11:54:20 das Exp $
+ * RCS: @(#) $Id: tkMacOSXButton.c,v 1.15 2005/09/10 14:53:20 das Exp $
*/
#include "tkButton.h"
@@ -841,12 +841,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;
}
@@ -865,12 +869,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;
}
@@ -993,7 +1001,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));
@@ -1123,7 +1133,9 @@ SetupBevelButton(
if (!(mbPtr->bevelButtonContent.u.picture
= OpenCPicture(&mbPtr->picParams)) ) {
+#ifdef TK_MAC_DEBUG
fprintf(stderr,"OpenCPicture failed\n");
+#endif
}
tkPictureIsOpen = 1;
@@ -1155,8 +1167,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) {
@@ -1183,8 +1197,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) {
@@ -1203,8 +1219,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 daeea6b..e946df5 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 2005/08/09 07:39:20 das Exp $
+ * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.4 2005/09/10 14:53:20 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 @@ MODULE_SCOPE 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 31dd4b8..ffcc739 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.5 2004/07/15 05:27:59 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.6 2005/09/10 14:53:20 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 fa430eb..6c2d2f4 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.4 2005/08/09 07:39:20 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.5 2005/09/10 14:53:20 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 1e659af..f4d79ae 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.3 2005/08/09 07:39:20 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.4 2005/09/10 14:53:20 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 c3a73d2..972e78f 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.16 2005/08/23 22:10:57 hobbs Exp $
+ * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.17 2005/09/10 14:53:20 das Exp $
*/
#include <Carbon/Carbon.h>
@@ -467,9 +467,9 @@ Tk_GetSaveFileObjCmd(
if (choiceLen &&
HandleInitialDirectory(interp, NULL, choice, &dirRef,
NULL, &initialDesc) != TCL_OK) {
- result = TCL_ERROR;
- goto end;
- }
+ result = TCL_ERROR;
+ goto end;
+ }
break;
case SAVE_INITFILE:
initialFile = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
@@ -496,7 +496,7 @@ Tk_GetSaveFileObjCmd(
break;
}
}
-
+
TkInitFileFilters(&ofd.fl);
ofd.usePopup = 0;
@@ -507,7 +507,7 @@ Tk_GetSaveFileObjCmd(
title, message, false, SAVE_FILE);
end:
-
+
AEDisposeDesc(&initialDesc);
if (title != NULL) {
CFRelease(title);
@@ -515,7 +515,7 @@ Tk_GetSaveFileObjCmd(
if (message != NULL) {
CFRelease(message);
}
-
+
return result;
}
@@ -817,21 +817,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;
}
}
@@ -846,10 +852,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
}
}
}
@@ -884,10 +894,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;
@@ -900,13 +914,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 d638906..8b8f86a 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.6 2005/08/09 07:39:20 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.7 2005/09/10 14:53:20 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.
@@ -57,8 +42,8 @@ static EventTargetRef targetRef;
*----------------------------------------------------------------------
*/
-void
-tkMacOSXFlushWindows ()
+MODULE_SCOPE void
+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;
}
@@ -182,7 +125,7 @@ TkMacOSXProcessAppleEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr)
*----------------------------------------------------------------------
*/
-int
+MODULE_SCOPE int
TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr)
{
switch (eventPtr->eClass) {
@@ -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()
+MODULE_SCOPE 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 37b98d1..d329ebc 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.4 2005/08/09 07:39:20 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.5 2005/09/10 14:53:20 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,15 +75,20 @@ 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);
+MODULE_SCOPE OSStatus TkMacOSXReceiveAndProcessEvent();
+MODULE_SCOPE void TkMacOSXFlushWindows();
+MODULE_SCOPE int TkMacOSXProcessEvent(TkMacOSXEvent *eventPtr,
+ MacEventStatus *statusPtr);
+MODULE_SCOPE int TkMacOSXProcessMouseEvent(TkMacOSXEvent *e,
+ MacEventStatus *statusPtr);
+MODULE_SCOPE int TkMacOSXProcessWindowEvent(TkMacOSXEvent *e,
+ MacEventStatus *statusPtr);
+MODULE_SCOPE int TkMacOSXProcessKeyboardEvent(TkMacOSXEvent *e,
+ MacEventStatus *statusPtr);
+MODULE_SCOPE int TkMacOSXProcessApplicationEvent(TkMacOSXEvent *e,
+ MacEventStatus *statusPtr);
-int TkMacOSXKeycodeToUnicode(
+MODULE_SCOPE int TkMacOSXKeycodeToUnicode(
UniChar * uniChars, int maxChars,
EventKind eKind,
UInt32 keycode, UInt32 modifiers,
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index bf651ca..06c1618 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.14 2005/08/09 07:39:21 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInit.c,v 1.15 2005/09/10 14:53:20 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 a9cc17a..64f4932 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.10 2005/08/09 07:39:21 das Exp $
+ * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.11 2005/09/10 14:53:21 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -135,7 +135,8 @@ static int KeycodeToUnicodeViaKCHRResource(
*----------------------------------------------------------------------
*/
-int TkMacOSXProcessKeyboardEvent(
+MODULE_SCOPE 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;
}
@@ -1143,7 +1158,7 @@ KeycodeToUnicodeViaKCHRResource(
*----------------------------------------------------------------------
*/
-int
+MODULE_SCOPE int
TkMacOSXKeycodeToUnicode(
UniChar * uniChars, int maxChars,
EventKind eKind,
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 4db2bf3..29f1040 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.19 2005/08/09 07:39:21 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.20 2005/09/10 14:53:21 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
@@ -4051,7 +4063,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 58ec4c5..7b9452c 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.4 2005/05/14 20:48:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.5 2005/09/10 14:53:21 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 163e232..a8414f3 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.13 2005/08/09 07:39:21 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.14 2005/09/10 14:53:21 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);
@@ -110,7 +110,7 @@ extern void TkMacOSXSetEatButtonUp(int f);
*----------------------------------------------------------------------
*/
-int
+MODULE_SCOPE int
TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
{
Tk_Window tkwin;
@@ -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 cf095b8..745ec67 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.12 2005/05/29 07:00:26 das Exp $
+ * RCS: @(#) $Id: tkMacOSXNotify.c,v 1.13 2005/09/10 14:53:21 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 fd111f2..f00d729 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.5 2005/08/09 07:39:21 das Exp $
+ * RCS: @(#) $Id: tkMacOSXScale.c,v 1.6 2005/09/10 14:53:21 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 b5633e7..f43dcce 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.6 2005/08/09 07:39:21 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.7 2005/09/10 14:53:21 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -96,7 +96,7 @@ static int GenerateActivateEvents( Window window, int activeFlag);
*----------------------------------------------------------------------
*/
-int
+MODULE_SCOPE int
TkMacOSXProcessApplicationEvent(
TkMacOSXEvent *eventPtr,
MacEventStatus *statusPtr)
@@ -122,10 +122,7 @@ TkMacOSXProcessApplicationEvent(
HideFloatingWindows();
break;
case kEventAppQuit:
- case kEventAppLaunchNotification:
- case kEventAppLaunched:
- case kEventAppTerminated:
- case kEventAppFrontSwitched:
+ statusPtr->stopProcessing = 1;
break;
case kEventAppHidden:
/*
@@ -176,7 +173,7 @@ TkMacOSXProcessApplicationEvent(
*----------------------------------------------------------------------
*/
-int
+MODULE_SCOPE int
TkMacOSXProcessWindowEvent(
TkMacOSXEvent * eventPtr,
MacEventStatus * statusPtr)
@@ -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 0d6ca96..3cf9e16 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.19 2005/08/09 07:39:21 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.20 2005/09/10 14:53:21 das Exp $
*/
#include <Carbon/Carbon.h>
@@ -5275,8 +5275,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 d75c52f..649d121 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.11 2005/05/29 06:47:05 das Exp $
+ * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.12 2005/09/10 14:53:21 das Exp $
*/
#include "tkInt.h"
@@ -709,6 +709,14 @@ Tk_FreeXId (
{
/* no-op function needed for stubs implementation. */
}
+
+int
+XSync (Display *display, Bool flag)
+{
+ TkMacOSXFlushWindows();
+ display->request++;
+ return 0;
+}
/*
*----------------------------------------------------------------------
diff --git a/unix/configure b/unix/configure
index 2ae379d..1807632 100755
--- a/unix/configure
+++ b/unix/configure
@@ -8238,6 +8238,13 @@ _ACEOF
LIBS="$LIBS -framework Carbon -framework IOKit"
CFLAGS="$CFLAGS -fpascal-strings"
TK_WINDOWINGSYSTEM=AQUA
+ if test "${enable_symbols+set}" = set; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TK_MAC_DEBUG 1
+_ACEOF
+
+ fi
else
#--------------------------------------------------------------------
# Locate the X11 header files and the X11 library archive. Try
diff --git a/unix/configure.in b/unix/configure.in
index cc7996a..a201158 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tk installation
dnl to configure the system for the local environment.
#
-# RCS: @(#) $Id: configure.in,v 1.110 2005/08/23 18:25:34 mdejong Exp $
+# RCS: @(#) $Id: configure.in,v 1.111 2005/09/10 14:53:21 das Exp $
AC_INIT([tk],[8.5])
AC_PREREQ(2.59)
@@ -235,6 +235,9 @@ if test $tk_aqua = yes; then
LIBS="$LIBS -framework Carbon -framework IOKit"
CFLAGS="$CFLAGS -fpascal-strings"
TK_WINDOWINGSYSTEM=AQUA
+ if test "${enable_symbols+set}" = set; then
+ AC_DEFINE(TK_MAC_DEBUG, 1, [Are TkAqua debug messages enabled?])
+ fi
else
#--------------------------------------------------------------------
# Locate the X11 header files and the X11 library archive. Try
diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in
index b272c02..ea53933 100644
--- a/unix/tkConfig.h.in
+++ b/unix/tkConfig.h.in
@@ -168,24 +168,15 @@
/* Is Tk built as a framework? */
#undef TK_FRAMEWORK
-/* Should we use <a.out.h> when doing dynamic loading? */
-#undef USE_A_OUT_H
+/* Are TkAqua debug messages enabled? */
+#undef TK_MAC_DEBUG
/* Do we need a special AIX hack for timezones? */
#undef USE_DELTA_FOR_TZ
-/* Should we use <sys/exec_aout.h> when doing dynamic loading? */
-#undef USE_SYS_EXEC_AOUT_H
-
-/* Should we use <sys/exec.h> when doing dynamic loading? */
-#undef USE_SYS_EXEC_H
-
/* Do we want to use the threaded memory allocator? */
#undef USE_THREAD_ALLOC
-/* Use the generic thread storage subsystem? */
-#undef USE_THREAD_STORAGE
-
/* Should we use vfork() instead of fork()? */
#undef USE_VFORK
diff --git a/xlib/xcolors.c b/xlib/xcolors.c
index cc88e53..21c509c 100644
--- a/xlib/xcolors.c
+++ b/xlib/xcolors.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: xcolors.c,v 1.5 2002/08/31 06:12:31 das Exp $
+ * RCS: @(#) $Id: xcolors.c,v 1.6 2005/09/10 14:53:21 das Exp $
*/
#include <tkInt.h>
@@ -820,7 +820,7 @@ FindColor(name, colorPtr)
const char *name;
XColor *colorPtr;
{
- int l, u, r, i;
+ int l, u, r, i = 0;
/*
* Count the number of elements in the color array if we haven't