windows: better looking titlebar (#9053)
~~work in progress. not ready for review. made for visibility only, but feel free to comment :)~~ TODO: - [x] add close/min/max buttons (to be rendered with gpui) - [x] snap layout support - [x] fix issues with clicking items in titlebar - [x] cleanup/document Release Notes: - Added custom windows titlebar  --------- Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
co-authored by
Mikayla
parent
6bbc5e2efa
commit
948b3827c8
@@ -324,7 +324,7 @@ struct MacWindowState {
|
||||
renderer: renderer::Renderer,
|
||||
kind: WindowKind,
|
||||
request_frame_callback: Option<Box<dyn FnMut()>>,
|
||||
event_callback: Option<Box<dyn FnMut(PlatformInput) -> bool>>,
|
||||
event_callback: Option<Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>>,
|
||||
activate_callback: Option<Box<dyn FnMut(bool)>>,
|
||||
resize_callback: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
|
||||
fullscreen_callback: Option<Box<dyn FnMut(bool)>>,
|
||||
@@ -411,6 +411,14 @@ impl MacWindowState {
|
||||
self.display_link = None;
|
||||
}
|
||||
|
||||
fn is_maximized(&self) -> bool {
|
||||
unsafe {
|
||||
let bounds = self.bounds();
|
||||
let screen_size = self.native_window.screen().visibleFrame().into();
|
||||
bounds.size == screen_size
|
||||
}
|
||||
}
|
||||
|
||||
fn is_fullscreen(&self) -> bool {
|
||||
unsafe {
|
||||
let style_mask = self.native_window.styleMask();
|
||||
@@ -716,6 +724,11 @@ impl PlatformWindow for MacWindow {
|
||||
self.0.as_ref().lock().bounds()
|
||||
}
|
||||
|
||||
// todo(mac)
|
||||
fn is_maximized(&self) -> bool {
|
||||
self.0.as_ref().lock().is_maximized()
|
||||
}
|
||||
|
||||
fn content_size(&self) -> Size<Pixels> {
|
||||
self.0.as_ref().lock().content_size()
|
||||
}
|
||||
@@ -968,7 +981,7 @@ impl PlatformWindow for MacWindow {
|
||||
self.0.as_ref().lock().request_frame_callback = Some(callback);
|
||||
}
|
||||
|
||||
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
|
||||
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>) {
|
||||
self.0.as_ref().lock().event_callback = Some(callback);
|
||||
}
|
||||
|
||||
@@ -1191,7 +1204,7 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent:
|
||||
window_state.lock().previous_keydown_inserted_text = Some(text.clone());
|
||||
if let Some(callback) = callback.as_mut() {
|
||||
event.keystroke.ime_key = Some(text.clone());
|
||||
handled = callback(PlatformInput::KeyDown(event));
|
||||
handled = !callback(PlatformInput::KeyDown(event)).propagate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1204,7 +1217,7 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent:
|
||||
let is_held = event.is_held;
|
||||
|
||||
if let Some(callback) = callback.as_mut() {
|
||||
handled = callback(PlatformInput::KeyDown(event));
|
||||
handled = !callback(PlatformInput::KeyDown(event)).propagate;
|
||||
}
|
||||
|
||||
if !handled && is_held {
|
||||
|
||||
Reference in New Issue
Block a user