bool CGUIWindowManager::OnAction(const CAction &action) const { CSingleLock lock(g_graphicsContext); unsigned int topMost = m_activeDialogs.size(); while (topMost) { CGUIWindow *dialog = m_activeDialogs[--topMost]; lock.Leave(); if (dialog->IsModalDialog()) { // we have the topmost modal dialog if (!dialog->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) { bool fallThrough = (dialog->GetID() == WINDOW_DIALOG_FULLSCREEN_INFO); if (dialog->OnAction(action)) return true; // dialog didn't want the action - we'd normally return false // but for some dialogs we want to drop the actions through if (fallThrough) break; return false; } return true; // do nothing with the action until the anim is finished } lock.Enter(); if (topMost > m_activeDialogs.size()) topMost = m_activeDialogs.size(); } lock.Leave(); CGUIWindow* window = GetWindow(GetActiveWindow()); if (window) return window->OnAction(action); return false; }
bool CGUIWindowManager::OnAction(const CAction &action) { if (g_powerManager.IsSuspended()) { g_powerManager.Resume(); return true; } // If the screen saver is active, it is on top of // existing dialogs. Pass the actions to the screen // saver and not to the dialogs if (!g_application.GetInSlideshowScreensaver()) { CSingleLock lock(g_graphicsContext); unsigned int topMost = m_activeDialogs.size(); while (topMost) { CGUIWindow *dialog = m_activeDialogs[--topMost]; lock.Leave(); if (dialog->IsModalDialog()) { // we have the topmost modal dialog if (!dialog->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) { bool fallThrough = (dialog->GetID() == WINDOW_DIALOG_FULLSCREEN_INFO); if (dialog->OnAction(action)) return true; // dialog didn't want the action - we'd normally return false // but for some dialogs we want to drop the actions through if (fallThrough) break; return false; } return true; // do nothing with the action until the anim is finished } // music or video overlay are handled as a special case, as they're modeless, but we allow // clicking on them with the mouse. if (action.id == ACTION_MOUSE && (dialog->GetID() == WINDOW_VIDEO_OVERLAY || dialog->GetID() == WINDOW_MUSIC_OVERLAY)) { if (dialog->OnAction(action)) return true; } lock.Enter(); if (topMost > m_activeDialogs.size()) topMost = m_activeDialogs.size(); } lock.Leave(); } CGUIWindow* window = GetWindow(GetActiveWindow()); if (window) return window->OnAction(action); return false; }
bool CGUIWindowManager::OnAction(const CAction &action) { /* 参数: 1、 返回: 1、 说明: 1、 */ CSingleLock lock(g_graphicsContext); unsigned int topMost = m_activeDialogs.size(); while (topMost) { CGUIWindow *dialog = m_activeDialogs[--topMost]; lock.Leave(); if (dialog->IsModalDialog()) { // we have the topmost modal dialog if (!dialog->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) { bool fallThrough = (dialog->GetID() == WINDOW_DIALOG_FULLSCREEN_INFO); if (dialog->OnAction(action)) return true; // dialog didn't want the action - we'd normally return false // but for some dialogs we want to drop the actions through if (fallThrough) break; return false; } return true; // do nothing with the action until the anim is finished } // music or video overlay are handled as a special case, as they're modeless, but we allow // clicking on them with the mouse. if (action.IsMouse() && (dialog->GetID() == WINDOW_DIALOG_VIDEO_OVERLAY || dialog->GetID() == WINDOW_DIALOG_MUSIC_OVERLAY)) { if (dialog->OnAction(action)) return true; } lock.Enter(); if (topMost > m_activeDialogs.size()) topMost = m_activeDialogs.size(); } lock.Leave(); CGUIWindow* window = GetWindow(GetActiveWindow()); if (window) return window->OnAction(action); return false; }
/// \brief Get the ID of the top most routed window /// \return id ID of the window or WINDOW_INVALID if no routed window available int CGUIWindowManager::GetTopMostModalDialogID(bool ignoreClosing /*= false*/) const { CSingleLock lock(g_graphicsContext); for (crDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it) { CGUIWindow *dialog = *it; if (dialog->IsModalDialog() && (!ignoreClosing || !dialog->IsAnimating(ANIM_TYPE_WINDOW_CLOSE))) { // have a modal window return dialog->GetID(); } } return WINDOW_INVALID; }
/// \brief Get the ID of the top most routed window /// \return id ID of the window or WINDOW_INVALID if no routed window available int CGUIWindowManager::GetTopMostModalDialogID() const { CSingleLock lock(g_graphicsContext); for (crDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it) { CGUIWindow *dialog = *it; if (dialog->IsModalDialog()) { // have a modal window return dialog->GetID(); } } return WINDOW_INVALID; }
bool CGUIWindowManager::HasModalDialog() const { CSingleLock lock(g_graphicsContext); for (ciDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it) { CGUIWindow *window = *it; if (window->IsModalDialog()) { // have a modal window if (!window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) return true; } } return false; }
/// \brief Get the ID of the top most routed window /// \return id ID of the window or WINDOW_INVALID if no routed window available int CGUIWindowManager::GetTopMostModalDialogID() const { // If the screen saver is active, don't tell anyone that there // are any dialogs open, so the window will get the events and // not the dialogs if (g_application.GetInSlideshowScreensaver()) return WINDOW_INVALID; CSingleLock lock(g_graphicsContext); for (crDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it) { CGUIWindow *dialog = *it; if (dialog->IsModalDialog()) { // have a modal window return dialog->GetID(); } } return WINDOW_INVALID; }
bool CGUIWindowManager::HasModalDialog() const { // If the screen saver is active, don't tell anyone that there // are any dialogs open, so the window will get the events and // not the dialogs if (g_application.GetInSlideshowScreensaver()) return false; CSingleLock lock(g_graphicsContext); for (ciDialog it = m_activeDialogs.begin(); it != m_activeDialogs.end(); ++it) { CGUIWindow *window = *it; if (window->IsModalDialog()) { // have a modal window if (!window->IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) return true; } } return false; }
bool CGUIWindowManager::SendMessage(CGUIMessage& message) { bool handled = false; // CLog::Log(LOGDEBUG,"SendMessage: mess=%d send=%d control=%d param1=%d", message.GetMessage(), message.GetSenderId(), message.GetControlId(), message.GetParam1()); // Send the message to all none window targets for (int i = 0; i < (int) m_vecMsgTargets.size(); i++) { IMsgTargetCallback* pMsgTarget = m_vecMsgTargets[i]; if (pMsgTarget) { if (pMsgTarget->OnMessage( message )) handled = true; } } // A GUI_MSG_NOTIFY_ALL is send to any active modal dialog // and all windows whether they are active or not if (message.GetMessage()==GUI_MSG_NOTIFY_ALL) { CSingleLock lock(g_graphicsContext); for (rDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it) { CGUIWindow *dialog = *it; dialog->OnMessage(message); } for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++) { CGUIWindow *pWindow = (*it).second; pWindow->OnMessage(message); } return true; } // Normal messages are sent to: // 1. All active modeless dialogs // 2. The topmost dialog that accepts the message // 3. The underlying window (only if it is the sender or receiver if a modal dialog is active) bool hasModalDialog(false); bool modalAcceptedMessage(false); // don't use an iterator for this loop, as some messages mean that m_activeDialogs is altered, // which will invalidate any iterator CSingleLock lock(g_graphicsContext); unsigned int topWindow = m_activeDialogs.size(); while (topWindow) { CGUIWindow* dialog = m_activeDialogs[--topWindow]; lock.Leave(); if (!modalAcceptedMessage && dialog->IsModalDialog()) { // modal window hasModalDialog = true; if (!modalAcceptedMessage && dialog->OnMessage( message )) { modalAcceptedMessage = handled = true; } } else if (!dialog->IsModalDialog()) { // modeless if (dialog->OnMessage( message )) handled = true; } lock.Enter(); if (topWindow > m_activeDialogs.size()) topWindow = m_activeDialogs.size(); } lock.Leave(); // now send to the underlying window CGUIWindow* window = GetWindow(GetActiveWindow()); if (window) { if (hasModalDialog) { // only send the message to the underlying window if it's the recipient // or sender (or we have no sender) if (message.GetSenderId() == window->GetID() || message.GetControlId() == window->GetID() || message.GetSenderId() == 0 ) { if (window->OnMessage(message)) handled = true; } } else { if (window->OnMessage(message)) handled = true; } } return handled; }