Hide all output mode behind WLDASH_ALL_OUTPUTS=1
This commit is contained in:
+68
-40
@@ -42,10 +42,11 @@ struct AppInner {
|
|||||||
shell: Option<zwlr_layer_shell_v1::ZwlrLayerShellV1>,
|
shell: Option<zwlr_layer_shell_v1::ZwlrLayerShellV1>,
|
||||||
dimensions: (u32, u32),
|
dimensions: (u32, u32),
|
||||||
draw_tx: Sender<bool>,
|
draw_tx: Sender<bool>,
|
||||||
|
all_outputs: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppInner {
|
impl AppInner {
|
||||||
fn new(tx: Sender<bool>) -> AppInner{
|
fn new(tx: Sender<bool>, all_outputs: bool) -> AppInner{
|
||||||
AppInner{
|
AppInner{
|
||||||
compositor: None,
|
compositor: None,
|
||||||
surfaces: Vec::new(),
|
surfaces: Vec::new(),
|
||||||
@@ -55,9 +56,54 @@ impl AppInner {
|
|||||||
shell: None,
|
shell: None,
|
||||||
dimensions: (0, 0),
|
dimensions: (0, 0),
|
||||||
draw_tx: tx,
|
draw_tx: tx,
|
||||||
|
all_outputs: all_outputs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_shell_surface(
|
||||||
|
compositor: &wl_compositor::WlCompositor,
|
||||||
|
shell: &zwlr_layer_shell_v1::ZwlrLayerShellV1,
|
||||||
|
dimensions: (u32, u32),
|
||||||
|
configured_surfaces: Arc<Mutex<usize>>,
|
||||||
|
tx: Sender<bool>,
|
||||||
|
output: Option<&wl_output::WlOutput>
|
||||||
|
) -> (
|
||||||
|
wl_surface::WlSurface,
|
||||||
|
zwlr_layer_surface_v1::ZwlrLayerSurfaceV1
|
||||||
|
) {
|
||||||
|
let surface = compositor
|
||||||
|
.create_surface(NewProxy::implement_dummy)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let shell_surface = shell
|
||||||
|
.get_layer_surface(
|
||||||
|
&surface,
|
||||||
|
output,
|
||||||
|
zwlr_layer_shell_v1::Layer::Overlay,
|
||||||
|
"".to_string(),
|
||||||
|
move |layer| {
|
||||||
|
layer.implement_closure(
|
||||||
|
move |evt, layer| match evt {
|
||||||
|
zwlr_layer_surface_v1::Event::Configure { serial, .. } => {
|
||||||
|
*(configured_surfaces.lock().unwrap()) += 1;
|
||||||
|
layer.ack_configure(serial);
|
||||||
|
tx.send(false).unwrap();
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
},
|
||||||
|
(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
shell_surface.set_keyboard_interactivity(1);
|
||||||
|
shell_surface.set_size(dimensions.0, dimensions.1);
|
||||||
|
|
||||||
|
surface.commit();
|
||||||
|
(surface, shell_surface)
|
||||||
|
}
|
||||||
|
|
||||||
fn outputs_changed(&mut self) {
|
fn outputs_changed(&mut self) {
|
||||||
let shell = match self.shell {
|
let shell = match self.shell {
|
||||||
Some(ref shell) => shell.to_owned(),
|
Some(ref shell) => shell.to_owned(),
|
||||||
@@ -68,6 +114,10 @@ impl AppInner {
|
|||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if !self.all_outputs && self.shell_surfaces.len() > 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for shell_surface in self.shell_surfaces.iter() {
|
for shell_surface in self.shell_surfaces.iter() {
|
||||||
shell_surface.destroy();
|
shell_surface.destroy();
|
||||||
}
|
}
|
||||||
@@ -75,46 +125,24 @@ impl AppInner {
|
|||||||
surface.destroy();
|
surface.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut surfaces = Vec::new();
|
|
||||||
let mut shell_surfaces = Vec::new();
|
|
||||||
self.configured_surfaces = Arc::new(Mutex::new(0));
|
self.configured_surfaces = Arc::new(Mutex::new(0));
|
||||||
for output in self.outputs.iter() {
|
|
||||||
let surface = compositor
|
|
||||||
.create_surface(NewProxy::implement_dummy)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let configured = self.configured_surfaces.clone();
|
if self.all_outputs {
|
||||||
let tx = self.draw_tx.clone();
|
let mut surfaces = Vec::new();
|
||||||
let shell_surface = shell
|
let mut shell_surfaces = Vec::new();
|
||||||
.get_layer_surface(
|
for output in self.outputs.iter() {
|
||||||
&surface,
|
let (surface, shell_surface) = AppInner::add_shell_surface(&compositor, &shell, self.dimensions, self.configured_surfaces.clone(), self.draw_tx.clone(), Some(&output.1));
|
||||||
Some(&output.1),
|
surfaces.push(surface);
|
||||||
zwlr_layer_shell_v1::Layer::Overlay,
|
shell_surfaces.push(shell_surface);
|
||||||
"".to_string(),
|
}
|
||||||
move |layer| {
|
self.surfaces = surfaces;
|
||||||
layer.implement_closure(
|
self.shell_surfaces = shell_surfaces;
|
||||||
move |evt, layer| match evt {
|
} else {
|
||||||
zwlr_layer_surface_v1::Event::Configure { serial, .. } => {
|
let (surface, shell_surface) = AppInner::add_shell_surface(&compositor, &shell, self.dimensions, self.configured_surfaces.clone(), self.draw_tx.clone(), None);
|
||||||
*(configured.lock().unwrap()) += 1;
|
self.surfaces = vec![surface];
|
||||||
layer.ack_configure(serial);
|
self.shell_surfaces = vec![shell_surface];
|
||||||
tx.send(false).unwrap();
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
},
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
shell_surface.set_keyboard_interactivity(1);
|
|
||||||
shell_surface.set_size(self.dimensions.0, self.dimensions.1);
|
|
||||||
surface.commit();
|
|
||||||
shell_surfaces.push(shell_surface);
|
|
||||||
surfaces.push(surface);
|
|
||||||
}
|
}
|
||||||
self.surfaces = surfaces;
|
|
||||||
self.shell_surfaces = shell_surfaces;
|
|
||||||
self.draw_tx.send(false).unwrap();
|
self.draw_tx.send(false).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,8 +291,8 @@ impl App {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(tx: Sender<bool>) -> App {
|
pub fn new(tx: Sender<bool>, all_outputs: bool) -> App {
|
||||||
let inner = Arc::new(Mutex::new(AppInner::new(tx.clone())));
|
let inner = Arc::new(Mutex::new(AppInner::new(tx.clone(), all_outputs)));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set up modules
|
// Set up modules
|
||||||
|
|||||||
+7
-1
@@ -1,6 +1,7 @@
|
|||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
use nix::poll::{poll, PollFd, PollFlags};
|
use nix::poll::{poll, PollFd, PollFlags};
|
||||||
use os_pipe::pipe;
|
use os_pipe::pipe;
|
||||||
@@ -17,7 +18,12 @@ fn main() {
|
|||||||
let (mut rx_pipe, mut tx_pipe) = pipe().unwrap();
|
let (mut rx_pipe, mut tx_pipe) = pipe().unwrap();
|
||||||
let (tx_draw, rx_draw) = channel();
|
let (tx_draw, rx_draw) = channel();
|
||||||
|
|
||||||
let mut app = App::new(tx_draw);
|
let all_outputs = match env::var("WLDASH_ALL_OUTPUTS") {
|
||||||
|
Ok(_) => true,
|
||||||
|
Err(_) => false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut app = App::new(tx_draw, all_outputs);
|
||||||
app.wipe();
|
app.wipe();
|
||||||
|
|
||||||
let worker_queue = app.cmd_queue();
|
let worker_queue = app.cmd_queue();
|
||||||
|
|||||||
Reference in New Issue
Block a user