mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Hide decoration globals when we need CSD
This gets the current SDL2 with libdecor working.
This commit is contained in:
@@ -25,9 +25,12 @@ impl ServiceChannel {
|
||||
}
|
||||
|
||||
let (sock1, sock2) = UnixStream::pair().unwrap();
|
||||
self.display
|
||||
.insert_client(sock2, Arc::new(ClientState::default()))
|
||||
.unwrap();
|
||||
let data = Arc::new(ClientState {
|
||||
compositor_state: Default::default(),
|
||||
// Would be nice to thread config here but for now it's fine.
|
||||
can_view_decoration_globals: false,
|
||||
});
|
||||
self.display.insert_client(sock2, data).unwrap();
|
||||
Ok(unsafe { zbus::zvariant::OwnedFd::from_raw_fd(sock1.into_raw_fd()) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,13 +277,9 @@ delegate_xdg_shell!(State);
|
||||
|
||||
impl XdgDecorationHandler for State {
|
||||
fn new_decoration(&mut self, toplevel: ToplevelSurface) {
|
||||
let mode = if self.niri.config.borrow().prefer_no_csd {
|
||||
Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
// If we want CSD, we hide this global altogether.
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = mode;
|
||||
state.decoration_mode = Some(zxdg_toplevel_decoration_v1::Mode::ServerSide);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -308,13 +304,9 @@ impl XdgDecorationHandler for State {
|
||||
}
|
||||
|
||||
fn unset_mode(&mut self, toplevel: ToplevelSurface) {
|
||||
let mode = if self.niri.config.borrow().prefer_no_csd {
|
||||
Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
// If we want CSD, we hide this global altogether.
|
||||
toplevel.with_pending_state(|state| {
|
||||
state.decoration_mode = mode;
|
||||
state.decoration_mode = Some(zxdg_toplevel_decoration_v1::Mode::ServerSide);
|
||||
});
|
||||
|
||||
// A configure is required in response to this event. However, if an initial configure
|
||||
|
||||
+22
-8
@@ -695,13 +695,22 @@ impl Niri {
|
||||
&display_handle,
|
||||
[WmCapabilities::Fullscreen],
|
||||
);
|
||||
let xdg_decoration_state = XdgDecorationState::new::<State>(&display_handle);
|
||||
let kde_decoration_state = KdeDecorationState::new::<State>(
|
||||
let xdg_decoration_state =
|
||||
XdgDecorationState::new_with_filter::<State, _>(&display_handle, |client| {
|
||||
client
|
||||
.get_data::<ClientState>()
|
||||
.unwrap()
|
||||
.can_view_decoration_globals
|
||||
});
|
||||
let kde_decoration_state = KdeDecorationState::new_with_filter::<State, _>(
|
||||
&display_handle,
|
||||
if config_.prefer_no_csd {
|
||||
KdeDecorationsMode::Server
|
||||
} else {
|
||||
KdeDecorationsMode::Client
|
||||
// If we want CSD we will hide the global.
|
||||
KdeDecorationsMode::Server,
|
||||
|client| {
|
||||
client
|
||||
.get_data::<ClientState>()
|
||||
.unwrap()
|
||||
.can_view_decoration_globals
|
||||
},
|
||||
);
|
||||
let layer_shell_state = WlrLayerShellState::new::<State>(&display_handle);
|
||||
@@ -768,7 +777,12 @@ impl Niri {
|
||||
let socket_name = socket_source.socket_name().to_os_string();
|
||||
event_loop
|
||||
.insert_source(socket_source, move |client, _, state| {
|
||||
let data = Arc::new(ClientState::default());
|
||||
let config = state.niri.config.borrow();
|
||||
let data = Arc::new(ClientState {
|
||||
compositor_state: Default::default(),
|
||||
can_view_decoration_globals: config.prefer_no_csd,
|
||||
});
|
||||
|
||||
if let Err(err) = state.niri.display_handle.insert_client(client, data) {
|
||||
error!("error inserting client: {err}");
|
||||
}
|
||||
@@ -2518,9 +2532,9 @@ impl Niri {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ClientState {
|
||||
pub compositor_state: CompositorClientState,
|
||||
pub can_view_decoration_globals: bool,
|
||||
}
|
||||
|
||||
impl ClientData for ClientState {
|
||||
|
||||
Reference in New Issue
Block a user