fix: gdk layout crash
This commit is contained in:
parent
fb95442a0b
commit
253b0a518e
1 changed files with 37 additions and 41 deletions
|
|
@ -213,7 +213,7 @@ impl Window {
|
|||
let resize = glib::clone!(@weak window => move || {
|
||||
let s = window.surface().expect("Failed to get Surface for Window");
|
||||
revealer.set_reveal_child(true);
|
||||
let height = s.height() * s.scale_factor();
|
||||
let height = window.height();
|
||||
|
||||
if let Some((display, _surface)) = x::get_window_x11(&window) {
|
||||
let monitor = display
|
||||
|
|
@ -228,7 +228,7 @@ impl Window {
|
|||
// dbg!(monitor_width);
|
||||
// dbg!(monitor_height);
|
||||
// dbg!(width);
|
||||
// dbg!(height);
|
||||
dbg!(height);
|
||||
let w_conf = xproto::ConfigureWindowAux::default()
|
||||
.y((monitor_y + monitor_height - height).clamp(0, monitor_y + monitor_height - 1));
|
||||
let conn = X11_CONN.get().expect("Failed to get X11_CONN");
|
||||
|
|
@ -242,9 +242,8 @@ impl Window {
|
|||
&w_conf,
|
||||
)
|
||||
.expect("failed to configure window...");
|
||||
conn.flush().expect("failed to flush");let frame_clock = s.frame_clock().unwrap();
|
||||
frame_clock.request_phase(gdk4::FrameClockPhase::FLUSH_EVENTS); } else {
|
||||
println!("failed to get X11 window");
|
||||
conn.flush().expect("failed to flush");
|
||||
s.request_layout();
|
||||
}
|
||||
});
|
||||
glib::source::idle_add_local_once(resize);
|
||||
|
|
@ -270,7 +269,7 @@ impl Window {
|
|||
// dbg!(monitor_width);
|
||||
// dbg!(monitor_height);
|
||||
// dbg!(width);
|
||||
// dbg!(height);
|
||||
dbg!(height);
|
||||
let w_conf = xproto::ConfigureWindowAux::default()
|
||||
.y((monitor_y + monitor_height - height).clamp(0, monitor_y + monitor_height - 1));
|
||||
let conn = X11_CONN.get().expect("Failed to get X11_CONN");
|
||||
|
|
@ -285,9 +284,7 @@ impl Window {
|
|||
)
|
||||
.expect("failed to configure window...");
|
||||
conn.flush().expect("failed to flush");
|
||||
s.queue_render();
|
||||
let frame_clock = s.frame_clock().unwrap();
|
||||
frame_clock.request_phase(gdk4::FrameClockPhase::FLUSH_EVENTS);
|
||||
s.request_layout();
|
||||
} else {
|
||||
println!("failed to get X11 window");
|
||||
}
|
||||
|
|
@ -300,40 +297,39 @@ impl Window {
|
|||
let surface_resize_handler = glib::clone!(@weak window => move |s: &Surface| {
|
||||
let resize = glib::clone!(@weak s => move || {
|
||||
if let Some((display, _surface)) = x::get_window_x11(&window) {
|
||||
let width = s.width() * s.scale_factor();
|
||||
// let height = s.height() * s.scale_factor();
|
||||
// hide by default
|
||||
let height = 4;
|
||||
let monitor = display
|
||||
.primary_monitor()
|
||||
.expect("Failed to get Monitor");
|
||||
let Rectangle {
|
||||
x: monitor_x,
|
||||
y: monitor_y,
|
||||
width: monitor_width,
|
||||
height: monitor_height,
|
||||
} = monitor.geometry();
|
||||
// dbg!(monitor_width);
|
||||
// dbg!(monitor_height);
|
||||
// dbg!(width);
|
||||
// dbg!(heightt - 1);
|
||||
let w_conf = xproto::ConfigureWindowAux::default()
|
||||
.x((monitor_x + monitor_width / 2 - width / 2).clamp(0, monitor_x + monitor_width - 1))
|
||||
.y((monitor_y + monitor_height - height).clamp(0, monitor_y + monitor_height - 1));
|
||||
let conn = X11_CONN.get().expect("Failed to get X11_CONN");
|
||||
let width = window.width();
|
||||
// let height = s.height() * s.scale_factor();
|
||||
// hide by default
|
||||
let height = 4;
|
||||
let monitor = display
|
||||
.primary_monitor()
|
||||
.expect("Failed to get Monitor");
|
||||
let Rectangle {
|
||||
x: monitor_x,
|
||||
y: monitor_y,
|
||||
width: monitor_width,
|
||||
height: monitor_height,
|
||||
} = monitor.geometry();
|
||||
// dbg!(monitor_width);
|
||||
// dbg!(monitor_height);
|
||||
// dbg!(width);
|
||||
// dbg!(heightt - 1);
|
||||
let w_conf = xproto::ConfigureWindowAux::default()
|
||||
.x((monitor_x + monitor_width / 2 - width / 2).clamp(0, monitor_x + monitor_width - 1))
|
||||
.y((monitor_y + monitor_height - height).clamp(0, monitor_y + monitor_height - 1));
|
||||
let conn = X11_CONN.get().expect("Failed to get X11_CONN");
|
||||
|
||||
let x11surface = gdk4_x11::X11Surface::xid(
|
||||
&s.clone().downcast::<X11Surface>()
|
||||
.expect("Failed to downcast Surface to X11Surface"),
|
||||
);
|
||||
conn.configure_window(
|
||||
x11surface.try_into().expect("Failed to convert XID"),
|
||||
&w_conf,
|
||||
)
|
||||
.expect("failed to configure window...");
|
||||
let x11surface = gdk4_x11::X11Surface::xid(
|
||||
&s.clone().downcast::<X11Surface>()
|
||||
.expect("Failed to downcast Surface to X11Surface"),
|
||||
);
|
||||
conn.configure_window(
|
||||
x11surface.try_into().expect("Failed to convert XID"),
|
||||
&w_conf,
|
||||
)
|
||||
.expect("failed to configure window...");
|
||||
conn.flush().expect("failed to flush");
|
||||
let frame_clock = s.frame_clock().unwrap();
|
||||
frame_clock.request_phase(gdk4::FrameClockPhase::FLUSH_EVENTS);
|
||||
s.request_layout();
|
||||
} else {
|
||||
println!("failed to get X11 window");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue