theme: add bar-position setting
This commit is contained in:
parent
3ea687a5c8
commit
2500c05f70
15 changed files with 178 additions and 32 deletions
|
|
@ -67,7 +67,7 @@ use {
|
|||
},
|
||||
keyboard::{Keymap, mods::Modifiers, syms::KeySym},
|
||||
logging::LogLevel,
|
||||
theme::{colors::Colorable, sized::Resizable},
|
||||
theme::{BarPosition, colors::Colorable, sized::Resizable},
|
||||
timer::Timer as JayTimer,
|
||||
video::{
|
||||
BlendSpace as ConfigBlendSpace, ColorSpace, Connector, DrmDevice, Eotf as ConfigEotf,
|
||||
|
|
@ -1392,6 +1392,17 @@ impl ConfigProxyHandler {
|
|||
});
|
||||
}
|
||||
|
||||
fn handle_set_bar_position(&self, position: BarPosition) {
|
||||
self.state.theme.bar_position.set(position);
|
||||
self.spaces_change();
|
||||
}
|
||||
|
||||
fn handle_get_bar_position(&self) {
|
||||
self.respond(Response::GetBarPosition {
|
||||
position: self.state.theme.bar_position.get(),
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_set_show_float_pin_icon(&self, show: bool) {
|
||||
self.state.show_pin_icon.set(show);
|
||||
for stacked in self.state.root.stacked.iter() {
|
||||
|
|
@ -3236,6 +3247,8 @@ impl ConfigProxyHandler {
|
|||
ClientMessage::GetShowBar => self.handle_get_show_bar(),
|
||||
ClientMessage::SetShowTitles { show } => self.handle_set_show_titles(show),
|
||||
ClientMessage::GetShowTitles => self.handle_get_show_titles(),
|
||||
ClientMessage::SetBarPosition { position } => self.handle_set_bar_position(position),
|
||||
ClientMessage::GetBarPosition => self.handle_get_bar_position(),
|
||||
ClientMessage::SeatFocusHistory { seat, timeline } => self
|
||||
.handle_seat_focus_history(seat, timeline)
|
||||
.wrn("seat_focus_history")?,
|
||||
|
|
|
|||
|
|
@ -135,7 +135,6 @@ impl<T: TrayItem> DynTrayItem for T {
|
|||
}
|
||||
|
||||
trait TrayItem: Sized + 'static {
|
||||
fn send_initial_configure(&self);
|
||||
fn send_current_configure(&self);
|
||||
fn data(&self) -> &TrayItemData;
|
||||
fn popups(&self) -> &CopyHashMap<XdgPopupId, Rc<Popup<Self>>>;
|
||||
|
|
@ -353,7 +352,7 @@ fn install<T: TrayItem>(item: &Rc<T>) -> Result<(), TrayItemError> {
|
|||
if let Some(node) = data.output.node() {
|
||||
data.surface
|
||||
.set_output(&node, NodeLocation::Output(node.id));
|
||||
item.send_initial_configure();
|
||||
item.send_current_configure();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ use {
|
|||
ack_configure, destroy, get_popup, install,
|
||||
},
|
||||
},
|
||||
xdg_positioner::{ANCHOR_BOTTOM_LEFT, ANCHOR_BOTTOM_RIGHT},
|
||||
xdg_positioner::{
|
||||
ANCHOR_BOTTOM_LEFT, ANCHOR_BOTTOM_RIGHT, ANCHOR_TOP_LEFT, ANCHOR_TOP_RIGHT,
|
||||
},
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
|
|
@ -17,6 +19,7 @@ use {
|
|||
utils::copyhashmap::CopyHashMap,
|
||||
wire::{JayTrayItemV1Id, XdgPopupId, jay_tray_item_v1::*},
|
||||
},
|
||||
jay_config::theme::BarPosition,
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
|
@ -59,16 +62,24 @@ impl JayTrayItemV1 {
|
|||
}
|
||||
|
||||
fn send_preferred_anchor(&self) {
|
||||
let anchor = match self.data.client.state.theme.bar_position.get() {
|
||||
BarPosition::Bottom => ANCHOR_TOP_RIGHT,
|
||||
BarPosition::Top | _ => ANCHOR_BOTTOM_RIGHT,
|
||||
};
|
||||
self.data.client.event(PreferredAnchor {
|
||||
self_id: self.id,
|
||||
anchor: ANCHOR_BOTTOM_LEFT,
|
||||
anchor,
|
||||
});
|
||||
}
|
||||
|
||||
fn send_preferred_gravity(&self) {
|
||||
let gravity = match self.data.client.state.theme.bar_position.get() {
|
||||
BarPosition::Bottom => ANCHOR_TOP_LEFT,
|
||||
BarPosition::Top | _ => ANCHOR_BOTTOM_LEFT,
|
||||
};
|
||||
self.data.client.event(PreferredGravity {
|
||||
self_id: self.id,
|
||||
gravity: ANCHOR_BOTTOM_RIGHT,
|
||||
gravity,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -106,13 +117,9 @@ impl JayTrayItemV1RequestHandler for JayTrayItemV1 {
|
|||
}
|
||||
|
||||
impl TrayItem for JayTrayItemV1 {
|
||||
fn send_initial_configure(&self) {
|
||||
fn send_current_configure(&self) {
|
||||
self.send_preferred_anchor();
|
||||
self.send_preferred_gravity();
|
||||
<Self as TrayItem>::send_current_configure(self);
|
||||
}
|
||||
|
||||
fn send_current_configure(&self) {
|
||||
let size = self.data.client.state.tray_icon_size().max(1);
|
||||
self.send_configure_size(size, size);
|
||||
self.send_configure();
|
||||
|
|
|
|||
|
|
@ -139,6 +139,8 @@ impl Renderer<'_> {
|
|||
self.state.color_manager.srgb_gamma22(),
|
||||
);
|
||||
}
|
||||
x += bar_rect.x1() - non_exclusive_rect_rel.x1();
|
||||
y += bar_rect.y1() - non_exclusive_rect_rel.y1();
|
||||
if let Some(status) = &rd.status
|
||||
&& let Some(texture) = status.tex.texture()
|
||||
{
|
||||
|
|
@ -159,16 +161,12 @@ impl Renderer<'_> {
|
|||
srgb_srgb,
|
||||
);
|
||||
}
|
||||
{
|
||||
x += bar_rect.x1() - non_exclusive_rect_rel.x1();
|
||||
y += bar_rect.y1() - non_exclusive_rect_rel.y1();
|
||||
for item in output.tray_items.iter() {
|
||||
let data = item.data();
|
||||
if data.surface.buffer.is_some() {
|
||||
let rect = data.rel_pos.get().move_(x, y);
|
||||
let bounds = self.base.scale_rect(rect);
|
||||
self.render_surface(&data.surface, rect.x1(), rect.y1(), Some(&bounds));
|
||||
}
|
||||
for item in output.tray_items.iter() {
|
||||
let data = item.data();
|
||||
if data.surface.buffer.is_some() {
|
||||
let rect = data.rel_pos.get().move_(x, y);
|
||||
let bounds = self.base.scale_rect(rect);
|
||||
self.render_surface(&data.surface, rect.x1(), rect.y1(), Some(&bounds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use {
|
|||
cmm::cmm_eotf::{Eotf, bt1886_eotf_args, bt1886_inv_eotf_args},
|
||||
utils::clonecell::CloneCell,
|
||||
},
|
||||
jay_config::theme::BarPosition,
|
||||
num_traits::Float,
|
||||
std::{cell::Cell, cmp::Ordering, ops::Mul, sync::Arc},
|
||||
};
|
||||
|
|
@ -467,6 +468,7 @@ pub struct Theme {
|
|||
pub title_font: CloneCell<Option<Arc<String>>>,
|
||||
pub default_font: Arc<String>,
|
||||
pub show_titles: Cell<bool>,
|
||||
pub bar_position: Cell<BarPosition>,
|
||||
}
|
||||
|
||||
impl Default for Theme {
|
||||
|
|
@ -480,6 +482,7 @@ impl Default for Theme {
|
|||
title_font: Default::default(),
|
||||
default_font,
|
||||
show_titles: Cell::new(true),
|
||||
bar_position: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
jay_config::{
|
||||
theme::BarPosition,
|
||||
video::{TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode},
|
||||
workspace::WorkspaceDisplayOrder,
|
||||
},
|
||||
|
|
@ -807,11 +808,23 @@ impl OutputNode {
|
|||
let mut workspace_rect_rel = non_exclusive_rect_rel;
|
||||
if self.state.show_bar.get() {
|
||||
let underline_rect;
|
||||
bar_rect = Rect::new_sized_unchecked(x1, y1, width, bh);
|
||||
underline_rect = Rect::new_sized_unchecked(x1, y1 + bh, width, 1);
|
||||
bar_rect_with_underline = Rect::new_sized_unchecked(x1, y1, width, bh + 1);
|
||||
workspace_rect =
|
||||
Rect::new_sized_unchecked(x1, y1 + bh + 1, width, (height - bh - 1).max(0));
|
||||
match self.state.theme.bar_position.get() {
|
||||
BarPosition::Bottom => {
|
||||
workspace_rect =
|
||||
Rect::new_sized_unchecked(x1, y1, width, (height - bh - 1).max(0));
|
||||
bar_rect_with_underline =
|
||||
Rect::new_sized_unchecked(x1, y1 + height - bh - 1, width, bh + 1);
|
||||
underline_rect = Rect::new_sized_unchecked(x1, y1 + height - bh - 1, width, 1);
|
||||
bar_rect = Rect::new_sized_unchecked(x1, y1 + height - bh, width, bh);
|
||||
}
|
||||
BarPosition::Top | _ => {
|
||||
bar_rect = Rect::new_sized_unchecked(x1, y1, width, bh);
|
||||
underline_rect = Rect::new_sized_unchecked(x1, y1 + bh, width, 1);
|
||||
bar_rect_with_underline = Rect::new_sized_unchecked(x1, y1, width, bh + 1);
|
||||
workspace_rect =
|
||||
Rect::new_sized_unchecked(x1, y1 + bh + 1, width, (height - bh - 1).max(0));
|
||||
}
|
||||
}
|
||||
bar_rect_rel = bar_rect.move_(-rect.x1(), -rect.y1());
|
||||
underline_rect_rel = underline_rect.move_(-rect.x1(), -rect.y1());
|
||||
workspace_rect_rel = workspace_rect.move_(-rect.x1(), -rect.y1());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue