diff options
author | hobbs <hobbs> | 2002-06-15 00:21:41 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2002-06-15 00:21:41 (GMT) |
commit | 5c1e5bf298b329ec7a45cd601f6b4b208b24411b (patch) | |
tree | 25e00fe02d0a56b2865927347847b8561353fd94 | |
parent | 36d7ac0a1dfb49f2c05b66ff69dfc5cfabf3ebb6 (diff) | |
download | tk-5c1e5bf298b329ec7a45cd601f6b4b208b24411b.zip tk-5c1e5bf298b329ec7a45cd601f6b4b208b24411b.tar.gz tk-5c1e5bf298b329ec7a45cd601f6b4b208b24411b.tar.bz2 |
* generic/tk.decls: added TIP #84 implementation that adds a
* generic/tkDecls.h: Tk_CollapseMotionEvents API which controls
* generic/tkEvent.c: Tk's collapsing of incoming motion events
* generic/tkInt.h: on its windows. The default remains to do
* generic/tkStubInit.c: collapsing. Added a flags parameter to the
* generic/tkWindow.c: internal display structure to support this
* doc/QWinEvent.3: and be used in the future for other bits.
-rw-r--r-- | doc/QWinEvent.3 | 27 | ||||
-rw-r--r-- | generic/tk.decls | 6 | ||||
-rw-r--r-- | generic/tkDecls.h | 10 | ||||
-rw-r--r-- | generic/tkEvent.c | 49 | ||||
-rw-r--r-- | generic/tkInt.h | 9 | ||||
-rw-r--r-- | generic/tkStubInit.c | 3 | ||||
-rw-r--r-- | generic/tkWindow.c | 7 |
7 files changed, 97 insertions, 14 deletions
diff --git a/doc/QWinEvent.3 b/doc/QWinEvent.3 index cd80f71..15492dc 100644 --- a/doc/QWinEvent.3 +++ b/doc/QWinEvent.3 @@ -4,20 +4,27 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: QWinEvent.3,v 1.2 1998/09/14 18:22:53 stanton Exp $ +'\" RCS: @(#) $Id: QWinEvent.3,v 1.3 2002/06/15 00:21:42 hobbs Exp $ '\" .so man.macros .TH Tk_QueueWindowEvent 3 7.5 Tk "Tk Library Procedures" .BS .SH NAME -Tk_QueueWindowEvent \- Add a window event to the Tcl event queue +Tk_CollapseMotionEvents, Tk_QueueWindowEvent \- Add a window event to the Tcl event queue .SH SYNOPSIS .nf \fB#include <tk.h>\fR .sp +int +\fBTk_CollapseMotionEvents\fR(\fIdisplay, collapse\fR) +.sp \fBTk_QueueWindowEvent\fR(\fIeventPtr, position\fR) .SH ARGUMENTS .AS Tcl_QueuePosition position +.AP Display *display in +Display for which to control motion event collapsing. +.AP int collapse in +Indicates whether motion events should be collapsed or not. .AP XEvent *eventPtr in An event to add to the event queue. .AP Tcl_QueuePosition position in @@ -27,16 +34,20 @@ Where to add the new event in the queue: \fBTCL_QUEUE_TAIL\fR, .SH DESCRIPTION .PP -This procedure places a window event on Tcl's -internal event queue for eventual servicing. It creates a -Tcl_Event structure, copies the event into that structure, -and calls \fBTcl_QueueEvent\fR to add the event to the queue. -When the event is eventually removed from the queue it is +\fBTk_QueueWindowEvent\fR places a window event on Tcl's internal event +queue for eventual servicing. It creates a Tcl_Event structure, copies the +event into that structure, and calls \fBTcl_QueueEvent\fR to add the event +to the queue. When the event is eventually removed from the queue it is processed just like all window events. .PP +When multiple motion events are received for the same window in rapid +succession, they are collapsed by default. This behavior can be controlled +with \fBTk_CollapseMotionEvents\fR. \fBTk_CollapseMotionEvents\fR always +returns the previous value for collapse behavior on the \fIdisplay\fR. +.PP The \fIposition\fR argument to \fBTk_QueueWindowEvent\fR has the same significance as for \fBTcl_QueueEvent\fR; see the documentation for \fBTcl_QueueEvent\fR for details. .SH KEYWORDS -callback, clock, handler, modal timeout +callback, clock, handler, modal timeout, events diff --git a/generic/tk.decls b/generic/tk.decls index d3a7866..317baca 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -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: tk.decls,v 1.20 2002/06/14 14:07:50 dkf Exp $ +# RCS: @(#) $Id: tk.decls,v 1.21 2002/06/15 00:21:41 hobbs Exp $ library tk @@ -1176,6 +1176,10 @@ declare 247 generic { int subsampleX, int subsampleY, int compRule) } +declare 248 generic { + int Tk_CollapseMotionEvents (Display *display, int collapse) +} + # Define the platform specific public Tk interface. These functions are # only available on the designated platform. diff --git a/generic/tkDecls.h b/generic/tkDecls.h index 431b284..8c7daa4 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkDecls.h,v 1.20 2002/06/14 14:08:22 dkf Exp $ + * RCS: @(#) $Id: tkDecls.h,v 1.21 2002/06/15 00:21:41 hobbs Exp $ */ #ifndef _TKDECLS @@ -857,6 +857,9 @@ EXTERN void Tk_PhotoPutZoomedBlock _ANSI_ARGS_(( Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule)); +/* 248 */ +EXTERN int Tk_CollapseMotionEvents _ANSI_ARGS_(( + Display * display, int collapse)); typedef struct TkStubHooks { struct TkPlatStubs *tkPlatStubs; @@ -1117,6 +1120,7 @@ typedef struct TkStubs { void (*tk_SetCaretPos) _ANSI_ARGS_((Tk_Window tkwin, int x, int y, int height)); /* 245 */ void (*tk_PhotoPutBlock) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int compRule)); /* 246 */ void (*tk_PhotoPutZoomedBlock) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule)); /* 247 */ + int (*tk_CollapseMotionEvents) _ANSI_ARGS_((Display * display, int collapse)); /* 248 */ } TkStubs; #ifdef __cplusplus @@ -2119,6 +2123,10 @@ extern TkStubs *tkStubsPtr; #define Tk_PhotoPutZoomedBlock \ (tkStubsPtr->tk_PhotoPutZoomedBlock) /* 247 */ #endif +#ifndef Tk_CollapseMotionEvents +#define Tk_CollapseMotionEvents \ + (tkStubsPtr->tk_CollapseMotionEvents) /* 248 */ +#endif #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 68887f1..8ceb358 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.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: tkEvent.c,v 1.11 2002/06/14 23:49:13 mdejong Exp $ + * RCS: @(#) $Id: tkEvent.c,v 1.12 2002/06/15 00:21:42 hobbs Exp $ */ #include "tkPort.h" @@ -1171,6 +1171,40 @@ Tk_RestrictEvents(proc, arg, prevArgPtr) /* *---------------------------------------------------------------------- * + * Tk_CollapseMotionEvents -- + * + * This procedure controls whether we collapse motion events in a + * particular display or not. + * + * Results: + * The return value is the previous collapse value in effect. + * + * Side effects: + * Filtering of motion events may be changed after calling this. + * + *---------------------------------------------------------------------- + */ + +int +Tk_CollapseMotionEvents(display, collapse) + Display *display; /* Display handling these events. */ + int collapse; /* boolean value that specifies whether + * motion events should be collapsed. */ +{ + TkDisplay *dispPtr = (TkDisplay *) display; + int prev = (dispPtr->flags & TK_DISPLAY_COLLAPSE_MOTION_EVENTS); + + if (collapse) { + dispPtr->flags |= TK_DISPLAY_COLLAPSE_MOTION_EVENTS; + } else { + dispPtr->flags &= ~TK_DISPLAY_COLLAPSE_MOTION_EVENTS; + } + return prev; +} + +/* + *---------------------------------------------------------------------- + * * Tk_QueueWindowEvent -- * * Given an X-style window event, this procedure adds it to the @@ -1212,6 +1246,19 @@ Tk_QueueWindowEvent(eventPtr, position) } } + /* + * Don't filter motion events if the user + * defaulting to true (1), which could be set to false (0) when the + * user wishes to receive all the motion data) + */ + if (!(dispPtr->flags & TK_DISPLAY_COLLAPSE_MOTION_EVENTS)) { + wevPtr = (TkWindowEvent *) ckalloc(sizeof(TkWindowEvent)); + wevPtr->header.proc = WindowEventProc; + wevPtr->event = *eventPtr; + Tcl_QueueEvent(&wevPtr->header, position); + return; + } + if ((dispPtr->delayedMotionPtr != NULL) && (position == TCL_QUEUE_TAIL)) { if ((eventPtr->type == MotionNotify) && (eventPtr->xmotion.window == dispPtr->delayedMotionPtr->event.xmotion.window)) { diff --git a/generic/tkInt.h b/generic/tkInt.h index 75ac87f..0849d7e 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -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: tkInt.h,v 1.44 2002/04/12 10:06:09 hobbs Exp $ + * RCS: $Id: tkInt.h,v 1.45 2002/06/15 00:21:42 hobbs Exp $ */ #ifndef _TKINT @@ -493,8 +493,15 @@ typedef struct TkDisplay { * The following field(s) were all added for Tk8.4 */ long deletionEpoch; /* Incremented by window deletions */ + unsigned int flags; /* Various flag values: these are all + * defined in below. */ } TkDisplay; +/* + * Flag values for TkDisplay flags. + */ + +#define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) /* * One of the following structures exists for each error handler diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index dafa12d..43a081f 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubInit.c,v 1.35 2002/06/14 14:08:23 dkf Exp $ + * RCS: @(#) $Id: tkStubInit.c,v 1.36 2002/06/15 00:21:42 hobbs Exp $ */ #include "tkInt.h" @@ -898,6 +898,7 @@ TkStubs tkStubs = { Tk_SetCaretPos, /* 245 */ Tk_PhotoPutBlock, /* 246 */ Tk_PhotoPutZoomedBlock, /* 247 */ + Tk_CollapseMotionEvents, /* 248 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 5c1fd17..6bee9fa 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.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: tkWindow.c,v 1.46 2002/06/14 22:25:12 jenglish Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.47 2002/06/15 00:21:42 hobbs Exp $ */ #include "tkPort.h" @@ -470,6 +470,11 @@ GetScreen(interp, screenName, screenPtr) dispPtr->cursorFont = None; dispPtr->warpWindow = None; dispPtr->multipleAtom = None; + /* + * By default we do want to collapse motion events in + * Tk_QueueWindowEvent. + */ + dispPtr->flags |= TK_DISPLAY_COLLAPSE_MOTION_EVENTS; Tcl_InitHashTable(&dispPtr->winTable, TCL_ONE_WORD_KEYS); |