Integrate macOS window controls and fix palette text rendering

Center native window controls in the draggable tab bar. Preserve full text runs during GPUI layout and let AppKit compose text in palette and rename fields.
This commit is contained in:
James Magahern
2026-11-17 14:48:30 -08:00
parent 20ca5447ef
commit 12ba7abdd2
10 changed files with 112 additions and 28 deletions
+19 -6
View File
@@ -1,8 +1,9 @@
# GPUI 0.2.2 Wayland idle redraw patch
# Local GPUI 0.2.2 patches
This directory vendors the published `gpui` 0.2.2 crate unchanged except for
`src/window.rs`, `src/app.rs`, and this note. Upstream source and Apache-2.0
license are retained; see `LICENSE-APACHE` and `.cargo_vcs_info.json`.
This directory vendors the published `gpui` 0.2.2 crate with the patches below.
The upstream license and revision are in `LICENSE-APACHE` and `.cargo_vcs_info.json`.
## Wayland idle redraw
Wayland compositors can withhold a pending frame callback after GPUI skips
presenting a clean frame. Later asynchronous view notifications make the scene
@@ -14,9 +15,21 @@ of an app effect cycle, an invalidated idle window draws and presents once,
clearing the idle flag. Normal compositor callbacks then resume. Dirty active
windows remain callback-paced; clean idle windows submit no frames. The flag
starts false, avoiding presentation before the initial Wayland configure.
Other platform backends are unchanged. No foreign Wayland connection or raw
surface manipulation is used.
The optional `scripts/check-wayland-idle.py` exercises an actual headless Weston
window and verifies output repaints after an idle interval without pointer
input or screenshots waking the compositor.
## macOS titlebar dragging
The macOS implementation of `start_window_move` passes the current mouse
event to AppKit's `performWindowDragWithEvent:`. This lets applications
initiate native dragging from a custom titlebar. The implementation follows
[upstream GPUI](https://github.com/zed-industries/zed/blob/main/crates/gpui_macos/src/window.rs).
## Text truncation during layout
Flex layout can measure a label at a narrow width before allocating its final
width. Each truncation now starts from the original styled text runs, and the
measurement cache includes the width used for truncation. This preserves the
full command titles in the palette when there is room to display them.
+17 -9
View File
@@ -316,6 +316,7 @@ struct TextLayoutInner {
lines: SmallVec<[WrappedLine; 1]>,
line_height: Pixels,
wrap_width: Option<Pixels>,
truncate_width: Option<Pixels>,
size: Option<Size<Pixels>>,
bounds: Option<Bounds<Pixels>>,
}
@@ -334,7 +335,7 @@ impl TextLayout {
.line_height
.to_pixels(font_size.into(), window.rem_size());
let mut runs = if let Some(runs) = runs {
let runs = if let Some(runs) = runs {
runs
} else {
vec![text_style.to_run(text.len())]
@@ -372,19 +373,24 @@ impl TextLayout {
if let Some(text_layout) = element_state.0.borrow().as_ref()
&& text_layout.size.is_some()
&& (wrap_width.is_none() || wrap_width == text_layout.wrap_width)
&& wrap_width == text_layout.wrap_width
&& truncate_width == text_layout.truncate_width
{
return text_layout.size.unwrap();
}
let mut line_wrapper = cx.text_system().line_wrapper(text_style.font(), font_size);
// Flex layout may measure the same element at several widths. Each
// measurement needs the original runs, including their full lengths.
let mut runs = std::borrow::Cow::Borrowed(&runs);
let text = if let Some(truncate_width) = truncate_width {
line_wrapper.truncate_line(
text.clone(),
truncate_width,
&truncation_suffix,
&mut runs,
)
cx.text_system()
.line_wrapper(text_style.font(), font_size)
.truncate_line(
text.clone(),
truncate_width,
&truncation_suffix,
runs.to_mut(),
)
} else {
text.clone()
};
@@ -406,6 +412,7 @@ impl TextLayout {
len: 0,
line_height,
wrap_width,
truncate_width,
size: Some(Size::default()),
bounds: None,
});
@@ -424,6 +431,7 @@ impl TextLayout {
len,
line_height,
wrap_width,
truncate_width,
size: Some(size),
bounds: None,
});
+11
View File
@@ -1498,6 +1498,17 @@ impl PlatformWindow for MacWindow {
.detach()
}
fn start_window_move(&self) {
let window = self.0.lock().native_window;
unsafe {
let app = NSApplication::sharedApplication(nil);
let event: id = msg_send![app, currentEvent];
if !event.is_null() {
let _: () = msg_send![window, performWindowDragWithEvent: event];
}
}
}
fn titlebar_double_click(&self) {
let this = self.0.lock();
let window = this.native_window;