[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12294: Various cleanups. Add a way
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12294: Various cleanups. Add a way to exit properly from movie_root. |
Date: |
Sun, 11 Jul 2010 09:56:03 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12294 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sun 2010-07-11 09:56:03 +0200
message:
Various cleanups. Add a way to exit properly from movie_root.
modified:
gui/Player.cpp
gui/Player.h
libcore/movie_root.cpp
libcore/movie_root.h
testsuite/MovieTester.cpp
utilities/processor.cpp
=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp 2010-06-24 15:36:06 +0000
+++ b/gui/Player.cpp 2010-07-11 06:43:23 +0000
@@ -583,6 +583,11 @@
return EXIT_SUCCESS;
}
+void
+Player::CallbacksHandler::exit()
+{
+ _gui.quit();
+}
void
Player::CallbacksHandler::error(const std::string& msg)
=== modified file 'gui/Player.h'
--- a/gui/Player.h 2010-05-21 01:26:20 +0000
+++ b/gui/Player.h 2010-07-11 06:43:23 +0000
@@ -222,6 +222,8 @@
bool yesNo(const std::string& query);
void error(const std::string& msg);
+
+ void exit();
// For handling notification callbacks from ActionScript.
// The callback is always sent to a hosting application
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2010-07-10 15:29:18 +0000
+++ b/libcore/movie_root.cpp 2010-07-11 06:43:23 +0000
@@ -92,6 +92,17 @@
const DisplayObject* getNearestObject(const DisplayObject* o);
as_object* getBuiltinObject(movie_root& mr, string_table::key cl);
void advanceLiveChar(MovieClip* ch);
+
+ /// Erase unloaded DisplayObjects from the given listeners list
+ void cleanupListeners(movie_root::Listeners& ll);
+
+ /// Push a DisplayObject listener to the front of given container, if not
+ /// already present
+ void add_listener(movie_root::Listeners& ll, InteractiveObject* elem);
+
+ /// Remove a listener from the list
+ void remove_listener(movie_root::Listeners& ll, InteractiveObject* elem);
+
}
// Utility classes
@@ -125,7 +136,6 @@
m_viewport_height(1),
m_background_color(255, 255, 255, 255),
m_background_color_set(false),
- m_timer(0.0f),
_mouseX(0),
_mouseY(0),
_lastTimerId(0),
@@ -977,55 +987,6 @@
void
-movie_root::cleanupUnloadedListeners(Listeners& ll)
-{
- bool needScan;
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
- int scansCount = 0;
-#endif
-
- do
- {
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
- scansCount++;
- int cleaned =0;
-#endif
-
- needScan=false;
-
- // remove unloaded DisplayObject listeners from movie_root
- for (Listeners::iterator iter = ll.begin(); iter != ll.end(); )
- {
- InteractiveObject* const ch = *iter;
- if ( ch->unloaded() )
- {
- if ( ! ch->isDestroyed() )
- {
- ch->destroy();
- needScan=true; // ->destroy() might mark already-scanned chars
as unloaded
- }
- iter = ll.erase(iter);
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
- cleaned++;
-#endif
-
- }
-
- else ++iter;
- }
-
-#ifdef GNASH_DEBUG_DLIST_CLEANUP
- cout << " Scan " << scansCount << " cleaned " << cleaned << " instances"
<< endl;
-#endif
-
- } while (needScan);
-
-}
-
-void
movie_root::notify_key_listeners(key::code k, bool down)
{
@@ -1057,25 +1018,6 @@
}
void
-movie_root::add_listener(Listeners& ll, InteractiveObject* listener)
-{
- assert(listener);
-
- // Don't add the same listener twice (why not use a set?)
- if (std::find(ll.begin(), ll.end(), listener) != ll.end()) return;
-
- ll.push_front(listener);
-}
-
-
-void
-movie_root::remove_listener(Listeners& ll, InteractiveObject* listener)
-{
- assert(listener);
- ll.remove_if(std::bind2nd(std::equal_to<InteractiveObject*>(), listener));
-}
-
-void
movie_root::notify_mouse_listeners(const event_id& event)
{
@@ -1200,13 +1142,6 @@
}
-bool
-movie_root::isMouseOverActiveEntity() const
-{
- assert(testInvariant());
- return (_mouseButtonState.activeEntity);
-}
-
void
movie_root::setQuality(Quality q)
{
@@ -1323,7 +1258,7 @@
// or shows the menubar. Flash expects this option to disable some
// context menu items.
// callInterface is the proper handler for this
- callInterface("Stage.showMenu", (_showMenu) ? "true" : "false"); //or
this?
+ callInterface("Stage.showMenu", (_showMenu) ? "true" : "false");
}
/// Returns the string representation of the current align mode,
@@ -1632,10 +1567,10 @@
// These are the default methods used by ExternalInterface
if (invoke->name == "Quit") {
- // The browser is telling us to quit.
- // FIXME: This is probably not the right way to exit, but it
- // beats turning into a zombie and eating cpu cycles.
- exit(0);
+ // Leave to the hosting application. If there isn't one or it
+ // chooses not to exit, that's fine.
+ if (_interfaceHandler) _interfaceHandler->exit();
+
} else if (invoke->name == "SetVariable") {
// SetVariable doesn't send a response
} else if (invoke->name == "GetVariable") {
@@ -1985,6 +1920,24 @@
return as_value();
}
+void
+movie_root::cleanupUnloadedListeners()
+{
+ cleanupListeners(_keyListeners);
+}
+
+void
+movie_root::add_key_listener(InteractiveObject* listener)
+{
+ add_listener(_keyListeners, listener);
+}
+
+/// Remove a DisplayObject listener for key events
+void
+movie_root::remove_key_listener(InteractiveObject* listener)
+{
+ remove_listener(_keyListeners, listener);
+}
void
movie_root::cleanupDisplayList()
@@ -2646,11 +2599,76 @@
#endif
}
-
-
-}
-
-
+void
+add_listener(movie_root::Listeners& ll, InteractiveObject* listener)
+{
+ assert(listener);
+
+ // Don't add the same listener twice (why not use a set?)
+ if (std::find(ll.begin(), ll.end(), listener) != ll.end()) return;
+
+ ll.push_front(listener);
+}
+
+
+void
+remove_listener(movie_root::Listeners& ll, InteractiveObject* listener)
+{
+ assert(listener);
+ ll.remove_if(std::bind2nd(std::equal_to<InteractiveObject*>(), listener));
+}
+
+void
+cleanupListeners(movie_root::Listeners& ll)
+{
+ bool needScan;
+
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+ int scansCount = 0;
+#endif
+
+ do
+ {
+
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+ scansCount++;
+ int cleaned =0;
+#endif
+
+ needScan=false;
+
+ // remove unloaded DisplayObject listeners from movie_root
+ for (movie_root::Listeners::iterator iter = ll.begin();
+ iter != ll.end(); ) {
+ InteractiveObject* const ch = *iter;
+ if ( ch->unloaded() )
+ {
+ if ( ! ch->isDestroyed() )
+ {
+ ch->destroy();
+ needScan=true; // ->destroy() might mark already-scanned chars
as unloaded
+ }
+ iter = ll.erase(iter);
+
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+ cleaned++;
+#endif
+
+ }
+
+ else ++iter;
+ }
+
+#ifdef GNASH_DEBUG_DLIST_CLEANUP
+ cout << " Scan " << scansCount << " cleaned " << cleaned << " instances"
<< endl;
+#endif
+
+ } while (needScan);
+
+}
+
+
+} // anonymous namespace
} // namespace gnash
// local Variables:
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2010-07-10 16:48:34 +0000
+++ b/libcore/movie_root.h 2010-07-11 06:43:23 +0000
@@ -468,16 +468,10 @@
DSOEXPORT void notify_key_listeners(key::code k, bool down);
/// Push a new DisplayObject listener for key events
- void add_key_listener(InteractiveObject* listener)
- {
- add_listener(_keyListeners, listener);
- }
+ void add_key_listener(InteractiveObject* listener);
/// Remove a DisplayObject listener for key events
- void remove_key_listener(InteractiveObject* listener)
- {
- remove_listener(_keyListeners, listener);
- }
+ void remove_key_listener(InteractiveObject* listener);
/// Notify still loaded DisplayObject listeners for mouse events
DSOEXPORT void notify_mouse_listeners(const event_id& event);
@@ -523,9 +517,6 @@
/// Return the DisplayObject currently being dragged, if any
DisplayObject* getDraggingCharacter() const;
- /// Return true if the mouse pointer is over an active entity
- bool isMouseOverActiveEntity() const;
-
bool testInvariant() const;
/// The possible values of Stage.displayState
@@ -600,7 +591,7 @@
/// Sets the value of _showMenu and calls the fscommand handler for the
/// current gui
- void setShowMenuState( bool state );
+ void setShowMenuState(bool state);
// This is a flag that specifies whether exceptions in ActionScript
// should be propogated to JavaScript in the browser.
@@ -838,6 +829,9 @@
/// a question.
virtual bool yesNo(const std::string& cmd) = 0;
+ /// Instruct the hosting application to exit.
+ virtual void exit() = 0;
+
/// Send an error message to the hosting application.
//
/// This does not have to be implemented; the default is a no-op.
@@ -996,24 +990,11 @@
void executeTimers();
/// Remove unloaded key and mouselisteners.
- void cleanupUnloadedListeners()
- {
- cleanupUnloadedListeners(_keyListeners);
- }
-
- /// Erase unloaded DisplayObjects from the given listeners list
- static void cleanupUnloadedListeners(Listeners& ll);
+ void cleanupUnloadedListeners();
/// Cleanup references to unloaded DisplayObjects and run the GC.
void cleanupAndCollect();
-
- /// Push a DisplayObject listener to the front of given container, if not
- /// already present
- static void add_listener(Listeners& ll, InteractiveObject* elem);
-
- /// Remove a listener from the list
- static void remove_listener(Listeners& ll, InteractiveObject* elem);
-
+
/// This function should return TRUE iff any action triggered
/// by the event requires redraw, see \ref events_handling for
/// more info.
@@ -1116,7 +1097,6 @@
rgba m_background_color;
bool m_background_color_set;
- float m_timer;
boost::int32_t _mouseX;
boost::int32_t _mouseY;
@@ -1181,28 +1161,36 @@
//
/// This is here, not just in the Renderer, so that AS compatibility
/// does not rely on the presence of a renderer.
- Quality _quality;
+ Quality _quality;
+
+ /// The alignment of the Stage
std::bitset<4u> _alignMode;
+
AllowScriptAccessMode _allowScriptAccess;
bool _marshallExceptions;
- bool _showMenu;
- ScaleMode _scaleMode;
- DisplayState _displayState;
+
+ /// Whether to show the menu or not.
+ bool _showMenu;
+
+ /// The current scaling mode of the Stage.
+ ScaleMode _scaleMode;
+
+ /// The current state of the Stage (fullscreen or not).
+ DisplayState _displayState;
- // The maximum number of recursions e.g. when finding
- // 'super', set in the ScriptLimits tag.
+ // Maximum number of recursions set in the ScriptLimits tag.
boost::uint16_t _recursionLimit;
- // The timeout in seconds for script execution, in the
- // ScriptLimits tag.
+ // Timeout in seconds for script execution, set in the ScriptLimits tag.
boost::uint16_t _timeoutLimit;
// delay between movie advancement, in milliseconds
- unsigned int _movieAdvancementDelay;
+ size_t _movieAdvancementDelay;
// time of last movie advancement, in milliseconds
- unsigned int _lastMovieAdvancement;
+ size_t _lastMovieAdvancement;
+ /// The number of the last unnamed instance, used to name instances.
size_t _unnamedInstance;
MovieLoader _movieLoader;
=== modified file 'testsuite/MovieTester.cpp'
--- a/testsuite/MovieTester.cpp 2010-07-10 09:23:03 +0000
+++ b/testsuite/MovieTester.cpp 2010-07-11 06:16:06 +0000
@@ -447,7 +447,7 @@
bool
MovieTester::isMouseOverMouseEntity()
{
- return _movie_root->isMouseOverActiveEntity();
+ return (_movie_root->getActiveEntityUnderPointer());
}
geometry::SnappingRanges2d<int>
=== modified file 'utilities/processor.cpp'
--- a/utilities/processor.cpp 2010-04-25 21:14:14 +0000
+++ b/utilities/processor.cpp 2010-07-11 06:43:23 +0000
@@ -158,7 +158,8 @@
}
};
-class EventCallback: public movie_root::AbstractIfaceCallback {
+class EventCallback: public movie_root::AbstractIfaceCallback
+{
public:
std::string call(const std::string& event, const std::string& arg)
{
@@ -169,37 +170,37 @@
// These should return "true" if the mouse was visible before
// the call.
if ( event == "Mouse.hide" ) {
- bool state = mouseShown;
- mouseShown = false;
- return state ? "true" : "false";
+ bool state = mouseShown;
+ mouseShown = false;
+ return state ? "true" : "false";
}
if ( event == "Mouse.show" ) {
- bool state = mouseShown;
- mouseShown = true;
- return state ? "true" : "false" ;
+ bool state = mouseShown;
+ mouseShown = true;
+ return state ? "true" : "false" ;
}
// Some fake values for consistent test results.
if ( event == "System.capabilities.screenResolutionX" ) {
- return "800";
+ return "800";
}
if ( event == "System.capabilities.screenResolutionY" ) {
- return "640";
+ return "640";
}
if ( event == "System.capabilities.screenDPI" ) {
- return "72";
+ return "72";
}
if ( event == "System.capabilities.screenColor" ) {
- return "Color";
+ return "Color";
}
if ( event == "System.capabilities.playerType" ) {
- return "StandAlone";
+ return "StandAlone";
}
return "";
@@ -210,6 +211,10 @@
{
return true;
}
+
+ void exit() {
+ std::exit(EXIT_SUCCESS);
+ }
};
EventCallback eventCallback;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12294: Various cleanups. Add a way to exit properly from movie_root.,
Benjamin Wolsey <=