QIIHRSY26Q3QJQUIDTU4M4C5NGAW3NGDOKT5UVZBD25A6UVPQDPQC ZR6I4SJG6KY6VHLIAEZSUW7CWISQWLUE5H4USXH2JB67QNH3RPTQC L2QLSXLWYBIPQD2K7D5MGNCCS3AONK2UA7WDQXT5GVMXELM2BCRQC MO5ORR7VSER3YUNO77DZJVKGOVYC2KNDCSC72J4NF7JYOHHTLRQAC J6OSBEBQXZR5JZ5TOCCUPELBPUVEQULGCXURXLPY7WFYTDEQOU2AC 7B74AT3BXYB7PVW4F6SGQNPMHOU5TEV5TZ54CG6VSQI46XSEKWXQC D425ND7AT3F7QJ3CCSESMVDOC3J5C5P32M5SJDBHECZJXLHNQ2FAC S7RXJJZG4IEIVLPHEWFT5M2T3SRRO5US5SYBPXSYSWJJLXAKNNPAC O5JVMDEEKP334BAYMJ6HHXROW4X4WC24JHCYZTKJRQE5UGYXV7YQC 24NXTKJNNOM6P3OPCN7OZE6LGGMFKRWFR6NUZ5JKETRABZA4YAGQC ZDQINUTDXQUS7OBW53UEYR6IN7DJLTPBOMRURGYQBGJ2FBROIQVAC 2QL2H4REDZT46FI3LQ4RYEMQYZBNBK3IC3KH3XERAJU3NCZWMNYQC ZS3JMIJKWXEQU566WUC2YPXRXWOYY2VKATUYZN7B3V435QBJGHWAC CD2JEM3MH5BXN7ADZAWLJFTRZG7PMDCKISDNJEO472PIBEJHBH2AC XKWY25ZVEJIJU7R23CEG5CTYRAWKZ5FXSHY3ZEZRGCIWYIKQSLOAC 6LVZRZGDURMWBUBXHFGV4HGB7L5M2FKCYGJCAU3X2PK74VJQ6RCAC QL6IFEPOHHUDBY2SGUZNNIRTDSZOSRJIHJKVU54LZSGTPTFPM2UAC IH7QAHDQUTGT7KS2IP7SLDHYDEDX4BCQ4KDRYKIGV5Y477X3ZABQC }}voidfocus(Client *c, struct wlr_surface *surface){if (c) {/* assert(VISIBLEON(c, c->mon)); ? *//* Default surface is the client's main xdg_surface */if (!surface)surface = c->xdg_surface->surface;/* Focus the correct monitor as well */selmon = c->mon;}/* XXX Need to understand xdg toplevel/popups to know if there's more* simplification that can be done in this function */struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface;/* Don't re-focus an already focused surface. */if (prev_surface == surface)return;if (prev_surface) {/** Deactivate the previously focused surface. This lets the* client know it no longer has focus and the client will* repaint accordingly, e.g. stop displaying a caret.*/struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface(seat->keyboard_state.focused_surface);wlr_xdg_toplevel_set_activated(previous, false);}if (!c) {wlr_seat_keyboard_clear_focus(seat);return;
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);/* Move the client to the front of the focus stack */wl_list_remove(&c->flink);wl_list_insert(&fstack, &c->flink);/* Activate the new surface */wlr_xdg_toplevel_set_activated(c->xdg_surface, true);/** Tell the seat to have the keyboard enter this surface.* wlroots will keep track of this and automatically send key* events to the appropriate clients without additional work on* your part.*/wlr_seat_keyboard_notify_enter(seat, c->xdg_surface->surface,keyboard->keycodes, keyboard->num_keycodes,&keyboard->modifiers);
}voidkeyboardfocus(Client *c, struct wlr_surface *surface){if (c) {/* assert(VISIBLEON(c, c->mon)); ? *//* If no surface provided, use the client's xdg_surface */if (!surface)surface = c->xdg_surface->surface;/* Focus the correct monitor as well */selmon = c->mon;}/* XXX Need to understand xdg toplevel/popups to know if there's more* simplification that can be done in this function */struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface;/* Don't re-focus an already focused surface. */if (prev_surface == surface)return;if (prev_surface) {/** Deactivate the previously focused surface. This lets the* client know it no longer has focus and the client will* repaint accordingly, e.g. stop displaying a caret.*/struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface(seat->keyboard_state.focused_surface);wlr_xdg_toplevel_set_activated(previous, false);}if (!c) {wlr_seat_keyboard_clear_focus(seat);return;}/* Move the client to the front of the focus stack */wl_list_remove(&c->flink);wl_list_insert(&fstack, &c->flink);/* Activate the new surface */wlr_xdg_toplevel_set_activated(c->xdg_surface, true);/** Tell the seat to have the keyboard enter this surface.* wlroots will keep track of this and automatically send key* events to the appropriate clients without additional work on* your part.*/struct wlr_keyboard *kb = wlr_seat_get_keyboard(seat);wlr_seat_keyboard_notify_enter(seat, c->xdg_surface->surface,kb->keycodes, kb->num_keycodes, &kb->modifiers);
if (!surface) {/* Clear pointer focus so future button events and such are not sent to* the last client to have the cursor over it. */wlr_seat_pointer_clear_focus(seat);/* If keyboard focus follows mouse, clear that too */if (sloppyfocus)focus(NULL, NULL);return;}
/** "Enter" the surface if necessary. This lets the client know that the* cursor has entered one of its surfaces.** Note that this gives the surface "pointer focus", which is distinct* from keyboard focus. You get pointer focus by moving the pointer over* a window.*/if (surface != seat->pointer_state.focused_surface) {wlr_seat_pointer_notify_enter(seat, surface, sx, sy);if (sloppyfocus)focus(c, surface);} else {/* The enter event contains coordinates, so we only need to notify* on motion if the focus did not change. */
/* If surface is already focused, only notify of motion, otherwise give* surface the pointer focus */if (surface && surface == seat->pointer_state.focused_surface)
pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy){/* If surface is NULL, clear pointer focus, otherwise let the client* know that the mouse cursor has entered one of its surfaces. */if (!surface)wlr_seat_pointer_clear_focus(seat);elsewlr_seat_pointer_notify_enter(seat, surface, sx, sy);/* If keyboard focus follows mouse, enforce that */if (sloppyfocus)keyboardfocus(c, surface);}void