/************************************************************************** * * Moves focus to specified window * *************************************************************************/ void FocusOn(FvwmWindow *t, Bool FocusByMouse, char *action) { int dx,dy; int cx,cy; Bool do_not_warp; if (t == NULL || HAS_NEVER_FOCUS(t)) { UngrabEm(GRAB_NORMAL); if (t) { /* give the window a chance to take the focus itself */ MoveFocus(t->w, t, FocusByMouse, 1, 0); } return; } if (!(do_not_warp = StrEquals(PeekToken(action, NULL), "NoWarp"))) { if (t->Desk != Scr.CurrentDesk) { goto_desk(t->Desk); } if (IS_ICONIFIED(t)) { cx = t->icon_xl_loc + t->icon_g.width/2; cy = t->icon_g.y + t->icon_p_height + ICON_HEIGHT(t) / 2; } else { cx = t->frame_g.x + t->frame_g.width/2; cy = t->frame_g.y + t->frame_g.height/2; } dx = (cx + Scr.Vx)/Scr.MyDisplayWidth*Scr.MyDisplayWidth; dy = (cy +Scr.Vy)/Scr.MyDisplayHeight*Scr.MyDisplayHeight; MoveViewport(dx,dy,True); /* If the window is still not visible, make it visible! */ if (((t->frame_g.x + t->frame_g.height)< 0)|| (t->frame_g.y + t->frame_g.width < 0)|| (t->frame_g.x >Scr.MyDisplayWidth)||(t->frame_g.y>Scr.MyDisplayHeight)) { SetupFrame(t, 0, 0, t->frame_g.width, t->frame_g.height, False); if (HAS_MOUSE_FOCUS(t) || HAS_SLOPPY_FOCUS(t)) { XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, 2,2); } } } UngrabEm(GRAB_NORMAL); if (t->Desk == Scr.CurrentDesk) { MoveFocus(t->w, t, FocusByMouse, do_not_warp, 0); } return; }
void MAS::Window::MsgLostfocus() { Dialog::MsgLostfocus(); bLeft.SendMessage(MSG_LOSTFOCUS); bRight.SendMessage(MSG_LOSTFOCUS); bTop.SendMessage(MSG_LOSTFOCUS); bBottom.SendMessage(MSG_LOSTFOCUS); bGrip.SendMessage(MSG_LOSTFOCUS); textBack.SendMessage(MSG_LOSTFOCUS); UpdateWindowProperties(); MoveFocus(focusObject, NULL); iconExit.Disable(); iconMin.Disable(); iconMax.Disable(); title.Disable(); }
void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { if(!mIsKeyboardFocusEnabled) { return; } AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get(); bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled(); Toolkit::AccessibilityManager accessibilityManager = Toolkit::AccessibilityManager::Get(); std::string keyName = event.keyPressedName; bool isFocusStartableKey = false; if(event.state == KeyEvent::Down) { if (keyName == "Left") { if(!isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards left MoveFocus(Toolkit::Control::KeyboardFocus::LEFT); } isFocusStartableKey = true; } else { // Move the accessibility focus backward accessibilityManager.MoveFocusBackward(); } } else if (keyName == "Right") { if(!isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards right MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); } } else { // Move the accessibility focus forward accessibilityManager.MoveFocusForward(); } isFocusStartableKey = true; } else if (keyName == "Up" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards up MoveFocus(Toolkit::Control::KeyboardFocus::UP); } isFocusStartableKey = true; } else if (keyName == "Down" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards down MoveFocus(Toolkit::Control::KeyboardFocus::DOWN); } isFocusStartableKey = true; } else if (keyName == "Tab" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // "Tab" key changes the focus group in the forward direction and // "Shift-Tab" key changes it in the backward direction. DoMoveFocusToNextFocusGroup(!event.IsShiftModifier()); } isFocusStartableKey = true; } else if (keyName == "space" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } isFocusStartableKey = true; } else if (keyName == "" && !isAccessibilityEnabled) { // Check the fake key event for evas-plugin case if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } isFocusStartableKey = true; } else if (keyName == "Backspace" && !isAccessibilityEnabled) { // Emit signal to go back to the previous view??? } } else if(event.state == KeyEvent::Up) { if (keyName == "Return") { if(!mIsFocusIndicatorEnabled && !isAccessibilityEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // The focused actor has enter pressed on it Actor actor; if( !isAccessibilityEnabled ) { actor = GetCurrentFocusActor(); } else { actor = accessibilityManager.GetCurrentFocusActor(); } if( actor ) { DoKeyboardEnter( actor ); } } isFocusStartableKey = true; } } if(isFocusStartableKey && mIsFocusIndicatorEnabled && !isAccessibilityEnabled) { Actor actor = GetCurrentFocusActor(); if( !actor ) { // No actor is focused but keyboard focus is activated by the key press // Let's try to move the initial focus MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); } else if(mFocusIndicatorActor) { // Make sure the focused actor is highlighted actor.Add(mFocusIndicatorActor); } } }
void ForceDeleteFocus(Bool FocusByMouse) { MoveFocus(Scr.NoFocusWin, NULL, FocusByMouse, False, True); }
void ReturnFocusWindow(FvwmWindow *Fw, Bool FocusByMouse) { MoveFocus(Fw->w, Fw, FocusByMouse, True, False); }
void SetFocusWindow(FvwmWindow *Fw, Bool FocusByMouse) { MoveFocus(Fw->w, Fw, FocusByMouse, False, False); }
HRESULT CUIWindow::Display(int OffsetX, int OffsetY) { // go exclusive if(m_Mode==WINDOW_EXCLUSIVE || m_Mode==WINDOW_SYSTEM_EXCLUSIVE) { if(!m_ShieldWindow) m_ShieldWindow = new CUIWindow(Game); if(m_ShieldWindow) { m_ShieldWindow->m_PosX = m_ShieldWindow->m_PosY = 0; m_ShieldWindow->m_Width = Game->m_Renderer->m_Width; m_ShieldWindow->m_Height = Game->m_Renderer->m_Height; m_ShieldWindow->Display(); } } else if(m_IsMenu) { if(!m_ShieldButton) { m_ShieldButton = new CUIButton(Game); m_ShieldButton->SetName("close"); m_ShieldButton->SetListener(this, m_ShieldButton, 0); m_ShieldButton->m_Parent = this; } if(m_ShieldButton) { m_ShieldButton->m_PosX = m_ShieldButton->m_PosY = 0; m_ShieldButton->m_Width = Game->m_Renderer->m_Width; m_ShieldButton->m_Height = Game->m_Renderer->m_Height; m_ShieldButton->Display(); } } if(!m_Visible) return S_OK; if(m_FadeBackground) Game->m_Renderer->FadeToColor(m_FadeColor); if(m_Dragging) { m_PosX += (Game->m_MousePos.x - m_DragFrom.x); m_PosY += (Game->m_MousePos.y - m_DragFrom.y); m_DragFrom.x = Game->m_MousePos.x; m_DragFrom.y = Game->m_MousePos.y; } if(!m_FocusedWidget || (!m_FocusedWidget->m_CanFocus || m_FocusedWidget->m_Disable || !m_FocusedWidget->m_Visible)) { MoveFocus(); } bool PopViewport = false; if(m_ClipContents) { if(!m_Viewport) m_Viewport = new CBViewport(Game); if(m_Viewport) { m_Viewport->SetRect(m_PosX+OffsetX, m_PosY+OffsetY, m_PosX+m_Width+OffsetX, m_PosY+m_Height+OffsetY); Game->PushViewport(m_Viewport); PopViewport = true; } } CUITiledImage* back = m_Back; CBSprite* image = m_Image; CBFont* font = m_Font; if(!IsFocused()) { if(m_BackInactive) back = m_BackInactive; if(m_ImageInactive) image = m_ImageInactive; if(m_FontInactive) font = m_FontInactive; } if(m_AlphaColor!=0) Game->m_Renderer->m_ForceAlphaColor = m_AlphaColor; if(back) { back->Display(m_PosX + OffsetX, m_PosY + OffsetY, m_Width, m_Height); } if(image) { image->Draw(m_PosX + OffsetX, m_PosY + OffsetY, m_Transparent?NULL:this); } if(!CBPlatform::IsRectEmpty(&m_TitleRect) && font && m_Text) { font->DrawText((BYTE*)m_Text, m_PosX+OffsetX+m_TitleRect.left, m_PosY+OffsetY+m_TitleRect.top, m_TitleRect.right-m_TitleRect.left, m_TitleAlign, m_TitleRect.bottom-m_TitleRect.top); } if(!m_Transparent && !image) Game->m_Renderer->m_RectList.Add(new CBActiveRect(Game, this, NULL, m_PosX+OffsetX, m_PosY+OffsetY, m_Width, m_Height, 100, 100, false)); for(int i=0; i<m_Widgets.GetSize(); i++) { m_Widgets[i]->Display(m_PosX+OffsetX, m_PosY+OffsetY); } if(m_AlphaColor!=0) Game->m_Renderer->m_ForceAlphaColor = 0; if(PopViewport) { Game->PopViewport(); } return S_OK; }