Skip to content

Commit

Permalink
Merge pull request xbmc#17893 from enen92/fixactivate
Browse files Browse the repository at this point in the history
[GUI] Fix ActivateWindow if 'return' is defined
  • Loading branch information
enen92 authored and Maven85 committed Aug 6, 2020
1 parent c69b346 commit 9fd1eec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 7 additions & 5 deletions xbmc/interfaces/builtins/GUIBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,21 +419,23 @@ static int ToggleDirty(const std::vector<std::string>&)
/// @param[in] loop Send "loop" to loop the alarm.
/// }
/// \table_row2_l{
/// <b>`ActivateWindow(window[\,dir])`</b>
/// <b>`ActivateWindow(window[\,dir\, return])`</b>
/// ,
/// Opens the given window. The parameter window can either be the window's id\,
/// or in the case of a standard window\, the window's name. See here for a list
/// of window names\, and their respective ids. If\, furthermore\, the window is
/// or in the case of a standard window\, the window's name. See \ref window_ids "here" for a list
/// of window names\, and their respective ids.
/// If\, furthermore\, the window is
/// Music\, Video\, Pictures\, or Program files\, then the optional dir parameter
/// specifies which folder Kodi should default to once the window is opened.
/// This must be a source as specified in sources.xml\, or a subfolder of a
/// valid source. For some windows (MusicLibrary and VideoLibrary)\, the return
/// parameter may be specified\, which indicates that Kodi should use this
/// valid source. For some windows (MusicLibrary and VideoLibrary)\, a third
/// parameter (return) may be specified\, which indicates that Kodi should use this
/// folder as the "root" of the level\, and thus the "parent directory" action
/// from within this folder will return the user to where they were prior to
/// the window activating.
/// @param[in] window The window name.
/// @param[in] dir Window starting folder (optional).
/// @param[in] return if dir should be used as the rootfolder of the level
/// }
/// \table_row2_l{
/// <b>`ActivateWindowAndFocus(id1\, id2\,item1\, id3\,item2)`</b>
Expand Down
16 changes: 13 additions & 3 deletions xbmc/windows/GUIMediaWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,22 @@ bool CGUIMediaWindow::OnMessage(CGUIMessage& message)
if (resetHistory)
{
m_vecItems->RemoveDiscCache(GetID());
SetHistoryForPath(m_vecItems->GetPath());
// only compute the history for the provided path if "return" is not defined
// (otherwise the root level for the path will be added by default to the path history
// and we won't be able to move back to the path we came from)
if (!returning)
SetHistoryForPath(m_vecItems->GetPath());
}
}
if (message.GetParam1() != WINDOW_INVALID)
{ // first time to this window - make sure we set the root path
m_startDirectory = returning ? dir : GetRootPath();
{
// if this is the first time to this window - make sure we set the root path
// if "return" is defined make sure we set the startDirectory to the directory we are
// moving to (so that we can move back to where we were onBack). If we are activating
// the same window but with a different path, do nothing - we are simply adding to the
// window history.
if (message.GetParam1() != message.GetParam2())
m_startDirectory = returning ? dir : GetRootPath();
}
if (message.GetParam2() == PLUGIN_REFRESH_DELAY)
{
Expand Down

0 comments on commit 9fd1eec

Please sign in to comment.