Skip to content

Commit ce2414f

Browse files
committed
X11: Do not report a parent window change back to the host
1 parent 71ae1ee commit ce2414f

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

examples/plugin_clack/src/gui.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> {
7777
fn can_resize(&mut self) -> bool {
7878
let Some(gui) = &self.gui else { return false };
7979

80+
dbg!("can_resize", gui.handle.is_resizable());
81+
8082
gui.handle.is_resizable()
8183
}
8284

src/platform/x11/event_loop.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ impl EventLoop {
171171
}
172172

173173
fn handle_coalesced_resize_events(&mut self) -> Result<(), FatalError> {
174+
let mut comes_from_parent = false;
174175
if let Some(new_parent_size) = self.new_parent_size.take() {
175176
if new_parent_size != self.window.get_size() {
176177
// The parent was resized, which means we should resize ourselves too.
@@ -180,6 +181,7 @@ impl EventLoop {
180181
// Makes the rest of this function run on the new parent size immediately (without waiting for a ConfigureNotify round-trip)
181182
// Also overrides any new sizes we may have received this event loop iteration,it would probably be invalidated anyway
182183
self.new_size = Some(new_parent_size);
184+
comes_from_parent = true;
183185
}
184186
}
185187
}
@@ -198,21 +200,24 @@ impl EventLoop {
198200
warn!("Window Handler failed to resize: {}", e);
199201
self.window.store_size(previous);
200202
self.window.xcb_window.resize(previous.cast())?.check_warn();
201-
} else {
202-
// Host requests use resize_immediately, which stops the previous == new_size condition
203-
// So if we're here, it's guaranteed not to be from a host request
203+
return Ok(());
204+
}
205+
206+
// Host requests use resize_immediately, which stops the previous == new_size condition
207+
// So if we're here, it's guaranteed not to be from a host request
204208

209+
if !comes_from_parent {
205210
if let Some(host) = self.main_thread.as_mut() {
206211
host.send(HostCallback::Resized {
207212
new_size,
208213
previous: WindowSize::from_physical(previous.cast(), scale_factor),
209214
})?;
210215
}
211-
212-
// Immediately schedule a redraw, do not wait for an "expose" event
213-
self.exposed = true;
214216
}
215217

218+
// Immediately schedule a redraw, do not wait for an "expose" event
219+
self.exposed = true;
220+
216221
Ok(())
217222
}
218223

0 commit comments

Comments
 (0)