Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux/x11: Ignore bounds.origin on resize event #12604

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions crates/gpui/src/platform/linux/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use x11rb::{
use std::{
cell::RefCell,
ffi::c_void,
mem,
num::NonZeroU32,
ops::Div,
ptr::NonNull,
Expand Down Expand Up @@ -610,11 +609,21 @@ impl X11WindowStatePtr {

pub fn configure(&self, bounds: Bounds<i32>) {
let mut resize_args = None;
let do_move;
let is_resize;
{
let mut state = self.state.borrow_mut();
let old_bounds = mem::replace(&mut state.bounds, bounds);
do_move = old_bounds.origin != bounds.origin;

is_resize = bounds.size.width != state.bounds.size.width
|| bounds.size.height != state.bounds.size.height;

// If it's a resize event (only width/height changed), we ignore `bounds.origin`
// because it contains wrong values.
if is_resize {
state.bounds.size = bounds.size;
} else {
state.bounds = bounds;
}

let gpu_size = query_render_extent(&self.xcb_connection, self.x_window);
if state.renderer.viewport_size() != gpu_size {
state
Expand All @@ -630,7 +639,7 @@ impl X11WindowStatePtr {
fun(content_size, scale_factor)
}
}
if do_move {
if !is_resize {
if let Some(ref mut fun) = callbacks.moved {
fun()
}
Expand Down
Loading