gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gui.cpp gui/gui...


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gui.cpp gui/gui...
Date: Thu, 27 Jul 2006 00:15:23 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     06/07/27 00:15:22

Modified files:
        .              : ChangeLog 
        gui            : gtk.cpp gui.cpp gui.h sdl.cpp 
        plugin         : plugin.cpp 
        server         : movie.h movie_interface.h movie_root.cpp 
                         movie_root.h 

Log message:
                * gui/{gtk.cpp, gui.cpp, gui.h, sdl.cpp}, server/{movie.h,
                movie_interface.h, movie_root.cpp, movie_root.h}: Make sure 
that no
                mouse events are ignored by handling them outside of the 
advance_movie
                loop.
        
                * plugin/plugin.cpp: Don't assume anything about the value of
                string::npos.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.532&r2=1.533
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/sdl.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/plugin/plugin.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_interface.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.6&r2=1.7

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.532
retrieving revision 1.533
diff -u -b -r1.532 -r1.533
--- ChangeLog   26 Jul 2006 21:49:05 -0000      1.532
+++ ChangeLog   27 Jul 2006 00:15:22 -0000      1.533
@@ -1,3 +1,14 @@
+2006-07-27 Ivor Blockley <address@hidden>
+
+       * gui/{gtk.cpp, gui.cpp, gui.h, sdl.cpp}, server/{movie.h,
+       movie_interface.h, movie_root.cpp, movie_root.h}: Make sure that no
+       mouse events are ignored by handling them outside of the advance_movie
+       loop.
+
+2006-07-27 Sebastià Annonygmouse <address@hidden>
+
+       * plugin/plugin.cpp: Don't assume anything about the value of
+       string::npos.
 
 2006-07-26 Tomas Groth Christensen <address@hidden>
 

Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- gui/gtk.cpp 15 Jul 2006 16:02:23 -0000      1.13
+++ gui/gtk.cpp 27 Jul 2006 00:15:22 -0000      1.14
@@ -528,15 +528,10 @@
                            const gpointer data)
 {
     GNASH_REPORT_FUNCTION;
-
     Gui *obj = static_cast<Gui *>(data);
-    int        mask = 1 << (event->button - 1);
-    int buttons = obj->getMouseButtons();
-    obj->setMouseButtons(buttons |= mask);
-    float scale = obj->getScale();
-    obj->setMouseX(int(event->x / scale));
-    obj->setMouseY(int(event->y / scale));
 
+    int        mask = 1 << (event->button - 1);
+    obj->notify_mouse_clicked(true, mask);
     return true;
 }
 
@@ -547,14 +542,9 @@
 {
     GNASH_REPORT_FUNCTION;
     Gui *obj = static_cast<Gui *>(data);
-    int        mask = 1 << (event->button - 1);
-    int buttons = obj->getMouseButtons();
-
-    obj->setMouseButtons(buttons &= ~mask);
-    float scale = obj->getScale();
-    obj->setMouseX(int(event->x / scale));
-    obj->setMouseY(int(event->y / scale));
 
+    int        mask = 1 << (event->button - 1);
+    obj->notify_mouse_clicked(false, mask);
     return true;
 }
 
@@ -567,9 +557,7 @@
     Gui *obj = static_cast<Gui *>(data);
 
     float scale = obj->getScale();
-    obj->setMouseX(int(event->x / scale));
-    obj->setMouseY(int(event->y / scale));
-
+    obj->notify_mouse_moved(int(event->x / scale), int(event->y / scale));
     return true;
 }
 

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- gui/gui.cpp 15 Jul 2006 16:02:23 -0000      1.10
+++ gui/gui.cpp 27 Jul 2006 00:15:22 -0000      1.11
@@ -57,10 +57,7 @@
     _xid(0),
     _width(0),
     _height(0),
-    _mouse_x(0),
-    _mouse_y(0),
     _scale(1.0f),
-    _mouse_buttons(0),
     _depth(16)
 #if defined(FIX_I810_LOD_BIAS)
    ,_tex_lod_bias(-1.2f)
@@ -74,10 +71,7 @@
     _xid(xid),
     _width(0),
     _height(0),
-    _mouse_x(0),
-    _mouse_y(0),
     _scale(scale),
-    _mouse_buttons(0),
     _depth(depth)
 #if defined(FIX_I810_LOD_BIAS)
    ,_tex_lod_bias(-1.2f)
@@ -191,6 +185,18 @@
     m->goto_frame(m->get_current_frame()-10);
 }
 
