Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target/
.DS_Store
**/*.rs.bk
bk_gpui/
.pi-lens/
38 changes: 14 additions & 24 deletions crates/gpui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,18 @@ workspace = true
[features]
default = ["font-kit", "wayland", "x11", "windows-manifest"]
test-support = [
"leak-detection",
"collections/test-support",
"util/test-support",
"http_client/test-support",
"wayland",
"x11",
"leak-detection",
"collections/test-support",
"util/test-support",
"http_client/test-support",
"wayland",
"x11",
]
inspector = ["gpui_macros/inspector"]
leak-detection = ["backtrace"]
wayland = [
"bitflags",
]
x11 = [
"scap?/x11",
]
screen-capture = [
"scap",
]
wayland = ["bitflags"]
x11 = ["scap?/x11"]
screen-capture = ["scap"]
windows-manifest = []

[lib]
Expand Down Expand Up @@ -77,10 +71,10 @@ refineable.workspace = true
regex.workspace = true
scheduler.workspace = true
resvg = { version = "0.45.0", default-features = false, features = [
"text",
"system-fonts",
"memmap-fonts",
"raster-images",
"text",
"system-fonts",
"memmap-fonts",
"raster-images",
] }
usvg = { version = "0.45.0", default-features = false }
ttf-parser = "0.25"
Expand Down Expand Up @@ -132,7 +126,6 @@ pathfinder_geometry = "0.5"
scap = { workspace = true, optional = true }



[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.61", features = ["Win32_Foundation"] }

Expand All @@ -141,7 +134,7 @@ windows = { version = "0.61", features = ["Win32_Foundation"] }
backtrace.workspace = true
collections = { workspace = true, features = ["test-support"] }
env_logger.workspace = true
gpui_platform.workspace = true
gpui_platform = { workspace = true, features = ["font-kit", "wayland", "x11"] }
http_client = { workspace = true, features = ["test-support"] }
lyon = { version = "1.0", features = ["extra"] }
pretty_assertions.workspace = true
Expand All @@ -160,7 +153,6 @@ wasm-bindgen = { workspace = true }
gpui_web.workspace = true



[target.'cfg(target_os = "windows")'.build-dependencies]
embed-resource = "3.0"

Expand All @@ -170,8 +162,6 @@ cbindgen = { version = "0.28.0", default-features = false }
naga.workspace = true




[[example]]
name = "hello_world"
path = "examples/hello_world.rs"
Expand Down
39 changes: 39 additions & 0 deletions crates/gpui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ pub enum QuitMode {
Explicit,
}

/// Controls when GPUI hides the mouse cursor in response to keyboard input.
///
/// Restoration on mouse motion is handled by the platform layer; this enum
/// only describes the policy for *triggering* a hide.
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub enum CursorHideMode {
/// Never hide the cursor automatically.
Never,
/// Hide on character-producing key presses (typing).
OnTyping,
/// Hide on character-producing key presses, *and* when a key binding
/// resolves to an action that consumes the keystroke.
#[default]
OnTypingAndAction,
}

#[doc(hidden)]
#[derive(Clone, PartialEq, Eq)]
pub struct SystemWindowTab {
Expand Down Expand Up @@ -639,6 +655,7 @@ pub struct App {

pub(crate) window_update_stack: Vec<WindowId>,
pub(crate) mode: GpuiMode,
pub(crate) cursor_hide_mode: CursorHideMode,
flushing_effects: bool,
pending_updates: usize,
quit_mode: QuitMode,
Expand Down Expand Up @@ -727,6 +744,7 @@ impl App {
inspector_element_registry: InspectorElementRegistry::default(),
quit_mode: QuitMode::default(),
quitting: false,
cursor_hide_mode: CursorHideMode::default(),

#[cfg(any(test, feature = "test-support", debug_assertions))]
name: None,
Expand Down Expand Up @@ -836,6 +854,27 @@ impl App {
self.platform.quit();
}

/// Returns the current policy for hiding the cursor in response to
/// keyboard input.
pub fn cursor_hide_mode(&self) -> CursorHideMode {
self.cursor_hide_mode
}

/// Sets the policy controlling when GPUI hides the cursor in response
/// to keyboard input.
pub fn set_cursor_hide_mode(&mut self, mode: CursorHideMode) {
self.cursor_hide_mode = mode;
}

/// Returns whether the cursor is currently visible according to the
/// platform. This will report `false` after a keyboard input has hidden
/// the cursor and the user has not yet moved the mouse to restore it.
///
/// See [`App::set_cursor_hide_mode`].
pub fn is_cursor_visible(&self) -> bool {
self.platform.is_cursor_visible()
}

/// Schedules all windows in the application to be redrawn. This can be called
/// multiple times in an update cycle and still result in a single redraw.
pub fn refresh_windows(&mut self) {
Expand Down
Loading
Loading