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: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gui.cpp gui/gui...
Date: Wed, 12 Sep 2007 08:25:38 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   07/09/12 08:25:38

Modified files:
        .              : ChangeLog 
        gui            : gtk.cpp gui.cpp gui.h 
        server         : edit_text_character.cpp event_id.h 
                         movie_root.cpp movie_root.h 
        server/asobj   : Key.cpp Key.h 
        testsuite      : MovieTester.cpp MovieTester.h 

Log message:
                * gui/gtk.cpp: pass unicode of key event when notifying gui.
                * gui/gui.{cpp,h}: pass unicode to movie_root.
                * server/movie_root{cpp,h}: notify key listeners of unicode.
                * server/event_id.h: add m_unicode.
                * server/asobj/Key.{cpp,h}: fix getAscii().
                * server/edit_text_character.cpp: read unicode, not swf keycode.
                * testsuite/MovieTester{cpp,h}: update notify_key_event test.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4282&r2=1.4283
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.107&r2=1.108
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.94&r2=1.95
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.110&r2=1.111
http://cvs.savannah.gnu.org/viewcvs/gnash/server/event_id.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.85&r2=1.86
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.h?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.h?cvsroot=gnash&r1=1.28&r2=1.29

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4282
retrieving revision 1.4283
diff -u -b -r1.4282 -r1.4283
--- ChangeLog   12 Sep 2007 07:24:04 -0000      1.4282
+++ ChangeLog   12 Sep 2007 08:25:37 -0000      1.4283
@@ -1,3 +1,13 @@
+2007-09-12 Benjamin Wolsey <address@hidden>
+
+       * gui/gtk.cpp: pass unicode of key event when notifying gui.
+       * gui/gui.{cpp,h}: pass unicode to movie_root.
+       * server/movie_root{cpp,h}: notify key listeners of unicode.
+       * server/event_id.h: add m_unicode.
+       * server/asobj/Key.{cpp,h}: fix getAscii().
+       * server/edit_text_character.cpp: read unicode, not swf keycode.
+       * testsuite/MovieTester{cpp,h}: update notify_key_event test.
+
 2007-09-12 Chad Musick <address@hidden>
 
        * server/as_value.cpp: Move test to silence compiler warnings.

Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -b -r1.107 -r1.108
--- gui/gtk.cpp 11 Sep 2007 15:35:42 -0000      1.107
+++ gui/gtk.cpp 12 Sep 2007 08:25:37 -0000      1.108
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: gtk.cpp,v 1.107 2007/09/11 15:35:42 bwy Exp $ */
+/* $Id: gtk.cpp,v 1.108 2007/09/12 08:25:37 bwy Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1518,7 +1518,7 @@
     int mod = gdk_to_gnash_modifier(event->state);
     
     if (c != gnash::key::INVALID) {
-        gui->notify_key_event(c, mod, true);
+        gui->notify_key_event(c, gdk_keyval_to_unicode(event->keyval), mod, 
true);
     }
         
     return true;
@@ -1539,7 +1539,7 @@
     int mod = gdk_to_gnash_modifier(event->state);
     
     if (c != gnash::key::INVALID) {
-        gui->notify_key_event(c, mod, false);
+        gui->notify_key_event(c, gdk_keyval_to_unicode(event->keyval), mod, 
false);
     }
     
     return true;

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- gui/gui.cpp 22 Aug 2007 21:38:22 -0000      1.94
+++ gui/gui.cpp 12 Sep 2007 08:25:37 -0000      1.95
@@ -312,11 +312,11 @@
 }
 
 void
-Gui::notify_key_event(gnash::key::code k, int modifier, bool pressed) 
+Gui::notify_key_event(gnash::key::code k, uint32_t utf_8, int modifier, bool 
pressed) 
 {
        movie_root* m = get_current_root();
 
-       if ( m->notify_key_event(k, pressed) )
+       if ( m->notify_key_event(k, utf_8, pressed) )
        {
                // any action triggered by the
                // event required screen refresh

Index: gui/gui.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- gui/gui.h   22 Aug 2007 21:38:22 -0000      1.60
+++ gui/gui.h   12 Sep 2007 08:25:37 -0000      1.61
@@ -182,7 +182,7 @@
     /// @param pressed Determines whether the key is being
     ///           pressed (true) or being released (false)
     ///
-    void notify_key_event(gnash::key::code k, int modifier, bool pressed);
+    void notify_key_event(gnash::key::code k, uint32_t utf_8, int modifier, 
bool pressed);
 
     /// Resize the client area view and the window accordingly.
     //

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -b -r1.110 -r1.111
--- server/edit_text_character.cpp      5 Sep 2007 16:47:55 -0000       1.110
+++ server/edit_text_character.cpp      12 Sep 2007 08:25:37 -0000      1.111
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: edit_text_character.cpp,v 1.110 2007/09/05 16:47:55 meteoryte Exp $ */
+/* $Id: edit_text_character.cpp,v 1.111 2007/09/12 08:25:37 bwy Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -586,13 +586,15 @@
                case event_id::KEY_PRESS:
                {
                        std::string s(_text);
-                       std::string c;
-                       c = (char) id.m_key_code;
+                       int c;
+                       std::string uc;
+                       c = id.m_key_code;
+                       uc = (char) id.m_unicode;
 
                        // may be _text is changed in ActionScript
                        m_cursor = imin(m_cursor, _text.size());
 
-                       switch (c[0])
+                       switch (c)
                        {
                                case key::BACKSPACE:
                                        if (m_cursor > 0)
@@ -640,7 +642,7 @@
 
                                default:
                                {
-                                       s.insert(m_cursor, c);
+                                       s.insert(m_cursor, uc);
                                        m_cursor++;
                                        set_text_value(s.c_str());
                                        break;

Index: server/event_id.h
===================================================================
RCS file: /sources/gnash/gnash/server/event_id.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/event_id.h   1 Jul 2007 10:54:22 -0000       1.10
+++ server/event_id.h   12 Sep 2007 08:25:38 -0000      1.11
@@ -95,13 +95,15 @@
 
        id_code m_id;
        unsigned char   m_key_code;
+       uint32_t m_unicode;
 
-       event_id() : m_id(INVALID), m_key_code(key::INVALID) {}
+       event_id() : m_id(INVALID), m_key_code(key::INVALID), m_unicode(0) {}
 
-       event_id(id_code id, key::code c = key::INVALID)
+       event_id(id_code id, key::code c = key::INVALID, uint32_t utf_8 = 0)
                :
                m_id(id),
-               m_key_code((unsigned char) c)
+               m_key_code((unsigned char) c),
+               m_unicode ((uint32_t) utf_8)
        {
                // you must supply a key code for KEY_PRESS event
                // 

Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- server/movie_root.cpp       7 Sep 2007 11:56:06 -0000       1.85
+++ server/movie_root.cpp       12 Sep 2007 08:25:38 -0000      1.86
@@ -290,7 +290,7 @@
 
 
 key_as_object *
-movie_root::notify_global_key(key::code k, bool down)
+movie_root::notify_global_key(key::code k, uint32_t utf_8, bool down)
 {
        VM& vm = VM::get();
        if ( vm.getSWFVersion() < 5 )
@@ -302,7 +302,7 @@
        boost::intrusive_ptr<key_as_object> keyobject = getKeyObject();
        if ( keyobject )
        {
-               if (down) _keyobject->set_key_down(k);
+               if (down) _keyobject->set_key_down(k, utf_8);
                else _keyobject->set_key_up(k);
        }
        else
@@ -314,17 +314,17 @@
 }
 
 bool
-movie_root::notify_key_event(key::code k, bool down)
+movie_root::notify_key_event(key::code k, uint32_t utf_8, bool down)
 {
 //GNASH_REPORT_FUNCTION;
 
        //
        // First of all, notify the _global.Key object about key event
        //
-       key_as_object * global_key = notify_global_key(k, down);
+       key_as_object * global_key = notify_global_key(k, utf_8, down);
 
        // Notify character key listeners.
-       notify_key_listeners(k, down);
+       notify_key_listeners(k, utf_8, down);
 
 #ifndef NEW_KEY_LISTENER_LIST_DESIGN
        // Notify both character and non-character Key listeners
@@ -794,7 +794,7 @@
 #endif
 }
 
-void movie_root::notify_key_listeners(key::code k, bool down)
+void movie_root::notify_key_listeners(key::code k, uint32_t utf_8, bool down)
 {
     //log_msg("Notifying " SIZET_FMT " keypress listeners", 
_keyListeners.size());
 
@@ -824,7 +824,7 @@
                     }
                 }
                 // invoke onClipKeyPress handler
-                ch->on_event(event_id(event_id::KEY_PRESS, k));
+                ch->on_event(event_id(event_id::KEY_PRESS, k, utf_8));
             }
             else
             {
@@ -922,7 +922,7 @@
 #endif
 }
 
-void movie_root::notify_key_listeners(key::code k, bool down)
+void movie_root::notify_key_listeners(key::code k, uint32_t utf_8, bool down)
 {
        log_msg("Notifying " SIZET_FMT " keypress listeners", 
                m_key_listeners.size());

Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- server/movie_root.h 1 Sep 2007 01:20:46 -0000       1.71
+++ server/movie_root.h 12 Sep 2007 08:25:38 -0000      1.72
@@ -15,7 +15,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: movie_root.h,v 1.71 2007/09/01 01:20:46 strk Exp $ */
+/* $Id: movie_root.h,v 1.72 2007/09/12 08:25:38 bwy Exp $ */
 
 /// \page events_handling Handling of user events
 ///
@@ -332,7 +332,7 @@
     /// by the event requires redraw, see \ref events_handling for
     /// more info.
     ///
-    bool notify_key_event(key::code k, bool down);
+    bool notify_key_event(key::code k, uint32_t utf_8, bool down);
 
     /// \brief
     /// Use this to retrieve the last state of the mouse, as set via
@@ -477,7 +477,7 @@
     void * get_userdata() { return m_userdata; }
     void set_userdata(void * ud ) { m_userdata = ud;  }
 
-    DSOEXPORT void notify_key_listeners(key::code k, bool down);
+    DSOEXPORT void notify_key_listeners(key::code k, uint32_t utf_8, bool 
down);
 #ifdef NEW_KEY_LISTENER_LIST_DESIGN
     // Push a new key listener to the container if it is not there,
     // otherwise, just register it.
@@ -556,7 +556,7 @@
     void executeTimers();
 
     /// Notify the global Key ActionScript object about a key status change
-    key_as_object * notify_global_key(key::code k, bool down);
+    key_as_object * notify_global_key(key::code k, uint32_t utf_8, bool down);
     
     /// Remove all listeners with a ref-count of 1
     /// (only referenced as key listeners)

Index: server/asobj/Key.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- server/asobj/Key.cpp        31 Aug 2007 21:53:32 -0000      1.31
+++ server/asobj/Key.cpp        12 Sep 2007 08:25:38 -0000      1.32
@@ -72,12 +72,14 @@
 }
 
 void
