/************************************************************************** * * 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; }
/************************************************************************** * * Moves pointer to specified window * *************************************************************************/ static void warp_to_fvwm_window( XEvent *eventp, FvwmWindow *t, int warp_x, int x_unit, int warp_y, int y_unit) { int dx,dy; int cx,cy; int x,y; if(t == (FvwmWindow *)0 || (IS_ICONIFIED(t) && t->icon_w == None)) return; 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(IS_ICONIFIED(t)) { x = t->icon_xl_loc + t->icon_g.width / 2; y = t->icon_g.y + t->icon_p_height + ICON_HEIGHT(t) / 2; } else { if (x_unit != Scr.MyDisplayWidth && warp_x >= 0) x = t->frame_g.x + warp_x; else if (x_unit != Scr.MyDisplayWidth) x = t->frame_g.x + t->frame_g.width + warp_x; else if (warp_x >= 0) x = t->frame_g.x + (t->frame_g.width - 1) * warp_x / 100; else x = t->frame_g.x + (t->frame_g.width - 1) * (100 + warp_x) / 100; if (y_unit != Scr.MyDisplayHeight && warp_y >= 0) y = t->frame_g.y + warp_y; else if (y_unit != Scr.MyDisplayHeight) y = t->frame_g.y + t->frame_g.height + warp_y; else if (warp_y >= 0) y = t->frame_g.y + (t->frame_g.height - 1) * warp_y / 100; else y = t->frame_g.y + (t->frame_g.height - 1) * (100 + warp_y) / 100; } XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, x, y); SetPointerEventPosition(eventp, x, y); RaiseWindow(t); /* If the window is still not visible, make it visible! */ if (t->frame_g.x + t->frame_g.width < 0 || t->frame_g.y + t->frame_g.height < 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); XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, 2,2); SetPointerEventPosition(eventp, 2, 2); } }
/* * * Moves focus to specified window; only to be called bay Focus and FlipFocus * */ static void __activate_window_by_command( F_CMD_ARGS, int is_focus_by_flip_focus_cmd) { int cx; int cy; Bool do_not_warp; sftfwin_args_t sf_args; FvwmWindow * const fw = exc->w.fw; memset(&sf_args, 0, sizeof(sf_args)); sf_args.do_allow_force_broadcast = 1; sf_args.is_focus_by_flip_focus_cmd = is_focus_by_flip_focus_cmd; sf_args.set_by = FOCUS_SET_BY_FUNCTION; sf_args.client_entered = 0; if (fw == NULL || !FP_DO_FOCUS_BY_FUNCTION(FW_FOCUS_POLICY(fw))) { UngrabEm(GRAB_NORMAL); if (fw) { /* give the window a chance to take the focus itself */ sf_args.do_forbid_warp = 1; sf_args.do_force = 0; set_focus_to_fwin(FW_W(fw), fw, &sf_args); } return; } do_not_warp = StrEquals(PeekToken(action, NULL), "NoWarp"); if (!do_not_warp) { if (fw->Desk != Scr.CurrentDesk) { goto_desk(fw->Desk); } if (IS_ICONIFIED(fw)) { rectangle g; Bool rc; rc = get_visible_icon_title_geometry(fw, &g); if (rc == False) { get_visible_icon_picture_geometry(fw, &g); } cx = g.x + g.width / 2; cy = g.y + g.height / 2; } else { cx = fw->g.frame.x + fw->g.frame.width/2; cy = fw->g.frame.y + fw->g.frame.height/2; } if ( cx < 0 || cx >= Scr.MyDisplayWidth || cy < 0 || cy >= Scr.MyDisplayHeight) { int dx; int dy; dx = ((cx + Scr.Vx) / Scr.MyDisplayWidth) * Scr.MyDisplayWidth; dy = ((cy + Scr.Vy) / Scr.MyDisplayHeight) * Scr.MyDisplayHeight; MoveViewport(dx, dy, True); } #if 0 /* can not happen */ /* If the window is still not visible, make it visible! */ if (fw->g.frame.x + fw->g.frame.width < 0 || fw->g.frame.y + fw->g.frame.height < 0 || fw->g.frame.x >= Scr.MyDisplayWidth || fw->g.frame.y >= Scr.MyDisplayHeight) { frame_setup_window( fw, 0, 0, fw->g.frame.width, fw->g.frame.height, False); if ( FP_DO_WARP_POINTER_ON_FOCUS_FUNC( FW_FOCUS_POLICY(fw))) { FWarpPointerUpdateEvpos( exc->x.elast, dpy, None, Scr.Root, 0, 0, 0, 0, 2, 2); } } #endif } UngrabEm(GRAB_NORMAL); if (fw->Desk == Scr.CurrentDesk) { FvwmWindow *sf; sf = get_focus_window(); sf_args.do_forbid_warp = !!do_not_warp; sf_args.do_force = 0; sf_args.client_entered = 0; set_focus_to_fwin(FW_W(fw), fw, &sf_args); if (sf != get_focus_window()) { /* Ignore EnterNotify event while we are waiting for * this window to be focused. */ Scr.focus_in_pending_window = sf; } } return; }
/* * * Moves pointer to specified window * */ static void warp_to_fvwm_window( const exec_context_t *exc, int warp_x, int x_unit, int warp_y, int y_unit, int do_raise) { int dx,dy; int cx,cy; int x,y; FvwmWindow *t = exc->w.fw; if (t == (FvwmWindow *)0 || (IS_ICONIFIED(t) && FW_W_ICON_TITLE(t) == None)) { return; } if (t->Desk != Scr.CurrentDesk) { goto_desk(t->Desk); } if (IS_ICONIFIED(t)) { rectangle g; Bool rc; rc = get_visible_icon_title_geometry(t, &g); if (rc == False) { get_visible_icon_picture_geometry(t, &g); } cx = g.x + g.width / 2; cy = g.y + g.height / 2; } else { cx = t->g.frame.x + t->g.frame.width/2; cy = t->g.frame.y + t->g.frame.height/2; } dx = (cx + Scr.Vx) / Scr.MyDisplayWidth * Scr.MyDisplayWidth; dy = (cy + Scr.Vy) / Scr.MyDisplayHeight * Scr.MyDisplayHeight; if (dx != Scr.Vx || dy != Scr.Vy) { MoveViewport(dx, dy, True); } if (IS_ICONIFIED(t)) { rectangle g; Bool rc; rc = get_visible_icon_title_geometry(t, &g); if (rc == False) { get_visible_icon_picture_geometry(t, &g); } x = g.x + g.width / 2; y = g.y + g.height / 2; } else { if (x_unit != Scr.MyDisplayWidth && warp_x >= 0) { x = t->g.frame.x + warp_x; } else if (x_unit != Scr.MyDisplayWidth) { x = t->g.frame.x + t->g.frame.width + warp_x; } else if (warp_x >= 0) { x = t->g.frame.x + (t->g.frame.width - 1) * warp_x / 100; } else { x = t->g.frame.x + (t->g.frame.width - 1) * (100 + warp_x) / 100; } if (y_unit != Scr.MyDisplayHeight && warp_y >= 0) { y = t->g.frame.y + warp_y; } else if (y_unit != Scr.MyDisplayHeight) { y = t->g.frame.y + t->g.frame.height + warp_y; } else if (warp_y >= 0) { y = t->g.frame.y + (t->g.frame.height - 1) * warp_y / 100; } else { y = t->g.frame.y + (t->g.frame.height - 1) * (100 + warp_y) / 100; } } FWarpPointerUpdateEvpos( exc->x.elast, dpy, None, Scr.Root, 0, 0, 0, 0, x, y); if (do_raise) { RaiseWindow(t, False); } /* If the window is still not visible, make it visible! */ if (t->g.frame.x + t->g.frame.width < 0 || t->g.frame.y + t->g.frame.height < 0 || t->g.frame.x >= Scr.MyDisplayWidth || t->g.frame.y >= Scr.MyDisplayHeight) { frame_setup_window( t, 0, 0, t->g.frame.width, t->g.frame.height, False); FWarpPointerUpdateEvpos( exc->x.elast, dpy, None, Scr.Root, 0, 0, 0, 0, 2, 2); } return; }