Bug-Fix: Fixing the floating window to be centered by default
Browse files
+17 −2 src/window_manager.rs
| @@ -322,11 +322,26 @@ impl WindowManager { | |||
| 322 | self.floating_windows.remove(&focused); | 322 | self.floating_windows.remove(&focused); |
| 323 | self.apply_layout()?; | 323 | self.apply_layout()?; |
| 324 | } else { | 324 | } else { |
| 325 | - self.floating_windows.insert(focused); | 325 | + let float_width = (self.screen.width_in_pixels / 2) as u32; |
| 326 | + let float_height = (self.screen.height_in_pixels / 2) as u32; | ||
| 327 | + | ||
| 328 | + let border_width = self.config.border_width; | ||
| 329 | + | ||
| 330 | + let center_width = ((self.screen.width_in_pixels - float_width as u16)/2) as i32; | ||
| 331 | + let center_height = ((self.screen.height_in_pixels - float_height as u16)/2) as i32; | ||
| 332 | + | ||
| 326 | self.connection.configure_window( | 333 | self.connection.configure_window( |
| 327 | focused, | 334 | focused, |
| 328 | - &ConfigureWindowAux::new().stack_mode(StackMode::ABOVE), | 335 | + &ConfigureWindowAux::new() |
| 336 | + .x(center_width) | ||
| 337 | + .y(center_height) | ||
| 338 | + .width(float_width) | ||
| 339 | + .height(float_height) | ||
| 340 | + .border_width(border_width) | ||
| 341 | + .stack_mode(StackMode::ABOVE), | ||
| 329 | )?; | 342 | )?; |
| 343 | + | ||
| 344 | + self.floating_windows.insert(focused); | ||
| 330 | self.apply_layout()?; | 345 | self.apply_layout()?; |
| 331 | self.connection.flush()?; | 346 | self.connection.flush()?; |
| 332 | } | 347 | } |