summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXEvent.c
diff options
context:
space:
mode:
authordas <das>2005-09-10 14:54:17 (GMT)
committerdas <das>2005-09-10 14:54:17 (GMT)
commitb9cdc82d5a519ef9d27ee4bb737b1f4f8117b3de (patch)
treec5d114fa56aed882bdf4f126b2e1efcf0d19cb72 /macosx/tkMacOSXEvent.c
parent2fa6889f4c599bda43fd66dbc9d1c04870413e59 (diff)
downloadtk-b9cdc82d5a519ef9d27ee4bb737b1f4f8117b3de.zip
tk-b9cdc82d5a519ef9d27ee4bb737b1f4f8117b3de.tar.gz
tk-b9cdc82d5a519ef9d27ee4bb737b1f4f8117b3de.tar.bz2
* 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/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.13 * library/listbox.tcl: corrected comments. * library/text.tcl: * xlib/xcolors.c: fixed warning
Diffstat (limited to 'macosx/tkMacOSXEvent.c')
-rw-r--r--macosx/tkMacOSXEvent.c140
1 files changed, 34 insertions, 106 deletions
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;
}