mirror of
https://github.com/YaLTeR/niri.git
synced 2024-09-11 20:37:25 +03:00
Merge e9a93cae11
into a283c34dbb
This commit is contained in:
commit
812e6d7bfd
@ -499,7 +499,7 @@ pub enum Transform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Toplevel window.
|
/// Toplevel window.
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Eq, PartialEq, Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
/// Title, if set.
|
/// Title, if set.
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
@ -531,6 +531,8 @@ pub struct Workspace {
|
|||||||
pub output: Option<String>,
|
pub output: Option<String>,
|
||||||
/// Whether the workspace is currently active on its output.
|
/// Whether the workspace is currently active on its output.
|
||||||
pub is_active: bool,
|
pub is_active: bool,
|
||||||
|
/// The windows currently on this workspace
|
||||||
|
pub windows: Vec<Window>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for WorkspaceReferenceArg {
|
impl FromStr for WorkspaceReferenceArg {
|
||||||
|
@ -147,23 +147,12 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
|
|||||||
Response::Outputs(outputs.collect())
|
Response::Outputs(outputs.collect())
|
||||||
}
|
}
|
||||||
Request::FocusedWindow => {
|
Request::FocusedWindow => {
|
||||||
let window = ctx.ipc_focused_window.lock().unwrap().clone();
|
let window = ctx
|
||||||
let window = window.map(|window| {
|
.ipc_focused_window
|
||||||
let wl_surface = window.toplevel().expect("no X11 support").wl_surface();
|
.lock()
|
||||||
with_states(wl_surface, |states| {
|
.unwrap()
|
||||||
let role = states
|
.as_ref()
|
||||||
.data_map
|
.map(smithay_window_to_ipc);
|
||||||
.get::<XdgToplevelSurfaceData>()
|
|
||||||
.unwrap()
|
|
||||||
.lock()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
niri_ipc::Window {
|
|
||||||
title: role.title.clone(),
|
|
||||||
app_id: role.app_id.clone(),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
Response::FocusedWindow(window)
|
Response::FocusedWindow(window)
|
||||||
}
|
}
|
||||||
Request::Action(action) => {
|
Request::Action(action) => {
|
||||||
@ -239,3 +228,20 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
|
|||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn smithay_window_to_ipc(window: &smithay::desktop::Window) -> niri_ipc::Window {
|
||||||
|
let wl_surface = window.toplevel().expect("no X11 support").wl_surface();
|
||||||
|
with_states(wl_surface, |states| {
|
||||||
|
let role = states
|
||||||
|
.data_map
|
||||||
|
.get::<XdgToplevelSurfaceData>()
|
||||||
|
.unwrap()
|
||||||
|
.lock()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
niri_ipc::Window {
|
||||||
|
title: role.title.clone(),
|
||||||
|
app_id: role.app_id.clone(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -46,6 +46,7 @@ use smithay::utils::{Logical, Point, Scale, Serial, Size, Transform};
|
|||||||
pub use self::monitor::MonitorRenderElement;
|
pub use self::monitor::MonitorRenderElement;
|
||||||
use self::monitor::{Monitor, WorkspaceSwitch};
|
use self::monitor::{Monitor, WorkspaceSwitch};
|
||||||
use self::workspace::{compute_working_area, Column, ColumnWidth, OutputId, Workspace};
|
use self::workspace::{compute_working_area, Column, ColumnWidth, OutputId, Workspace};
|
||||||
|
use crate::ipc::server::smithay_window_to_ipc;
|
||||||
use crate::niri_render_elements;
|
use crate::niri_render_elements;
|
||||||
use crate::render_helpers::renderer::NiriRenderer;
|
use crate::render_helpers::renderer::NiriRenderer;
|
||||||
use crate::render_helpers::snapshot::RenderSnapshot;
|
use crate::render_helpers::snapshot::RenderSnapshot;
|
||||||
@ -53,7 +54,7 @@ use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderEleme
|
|||||||
use crate::render_helpers::texture::TextureBuffer;
|
use crate::render_helpers::texture::TextureBuffer;
|
||||||
use crate::render_helpers::{BakedBuffer, RenderTarget, SplitElements};
|
use crate::render_helpers::{BakedBuffer, RenderTarget, SplitElements};
|
||||||
use crate::utils::{output_size, round_logical_in_physical_max1, ResizeEdge};
|
use crate::utils::{output_size, round_logical_in_physical_max1, ResizeEdge};
|
||||||
use crate::window::ResolvedWindowRules;
|
use crate::window::{Mapped, ResolvedWindowRules};
|
||||||
|
|
||||||
pub mod closing_window;
|
pub mod closing_window;
|
||||||
pub mod focus_ring;
|
pub mod focus_ring;
|
||||||
@ -2470,7 +2471,9 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Layout<Mapped> {
|
||||||
pub fn ipc_workspaces(&self) -> Vec<niri_ipc::Workspace> {
|
pub fn ipc_workspaces(&self) -> Vec<niri_ipc::Workspace> {
|
||||||
match &self.monitor_set {
|
match &self.monitor_set {
|
||||||
MonitorSet::Normal {
|
MonitorSet::Normal {
|
||||||
@ -2487,6 +2490,10 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
name: workspace.name.clone(),
|
name: workspace.name.clone(),
|
||||||
output: Some(monitor.output.name()),
|
output: Some(monitor.output.name()),
|
||||||
is_active: monitor.active_workspace_idx == idx,
|
is_active: monitor.active_workspace_idx == idx,
|
||||||
|
windows: workspace
|
||||||
|
.windows()
|
||||||
|
.map(|mapped| smithay_window_to_ipc(&mapped.window))
|
||||||
|
.collect(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2501,6 +2508,10 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
name: ws.name.clone(),
|
name: ws.name.clone(),
|
||||||
output: None,
|
output: None,
|
||||||
is_active: false,
|
is_active: false,
|
||||||
|
windows: ws
|
||||||
|
.windows()
|
||||||
|
.map(|mapped| smithay_window_to_ipc(&mapped.window))
|
||||||
|
.collect(),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user