XISETFOCUS(3)

πŸ’– XISETFOCUS πŸ’–

okay bestie, so you know how the X server has a focus, like who's getting the keyboard events? yeah. this is the Input extension's version of that, but for individual devices. it's giving "every mouse and tablet gets its own main character window" ✨

this page covers two functions: XISetFocus and XIGetFocus, from the XISETFOCUS(3) manual, section 3 of the X Input extension docs πŸŽ€


🌸 NAME 🌸

XISetFocus, XIGetFocus β€” set or get the device's focus. that's it, that's the whole vibe πŸ’…


✨ SYNOPSIS ✨

#include <X11/extensions/XInput2.h>

Status XISetFocus( Display *display,
                   int deviceid,
                   Window focus,
                   Time time);

Status XIGetFocus( Display *display,
                   Window *focus_return);

🫢 the arguments, explained with love

  • display β€” the connection to the X server. your lil line to the server, your group chat with the X server basically πŸ“ž
  • deviceid β€” which device's focus we're querying or changing. like tagging the right person in the message so the right device gets the info πŸ‘‘
  • focus β€” the new focus window. the window that's about to be That Girl πŸ’…
  • focus_return β€” returns the current focus window. the server hands it back to you, no cap 🎁
  • time β€” a valid timestamp, or CurrentTime. literally what it says on the tin ⏰

πŸ’œ DESCRIPTION πŸ’œ

okay so XISetFocus changes the focus of the specified device and its last-focus-change time. obsessed. but β€” and this is important β€” it has no effect if the specified time is earlier than the current last-focus-change time, or is later than the current X server time. otherwise, the last-focus-change time gets set to the specified time. and CurrentTime gets replaced by the current X server time (yes there's a stray ) in the original, we don't talk about it πŸ™ˆ). XISetFocus causes the X server to generate core, XI and XI2 focus events. so many events. iconic πŸ”₯

now, if the focus window is None, all keyboard events by this device are discarded until a new focus window is set. like, muted. on do not disturb. πŸ’€ otherwise, if focus is a window, it becomes the device's focus window. and if a generated device event would normally be reported to this window or one of its inferiors, the event is reported as usual. otherwise, the event is reported relative to the focus window. ✨

⚠️ the specified focus window must be viewable at the time XISetFocus is called, or a BadMatch error results. so don't come for it with a hidden window, bestie, it will not go well 😭

if the focus window later becomes not viewable, the focus reverts to the parent (or the closest viewable ancestor). when the focus reverts, the X server generates core, XI and XI2 focus events, but the last-focus-change time is not affected. okay so the events fire but the timestamp stays put. noted πŸ“

πŸ’€ attempting to set the focus on a master pointer device or an attached slave device will result in a BadDevice error. do not do this. the server said no and it meant it.

XISetFocus can generate BadDevice, BadMatch, BadValue, and BadWindow errors. four whole error girls. she's versatile 🌈


πŸ¦‹ DIAGNOSTICS πŸ¦‹

  • BadValue β€” a value is outside of the permitted range. out of pocket, literally 🚫
  • BadDevice β€” an invalid device was specified. the device does not exist, or is not appropriate for the type of change. wrong device, wrong vibe, no notes πŸ’€
  • BadMatch β€” the window is not viewable. she's not showing up, so she's not getting focus πŸ™ˆ
  • BadWindow β€” a value for a Window argument does not name a defined Window. that window? doesn't exist. ghosted fr fr πŸ‘»

🌟 SEE ALSO 🌟

nothing listed here bestie, this page stands on its own πŸ’…βœ¨


and that's the whole thing!! go forth and set some focus, you've got this 🫢✨

this was from the XISETFOCUS(3) manual page, dated 05/18/2026 β€” stay slay, stay viewable, and always check your timestamps πŸ’–

πŸ“¦ where this page comes from