gpui: Implement dynamic window control elements (#30828)

Allows setting element as window control elements which consist of
`Drag`, `Close`, `Max`, or `Min`. This allows you to implement
dynamically sized elements that control the platform window, this is
used for areas such as the title bar. Currently only implemented for
Windows.

Release Notes:

- N/A
This commit is contained in:
Matin Aniss
2025-06-06 10:11:24 -07:00
committed by GitHub
parent d9efa2860f
commit ca3f46588a
11 changed files with 129 additions and 96 deletions
@@ -31,8 +31,8 @@ use crate::{
AnyWindowHandle, Bounds, Decorations, Globals, GpuSpecs, Modifiers, Output, Pixels,
PlatformDisplay, PlatformInput, Point, PromptButton, PromptLevel, RequestFrameOptions,
ResizeEdge, ScaledPixels, Size, Tiling, WaylandClientStatePtr, WindowAppearance,
WindowBackgroundAppearance, WindowBounds, WindowControls, WindowDecorations, WindowParams, px,
size,
WindowBackgroundAppearance, WindowBounds, WindowControlArea, WindowControls, WindowDecorations,
WindowParams, px, size,
};
#[derive(Default)]
@@ -978,6 +978,10 @@ impl PlatformWindow for WaylandWindow {
self.0.callbacks.borrow_mut().close = Some(callback);
}
fn on_hit_test_window_control(&self, _callback: Box<dyn FnMut() -> Option<WindowControlArea>>) {
unimplemented!()
}
fn on_appearance_changed(&self, callback: Box<dyn FnMut()>) {
self.0.callbacks.borrow_mut().appearance_changed = Some(callback);
}
+6 -2
View File
@@ -5,8 +5,8 @@ use crate::{
AnyWindowHandle, Bounds, Decorations, DevicePixels, ForegroundExecutor, GpuSpecs, Modifiers,
Pixels, PlatformAtlas, PlatformDisplay, PlatformInput, PlatformInputHandler, PlatformWindow,
Point, PromptButton, PromptLevel, RequestFrameOptions, ResizeEdge, ScaledPixels, Scene, Size,
Tiling, WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowDecorations,
WindowKind, WindowParams, X11ClientStatePtr, px, size,
Tiling, WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowControlArea,
WindowDecorations, WindowKind, WindowParams, X11ClientStatePtr, px, size,
};
use blade_graphics as gpu;
@@ -1408,6 +1408,10 @@ impl PlatformWindow for X11Window {
self.0.callbacks.borrow_mut().close = Some(callback);
}
fn on_hit_test_window_control(&self, _callback: Box<dyn FnMut() -> Option<WindowControlArea>>) {
unimplemented!()
}
fn on_appearance_changed(&self, callback: Box<dyn FnMut()>) {
self.0.callbacks.borrow_mut().appearance_changed = Some(callback);
}