gardesk/gar / efcbf6d

Browse files

transfer: add refresh_layout IPC command and garctl subcommand

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
efcbf6dec08901f0492c8500600181bcf98225dc
Parents
8661e62
Tree
c758812

2 changed files

StatusFile+-
M gar/src/x11/events.rs 20 0
M garctl/src/main.rs 5 0
gar/src/x11/events.rsmodified
@@ -2274,6 +2274,14 @@ impl WindowManager {
22742274
         Ok(())
22752275
     }
22762276
 
2277
+    /// Force refresh layout - just re-apply layout.
2278
+    /// Note: GTK apps may not fully re-render at new scale without restart.
2279
+    fn force_refresh_layout(&mut self) -> Result<()> {
2280
+        self.apply_layout()?;
2281
+        tracing::info!("Layout refreshed");
2282
+        Ok(())
2283
+    }
2284
+
22772285
     /// Execute an i3-compatible command (from IPC RUN_COMMAND).
22782286
     /// Returns true if the command was executed successfully.
22792287
     fn execute_i3_command(&mut self, cmd: &str) -> bool {
@@ -2832,6 +2840,18 @@ impl WindowManager {
28322840
                     Err(e) => Response::error(e.to_string()),
28332841
                 }
28342842
             }
2843
+            "refresh_layout" => {
2844
+                // Re-apply layout to all windows without changing ratios.
2845
+                // Useful after display scaling changes when GTK apps resize internally.
2846
+                // Two-step approach: first shrink windows, then expand - forces GTK to re-layout.
2847
+                match self.force_refresh_layout() {
2848
+                    Ok(_) => {
2849
+                        tracing::info!("Layout force-refreshed");
2850
+                        Response::success(None)
2851
+                    }
2852
+                    Err(e) => Response::error(e.to_string()),
2853
+                }
2854
+            }
28352855
             "reload" => {
28362856
                 match self.reload_config() {
28372857
                     Ok(_) => Response::success(None),
garctl/src/main.rsmodified
@@ -49,6 +49,8 @@ enum Command {
4949
     ToggleFloating,
5050
     /// Equalize split ratios
5151
     Equalize,
52
+    /// Refresh window layout (re-apply without changing ratios)
53
+    RefreshLayout,
5254
     /// Reload configuration
5355
     Reload,
5456
     /// Exit gar
@@ -129,6 +131,9 @@ fn main() {
129131
         Command::Equalize => {
130132
             json!({ "command": "equalize", "args": {} })
131133
         }
134
+        Command::RefreshLayout => {
135
+            json!({ "command": "refresh_layout", "args": {} })
136
+        }
132137
         Command::Reload => {
133138
             json!({ "command": "reload", "args": {} })
134139
         }