void FocusHandleEnter(EWin * ewin, XEvent * ev) { Mode.mouse_over_ewin = ewin; #if 0 /* FIXME - Remove? */ if (ev->xcrossing.mode == NotifyUngrab && ev->xcrossing.detail == NotifyNonlinearVirtual) { if (EDebug(1)) Eprintf("%s: Previously ignored: focused: %s, enter: %s\n", __func__, EoGetNameSafe(Mode.focuswin), EoGetNameSafe(ewin)); } #endif if ((int)ev->xcrossing.serial - focus_request < 0) { /* This event was caused by a request older than the latest * focus assignment request - ignore */ if (EDebug(EDBUG_TYPE_FOCUS)) Eprintf("%s: Ignore serial < %#x\n", __func__, focus_request); return; } if (!ewin) { /* Entering root may mean entering this screen */ FocusToEWin(NULL, FOCUS_DESK_ENTER); return; } switch (Conf.focus.mode) { default: case MODE_FOCUS_CLICK: break; case MODE_FOCUS_SLOPPY: if (FocusEwinValid(ewin, 1, 0, 0)) FocusToEWin(ewin, FOCUS_ENTER); break; case MODE_FOCUS_POINTER: if (FocusEwinValid(ewin, 1, 0, 0)) FocusToEWin(ewin, FOCUS_ENTER); else FocusToEWin(NULL, FOCUS_NONE); break; } }
/* * dir > 0: Focus previously focused window * else : Focus least recently focused window */ static void FocusCycleEwin(int dir) { EWin *const *lst; EWin *ewin; int i, j, num; lst = EwinListFocusGet(&num); if (num <= 1) return; dir = (dir > 0) ? 1 : -1; for (j = 0; j < num; j++) { if (lst[j] == Mode.focuswin) break; } for (i = 1; i < num; i++) { ewin = lst[(j + i * dir + num) % num]; if (!FocusEwinValid(ewin, 1, 0, 0) || ewin->props.skip_focuslist) continue; FocusToEWin(ewin, FOCUS_PREV); break; } }
void FocusNewDesk(void) { FocusEnable(1); FocusToEWin(NULL, FOCUS_DESK_ENTER); /* Unfreeze keyboard */ GrabKeyboardRelease(); }
static void FocusInit(void) { /* Start focusing windows */ FocusEnable(1); FocusToEWin(NULL, FOCUS_INIT); FocusSet(); /* Enable window placement features */ Mode.place.enable_features++; }
void FocusHandleLeave(EWin * ewin, XEvent * ev) { if ((int)ev->xcrossing.serial - focus_request < 0) { /* This event was caused by a request older than the latest * focus assignment request - ignore */ if (EDebug(EDBUG_TYPE_FOCUS)) Eprintf("%s: Ignore serial < %#x\n", __func__, focus_request); return; } /* Leaving root may mean entering other screen */ if (!ewin) { if (ev->xcrossing.mode == NotifyNormal && ev->xcrossing.detail != NotifyInferior) FocusToEWin(NULL, FOCUS_DESK_LEAVE); } }
static void WarpFocusClick(int ix) { EWin *ewin; if (!warplist) return; if (ix < 0 || ix >= warplist_num) return; if (ix == warpFocusIndex) return; warpFocusIndex = ix; WarpFocusShow(); ewin = warplist[ix].ewin; if (!EwinFindByPtr(ewin)) return; if (Conf.focus.raise_on_next) EwinRaise(ewin); FocusToEWin(ewin, FOCUS_SET); }
void WarpFocus(int delta) { WarpFocusWin *fw = warpFocusWindow; EWin *const *lst; EWin *ewin; int i, num; WarplistItem *wl; /* Remember invoking keycode (ugly hack) */ if (!fw || !EoIsShown(fw)) { warpFocusKey = Mode.events.last_keycode; warpFocusState = Mode.events.last_keystate; } if (!warplist) { warplist_num = 0; /* Not necessary but silences clang */ lst = EwinListFocusGet(&num); for (i = 0; i < num; i++) { ewin = lst[i]; if ( /* Either visible or iconified */ ((EwinIsOnScreen(ewin)) || (ewin->state.iconified) || (Conf.warplist.showalldesks)) && /* Exclude windows that explicitely say so */ (!ewin->props.skip_focuslist) && (!ewin->props.skip_ext_task) && /* Keep shaded windows if conf say so */ ((!ewin->state.shaded) || (Conf.warplist.showshaded)) && /* Keep sticky windows if conf say so */ ((!EoIsSticky(ewin)) || (Conf.warplist.showsticky)) && /* Keep iconified windows if conf say so */ ((!ewin->state.iconified) || (Conf.warplist.showiconified))) { warplist_num++; warplist = EREALLOC(WarplistItem, warplist, warplist_num); wl = warplist + warplist_num - 1; wl->ewin = ewin; } } /* Hmmm. Hack... */ if (warplist_num >= 2 && warplist[1].ewin == GetFocusEwin()) { warplist[1].ewin = warplist[0].ewin; warplist[0].ewin = GetFocusEwin(); } warpFocusIndex = 0; } if (!warplist) return; warpFocusIndex = (warpFocusIndex + warplist_num + delta) % warplist_num; ewin = warplist[warpFocusIndex].ewin; if (!EwinFindByPtr(ewin)) ewin = NULL; if (!ewin) return; WarpFocusShow(); if (!EwinIsOnScreen(ewin)) return; if (Conf.warplist.show_shape) WarpShapeDraw(ewin); if (Conf.focus.raise_on_next) EwinRaise(ewin); if (Conf.focus.warp_on_next) EwinWarpTo(ewin, 0); if (Conf.warplist.warpfocused) FocusToEWin(ewin, FOCUS_SET); }
/* outstanding BUG: zooming on shaped windows leaves stuff exposed beneath them..... */ void Zoom(EWin * ewin, int on) { if (Mode.wm.window) return; if (!ewin) ewin = zoom_last_ewin; if (!ewin) return; if (zoom_can == 0) ZoomInit(); if (zoom_can <= 0) return; Dprintf("%s: on=%d\n", __func__, on); if (!on) { /* Unzoom */ if (ewin != zoom_last_ewin) return; _ZoomEwinRestore(ewin); SwitchRes(0, 0, 0, 0, 0, NULL, NULL); zw = zh = 0; zoom_last_ewin = NULL; } else if (ewin == zoom_last_ewin) { /* Already zoomed */ return; } else { /* Zoom */ if (ewin->state.fullscreen) return; if (!zoom_last_ewin) /* first zoom */ { on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h, &zw, &zh); } else /* we are zoomed in on another window already.... */ { _ZoomEwinRestore(zoom_last_ewin); if ((ewin->client.w <= zw) && (ewin->client.h <= zh) && ((ewin->client.w >= zw / 2) || (ewin->client.h >= zh / 2))) { /* YAY no need to change resolution :-D */ } else { /* SwitchRes only tracks the LAST mode, so we have to switch back to * the original mode before switching to new target mode * so that we can restore the original vid mode when we zoom * out of the last window ;( */ SwitchRes(0, 0, 0, 0, 0, NULL, NULL); on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h, &zw, &zh); } } Dprintf("%s: SwitchRes=%d - client size %dx%d -> screen %dx%d\n", __func__, on, ewin->client.w, ewin->client.h, zw, zh); if (!on) return; ewin->save_fs.x = EoGetX(ewin); ewin->save_fs.y = EoGetY(ewin); EwinRaise(ewin); EwinBorderSetTo(ewin, BorderCreateFiller(ewin->client.w, ewin->client.h, zw, zh)); EwinMoveResize(ewin, 0, 0, ewin->client.w, ewin->client.h, 0); ewin->state.zoomed = 1; FocusToEWin(ewin, FOCUS_SET); zoom_last_ewin = ewin; } EwinWarpTo(ewin, 1); ESync(0); EwinStateUpdate(ewin); HintsSetWindowState(ewin); }