From b5562132e5471c9ed3f714a12f8976d229e5ce0b Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 3 Dec 2004 03:14:17 +0000 Subject: [PATCH] Fl::event_number() didn't always match the value sent to the handle() method (STR #634) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3930 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ FL/Fl_Free.H | 14 +++++++------- src/Fl.cxx | 24 ++++++++++++++++++------ src/Fl_Group.cxx | 8 +++++--- src/Fl_mac.cxx | 16 +++++++++++----- src/Fl_win32.cxx | 8 +++++--- src/Fl_x.cxx | 12 ++++++++---- src/fl_dnd_mac.cxx | 8 +++++--- src/fl_dnd_win32.cxx | 16 +++++++++++----- src/forms_free.cxx | 8 +++++--- 10 files changed, 77 insertions(+), 39 deletions(-) diff --git a/CHANGES b/CHANGES index c324d1f4f..01752e376 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ CHANGES IN FLTK 1.1.7 + - Fl::event_number() didn't always match the value sent + to the handle() method (STR #634) - Fl_Shared_Image::reload() didn't set the image_ pointer properly in all cases (STR #632) - Fl_Help_View::topline() incorrectly set the changed() diff --git a/FL/Fl_Free.H b/FL/Fl_Free.H index 27e2e04dd..8f14c0966 100644 --- a/FL/Fl_Free.H +++ b/FL/Fl_Free.H @@ -1,5 +1,5 @@ // -// "$Id: Fl_Free.H,v 1.5.2.4.2.4 2004/04/11 04:38:54 easysw Exp $" +// "$Id: Fl_Free.H,v 1.5.2.4.2.5 2004/12/03 03:14:15 easysw Exp $" // // Forms free header file for the Fast Light Tool Kit (FLTK). // @@ -51,14 +51,14 @@ public: // old event names for compatability: #define FL_MOUSE FL_DRAG -#define FL_DRAW 0 -#define FL_STEP 9 -#define FL_FREEMEM 12 -#define FL_FREEZE FL_UNMAP -#define FL_THAW FL_MAP +#define FL_DRAW 100 // NOT USED +#define FL_STEP 101 +#define FL_FREEMEM 102 // NOT USED +#define FL_FREEZE 103 // NOT USED +#define FL_THAW 104 // NOT USED #endif // -// End of "$Id: Fl_Free.H,v 1.5.2.4.2.4 2004/04/11 04:38:54 easysw Exp $". +// End of "$Id: Fl_Free.H,v 1.5.2.4.2.5 2004/12/03 03:14:15 easysw Exp $". // diff --git a/src/Fl.cxx b/src/Fl.cxx index 42f0a94b5..79ef28a0f 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.24.2.41.2.71 2004/11/23 19:50:58 easysw Exp $" +// "$Id: Fl.cxx,v 1.24.2.41.2.72 2004/12/03 03:14:15 easysw Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -447,10 +447,13 @@ void Fl::focus(Fl_Widget *o) { Fl::compose_reset(); focus_ = o; fl_oldfocus = 0; + int old_event = e_number; + e_number = FL_UNFOCUS; for (; p; p = p->parent()) { p->handle(FL_UNFOCUS); fl_oldfocus = p; } + e_number = old_event; } } @@ -461,9 +464,12 @@ void Fl::belowmouse(Fl_Widget *o) { Fl_Widget *p = belowmouse_; if (o != p) { belowmouse_ = o; + int old_event = e_number; + e_number = dnd_flag ? FL_DND_LEAVE : FL_LEAVE; for (; p && !p->contains(o); p = p->parent()) { - p->handle(dnd_flag ? FL_DND_LEAVE : FL_LEAVE); + p->handle(e_number); } + e_number = old_event; } } @@ -516,13 +522,17 @@ void fl_fix_focus() { if (w) { if (Fl::modal()) w = Fl::modal(); if (!w->contains(Fl::belowmouse())) { - w->handle(FL_ENTER); + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_ENTER); + Fl::e_number = old_event; if (!w->contains(Fl::belowmouse())) Fl::belowmouse(w); } else { // send a FL_MOVE event so the enter/leave state is up to date Fl::e_x = Fl::e_x_root-fl_xmousewin->x(); Fl::e_y = Fl::e_y_root-fl_xmousewin->y(); - w->handle(FL_MOVE); + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_MOVE); + Fl::e_number = old_event; } } else { Fl::belowmouse(0); @@ -568,6 +578,7 @@ void fl_throw_focus(Fl_Widget *o) { // window the event was posted to by X: static int send(int event, Fl_Widget* to, Fl_Window* window) { int dx, dy; + int old_event = Fl::e_number; if (window) { dx = window->x(); dy = window->y(); @@ -578,7 +589,8 @@ static int send(int event, Fl_Widget* to, Fl_Window* window) { if (w->type()>=FL_WINDOW) {dx -= w->x(); dy -= w->y();} int save_x = Fl::e_x; Fl::e_x += dx; int save_y = Fl::e_y; Fl::e_y += dy; - int ret = to->handle(event); + int ret = to->handle(Fl::e_number = event); + Fl::e_number = old_event; Fl::e_y = save_y; Fl::e_x = save_x; return ret; @@ -1096,5 +1108,5 @@ Fl::do_widget_deletion() { // -// End of "$Id: Fl.cxx,v 1.24.2.41.2.71 2004/11/23 19:50:58 easysw Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.41.2.72 2004/12/03 03:14:15 easysw Exp $". // diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index 522ff0da3..a3680a678 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Group.cxx,v 1.8.2.8.2.25 2004/10/18 20:22:22 easysw Exp $" +// "$Id: Fl_Group.cxx,v 1.8.2.8.2.26 2004/12/03 03:14:16 easysw Exp $" // // Group widget for the Fast Light Tool Kit (FLTK). // @@ -227,7 +227,9 @@ int Fl_Group::handle(int event) { o = *a++; if (event == FL_HIDE && o == Fl::focus()) { // Give up input focus... - o->handle(FL_UNFOCUS); + int old_event = Fl::e_number; + o->handle(Fl::e_number = FL_UNFOCUS); + Fl::e_number = old_event; Fl::focus(0); } if (o->visible()) o->handle(event); @@ -591,5 +593,5 @@ void Fl_Group::draw_outside_label(const Fl_Widget& widget) const { } // -// End of "$Id: Fl_Group.cxx,v 1.8.2.8.2.25 2004/10/18 20:22:22 easysw Exp $". +// End of "$Id: Fl_Group.cxx,v 1.8.2.8.2.26 2004/12/03 03:14:16 easysw Exp $". // diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 9f7af2e01..d7d5786c9 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_mac.cxx,v 1.1.2.65 2004/11/23 00:28:35 matthiaswm Exp $" +// "$Id: Fl_mac.cxx,v 1.1.2.66 2004/12/03 03:14:16 easysw Exp $" // // MacOS specific code for the Fast Light Tool Kit (FLTK). // @@ -1548,7 +1548,9 @@ static pascal OSErr dndReceiveHandler( WindowPtr w, void *userData, DragReferenc // if ( Fl::e_text[Fl::e_length-1]==0 ) Fl::e_length--; // modify, if trailing 0 is part of string Fl::e_length = dst - Fl::e_text - 1; // printf("Sending following text to widget %p:\n%s\n", Fl::belowmouse(), Fl::e_text); - target->handle(FL_PASTE); + int old_event = Fl::e_number; + target->handle(Fl::e_number = FL_PASTE); + Fl::e_number = old_event; free( Fl::e_text ); fl_dnd_target_window = 0L; @@ -1591,7 +1593,9 @@ void Fl_X::make(Fl_Window* w) x->wait_for_expose = 0; x->next = Fl_X::first; // must be in the list for ::flush() Fl_X::first = x; - w->handle(FL_SHOW); + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_SHOW); + Fl::e_number = old_event; w->redraw(); // force draw to happen } fl_show_iconic = 0; @@ -1760,7 +1764,9 @@ void Fl_X::make(Fl_Window* w) w->x(rect.left); w->y(rect.top); w->w(rect.right-rect.left); w->h(rect.bottom-rect.top); - w->handle(FL_SHOW); + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_SHOW); + Fl::e_number = old_event; w->redraw(); // force draw to happen w->set_visible(); @@ -2065,6 +2071,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { // -// End of "$Id: Fl_mac.cxx,v 1.1.2.65 2004/11/23 00:28:35 matthiaswm Exp $". +// End of "$Id: Fl_mac.cxx,v 1.1.2.66 2004/12/03 03:14:16 easysw Exp $". // diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 5573a8848..f9fb43657 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_win32.cxx,v 1.33.2.37.2.51 2004/10/19 18:21:52 easysw Exp $" +// "$Id: Fl_win32.cxx,v 1.33.2.37.2.52 2004/12/03 03:14:16 easysw Exp $" // // WIN32-specific code for the Fast Light Tool Kit (FLTK). // @@ -1095,7 +1095,9 @@ Fl_X* Fl_X::make(Fl_Window* w) { if (fl_show_iconic) {showit = 0; fl_show_iconic = 0;} if (showit) { w->set_visible(); - w->handle(FL_SHOW); // get child windows to appear + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_SHOW); // get child windows to appear + Fl::e_number = old_event; w->redraw(); // force draw to happen } // If we've captured the mouse, we dont want do activate any @@ -1242,5 +1244,5 @@ void Fl_Window::make_current() { } // -// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.51 2004/10/19 18:21:52 easysw Exp $". +// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.52 2004/12/03 03:14:16 easysw Exp $". // diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 136af7c62..7649d9ba2 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_x.cxx,v 1.24.2.24.2.40 2004/11/20 13:52:47 easysw Exp $" +// "$Id: Fl_x.cxx,v 1.24.2.24.2.41 2004/12/03 03:14:16 easysw Exp $" // // X specific code for the Fast Light Tool Kit (FLTK). // @@ -555,7 +555,9 @@ int fl_handle(const XEvent& thisevent) } Fl::e_text = buffer ? (char*)buffer : (char *)""; Fl::e_length = bytesread; - fl_selection_requestor->handle(FL_PASTE); + int old_event = Fl::e_number; + fl_selection_requestor->handle(Fl::e_number = FL_PASTE); + Fl::e_number = old_event; // Detect if this paste is due to Xdnd by the property name (I use // XA_SECONDARY for that) and send an XdndFinished message. It is not // clear if this has to be delayed until now or if it can be done @@ -1140,7 +1142,9 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap) XMapWindow(fl_display, xp->xid); if (showit) { win->set_visible(); - win->handle(FL_SHOW); // get child windows to appear + int old_event = Fl::e_number; + win->handle(Fl::e_number = FL_SHOW); // get child windows to appear + Fl::e_number = old_event; win->redraw(); } } @@ -1299,5 +1303,5 @@ void Fl_Window::make_current() { #endif // -// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.40 2004/11/20 13:52:47 easysw Exp $". +// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.41 2004/12/03 03:14:16 easysw Exp $". // diff --git a/src/fl_dnd_mac.cxx b/src/fl_dnd_mac.cxx index 257540be9..302d5c69f 100644 --- a/src/fl_dnd_mac.cxx +++ b/src/fl_dnd_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_dnd_mac.cxx,v 1.1.2.7 2004/09/09 21:34:47 matthiaswm Exp $" +// "$Id: fl_dnd_mac.cxx,v 1.1.2.8 2004/12/03 03:14:17 easysw Exp $" // // Drag & Drop code for the Fast Light Tool Kit (FLTK). // @@ -71,7 +71,9 @@ int Fl::dnd() Fl_Widget *w = Fl::pushed(); if ( w ) { - w->handle( FL_RELEASE ); + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_RELEASE); + Fl::e_number = old_event; Fl::pushed( 0 ); } @@ -84,5 +86,5 @@ int Fl::dnd() // -// End of "$Id: fl_dnd_mac.cxx,v 1.1.2.7 2004/09/09 21:34:47 matthiaswm Exp $". +// End of "$Id: fl_dnd_mac.cxx,v 1.1.2.8 2004/12/03 03:14:17 easysw Exp $". // diff --git a/src/fl_dnd_win32.cxx b/src/fl_dnd_win32.cxx index b6c1c3fba..4ab73356c 100644 --- a/src/fl_dnd_win32.cxx +++ b/src/fl_dnd_win32.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_dnd_win32.cxx,v 1.5.2.16 2004/04/11 04:38:59 easysw Exp $" +// "$Id: fl_dnd_win32.cxx,v 1.5.2.17 2004/12/03 03:14:17 easysw Exp $" // // Drag & Drop code for the Fast Light Tool Kit (FLTK). // @@ -172,7 +172,9 @@ public: //long len = GlobalSize( medium.hGlobal ); Fl::e_length = strlen( (char*)stuff ); // min(strlen, len) Fl::e_text = (char*)stuff; - Fl::belowmouse()->handle(FL_PASTE); // e_text will be invalid after this call + int old_event = Fl::e_number; + Fl::belowmouse()->handle(Fl::e_number = FL_PASTE); // e_text will be invalid after this call + Fl::e_number = old_event; GlobalUnlock( medium.hGlobal ); ReleaseStgMedium( &medium ); SetForegroundWindow( hwnd ); @@ -197,7 +199,9 @@ public: if ( ihandle(FL_PASTE); + int old_event = Fl::e_number; + Fl::belowmouse()->handle(Fl::e_number = FL_PASTE); + Fl::e_number = old_event; free( Fl::e_text ); ReleaseStgMedium( &medium ); SetForegroundWindow( hwnd ); @@ -333,7 +337,9 @@ int Fl::dnd() Fl_Widget *w = Fl::pushed(); if ( w ) { - w->handle( FL_RELEASE ); + int old_event = Fl::e_number; + w->handle(Fl::e_number = FL_RELEASE); + Fl::e_number = old_event; Fl::pushed( 0 ); } if ( ret==DRAGDROP_S_DROP ) return 1; // or DD_S_CANCEL @@ -349,5 +355,5 @@ int Fl::dnd() // -// End of "$Id: fl_dnd_win32.cxx,v 1.5.2.16 2004/04/11 04:38:59 easysw Exp $". +// End of "$Id: fl_dnd_win32.cxx,v 1.5.2.17 2004/12/03 03:14:17 easysw Exp $". // diff --git a/src/forms_free.cxx b/src/forms_free.cxx index a3e838a5c..9ffe0d1a1 100644 --- a/src/forms_free.cxx +++ b/src/forms_free.cxx @@ -1,5 +1,5 @@ // -// "$Id: forms_free.cxx,v 1.4.2.4.2.4 2004/04/11 04:39:00 easysw Exp $" +// "$Id: forms_free.cxx,v 1.4.2.4.2.5 2004/12/03 03:14:17 easysw Exp $" // // Forms free widget routines for the Fast Light Tool Kit (FLTK). // @@ -33,7 +33,9 @@ void Fl_Free::step(void *v) { Fl_Free *f = (Fl_Free *)v; - f->handle(FL_STEP); + int old_event = Fl::e_number; + f->handle(Fl::e_number == FL_STEP); + Fl::e_number = old_event; Fl::add_timeout(.01,step,v); } @@ -73,5 +75,5 @@ int Fl_Free::handle(int e) { } // -// End of "$Id: forms_free.cxx,v 1.4.2.4.2.4 2004/04/11 04:39:00 easysw Exp $". +// End of "$Id: forms_free.cxx,v 1.4.2.4.2.5 2004/12/03 03:14:17 easysw Exp $". //