diff options
author | Rick Pasetto <rick@lindenlab.com> | 2009-12-01 15:38:09 -0800 |
---|---|---|
committer | Rick Pasetto <rick@lindenlab.com> | 2009-12-01 15:38:09 -0800 |
commit | 659dc5224e2f4b6ce90b4f739cc015befc098c12 (patch) | |
tree | 43a7d9b6027a82cf917cda3c7fd59e70f7264269 /indra/newview/llviewermedia.cpp | |
parent | 948af3093c93461d11ab6a76a8aab7ea10e377c6 (diff) |
DEV-42989: Adjust media priority based on app minimization and focus
Review #49
This change adjusts each media's priority based on whether the viewer is minimized (media priority becomes HIDDEN) or unfocused (media priority becomes LOW). However, due to the fact that updateMedia() was no longer being called when minimized, I moved its call out of LLViewerTextureList::updateImages() (a seemingly odd place anyway) and into its own idle callback.
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rw-r--r-- | indra/newview/llviewermedia.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index f2ddb0b1f1..3bc3292876 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -45,6 +45,9 @@ #include "llviewertexturelist.h" #include "llvovolume.h" #include "llpluginclassmedia.h" +#include "llviewerwindow.h" +#include "llfocusmgr.h" +#include "llcallbacklist.h" #include "llevent.h" // LLSimpleListener #include "llnotificationsutil.h" @@ -738,6 +741,19 @@ void LLViewerMedia::updateMedia() impl_count_total++; } + // Overrides if the window is minimized or we lost focus (taking care + // not to accidentally "raise" the priority either) + if (!gViewerWindow->getActive() /* viewer window minimized? */ + && new_priority > LLPluginClassMedia::PRIORITY_HIDDEN) + { + new_priority = LLPluginClassMedia::PRIORITY_HIDDEN; + } + else if (!gFocusMgr.getAppHasFocus() /* viewer window lost focus? */ + && new_priority > LLPluginClassMedia::PRIORITY_LOW) + { + new_priority = LLPluginClassMedia::PRIORITY_LOW; + } + pimpl->setPriority(new_priority); if(pimpl->getUsedInUI()) @@ -774,11 +790,24 @@ void LLViewerMedia::updateMedia() } +// idle callback function...only here to provide a hop to updateMedia() +static void llviewermedia_updatemedia_thunk(void*) +{ + LLViewerMedia::updateMedia(); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// static +void LLViewerMedia::initClass() +{ + gIdleCallbacks.addFunction(llviewermedia_updatemedia_thunk, NULL); +} + ////////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::cleanupClass() { - // This is no longer necessary, since sViewerMediaImplList is no longer smart pointers. + gIdleCallbacks.deleteFunction(llviewermedia_updatemedia_thunk, NULL); } ////////////////////////////////////////////////////////////////////////////////////////// |