Hide all output mode behind WLDASH_ALL_OUTPUTS=1
This commit is contained in:
+58
-30
@@ -42,10 +42,11 @@ struct AppInner {
|
||||
shell: Option<zwlr_layer_shell_v1::ZwlrLayerShellV1>,
|
||||
dimensions: (u32, u32),
|
||||
draw_tx: Sender<bool>,
|
||||
all_outputs: bool,
|
||||
}
|
||||
|
||||
impl AppInner {
|
||||
fn new(tx: Sender<bool>) -> AppInner{
|
||||
fn new(tx: Sender<bool>, all_outputs: bool) -> AppInner{
|
||||
AppInner{
|
||||
compositor: None,
|
||||
surfaces: Vec::new(),
|
||||
@@ -55,47 +56,36 @@ impl AppInner {
|
||||
shell: None,
|
||||
dimensions: (0, 0),
|
||||
draw_tx: tx,
|
||||
all_outputs: all_outputs,
|
||||
}
|
||||
}
|
||||
|
||||
fn outputs_changed(&mut self) {
|
||||
let shell = match self.shell {
|
||||
Some(ref shell) => shell.to_owned(),
|
||||
None => return,
|
||||
};
|
||||
let compositor = match self.compositor {
|
||||
Some(ref c) => c.to_owned(),
|
||||
None => return,
|
||||
};
|
||||
|
||||
for shell_surface in self.shell_surfaces.iter() {
|
||||
shell_surface.destroy();
|
||||
}
|
||||
for surface in self.surfaces.iter() {
|
||||
surface.destroy();
|
||||
}
|
||||
|
||||
let mut surfaces = Vec::new();
|
||||
let mut shell_surfaces = Vec::new();
|
||||
self.configured_surfaces = Arc::new(Mutex::new(0));
|
||||
for output in self.outputs.iter() {
|
||||
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 configured = self.configured_surfaces.clone();
|
||||
let tx = self.draw_tx.clone();
|
||||
let shell_surface = shell
|
||||
.get_layer_surface(
|
||||
&surface,
|
||||
Some(&output.1),
|
||||
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.lock().unwrap()) += 1;
|
||||
*(configured_surfaces.lock().unwrap()) += 1;
|
||||
layer.ack_configure(serial);
|
||||
tx.send(false).unwrap();
|
||||
}
|
||||
@@ -108,13 +98,51 @@ impl AppInner {
|
||||
.unwrap();
|
||||
|
||||
shell_surface.set_keyboard_interactivity(1);
|
||||
shell_surface.set_size(self.dimensions.0, self.dimensions.1);
|
||||
shell_surface.set_size(dimensions.0, dimensions.1);
|
||||
|
||||
surface.commit();
|
||||
shell_surfaces.push(shell_surface);
|
||||
(surface, shell_surface)
|
||||
}
|
||||
|
||||
fn outputs_changed(&mut self) {
|
||||
let shell = match self.shell {
|
||||
Some(ref shell) => shell.to_owned(),
|
||||
None => return,
|
||||
};
|
||||
let compositor = match self.compositor {
|
||||
Some(ref c) => c.to_owned(),
|
||||
None => return,
|
||||
};
|
||||
|
||||
if !self.all_outputs && self.shell_surfaces.len() > 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
for shell_surface in self.shell_surfaces.iter() {
|
||||
shell_surface.destroy();
|
||||
}
|
||||
for surface in self.surfaces.iter() {
|
||||
surface.destroy();
|
||||
}
|
||||
|
||||
self.configured_surfaces = Arc::new(Mutex::new(0));
|
||||
|
||||
if self.all_outputs {
|
||||
let mut surfaces = Vec::new();
|
||||
let mut shell_surfaces = Vec::new();
|
||||
for output in self.outputs.iter() {
|
||||
let (surface, shell_surface) = AppInner::add_shell_surface(&compositor, &shell, self.dimensions, self.configured_surfaces.clone(), self.draw_tx.clone(), Some(&output.1));
|
||||
surfaces.push(surface);
|
||||
shell_surfaces.push(shell_surface);
|
||||
}
|
||||
self.surfaces = surfaces;
|
||||
self.shell_surfaces = shell_surfaces;
|
||||
} else {
|
||||
let (surface, shell_surface) = AppInner::add_shell_surface(&compositor, &shell, self.dimensions, self.configured_surfaces.clone(), self.draw_tx.clone(), None);
|
||||
self.surfaces = vec![surface];
|
||||
self.shell_surfaces = vec![shell_surface];
|
||||
}
|
||||
|
||||
self.draw_tx.send(false).unwrap();
|
||||
}
|
||||
|
||||
@@ -263,8 +291,8 @@ impl App {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn new(tx: Sender<bool>) -> App {
|
||||
let inner = Arc::new(Mutex::new(AppInner::new(tx.clone())));
|
||||
pub fn new(tx: Sender<bool>, all_outputs: bool) -> App {
|
||||
let inner = Arc::new(Mutex::new(AppInner::new(tx.clone(), all_outputs)));
|
||||
|
||||
//
|
||||
// Set up modules
|
||||
|
||||
+7
-1
@@ -1,6 +1,7 @@
|
||||
use std::io::{Read, Write};
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::env;
|
||||
|
||||
use nix::poll::{poll, PollFd, PollFlags};
|
||||
use os_pipe::pipe;
|
||||
@@ -17,7 +18,12 @@ fn main() {
|
||||
let (mut rx_pipe, mut tx_pipe) = pipe().unwrap();
|
||||
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();
|
||||
|
||||
let worker_queue = app.cmd_queue();
|
||||
|
||||
Reference in New Issue
Block a user