Skip to content

Commit fb3590a

Browse files
authored
Fix title bar height on macOS Tahoe (#11241)
1 parent 4fd5eec commit fb3590a

File tree

10 files changed

+190
-28
lines changed

10 files changed

+190
-28
lines changed

Cargo.lock

Lines changed: 71 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ dependencies = [
358358
"clipboard-win",
359359
"image",
360360
"log",
361-
"objc2 0.6.1",
361+
"objc2 0.6.2",
362362
"objc2-app-kit 0.3.1",
363363
"objc2-core-foundation",
364364
"objc2-core-graphics",
@@ -1244,7 +1244,7 @@ version = "0.6.1"
12441244
source = "registry+https://github.com/rust-lang/crates.io-index"
12451245
checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2"
12461246
dependencies = [
1247-
"objc2 0.6.1",
1247+
"objc2 0.6.2",
12481248
]
12491249

12501250
[[package]]
@@ -2953,7 +2953,7 @@ dependencies = [
29532953
"bitflags 2.9.1",
29542954
"block2 0.6.1",
29552955
"libc",
2956-
"objc2 0.6.1",
2956+
"objc2 0.6.2",
29572957
]
29582958

29592959
[[package]]
@@ -2963,7 +2963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
29632963
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
29642964
dependencies = [
29652965
"bitflags 2.9.1",
2966-
"objc2 0.6.1",
2966+
"objc2 0.6.2",
29672967
]
29682968

29692969
[[package]]
@@ -3984,7 +3984,7 @@ dependencies = [
39843984
"glutin_glx_sys",
39853985
"glutin_wgl_sys",
39863986
"libloading 0.8.8",
3987-
"objc2 0.6.1",
3987+
"objc2 0.6.2",
39883988
"objc2-app-kit 0.3.1",
39893989
"objc2-core-foundation",
39903990
"objc2-foundation 0.3.1",
@@ -5812,9 +5812,9 @@ dependencies = [
58125812

58135813
[[package]]
58145814
name = "objc2"
5815-
version = "0.6.1"
5815+
version = "0.6.2"
58165816
source = "registry+https://github.com/rust-lang/crates.io-index"
5817-
checksum = "88c6597e14493ab2e44ce58f2fdecf095a51f12ca57bec060a11c57332520551"
5817+
checksum = "561f357ba7f3a2a61563a186a163d0a3a5247e1089524a3981d49adb775078bc"
58185818
dependencies = [
58195819
"objc2-encode",
58205820
]
@@ -5829,10 +5829,10 @@ dependencies = [
58295829
"block2 0.5.1",
58305830
"libc",
58315831
"objc2 0.5.2",
5832-
"objc2-core-data",
5833-
"objc2-core-image",
5832+
"objc2-core-data 0.2.2",
5833+
"objc2-core-image 0.2.2",
58345834
"objc2-foundation 0.2.2",
5835-
"objc2-quartz-core",
5835+
"objc2-quartz-core 0.2.2",
58365836
]
58375837

58385838
[[package]]
@@ -5843,10 +5843,15 @@ checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc"
58435843
dependencies = [
58445844
"bitflags 2.9.1",
58455845
"block2 0.6.1",
5846-
"objc2 0.6.1",
5846+
"libc",
5847+
"objc2 0.6.2",
5848+
"objc2-cloud-kit 0.3.1",
5849+
"objc2-core-data 0.3.1",
58475850
"objc2-core-foundation",
58485851
"objc2-core-graphics",
5852+
"objc2-core-image 0.3.1",
58495853
"objc2-foundation 0.3.1",
5854+
"objc2-quartz-core 0.3.1",
58505855
]
58515856

58525857
[[package]]
@@ -5862,6 +5867,17 @@ dependencies = [
58625867
"objc2-foundation 0.2.2",
58635868
]
58645869

5870+
[[package]]
5871+
name = "objc2-cloud-kit"
5872+
version = "0.3.1"
5873+
source = "registry+https://github.com/rust-lang/crates.io-index"
5874+
checksum = "17614fdcd9b411e6ff1117dfb1d0150f908ba83a7df81b1f118005fe0a8ea15d"
5875+
dependencies = [
5876+
"bitflags 2.9.1",
5877+
"objc2 0.6.2",
5878+
"objc2-foundation 0.3.1",
5879+
]
5880+
58655881
[[package]]
58665882
name = "objc2-contacts"
58675883
version = "0.2.2"
@@ -5885,6 +5901,17 @@ dependencies = [
58855901
"objc2-foundation 0.2.2",
58865902
]
58875903

5904+
[[package]]
5905+
name = "objc2-core-data"
5906+
version = "0.3.1"
5907+
source = "registry+https://github.com/rust-lang/crates.io-index"
5908+
checksum = "291fbbf7d29287518e8686417cf7239c74700fd4b607623140a7d4a3c834329d"
5909+
dependencies = [
5910+
"bitflags 2.9.1",
5911+
"objc2 0.6.2",
5912+
"objc2-foundation 0.3.1",
5913+
]
5914+
58885915
[[package]]
58895916
name = "objc2-core-foundation"
58905917
version = "0.3.1"
@@ -5893,7 +5920,7 @@ checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
58935920
dependencies = [
58945921
"bitflags 2.9.1",
58955922
"dispatch2 0.3.0",
5896-
"objc2 0.6.1",
5923+
"objc2 0.6.2",
58975924
]
58985925

58995926
[[package]]
@@ -5904,7 +5931,7 @@ checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4"
59045931
dependencies = [
59055932
"bitflags 2.9.1",
59065933
"dispatch2 0.3.0",
5907-
"objc2 0.6.1",
5934+
"objc2 0.6.2",
59085935
"objc2-core-foundation",
59095936
"objc2-io-surface",
59105937
]
@@ -5921,6 +5948,16 @@ dependencies = [
59215948
"objc2-metal",
59225949
]
59235950

5951+
[[package]]
5952+
name = "objc2-core-image"
5953+
version = "0.3.1"
5954+
source = "registry+https://github.com/rust-lang/crates.io-index"
5955+
checksum = "79b3dc0cc4386b6ccf21c157591b34a7f44c8e75b064f85502901ab2188c007e"
5956+
dependencies = [
5957+
"objc2 0.6.2",
5958+
"objc2-foundation 0.3.1",
5959+
]
5960+
59245961
[[package]]
59255962
name = "objc2-core-location"
59265963
version = "0.2.2"
@@ -5959,7 +5996,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
59595996
checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c"
59605997
dependencies = [
59615998
"bitflags 2.9.1",
5962-
"objc2 0.6.1",
5999+
"objc2 0.6.2",
59636000
"objc2-core-foundation",
59646001
]
59656002

@@ -5970,7 +6007,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
59706007
checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c"
59716008
dependencies = [
59726009
"bitflags 2.9.1",
5973-
"objc2 0.6.1",
6010+
"objc2 0.6.2",
59746011
"objc2-core-foundation",
59756012
]
59766013

@@ -6011,6 +6048,17 @@ dependencies = [
60116048
"objc2-metal",
60126049
]
60136050

6051+
[[package]]
6052+
name = "objc2-quartz-core"
6053+
version = "0.3.1"
6054+
source = "registry+https://github.com/rust-lang/crates.io-index"
6055+
checksum = "90ffb6a0cd5f182dc964334388560b12a57f7b74b3e2dec5e2722aa2dfb2ccd5"
6056+
dependencies = [
6057+
"bitflags 2.9.1",
6058+
"objc2 0.6.2",
6059+
"objc2-foundation 0.3.1",
6060+
]
6061+
60146062
[[package]]
60156063
name = "objc2-symbols"
60166064
version = "0.2.2"
@@ -6030,13 +6078,13 @@ dependencies = [
60306078
"bitflags 2.9.1",
60316079
"block2 0.5.1",
60326080
"objc2 0.5.2",
6033-
"objc2-cloud-kit",
6034-
"objc2-core-data",
6035-
"objc2-core-image",
6081+
"objc2-cloud-kit 0.2.2",
6082+
"objc2-core-data 0.2.2",
6083+
"objc2-core-image 0.2.2",
60366084
"objc2-core-location",
60376085
"objc2-foundation 0.2.2",
60386086
"objc2-link-presentation",
6039-
"objc2-quartz-core",
6087+
"objc2-quartz-core 0.2.2",
60406088
"objc2-symbols",
60416089
"objc2-uniform-type-identifiers",
60426090
"objc2-user-notifications",
@@ -8661,8 +8709,10 @@ dependencies = [
86618709
"jiff",
86628710
"notify",
86638711
"num-traits",
8712+
"objc2-app-kit 0.3.1",
86648713
"parking_lot",
86658714
"rand 0.8.5",
8715+
"raw-window-handle",
86668716
"re_analytics",
86678717
"re_build_tools",
86688718
"re_entity_db",
@@ -9564,7 +9614,7 @@ dependencies = [
95649614
"dispatch2 0.2.0",
95659615
"js-sys",
95669616
"log",
9567-
"objc2 0.6.1",
9617+
"objc2 0.6.2",
95689618
"objc2-app-kit 0.3.1",
95699619
"objc2-core-foundation",
95709620
"objc2-foundation 0.3.1",
@@ -11757,7 +11807,7 @@ dependencies = [
1175711807
"jni",
1175811808
"log",
1175911809
"ndk-context",
11760-
"objc2 0.6.1",
11810+
"objc2 0.6.2",
1176111811
"objc2-foundation 0.3.1",
1176211812
"url",
1176311813
"web-sys",

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ notify = { version = "6.1.1", features = ["macos_kqueue"] }
276276
num-derive = "0.4"
277277
num-traits = "0.2"
278278
numpy = "0.24"
279+
objc2-app-kit = "0.3"
279280
opentelemetry = { version = "0.30", features = ["metrics"] }
280281
opentelemetry-appender-tracing = "0.30"
281282
opentelemetry-otlp = "0.30"
@@ -305,6 +306,7 @@ pyo3-build-config = "0.24.1"
305306
quote = "1.0"
306307
rand = { version = "0.8", default-features = false, features = ["small_rng"] }
307308
rand_distr = { version = "0.4", default-features = false }
309+
raw-window-handle = "0.6"
308310
rayon = "1.7"
309311
regex-lite = "0.1.6"
310312
rexif = "0.7.5"
@@ -318,8 +320,8 @@ rust-format = "0.3"
318320
rustdoc-json = "0.9.4"
319321
rustdoc-types = "0.35.0"
320322
rustls = { version = "0.23", default-features = false }
321-
seq-macro = "0.3"
322323
semver = "1.0.26"
324+
seq-macro = "0.3"
323325
serde = { version = "1", features = ["derive"] }
324326
serde_bytes = "0.11"
325327
serde_json = { version = "1", default-features = false, features = ["std"] }

crates/viewer/re_ui/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ url.workspace = true
6464
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
6565
notify.workspace = true # Only used with the `hot_reload_design_tokens` feature
6666

67+
# Mac-specific
68+
[target.'cfg(target_os = "macos")'.dependencies]
69+
objc2-app-kit.workspace = true
70+
raw-window-handle.workspace = true
71+
72+
6773
[dev-dependencies]
6874
egui_kittest.workspace = true
6975
rand = { workspace = true, features = ["std"] }

crates/viewer/re_ui/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ Rerun GUI theme and helpers, built around [`egui`](https://www.egui.rs/).
1212
Defines the theme of the Rerun Viewer, and has helpers for constructing some UI elements.
1313

1414
Also contains our fonts and icons.
15+
16+
Run the example with `cargo r -p re_ui --example re_ui_example`

crates/viewer/re_ui/examples/re_ui_example/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Run the example with `cargo r -p re_ui --example re_ui_example`
2+
13
mod drag_and_drop;
24
mod hierarchical_drag_and_drop;
35
mod right_panel;
@@ -157,7 +159,7 @@ impl eframe::App for ExampleApp {
157159

158160
self.show_text_logs_as_notifications();
159161

160-
self.top_bar(egui_ctx);
162+
self.top_bar(_frame, egui_ctx);
161163

162164
egui::TopBottomPanel::bottom("bottom_panel")
163165
.frame(egui_ctx.tokens().bottom_panel_frame())
@@ -413,8 +415,8 @@ fn parse_url(url: &str) -> Option<CommandPaletteUrl> {
413415
}
414416

415417
impl ExampleApp {
416-
fn top_bar(&mut self, egui_ctx: &egui::Context) {
417-
let top_bar_style = egui_ctx.top_bar_style(false);
418+
fn top_bar(&mut self, frame: &eframe::Frame, egui_ctx: &egui::Context) {
419+
let top_bar_style = egui_ctx.top_bar_style(frame, false);
418420

419421
egui::TopBottomPanel::top("top_bar")
420422
.frame(egui_ctx.tokens().top_panel_frame())

crates/viewer/re_ui/src/context_ext.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub trait ContextExt {
8888
egui::RichText::new(text).color(style.visuals.error_fg_color)
8989
}
9090

91-
fn top_bar_style(&self, style_like_web: bool) -> TopBarStyle {
91+
fn top_bar_style(&self, _frame: &eframe::Frame, style_like_web: bool) -> TopBarStyle {
9292
let tokens = self.tokens();
9393
let egui_zoom_factor = self.ctx().zoom_factor();
9494
let fullscreen = self
@@ -103,7 +103,31 @@ pub trait ContextExt {
103103
&& crate::fullsize_content(self.ctx().os())
104104
&& !fullscreen;
105105

106-
let native_buttons_size_in_native_scale = egui::vec2(64.0, 24.0); // source: I measured /emilk
106+
let traffic_button_sizes_fallback = egui::vec2(64.0, 24.0); // source: I measured /emilk
107+
108+
#[cfg(target_os = "macos")]
109+
let native_buttons_size_in_native_scale = {
110+
use crate::egui_ext::WindowChromeMetrics;
111+
use raw_window_handle::HasWindowHandle as _;
112+
113+
let metrics = _frame
114+
.window_handle()
115+
.ok()
116+
.and_then(|handle| WindowChromeMetrics::from_window_handle(&handle.as_raw()));
117+
if let Some(metrics) = metrics {
118+
let WindowChromeMetrics {
119+
traffic_lights_size,
120+
} = metrics;
121+
traffic_lights_size
122+
} else {
123+
if cfg!(debug_assertions) {
124+
re_log::warn_once!("Failed to measure the size of the mac traffic light area");
125+
}
126+
traffic_button_sizes_fallback
127+
}
128+
};
129+
#[cfg(not(target_os = "macos"))]
130+
let native_buttons_size_in_native_scale = traffic_button_sizes_fallback;
107131

108132
let height = if make_room_for_window_buttons {
109133
// On mac we want to match the height of the native red/yellow/green close/minimize/maximize buttons.

0 commit comments

Comments
 (0)