formatting fixes
This commit is contained in:
parent
373eed4ac5
commit
1ab0196502
6 changed files with 140 additions and 94 deletions
151
src/debug.rs
151
src/debug.rs
|
|
@ -188,13 +188,28 @@ pub fn debug_ui(
|
||||||
.default_pos([300.0, 300.0])
|
.default_pos([300.0, 300.0])
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.label(format!("Global Space: {:?}", state.spaces.global_space()));
|
ui.label(format!("Global Space: {:?}", state.spaces.global_space()));
|
||||||
for output in state.spaces.outputs().cloned().collect::<Vec<_>>().into_iter() {
|
for output in state
|
||||||
|
.spaces
|
||||||
|
.outputs()
|
||||||
|
.cloned()
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.into_iter()
|
||||||
|
{
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.collapsing(output.name(), |ui| {
|
ui.collapsing(output.name(), |ui| {
|
||||||
ui.label(format!("Output: {:#?}", output));
|
ui.label(format!("Output: {:#?}", output));
|
||||||
ui.label(format!("Geometry: {:?}", state.spaces.output_geometry(&output)));
|
ui.label(format!(
|
||||||
ui.label(format!("Local Geometry: {:?}", state.spaces.active_space(&output).output_geometry(&output)));
|
"Geometry: {:?}",
|
||||||
ui.label(format!("Relative Geometry: {:?}", state.spaces.space_relative_output_geometry((0, 0), &output)));
|
state.spaces.output_geometry(&output)
|
||||||
|
));
|
||||||
|
ui.label(format!(
|
||||||
|
"Local Geometry: {:?}",
|
||||||
|
state.spaces.active_space(&output).output_geometry(&output)
|
||||||
|
));
|
||||||
|
ui.label(format!(
|
||||||
|
"Relative Geometry: {:?}",
|
||||||
|
state.spaces.space_relative_output_geometry((0, 0), &output)
|
||||||
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -220,52 +235,72 @@ pub fn log_ui(
|
||||||
Some(state.egui.log_state.run(
|
Some(state.egui.log_state.run(
|
||||||
|ctx| {
|
|ctx| {
|
||||||
egui::SidePanel::right("Log")
|
egui::SidePanel::right("Log")
|
||||||
.frame(egui::Frame {
|
.frame(egui::Frame {
|
||||||
margin: egui::Vec2::new(10.0, 10.0),
|
margin: egui::Vec2::new(10.0, 10.0),
|
||||||
corner_radius: 5.0,
|
corner_radius: 5.0,
|
||||||
shadow: egui::epaint::Shadow {
|
shadow: egui::epaint::Shadow {
|
||||||
extrusion: 0.0,
|
extrusion: 0.0,
|
||||||
color: egui::Color32::TRANSPARENT,
|
color: egui::Color32::TRANSPARENT,
|
||||||
},
|
},
|
||||||
fill: egui::Color32::from_black_alpha(100),
|
fill: egui::Color32::from_black_alpha(100),
|
||||||
stroke: egui::Stroke::none(),
|
stroke: egui::Stroke::none(),
|
||||||
})
|
})
|
||||||
|
.default_width(default_width)
|
||||||
.default_width(default_width)
|
.default_width(default_width)
|
||||||
.show(ctx, |ui| {
|
.default_width(default_width)
|
||||||
egui::ScrollArea::vertical()
|
.show(ctx, |ui| {
|
||||||
.always_show_scroll(true)
|
egui::ScrollArea::vertical()
|
||||||
.stick_to_bottom()
|
.always_show_scroll(true)
|
||||||
.show(ui, |ui| {
|
.stick_to_bottom()
|
||||||
for (i, record) in state.log.debug_buffer.lock().unwrap().iter().rev().enumerate() {
|
.show(ui, |ui| {
|
||||||
let mut message = egui::text::LayoutJob::single_section(
|
for (_i, record) in state
|
||||||
record.level.as_short_str().to_string(),
|
.log
|
||||||
egui::TextFormat::simple(egui::TextStyle::Monospace, match record.level {
|
.debug_buffer
|
||||||
slog::Level::Critical => egui::Color32::RED,
|
.lock()
|
||||||
slog::Level::Error => egui::Color32::LIGHT_RED,
|
.unwrap()
|
||||||
slog::Level::Warning => egui::Color32::LIGHT_YELLOW,
|
.iter()
|
||||||
slog::Level::Info => egui::Color32::LIGHT_BLUE,
|
.rev()
|
||||||
slog::Level::Debug => egui::Color32::LIGHT_GREEN,
|
.enumerate()
|
||||||
slog::Level::Trace => egui::Color32::GRAY,
|
{
|
||||||
})
|
let mut message = egui::text::LayoutJob::single_section(
|
||||||
);
|
record.level.as_short_str().to_string(),
|
||||||
message.append(&record.message, 6.0, egui::TextFormat::simple(
|
egui::TextFormat::simple(
|
||||||
egui::TextStyle::Body, egui::Color32::WHITE,
|
egui::TextStyle::Monospace,
|
||||||
));
|
match record.level {
|
||||||
ui.vertical(|ui| {
|
slog::Level::Critical => egui::Color32::RED,
|
||||||
ui.add(egui::Label::new(message));
|
slog::Level::Error => egui::Color32::LIGHT_RED,
|
||||||
ui.add_space(4.0);
|
slog::Level::Warning => egui::Color32::LIGHT_YELLOW,
|
||||||
for (k, v) in &record.kv {
|
slog::Level::Info => egui::Color32::LIGHT_BLUE,
|
||||||
ui.horizontal(|ui| {
|
slog::Level::Debug => egui::Color32::LIGHT_GREEN,
|
||||||
ui.add(egui::Label::new(egui::RichText::new(k).code())
|
slog::Level::Trace => egui::Color32::GRAY,
|
||||||
.sense(egui::Sense::click()))
|
},
|
||||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
),
|
||||||
render_value(ui, v);
|
);
|
||||||
|
message.append(
|
||||||
|
&record.message,
|
||||||
|
6.0,
|
||||||
|
egui::TextFormat::simple(
|
||||||
|
egui::TextStyle::Body,
|
||||||
|
egui::Color32::WHITE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.add(egui::Label::new(message));
|
||||||
|
ui.add_space(4.0);
|
||||||
|
for (k, v) in &record.kv {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.add(
|
||||||
|
egui::Label::new(egui::RichText::new(k).code())
|
||||||
|
.sense(egui::Sense::click()),
|
||||||
|
)
|
||||||
|
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||||
|
render_value(ui, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
});
|
||||||
})
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
area,
|
area,
|
||||||
scale,
|
scale,
|
||||||
|
|
@ -279,10 +314,18 @@ fn render_value(ui: &mut egui::Ui, value: &serde_json::Value) {
|
||||||
use serde_json::Value::*;
|
use serde_json::Value::*;
|
||||||
|
|
||||||
match value {
|
match value {
|
||||||
Null => { ui.label(egui::RichText::new("null").code()); },
|
Null => {
|
||||||
Bool(val) => { ui.label(egui::RichText::new(format!("{}", val)).code()); },
|
ui.label(egui::RichText::new("null").code());
|
||||||
Number(val) => { ui.label(egui::RichText::new(format!("{}", val)).code()); },
|
}
|
||||||
String(val) => { ui.label(val); },
|
Bool(val) => {
|
||||||
|
ui.label(egui::RichText::new(format!("{}", val)).code());
|
||||||
|
}
|
||||||
|
Number(val) => {
|
||||||
|
ui.label(egui::RichText::new(format!("{}", val)).code());
|
||||||
|
}
|
||||||
|
String(val) => {
|
||||||
|
ui.label(val);
|
||||||
|
}
|
||||||
Array(list) => {
|
Array(list) => {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.label("[");
|
ui.label("[");
|
||||||
|
|
@ -294,7 +337,7 @@ fn render_value(ui: &mut egui::Ui, value: &serde_json::Value) {
|
||||||
}
|
}
|
||||||
ui.label("]");
|
ui.label("]");
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
Object(map) => {
|
Object(map) => {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
for (k, val) in map {
|
for (k, val) in map {
|
||||||
|
|
@ -305,8 +348,6 @@ fn render_value(ui: &mut egui::Ui, value: &serde_json::Value) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -207,7 +207,9 @@ impl Common {
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
|modifiers, handle| {
|
|modifiers, handle| {
|
||||||
if state == KeyState::Released && userdata.get::<SupressedKeys>().unwrap().filter(&handle) {
|
if state == KeyState::Released
|
||||||
|
&& userdata.get::<SupressedKeys>().unwrap().filter(&handle)
|
||||||
|
{
|
||||||
return FilterResult::Intercept(());
|
return FilterResult::Intercept(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,14 +229,21 @@ impl Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
if modifiers.logo
|
if modifiers.logo
|
||||||
&& handle.raw_syms().iter().any(|sym| *sym >= keysyms::KEY_0 && *sym <= keysyms::KEY_9)
|
&& handle
|
||||||
|
.raw_syms()
|
||||||
|
.iter()
|
||||||
|
.any(|sym| *sym >= keysyms::KEY_0 && *sym <= keysyms::KEY_9)
|
||||||
&& state == KeyState::Pressed
|
&& state == KeyState::Pressed
|
||||||
{
|
{
|
||||||
let current_output = active_output(seat, &self);
|
let current_output = active_output(seat, &self);
|
||||||
let key_num = handle.raw_syms()
|
let key_num = handle
|
||||||
|
.raw_syms()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|sym| **sym >= keysyms::KEY_0 && **sym <= keysyms::KEY_9)
|
.find(|sym| {
|
||||||
.unwrap() - keysyms::KEY_0;
|
**sym >= keysyms::KEY_0 && **sym <= keysyms::KEY_9
|
||||||
|
})
|
||||||
|
.unwrap()
|
||||||
|
- keysyms::KEY_0;
|
||||||
let workspace = match key_num {
|
let workspace = match key_num {
|
||||||
0 => 9,
|
0 => 9,
|
||||||
x => x - 1,
|
x => x - 1,
|
||||||
|
|
@ -243,8 +252,9 @@ impl Common {
|
||||||
userdata.get::<SupressedKeys>().unwrap().add(&handle);
|
userdata.get::<SupressedKeys>().unwrap().add(&handle);
|
||||||
return FilterResult::Intercept(());
|
return FilterResult::Intercept(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if modifiers.logo && modifiers.shift
|
if modifiers.logo
|
||||||
|
&& modifiers.shift
|
||||||
&& handle.raw_syms().contains(&keysyms::KEY_Escape)
|
&& handle.raw_syms().contains(&keysyms::KEY_Escape)
|
||||||
&& state == KeyState::Pressed
|
&& state == KeyState::Pressed
|
||||||
{
|
{
|
||||||
|
|
@ -499,9 +509,7 @@ impl Common {
|
||||||
let device = event.device();
|
let device = event.device();
|
||||||
for seat in self.seats.clone().iter() {
|
for seat in self.seats.clone().iter() {
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
if self.seats.iter().position(|x| x == seat).unwrap() == 0
|
if self.seats.iter().position(|x| x == seat).unwrap() == 0 && self.egui.active {
|
||||||
&& self.egui.active
|
|
||||||
{
|
|
||||||
if self.egui.debug_state.wants_pointer() {
|
if self.egui.debug_state.wants_pointer() {
|
||||||
self.egui.debug_state.handle_pointer_axis(
|
self.egui.debug_state.handle_pointer_axis(
|
||||||
event
|
event
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,10 @@
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
sync::{Arc, Mutex, atomic::{AtomicBool, Ordering}},
|
sync::{
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
Arc, Mutex,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
@ -22,13 +25,13 @@ pub type LogBuffer = Arc<Mutex<VecDeque<OwnedRecord>>>;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct DebugDrain {
|
struct DebugDrain {
|
||||||
buffer: LogBuffer,
|
buffer: LogBuffer,
|
||||||
dirty_flag:Arc<AtomicBool>,
|
dirty_flag: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LogState {
|
pub struct LogState {
|
||||||
_guard: slog_scope::GlobalLoggerGuard,
|
_guard: slog_scope::GlobalLoggerGuard,
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
pub dirty_flag:Arc<AtomicBool>,
|
pub dirty_flag: Arc<AtomicBool>,
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
pub debug_buffer: LogBuffer,
|
pub debug_buffer: LogBuffer,
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +51,7 @@ impl DebugDrain {
|
||||||
(
|
(
|
||||||
DebugDrain {
|
DebugDrain {
|
||||||
buffer: buffer.clone(),
|
buffer: buffer.clone(),
|
||||||
dirty_flag: dirty_flag.clone()
|
dirty_flag: dirty_flag.clone(),
|
||||||
},
|
},
|
||||||
buffer,
|
buffer,
|
||||||
dirty_flag,
|
dirty_flag,
|
||||||
|
|
@ -64,14 +67,11 @@ impl Drain for DebugDrain {
|
||||||
fn log(
|
fn log(
|
||||||
&self,
|
&self,
|
||||||
record: &slog::Record<'_>,
|
record: &slog::Record<'_>,
|
||||||
values: &slog::OwnedKVList
|
values: &slog::OwnedKVList,
|
||||||
) -> Result<Self::Ok, Self::Err> {
|
) -> Result<Self::Ok, Self::Err> {
|
||||||
use slog::KV;
|
use serde_json::value::{Serializer as ValueSerializer, Value};
|
||||||
use serializer::SerdeSerializer;
|
use serializer::SerdeSerializer;
|
||||||
use serde_json::value::{
|
use slog::KV;
|
||||||
Serializer as ValueSerializer,
|
|
||||||
Value,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut serializer = SerdeSerializer::start(ValueSerializer, None)?;
|
let mut serializer = SerdeSerializer::start(ValueSerializer, None)?;
|
||||||
values.serialize(record, &mut serializer)?;
|
values.serialize(record, &mut serializer)?;
|
||||||
|
|
@ -116,7 +116,7 @@ pub fn init_logger() -> Result<LogState> {
|
||||||
std::sync::Mutex::new(
|
std::sync::Mutex::new(
|
||||||
slog_term::CompactFormat::new(decorator)
|
slog_term::CompactFormat::new(decorator)
|
||||||
.build()
|
.build()
|
||||||
.ignore_res()
|
.ignore_res(),
|
||||||
),
|
),
|
||||||
debug_drain,
|
debug_drain,
|
||||||
)
|
)
|
||||||
|
|
@ -142,4 +142,4 @@ pub fn init_logger() -> Result<LogState> {
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
dirty_flag,
|
dirty_flag,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,7 @@ where
|
||||||
fn emit_str(&mut self, key: Key, val: &str) -> slog::Result {
|
fn emit_str(&mut self, key: Key, val: &str) -> slog::Result {
|
||||||
impl_m!(self, key, &val)
|
impl_m!(self, key, &val)
|
||||||
}
|
}
|
||||||
fn emit_arguments(
|
fn emit_arguments(&mut self, key: Key, val: &fmt::Arguments) -> slog::Result {
|
||||||
&mut self,
|
|
||||||
key: Key,
|
|
||||||
val: &fmt::Arguments,
|
|
||||||
) -> slog::Result {
|
|
||||||
TL_BUF.with(|buf| {
|
TL_BUF.with(|buf| {
|
||||||
let mut buf = buf.borrow_mut();
|
let mut buf = buf.borrow_mut();
|
||||||
|
|
||||||
|
|
@ -132,4 +128,4 @@ where
|
||||||
res
|
res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,13 @@ use smithay::reexports::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use std::{
|
use std::{ffi::OsString, sync::atomic::Ordering};
|
||||||
ffi::OsString,
|
|
||||||
sync::atomic::Ordering,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
|
mod logger;
|
||||||
pub mod shell;
|
pub mod shell;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
mod logger;
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
|
|
|
||||||
16
src/state.rs
16
src/state.rs
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{kms::KmsState, winit::WinitState, x11::X11State},
|
backend::{kms::KmsState, winit::WinitState, x11::X11State},
|
||||||
shell::{init_shell, workspaces::Workspaces, ShellStates},
|
|
||||||
logger::LogState,
|
logger::LogState,
|
||||||
|
shell::{init_shell, workspaces::Workspaces, ShellStates},
|
||||||
};
|
};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
reexports::{
|
reexports::{
|
||||||
|
|
@ -127,7 +127,12 @@ pub fn get_dnd_icon(seat: &Seat) -> Option<WlSurface> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn new(mut display: Display, socket: OsString, handle: LoopHandle<'static, State>, log: LogState) -> State {
|
pub fn new(
|
||||||
|
mut display: Display,
|
||||||
|
socket: OsString,
|
||||||
|
handle: LoopHandle<'static, State>,
|
||||||
|
log: LogState,
|
||||||
|
) -> State {
|
||||||
init_shm_global(&mut display, vec![], None);
|
init_shm_global(&mut display, vec![], None);
|
||||||
init_xdg_output_manager(&mut display, None);
|
init_xdg_output_manager(&mut display, None);
|
||||||
let shell_handles = init_shell(&mut display);
|
let shell_handles = init_shell(&mut display);
|
||||||
|
|
@ -183,7 +188,8 @@ impl State {
|
||||||
egui: Egui {
|
egui: Egui {
|
||||||
debug_state: smithay_egui::EguiState::new(smithay_egui::EguiMode::Continuous),
|
debug_state: smithay_egui::EguiState::new(smithay_egui::EguiMode::Continuous),
|
||||||
log_state: {
|
log_state: {
|
||||||
let mut state = smithay_egui::EguiState::new(smithay_egui::EguiMode::Continuous);
|
let mut state =
|
||||||
|
smithay_egui::EguiState::new(smithay_egui::EguiMode::Continuous);
|
||||||
state.set_zindex(0);
|
state.set_zindex(0);
|
||||||
state
|
state
|
||||||
},
|
},
|
||||||
|
|
@ -251,9 +257,7 @@ impl Fps {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
let secs = match (self.frames.front(), self.frames.back()) {
|
let secs = match (self.frames.front(), self.frames.back()) {
|
||||||
(Some((start, _)), Some((end, dur))) => {
|
(Some((start, _)), Some((end, dur))) => end.duration_since(*start) + *dur,
|
||||||
end.duration_since(*start) + *dur
|
|
||||||
}
|
|
||||||
_ => Duration::ZERO,
|
_ => Duration::ZERO,
|
||||||
}
|
}
|
||||||
.as_secs_f64();
|
.as_secs_f64();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue