static-text: add new utility
This commit is contained in:
parent
8f57f72d14
commit
97f7b68369
10 changed files with 150 additions and 15 deletions
|
|
@ -22,6 +22,7 @@ use {
|
|||
},
|
||||
},
|
||||
libinput::consts::DeviceCapability,
|
||||
utils::static_text::StaticText,
|
||||
video::drm::{
|
||||
ConnectorType, DRM_MODE_COLORIMETRY_BT2020_RGB, DRM_MODE_COLORIMETRY_DEFAULT,
|
||||
DrmConnector, DrmError, DrmVersion, HDMI_EOTF_SMPTE_ST2084,
|
||||
|
|
@ -278,6 +279,20 @@ pub enum InputDeviceCapability {
|
|||
Switch,
|
||||
}
|
||||
|
||||
impl StaticText for InputDeviceCapability {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
InputDeviceCapability::Keyboard => "keyboard",
|
||||
InputDeviceCapability::Pointer => "pointer",
|
||||
InputDeviceCapability::Touch => "touch",
|
||||
InputDeviceCapability::TabletTool => "tablet tool",
|
||||
InputDeviceCapability::TabletPad => "tablet pad",
|
||||
InputDeviceCapability::Gesture => "gesture",
|
||||
InputDeviceCapability::Switch => "switch",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InputDeviceCapability {
|
||||
pub fn to_libinput(self) -> DeviceCapability {
|
||||
use crate::libinput::consts::*;
|
||||
|
|
@ -299,6 +314,15 @@ pub enum InputDeviceAccelProfile {
|
|||
Adaptive,
|
||||
}
|
||||
|
||||
impl StaticText for InputDeviceAccelProfile {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
InputDeviceAccelProfile::Flat => "Flat",
|
||||
InputDeviceAccelProfile::Adaptive => "Adaptive",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum InputDeviceClickMethod {
|
||||
None,
|
||||
|
|
@ -306,6 +330,16 @@ pub enum InputDeviceClickMethod {
|
|||
Clickfinger,
|
||||
}
|
||||
|
||||
impl StaticText for InputDeviceClickMethod {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
InputDeviceClickMethod::None => "none",
|
||||
InputDeviceClickMethod::ButtonAreas => "button-areas",
|
||||
InputDeviceClickMethod::Clickfinger => "clickfinger",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum BackendEvent {
|
||||
NewDrmDevice(Rc<dyn BackendDrmDevice>),
|
||||
NewConnector(Rc<dyn Connector>),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use {
|
|||
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER, LIBINPUT_CONFIG_CLICK_METHOD_NONE,
|
||||
},
|
||||
tools::tool_client::{Handle, ToolClient, with_tool_client},
|
||||
utils::{errorfmt::ErrorFmt, string_ext::StringExt},
|
||||
utils::{errorfmt::ErrorFmt, static_text::StaticText, string_ext::StringExt},
|
||||
wire::{JayInputId, jay_compositor, jay_input},
|
||||
},
|
||||
clap::{Args, Subcommand, ValueEnum, ValueHint},
|
||||
|
|
@ -854,21 +854,11 @@ impl Input {
|
|||
print!("{prefix} capabilities:");
|
||||
let mut first = true;
|
||||
for cap in &device.capabilities {
|
||||
use InputDeviceCapability::*;
|
||||
print!(" ");
|
||||
if !mem::take(&mut first) {
|
||||
print!("| ");
|
||||
}
|
||||
let name = match cap {
|
||||
Keyboard => "keyboard",
|
||||
Pointer => "pointer",
|
||||
Touch => "touch",
|
||||
TabletTool => "tablet tool",
|
||||
TabletPad => "tablet pad",
|
||||
Gesture => "gesture",
|
||||
Switch => "switch",
|
||||
};
|
||||
print!("{}", name);
|
||||
print!("{}", cap.text());
|
||||
}
|
||||
println!();
|
||||
if let Some(v) = &device.accel_profile {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use {
|
|||
pending_serial::PendingSerial,
|
||||
pid_info::{PidInfo, get_pid_info, get_socket_creds},
|
||||
pidfd_send_signal::pidfd_send_signal,
|
||||
static_text::StaticText,
|
||||
},
|
||||
wire::WlRegistryId,
|
||||
},
|
||||
|
|
@ -68,6 +69,28 @@ bitflags! {
|
|||
CAP_GAMMA_CONTROL_MANAGER = 1 << 14,
|
||||
}
|
||||
|
||||
impl StaticText for ClientCapsEnum {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
ClientCapsEnum::CAP_DATA_CONTROL_MANAGER => "data-control",
|
||||
ClientCapsEnum::CAP_VIRTUAL_KEYBOARD_MANAGER => "virtual-keyboard",
|
||||
ClientCapsEnum::CAP_FOREIGN_TOPLEVEL_LIST => "foreign-toplevel-list",
|
||||
ClientCapsEnum::CAP_IDLE_NOTIFIER => "idle-notifier",
|
||||
ClientCapsEnum::CAP_SESSION_LOCK_MANAGER => "session-lock",
|
||||
ClientCapsEnum::CAP_JAY_COMPOSITOR => "jay-compositor",
|
||||
ClientCapsEnum::CAP_LAYER_SHELL => "layer-shell",
|
||||
ClientCapsEnum::CAP_SCREENCOPY_MANAGER => "screencopy",
|
||||
ClientCapsEnum::CAP_SEAT_MANAGER => "seat-manager",
|
||||
ClientCapsEnum::CAP_DRM_LEASE => "drm-lease",
|
||||
ClientCapsEnum::CAP_INPUT_METHOD => "input-method",
|
||||
ClientCapsEnum::CAP_WORKSPACE => "workspace-manager",
|
||||
ClientCapsEnum::CAP_FOREIGN_TOPLEVEL_MANAGER => "foreign-toplevel-manager",
|
||||
ClientCapsEnum::CAP_HEAD_MANAGER => "head-manager",
|
||||
ClientCapsEnum::CAP_GAMMA_CONTROL_MANAGER => "gamma-control-manager",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const CAPS_DEFAULT: ClientCaps = ClientCaps(CAP_LAYER_SHELL.0 | CAP_DRM_LEASE.0);
|
||||
pub const CAPS_DEFAULT_SANDBOXED: ClientCaps = ClientCaps(CAP_DRM_LEASE.0);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ use {
|
|||
rc_eq::RcEq,
|
||||
refcounted::RefCounted,
|
||||
run_toplevel::RunToplevel,
|
||||
static_text::StaticText,
|
||||
tri::Try,
|
||||
},
|
||||
version::VERSION,
|
||||
|
|
@ -850,6 +851,19 @@ impl From<LevelFilter> for LogLevel {
|
|||
}
|
||||
}
|
||||
|
||||
impl StaticText for LogLevel {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
LogLevel::Off => "Off",
|
||||
LogLevel::Error => "Error",
|
||||
LogLevel::Warn => "Warn",
|
||||
LogLevel::Info => "Info",
|
||||
LogLevel::Debug => "Debug",
|
||||
LogLevel::Trace => "Trace",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ConfigLogLevel> for LogLevel {
|
||||
fn from(value: ConfigLogLevel) -> Self {
|
||||
match value {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use {
|
|||
state::State,
|
||||
theme::Color,
|
||||
tree::{Node, OutputNode, Transform},
|
||||
utils::{clonecell::UnsafeCellCloneSafe, errorfmt::ErrorFmt},
|
||||
utils::{clonecell::UnsafeCellCloneSafe, errorfmt::ErrorFmt, static_text::StaticText},
|
||||
video::{
|
||||
Modifier,
|
||||
dmabuf::DmaBuf,
|
||||
|
|
@ -47,6 +47,12 @@ pub enum GfxApi {
|
|||
Vulkan,
|
||||
}
|
||||
|
||||
impl StaticText for GfxApi {
|
||||
fn text(&self) -> &'static str {
|
||||
self.to_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<ConfigGfxApi> for GfxApi {
|
||||
type Error = ();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use {
|
|||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::static_text::StaticText,
|
||||
wire::{WpContentTypeV1Id, wp_content_type_v1::*},
|
||||
},
|
||||
jay_config::window::{
|
||||
|
|
@ -26,6 +27,16 @@ pub enum ContentType {
|
|||
Game,
|
||||
}
|
||||
|
||||
impl StaticText for ContentType {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Photo => "Photo",
|
||||
Self::Video => "Video",
|
||||
Self::Game => "Game",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ContentTypeExt {
|
||||
fn to_config(&self) -> ConfigContentType;
|
||||
}
|
||||
|
|
|
|||
46
src/theme.rs
46
src/theme.rs
|
|
@ -4,7 +4,7 @@ use {
|
|||
crate::{
|
||||
cmm::cmm_eotf::{Eotf, bt1886_eotf_args, bt1886_inv_eotf_args},
|
||||
gfx_api::AlphaMode,
|
||||
utils::clonecell::CloneCell,
|
||||
utils::{clonecell::CloneCell, static_text::StaticText},
|
||||
},
|
||||
jay_config::theme::BarPosition as ConfigBarPosition,
|
||||
linearize::Linearize,
|
||||
|
|
@ -456,6 +456,30 @@ colors! {
|
|||
highlight = (0x9d, 0x28, 0xc6, 0x7f),
|
||||
}
|
||||
|
||||
impl StaticText for ThemeColor {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
ThemeColor::background => "Background",
|
||||
ThemeColor::unfocused_title_background => "Title Background (unfocused)",
|
||||
ThemeColor::focused_title_background => "Title Background (focused)",
|
||||
ThemeColor::captured_unfocused_title_background => {
|
||||
"Title Background (unfocused, captured)"
|
||||
}
|
||||
ThemeColor::captured_focused_title_background => "Title Background (focused, captured)",
|
||||
ThemeColor::focused_inactive_title_background => "Title Background (focused, inactive)",
|
||||
ThemeColor::unfocused_title_text => "Title Text (unfocused)",
|
||||
ThemeColor::focused_title_text => "Title Text (focused)",
|
||||
ThemeColor::focused_inactive_title_text => "Title Text (focused, inactive)",
|
||||
ThemeColor::separator => "Separator",
|
||||
ThemeColor::border => "Border",
|
||||
ThemeColor::bar_background => "Bar Background",
|
||||
ThemeColor::bar_text => "Bar Text",
|
||||
ThemeColor::attention_requested_background => "Attention Requested",
|
||||
ThemeColor::highlight => "Highlight",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ThemeSize {
|
||||
pub val: Cell<i32>,
|
||||
pub set: Cell<bool>,
|
||||
|
|
@ -564,6 +588,17 @@ sizes! {
|
|||
bar_separator_width = (0, 1000, 1),
|
||||
}
|
||||
|
||||
impl StaticText for ThemeSized {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
ThemeSized::title_height => "Title Height",
|
||||
ThemeSized::bar_height => "Bar Height",
|
||||
ThemeSized::border_width => "Border Width",
|
||||
ThemeSized::bar_separator_width => "Bar Separator Width",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const DEFAULT_FONT: &str = "monospace 8";
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default, Linearize)]
|
||||
|
|
@ -573,6 +608,15 @@ pub enum BarPosition {
|
|||
Bottom,
|
||||
}
|
||||
|
||||
impl StaticText for BarPosition {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
BarPosition::Top => "Top",
|
||||
BarPosition::Bottom => "Bottom",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<ConfigBarPosition> for BarPosition {
|
||||
type Error = ();
|
||||
|
||||
|
|
|
|||
11
src/tree.rs
11
src/tree.rs
|
|
@ -25,7 +25,7 @@ use {
|
|||
keyboard::KeyboardState,
|
||||
rect::Rect,
|
||||
renderer::Renderer,
|
||||
utils::{linkedlist::NodeRef, numcell::NumCell},
|
||||
utils::{linkedlist::NodeRef, numcell::NumCell, static_text::StaticText},
|
||||
},
|
||||
jay_config::{
|
||||
Direction as JayDirection, video::Transform as ConfigTransform,
|
||||
|
|
@ -79,6 +79,15 @@ impl Into<ConfigWorkspaceDisplayOrder> for WorkspaceDisplayOrder {
|
|||
}
|
||||
}
|
||||
|
||||
impl StaticText for WorkspaceDisplayOrder {
|
||||
fn text(&self) -> &'static str {
|
||||
match self {
|
||||
WorkspaceDisplayOrder::Manual => "Manual",
|
||||
WorkspaceDisplayOrder::Sorted => "Sorted",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default, Linearize)]
|
||||
pub enum Transform {
|
||||
#[default]
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ pub mod run_toplevel;
|
|||
pub mod scroller;
|
||||
pub mod smallmap;
|
||||
pub mod stack;
|
||||
pub mod static_text;
|
||||
pub mod string_ext;
|
||||
pub mod syncqueue;
|
||||
pub mod threshold_counter;
|
||||
|
|
|
|||
3
src/utils/static_text.rs
Normal file
3
src/utils/static_text.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pub trait StaticText {
|
||||
fn text(&self) -> &'static str;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue