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 {
2274
         Ok(())
2274
         Ok(())
2275
     }
2275
     }
2276
 
2276
 
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
+
2277
     /// Execute an i3-compatible command (from IPC RUN_COMMAND).
2285
     /// Execute an i3-compatible command (from IPC RUN_COMMAND).
2278
     /// Returns true if the command was executed successfully.
2286
     /// Returns true if the command was executed successfully.
2279
     fn execute_i3_command(&mut self, cmd: &str) -> bool {
2287
     fn execute_i3_command(&mut self, cmd: &str) -> bool {
@@ -2832,6 +2840,18 @@ impl WindowManager {
2832
                     Err(e) => Response::error(e.to_string()),
2840
                     Err(e) => Response::error(e.to_string()),
2833
                 }
2841
                 }
2834
             }
2842
             }
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
+            }
2835
             "reload" => {
2855
             "reload" => {
2836
                 match self.reload_config() {
2856
                 match self.reload_config() {
2837
                     Ok(_) => Response::success(None),
2857
                     Ok(_) => Response::success(None),
garctl/src/main.rsmodified
@@ -49,6 +49,8 @@ enum Command {
49
     ToggleFloating,
49
     ToggleFloating,
50
     /// Equalize split ratios
50
     /// Equalize split ratios
51
     Equalize,
51
     Equalize,
52
+    /// Refresh window layout (re-apply without changing ratios)
53
+    RefreshLayout,
52
     /// Reload configuration
54
     /// Reload configuration
53
     Reload,
55
     Reload,
54
     /// Exit gar
56
     /// Exit gar
@@ -129,6 +131,9 @@ fn main() {
129
         Command::Equalize => {
131
         Command::Equalize => {
130
             json!({ "command": "equalize", "args": {} })
132
             json!({ "command": "equalize", "args": {} })
131
         }
133
         }
134
+        Command::RefreshLayout => {
135
+            json!({ "command": "refresh_layout", "args": {} })
136
+        }
132
         Command::Reload => {
137
         Command::Reload => {
133
             json!({ "command": "reload", "args": {} })
138
             json!({ "command": "reload", "args": {} })
134
         }
139
         }