Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] Fix ActivateWindow if 'return' is defined #17893

Merged
merged 1 commit into from Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions xbmc/interfaces/builtins/GUIBuiltins.cpp
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
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