logiguard fork v3: full patch set on verified 8c74db0 tree
Includes prior-session patches (carry forward so the app compiles): - crates/gpui/build.rs: cross-compile manifest fix - crates/gpui/src/platform.rs: PlatformWindow::activate_with_token trait method - crates/gpui/src/window.rs: Window::activate_with_token public API - crates/gpui_linux/src/linux/wayland/window.rs: WaylandWindow::activate_with_token + activate() keyboard-serial fix Plus the focus-serial fix: - serial.rs: SerialKind::KeyboardEnter - client.rs: store wl_keyboard.enter serial; latest_serial_of() Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
101
crates/gpui/examples/layer_shell.rs
Normal file
101
crates/gpui/examples/layer_shell.rs
Normal file
@@ -0,0 +1,101 @@
|
||||
#![cfg_attr(target_family = "wasm", no_main)]
|
||||
|
||||
fn run_example() {
|
||||
#[cfg(all(target_os = "linux", feature = "wayland"))]
|
||||
example::main();
|
||||
|
||||
#[cfg(not(all(target_os = "linux", feature = "wayland")))]
|
||||
panic!("This example requires the `wayland` feature and a linux system.");
|
||||
}
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
fn main() {
|
||||
run_example();
|
||||
}
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(start)]
|
||||
pub fn start() {
|
||||
gpui_platform::web_init();
|
||||
run_example();
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "wayland"))]
|
||||
mod example {
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use gpui::{
|
||||
App, Bounds, Context, FontWeight, Size, Window, WindowBackgroundAppearance, WindowBounds,
|
||||
WindowKind, WindowOptions, div, layer_shell::*, point, prelude::*, px, rems, rgba, white,
|
||||
};
|
||||
use gpui_platform::application;
|
||||
|
||||
struct LayerShellExample;
|
||||
|
||||
impl LayerShellExample {
|
||||
fn new(cx: &mut Context<Self>) -> Self {
|
||||
cx.spawn(async move |this, cx| {
|
||||
loop {
|
||||
let _ = this.update(cx, |_, cx| cx.notify());
|
||||
cx.background_executor()
|
||||
.timer(Duration::from_millis(500))
|
||||
.await;
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
LayerShellExample
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for LayerShellExample {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let now = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
|
||||
let hours = (now / 3600) % 24;
|
||||
let minutes = (now / 60) % 60;
|
||||
let seconds = now % 60;
|
||||
|
||||
div()
|
||||
.size_full()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.text_size(rems(4.5))
|
||||
.font_weight(FontWeight::EXTRA_BOLD)
|
||||
.text_color(white())
|
||||
.bg(rgba(0x0000044))
|
||||
.rounded_xl()
|
||||
.child(format!("{:02}:{:02}:{:02}", hours, minutes, seconds))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
application().run(|cx: &mut App| {
|
||||
cx.open_window(
|
||||
WindowOptions {
|
||||
titlebar: None,
|
||||
window_bounds: Some(WindowBounds::Windowed(Bounds {
|
||||
origin: point(px(0.), px(0.)),
|
||||
size: Size::new(px(500.), px(200.)),
|
||||
})),
|
||||
app_id: Some("gpui-layer-shell-example".to_string()),
|
||||
window_background: WindowBackgroundAppearance::Transparent,
|
||||
kind: WindowKind::LayerShell(LayerShellOptions {
|
||||
namespace: "gpui".to_string(),
|
||||
anchor: Anchor::LEFT | Anchor::RIGHT | Anchor::BOTTOM,
|
||||
margin: Some((px(0.), px(0.), px(40.), px(0.))),
|
||||
keyboard_interactivity: KeyboardInteractivity::None,
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
|_, cx| cx.new(LayerShellExample::new),
|
||||
)
|
||||
.unwrap();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user