formatting commit
This commit is contained in:
parent
c46f327384
commit
d78a06123f
6 changed files with 131 additions and 97 deletions
|
|
@ -4,8 +4,8 @@ use crate::state::State;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use smithay::reexports::calloop::EventLoop;
|
use smithay::reexports::calloop::EventLoop;
|
||||||
|
|
||||||
pub mod x11;
|
|
||||||
pub mod winit;
|
pub mod winit;
|
||||||
|
pub mod x11;
|
||||||
// TODO
|
// TODO
|
||||||
// pub mod wayland; // tbd in smithay
|
// pub mod wayland; // tbd in smithay
|
||||||
// pub mod udev;
|
// pub mod udev;
|
||||||
|
|
@ -15,17 +15,21 @@ pub fn init_backend_auto(event_loop: &mut EventLoop<State>, state: &mut State) -
|
||||||
Ok(x) if x == "x11" => x11::init_backend(event_loop, state),
|
Ok(x) if x == "x11" => x11::init_backend(event_loop, state),
|
||||||
Ok(x) if x == "winit" => winit::init_backend(event_loop, state),
|
Ok(x) if x == "winit" => winit::init_backend(event_loop, state),
|
||||||
Ok(_) => unimplemented!("There is no backend with this identifier"),
|
Ok(_) => unimplemented!("There is no backend with this identifier"),
|
||||||
Err(_) => if std::env::var_os("DISPLAY").is_some() || std::env::var_os("WAYLAND_DISPLAY").is_some() {
|
Err(_) => {
|
||||||
match x11::init_backend(event_loop, state) {
|
if std::env::var_os("DISPLAY").is_some()
|
||||||
Ok(_) => Ok(()),
|
|| std::env::var_os("WAYLAND_DISPLAY").is_some()
|
||||||
Err(err) => {
|
{
|
||||||
slog_scope::warn!("X11 Backend failed with error: {}", err);
|
match x11::init_backend(event_loop, state) {
|
||||||
slog_scope::info!("Falling back to winit backend.");
|
Ok(_) => Ok(()),
|
||||||
winit::init_backend(event_loop, state)
|
Err(err) => {
|
||||||
|
slog_scope::warn!("X11 Backend failed with error: {}", err);
|
||||||
|
slog_scope::info!("Falling back to winit backend.");
|
||||||
|
winit::init_backend(event_loop, state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
unimplemented!("Currently this runs only nested")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
unimplemented!("Currently this runs only nested")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use anyhow::{Context, Result};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
renderer::{ImportDma, ImportEgl},
|
renderer::{ImportDma, ImportEgl},
|
||||||
winit::{self, WinitGraphicsBackend, WinitEvent, WinitVirtualDevice},
|
winit::{self, WinitEvent, WinitGraphicsBackend, WinitVirtualDevice},
|
||||||
},
|
},
|
||||||
desktop::layer_map_for_output,
|
desktop::layer_map_for_output,
|
||||||
reexports::{
|
reexports::{
|
||||||
|
|
@ -24,15 +24,12 @@ use smithay::{
|
||||||
output::{Mode, Output, PhysicalProperties},
|
output::{Mode, Output, PhysicalProperties},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{cell::RefCell, rc::Rc};
|
||||||
cell::RefCell,
|
|
||||||
rc::Rc,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
use smithay::backend::renderer::gles2::Gles2Renderer;
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
use crate::{debug::debug_ui, state::Fps};
|
use crate::{debug::debug_ui, state::Fps};
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
use smithay::backend::renderer::gles2::Gles2Renderer;
|
||||||
|
|
||||||
pub struct WinitState {
|
pub struct WinitState {
|
||||||
// The winit backend currently has no notion of multiple windows
|
// The winit backend currently has no notion of multiple windows
|
||||||
|
|
@ -44,10 +41,7 @@ pub struct WinitState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WinitState {
|
impl WinitState {
|
||||||
pub fn render_output(
|
pub fn render_output(&mut self, state: &mut Common) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
state: &mut Common,
|
|
||||||
) -> Result<()> {
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
let mut custom_elements = Vec::new();
|
let mut custom_elements = Vec::new();
|
||||||
|
|
||||||
|
|
@ -94,11 +88,12 @@ impl WinitState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Result<()> {
|
pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Result<()> {
|
||||||
let (backend, mut input) = winit::init(None).with_context(|| "Failed to initilize winit backend")?;
|
let (backend, mut input) =
|
||||||
|
winit::init(None).with_context(|| "Failed to initilize winit backend")?;
|
||||||
let backend = Rc::new(RefCell::new(backend));
|
let backend = Rc::new(RefCell::new(backend));
|
||||||
|
|
||||||
init_egl_client_side(&mut *state.common.display.borrow_mut(), backend.clone())?;
|
init_egl_client_side(&mut *state.common.display.borrow_mut(), backend.clone())?;
|
||||||
|
|
||||||
let name = format!("WINIT-0");
|
let name = format!("WINIT-0");
|
||||||
let size = backend.borrow().window_size();
|
let size = backend.borrow().window_size();
|
||||||
let props = PhysicalProperties {
|
let props = PhysicalProperties {
|
||||||
|
|
@ -113,47 +108,54 @@ pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Res
|
||||||
};
|
};
|
||||||
let (output, _global) = Output::new(&mut *state.common.display.borrow_mut(), name, props, None);
|
let (output, _global) = Output::new(&mut *state.common.display.borrow_mut(), name, props, None);
|
||||||
//let _global = global.into();
|
//let _global = global.into();
|
||||||
output.change_current_state(Some(mode), Some(Transform::Flipped180), None, Some((0, 0).into()));
|
output.change_current_state(
|
||||||
|
Some(mode),
|
||||||
|
Some(Transform::Flipped180),
|
||||||
|
None,
|
||||||
|
Some((0, 0).into()),
|
||||||
|
);
|
||||||
output.set_preferred(mode);
|
output.set_preferred(mode);
|
||||||
|
|
||||||
state.common.spaces.map_output(&output);
|
state.common.spaces.map_output(&output);
|
||||||
|
|
||||||
let (event_ping, event_source) = ping::make_ping().with_context(|| "Failed to init eventloop timer for winit")?;
|
let (event_ping, event_source) =
|
||||||
let (render_ping, render_source) = ping::make_ping().with_context(|| "Failed to init eventloop timer for winit")?;
|
ping::make_ping().with_context(|| "Failed to init eventloop timer for winit")?;
|
||||||
|
let (render_ping, render_source) =
|
||||||
|
ping::make_ping().with_context(|| "Failed to init eventloop timer for winit")?;
|
||||||
let event_ping_handle = event_ping.clone();
|
let event_ping_handle = event_ping.clone();
|
||||||
let render_ping_handle = render_ping.clone();
|
let render_ping_handle = render_ping.clone();
|
||||||
let mut token = Some(event_loop
|
let mut token = Some(
|
||||||
.handle()
|
event_loop
|
||||||
.insert_source(
|
.handle()
|
||||||
render_source,
|
.insert_source(render_source, move |_, _, state| {
|
||||||
move |_, _, state| {
|
|
||||||
if let Err(err) = state.backend.winit().render_output(&mut state.common) {
|
if let Err(err) = state.backend.winit().render_output(&mut state.common) {
|
||||||
slog_scope::error!("Failed to render frame: {}", err);
|
slog_scope::error!("Failed to render frame: {}", err);
|
||||||
render_ping.ping();
|
render_ping.ping();
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
).map_err(|_| anyhow::anyhow!("Failed to init eventloop timer for winit"))?);
|
.map_err(|_| anyhow::anyhow!("Failed to init eventloop timer for winit"))?,
|
||||||
|
);
|
||||||
let event_loop_handle = event_loop.handle();
|
let event_loop_handle = event_loop.handle();
|
||||||
event_loop
|
event_loop
|
||||||
.handle()
|
.handle()
|
||||||
.insert_source(
|
.insert_source(event_source, move |_, _, state| {
|
||||||
event_source,
|
match input
|
||||||
move |_, _, state| {
|
.dispatch_new_events(|event| state.process_winit_event(event, &render_ping_handle))
|
||||||
match input.dispatch_new_events(|event| state.process_winit_event(event, &render_ping_handle)) {
|
{
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
event_ping_handle.ping();
|
event_ping_handle.ping();
|
||||||
render_ping_handle.ping();
|
render_ping_handle.ping();
|
||||||
},
|
}
|
||||||
Err(winit::WinitError::WindowClosed) => {
|
Err(winit::WinitError::WindowClosed) => {
|
||||||
let winit_state = state.backend.winit();
|
let winit_state = state.backend.winit();
|
||||||
state.common.spaces.unmap_output(&winit_state.output);
|
state.common.spaces.unmap_output(&winit_state.output);
|
||||||
if let Some(token) = token.take() {
|
if let Some(token) = token.take() {
|
||||||
event_loop_handle.remove(token);
|
event_loop_handle.remove(token);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
).map_err(|_| anyhow::anyhow!("Failed to init eventloop timer for winit"))?;
|
})
|
||||||
|
.map_err(|_| anyhow::anyhow!("Failed to init eventloop timer for winit"))?;
|
||||||
event_ping.ping();
|
event_ping.ping();
|
||||||
|
|
||||||
state.backend = BackendData::Winit(WinitState {
|
state.backend = BackendData::Winit(WinitState {
|
||||||
|
|
@ -162,11 +164,14 @@ pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Res
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
fps: Fps::default(),
|
fps: Fps::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_egl_client_side(display: &mut Display, renderer: Rc<RefCell<WinitGraphicsBackend>>) -> Result<()> {
|
fn init_egl_client_side(
|
||||||
|
display: &mut Display,
|
||||||
|
renderer: Rc<RefCell<WinitGraphicsBackend>>,
|
||||||
|
) -> Result<()> {
|
||||||
let bind_result = renderer.borrow_mut().renderer().bind_wl_display(display);
|
let bind_result = renderer.borrow_mut().renderer().bind_wl_display(display);
|
||||||
match bind_result {
|
match bind_result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
|
@ -180,7 +185,13 @@ fn init_egl_client_side(display: &mut Display, renderer: Rc<RefCell<WinitGraphic
|
||||||
init_dmabuf_global(
|
init_dmabuf_global(
|
||||||
display,
|
display,
|
||||||
dmabuf_formats,
|
dmabuf_formats,
|
||||||
move |buffer, _| renderer.borrow_mut().renderer().import_dmabuf(buffer).is_ok(),
|
move |buffer, _| {
|
||||||
|
renderer
|
||||||
|
.borrow_mut()
|
||||||
|
.renderer()
|
||||||
|
.import_dmabuf(buffer)
|
||||||
|
.is_ok()
|
||||||
|
},
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -215,10 +226,10 @@ impl State {
|
||||||
output.set_preferred(mode);
|
output.set_preferred(mode);
|
||||||
layer_map_for_output(output).arrange();
|
layer_map_for_output(output).arrange();
|
||||||
render_ping.ping();
|
render_ping.ping();
|
||||||
},
|
}
|
||||||
WinitEvent::Refresh => render_ping.ping(),
|
WinitEvent::Refresh => render_ping.ping(),
|
||||||
WinitEvent::Input(event) => self.common.process_input_event(event),
|
WinitEvent::Input(event) => self.common.process_input_event(event),
|
||||||
_ => {},
|
_ => {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,9 @@ impl X11State {
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|s| s.output == output_ref)
|
.find(|s| s.output == output_ref)
|
||||||
{
|
{
|
||||||
if let Err(err) = surface.render_output(
|
if let Err(err) = surface
|
||||||
&mut *x11_state.renderer.borrow_mut(),
|
.render_output(&mut *x11_state.renderer.borrow_mut(), &mut state.common)
|
||||||
&mut state.common,
|
{
|
||||||
) {
|
|
||||||
slog_scope::error!("Error rendering: {}", err);
|
slog_scope::error!("Error rendering: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
74
src/debug.rs
74
src/debug.rs
|
|
@ -1,10 +1,16 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use crate::state::{Common, Fps};
|
use crate::state::{Common, Fps};
|
||||||
|
use smithay::utils::{Logical, Rectangle};
|
||||||
use smithay_egui::EguiFrame;
|
use smithay_egui::EguiFrame;
|
||||||
use smithay::utils::{Rectangle, Logical};
|
|
||||||
|
|
||||||
pub fn debug_ui(state: &mut Common, fps: &Fps, area: Rectangle<i32, Logical>, scale: f64, primary: bool) -> EguiFrame {
|
pub fn debug_ui(
|
||||||
|
state: &mut Common,
|
||||||
|
fps: &Fps,
|
||||||
|
area: Rectangle<i32, Logical>,
|
||||||
|
scale: f64,
|
||||||
|
primary: bool,
|
||||||
|
) -> EguiFrame {
|
||||||
let size = area.size;
|
let size = area.size;
|
||||||
let alpha = state.egui.alpha;
|
let alpha = state.egui.alpha;
|
||||||
|
|
||||||
|
|
@ -32,7 +38,7 @@ pub fn debug_ui(state: &mut Common, fps: &Fps, area: Rectangle<i32, Logical>, sc
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
// FPS
|
// FPS
|
||||||
|
|
||||||
let (max, min, avg, avg_fps) = (
|
let (max, min, avg, avg_fps) = (
|
||||||
fps.max_frametime().as_secs_f64(),
|
fps.max_frametime().as_secs_f64(),
|
||||||
fps.min_frametime().as_secs_f64(),
|
fps.min_frametime().as_secs_f64(),
|
||||||
|
|
@ -48,11 +54,14 @@ pub fn debug_ui(state: &mut Common, fps: &Fps, area: Rectangle<i32, Logical>, sc
|
||||||
let fps_chart = BarChart::new(
|
let fps_chart = BarChart::new(
|
||||||
fps.frames
|
fps.frames
|
||||||
.iter()
|
.iter()
|
||||||
.rev().take(30).rev()
|
.rev()
|
||||||
|
.take(30)
|
||||||
|
.rev()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, d)| {
|
.map(|(i, d)| {
|
||||||
let value = d.as_secs_f64();
|
let value = d.as_secs_f64();
|
||||||
let transformed = ((value - min) / (max - min) * 255.0).round() as u8;
|
let transformed =
|
||||||
|
((value - min) / (max - min) * 255.0).round() as u8;
|
||||||
Bar::new(i as f64, value).fill(egui::Color32::from_rgb(
|
Bar::new(i as f64, value).fill(egui::Color32::from_rgb(
|
||||||
transformed,
|
transformed,
|
||||||
255 - transformed,
|
255 - transformed,
|
||||||
|
|
@ -74,21 +83,23 @@ pub fn debug_ui(state: &mut Common, fps: &Fps, area: Rectangle<i32, Logical>, sc
|
||||||
.show(ui, |plot_ui| {
|
.show(ui, |plot_ui| {
|
||||||
plot_ui.bar_chart(fps_chart);
|
plot_ui.bar_chart(fps_chart);
|
||||||
plot_ui.hline(
|
plot_ui.hline(
|
||||||
HLine::new(avg)
|
HLine::new(avg).highlight().color(egui::Color32::LIGHT_BLUE),
|
||||||
.highlight()
|
|
||||||
.color(egui::Color32::LIGHT_BLUE),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
// Toggles and stuff
|
// Toggles and stuff
|
||||||
ui.add(egui::Slider::new(&mut state.egui.alpha, 0.1..=1.0).clamp_to_range(true).text("Opacity"));
|
ui.add(
|
||||||
|
egui::Slider::new(&mut state.egui.alpha, 0.1..=1.0)
|
||||||
|
.clamp_to_range(true)
|
||||||
|
.text("Opacity"),
|
||||||
|
);
|
||||||
ui.checkbox(&mut state.egui.spaces, "Workspace UI");
|
ui.checkbox(&mut state.egui.spaces, "Workspace UI");
|
||||||
//TODO: ui.checkbox(&mut state.egui.outputs, "Outputs UI");
|
//TODO: ui.checkbox(&mut state.egui.outputs, "Outputs UI");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// don't show these one others then the primary monitor
|
// don't show these one others then the primary monitor
|
||||||
if primary {
|
if primary {
|
||||||
egui::Window::new("Workspaces")
|
egui::Window::new("Workspaces")
|
||||||
|
|
@ -99,11 +110,15 @@ pub fn debug_ui(state: &mut Common, fps: &Fps, area: Rectangle<i32, Logical>, sc
|
||||||
|
|
||||||
ui.set_min_width(250.0);
|
ui.set_min_width(250.0);
|
||||||
|
|
||||||
// Mode
|
// Mode
|
||||||
|
|
||||||
ui.label(egui::RichText::new("Mode").heading());
|
ui.label(egui::RichText::new("Mode").heading());
|
||||||
let mut mode = *state.spaces.mode();
|
let mut mode = *state.spaces.mode();
|
||||||
let active = if let Mode::Global { active } = mode { active } else { 0 };
|
let active = if let Mode::Global { active } = mode {
|
||||||
|
active
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
ui.radio_value(&mut mode, Mode::OutputBound, "Output bound");
|
ui.radio_value(&mut mode, Mode::OutputBound, "Output bound");
|
||||||
ui.radio_value(&mut mode, Mode::Global { active }, "Global");
|
ui.radio_value(&mut mode, Mode::Global { active }, "Global");
|
||||||
state.spaces.set_mode(mode);
|
state.spaces.set_mode(mode);
|
||||||
|
|
@ -121,20 +136,29 @@ pub fn debug_ui(state: &mut Common, fps: &Fps, area: Rectangle<i32, Logical>, sc
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut active_val = active as f64;
|
let mut active_val = active as f64;
|
||||||
ui.label(output.name());
|
ui.label(output.name());
|
||||||
ui.add(egui::DragValue::new(&mut active_val).clamp_range(0..=(MAX_WORKSPACES-1)).speed(1.0));
|
ui.add(
|
||||||
|
egui::DragValue::new(&mut active_val)
|
||||||
|
.clamp_range(0..=(MAX_WORKSPACES - 1))
|
||||||
|
.speed(1.0),
|
||||||
|
);
|
||||||
if active != active_val as usize {
|
if active != active_val as usize {
|
||||||
state.spaces.activate(&output, active_val as usize);
|
state.spaces.activate(&output, active_val as usize);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
Mode::Global { active } => {
|
Mode::Global { active } => {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let mut active_val = active as f64;
|
let mut active_val = active as f64;
|
||||||
ui.label("Workspace:");
|
ui.label("Workspace:");
|
||||||
ui.add(egui::DragValue::new(&mut active_val).clamp_range(0..=(MAX_WORKSPACES-1)).speed(1.0));
|
ui.add(
|
||||||
|
egui::DragValue::new(&mut active_val)
|
||||||
|
.clamp_range(0..=(MAX_WORKSPACES - 1))
|
||||||
|
.speed(1.0),
|
||||||
|
);
|
||||||
if active != active_val as usize {
|
if active != active_val as usize {
|
||||||
let output = state.spaces.outputs().next().cloned().unwrap();
|
let output =
|
||||||
|
state.spaces.outputs().next().cloned().unwrap();
|
||||||
state.spaces.activate(&output, active_val as usize);
|
state.spaces.activate(&output, active_val as usize);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -147,21 +171,25 @@ pub fn debug_ui(state: &mut Common, fps: &Fps, area: Rectangle<i32, Logical>, sc
|
||||||
ui.collapsing(format!("Windows"), |ui| {
|
ui.collapsing(format!("Windows"), |ui| {
|
||||||
for window in space.windows() {
|
for window in space.windows() {
|
||||||
ui.collapsing(format!("{:?}", window.toplevel()), |ui| {
|
ui.collapsing(format!("{:?}", window.toplevel()), |ui| {
|
||||||
ui.label(format!("Rect: {:?}", space.window_geometry(window)));
|
ui.label(format!(
|
||||||
ui.label(format!("Bounding box: {:?}", space.window_bbox(window)));
|
"Rect: {:?}",
|
||||||
|
space.window_geometry(window)
|
||||||
|
));
|
||||||
|
ui.label(format!(
|
||||||
|
"Bounding box: {:?}",
|
||||||
|
space.window_bbox(window)
|
||||||
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
egui::Window::new("Outputs")
|
egui::Window::new("Outputs")
|
||||||
.open(&mut state.egui.outputs)
|
.open(&mut state.egui.outputs)
|
||||||
.hscroll(true)
|
.hscroll(true)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {});
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
area,
|
area,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use crate::state::Common;
|
use crate::state::Common;
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
use smithay::{backend::input::KeyState, wayland::seat::keysyms};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::input::{Device, DeviceCapability, InputBackend, InputEvent},
|
backend::input::{Device, DeviceCapability, InputBackend, InputEvent},
|
||||||
desktop::{layer_map_for_output, Space},
|
desktop::{layer_map_for_output, Space},
|
||||||
|
|
@ -14,11 +16,6 @@ use smithay::{
|
||||||
SERIAL_COUNTER,
|
SERIAL_COUNTER,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
use smithay::{
|
|
||||||
backend::input::KeyState,
|
|
||||||
wayland::seat::keysyms,
|
|
||||||
};
|
|
||||||
use std::{cell::RefCell, collections::HashMap};
|
use std::{cell::RefCell, collections::HashMap};
|
||||||
|
|
||||||
pub struct ActiveOutput(pub RefCell<Output>);
|
pub struct ActiveOutput(pub RefCell<Output>);
|
||||||
|
|
@ -217,8 +214,7 @@ impl Common {
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
{
|
{
|
||||||
self.egui.modifiers = modifiers.clone();
|
self.egui.modifiers = modifiers.clone();
|
||||||
if self.seats.iter().position(|x| x == seat).unwrap()
|
if self.seats.iter().position(|x| x == seat).unwrap() == 0
|
||||||
== 0
|
|
||||||
&& modifiers.logo
|
&& modifiers.logo
|
||||||
&& handle.raw_syms().contains(&keysyms::KEY_Escape)
|
&& handle.raw_syms().contains(&keysyms::KEY_Escape)
|
||||||
&& state == KeyState::Pressed
|
&& state == KeyState::Pressed
|
||||||
|
|
@ -227,8 +223,7 @@ impl Common {
|
||||||
userdata.get::<SupressedKeys>().unwrap().add(&handle);
|
userdata.get::<SupressedKeys>().unwrap().add(&handle);
|
||||||
return FilterResult::Intercept(());
|
return FilterResult::Intercept(());
|
||||||
}
|
}
|
||||||
if self.seats.iter().position(|x| x == seat).unwrap()
|
if self.seats.iter().position(|x| x == seat).unwrap() == 0
|
||||||
== 0
|
|
||||||
&& self.egui.active
|
&& self.egui.active
|
||||||
&& self.egui.state.wants_keyboard()
|
&& self.egui.state.wants_keyboard()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{
|
backend::{winit::WinitState, x11::X11State},
|
||||||
x11::X11State,
|
|
||||||
winit::WinitState,
|
|
||||||
},
|
|
||||||
shell::{init_shell, workspaces::Workspaces, ShellStates},
|
shell::{init_shell, workspaces::Workspaces, ShellStates},
|
||||||
};
|
};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
|
|
@ -177,7 +174,7 @@ impl Default for Fps {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
pub fn avg_fps<'a>(iter: impl Iterator<Item=&'a Duration>) -> f64 {
|
pub fn avg_fps<'a>(iter: impl Iterator<Item = &'a Duration>) -> f64 {
|
||||||
let sum_secs = iter.map(|d| d.as_secs_f64()).sum::<f64>();
|
let sum_secs = iter.map(|d| d.as_secs_f64()).sum::<f64>();
|
||||||
1.0 / (sum_secs / Fps::WINDOW_SIZE as f64)
|
1.0 / (sum_secs / Fps::WINDOW_SIZE as f64)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue