gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10645: Send event on gui-initiated


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10645: Send event on gui-initiated fullscreen.
Date: Mon, 02 Mar 2009 14:56:25 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10645
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-03-02 14:56:25 +0100
message:
  Send event on gui-initiated fullscreen.
  
  Minor cleanups.
modified:
  gui/gui.cpp
  libcore/as_function.cpp
  libcore/asobj/AsBroadcaster.cpp
  libcore/asobj/Stage_as.cpp
  libcore/asobj/Stage_as.h
  libcore/movie_root.cpp
  libcore/movie_root.h
  libcore/vm/fn_call.h
    ------------------------------------------------------------
    revno: 10644.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2009-03-02 12:52:46 +0100
    message:
      Clean up code and formatting.
    modified:
      libcore/as_function.cpp
    ------------------------------------------------------------
    revno: 10644.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2009-03-02 13:12:15 +0100
    message:
      Use ctor initializers properly. Don't reimplement vector::erase().
    modified:
      libcore/vm/fn_call.h
    ------------------------------------------------------------
    revno: 10644.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2009-03-02 13:12:43 +0100
    message:
      Set fullscreen via core. This is necessary because many video players 
change
      form when they receive a Stage display state event (onFullScreen). 
Pressing
      escape on YouTube fullscreen now restores the widgets correctly.
      
      This also now applies to the fullscreen option from the Gnash menu for the
      same reason. It potentially reduces user control by notifying actionscript
      on every change, so may be revised if it makes Gnash less useful.
      
      Rename enums, minor cleanups.
    modified:
      gui/gui.cpp
      libcore/asobj/AsBroadcaster.cpp
      libcore/asobj/Stage_as.cpp
      libcore/asobj/Stage_as.h
      libcore/movie_root.cpp
      libcore/movie_root.h
=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp       2009-02-11 09:25:41 +0000
+++ b/gui/gui.cpp       2009-03-02 12:12:43 +0000
@@ -213,11 +213,12 @@
 void
 Gui::toggleFullscreen()
 {
+    /// Sends request to Gnash core to change display state.
        if (_fullscreen) {
-               unsetFullscreen();
+               _stage->setStageDisplayState(movie_root::DISPLAYSTATE_NORMAL);
        }
        else {
-               setFullscreen();
+               
_stage->setStageDisplayState(movie_root::DISPLAYSTATE_FULLSCREEN);
        } 
 }
 
@@ -524,16 +525,13 @@
 void
 Gui::notify_key_event(gnash::key::code k, int modifier, bool pressed) 
 {
-       movie_root* m = _stage;
 
        /* Handle GUI shortcuts */
        if (pressed)
        {
-               if (k == gnash::key::ESCAPE)
-               {
-                       if (isFullscreen())
-                       {
-                               unsetFullscreen();
+               if (k == gnash::key::ESCAPE) {
+                       if (isFullscreen()) {
+                               
_stage->setStageDisplayState(movie_root::DISPLAYSTATE_NORMAL);
                        }
                }
                
@@ -651,11 +649,11 @@
 
     if ( _stopped ) return;
 
-       if ( m->notify_key_event(k, pressed) )
+       if ( _stage->notify_key_event(k, pressed) )
        {
                // any action triggered by the
                // event required screen refresh
-               display(m);
+               display(_stage);
        }
 
 }
@@ -943,9 +941,9 @@
 
                if ( displayTime > estimatedDisplayTime)
                {
-                       //log_debug("Display took %6.6g seconds over %6.6g 
available for each frame", displayTime, timeSlot);
 
-                       // Don't update estimatedDisplayTime if it's bigger 
then timeSlot*0.8
+                       // Don't update estimatedDisplayTime if it's bigger 
then 
+            // timeSlot*0.8
                        if (  displayTime < timeSlot*0.8 )
                        {
                                // TODO: check for absurdly high values, like 
we can't set

=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp   2009-03-01 08:46:57 +0000
+++ b/libcore/as_function.cpp   2009-03-02 11:52:46 +0000
@@ -354,10 +354,10 @@
        boost::intrusive_ptr<as_object> newobj;
 
        as_value us;
-       bool has_proto = false;
-       get_member(NSV::PROP_PROTOTYPE, &us);
-       
-    if (!us.is_undefined()) has_proto = true;
+       
+    get_member(NSV::PROP_PROTOTYPE, &us);
+       
+    bool has_proto = !us.is_undefined();
 
     // a built-in class takes care of assigning a prototype
     // TODO: change this
@@ -375,7 +375,7 @@
         catch (GnashException& ex) {
             // Catching a std::exception here can mask all sorts of bad 
             // behaviour, as (for instance) a poorly constructed string may
-            // smash the stack, throw and exception, but not abort.
+            // smash the stack, throw an exception, but not abort.
             // This is very effective at confusing debugging tools.
             // We only throw GnashExceptions. A std::bad_alloc may also be
             // reasonable, but anything else shouldn't be caught here.
@@ -394,7 +394,9 @@
                // Add a __constructor__ member to the new object, but only for 
SWF6 up
                // (to be checked). NOTE that we assume the builtin constructors
                // won't set __constructor__ to some other value...
-               int flags = as_prop_flags::dontEnum|as_prop_flags::onlySWF6Up; 
// can delete, hidden in swf5
+               int flags = as_prop_flags::dontEnum | 
+                    as_prop_flags::onlySWF6Up; 
+
                newobj->init_member(NSV::PROP_uuCONSTRUCTORuu, as_value(this), 
flags);
 
         // Also for SWF5+ only?
@@ -413,9 +415,8 @@
                // method directly instead) TODO
                /*bool func_has_prototype=*/ get_member(NSV::PROP_PROTOTYPE, 
&proto);
 
-               // user could have dropped the prototype..
+               // User could have dropped the prototype.
                // see construct-properties-#.swf from swfdec testsuite
-               //assert(func_has_prototype);
 
                IF_VERBOSE_ACTION(
             log_action(_("constructor prototype is %s"), proto);
@@ -426,11 +427,14 @@
 
                // Add a __constructor__ member to the new object, but only for 
SWF6 up
                // (to be checked)
-               int flags = as_prop_flags::dontEnum|as_prop_flags::onlySWF6Up; 
// can delete, hidden in swf5
-               newobj->init_member(NSV::PROP_uuCONSTRUCTORuu, as_value(this), 
flags);
+        // Can delete, hidden in swf5 
+               int flags = as_prop_flags::dontEnum | 
+                    as_prop_flags::onlySWF6Up; 
+
+               newobj->init_member(NSV::PROP_uuCONSTRUCTORuu, this, flags);
 
                if (swfversion < 7) {
-                       newobj->init_member(NSV::PROP_CONSTRUCTOR, 
as_value(this), flags);
+                       newobj->init_member(NSV::PROP_CONSTRUCTOR, this, flags);
                }
 
                // Super is computed from the object we're constructing,
@@ -445,8 +449,7 @@
                call(fn);
        }
 
-       if (!has_proto)
-               set_member(NSV::PROP_PROTOTYPE, as_value(newobj));
+       if (!has_proto) set_member(NSV::PROP_PROTOTYPE, as_value(newobj));
     
        return newobj;
 }

=== modified file 'libcore/asobj/AsBroadcaster.cpp'
--- a/libcore/asobj/AsBroadcaster.cpp   2009-01-22 20:10:39 +0000
+++ b/libcore/asobj/AsBroadcaster.cpp   2009-03-02 12:12:43 +0000
@@ -79,7 +79,7 @@
                _fn(fn)
        {
                _eventName = fn.arg(0).to_string();
-               _eventKey = VM::get().getStringTable().find(_eventName);
+               _eventKey = fn.getVM().getStringTable().find(_eventName);
                _fn.drop_bottom();
        }
 
@@ -93,12 +93,9 @@
                o->get_member(_eventKey, &method);
         _fn.super = o->get_super(_eventName.c_str());
 
-               if ( method.is_function() )
-               {
-
+               if (method.is_function()) {
                        _fn.this_ptr = o.get();
                        method.to_as_function()->call(_fn);
-
                }
 
                ++_dispatched;

=== modified file 'libcore/asobj/Stage_as.cpp'
--- a/libcore/asobj/Stage_as.cpp        2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/Stage_as.cpp        2009-03-02 12:12:43 +0000
@@ -273,28 +273,22 @@
 
     movie_root& m = obj->getVM().getRoot();
 
-       if ( fn.nargs == 0 ) // getter
-       {
-               return 
as_value(getDisplayStateString(m.getStageDisplayState()));
-       }
-       else // setter
-       {
-
-        StringNoCaseEqual noCaseCompare;
-
-               const std::string& str = fn.arg(0).to_string();
-               if ( noCaseCompare(str, "normal") )
-               {
-                   m.setStageDisplayState(movie_root::normal);
-               }
-               else if ( noCaseCompare(str, "fullScreen") ) 
-               {
-                   m.setStageDisplayState(movie_root::fullScreen);
-        }
-
-        // If invalid, do nothing.
-               return as_value();
-       }
+       if (!fn.nargs) {
+               return getDisplayStateString(m.getStageDisplayState());
+       }
+
+    StringNoCaseEqual noCaseCompare;
+
+    const std::string& str = fn.arg(0).to_string();
+    if (noCaseCompare(str, "normal")) {
+        m.setStageDisplayState(movie_root::DISPLAYSTATE_NORMAL);
+    }
+    else if (noCaseCompare(str, "fullScreen")) {
+        m.setStageDisplayState(movie_root::DISPLAYSTATE_FULLSCREEN);
+    }
+
+    // If invalid, do nothing.
+    return as_value();
 }
 
 // extern (used by Global.cpp)

=== modified file 'libcore/asobj/Stage_as.h'
--- a/libcore/asobj/Stage_as.h  2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/Stage_as.h  2009-03-02 12:12:43 +0000
@@ -65,6 +65,5 @@
   
 } // end of gnash namespace
 
-// __GNASH_ASOBJ_STAGE_H__
 #endif
 

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2009-02-26 18:48:57 +0000
+++ b/libcore/movie_root.cpp    2009-03-02 12:12:43 +0000
@@ -122,7 +122,7 @@
        _hostfd(-1),
        _alignMode(0),
        _scaleMode(showAll),
-       _displayState(normal),
+       _displayState(DISPLAYSTATE_NORMAL),
        _recursionLimit(256),
        _timeoutLimit(15),
        _movieAdvancementDelay(83), // ~12 fps by default
@@ -1565,17 +1565,20 @@
     _displayState = ds;
 
     boost::intrusive_ptr<Stage_as> stage = getStageObject();
-    if ( stage ) stage->notifyFullScreen( (_displayState == fullScreen) );
+    if (stage) {
+        stage->notifyFullScreen((_displayState == DISPLAYSTATE_FULLSCREEN));
+    }
 
        if (!_interfaceHandler) return; // No registered callback
        
-       if (_displayState == fullScreen)
-       {
-           callInterface("Stage.displayState", "fullScreen");
-       }
-       else if (_displayState == normal)
-       {
-           callInterface("Stage.displayState", "normal");
+    switch (_displayState)
+    {
+        case DISPLAYSTATE_FULLSCREEN:
+            callInterface("Stage.displayState", "fullScreen");
+            break;
+        case DISPLAYSTATE_NORMAL:
+               callInterface("Stage.displayState", "normal");
+            break;
        }   
 }
 

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2009-02-26 18:48:57 +0000
+++ b/libcore/movie_root.h      2009-03-02 12:12:43 +0000
@@ -468,8 +468,8 @@
 
     /// The possible values of Stage.displayState
     enum DisplayState {
-        normal,
-        fullScreen
+        DISPLAYSTATE_NORMAL,
+        DISPLAYSTATE_FULLSCREEN
     };
 
     /// The possibile values of Stage.scaleMode

=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h      2009-02-25 22:33:03 +0000
+++ b/libcore/vm/fn_call.h      2009-03-02 12:12:15 +0000
@@ -67,11 +67,9 @@
         super(fn.super),
                nargs(fn.nargs),
         callerDef(fn.callerDef),
-        _env(fn._env)
+        _env(fn._env),
+        _args(fn._args.get() ? new std::vector<as_value>(*fn._args) : 0)
        {
-               if (fn._args.get()) {
-                       _args.reset(new std::vector<as_value>(*fn._args));
-        }
        }
 
        fn_call(const fn_call& fn, as_object* this_in, as_object* sup = 0)
@@ -80,11 +78,9 @@
         super(sup),
         nargs(fn.nargs),
         callerDef(fn.callerDef),
-               _env(fn._env)
+               _env(fn._env),
+        _args(fn._args.get() ? new std::vector<as_value>(*fn._args) : 0)
        {
-               if (fn._args.get()) {
-                       _args.reset(new std::vector<as_value>(*fn._args));
-        }
        }
 
        fn_call(as_object* this_in, as_environment& env_in,
@@ -118,8 +114,7 @@
                super(0),
                nargs(0),
         callerDef(0),
-               _env(env_in),
-               _args(0)
+               _env(env_in)
        {
        }
 
@@ -154,12 +149,8 @@
 
        void drop_bottom()
        {
-               assert(_args.get() && !(*_args).empty());
-               for (size_t i=0; i<(*_args).size()-1; ++i)
-               {
-                       (*_args)[i] = (*_args)[i+1];
-               }
-               _args->pop_back();
+               assert(_args.get() && !_args->empty());
+        _args->erase(_args->begin());
                --nargs;
        }
 
@@ -194,7 +185,7 @@
 
        void pushArg(const as_value& arg)
        {
-               nargs++;
+               ++nargs;
                _args->push_back(arg);
        }
 


reply via email to

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