tony / oxwm

feat: Implemntation of full screen mode Browse files
xsoder committed 2025-10-09 parent 5047795 commit 23428976e66d6420ab55dc0783a42f435e5fb20c
Showing 3 changed files with 70 additions and 9 deletions. UnifiedSplit
+11 −9 src/config.rs
@@ -6,15 +6,15 @@ use x11rb::protocol::xproto::KeyButMask;
6 // ======================================== 6 // ========================================
7 // APPEARANCE 7 // APPEARANCE
8 // ======================================== 8 // ========================================
9 -pub const BORDER_WIDTH: u32 = 0; 9 +pub const BORDER_WIDTH: u32 = 2;
10 pub const BORDER_FOCUSED: u32 = 0x6dade3; 10 pub const BORDER_FOCUSED: u32 = 0x6dade3;
11 pub const BORDER_UNFOCUSED: u32 = 0xbbbbbb; 11 pub const BORDER_UNFOCUSED: u32 = 0xbbbbbb;
12 -pub const FONT: &str = "IosevkaNerdFont:style=Bold:size=14"; 12 +pub const FONT: &str = "IosevkaNerdFont:style=Bold:size=10";
13 13
14 // ======================================== 14 // ========================================
15 // GAPS (Vanity Gaps) 15 // GAPS (Vanity Gaps)
16 // ======================================== 16 // ========================================
17 -pub const GAPS_ENABLED: bool = true; 17 +pub const GAPS_ENABLED: bool = false;
18 pub const GAP_INNER_HORIZONTAL: u32 = 3; 18 pub const GAP_INNER_HORIZONTAL: u32 = 3;
19 pub const GAP_INNER_VERTICAL: u32 = 3; 19 pub const GAP_INNER_VERTICAL: u32 = 3;
20 pub const GAP_OUTER_HORIZONTAL: u32 = 3; 20 pub const GAP_OUTER_HORIZONTAL: u32 = 3;
@@ -70,19 +70,19 @@ pub const SCHEME_SELECTED: ColorScheme = ColorScheme {
70 // Commands 70 // Commands
71 // ======================================== 71 // ========================================
72 const SCREENSHOT_CMD: &[&str] = &[ 72 const SCREENSHOT_CMD: &[&str] = &[
73 - "sh", 73 + "sh", "-c","/home/xsoder/scripts/screeshot",
74 - "-c",
75 - "maim -s | xclip -selection clipboard -t image/png",
76 ]; 74 ];
77 75
78 const DMENU_CMD: &[&str] = &["sh", "-c", "dmenu_run"]; 76 const DMENU_CMD: &[&str] = &["sh", "-c", "dmenu_run"];
77 +const ZOOM_CMD: &[&str] = &["sh", "-c", "boomer"];
78 +const SCRIPT_CMD: &[&str] = &["sh", "-c", "/home/xsoder/scripts/master"];
79 79
80 // ======================================== 80 // ========================================
81 // TAGS 81 // TAGS
82 // ======================================== 82 // ========================================
83 pub const TAG_COUNT: usize = 9; 83 pub const TAG_COUNT: usize = 9;
84 pub const TAGS: [&str; TAG_COUNT] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]; 84 pub const TAGS: [&str; TAG_COUNT] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
85 -// pub const TAGS: [&str; TAG_COUNT] = ["", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮"]; 85 +//pub const TAGS: [&str; TAG_COUNT] = ["", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮"];
86 // pub const TAGS: [&str; TAG_COUNT] = [ 86 // pub const TAGS: [&str; TAG_COUNT] = [
87 // "DEV", "WWW", "SYS", "DOC", "VBOX", "CHAT", "MUS", "VID", "MISC", 87 // "DEV", "WWW", "SYS", "DOC", "VBOX", "CHAT", "MUS", "VID", "MISC",
88 // ]; 88 // ];
@@ -93,11 +93,13 @@ pub const TAGS: [&str; TAG_COUNT] = ["1", "2", "3", "4", "5", "6", "7", "8", "9"
93 #[rustfmt::skip] 93 #[rustfmt::skip]
94 pub const KEYBINDINGS: &[Key] = &[ 94 pub const KEYBINDINGS: &[Key] = &[
95 Key::new(&[MODKEY], keycodes::RETURN, KeyAction::Spawn, Arg::Str(TERMINAL)), 95 Key::new(&[MODKEY], keycodes::RETURN, KeyAction::Spawn, Arg::Str(TERMINAL)),
96 - Key::new(&[MODKEY], keycodes::F, KeyAction::Spawn, Arg::Str(XCLOCK)),
97 96
98 - Key::new(&[MODKEY], keycodes::S, KeyAction::Spawn, Arg::Array(SCREENSHOT_CMD)),
99 Key::new(&[MODKEY], keycodes::D, KeyAction::Spawn, Arg::Array(DMENU_CMD)), 97 Key::new(&[MODKEY], keycodes::D, KeyAction::Spawn, Arg::Array(DMENU_CMD)),
98 + Key::new(&[MODKEY], keycodes::Z, KeyAction::Spawn, Arg::Array(ZOOM_CMD)),
99 + Key::new(&[MODKEY, SHIFT], keycodes::S, KeyAction::Spawn, Arg::Array(SCREENSHOT_CMD)),
100 + Key::new(&[MODKEY], keycodes::O, KeyAction::Spawn, Arg::Array(SCRIPT_CMD)),
100 Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None), 101 Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None),
102 + Key::new(&[MODKEY], keycodes::F, KeyAction::ToggleFullScreen, Arg::None),
101 Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None), 103 Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
102 Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None), 104 Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
103 Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None), 105 Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None),
+1 −0 src/keyboard/handlers.rs
@@ -12,6 +12,7 @@ pub enum KeyAction {
12 Restart, 12 Restart,
13 ViewTag, 13 ViewTag,
14 ToggleGaps, 14 ToggleGaps,
15 + ToggleFullScreen,
15 MoveToTag, 16 MoveToTag,
16 None, 17 None,
17 } 18 }
+58 −0 src/window_manager.rs
@@ -30,6 +30,7 @@ pub struct WindowManager {
30 window_tags: std::collections::HashMap<Window, TagMask>, 30 window_tags: std::collections::HashMap<Window, TagMask>,
31 selected_tags: TagMask, 31 selected_tags: TagMask,
32 gaps_enabled: bool, 32 gaps_enabled: bool,
33 + fullscreen_window: Option<Window>,
33 bar: Bar, 34 bar: Bar,
34 } 35 }
35 36
@@ -67,6 +68,7 @@ impl WindowManager {
67 window_tags: std::collections::HashMap::new(), 68 window_tags: std::collections::HashMap::new(),
68 selected_tags, 69 selected_tags,
69 gaps_enabled, 70 gaps_enabled,
71 + fullscreen_window: None,
70 bar, 72 bar,
71 }; 73 };
72 74
@@ -278,6 +280,46 @@ impl WindowManager {
278 } 280 }
279 } 281 }
280 282
283 + fn toggle_fullscreen(&mut self) -> Result<()> {
284 + if let Some(focused) = self.focused_window {
285 + if self.fullscreen_window == Some(focused) {
286 + // Exit fullscreen
287 + self.fullscreen_window = None;
288 +
289 + // Show bar
290 + self.connection.map_window(self.bar.window())?;
291 +
292 + // Restore normal layout
293 + self.apply_layout()?;
294 + self.update_focus_visuals()?;
295 + } else {
296 + // Enter fullscreen
297 + self.fullscreen_window = Some(focused);
298 +
299 + // Hide bar
300 + self.connection.unmap_window(self.bar.window())?;
301 +
302 + // Make window fill entire screen
303 + let screen_width = self.screen.width_in_pixels as u32;
304 + let screen_height = self.screen.height_in_pixels as u32;
305 +
306 + self.connection.configure_window(
307 + focused,
308 + &ConfigureWindowAux::new()
309 + .x(0)
310 + .y(0)
311 + .width(screen_width)
312 + .height(screen_height)
313 + .border_width(0)
314 + .stack_mode(StackMode::ABOVE), // This raises the window
315 + )?;
316 +
317 + self.connection.flush()?;
318 + }
319 + }
320 + Ok(())
321 + }
322 +
281 fn update_bar(&mut self) -> Result<()> { 323 fn update_bar(&mut self) -> Result<()> {
282 let mut occupied_tags: TagMask = 0; 324 let mut occupied_tags: TagMask = 0;
283 for &tags in self.window_tags.values() { 325 for &tags in self.window_tags.values() {
@@ -315,6 +357,9 @@ impl WindowManager {
315 } 357 }
316 } 358 }
317 } 359 }
360 + KeyAction::ToggleFullScreen => {
361 + self.toggle_fullscreen()?;
362 + }
318 KeyAction::FocusStack => { 363 KeyAction::FocusStack => {
319 if let Arg::Int(direction) = arg { 364 if let Arg::Int(direction) = arg {
320 self.cycle_focus(*direction)?; 365 self.cycle_focus(*direction)?;
@@ -377,6 +422,11 @@ impl WindowManager {
377 return Ok(()); 422 return Ok(());
378 } 423 }
379 424
425 + if self.fullscreen_window.is_some() {
426 + self.fullscreen_window = None;
427 + self.connection.map_window(self.bar.window())?;
428 + }
429 +
380 self.selected_tags = tag_mask(tag_index); 430 self.selected_tags = tag_mask(tag_index);
381 431
382 self.save_selected_tags()?; 432 self.save_selected_tags()?;
@@ -571,6 +621,9 @@ impl WindowManager {
571 } 621 }
572 622
573 fn apply_layout(&self) -> Result<()> { 623 fn apply_layout(&self) -> Result<()> {
624 + if self.fullscreen_window.is_some() {
625 + return Ok(());
626 + }
574 let screen_width = self.screen.width_in_pixels as u32; 627 let screen_width = self.screen.width_in_pixels as u32;
575 let screen_height = self.screen.height_in_pixels as u32; 628 let screen_height = self.screen.height_in_pixels as u32;
576 let border_width = BORDER_WIDTH; 629 let border_width = BORDER_WIDTH;
@@ -623,6 +676,11 @@ impl WindowManager {
623 self.windows.retain(|&w| w != window); 676 self.windows.retain(|&w| w != window);
624 self.window_tags.remove(&window); 677 self.window_tags.remove(&window);
625 678
679 + if self.fullscreen_window == Some(window) {
680 + self.fullscreen_window = None;
681 + self.connection.map_window(self.bar.window())?;
682 + }
683 +
626 if self.windows.len() < initial_count { 684 if self.windows.len() < initial_count {
627 if self.focused_window == Some(window) { 685 if self.focused_window == Some(window) {
628 let new_focus = if self.windows.is_empty() { 686 let new_focus = if self.windows.is_empty() {