Skip to content

Commit

Permalink
[gui] introduce new force window activation which do not check for ac…
Browse files Browse the repository at this point in the history
…tive modals
  • Loading branch information
xhaggi committed May 12, 2015
1 parent c38f8fd commit 7db2676
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
7 changes: 4 additions & 3 deletions xbmc/ApplicationMessenger.cpp
Expand Up @@ -705,7 +705,7 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)

case TMSG_GUI_ACTIVATE_WINDOW:
{
g_windowManager.ActivateWindow(pMsg->param1, pMsg->params, pMsg->param2 > 0);
g_windowManager.ActivateWindow(pMsg->param1, pMsg->params, pMsg->param2 & 0x1 ? true : false, pMsg->param2 & 0x2 ? true : false);
}
break;

Expand Down Expand Up @@ -1256,9 +1256,10 @@ void CApplicationMessenger::Close(CGUIWindow *window, bool forceClose, bool wait
SendMessage(tMsg, waitResult);
}

void CApplicationMessenger::ActivateWindow(int windowID, const vector<string> &params, bool swappingWindows)
void CApplicationMessenger::ActivateWindow(int windowID, const vector<string> &params, bool swappingWindows, bool force /* = false */)
{
ThreadMessage tMsg = {TMSG_GUI_ACTIVATE_WINDOW, windowID, swappingWindows ? 1 : 0};
ThreadMessage tMsg = {TMSG_GUI_ACTIVATE_WINDOW, windowID};
tMsg.param2 = (swappingWindows ? 0x01 : 0) | (force ? 0x02 : 0);
tMsg.params = params;
SendMessage(tMsg, true);
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/ApplicationMessenger.h
Expand Up @@ -231,7 +231,7 @@ class CApplicationMessenger
void DoModal(CGUIDialog *pDialog, int iWindowID, const std::string &param = "");
void Show(CGUIDialog *pDialog);
void Close(CGUIWindow *window, bool forceClose, bool waitResult = true, int nextWindowID = 0, bool enableSound = true);
void ActivateWindow(int windowID, const std::vector<std::string> &params, bool swappingWindows);
void ActivateWindow(int windowID, const std::vector<std::string> &params, bool swappingWindows, bool force = false);
void SendAction(const CAction &action, int windowID = WINDOW_INVALID, bool waitResult=true);

//! \brief Send text to currently focused window / keyboard.
Expand Down
18 changes: 13 additions & 5 deletions xbmc/guilib/GUIWindowManager.cpp
Expand Up @@ -707,22 +707,30 @@ void CGUIWindowManager::ActivateWindow(int iWindowID, const std::string& strPath
ActivateWindow(iWindowID, params, false);
}

void CGUIWindowManager::ActivateWindow(int iWindowID, const vector<string>& params, bool swappingWindows)
void CGUIWindowManager::ForceActivateWindow(int iWindowID, const std::string& strPath)
{
vector<string> params;
if (!strPath.empty())
params.push_back(strPath);
ActivateWindow(iWindowID, params, false, true);
}

void CGUIWindowManager::ActivateWindow(int iWindowID, const vector<string>& params, bool swappingWindows /* = false */, bool force /* = false */)
{
if (!g_application.IsCurrentThread())
{
// make sure graphics lock is not held
CSingleExit leaveIt(g_graphicsContext);
CApplicationMessenger::Get().ActivateWindow(iWindowID, params, swappingWindows);
CApplicationMessenger::Get().ActivateWindow(iWindowID, params, swappingWindows, force);
}
else
{
CSingleLock lock(g_graphicsContext);
ActivateWindow_Internal(iWindowID, params, swappingWindows);
ActivateWindow_Internal(iWindowID, params, swappingWindows, force);
}
}

void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<string>& params, bool swappingWindows)
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<string>& params, bool swappingWindows, bool force /* = false */)
{
// translate virtual windows
// virtual music window which returns the last open music window (aka the music start window)
Expand Down Expand Up @@ -776,7 +784,7 @@ void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<stri
}

// don't activate a window if there are active modal dialogs
if (HasModalDialog())
if (!force && HasModalDialog())
{
CLog::Log(LOG_LEVEL_DEBUG, "Activate of window '%i' refused because there are active modal dialogs", iWindowID);
g_audioManager.PlayActionSound(CAction(ACTION_ERROR));
Expand Down
13 changes: 11 additions & 2 deletions xbmc/guilib/GUIWindowManager.h
Expand Up @@ -59,8 +59,9 @@ class CGUIWindowManager
void Remove(int id);
void Delete(int id);
void ActivateWindow(int iWindowID, const std::string &strPath = "");
void ForceActivateWindow(int iWindowID, const std::string &strPath = "");
void ChangeActiveWindow(int iNewID, const std::string &strPath = "");
void ActivateWindow(int iWindowID, const std::vector<std::string>& params, bool swappingWindows = false);
void ActivateWindow(int iWindowID, const std::vector<std::string>& params, bool swappingWindows = false, bool force = false);
void PreviousWindow();

void CloseDialogs(bool forceClose = false) const;
Expand Down Expand Up @@ -181,7 +182,15 @@ class CGUIWindowManager
CGUIWindow *GetTopMostDialog() const;

friend class CApplicationMessenger;
void ActivateWindow_Internal(int windowID, const std::vector<std::string> &params, bool swappingWindows);

/*! \brief Activate the given window.
*
* \param windowID The window ID to activate.
* \param params Parameter
* \param swappingWindows True if the window should be swapped with the previous window instead of put it in the window history, otherwise false
* \param force True to ignore checks which refuses opening the window, otherwise false
*/
void ActivateWindow_Internal(int windowID, const std::vector<std::string> &params, bool swappingWindows, bool force = false);

typedef std::map<int, CGUIWindow *> WindowMap;
WindowMap m_mapWindows;
Expand Down

0 comments on commit 7db2676

Please sign in to comment.