tony / oxwm

updating padding Browse files
tonybanters committed 2025-10-03 parent c55f819 commit 9c46346da72cdd346c59dd6529a19fb5710d8c84
Showing 1 changed file with 10 additions and 11 deletions. UnifiedSplit
+10 −11 src/bar/bar.rs
@@ -32,7 +32,6 @@ impl Bar {
32 32 anyhow::bail!("Failed to open X11 display for XFT");
33 33 }
34 34 let font = Font::new(display, screen_num as i32, FONT)?;
35 -
36 35 let height = font.height() + 4;
37 36
38 37 connection.create_window(
@@ -68,13 +67,13 @@ impl Bar {
68 67
69 68 let font_draw = FontDraw::new(display, window as x11::xlib::Drawable, visual, colormap)?;
70 69
70 + let horizontal_padding = (font.height() as f32 * 0.6) as u16;
71 +
71 72 let tag_widths = TAGS
72 73 .iter()
73 74 .map(|tag| {
74 75 let text_width = font.text_width(tag);
75 - let left_padding = 10;
76 - let right_padding = 10;
77 - text_width + left_padding + right_padding
76 + text_width + (horizontal_padding * 2)
78 77 })
79 78 .collect();
80 79
@@ -145,9 +144,9 @@ impl Bar {
145 144 &SCHEME_NORMAL
146 145 };
147 146
147 + // Center text horizontally in tag box
148 148 let text_width = self.font.text_width(tag);
149 - let left_padding = (tag_width - text_width) / 2;
150 - let text_x = x_position + left_padding as i16;
149 + let text_x = x_position + ((tag_width - text_width) / 2) as i16;
151 150
152 151 let text_height = self.font.height();
153 152 let top_margin = (self.height as i16 - text_height as i16) / 4;
@@ -157,13 +156,13 @@ impl Bar {
157 156 .draw_text(&self.font, scheme.foreground, text_x, text_y, tag);
158 157
159 158 if is_selected {
160 - let underline_height = 3;
159 + // Scale underline thickness with font size (roughly 1/8 of font height)
160 + let underline_height = (self.font.height() / 8).max(2) as u16;
161 161 let bottom_margin = 4;
162 162 let underline_y = self.height as i16 - underline_height as i16 - bottom_margin;
163 163
164 - let text_width = self.font.text_width(tag);
165 - let underline_width = text_width + 4;
166 - let underline_x = x_position + ((tag_width - underline_width) / 2) as i16;
164 + // Make underline same width and position as text
165 + let underline_x = text_x;
167 166
168 167 connection.change_gc(
169 168 self.graphics_context,
@@ -175,7 +174,7 @@ impl Bar {
175 174 &[Rectangle {
176 175 x: underline_x,
177 176 y: underline_y,
178 - width: underline_width,
177 + width: text_width,
179 178 height: underline_height,
180 179 }],
181 180 )?;