gpui: Move 'app closing on last window closed' behavior to app-side (#41436)
This commit is a continuation of #36548. As per [mikayla-maki's Comment](https://github.com/zed-industries/zed/pull/36548#issuecomment-3412140698), I removed the process management behavior located in GPUI and reimplemented it in Zed. Release Notes: - N/A --------- Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
@@ -387,9 +387,6 @@ impl WaylandClientStatePtr {
|
||||
{
|
||||
state.keyboard_focused_window = Some(window);
|
||||
}
|
||||
if state.windows.is_empty() {
|
||||
state.common.signal.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -246,10 +246,6 @@ impl X11ClientStatePtr {
|
||||
state.keyboard_focused_window = None;
|
||||
}
|
||||
state.cursor_styles.remove(&x_window);
|
||||
|
||||
if state.windows.is_empty() {
|
||||
state.common.signal.stop();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_ime_position(&self, bounds: Bounds<Pixels>) {
|
||||
|
||||
@@ -753,9 +753,7 @@ impl WindowsPlatformInner {
|
||||
}
|
||||
match message {
|
||||
WM_GPUI_CLOSE_ONE_WINDOW => {
|
||||
if self.close_one_window(HWND(lparam.0 as _)) {
|
||||
unsafe { PostQuitMessage(0) };
|
||||
}
|
||||
self.close_one_window(HWND(lparam.0 as _));
|
||||
Some(0)
|
||||
}
|
||||
WM_GPUI_TASK_DISPATCHED_ON_MAIN_THREAD => self.run_foreground_task(),
|
||||
|
||||
+20
-9
@@ -274,16 +274,27 @@ pub fn init(cx: &mut App) {
|
||||
}
|
||||
|
||||
fn bind_on_window_closed(cx: &mut App) -> Option<gpui::Subscription> {
|
||||
WorkspaceSettings::get_global(cx)
|
||||
.on_last_window_closed
|
||||
.is_quit_app()
|
||||
.then(|| {
|
||||
cx.on_window_closed(|cx| {
|
||||
if cx.windows().is_empty() {
|
||||
cx.quit();
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
WorkspaceSettings::get_global(cx)
|
||||
.on_last_window_closed
|
||||
.is_quit_app()
|
||||
.then(|| {
|
||||
cx.on_window_closed(|cx| {
|
||||
if cx.windows().is_empty() {
|
||||
cx.quit();
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
Some(cx.on_window_closed(|cx| {
|
||||
if cx.windows().is_empty() {
|
||||
cx.quit();
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_window_options(display_uuid: Option<Uuid>, cx: &mut App) -> WindowOptions {
|
||||
|
||||
Reference in New Issue
Block a user