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,13 @@
[package]
name = "release_channel"
version = "0.1.0"
edition.workspace = true
publish.workspace = true
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
gpui.workspace = true
semver.workspace = true

View File

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

View File

@@ -0,0 +1,240 @@
//! Provides constructs for the Zed app version and release channel.
#![deny(missing_docs)]
use std::{env, str::FromStr, sync::LazyLock};
use gpui::{App, Global};
use semver::Version;
/// stable | dev | nightly | preview
pub static RELEASE_CHANNEL_NAME: LazyLock<String> = LazyLock::new(|| {
if cfg!(debug_assertions) {
env::var("ZED_RELEASE_CHANNEL")
.unwrap_or_else(|_| include_str!("../../zed/RELEASE_CHANNEL").trim().to_string())
} else {
include_str!("../../zed/RELEASE_CHANNEL").trim().to_string()
}
});
#[doc(hidden)]
pub static RELEASE_CHANNEL: LazyLock<ReleaseChannel> =
LazyLock::new(|| match ReleaseChannel::from_str(&RELEASE_CHANNEL_NAME) {
Ok(channel) => channel,
_ => panic!("invalid release channel {}", *RELEASE_CHANNEL_NAME),
});
/// The app identifier for the current release channel, Windows only.
#[cfg(target_os = "windows")]
pub fn app_identifier() -> &'static str {
match *RELEASE_CHANNEL {
ReleaseChannel::Dev => "Zed-Editor-Dev",
ReleaseChannel::Nightly => "Zed-Editor-Nightly",
ReleaseChannel::Preview => "Zed-Editor-Preview",
ReleaseChannel::Stable => "Zed-Editor-Stable",
}
}
/// The Git commit SHA that Zed was built at.
#[derive(Clone, Eq, Debug, PartialEq)]
pub struct AppCommitSha(String);
struct GlobalAppCommitSha(AppCommitSha);
impl Global for GlobalAppCommitSha {}
impl AppCommitSha {
/// Creates a new [`AppCommitSha`].
pub fn new(sha: String) -> Self {
AppCommitSha(sha)
}
/// Returns the global [`AppCommitSha`], if one is set.
pub fn try_global(cx: &App) -> Option<AppCommitSha> {
cx.try_global::<GlobalAppCommitSha>()
.map(|sha| sha.0.clone())
}
/// Sets the global [`AppCommitSha`].
pub fn set_global(sha: AppCommitSha, cx: &mut App) {
cx.set_global(GlobalAppCommitSha(sha))
}
/// Returns the full commit SHA.
pub fn full(&self) -> String {
self.0.to_string()
}
/// Returns the short (7 character) commit SHA.
pub fn short(&self) -> String {
self.0.chars().take(7).collect()
}
}
struct GlobalAppVersion(Version);
impl Global for GlobalAppVersion {}
/// The version of Zed.
pub struct AppVersion;
impl AppVersion {
/// Load the app version from env.
pub fn load(
pkg_version: &str,
build_id: Option<&str>,
commit_sha: Option<AppCommitSha>,
) -> Version {
let mut version: Version = if let Ok(from_env) = env::var("ZED_APP_VERSION") {
from_env.parse().expect("invalid ZED_APP_VERSION")
} else {
pkg_version.parse().expect("invalid version in Cargo.toml")
};
let mut pre = String::from(RELEASE_CHANNEL.dev_name());
if let Some(build_id) = build_id {
pre.push('.');
pre.push_str(&build_id);
}
if let Some(sha) = commit_sha {
pre.push('.');
pre.push_str(&sha.0);
}
if let Ok(build) = semver::BuildMetadata::new(&pre) {
version.build = build;
}
version
}
/// Returns the global version number.
pub fn global(cx: &App) -> Version {
if cx.has_global::<GlobalAppVersion>() {
cx.global::<GlobalAppVersion>().0.clone()
} else {
Version::new(0, 0, 0)
}
}
}
/// A Zed release channel.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
pub enum ReleaseChannel {
/// The development release channel.
///
/// Used for local debug builds of Zed.
#[default]
Dev,
/// The Nightly release channel.
Nightly,
/// The Preview release channel.
Preview,
/// The Stable release channel.
Stable,
}
struct GlobalReleaseChannel(ReleaseChannel);
impl Global for GlobalReleaseChannel {}
/// Initializes the release channel.
pub fn init(app_version: Version, cx: &mut App) {
cx.set_global(GlobalAppVersion(app_version));
cx.set_global(GlobalReleaseChannel(*RELEASE_CHANNEL))
}
/// Initializes the release channel for tests that rely on fake release channel.
pub fn init_test(app_version: Version, release_channel: ReleaseChannel, cx: &mut App) {
cx.set_global(GlobalAppVersion(app_version));
cx.set_global(GlobalReleaseChannel(release_channel))
}
impl ReleaseChannel {
/// All release channels.
pub const ALL: [ReleaseChannel; 4] = [
ReleaseChannel::Dev,
ReleaseChannel::Nightly,
ReleaseChannel::Preview,
ReleaseChannel::Stable,
];
/// Returns the global [`ReleaseChannel`].
pub fn global(cx: &App) -> Self {
cx.global::<GlobalReleaseChannel>().0
}
/// Returns the global [`ReleaseChannel`], if one is set.
pub fn try_global(cx: &App) -> Option<Self> {
cx.try_global::<GlobalReleaseChannel>()
.map(|channel| channel.0)
}
/// Returns whether we want to poll for updates for this [`ReleaseChannel`]
pub fn poll_for_updates(&self) -> bool {
!matches!(self, ReleaseChannel::Dev)
}
/// Returns the display name for this [`ReleaseChannel`].
pub fn display_name(&self) -> &'static str {
match self {
ReleaseChannel::Dev => "Zed Dev",
ReleaseChannel::Nightly => "Zed Nightly",
ReleaseChannel::Preview => "Zed Preview",
ReleaseChannel::Stable => "Zed",
}
}
/// Returns the programmatic name for this [`ReleaseChannel`].
pub fn dev_name(&self) -> &'static str {
match self {
ReleaseChannel::Dev => "dev",
ReleaseChannel::Nightly => "nightly",
ReleaseChannel::Preview => "preview",
ReleaseChannel::Stable => "stable",
}
}
/// Returns the application ID that's used by Wayland as application ID
/// and WM_CLASS on X11.
/// This also has to match the bundle identifier for Zed on macOS.
pub fn app_id(&self) -> &'static str {
match self {
ReleaseChannel::Dev => "dev.zed.Zed-Dev",
ReleaseChannel::Nightly => "dev.zed.Zed-Nightly",
ReleaseChannel::Preview => "dev.zed.Zed-Preview",
ReleaseChannel::Stable => "dev.zed.Zed",
}
}
/// Returns the query parameter for this [`ReleaseChannel`].
pub fn release_query_param(&self) -> Option<&'static str> {
match self {
Self::Dev => None,
Self::Nightly => Some("nightly=1"),
Self::Preview => Some("preview=1"),
Self::Stable => None,
}
}
}
/// Error indicating that release channel string does not match any known release channel names.
#[derive(Copy, Clone, Debug, Hash, PartialEq)]
pub struct InvalidReleaseChannel;
impl FromStr for ReleaseChannel {
type Err = InvalidReleaseChannel;
fn from_str(channel: &str) -> Result<Self, Self::Err> {
Ok(match channel {
"dev" => ReleaseChannel::Dev,
"nightly" => ReleaseChannel::Nightly,
"preview" => ReleaseChannel::Preview,
"stable" => ReleaseChannel::Stable,
_ => return Err(InvalidReleaseChannel),
})
}
}