logiguard fork: GPUI xdg-activation keyboard-focus serial fix
Some checks failed
Update All Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Triage Project Sync (#84) / Sync triage project (push) Has been cancelled
release_nightly / notify_on_failure (push) Has been cancelled
release_nightly / check_style (push) Has been cancelled
release_nightly / run_tests_windows (push) Has been cancelled
release_nightly / clippy_windows (push) Has been cancelled
release_nightly / bundle_linux_aarch64 (push) Has been cancelled
release_nightly / bundle_linux_x86_64 (push) Has been cancelled
release_nightly / bundle_mac_aarch64 (push) Has been cancelled
release_nightly / bundle_mac_x86_64 (push) Has been cancelled
release_nightly / bundle_windows_aarch64 (push) Has been cancelled
release_nightly / bundle_windows_x86_64 (push) Has been cancelled
release_nightly / build_nix_linux_x86_64 (push) Has been cancelled
release_nightly / build_nix_mac_aarch64 (push) Has been cancelled
release_nightly / update_nightly_tag (push) Has been cancelled
Hotfix Review Monitor / check-hotfix-reviews (push) Has been cancelled
Stale PR Review Reminder / check-stale-prs (push) Has been cancelled
Update Weekly Top Ranking Issues / update_top_ranking_issues (push) Has been cancelled
Bump collab-staging Tag / update-collab-staging-tag (push) Has been cancelled
compliance_check / scheduled_compliance_check (push) Has been cancelled

Single-commit orphan branch: full zed-industries/zed @ 8c74db0 source tree
with a 3-file patch applied (no upstream history).

Patch (crates/gpui_linux/src/linux/wayland/):
  - serial.rs: add SerialKind::KeyboardEnter
  - client.rs: store wl_keyboard.enter serial; add latest_serial_of()
  - window.rs: activate() uses keyboard-enter serial (Mutter focus gate)

Mutter honors window activation only when the token carries the keyboard-
focus serial from wl_keyboard.enter; GPUI used a stale mouse-press serial.
See docs/tray-window-focus-wayland.md in logiguard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mohamad Khani
2026-07-14 02:22:17 +03:30
commit b72a46db68
3984 changed files with 1583326 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
[package]
name = "file_icons"
version = "0.1.0"
edition.workspace = true
publish.workspace = true
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/file_icons.rs"
doctest = false
[dependencies]
gpui.workspace = true
serde.workspace = true
theme.workspace = true
util.workspace = true

View File

@@ -0,0 +1 @@
../../LICENSE-GPL

View File

@@ -0,0 +1,166 @@
use std::sync::Arc;
use std::{path::Path, str};
use gpui::{App, SharedString};
use theme::{GlobalTheme, IconTheme, ThemeRegistry};
use util::paths::PathExt;
#[derive(Debug)]
pub struct FileIcons {
icon_theme: Arc<IconTheme>,
}
impl FileIcons {
pub fn get(cx: &App) -> Self {
Self {
icon_theme: GlobalTheme::icon_theme(cx).clone(),
}
}
pub fn get_icon(path: &Path, cx: &App) -> Option<SharedString> {
let this = Self::get(cx);
let get_icon_from_suffix = |suffix: &str| -> Option<SharedString> {
this.icon_theme
.file_stems
.get(suffix)
.or_else(|| this.icon_theme.file_suffixes.get(suffix))
.and_then(|typ| this.get_icon_for_type(typ, cx))
};
// TODO: Associate a type with the languages and have the file's language
// override these associations
if let Some(mut typ) = path.file_name().and_then(|typ| typ.to_str()) {
// check if file name is in suffixes
// e.g. catch file named `eslint.config.js` instead of `.eslint.config.js`
let maybe_path = get_icon_from_suffix(typ);
if maybe_path.is_some() {
return maybe_path;
}
// check if suffix based on first dot is in suffixes
// e.g. consider `module.js` as suffix to angular's module file named `auth.module.js`
while let Some((_, suffix)) = typ.split_once('.') {
let maybe_path = get_icon_from_suffix(suffix);
if maybe_path.is_some() {
return maybe_path;
}
typ = suffix;
}
}
// handle cases where the file extension is made up of multiple important
// parts (e.g Component.stories.tsx) that refer to an alternative icon style
if let Some(suffix) = path.multiple_extensions() {
let maybe_path = get_icon_from_suffix(suffix.as_str());
if maybe_path.is_some() {
return maybe_path;
}
}
// primary case: check if the files extension or the hidden file name
// matches some icon path
if let Some(suffix) = path.extension_or_hidden_file_name() {
let maybe_path = get_icon_from_suffix(suffix);
if maybe_path.is_some() {
return maybe_path;
}
}
// this _should_ only happen when the file is hidden (has leading '.')
// and is not a "special" file we have an icon (e.g. not `.eslint.config.js`)
// that should be caught above. In the remaining cases, we want to check
// for a normal supported extension e.g. `.data.json` -> `json`
let extension = path.extension().and_then(|ext| ext.to_str());
if let Some(extension) = extension {
let maybe_path = get_icon_from_suffix(extension);
if maybe_path.is_some() {
return maybe_path;
}
}
this.get_icon_for_type("default", cx)
}
fn default_icon_theme(cx: &App) -> Option<Arc<IconTheme>> {
let theme_registry = ThemeRegistry::global(cx);
theme_registry.default_icon_theme().ok()
}
pub fn get_icon_for_type(&self, typ: &str, cx: &App) -> Option<SharedString> {
fn get_icon_for_type(icon_theme: &Arc<IconTheme>, typ: &str) -> Option<SharedString> {
icon_theme
.file_icons
.get(typ)
.map(|icon_definition| icon_definition.path.clone())
}
get_icon_for_type(GlobalTheme::icon_theme(cx), typ).or_else(|| {
Self::default_icon_theme(cx).and_then(|icon_theme| get_icon_for_type(&icon_theme, typ))
})
}
pub fn get_folder_icon(expanded: bool, path: &Path, cx: &App) -> Option<SharedString> {
fn get_folder_icon(
icon_theme: &Arc<IconTheme>,
path: &Path,
expanded: bool,
) -> Option<SharedString> {
let name = path.file_name()?.to_str()?.trim();
if name.is_empty() {
return None;
}
let directory_icons = icon_theme.named_directory_icons.get(name)?;
if expanded {
directory_icons.expanded.clone()
} else {
directory_icons.collapsed.clone()
}
}
get_folder_icon(GlobalTheme::icon_theme(cx), path, expanded)
.or_else(|| {
Self::default_icon_theme(cx)
.and_then(|icon_theme| get_folder_icon(&icon_theme, path, expanded))
})
.or_else(|| {
// If we can't find a specific folder icon for the folder at the given path, fall back to the generic folder
// icon.
Self::get_generic_folder_icon(expanded, cx)
})
}
fn get_generic_folder_icon(expanded: bool, cx: &App) -> Option<SharedString> {
fn get_generic_folder_icon(
icon_theme: &Arc<IconTheme>,
expanded: bool,
) -> Option<SharedString> {
if expanded {
icon_theme.directory_icons.expanded.clone()
} else {
icon_theme.directory_icons.collapsed.clone()
}
}
get_generic_folder_icon(GlobalTheme::icon_theme(cx), expanded).or_else(|| {
Self::default_icon_theme(cx)
.and_then(|icon_theme| get_generic_folder_icon(&icon_theme, expanded))
})
}
pub fn get_chevron_icon(expanded: bool, cx: &App) -> Option<SharedString> {
fn get_chevron_icon(icon_theme: &Arc<IconTheme>, expanded: bool) -> Option<SharedString> {
if expanded {
icon_theme.chevron_icons.expanded.clone()
} else {
icon_theme.chevron_icons.collapsed.clone()
}
}
get_chevron_icon(GlobalTheme::icon_theme(cx), expanded).or_else(|| {
Self::default_icon_theme(cx)
.and_then(|icon_theme| get_chevron_icon(&icon_theme, expanded))
})
}
}