void CGUIMediaWindow::LoadAdditionalTags(TiXmlElement *root) { CGUIWindow::LoadAdditionalTags(root); // configure our view control m_viewControl.Reset(); m_viewControl.SetParentWindow(GetID()); TiXmlElement *element = root->FirstChildElement("views"); if (element && element->FirstChild()) { // format is <views>50,29,51,95</views> CStdString allViews = element->FirstChild()->Value(); CStdStringArray views; StringUtils::SplitString(allViews, ",", views); for (unsigned int i = 0; i < views.size(); i++) { int controlID = atol(views[i].c_str()); CGUIControl *control = (CGUIControl *)GetControl(controlID); if (control && control->IsContainer()) m_viewControl.AddView(control); } } else { // backward compatibility vector<CGUIControl *> controls; GetContainers(controls); for (ciControls it = controls.begin(); it != controls.end(); it++) { CGUIControl *control = *it; if (control->GetID() >= CONTROL_VIEW_START && control->GetID() <= CONTROL_VIEW_END) m_viewControl.AddView(control); } } m_viewControl.SetViewControlID(CONTROL_BTNVIEWASICONS); }
bool CGUIWindowSettings::OnAction(const CAction &action) { if (action.id == ACTION_PREVIOUS_MENU) { g_windowManager.PreviousWindow(); return true; } else if (action.id == ACTION_PARENT_DIR) { g_windowManager.PreviousWindow(); return true; } else if (action.id == ACTION_SELECT_ITEM) { CGUIControl *focusedControl = GetFocusedControl(); if (focusedControl && focusedControl->IsContainer()) { m_iSelectedControl = focusedControl->GetID(); CGUIBaseContainer* container = (CGUIBaseContainer*)focusedControl; m_iSelectedItem = container->GetSelectedItem(); } } return CGUIWindow::OnAction(action); }
bool CGUIPVRChannelGroupsSelector::Initialize(CGUIWindow* parent, bool bRadio) { CGUIControl* control = parent->GetControl(CONTROL_LSTCHANNELGROUPS); if (control && control->IsContainer()) { m_control = control; m_channelGroups = CServiceBroker::GetPVRManager().ChannelGroups()->Get(bRadio)->GetMembers(true); CFileItemList channelGroupItems; for (const auto& group : m_channelGroups) { CFileItemPtr item(new CFileItem(group->GetPath(), true)); item->m_strTitle = group->GroupName(); item->SetLabel(group->GroupName()); channelGroupItems.Add(item); } CGUIMessage msg(GUI_MSG_LABEL_BIND, m_control->GetID(), CONTROL_LSTCHANNELGROUPS, 0, 0, &channelGroupItems); m_control->OnMessage(msg); return true; } return false; }
bool CGUIPythonWindowXML::OnMessage(CGUIMessage& message) { // TODO: We shouldn't be dropping down to CGUIWindow in any of this ideally. // We have to make up our minds about what python should be doing and // what this side of things should be doing switch (message.GetMessage()) { case GUI_MSG_WINDOW_DEINIT: { return CGUIMediaWindow::OnMessage(message); } break; case GUI_MSG_WINDOW_INIT: { CGUIMediaWindow::OnMessage(message); if(pCallbackWindow) { PyXBMC_AddPendingCall((PyThreadState*)m_threadState, Py_XBMC_Event_OnInit, new PyXBMCAction(pCallbackWindow)); PulseActionEvent(); } return true; } break; case GUI_MSG_FOCUSED: { if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != (int)message.GetControlId()) { m_viewControl.SetFocused(); return true; } // check if our focused control is one of our category buttons int iControl=message.GetControlId(); if(pCallbackWindow) { PyXBMCAction* inf = new PyXBMCAction(pCallbackWindow); inf->controlId = iControl; // aquire lock? PyXBMC_AddPendingCall((PyThreadState*)m_threadState, Py_XBMC_Event_OnFocus, inf); PulseActionEvent(); } } break; case GUI_MSG_CLICKED: { int iControl=message.GetSenderId(); // Handle Sort/View internally. Scripters shouldn't use ID 2, 3 or 4. if (iControl == CONTROL_BTNSORTASC) // sort asc { CLog::Log(LOGINFO, "WindowXML: Internal asc/dsc button not implemented"); /*if (m_guiState.get()) m_guiState->SetNextSortOrder(); UpdateFileList();*/ return true; } else if (iControl == CONTROL_BTNSORTBY) // sort by { CLog::Log(LOGINFO, "WindowXML: Internal sort button not implemented"); /*if (m_guiState.get()) m_guiState->SetNextSortMethod(); UpdateFileList();*/ return true; } else if (iControl == CONTROL_BTNVIEWASICONS) { // base class handles this one break; } if(pCallbackWindow && iControl && iControl != (int)this->GetID()) // pCallbackWindow && != this->GetID()) { CGUIControl* controlClicked = (CGUIControl*)this->GetControl(iControl); // The old python way used to check list AND SELECITEM method or if its a button, checkmark. // Its done this way for now to allow other controls without a python version like togglebutton to still raise a onAction event if (controlClicked) // Will get problems if we the id is not on the window and we try to do GetControlType on it. So check to make sure it exists { if ((controlClicked->IsContainer() && (message.GetParam1() == ACTION_SELECT_ITEM || message.GetParam1() == ACTION_MOUSE_LEFT_CLICK)) || !controlClicked->IsContainer()) { PyXBMCAction* inf = new PyXBMCAction(pCallbackWindow); inf->controlId = iControl; // aquire lock? PyXBMC_AddPendingCall((PyThreadState*)m_threadState, Py_XBMC_Event_OnClick, inf); PulseActionEvent(); return true; } else if (controlClicked->IsContainer() && message.GetParam1() == ACTION_MOUSE_RIGHT_CLICK) { PyXBMCAction* inf = new PyXBMCAction(pCallbackWindow); inf->pObject = Action_FromAction(CAction(ACTION_CONTEXT_MENU)); // aquire lock? PyXBMC_AddPendingCall((PyThreadState*)m_threadState, Py_XBMC_Event_OnAction, inf); PulseActionEvent(); return true; } } } } break; } return CGUIMediaWindow::OnMessage(message); }
bool CGUIAddonWindow::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_DEINIT: { return CGUIMediaWindow::OnMessage(message); } break; case GUI_MSG_WINDOW_INIT: { CGUIMediaWindow::OnMessage(message); if (CBOnInit) CBOnInit(m_clientHandle); return true; } break; case GUI_MSG_FOCUSED: { if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != (int)message.GetControlId()) { m_viewControl.SetFocused(); return true; } // check if our focused control is one of our category buttons int iControl = message.GetControlId(); if (CBOnFocus) CBOnFocus(m_clientHandle, iControl); } break; case GUI_MSG_NOTIFY_ALL: { // most messages from GUI_MSG_NOTIFY_ALL break container content, whitelist working ones. if (message.GetParam1() == GUI_MSG_PAGE_CHANGE || message.GetParam1() == GUI_MSG_WINDOW_RESIZE) return CGUIMediaWindow::OnMessage(message); return true; } case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl && iControl != static_cast<int>(this->GetID())) { CGUIControl* controlClicked = dynamic_cast<CGUIControl*>(this->GetControl(iControl)); // The old python way used to check list AND SELECITEM method or if its a button, checkmark. // Its done this way for now to allow other controls without a python version like togglebutton to still raise a onAction event if (controlClicked) // Will get problems if we the id is not on the window and we try to do GetControlType on it. So check to make sure it exists { if ((controlClicked->IsContainer() && (message.GetParam1() == ACTION_SELECT_ITEM || message.GetParam1() == ACTION_MOUSE_LEFT_CLICK)) || !controlClicked->IsContainer()) { if (CBOnClick) return CBOnClick(m_clientHandle, iControl); } else if (controlClicked->IsContainer() && (message.GetParam1() == ACTION_MOUSE_RIGHT_CLICK || message.GetParam1() == ACTION_CONTEXT_MENU)) { if (CBOnAction) { // Check addon want to handle right click for a context menu, if // not used from addon becomes "GetContextButtons(...)" called. if (CBOnAction(m_clientHandle, ACTION_CONTEXT_MENU)) return true; } } } } } break; } return CGUIMediaWindow::OnMessage(message); }
bool CInputManager::OnKey(const CKey& key) { for (std::vector<KEYBOARD::IKeyboardHandler*>::iterator it = m_keyboardHandlers.begin(); it != m_keyboardHandlers.end(); ++it) { if ((*it)->OnKeyPress(key)) return true; } // Turn the mouse off, as we've just got a keypress from controller or remote m_Mouse.SetActive(false); // get the current active window int iWin = g_windowManager.GetActiveWindowID(); // this will be checked for certain keycodes that need // special handling if the screensaver is active CAction action = m_buttonTranslator->GetAction(iWin, key); // a key has been pressed. // reset Idle Timer g_application.ResetSystemIdleTimer(); bool processKey = AlwaysProcess(action); if (StringUtils::StartsWithNoCase(action.GetName(), "CECToggleState") || StringUtils::StartsWithNoCase(action.GetName(), "CECStandby")) { // do not wake up the screensaver right after switching off the playing device if (StringUtils::StartsWithNoCase(action.GetName(), "CECToggleState")) { CLog::LogF(LOGDEBUG, "action %s [%d], toggling state of playing device", action.GetName().c_str(), action.GetID()); bool result; CApplicationMessenger::GetInstance().SendMsg(TMSG_CECTOGGLESTATE, 0, 0, static_cast<void*>(&result)); if (!result) return true; } else { CApplicationMessenger::GetInstance().PostMsg(TMSG_CECSTANDBY); return true; } } g_application.ResetScreenSaver(); // allow some keys to be processed while the screensaver is active if (g_application.WakeUpScreenSaverAndDPMS(processKey) && !processKey) { CLog::LogF(LOGDEBUG, "%s pressed, screen saver/dpms woken up", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str()); return true; } if (iWin != WINDOW_FULLSCREEN_VIDEO) { // current active window isnt the fullscreen window // just use corresponding section from keymap.xml // to map key->action // first determine if we should use keyboard input directly bool useKeyboard = key.FromKeyboard() && (iWin == WINDOW_DIALOG_KEYBOARD || iWin == WINDOW_DIALOG_NUMERIC); CGUIWindow *window = g_windowManager.GetWindow(iWin); if (window) { CGUIControl *control = window->GetFocusedControl(); if (control) { // If this is an edit control set usekeyboard to true. This causes the // keypress to be processed directly not through the key mappings. if (control->GetControlType() == CGUIControl::GUICONTROL_EDIT) useKeyboard = true; // If the key pressed is shift-A to shift-Z set usekeyboard to true. // This causes the keypress to be used for list navigation. if (control->IsContainer() && key.GetModifiers() == CKey::MODIFIER_SHIFT && key.GetVKey() >= XBMCVK_A && key.GetVKey() <= XBMCVK_Z) useKeyboard = true; } } if (useKeyboard) { // use the virtualkeyboard section of the keymap, and send keyboard-specific or navigation // actions through if that's what they are CAction action = m_buttonTranslator->GetAction(WINDOW_DIALOG_KEYBOARD, key); if (!(action.GetID() == ACTION_MOVE_LEFT || action.GetID() == ACTION_MOVE_RIGHT || action.GetID() == ACTION_MOVE_UP || action.GetID() == ACTION_MOVE_DOWN || action.GetID() == ACTION_SELECT_ITEM || action.GetID() == ACTION_ENTER || action.GetID() == ACTION_PREVIOUS_MENU || action.GetID() == ACTION_NAV_BACK || action.GetID() == ACTION_VOICE_RECOGNIZE)) { // the action isn't plain navigation - check for a keyboard-specific keymap action = m_buttonTranslator->GetAction(WINDOW_DIALOG_KEYBOARD, key, false); if (!(action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) || action.GetID() == ACTION_BACKSPACE || action.GetID() == ACTION_SHIFT || action.GetID() == ACTION_SYMBOLS || action.GetID() == ACTION_CURSOR_LEFT || action.GetID() == ACTION_CURSOR_RIGHT) action = CAction(0); // don't bother with this action } // else pass the keys through directly if (!action.GetID()) { if (key.GetFromService()) action = CAction(key.GetButtonCode() != KEY_INVALID ? key.GetButtonCode() : 0, key.GetUnicode()); else { // Check for paste keypress #ifdef TARGET_WINDOWS // In Windows paste is ctrl-V if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_CTRL) #elif defined(TARGET_LINUX) // In Linux paste is ctrl-V if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_CTRL) #elif defined(TARGET_DARWIN_OSX) // In OSX paste is cmd-V if (key.GetVKey() == XBMCVK_V && key.GetModifiers() == CKey::MODIFIER_META) #else // Placeholder for other operating systems if (false) #endif action = CAction(ACTION_PASTE); // If the unicode is non-zero the keypress is a non-printing character else if (key.GetUnicode()) action = CAction(key.GetAscii() | KEY_ASCII, key.GetUnicode()); // The keypress is a non-printing character else action = CAction(key.GetVKey() | KEY_VKEY); } } CLog::LogF(LOGDEBUG, "%s pressed, trying keyboard action %x", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetID()); if (g_application.OnAction(action)) return true; // failed to handle the keyboard action, drop down through to standard action } if (key.GetFromService()) { if (key.GetButtonCode() != KEY_INVALID) action = m_buttonTranslator->GetAction(iWin, key); } else action = m_buttonTranslator->GetAction(iWin, key); } if (!key.IsAnalogButton()) CLog::LogF(LOGDEBUG, "%s pressed, action is %s", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str(), action.GetName().c_str()); return ExecuteInputAction(action); }