track monitor focus on mouse enter to empty workspaces
- SHA
ae7eded76fe2750057daaf472bdc2406291e162c- Parents
-
a1364c7 - Tree
5b9c907
ae7eded
ae7eded76fe2750057daaf472bdc2406291e162ca1364c7
5b9c907| Status | File | + | - |
|---|---|---|---|
| M |
gar/src/x11/connection.rs
|
2 | 1 |
| M |
gar/src/x11/events.rs
|
17 | 1 |
gar/src/x11/connection.rsmodified@@ -244,7 +244,8 @@ impl Connection { | |||
| 244 | EventMask::SUBSTRUCTURE_REDIRECT | 244 | EventMask::SUBSTRUCTURE_REDIRECT |
| 245 | | EventMask::SUBSTRUCTURE_NOTIFY | 245 | | EventMask::SUBSTRUCTURE_NOTIFY |
| 246 | | EventMask::STRUCTURE_NOTIFY | 246 | | EventMask::STRUCTURE_NOTIFY |
| 247 | - | EventMask::PROPERTY_CHANGE, | 247 | + | EventMask::PROPERTY_CHANGE |
| 248 | + | EventMask::ENTER_WINDOW, | ||
| 248 | ) | 249 | ) |
| 249 | .background_pixel(self.screen().black_pixel) | 250 | .background_pixel(self.screen().black_pixel) |
| 250 | .cursor(self.cursor_normal); | 251 | .cursor(self.cursor_normal); |
gar/src/x11/events.rsmodified@@ -1696,8 +1696,24 @@ impl WindowManager { | |||
| 1696 | return Ok(()); | 1696 | return Ok(()); |
| 1697 | } | 1697 | } |
| 1698 | 1698 | ||
| 1699 | - // Only focus windows we manage | 1699 | + // For unmanaged windows (root window / empty desktop areas), |
| 1700 | + // check if the pointer crossed to a different monitor and update | ||
| 1701 | + // focused workspace accordingly so garbar underline tracks correctly. | ||
| 1700 | if !self.windows.contains_key(&window) { | 1702 | if !self.windows.contains_key(&window) { |
| 1703 | + let monitor_idx = self.monitor_idx_at_point(event.root_x, event.root_y); | ||
| 1704 | + if monitor_idx != self.focused_monitor { | ||
| 1705 | + let old_workspace_idx = self.focused_workspace; | ||
| 1706 | + self.focused_monitor = monitor_idx; | ||
| 1707 | + let workspace_idx = self.monitors[monitor_idx].active_workspace; | ||
| 1708 | + self.focused_workspace = workspace_idx; | ||
| 1709 | + self.focused_window = None; | ||
| 1710 | + self.conn.set_active_window(None)?; | ||
| 1711 | + self.conn.set_current_desktop(workspace_idx as u32)?; | ||
| 1712 | + if workspace_idx != old_workspace_idx { | ||
| 1713 | + self.broadcast_i3_workspace_event("focus", workspace_idx, Some(old_workspace_idx)); | ||
| 1714 | + } | ||
| 1715 | + self.conn.flush()?; | ||
| 1716 | + } | ||
| 1701 | return Ok(()); | 1717 | return Ok(()); |
| 1702 | } | 1718 | } |
| 1703 | 1719 | ||