+void
+Gui::notify_mouse_moved(int x, int y) 
+{
+    get_current_root()->notify_mouse_moved(x, y);
+}
+
+void
+Gui::notify_mouse_clicked(bool mouse_pressed, int mask) 
+{
+    get_current_root()->notify_mouse_clicked(mouse_pressed, mask);
+}
+
 bool
 Gui::advance_movie(void *data)
 {
@@ -199,9 +205,6 @@
     Gui *gui = reinterpret_cast<Gui*> (data);
     gnash::movie_interface* m = gnash::get_current_root();
 
-//     log_msg("Mouse(x,y): %d,%d", gui->getMouseX(), gui->getMouseY());
-    m->notify_mouse_state(gui->getMouseX(), gui->getMouseY(), 
gui->getMouseButtons());
-
     m->advance(1.0);
     m->display();
     

Index: gui/gui.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gui/gui.h   15 Jul 2006 16:02:23 -0000      1.7
+++ gui/gui.h   27 Jul 2006 00:15:22 -0000      1.8
@@ -70,12 +70,6 @@
     virtual bool setupEvents() = 0;
     virtual void renderBuffer() = 0;
 
-    void setMouseX(int x)           { _mouse_x = x; }
-    void setMouseY(int y)           { _mouse_y= y; }
-    void setMouseButtons(int mask)  { _mouse_buttons = mask; }
-    int getMouseX()                 { return _mouse_x; }
-    int getMouseY()                 { return _mouse_y; }
-    int getMouseButtons()           { return _mouse_buttons; }
     float getScale()                { return _scale; }
     bool loops()                    { return _loop; }
 
@@ -92,6 +86,8 @@
     static void menu_step_backward();
     static void menu_jump_forward();
     static void menu_jump_backward();
+    static void notify_mouse_moved(int x, int y);
+    static void notify_mouse_clicked(bool mouse_pressed, int mask);
     static bool advance_movie(void *data);
     static void resize_view(int width, int height);
 
@@ -100,10 +96,7 @@
     unsigned long   _xid;
     int             _width;
     int             _height;
-    int             _mouse_x;
-    int             _mouse_y;
     float           _scale;
-    int             _mouse_buttons;
     int             _depth;
     std::string     _name;
     callback_t      _mouse_handler;

Index: gui/sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/sdl.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gui/sdl.cpp 15 Jul 2006 16:02:23 -0000      1.9
+++ gui/sdl.cpp 27 Jul 2006 00:15:22 -0000      1.10
@@ -84,6 +84,9 @@
 SDLGui::run(void *arg)
 {
     GNASH_REPORT_FUNCTION;
+    int x_old = -1;
+    int y_old = -1;
+    int button_state_old = -1;
 
     SDL_Event  event;
     while (true) {
@@ -97,17 +100,25 @@
 
         switch (event.type) {
           case SDL_MOUSEMOTION:
-            _mouse_x = (int) (event.motion.x / _scale);
-            _mouse_y = (int) (event.motion.y / _scale);
+            // SDL can generate MOUSEMOTION events even without mouse movement
+            if (event.motion.x == x_old && event.motion.y == y_old) { break; }
+            x_old = event.motion.x;
+            y_old = event.motion.y;
+            notify_mouse_moved((int) (x_old / _scale), (int) (y_old / _scale));
             break;
           case SDL_MOUSEBUTTONDOWN:
           case SDL_MOUSEBUTTONUP:
           {
             int        mask = 1 << (event.button.button - 1);
             if (event.button.state == SDL_PRESSED) {
-                _mouse_buttons |= mask;
+                // multiple events will be fired while the mouse is held down
+                // we are interested only in a change in the mouse state:
+                if (event.button.button == button_state_old) { break; }
+                notify_mouse_clicked(true, mask);
+                button_state_old = event.button.button;
             } else {
-                _mouse_buttons &= ~mask;
+                notify_mouse_clicked(false, mask);
+                button_state_old = -1;
             }
             break;
           }

Index: plugin/plugin.cpp
===================================================================
RCS file: /sources/gnash/gnash/plugin/plugin.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- plugin/plugin.cpp   16 Jul 2006 21:42:35 -0000      1.34
+++ plugin/plugin.cpp   27 Jul 2006 00:15:22 -0000      1.35
@@ -538,7 +538,7 @@
            start++;
        }
        end = opts.find("&", start);
-       if (end <= 0) {
+       if (end == string::npos) {
            end = opts.size();
        }
        if (eq == string::npos) {

Index: server/movie.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/movie.h      28 Jun 2006 23:27:44 -0000      1.11
+++ server/movie.h      27 Jul 2006 00:15:22 -0000      1.12
@@ -226,6 +226,22 @@
        }
 
        /// \brief
+        /// The host app can use this to tell the movie when
+        /// user's mouse pointer has moved.
+        virtual void notify_mouse_moved(int /*x*/, int /*y*/)
+        {
+           GNASH_REPORT_FUNCTION;
+        }
+
+       /// \brief
+        /// The host app can use this to tell the movie when a
+        /// button on the user's mouse has been pressed or released.
+        /// Set mouse_pressed to true on click, false on release.
+        virtual void notify_mouse_clicked(bool /*mouse_pressed*/, int /*mask*/)
+        {
+           GNASH_REPORT_FUNCTION;
+        }
+       /// \brief
        /// The host app uses this to tell the movie where the
        /// user's mouse pointer is.
        virtual void notify_mouse_state(int /*x*/, int /*y*/, int /*buttons*/)

Index: server/movie_interface.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_interface.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/movie_interface.h    28 Jun 2006 23:27:44 -0000      1.3
+++ server/movie_interface.h    27 Jul 2006 00:15:22 -0000      1.4
@@ -100,6 +100,8 @@
        virtual void    set_display_viewport(int x0, int y0, int w, int h) = 0;
        
        /// Input.
+        virtual void    notify_mouse_moved(int x, int y) = 0;
+        virtual void    notify_mouse_clicked(bool mouse_pressed, int mask) = 0;
        virtual void    notify_mouse_state(int x, int y, int buttons) = 0;
        
        /// Set an ActionScript variable within this movie.

Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- server/movie_root.cpp       10 Jul 2006 13:47:12 -0000      1.7
+++ server/movie_root.cpp       27 Jul 2006 00:15:22 -0000      1.8
@@ -115,16 +115,46 @@
     m_pixel_scale = fmax(scale_x, scale_y);
 }
 
+void
+movie_root::notify_mouse_moved(int x, int y)
+{
+    m_mouse_x = x;
+    m_mouse_y = y;
+    fire_mouse_event();
+}
+
+void
+movie_root::notify_mouse_clicked(bool mouse_pressed, int button_mask)
+{
+    if (mouse_pressed) {
+        m_mouse_buttons |= button_mask;
+    } else {
+        m_mouse_buttons &= ~button_mask;
+    }
+    fire_mouse_event();
+}
 
 void
 movie_root::notify_mouse_state(int x, int y, int buttons)
 {
-//         GNASH_REPORT_FUNCTION;
-//             dbglogfile << "X is: " << x << " Y is: " << y << " Button is: "
-//                        << buttons << endl;
     m_mouse_x = x;
     m_mouse_y = y;
     m_mouse_buttons = buttons;
+    fire_mouse_event();
+}
+
+void
+movie_root::fire_mouse_event()
+{
+//         GNASH_REPORT_FUNCTION;
+//             dbglogfile << "X is: " << x << " Y is: " << y << " Button is: "
+//                        << buttons << endl;
+
+    // Generate a mouse event
+    m_mouse_button_state.m_topmost_entity =
+        m_movie->get_topmost_mouse_entity(PIXELS_TO_TWIPS(m_mouse_x), 
PIXELS_TO_TWIPS(m_mouse_y));
+    m_mouse_button_state.m_mouse_button_state_current = (m_mouse_buttons & 1);
+    generate_mouse_button_events(&m_mouse_button_state);
 }
 
 void
@@ -219,12 +249,6 @@
         }
     }
                        
-    // Handle the mouse.
-    m_mouse_button_state.m_topmost_entity =
-        m_movie->get_topmost_mouse_entity(PIXELS_TO_TWIPS(m_mouse_x), 
PIXELS_TO_TWIPS(m_mouse_y));
-    m_mouse_button_state.m_mouse_button_state_current = (m_mouse_buttons & 1);
-    generate_mouse_button_events(&m_mouse_button_state);
-
 // m_movie->advance(delta_time);
 
                // Vitaly:

Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/movie_root.h 10 Jul 2006 13:47:12 -0000      1.6
+++ server/movie_root.h 27 Jul 2006 00:15:22 -0000      1.7
@@ -112,7 +112,16 @@
 
        void set_display_viewport(int x0, int y0, int w, int h);
 
-       /// The host app uses this to tell the movie where the
+       /// The host app can use this to tell the movie when
+       /// user's mouse pointer has moved.
+        void notify_mouse_moved(int x, int y);
+
+       /// The host app can use this to tell the movie when a
+       /// button on the user's mouse has been pressed or released.
+        /// Set mouse_pressed to true on click, false on release.
+        void notify_mouse_clicked(bool mouse_pressed, int mask);
+
+       /// The host app can use this to tell the movie where the
        /// user's mouse pointer is.
        void notify_mouse_state(int x, int y, int buttons);
 
@@ -251,6 +260,9 @@
        movie* get_active_entity();
        void set_active_entity(movie* ch);
 
+private:
+        void fire_mouse_event();
+
 };
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]