Expand description
Whether the pointer gives the keyboard: as the window manager does
between windows (system), or as the user chose (click, hover).
Experimental: may change in any release
(docs/stability.md).
In click mode the keyboard goes where the user clicks (or tabs).
In hover mode, moving the pointer over a surface (a focus scope:
a panel, an editor) gives it the keys, and a text field the pointer
moves over takes the keyboard (see follow_pointer); never while a
button is held, a drag is in progress or an overlay (a popup, a menu,
a dialog) is open.
The window manager’s way is read once, at start
(read_system):
- GNOME:
gsettings get org.gnome.desktop.wm.preferences focus-mode(click, orsloppyandmousefor hover); - KDE:
kreadconfig6(or5)--file kwinrc --group Windows --key FocusPolicy(ClickToFocus, orFocusFollowsMouse,FocusUnderMouse,FocusStrictlyUnderMousefor hover); - Windows: nothing read here, click. Spawning
reg queryflashed a console window at every start, and this crate has no registry access (no unsafe code, no Windows dependency). The registry is read in-process byegui_pop_platform::focus(the active window tracking bit ofUserPreferencesMask, asSPI_GETACTIVEWINDOWTRACKINGreports it, mapped bywindows_mask): give itsread()toAppBuilder::system_focus, or install itsFocusModePlugin; - macOS and anything else: click.
The environment variable ENV (click or hover) stands in for
the system, for tests and for users whose desktop is not read.
use egui_pop_core::focus_mode::{self, FocusMode, Preference, SystemFocus};
let ctx = egui::Context::default();
let modes = focus_mode::get(&ctx);
modes.set_system(SystemFocus { mode: FocusMode::Hover, from: Some("test") });
assert_eq!(modes.mode(), FocusMode::Hover);
modes.set_preference(Preference::Click);
assert_eq!(modes.mode(), FocusMode::Click);Structs§
- Focus
Modes - The focus mode of an application: the system’s way and the user’s
choice. Cheap to clone (shared); the application provides it as a
service, and a context uses one (
get,set). - Report
- What the debug bridge shows.
- System
Focus - The window manager’s way, as read, and where it was read.
Enums§
- Focus
Mode - Whether the pointer gives the keyboard.
- Preference
- What the user chose.
Constants§
- ENV
- The environment variable standing in for the system:
clickorhover(GNOME’ssloppyandmouseare read as hover).
Functions§
- follow_
pointer - In hover mode, gives the keyboard to a widget (a text field) when the pointer moves over it. Call it with the widget’s response.
- get
- The context’s focus modes (created on first use: the system not read, click).
- gnome
- GNOME’s
focus-modeasgsettingsprints it:'click','sloppy','mouse'. - kde
- KDE’s
FocusPolicy(kwinrc, group Windows); none written is a click. - mode
- The mode in force in a context.
- pointer_
may_ focus - Whether the pointer may move the keyboard focus in this pass: hover mode, the pointer moved, no button held, no drag, no overlay open.
- read_
system - The window manager’s way, read now (a short subprocess on Linux;
click on Windows, macOS and the web:
egui_pop_platform::focus::readreads Windows’ registry in-process). - read_
system_ with - The window manager’s way from what a reader would see: the
environment variable
ENV, the desktop (XDG_CURRENT_DESKTOP), andrun(a program and its arguments, its output when it succeeds). - set
- Makes a context use these focus modes.
- windows
- Windows’
UserPreferencesMaskasreg queryprints it (seewindows_mask). Nothing here runsregany more; kept for readers of a savedreg queryoutput. - windows_
mask - Windows’
UserPreferencesMaskfrom its first byte: the lowest bit is active window tracking (hover), whatSPI_GETACTIVEWINDOWTRACKINGreports.