-key_as_object::set_key_down(int code)
+key_as_object::set_key_down(int code, uint32_t utf_8)
 {
     if (code < 0 || code >= key::KEYCOUNT) return;
 
     m_last_key_pressed = code;
 
+    m_last_unicode = utf_8;
+
     int byte_index = code >> 3;
     int bit_index = code - (byte_index << 3);
     int mask = 1 << bit_index;
@@ -198,6 +200,11 @@
     return m_last_key_pressed;
 }
 
+uint32_t
+key_as_object::get_last_unicode() const
+{
+    return m_last_unicode;
+}
 
 as_value
 key_add_listener(const fn_call& fn)
@@ -243,19 +250,13 @@
 {
     boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
 
-    int code = ko->get_last_key_pressed();
-    if (code < 0)
-        return as_value();
+    if (ko->get_last_key_pressed() < 0 ) return as_value();
 
-    // @@ Crude for now; just jamming the key code in a string, as a character.
-    // Need to apply shift/capslock/numlock, etc...
-    char    buf[2];
-    buf[0] = (char) code;
-    buf[1] = 0;
+    int utf8 = ko->get_last_unicode();
 
-    log_unimpl("Key.getAscii partially implemented");
+    if (utf8 < 0 || utf8 > 255) return as_value();
 
-    return as_value(buf);
+    return as_value(int(utf8));
 }
 
 // Returns the keycode of the last key pressed.

Index: server/asobj/Key.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/asobj/Key.h  24 Jul 2007 14:19:32 -0000      1.24
+++ server/asobj/Key.h  12 Sep 2007 08:25:38 -0000      1.25
@@ -16,7 +16,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-/* $Id: Key.h,v 1.24 2007/07/24 14:19:32 strk Exp $ */
+/* $Id: Key.h,v 1.25 2007/09/12 08:25:38 bwy Exp $ */
 
 #ifndef __KEY_H__
 #define __KEY_H__
@@ -63,6 +63,7 @@
 #endif
 
        int     m_last_key_pressed;
+       uint32_t m_last_unicode;
 
 protected:
 
@@ -81,7 +82,7 @@
 
        bool is_key_down(int code);
 
-       void set_key_down(int code);
+       void set_key_down(int code, uint32_t utf_8);
 
        void set_key_up(int code);
        
@@ -103,6 +104,8 @@
 
        int get_last_key_pressed() const;
 
+       uint32_t get_last_unicode() const;
+
 };
 
 void key_class_init(as_object& global);

Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- testsuite/MovieTester.cpp   7 Sep 2007 11:56:06 -0000       1.48
+++ testsuite/MovieTester.cpp   12 Sep 2007 08:25:38 -0000      1.49
@@ -332,9 +332,9 @@
 }
 
 void
-MovieTester::pressKey(key::code code)
+MovieTester::pressKey(key::code code, uint32_t utf_8)
 {
-       if ( _movie_root->notify_key_event(code, true) )
+       if ( _movie_root->notify_key_event(code, utf_8, true) )
        {
                render();
        }
@@ -343,7 +343,7 @@
 void
 MovieTester::releaseKey(key::code code)
 {
-       if ( _movie_root->notify_key_event(code, false) )
+       if ( _movie_root->notify_key_event(code, 0, false) )
        {
                render();
        }

Index: testsuite/MovieTester.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- testsuite/MovieTester.h     1 Jul 2007 10:54:38 -0000       1.28
+++ testsuite/MovieTester.h     12 Sep 2007 08:25:38 -0000      1.29
@@ -197,7 +197,7 @@
        //
        /// See key codes in namespace gnash::key (gnash.h)
        ///
-       void pressKey(key::code k);
+       void pressKey(key::code k, uint32_t utf_8);
 
        /// Notify key release
        //




reply via email to

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