linux: Prompt library fixes (#16850)

This PR fixes two issues:
1. The prompt library window didn't set an `app_id` on Linux, which
caused it to be missing the Zed logo
2. A dangling reference to the window in the Wayland client code, which
caused the prompt library window not to close. See:
https://github.com/zed-industries/zed/pull/13201

Release Notes:

- Linux: Fixed the prompt library not closing on Wayland

---------

Co-authored-by: Junkui Zhang <364772080@qq.com>
This commit is contained in:
apricotbucket28 2024-08-29 00:11:01 -03:00 committed by GitHub
parent 9ad845b40a
commit a68a543d43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 6 deletions

1
Cargo.lock generated
View file

@ -406,6 +406,7 @@ dependencies = [
"proto", "proto",
"rand 0.8.5", "rand 0.8.5",
"regex", "regex",
"release_channel",
"rope", "rope",
"schemars", "schemars",
"search", "search",

View file

@ -32,8 +32,8 @@ client.workspace = true
clock.workspace = true clock.workspace = true
collections.workspace = true collections.workspace = true
command_palette_hooks.workspace = true command_palette_hooks.workspace = true
db.workspace = true
context_servers.workspace = true context_servers.workspace = true
db.workspace = true
editor.workspace = true editor.workspace = true
feature_flags.workspace = true feature_flags.workspace = true
fs.workspace = true fs.workspace = true
@ -58,9 +58,11 @@ open_ai = { workspace = true, features = ["schemars"] }
ordered-float.workspace = true ordered-float.workspace = true
parking_lot.workspace = true parking_lot.workspace = true
paths.workspace = true paths.workspace = true
picker.workspace = true
project.workspace = true project.workspace = true
proto.workspace = true proto.workspace = true
regex.workspace = true regex.workspace = true
release_channel.workspace = true
rope.workspace = true rope.workspace = true
schemars.workspace = true schemars.workspace = true
search.workspace = true search.workspace = true
@ -68,8 +70,8 @@ semantic_index.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
settings.workspace = true settings.workspace = true
smallvec.workspace = true
similar.workspace = true similar.workspace = true
smallvec.workspace = true
smol.workspace = true smol.workspace = true
telemetry_events.workspace = true telemetry_events.workspace = true
terminal.workspace = true terminal.workspace = true
@ -81,7 +83,6 @@ ui.workspace = true
util.workspace = true util.workspace = true
uuid.workspace = true uuid.workspace = true
workspace.workspace = true workspace.workspace = true
picker.workspace = true
zed_actions.workspace = true zed_actions.workspace = true
[dev-dependencies] [dev-dependencies]

View file

@ -23,6 +23,7 @@ use language_model::{
}; };
use parking_lot::RwLock; use parking_lot::RwLock;
use picker::{Picker, PickerDelegate}; use picker::{Picker, PickerDelegate};
use release_channel::ReleaseChannel;
use rope::Rope; use rope::Rope;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use settings::Settings; use settings::Settings;
@ -94,14 +95,16 @@ pub fn open_prompt_library(
cx.spawn(|cx| async move { cx.spawn(|cx| async move {
let store = store.await?; let store = store.await?;
cx.update(|cx| { cx.update(|cx| {
let app_id = ReleaseChannel::global(cx).app_id();
let bounds = Bounds::centered(None, size(px(1024.0), px(768.0)), cx); let bounds = Bounds::centered(None, size(px(1024.0), px(768.0)), cx);
cx.open_window( cx.open_window(
WindowOptions { WindowOptions {
titlebar: Some(TitlebarOptions { titlebar: Some(TitlebarOptions {
title: Some("Prompt Library".into()), title: Some("Prompt Library".into()),
appears_transparent: !cfg!(windows), appears_transparent: cfg!(target_os = "macos"),
traffic_light_position: Some(point(px(9.0), px(9.0))), traffic_light_position: Some(point(px(9.0), px(9.0))),
}), }),
app_id: Some(app_id.to_owned()),
window_bounds: Some(WindowBounds::Windowed(bounds)), window_bounds: Some(WindowBounds::Windowed(bounds)),
..Default::default() ..Default::default()
}, },

View file

@ -815,7 +815,8 @@ pub struct TitlebarOptions {
/// The initial title of the window /// The initial title of the window
pub title: Option<SharedString>, pub title: Option<SharedString>,
/// Whether the titlebar should appear transparent (macOS only) /// Should the default system titlebar be hidden to allow for a custom-drawn titlebar? (macOS and Windows only)
/// Refer to [`WindowOptions::window_decorations`] on Linux
pub appears_transparent: bool, pub appears_transparent: bool,
/// The position of the macOS traffic light buttons /// The position of the macOS traffic light buttons

View file

@ -982,7 +982,8 @@ impl Dispatch<xdg_toplevel::XdgToplevel, ObjectId> for WaylandClientStatePtr {
let should_close = window.handle_toplevel_event(event); let should_close = window.handle_toplevel_event(event);
if should_close { if should_close {
this.drop_window(surface_id); // The close logic will be handled in drop_window()
window.close();
} }
} }
} }