Skip to content

Commit 8b159db

Browse files
committed
Add setting for enabling SSD
Previously, this was controllable via the undocumented ZED_WINDOW_DECORATIONS environment variable (added in zed-industries#13866). Using an environment variable for this is inconvenient because it requires users to set that environment variable somehow before starting Zed, such as the .desktop file or persistently in their shell. Controlling this via a Zed setting is more convenient. Fixes zed-industries#14165
1 parent a53faff commit 8b159db

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

assets/settings/default.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@
172172
//
173173
// Default: true
174174
"zoomed_padding": true,
175+
// What draws Zed's window decorations (titlebar):
176+
// 1. Client application (Zed) draws its own window decorations
177+
// "client"
178+
// 2. Display server draws the window decorations. Not supported by GNOME Wayland.
179+
// "server"
180+
//
181+
// This requires restarting Zed for changes to take effect.
182+
//
183+
// Default: "client"
184+
"window_decorations": "client",
175185
// Whether to use the system provided dialogs for Open and Save As.
176186
// When set to false, Zed will use the built-in keyboard-first pickers.
177187
"use_system_path_prompts": true,

crates/rules_library/src/rules_library.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use ui::{
2525
Divider, KeyBinding, ListItem, ListItemSpacing, ListSubHeader, Render, Tooltip, prelude::*,
2626
};
2727
use util::{ResultExt, TryFutureExt};
28-
use workspace::{Workspace, client_side_decorations};
28+
use workspace::{Workspace, WorkspaceSettings, client_side_decorations};
2929
use zed_actions::assistant::InlineAssist;
3030

3131
use prompt_store::*;
@@ -119,10 +119,9 @@ pub fn open_rules_library(
119119
cx.update(|cx| {
120120
let app_id = ReleaseChannel::global(cx).app_id();
121121
let bounds = Bounds::centered(None, size(px(1024.0), px(768.0)), cx);
122-
let window_decorations = match std::env::var("ZED_WINDOW_DECORATIONS") {
123-
Ok(val) if val == "server" => gpui::WindowDecorations::Server,
124-
Ok(val) if val == "client" => gpui::WindowDecorations::Client,
125-
_ => gpui::WindowDecorations::Client,
122+
let window_decorations = match WorkspaceSettings::get_global(cx).window_decorations {
123+
settings::WindowDecorations::Server => gpui::WindowDecorations::Server,
124+
settings::WindowDecorations::Client => gpui::WindowDecorations::Client,
126125
};
127126
cx.open_window(
128127
WindowOptions {

crates/settings/src/settings_content/workspace.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ pub struct WorkspaceSettingsContent {
106106
///
107107
/// Default: true
108108
pub zoomed_padding: Option<bool>,
109+
/// What draws window decorations/titlebar, the client application (Zed) or display server
110+
/// Default: client
111+
pub window_decorations: Option<WindowDecorations>,
109112
}
110113

111114
#[skip_serializing_none]
@@ -226,6 +229,16 @@ pub enum BottomDockLayout {
226229
RightAligned,
227230
}
228231

232+
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema, MergeFrom)]
233+
#[serde(rename_all = "snake_case")]
234+
pub enum WindowDecorations {
235+
/// Zed draws its own window decorations/titlebar (client-side decoration)
236+
#[default]
237+
Client,
238+
/// Show system's window titlebar (server-side decoration; not supported by GNOME Wayland)
239+
Server,
240+
}
241+
229242
#[derive(Copy, Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug)]
230243
#[serde(rename_all = "snake_case")]
231244
pub enum CloseWindowWhenNoItems {

crates/workspace/src/workspace_settings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct WorkspaceSettings {
3333
pub close_on_file_delete: bool,
3434
pub use_system_window_tabs: bool,
3535
pub zoomed_padding: bool,
36+
pub window_decorations: settings::WindowDecorations,
3637
}
3738

3839
#[derive(Copy, Clone, PartialEq, Debug, Default)]
@@ -107,6 +108,7 @@ impl Settings for WorkspaceSettings {
107108
close_on_file_delete: workspace.close_on_file_delete.unwrap(),
108109
use_system_window_tabs: workspace.use_system_window_tabs.unwrap(),
109110
zoomed_padding: workspace.zoomed_padding.unwrap(),
111+
window_decorations: workspace.window_decorations.unwrap(),
110112
}
111113
}
112114

crates/zed/src/zed.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,9 @@ pub fn build_window_options(display_uuid: Option<Uuid>, cx: &mut App) -> WindowO
282282
.find(|display| display.uuid().ok() == Some(uuid))
283283
});
284284
let app_id = ReleaseChannel::global(cx).app_id();
285-
let window_decorations = match std::env::var("ZED_WINDOW_DECORATIONS") {
286-
Ok(val) if val == "server" => gpui::WindowDecorations::Server,
287-
Ok(val) if val == "client" => gpui::WindowDecorations::Client,
288-
_ => gpui::WindowDecorations::Client,
285+
let window_decorations = match WorkspaceSettings::get_global(cx).window_decorations {
286+
settings::WindowDecorations::Server => gpui::WindowDecorations::Server,
287+
settings::WindowDecorations::Client => gpui::WindowDecorations::Client,
289288
};
290289

291290
let use_system_window_tabs = WorkspaceSettings::get_global(cx).use_system_window_tabs;

0 commit comments

Comments
 (0)