Fix error prompt darkened background exceeding window boundaries on Linux (#57608)
Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior (visual difference only) - [x] Performance impact has been considered and is acceptable I was unable to find a specific issue or PR that mentions this. As Linux installations always use built-in prompts and ignore the `Use System Prompts` setting (as far as I'm aware) all users using Zed (with client-side decorations) are affected. The darkened prompt backdrop was drawn across the full window boundary, including the transparent decoration/shadow inset, causing it to overlap. This PR fixes the backdrop to respect the client-side decoration inset and only applies rounded corners on non-tiled edges. Tiled edges remain flush, matching the rest of the client-side window decoration behavior. I've verified it works on Wayland, X11 and causes no regressions on macOS or Windows (with `Use System Prompts` off). Notice the screenshots below on a white background showing the before and after, where the faint overlap is shown broken and fixed (sorry if you have to squint). Before:  After:  Release Notes: - Fixed prompt darkened backdrop/background rendering outside client-decorated window boundaries on Linux. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
1 parent
fbe923c57b
commit
17764ce0a3
5 files changed
+61
-75
No files matched your search
Generated
+1
@@ -19505,6 +19505,7 @@ dependencies = [
|
||||
"markdown",
|
||||
"menu",
|
||||
"settings",
|
||||
"theme",
|
||||
"theme_settings",
|
||||
"ui",
|
||||
"workspace",
|
||||
|
||||
@@ -25,7 +25,8 @@ use std::sync::Arc;
|
||||
use gpui::BorrowAppContext;
|
||||
use gpui::Global;
|
||||
use gpui::{
|
||||
App, AssetSource, Hsla, Pixels, SharedString, WindowAppearance, WindowBackgroundAppearance, px,
|
||||
App, AssetSource, Hsla, Pixels, SharedString, Styled, Tiling, WindowAppearance,
|
||||
WindowBackgroundAppearance, px,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -49,6 +50,28 @@ pub const CLIENT_SIDE_DECORATION_ROUNDING: Pixels = px(10.0);
|
||||
/// Defines window shadow size for platforms that use client side decorations.
|
||||
pub const CLIENT_SIDE_DECORATION_SHADOW: Pixels = px(10.0);
|
||||
|
||||
/// Styling helpers for elements that follow client-side window decorations.
|
||||
pub trait ClientDecorationsExt: Styled {
|
||||
/// Rounds each corner whose two adjacent edges are both untiled.
|
||||
fn rounded_client_corners(mut self, tiling: Tiling) -> Self {
|
||||
if !tiling.top && !tiling.left {
|
||||
self = self.rounded_tl(CLIENT_SIDE_DECORATION_ROUNDING);
|
||||
}
|
||||
if !tiling.top && !tiling.right {
|
||||
self = self.rounded_tr(CLIENT_SIDE_DECORATION_ROUNDING);
|
||||
}
|
||||
if !tiling.bottom && !tiling.left {
|
||||
self = self.rounded_bl(CLIENT_SIDE_DECORATION_ROUNDING);
|
||||
}
|
||||
if !tiling.bottom && !tiling.right {
|
||||
self = self.rounded_br(CLIENT_SIDE_DECORATION_ROUNDING);
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Styled> ClientDecorationsExt for T {}
|
||||
|
||||
/// The appearance of the theme.
|
||||
#[derive(Debug, PartialEq, Clone, Copy, Deserialize)]
|
||||
pub enum Appearance {
|
||||
|
||||
@@ -19,6 +19,7 @@ gpui.workspace = true
|
||||
markdown.workspace = true
|
||||
menu.workspace = true
|
||||
settings.workspace = true
|
||||
theme.workspace = true
|
||||
theme_settings.workspace = true
|
||||
ui.workspace = true
|
||||
workspace.workspace = true
|
||||
@@ -1,10 +1,11 @@
|
||||
use gpui::{
|
||||
App, Entity, EventEmitter, FocusHandle, Focusable, PromptButton, PromptHandle, PromptLevel,
|
||||
PromptResponse, RenderablePromptHandle, SharedString, TextStyleRefinement, Window, div,
|
||||
prelude::*,
|
||||
App, Decorations, Entity, EventEmitter, FocusHandle, Focusable, PromptButton, PromptHandle,
|
||||
PromptLevel, PromptResponse, RenderablePromptHandle, SharedString, TextStyleRefinement, Window,
|
||||
div, prelude::*,
|
||||
};
|
||||
use markdown::{Markdown, MarkdownElement, MarkdownStyle};
|
||||
use settings::{Settings, SettingsStore};
|
||||
use theme::ClientDecorationsExt;
|
||||
use theme_settings::ThemeSettings;
|
||||
use ui::{FluentBuilder, TintColor, prelude::*};
|
||||
use workspace::WorkspaceSettings;
|
||||
@@ -154,20 +155,28 @@ impl Render for ZedPromptRenderer {
|
||||
})),
|
||||
);
|
||||
|
||||
div()
|
||||
.size_full()
|
||||
.occlude()
|
||||
.bg(gpui::black().opacity(0.2))
|
||||
.child(
|
||||
v_flex()
|
||||
.size_full()
|
||||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.child(dialog),
|
||||
)
|
||||
let decorations = window.window_decorations();
|
||||
let inset = window.client_inset().unwrap_or(Pixels::ZERO);
|
||||
|
||||
div().size_full().child(
|
||||
v_flex()
|
||||
.occlude()
|
||||
.absolute()
|
||||
.inset_0()
|
||||
.bg(gpui::black().opacity(0.2))
|
||||
.map(|this| match decorations {
|
||||
Decorations::Server => this,
|
||||
Decorations::Client { tiling } => this
|
||||
.when(!tiling.top, |this| this.top(inset))
|
||||
.when(!tiling.bottom, |this| this.bottom(inset))
|
||||
.when(!tiling.left, |this| this.left(inset))
|
||||
.when(!tiling.right, |this| this.right(inset))
|
||||
.rounded_client_corners(tiling),
|
||||
})
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.child(dialog),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
use task::{DebugScenario, SharedTaskContext, SpawnInTerminal};
|
||||
use theme::{ActiveTheme, SystemAppearance};
|
||||
use theme::{ActiveTheme, ClientDecorationsExt, SystemAppearance};
|
||||
use theme_settings::ThemeSettings;
|
||||
pub use toolbar::{
|
||||
PaneSearchBarCallbacks, Toolbar, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView,
|
||||
@@ -10686,6 +10686,12 @@ pub fn client_side_decorations(
|
||||
Decorations::Server => Tiling::default(),
|
||||
Decorations::Client { tiling } => tiling,
|
||||
};
|
||||
let corner_tiling = Tiling {
|
||||
top: tiling.top || border_radius_tiling.top,
|
||||
bottom: tiling.bottom || border_radius_tiling.bottom,
|
||||
left: tiling.left || border_radius_tiling.left,
|
||||
right: tiling.right || border_radius_tiling.right,
|
||||
};
|
||||
|
||||
match decorations {
|
||||
Decorations::Client { .. } => window.set_client_inset(theme::CLIENT_SIDE_DECORATION_SHADOW),
|
||||
@@ -10701,34 +10707,7 @@ pub fn client_side_decorations(
|
||||
.map(|div| match decorations {
|
||||
Decorations::Server => div,
|
||||
Decorations::Client { .. } => div
|
||||
.when(
|
||||
!(tiling.top
|
||||
|| tiling.right
|
||||
|| border_radius_tiling.top
|
||||
|| border_radius_tiling.right),
|
||||
|div| div.rounded_tr(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.when(
|
||||
!(tiling.top
|
||||
|| tiling.left
|
||||
|| border_radius_tiling.top
|
||||
|| border_radius_tiling.left),
|
||||
|div| div.rounded_tl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.when(
|
||||
!(tiling.bottom
|
||||
|| tiling.right
|
||||
|| border_radius_tiling.bottom
|
||||
|| border_radius_tiling.right),
|
||||
|div| div.rounded_br(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.when(
|
||||
!(tiling.bottom
|
||||
|| tiling.left
|
||||
|| border_radius_tiling.bottom
|
||||
|| border_radius_tiling.left),
|
||||
|div| div.rounded_bl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.rounded_client_corners(corner_tiling)
|
||||
.when(!tiling.top, |div| {
|
||||
div.pt(theme::CLIENT_SIDE_DECORATION_SHADOW)
|
||||
})
|
||||
@@ -10783,34 +10762,7 @@ pub fn client_side_decorations(
|
||||
Decorations::Server => div,
|
||||
Decorations::Client { .. } => div
|
||||
.border_color(cx.theme().colors().border)
|
||||
.when(
|
||||
!(tiling.top
|
||||
|| tiling.right
|
||||
|| border_radius_tiling.top
|
||||
|| border_radius_tiling.right),
|
||||
|div| div.rounded_tr(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.when(
|
||||
!(tiling.top
|
||||
|| tiling.left
|
||||
|| border_radius_tiling.top
|
||||
|| border_radius_tiling.left),
|
||||
|div| div.rounded_tl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.when(
|
||||
!(tiling.bottom
|
||||
|| tiling.right
|
||||
|| border_radius_tiling.bottom
|
||||
|| border_radius_tiling.right),
|
||||
|div| div.rounded_br(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.when(
|
||||
!(tiling.bottom
|
||||
|| tiling.left
|
||||
|| border_radius_tiling.bottom
|
||||
|| border_radius_tiling.left),
|
||||
|div| div.rounded_bl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
|
||||
)
|
||||
.rounded_client_corners(corner_tiling)
|
||||
.when(!tiling.top, |div| div.border_t(BORDER_SIZE))
|
||||
.when(!tiling.bottom, |div| div.border_b(BORDER_SIZE))
|
||||
.when(!tiling.left, |div| div.border_l(BORDER_SIZE))
|
||||
|
||||
Reference in new issue
Block a user