@@ -25,6 +25,7 @@ use x11rb::protocol::xproto::{ |
| 25 | 25 | DestroyNotifyEvent, EventMask, MapNotifyEvent, PropertyNotifyEvent, |
| 26 | 26 | UnmapNotifyEvent, Window, |
| 27 | 27 | }; |
| 28 | +use x11rb::protocol::randr::{ConnectionExt as RandrConnectionExt, NotifyMask as RandrNotifyMask}; |
| 28 | 29 | use x11rb::protocol::Event; |
| 29 | 30 | |
| 30 | 31 | #[derive(Error, Debug)] |
@@ -102,6 +103,14 @@ impl Compositor { |
| 102 | 103 | &ChangeWindowAttributesAux::new().event_mask(event_mask), |
| 103 | 104 | )?; |
| 104 | 105 | |
| 106 | + // Subscribe to RandR screen change events (for rotation/resolution changes) |
| 107 | + if let Err(e) = conn.conn.randr_select_input( |
| 108 | + conn.root(), |
| 109 | + RandrNotifyMask::SCREEN_CHANGE, |
| 110 | + ) { |
| 111 | + tracing::warn!("Failed to subscribe to RandR events: {}", e); |
| 112 | + } |
| 113 | + |
| 105 | 114 | conn.flush()?; |
| 106 | 115 | |
| 107 | 116 | // Try to connect to gar |
@@ -475,6 +484,14 @@ impl Compositor { |
| 475 | 484 | Event::ConfigureNotify(e) => self.handle_configure(e)?, |
| 476 | 485 | Event::PropertyNotify(e) => self.handle_property(e)?, |
| 477 | 486 | Event::DamageNotify(e) => self.handle_damage(e), |
| 487 | + Event::RandrScreenChangeNotify(e) => { |
| 488 | + tracing::info!( |
| 489 | + "RandR screen change: {}x{} -> resizing compositor", |
| 490 | + e.width, e.height |
| 491 | + ); |
| 492 | + self.renderer.resize(e.width as u32, e.height as u32); |
| 493 | + self.needs_redraw = true; |
| 494 | + } |
| 478 | 495 | Event::Error(e) => { |
| 479 | 496 | tracing::warn!("X11 error: {:?}", e); |
| 480 | 497 | } |