mirror of
https://github.com/wez/wezterm.git
synced 2024-08-17 10:10:23 +03:00
fix #4985 - reimplement get_appearance for wayland
- was dropped with wayland reimplementation (#4777, 3eaba4e3d6
)
- get appearance from xdg desktop portal
- advise all windows of appearance changes to reload config
This commit is contained in:
parent
888366a15d
commit
d70624b169
@ -13,7 +13,7 @@ use wayland_client::{Connection as WConnection, EventQueue};
|
||||
|
||||
use crate::screen::{ScreenInfo, Screens};
|
||||
use crate::spawn::SPAWN_QUEUE;
|
||||
use crate::{Connection, ConnectionOps, ScreenRect};
|
||||
use crate::{Appearance, Connection, ConnectionOps, ScreenRect};
|
||||
|
||||
use super::state::WaylandState;
|
||||
use super::WaylandWindowInner;
|
||||
@ -46,7 +46,11 @@ impl WaylandConnection {
|
||||
Ok(wayland_connection)
|
||||
}
|
||||
|
||||
pub(crate) fn advise_of_appearance_change(&self, _appearance: crate::Appearance) {}
|
||||
pub(crate) fn advise_of_appearance_change(&self, appearance: crate::Appearance) {
|
||||
for win in self.wayland_state.borrow().windows.borrow().values() {
|
||||
win.borrow_mut().appearance_changed(appearance);
|
||||
}
|
||||
}
|
||||
|
||||
fn run_message_loop_impl(&self) -> anyhow::Result<()> {
|
||||
const TOK_WL: usize = 0xffff_fffc;
|
||||
@ -172,6 +176,18 @@ impl ConnectionOps for WaylandConnection {
|
||||
res
|
||||
}
|
||||
|
||||
fn get_appearance(&self) -> Appearance {
|
||||
match promise::spawn::block_on(crate::os::xdg_desktop_portal::get_appearance()) {
|
||||
Ok(Some(appearance)) => return appearance,
|
||||
Ok(None) => {}
|
||||
Err(err) => {
|
||||
log::warn!("Unable to resolve appearance using xdg-desktop-portal: {err:#}");
|
||||
}
|
||||
}
|
||||
// fallback
|
||||
Appearance::Light
|
||||
}
|
||||
|
||||
fn screens(&self) -> anyhow::Result<crate::screen::Screens> {
|
||||
log::trace!("Getting screens for wayland connection");
|
||||
|
||||
|
@ -48,6 +48,7 @@ use wezterm_input_types::{
|
||||
use crate::wayland::WaylandConnection;
|
||||
use crate::x11::KeyboardWithFallback;
|
||||
use crate::{
|
||||
Appearance,
|
||||
Clipboard, Connection, ConnectionOps, Dimensions, MouseCursor, Point, Rect,
|
||||
RequestedWindowGeometry, ResizeIncrement, ResolvedGeometry, Window, WindowEvent,
|
||||
WindowEventSender, WindowKeyEvent, WindowOps, WindowState,
|
||||
@ -268,6 +269,8 @@ impl WaylandWindow {
|
||||
surface_to_pending.insert(surface.id(), Arc::clone(&pending_mouse));
|
||||
}
|
||||
|
||||
let appearance = conn.get_appearance();
|
||||
|
||||
let inner = Rc::new(RefCell::new(WaylandWindowInner {
|
||||
events: WindowEventSender::new(event_handler),
|
||||
surface_factor: 1.0,
|
||||
@ -294,6 +297,7 @@ impl WaylandWindow {
|
||||
frame_callback: None,
|
||||
|
||||
text_cursor: None,
|
||||
appearance,
|
||||
|
||||
config,
|
||||
|
||||
@ -525,7 +529,7 @@ pub struct WaylandWindowInner {
|
||||
invalidated: bool,
|
||||
// font_config: Rc<FontConfiguration>,
|
||||
text_cursor: Option<Rect>,
|
||||
// appearance: Appearance,
|
||||
appearance: Appearance,
|
||||
config: ConfigHandle,
|
||||
// cache the title for comparison to avoid spamming
|
||||
// the compositor with updates that don't actually change it
|
||||
@ -1083,6 +1087,14 @@ impl WaylandWindowInner {
|
||||
self.text_cursor.take();
|
||||
}
|
||||
|
||||
pub(crate) fn appearance_changed(&mut self, appearance: Appearance) {
|
||||
if appearance != self.appearance {
|
||||
self.appearance = appearance;
|
||||
self.events
|
||||
.dispatch(WindowEvent::AppearanceChanged(appearance));
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn keyboard_event(
|
||||
&mut self,
|
||||
mapper: &mut KeyboardWithFallback,
|
||||
|
Loading…
Reference in New Issue
Block a user