Linux: native Wayland by default, with in-app window buttons on GNOME (#1853)

* Linux: native Wayland by default; CADCRAFT_X11=1 for XWayland

On a Wayland desktop CADCraft forced winit's X11 backend (XWayland)
whenever DISPLAY was set. The deb and rpm only recommend the X11
libraries, and without libxkbcommon-x11 winit panicked at startup:
"Library libxkbcommon-x11.so could not be loaded".

Run natively on Wayland instead: sharp at fractional scales, with
working input methods. File drops from the file manager work there too,
through storytold/winit's W15 patch. CADCRAFT_X11=1 opts into XWayland
as a fallback, and only when the X11 libraries load; otherwise it logs
what is missing and stays on Wayland. It is read with the other
variables in env.rs and replaces CADCRAFT_WAYLAND.
The deb and rpm recommend libxkbcommon-x11 (and rpm libX11-xcb) too.

Ported from WordCraft (storytold/wordcraft#3359).

* GNOME Wayland: draw the window buttons and resize edges in the app

GNOME's compositor offers no zxdg_decoration_manager_v1, so with native
Wayland it draws no frame for CADCraft. Where the protocol is missing,
the window opens without winit's frame and the app draws a title row as
GNOME's header bar: the drawing's name centred, and minimize, maximize
and close in the order GNOME's button-layout names (read once through
the XDG Desktop Portal). Thin zones along the window's edges resize it.
KDE, Sway, Hyprland, COSMIC and X11 keep the desktop's frame.

Options > Display > Use system title bar (OPTIONS key systemTitleBar)
brings back winit's frame at once. It is kept in workspace.json, which
is now read before the window opens. CADCRAFT_TITLEBAR=app or =system
overrides the detection. The new strings are translated in all 15
catalogs.

Ported from WordCraft (storytold/wordcraft#3361).

* Linux: decide the window frame from the backend winit runs on

On an X11-only session winit picks X11 without CADCRAFT_X11, so x11
stayed false and CADCRAFT_TITLEBAR=app drew the app's window buttons on
X11, whose window manager draws the frame. runs_on_x11 follows winit's
own choice (WAYLAND_DISPLAY or WAYLAND_SOCKET set and not empty).

* Linux: leave WAYLAND_SOCKET to winit; empty DISPLAY; TITLEBAR=app wins

Three CodeRabbit findings on #1853:

- The decorations probe connected with Connection::connect_to_env, which,
  given WAYLAND_SOCKET, takes that descriptor, removes the variable and
  closes it when the probe's connection drops, so winit had no Wayland
  connection left. The probe now connects only to WAYLAND_DISPLAY's
  socket (display_socket, found as wayland-client finds it); with only
  WAYLAND_SOCKET it doesn't probe and the desktop keeps the frame.
- An empty DISPLAY counted as an X display, so CADCRAFT_X11=1 forced X11
  with nothing to connect to. DISPLAY is now read as winit reads the
  Wayland variables: set and not empty.
- CADCRAFT_TITLEBAR=app chose the app's buttons, but a saved Use system
  title bar still kept winit's frame, at startup and in
  CadApp::draws_window_frame. Both now decide with app_draws_frame, which
  the override wins (CadApp::frame_forced), and Options doesn't offer the
  setting while it's overridden.

Tests: display_socket and forces_app (decorations), an empty DISPLAY
(main), and titlebar_app_overrides_the_saved_system_title_bar.

* i18n: window button and title bar rows for bs, ka, pl and vi

These catalogs arrived on main after this branch added "Minimize",
"Maximize", "Use system title bar" and its tooltip to the others, so
every catalog now has all four rows.

* Drop the parity-doc edits; the rows go in the PR description

AGENTS.md: PRs don't edit ROADMAP.md or docs/ui-parity.md.

---------

Co-authored-by: bmh129 <11478682+bmh129@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-12-03 15:07:20 +01:00
1 parent 36e8c31f0d
commit 44fa197bcc
33 files changed
+447 -21

No files matched your search

Generated
+2
View File
@@ -781,6 +781,8 @@ dependencies = [
"winit",
"winresource",
"winsafe",
"x11-dl",
"xkbcommon-dl",
"zbus",
]
+14
View File
@@ -396,6 +396,20 @@ RISC-V (riscv64) packages are `cadcraft-<ver>-linux-riscv64.deb`,
`cadcraft-<ver>-linux-riscv64.rpm`, and `cadcraft-<ver>-linux-riscv64.tar.gz`. They are
cross-compiled and need glibc 2.39 or newer (Ubuntu 24.04+, Debian 13+).
**Wayland:** on a Wayland desktop the app uses the native Wayland backend, which is sharp at
fractional scales, works with input methods and accepts files dropped from the file manager. If
the native backend misbehaves on your desktop, run the app through XWayland instead with
`CADCRAFT_X11=1` (this needs the X11 libraries: libX11, libX11-xcb, libXcursor, libXi and
libxkbcommon-x11):
```sh
CADCRAFT_X11=1 cadcraft
```
GNOME on Wayland draws no window frames, so there CADCraft's title bar carries the window
buttons, in GNOME's order. **Options ▸ Display ▸ Use system title bar** shows a basic frame
instead. `CADCRAFT_TITLEBAR=app` or `CADCRAFT_TITLEBAR=system` overrides the detection.
### FreeBSD
| Build | File |
+6
View File
@@ -40,6 +40,12 @@ winresource = "0.1"
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
winit = { version = "0.30", default-features = false, features = ["x11"] }
# Checks that the X11 libraries are installed before choosing XWayland (see main.rs). Already in
# the build through winit, at this version.
x11-dl = "2.21"
# Checks for libxkbcommon-x11 too, which winit's X11 backend needs for the keyboard and panics
# without. Already in the build through winit, at this version and with this feature.
xkbcommon-dl = { version = "0.4.2", features = ["x11"] }
# View ▸ Theme ▸ System: the desktop's light/dark choice from the XDG desktop portal
# (desktop_theme.rs). Already in Cargo.lock through accesskit; pinned to that version so nothing
# is built twice.
+8 -8
View File
@@ -12,7 +12,7 @@ const CONFIG_DIR: &str = "CADCRAFT_CONFIG_DIR";
const LOCALE: &str = "CADCRAFT_LOCALE";
const VSYNC: &str = "CADCRAFT_VSYNC";
const STENCIL: &str = "CADCRAFT_STENCIL";
const WAYLAND: &str = "CADCRAFT_WAYLAND";
const X11: &str = "CADCRAFT_X11";
const NO_NATIVE_MENU: &str = "CADCRAFT_NO_NATIVE_MENU";
const SYSTEM_CURSOR: &str = "CADCRAFT_SYSTEM_CURSOR";
const FONTALT: &str = "CADCRAFT_FONTALT";
@@ -27,7 +27,7 @@ pub(crate) const VARS: &[(&str, &str)] = &[
STENCIL,
"0 opens the window without a stencil buffer, 1 keeps it on every attempt; unset, a start that can't draw with it drops it (clipped layout viewports then draw unclipped)",
),
(WAYLAND, "1 keeps the native Wayland backend instead of XWayland; 0 or unset is off"),
(X11, "1 runs through XWayland instead of the native Wayland backend, as a fallback, when the X11 libraries load; 0 or unset is off"),
(NO_NATIVE_MENU, "macOS: 1 keeps the menus inside the window; 0 or unset is off"),
(SYSTEM_CURSOR, "1 uses the system cursor instead of the drawn crosshair; 0 or unset is off"),
(FONTALT, "the font that replaces a missing one"),
@@ -54,9 +54,9 @@ pub(crate) struct Env {
/// `renderer`). Some old drivers (Mesa on Intel HD 4000, old Intel drivers on Windows) accept a
/// stencil pass and then present a black window.
pub(crate) stencil: Switch,
/// Keep the native Wayland backend instead of XWayland.
/// Run through XWayland instead of the native Wayland backend.
#[cfg_attr(not(all(unix, not(target_os = "macos"))), allow(dead_code))]
pub(crate) wayland: Switch,
pub(crate) x11: Switch,
/// macOS: keep the menus inside the window.
#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
pub(crate) no_native_menu: Switch,
@@ -121,7 +121,7 @@ impl Env {
locale: text(LOCALE),
vsync: switch(VSYNC),
stencil: switch(STENCIL),
wayland: switch(WAYLAND),
x11: switch(X11),
no_native_menu: switch(NO_NATIVE_MENU),
system_cursor: switch(SYSTEM_CURSOR),
font_alt: text(FONTALT),
@@ -223,7 +223,7 @@ mod tests {
(LOCALE, "cs-CZ"),
(VSYNC, " On "),
(STENCIL, "No"),
(WAYLAND, "0"),
(X11, "0"),
(NO_NATIVE_MENU, "yes"),
(SYSTEM_CURSOR, "maybe"),
(FONTALT, "Noto Sans"),
@@ -238,7 +238,7 @@ mod tests {
locale: Some("cs-CZ".into()),
vsync: Switch::On,
stencil: Switch::Off,
wayland: Switch::Off,
x11: Switch::Off,
no_native_menu: Switch::On,
system_cursor: Switch::Default,
font_alt: Some("Noto Sans".into()),
@@ -249,7 +249,7 @@ mod tests {
let read = Env::from_vars(env(&blank));
assert_eq!(read.config_dir, None, "an empty variable means no directory, not the working directory");
assert_eq!((read.locale, read.font_alt, read.font_fallback), (None, None, None));
assert_eq!([read.vsync, read.stencil, read.wayland, read.no_native_menu, read.system_cursor], [Switch::Default; 5]);
assert_eq!([read.vsync, read.stencil, read.x11, read.no_native_menu, read.system_cursor], [Switch::Default; 5]);
}
#[test]
+81 -7
View File
@@ -498,6 +498,38 @@ fn prepare_launch() -> Option<Vec<std::ffi::OsString>> {
Some(launch.passthrough_args)
}
/// Whether the libraries winit's X11 backend opens at startup are installed (libX11, libXcursor,
/// libX11-xcb and libXi; libX11-xcb brings in libxcb; and libxkbcommon-x11, for the keyboard).
/// The deb and rpm only recommend them, and a forced X11 backend without them fails to start
/// (winit panics when libxkbcommon-x11 is missing).
#[cfg(all(unix, not(target_os = "macos")))]
fn x11_libraries_load() -> bool {
use x11_dl::{xcursor::Xcursor, xinput2::XInput2, xlib::Xlib, xlib_xcb::Xlib_xcb};
let missing = [Xlib::open().err(), Xcursor::open().err(), Xlib_xcb::open().err(), XInput2::open().err()];
let mut missing: Vec<String> = missing.into_iter().flatten().map(|e| e.to_string()).collect();
if xkbcommon_dl::x11::xkbcommon_x11_option().is_none() {
missing.push("libxkbcommon-x11.so.0 could not be loaded".into());
}
if !missing.is_empty() {
log::warn!("CADCRAFT_X11: X11 libraries missing, using the native Wayland backend: {}", missing.join("; "));
}
missing.is_empty()
}
/// Whether to force winit's X11 backend (XWayland on a Wayland desktop): an X display is there,
/// `CADCRAFT_X11` is on, and the X11 libraries load. The libraries are probed last, only when X11
/// would otherwise be chosen.
#[cfg(all(unix, not(target_os = "macos")))]
fn use_x11(display: bool, setting: Switch, x11_libraries_load: impl FnOnce() -> bool) -> bool {
display && setting == Switch::On && x11_libraries_load()
}
/// Whether a display variable names something: set and not empty, as winit reads them.
#[cfg(all(unix, not(target_os = "macos")))]
fn set(v: Option<&std::ffi::OsStr>) -> bool {
v.is_some_and(|v| !v.is_empty())
}
/// Parse CLI options (`--control`, `--sample`, files, `--version`), install logging and I/O hooks, build the services and app, and run eframe.
fn main() -> eframe::Result {
// A copy of this program started to read or write a DWG file does only that. It is started
@@ -589,9 +621,21 @@ fn main() -> eframe::Result {
cadcraft_engine::fonts::ttf::set_fallback_fonts(list);
}
let surface = cadcraft_ui_egui::gpu::surface_config(vars.vsync, cfg!(all(unix, not(target_os = "macos"))));
// XWayland when it's there (see below), unless CADCRAFT_WAYLAND=1 keeps the native Wayland backend.
let forced_x11 = cfg!(all(unix, not(target_os = "macos"))) && std::env::var_os("DISPLAY").is_some() && vars.wayland != Switch::On;
let frame = cadcraft_ui_egui::framework::frame_decision(forced_x11);
// winit runs natively on a Wayland desktop: sharp at fractional scales, with working input
// methods, and file drops from the file manager through storytold/winit's W15 patch.
// CADCRAFT_X11=1 runs through XWayland instead, as a fallback where the native backend
// misbehaves; 0, off or unset leaves it off. The X11 libraries are only recommended by the
// packages, so without them the setting is ignored rather than failing.
#[cfg(all(unix, not(target_os = "macos")))]
let forced_x11 = use_x11(set(std::env::var_os("DISPLAY").as_deref()), vars.x11, x11_libraries_load);
#[cfg(not(all(unix, not(target_os = "macos"))))]
let forced_x11 = false;
// Read before the window opens: Use system title bar decides the window's frame.
let (workspace, restored, workspace_error) = workspace::Workspace::load(vars.config_dir.as_deref());
// Where the desktop leaves the window frame to the app (GNOME on Wayland), the framework's title
// bar carries the window buttons, unless Options ▸ Display ▸ Use system title bar is on.
let title_bar = cadcraft_ui_egui::title_bar::decide(forced_x11, restored.as_ref().is_some_and(|ui| ui.system_title_bar));
let frame = cadcraft_ui_egui::framework::frame_decision(forced_x11).or_else(|| title_bar.as_ref().map(|t| t.decision().clone()));
let persistence_path = vars
.portable_storage_file
.clone()
@@ -620,9 +664,6 @@ fn main() -> eframe::Result {
d
});
}
// winit has no file drag-and-drop on Wayland (only on X11), so dropping files from the file
// manager showed a "no" cursor. Run through XWayland when it's there; CADCRAFT_WAYLAND=1
// keeps the native Wayland backend.
#[cfg(all(unix, not(target_os = "macos")))]
if forced_x11 {
options.event_loop_builder = Some(Box::new(|b| {
@@ -666,7 +707,6 @@ fn main() -> eframe::Result {
{
app.services.start_pick = Some(start_pick(cc.egui_ctx.clone()));
}
let (workspace, restored, workspace_error) = workspace::Workspace::load(vars.config_dir.as_deref());
if let Some(ui) = restored {
app.ui = ui;
}
@@ -716,6 +756,9 @@ fn main() -> eframe::Result {
app.session.set_lisp_support_dir(Some(support));
}
app.integrated_titlebar = cadcraft_ui_egui::framework::draws_title_row(frame.as_ref());
if let Some(title_bar) = title_bar {
app.set_title_bar(title_bar);
}
if surface.present_mode == eframe::wgpu::PresentMode::AutoNoVsync {
app.frame_cap = Some(cadcraft_ui_egui::gpu::FrameCap::new(240));
}
@@ -781,6 +824,37 @@ mod tests {
use super::{filters_for_save, follow_desktop, nightly_version_line, saved_window, version_string, window_options, without_tiny_window};
use crate::renderer::STENCIL_BITS;
/// A Wayland desktop without the X11 libraries (libxkbcommon-x11 removed, or a package
/// installed without its recommendations) crashed at startup: X11 was forced through XWayland
/// and winit panicked loading them. Native Wayland is now the default, `CADCRAFT_X11=1` asks
/// for X11 only when the libraries load, and probing them never panics, whichever of them
/// this machine has.
#[test]
#[cfg(all(unix, not(target_os = "macos")))]
fn x11_only_when_asked_for_and_the_libraries_load() {
use super::{use_x11, x11_libraries_load};
use cadcraft_ui_egui::switch::Switch;
let unprobed = || -> bool { panic!("the libraries are probed only when X11 would be chosen") };
assert!(!use_x11(true, Switch::Default, unprobed), "native Wayland by default");
assert!(!use_x11(true, Switch::Off, unprobed), "CADCRAFT_X11=0 leaves it off");
assert!(!use_x11(false, Switch::On, unprobed), "no X display");
assert!(use_x11(true, Switch::On, || true));
assert!(!use_x11(true, Switch::On, || false), "missing X11 libraries: native Wayland, no crash");
let loaded = x11_libraries_load();
assert_eq!(use_x11(true, Switch::On, || loaded), loaded);
}
/// An empty `DISPLAY` names no X server, so `CADCRAFT_X11=1` can't force X11 with it.
#[test]
#[cfg(all(unix, not(target_os = "macos")))]
fn an_empty_display_is_no_display() {
use super::set;
use std::ffi::OsStr;
assert!(set(Some(OsStr::new(":0"))));
assert!(!set(Some(OsStr::new(""))));
assert!(!set(None));
}
#[test]
fn save_dialog_offers_dwg_with_the_drawing_format_first() {
let first = |name: &str| filters_for_save(name)[0].1;
+4
View File
@@ -50,6 +50,7 @@ fn snapshot(ui: &UiState) -> Result<Value, String> {
"propertiesAll": ui.properties_all,
"inWindowMenu": ui.in_window_menu,
"historyLines": ui.history_lines,
"systemTitleBar": ui.system_title_bar,
}))
}
@@ -219,6 +220,7 @@ mod tests {
ui.toolset_tab = "Modeling".into();
ui.collapsed_groups = vec!["Solid".into()];
ui.history_lines = 5;
ui.system_title_bar = true;
ui.dialog = Some("layers".into());
ui.start_tab = true;
first.save_if_changed(&ui, Instant::now()).unwrap();
@@ -226,6 +228,7 @@ mod tests {
let value: Value = serde_json::from_slice(&bytes).unwrap();
assert!(value["workspace"].get("dialog").is_none());
assert!(value["workspace"].get("startTab").is_none());
assert_eq!(value["workspace"]["systemTitleBar"], true, "read before the window opens");
let (_, restored, error) = Workspace::at(Some(path.clone()));
assert!(error.is_none());
let restored = restored.unwrap();
@@ -340,6 +343,7 @@ mod tests {
assert_eq!(restored.toolset_tab, "Modeling");
assert_eq!(restored.collapsed_groups, ["Draw"]);
assert_eq!(restored.history_lines, 7);
assert!(!restored.system_title_bar, "older files keep the app's window buttons");
assert_eq!(serde_json::to_value(restored.docking).unwrap(), serde_json::to_value(UiState::default().docking).unwrap());
}
fs::remove_dir_all(directory).unwrap();
+15 -4
View File
@@ -44,13 +44,25 @@ const TOOLBAR: &[&[(Icon, &str, &str, Option<&str>)]] = &[
/// Height of the macOS integrated title row (#161): the standard 28 pt title-bar band AppKit centres the traffic
/// lights in.
const MAC_TITLE_BAR: f32 = 28.0;
/// Height of the framework's title bar where it carries the window buttons (GNOME on Wayland, [`crate::title_bar`]):
/// the framework theme's `size.bar.title`.
const INTEGRATED_TITLE_BAR: f32 = 38.0;
/// The width of the toolbar's More button.
const MORE_WIDTH: f32 = 30.0;
/// Title row (with the integrated macOS title bar) and the Tool Bar.
/// Title row (with the integrated macOS title bar, or the framework's title bar with the window buttons where the
/// desktop leaves the frame to the app) and the Tool Bar.
pub fn title_and_toolbar(app: &mut CadApp, ui: &mut egui::Ui) {
let t = Tokens::get();
let title_h = if app.integrated_titlebar { MAC_TITLE_BAR } else { 0.0 };
let mac = ui.ctx().os().is_mac();
// In full screen the framework's bar shows no window buttons, so the row goes too; the macOS row is unchanged.
let fullscreen = ui.ctx().input(|i| i.viewport().fullscreen.unwrap_or(false));
let title_h = match (app.integrated_titlebar, mac) {
(false, _) => 0.0,
(true, true) => MAC_TITLE_BAR,
(true, false) if fullscreen => 0.0,
(true, false) => INTEGRATED_TITLE_BAR,
};
let tb_h = if app.ui.show_toolbar { 34.0 } else { 0.0 };
egui::Panel::top("cc_title_toolbar").exact_size(title_h + tb_h).frame(egui::Frame::NONE.fill(t.chrome)).show(ui, |ui| {
let r = ui.max_rect();
@@ -70,10 +82,9 @@ pub fn title_and_toolbar(app: &mut CadApp, ui: &mut egui::Ui) {
}
if tb_h > 0.0 {
let row = Rect::from_min_size(pos2(r.left(), r.top() + title_h), vec2(r.width(), tb_h));
let mut x = r.left() + if app.integrated_titlebar { 120.0 } else { 12.0 };
let mut x = r.left() + if app.integrated_titlebar && mac { 120.0 } else { 12.0 };
let size = 26.0;
let mut clicked = None;
let mac = ui.ctx().os().is_mac();
let widths: Vec<_> = TOOLBAR.iter().map(|group| group.len() as f32 * (size + 6.0) - 6.0).collect();
let available = (row.right() - 12.0 - x).max(0.0);
let items: Vec<_> = widths.iter().enumerate().map(|(i, w)| FitItem::new(*w, i as u16, FitKeep::Free)).collect();
+2
View File
@@ -1504,6 +1504,8 @@ menu View عرض
This library has no drawings or blocks. لا تحتوي هذه المكتبة على رسومات أو كتل.
Only the first {n} are shown. يتم عرض أول {n} فقط.
The drawing changed. Close the window and open it again. تغيّر الرسم. أغلق النافذة وافتحها مرة أخرى.
Use system title bar استخدام شريط عنوان النظام
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. يعرض شريط عنوان بسيطاً لأزرار النافذة فوق شريط CADCraft نفسه. لا يرسم GNOME أشرطة العناوين للتطبيقات، لذا لا يتبع هذا الشريط سمته.
# ArtCraft feature naming
Additional Tools أدوات إضافية
Can't render this file because it contains an unexpected character in line 1336 and column 24.
+2
View File
@@ -1486,6 +1486,8 @@ menu Modify Izmijeni
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. Crtež se promijenio. Zatvorite prozor i otvorite ga ponovo.
Use system title bar Koristi sistemsku naslovnu traku
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Prikaži osnovnu naslovnu traku za dugmad prozora iznad CADCraftove vlastite. GNOME ne crta naslovne trake za aplikacije, pa ova ne prati njegovu temu.
# ArtCraft feature naming
Additional Tools Dodatni alati
Can't render this file because it contains an unexpected character in line 1444 and column 24.
+2
View File
@@ -1471,6 +1471,8 @@ menu Modify Modifikace
This drawing has no blocks. Tento výkres neobsahuje žádné bloky.
This library has no drawings or blocks. Tato knihovna neobsahuje žádné výkresy ani bloky.
Only the first {n} are shown. Zobrazuje se pouze prvních {n}.
Use system title bar Použít systémové záhlaví okna
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Zobrazí nad záhlavím CADCraftu jednoduché záhlaví s tlačítky okna. GNOME aplikacím záhlaví nekreslí, takže toto nesleduje jeho motiv.
# ArtCraft feature naming
Additional Tools Další nástroje
Can't render this file because it contains an unexpected character in line 1407 and column 24.
+2
View File
@@ -1085,6 +1085,8 @@
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. Die Zeichnung hat sich geändert. Schließen Sie das Fenster und öffnen Sie es erneut.
Use system title bar System-Titelleiste verwenden
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Eine einfache Titelleiste für die Fensterknöpfe über der von CADCraft anzeigen. GNOME zeichnet für Apps keine Titelleisten, daher folgt diese nicht seinem Design.
# ArtCraft feature naming
Additional Tools Zusätzliche Werkzeuge
1 # CADCraft German interface catalog — original translations by the CADCraft contributors.
1085
1086
1087
1088
1089
1090 # ArtCraft feature naming
1091
1092
+2
View File
@@ -1423,6 +1423,8 @@ menu View Προβολή
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. Το σχέδιο άλλαξε. Κλείστε το παράθυρο και ανοίξτε το ξανά.
Use system title bar Χρήση της γραμμής τίτλου του συστήματος
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Εμφανίζει μια απλή γραμμή τίτλου με τα κουμπιά του παραθύρου πάνω από τη γραμμή του CADCraft. Το GNOME δεν σχεδιάζει γραμμές τίτλου για τις εφαρμογές, οπότε αυτή δεν ακολουθεί το θέμα του.
# ArtCraft feature naming
Additional Tools Πρόσθετα εργαλεία
Can't render this file because it contains an unexpected character in line 234 and column 24.
+2
View File
@@ -1303,6 +1303,8 @@
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. El dibujo cambió. Cierre la ventana y ábrala de nuevo.
Use system title bar Usar la barra de título del sistema
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Muestra una barra de título básica con los botones de la ventana encima de la de CADCraft. GNOME no dibuja barras de título para las aplicaciones, así que esta no sigue su tema.
# ArtCraft feature naming
Additional Tools Herramientas adicionales
1 # CADCraft Spanish interface catalog — original translations.
1303
1304
1305
1306
1307
1308 # ArtCraft feature naming
1309
1310
+2
View File
@@ -1065,6 +1065,8 @@
Press the keys Appuyez sur les touches
Back to CADCraft's shortcut Revenir au raccourci de CADCraft
A shortcut you give wins over CADCraft's own. Changes apply at once and are kept for next time. Un raccourci que vous définissez l'emporte sur celui de CADCraft. Les modifications s'appliquent tout de suite et sont conservées.
Use system title bar Utiliser la barre de titre du système
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Affiche une barre de titre simple avec les boutons de la fenêtre au-dessus de celle de CADCraft. GNOME ne dessine pas de barre de titre pour les applications, celle-ci ne suit donc pas son thème.
# ArtCraft feature naming
Additional Tools Outils supplémentaires
1 # CADCraft French interface catalog — original translations by @pechnikov2026-star; terminology review by @YannFR81.
1065
1066
1067
1068
1069
1070 # ArtCraft feature naming
1071
1072
+2
View File
@@ -1388,6 +1388,8 @@ menu View Nézet
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. A rajz megváltozott. Zárja be az ablakot, és nyissa meg újra.
Use system title bar A rendszer címsorának használata
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Egyszerű címsort jelenít meg az ablak gombjaival a CADCraft saját címsora fölött. A GNOME nem rajzol címsort az alkalmazásoknak, ezért ez nem követi a témáját.
# ArtCraft feature naming
Additional Tools További eszközök
Can't render this file because it contains an unexpected character in line 16 and column 72.
+2
View File
@@ -1434,6 +1434,8 @@ menu Modify Edita
ENTER INVIO
Shortcut Menu: always enabled Menu di scelta rapida: sempre attivo
Shortcut Menu: enabled when command options are present Menu di scelta rapida: attivo se il comando ha opzioni
Use system title bar Usa la barra del titolo di sistema
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Mostra una semplice barra del titolo con i pulsanti della finestra sopra quella di CADCraft. GNOME non disegna barre del titolo per le app, quindi questa non segue il suo tema.
Check for updates when CADCraft starts Controlla gli aggiornamenti all'avvio di CADCraft
Turned off, CADCraft never offers an update on its own; Help ▸ Check for Updates… still looks. Se disattivato, CADCraft non propone mai un aggiornamento da solo; Aiuto ▸ Verifica aggiornamenti… continua a controllare.
1 # CADCraft Italian interface catalog — original translations by Emanuele Bottelli (AI-assisted, Claude).
1434
1435
1436
1437
1438
1439
1440
1441 # ArtCraft feature naming
+2
View File
@@ -1519,6 +1519,8 @@ menu View ხედი
This drawing has no blocks. ამ ნახაზში ბლოკები არ არის.
This library has no drawings or blocks. ამ ბიბლიოთეკაში ნახაზები ან ბლოკები არ არის.
Only the first {n} are shown. ნაჩვენებია მხოლოდ პირველი {n}.
Use system title bar სისტემის სათაურის ზოლის გამოყენება
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. ფანჯრის ღილაკებისთვის მარტივი სათაურის ზოლის ჩვენება CADCraft-ის საკუთარი ზოლის ზემოთ. GNOME აპებისთვის სათაურის ზოლებს არ ხატავს, ამიტომ ეს ზოლი მის თემას არ მიჰყვება.
# ArtCraft feature naming
Additional Tools დამატებითი ხელსაწყოები
Can't render this file because it contains an unexpected character in line 10 and column 14.
+2
View File
@@ -1287,6 +1287,8 @@ menu Modify 수정
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. 도면이 변경되었습니다. 창을 닫고 다시 여십시오.
Use system title bar 시스템 제목 표시줄 사용
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. CADCraft의 제목 표시줄 위에 창 단추가 있는 기본 제목 표시줄을 표시합니다. GNOME은 앱의 제목 표시줄을 그리지 않으므로 이 표시줄은 테마를 따르지 않습니다.
# ArtCraft feature naming
Additional Tools 추가 도구
1 # CADCraft Korean interface catalog — original Korean translations.
1287
1288
1289
1290
1291
1292 # ArtCraft feature naming
1293
1294
+2
View File
@@ -2170,6 +2170,8 @@ menu Dimension Wymiarowanie
The current file doesn't look whole, so {name} stays as it is and the current file will be replaced. Bieżący plik wygląda na niekompletny, więc {name} pozostanie bez zmian, a bieżący plik zostanie zastąpiony.
The current file is kept as {name} until the next save. Bieżący plik zostanie zachowany jako {name} do następnego zapisu.
The drawing changed. Close the window and open it again. Rysunek został zmieniony. Zamknij okno i otwórz je ponownie.
Use system title bar Użyj systemowego paska tytułu
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Pokaż prosty pasek tytułu z przyciskami okna nad własnym paskiem CADCraft. GNOME nie rysuje pasków tytułu dla aplikacji, więc ten nie korzysta z jego motywu.
This format can't keep these objects yet: {objects}. Ten format nie potrafi jeszcze zachować tych obiektów: {objects}.
Turn on time-sensitive right-click Włącz obsługę prawego przycisku zależną od czasu
Turned off, a right-click while a command runs does what Right-Click Customization sets for Command mode. Po wyłączeniu tej opcji prawy przycisk podczas polecenia działa zgodnie z ustawieniami trybu polecenia w oknie Dostosowanie prawego przycisku myszy.
Can't render this file because it contains an unexpected character in line 832 and column 20.
+2
View File
@@ -1493,6 +1493,8 @@ menu View Exibir
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. O desenho mudou. Feche a janela e abra-a novamente.
Use system title bar Usar a barra de título do sistema
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Mostra uma barra de título simples com os botões da janela acima da do CADCraft. O GNOME não desenha barras de título para os aplicativos, então esta não segue o tema dele.
# ArtCraft feature naming
Additional Tools Ferramentas adicionais
Can't render this file because it contains an unexpected character in line 1441 and column 24.
+2
View File
@@ -1060,6 +1060,8 @@
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. Чертёж изменился. Закройте окно и откройте его снова.
Use system title bar Использовать системный заголовок окна
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Показывает простой заголовок окна с кнопками над заголовком CADCraft. GNOME не рисует заголовки для приложений, поэтому этот не следует его теме.
# ArtCraft feature naming
Additional Tools Дополнительные инструменты
1 # CADCraft Russian interface catalog — original translations by @pechnikov2026-star.
1060
1061
1062
1063
1064
1065 # ArtCraft feature naming
1066
1067
+2
View File
@@ -1511,6 +1511,8 @@ menu Modify Ändra
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. Ritningen har ändrats. Stäng fönstret och öppna det igen.
Use system title bar Använd systemets namnlist
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Visar en enkel namnlist med fönsterknapparna ovanför CADCrafts egen. GNOME ritar inga namnlister åt appar, så den här följer inte dess tema.
DView DView
Keyboard Shortcuts... Kortkommandon...
Multiple Insert Infoga flera
Can't render this file because it contains an unexpected character in line 1500 and column 24.
+2
View File
@@ -1391,6 +1391,8 @@ menu View Görünüm
Ctrl+Enter to apply Ctrl+Enter to apply
Edit Text Edit Text
The drawing changed. Close the window and open it again. Çizim değişti. Pencereyi kapatıp yeniden açın.
Use system title bar Sistem başlık çubuğunu kullan
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. CADCraft'ın başlık çubuğunun üstünde pencere düğmelerini içeren basit bir başlık çubuğu gösterir. GNOME uygulamalar için başlık çubuğu çizmediğinden bu çubuk onun temasına uymaz.
# ArtCraft feature naming
Additional Tools Ek Araçlar
Can't render this file because it contains an unexpected character in line 11 and column 13.
+2
View File
@@ -1468,6 +1468,8 @@
ENTER Клавіша Enter
Shortcut Menu: always enabled Контекстне меню: завжди
Shortcut Menu: enabled when command options are present Контекстне меню: коли команда має параметри
Use system title bar Використовувати системний заголовок вікна
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Показує простий заголовок вікна з кнопками над заголовком CADCraft. GNOME не малює заголовки для застосунків, тому цей не відповідає його темі.
Check for updates when CADCraft starts Перевіряти оновлення під час запуску CADCraft
Turned off, CADCraft never offers an update on its own; Help ▸ Check for Updates… still looks. Якщо вимкнено, CADCraft ніколи сам не пропонує оновлення; Довідка ▸ Перевірити оновлення… усе одно перевіряє.
Can't render this file because it contains an unexpected character in line 1404 and column 24.
+2
View File
@@ -1492,6 +1492,8 @@ menu Modify Hiệu chỉnh
Ctrl+Enter to apply Ctrl+Enter để áp dụng
Edit Text Sửa chữ
The drawing changed. Close the window and open it again. Bản vẽ đã thay đổi. Đóng cửa sổ và mở lại.
Use system title bar Dùng thanh tiêu đề của hệ thống
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. Hiện một thanh tiêu đề đơn giản cho các nút cửa sổ phía trên thanh của CADCraft. GNOME không vẽ thanh tiêu đề cho ứng dụng, nên thanh này không theo chủ đề của nó.
# Phase 1 of craft-i18n#401: the strings the translation_gaps report listed as missing for vi.
# Dimension Style Manager (DIMSTYLE)
<style overrides> <ghi đè kiểu>
Can't render this file because it contains an unexpected character in line 1445 and column 24.
+2
View File
@@ -1530,6 +1530,8 @@ menu View 视图
Ctrl+Enter to apply Ctrl+Enter 应用
Edit Text 编辑文字
The drawing changed. Close the window and open it again. 图纸已切换。请关闭窗口后重新打开。
Use system title bar 使用系统标题栏
Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme. 在 CADCraft 自己的标题栏上方显示带窗口按钮的基本标题栏。GNOME 不为应用绘制标题栏,因此此标题栏不跟随其主题。
# ArtCraft feature naming
Additional Tools 其他工具
Can't render this file because it contains an unexpected character in line 1486 and column 24.
+13
View File
@@ -74,11 +74,13 @@ pub mod quick;
pub mod save_loss;
pub mod shortcut_menus;
pub mod theme;
pub mod title_bar;
#[cfg(not(target_arch = "wasm32"))]
pub mod updates_ui;
pub mod viewcube;
pub mod vpscale;
pub mod wblock;
mod window_edges;
pub mod exchange;
mod file_provider_app;
@@ -150,6 +152,10 @@ pub struct UiState {
pub last_lisp_dir: Option<String>,
/// The folder the Command Aliases dialog last imported a `.pgp` file from.
pub last_pgp_dir: Option<String>,
/// Options ▸ Display ▸ Use system title bar: where the desktop leaves the window frame to the app (GNOME on
/// Wayland), keep the desktop's frame instead of the framework's title bar ([`title_bar`]). Kept in the desktop
/// workspace file, which is read before the window opens.
pub system_title_bar: bool,
}
/// A DXF/DWG file version (2000 … 2018).
@@ -230,6 +236,7 @@ impl Default for UiState {
hatch_patterns: Default::default(),
last_lisp_dir: None,
last_pgp_dir: None,
system_title_bar: false,
}
}
}
@@ -323,6 +330,8 @@ pub struct CadApp {
/// Drawings being read on worker threads ([`opening`]).
pub opening: opening::Opening,
pub integrated_titlebar: bool,
/// Both frames of Use system title bar, where it applies ([`title_bar::TitleBar`]).
title_bar: Option<title_bar::TitleBar>,
control_rx: Option<Receiver<ControlRequest>>,
/// Fresh surface and identity snapshot (see [`capture`]).
pub(crate) capture_geometry: Option<capture::CaptureGeometry>,
@@ -439,6 +448,7 @@ impl CadApp {
status: None,
opening: opening::Opening::default(),
integrated_titlebar: false,
title_bar: None,
control_rx: None,
capture_geometry: None,
capture_epoch: 0,
@@ -1293,6 +1303,7 @@ impl CadApp {
self.sync_bars();
control::begin_frame(ui.ctx());
let t = theme::Tokens::get();
self.follow_title_bar(ui.ctx());
chrome::title_and_toolbar(self, ui);
if self.ui.in_window_menu {
menus::menu_bar(self, ui);
@@ -1326,6 +1337,8 @@ impl CadApp {
autosave::gpu_notice(self, ui.ctx());
autosave::failure_notice(self, ui.ctx());
self.run_framework_dialogs(ui);
// Last, so the edges' resize cursors win over the drawing area's.
window_edges::show(ui.ctx());
self.frame_ms = now_ms() - t0;
}
+7
View File
@@ -21,6 +21,7 @@
//! | `rightClickDefault`, `rightClickEdit` | with the time-sensitive right-click off, a right-click with no command running and nothing (`Default`) or something (`Edit`) selected: `"menu"` (the shortcut menu, default) or `"repeat"` (the last command) |
//! | `rightClickCommand` | a right-click while a command runs, with the time-sensitive right-click off: `"menu"` (default), `"enter"`, or `"menuWithOptions"` (the menu when the prompt has options, else Enter) |
//! | `systemCursor` | keep the system cursor visible over the drawing area |
//! | `systemTitleBar` | where the desktop leaves the window frame to the app (GNOME on Wayland), keep the desktop's frame instead of the framework's title bar with the window buttons |
//! | `historyLines` | command-line history lines, 0–12 |
//! | `modelBackground`, `paperBackground` | `"#rrggbb"`, or `null` for the default |
//! | `selectionColor` | the colour selected objects are highlighted in: `"#rrggbb"`, or `null` for the theme's |
@@ -230,6 +231,7 @@ struct UiChanges {
language: Option<crate::i18n::Preference>,
save_format: Option<crate::SaveFormat>,
system_cursor: Option<bool>,
system_title_bar: Option<bool>,
history_lines: Option<usize>,
model_background: Option<Option<Color32>>,
paper_background: Option<Option<Color32>>,
@@ -268,6 +270,7 @@ fn parse_ui(key: &str, v: &Value, c: &mut UiChanges) -> Result<bool, String> {
}
"saveFormat" => c.save_format = Some(crate::SaveFormat::parse(text()?).ok_or("saveFormat must be dxf or dwg")?),
"systemCursor" => c.system_cursor = Some(v.as_bool().ok_or("systemCursor must be true or false")?),
"systemTitleBar" => c.system_title_bar = Some(v.as_bool().ok_or("systemTitleBar must be true or false")?),
"historyLines" => {
let n = v.as_u64().filter(|n| *n <= crate::cmdline::MAX_LINES as u64).ok_or("historyLines must be a whole number from 0 to 12")?;
c.history_lines = Some(n as usize);
@@ -330,6 +333,7 @@ fn ui_json(app: &CadApp) -> Map<String, Value> {
m.insert("interfaceLanguage".into(), json!(app.ui.interface_language.code()));
m.insert("saveFormat".into(), json!(app.ui.save_format.as_str()));
m.insert("systemCursor".into(), json!(app.ui.system_cursor));
m.insert("systemTitleBar".into(), json!(app.ui.system_title_bar));
m.insert("historyLines".into(), json!(app.ui.history_lines));
m.insert("modelBackground".into(), color_json(o.model_background));
m.insert("paperBackground".into(), color_json(o.paper_background));
@@ -389,6 +393,9 @@ fn run_json(app: &mut CadApp, params: &Value) -> Result<Value, String> {
if let Some(b) = ui.system_cursor {
app.ui.system_cursor = b;
}
if let Some(b) = ui.system_title_bar {
app.ui.system_title_bar = b;
}
if let Some(n) = ui.history_lines {
app.ui.history_lines = n;
}
+15
View File
@@ -212,6 +212,21 @@ fn display(app: &CadApp, ui: &mut egui::Ui, changes: &mut Map<String, Value>) {
changes.insert("systemCursor".into(), json!(system_cursor));
}
hint(ui, crate::tl!("Screen magnifiers, screen readers and recorders follow the system cursor."));
// Only where the framework's title bar carries the window buttons (GNOME on Wayland); elsewhere
// the desktop draws the frame. `CADCRAFT_TITLEBAR` overrides the setting, so it isn't offered then.
if app.system_title_bar_applies() {
ui.add_space(6.0);
let mut system = app.ui.system_title_bar;
if ui.checkbox(&mut system, crate::tl!("Use system title bar")).changed() {
changes.insert("systemTitleBar".into(), json!(system));
}
hint(
ui,
crate::tl!(
"Show a basic title bar for the window buttons above CADCraft's own. GNOME doesn't draw title bars for apps, so this one doesn't follow its theme."
),
);
}
}
/// Files tab: save format and default version, new-drawing units, autosave interval and autosave file location; edits accumulate in `changes`.
+1 -1
View File
@@ -1,4 +1,4 @@
//! Boolean environment switches (`CADCRAFT_VSYNC`, `CADCRAFT_WAYLAND`, ...): one parser, so every
//! Boolean environment switches (`CADCRAFT_VSYNC`, `CADCRAFT_X11`, ...): one parser, so every
//! variable accepts the same spellings.
/// `1/on/true/yes` or `0/off/false/no`, case- and space-insensitive. Blank or unset is `Default`;
+122
View File
@@ -0,0 +1,122 @@
//! Options ▸ Display ▸ Use system title bar: where the desktop leaves the window frame to the app (GNOME on
//! Wayland), the framework's title bar carries the window buttons, in the order of GNOME's `button-layout`; the
//! setting gives the window the desktop's frame instead, at once. craft-window decides the frame
//! (`policy::decide_for`), as on macOS ([`crate::framework::frame_decision`]).
use craft_host::target::Backend;
use craft_ui::runtime::windows::WindowHost;
use craft_window::policy::{self, Decision, TitleBarPref};
use crate::CadApp;
/// The window's frame for each value of Use system title bar, both decided at start-up from the desktop as it was
/// then, so the app's buttons come back in the desktop's `button-layout` order.
#[derive(Clone, Debug, PartialEq)]
pub struct TitleBar {
/// The frame with the setting off: the app's buttons.
app: Decision,
/// The frame with the setting on: the desktop's.
system: Decision,
/// The setting the window's frame follows now.
applied: bool,
}
impl TitleBar {
/// The frames for both values of the setting, or `None` to leave the frame to the desktop, as before. Only where
/// the desktop draws no frame (a Wayland compositor without server-side decorations: GNOME) or
/// `CADCRAFT_TITLEBAR` asks: the policy would also draw the app's buttons on desktops that frame their windows
/// (Windows, KDE), which is a decision for the whole suite rather than this setting.
#[must_use]
pub fn new(app: Decision, system: Decision, system_title_bar: bool) -> Option<Self> {
let leaves_frame_to_app = app.desktop.ssd == Some(false);
(leaves_frame_to_app || app.overridden.is_some()).then_some(Self { app, system, applied: system_title_bar })
}
/// The frame the window opens with.
#[must_use]
pub fn decision(&self) -> &Decision {
if self.applied { &self.system } else { &self.app }
}
/// `Some(true)` when `CADCRAFT_TITLEBAR` forced the app's buttons, `Some(false)` the desktop's frame; the setting
/// then changes nothing.
fn forced(&self) -> Option<bool> {
self.app.overridden
}
}
/// [`TitleBar::new`] for this desktop; `forced_x11` when the app opens its window through XWayland.
#[must_use]
pub fn decide(forced_x11: bool, system_title_bar: bool) -> Option<TitleBar> {
let backend = if forced_x11 { Backend::X11 } else { Backend::from_env() };
let decide = |pref| policy::decide_for(craft_window::Prefix::new("CADCRAFT"), backend, pref);
TitleBar::new(decide(TitleBarPref::Integrated), decide(TitleBarPref::System), system_title_bar)
}
impl CadApp {
/// The window opened with `title_bar`'s frame ([`decide`]): Use system title bar now changes it, and the title
/// row follows it.
pub fn set_title_bar(&mut self, title_bar: TitleBar) {
self.integrated_titlebar = crate::framework::draws_title_row(Some(title_bar.decision()));
self.title_bar = Some(title_bar);
}
/// Whether Use system title bar changes anything here: the framework decides the frame and `CADCRAFT_TITLEBAR`
/// doesn't.
pub(crate) fn system_title_bar_applies(&self) -> bool {
self.title_bar.as_ref().is_some_and(|t| t.forced().is_none())
}
/// Follow Use system title bar at once, before the title row is drawn: the window gets the setting's frame, and
/// the title row shows or goes with the window buttons.
pub(crate) fn follow_title_bar(&mut self, ctx: &egui::Context) {
let system = self.ui.system_title_bar;
let Some(t) = self.title_bar.as_mut().filter(|t| t.forced().is_none() && t.applied != system) else { return };
t.applied = system;
let decision = t.decision().clone();
self.integrated_titlebar = crate::framework::draws_title_row(Some(&decision));
WindowHost::of(ctx).set_root_frame(decision);
}
}
#[cfg(test)]
mod tests {
use super::TitleBar;
use craft_host::target::Backend;
use craft_window::policy::{self, TitleBarPref};
/// Both frames as GNOME on Wayland gives them: no server-side decorations and no override.
fn gnome() -> (policy::Decision, policy::Decision) {
let decide = |pref| {
let mut d = policy::decide_for(craft_window::Prefix::new("CADCRAFT_TEST_UNSET"), Backend::Wayland, pref);
d.desktop.ssd = Some(false);
d.overridden = None;
d
};
(decide(TitleBarPref::Integrated), decide(TitleBarPref::System))
}
#[test]
fn only_where_the_desktop_leaves_the_frame_to_the_app() {
let (app, system) = gnome();
assert!(TitleBar::new(app.clone(), system.clone(), false).is_some(), "GNOME on Wayland");
let mut framed = app.clone();
framed.desktop.ssd = Some(true);
assert!(TitleBar::new(framed.clone(), system.clone(), false).is_none(), "KDE and Sway draw their own frames");
framed.overridden = Some(true);
assert!(TitleBar::new(framed, system, false).is_some(), "CADCRAFT_TITLEBAR=app asks anyway");
}
#[test]
fn the_setting_picks_the_frame_and_the_override_beats_it() {
let (app, system) = gnome();
let t = TitleBar::new(app.clone(), system.clone(), false).unwrap();
assert_eq!(t.decision(), &app);
assert_eq!(t.forced(), None);
let t = TitleBar::new(app.clone(), system.clone(), true).unwrap();
assert_eq!(t.decision(), &system, "Use system title bar on: the desktop's frame");
let mut forced = app;
forced.overridden = Some(true);
assert_eq!(TitleBar::new(forced, system, true).unwrap().forced(), Some(true));
}
}
+116
View File
@@ -0,0 +1,116 @@
//! Resize edges for the framework's integrated frame ([`crate::title_bar`]: GNOME on Wayland, where the desktop draws
//! no frame). The framework gives the window buttons and the move band, but only a window built from its own shell
//! gets its resize grips; CADCraft hosts its own egui UI, so thin zones along the window's edges start the desktop's
//! resize here. The resize goes through the framework (`WindowAction::StartResize`), which gives the button release
//! back after the desktop's grab.
use craft_ui::runtime::windows::{ResizeEdge, WindowAction, WindowHost};
use craft_window::policy::Frame;
use egui::{Color32, CursorIcon, Pos2, Rect, Sense, Stroke, Vec2, ViewportId};
/// How far into the window an edge resizes it.
const EDGE: f32 = 5.0;
/// How far along an edge a corner reaches, so corners are easy to hit.
const CORNER: f32 = 16.0;
/// The resize zones of a window filling `rect`: edges `edge` deep, and each corner an L of two strips reaching
/// `corner` along both edges (a square would reach into the content).
fn zones(rect: Rect, edge: f32, corner: f32) -> Vec<(ResizeEdge, Rect)> {
let (l, r, t, b) = (rect.left(), rect.right(), rect.top(), rect.bottom());
// Never inverted, however small the window.
let zone = |x0: f32, x1: f32, y0: f32, y1: f32| Rect::from_min_max(Pos2::new(x0, y0), Pos2::new(x1.max(x0), y1.max(y0)));
vec![
(ResizeEdge::TopLeft, zone(l, l + corner, t, t + edge)),
(ResizeEdge::TopLeft, zone(l, l + edge, t + edge, t + corner)),
(ResizeEdge::TopRight, zone(r - corner, r, t, t + edge)),
(ResizeEdge::TopRight, zone(r - edge, r, t + edge, t + corner)),
(ResizeEdge::BottomLeft, zone(l, l + corner, b - edge, b)),
(ResizeEdge::BottomLeft, zone(l, l + edge, b - corner, b - edge)),
(ResizeEdge::BottomRight, zone(r - corner, r, b - edge, b)),
(ResizeEdge::BottomRight, zone(r - edge, r, b - corner, b - edge)),
(ResizeEdge::Top, zone(l + corner, r - corner, t, t + edge)),
(ResizeEdge::Bottom, zone(l + corner, r - corner, b - edge, b)),
(ResizeEdge::Left, zone(l, l + edge, t + corner, b - corner)),
(ResizeEdge::Right, zone(r - edge, r, t + corner, b - corner)),
]
}
fn cursor(edge: ResizeEdge) -> CursorIcon {
match edge {
ResizeEdge::Top => CursorIcon::ResizeNorth,
ResizeEdge::Bottom => CursorIcon::ResizeSouth,
ResizeEdge::Right => CursorIcon::ResizeEast,
ResizeEdge::Left => CursorIcon::ResizeWest,
ResizeEdge::TopRight => CursorIcon::ResizeNorthEast,
ResizeEdge::BottomRight => CursorIcon::ResizeSouthEast,
ResizeEdge::TopLeft => CursorIcon::ResizeNorthWest,
ResizeEdge::BottomLeft => CursorIcon::ResizeSouthWest,
_ => CursorIcon::Default,
}
}
/// Resize zones along the root window's edges and a hairline border, while the framework's integrated frame is the
/// window's and the window is neither maximized nor full screen. The zones sit above everything else (in the
/// foreground order), so a press there resizes instead of reaching the panel or canvas under it.
pub(crate) fn show(ctx: &egui::Context) {
let host = WindowHost::of(ctx);
if !matches!(host.frame(), Frame::Integrated(_)) {
return;
}
let (maximized, fullscreen) = ctx.input(|i| (i.viewport().maximized.unwrap_or(false), i.viewport().fullscreen.unwrap_or(false)));
if maximized || fullscreen {
return;
}
let screen = ctx.content_rect();
let dark = crate::theme::active() == egui::Theme::Dark;
egui::Area::new(egui::Id::unique("cadcraft_window_edges")).order(egui::Order::Foreground).fixed_pos(screen.min).interactable(true).show(
ctx,
|ui| {
ui.set_min_size(Vec2::ZERO);
for (n, (edge, rect)) in zones(screen, EDGE, CORNER).into_iter().enumerate() {
if rect.width() <= 0.0 || rect.height() <= 0.0 {
continue;
}
let response = ui.interact(rect, ui.scope_id().with(("edge", n)), Sense::drag()).on_hover_cursor(cursor(edge));
// Sensing only drags, a drag starts on the press itself.
if response.drag_started() {
host.act(ViewportId::ROOT, WindowAction::StartResize(edge));
}
}
// Without the desktop's frame or shadow, a hairline keeps the window apart from what's behind it.
ui.painter().rect_stroke(screen, 0.0, Stroke::new(1.0, Color32::from_black_alpha(if dark { 160 } else { 60 })), egui::StrokeKind::Inside);
},
);
}
#[cfg(test)]
mod tests {
use super::{ResizeEdge, zones};
use egui::{Pos2, Rect};
#[test]
fn resize_zones_line_the_edges_without_overlapping() {
let window = Rect::from_min_size(Pos2::ZERO, egui::vec2(800.0, 600.0));
let zones = zones(window, 5.0, 16.0);
let at = |x: f32, y: f32| zones.iter().filter(|(_, r)| r.contains(Pos2::new(x, y))).map(|(e, _)| *e).collect::<Vec<_>>();
assert_eq!(at(1.0, 1.0), [ResizeEdge::TopLeft]);
assert_eq!(at(2.0, 12.0), [ResizeEdge::TopLeft]);
assert_eq!(at(400.0, 2.0), [ResizeEdge::Top]);
assert_eq!(at(799.0, 300.0), [ResizeEdge::Right]);
assert_eq!(at(400.0, 599.0), [ResizeEdge::Bottom]);
assert_eq!(at(1.0, 300.0), [ResizeEdge::Left]);
assert_eq!(at(799.0, 599.0), [ResizeEdge::BottomRight]);
assert!(at(400.0, 300.0).is_empty(), "the middle of the window is left alone");
assert!(at(12.0, 12.0).is_empty(), "corners stay along the edges");
// Strips meet without overlapping.
for y in [0.5, 4.5, 5.5, 15.5, 16.5, 595.5] {
for x in [0.5, 4.5, 5.5, 15.5, 16.5, 795.5, 799.5] {
assert!(at(x, y).len() <= 1, "({x}, {y}): {:?}", at(x, y));
}
}
// A window smaller than its corners gets empty (not inverted) edge zones.
for (_, r) in super::zones(Rect::from_min_size(Pos2::ZERO, egui::vec2(20.0, 20.0)), 5.0, 16.0) {
assert!(r.width() >= 0.0 && r.height() >= 0.0);
}
}
}
+5 -1
View File
@@ -24,7 +24,8 @@ description: |-
# The binaries link only glibc and libgcc_s directly. Windowing (X11/Wayland, xkbcommon) and the
# GPU (Vulkan, EGL/GL) are loaded at runtime, so they are dependencies/recommendations here
# rather than ELF NEEDED entries.
# rather than ELF NEEDED entries. On a Wayland desktop the app runs natively and needs X11 only
# with CADCRAFT_X11=1 (see main.rs), so the X11 libraries are recommendations.
overrides:
deb:
depends:
@@ -36,6 +37,7 @@ overrides:
- libwayland-client0
- libx11-6
- libx11-xcb1
- libxkbcommon-x11-0
- libxcursor1
- libxi6
- libxrandr2
@@ -48,6 +50,8 @@ overrides:
recommends:
- libwayland-client
- libX11
- libX11-xcb
- libxkbcommon-x11
- libXcursor
- libXi
- libXrandr