Use IsA<Window>

This commit is contained in:
Ian Douglas Scott 2021-08-26 22:04:07 -07:00
parent cf63465320
commit e26ae62532
2 changed files with 9 additions and 5 deletions

View file

@ -58,7 +58,7 @@ impl WidgetImpl for PanelWindowInner {
fn show(&self, obj: &PanelWindow) {
self.parent_show(obj);
if let Some((display, surface)) = x::get_window_x11(&obj.upcast_ref()) {
if let Some((display, surface)) = x::get_window_x11(obj) {
unsafe {
surface.set_skip_pager_hint(true);
surface.set_skip_taskbar_hint(true);
@ -127,7 +127,7 @@ impl PanelWindow {
return;
};
if let Some((display, surface)) = x::get_window_x11(self.upcast_ref()) {
if let Some((display, surface)) = x::get_window_x11(self) {
let top_start_x = geometry.x as x::c_ulong;
let top_end_x = top_start_x + geometry.width as x::c_ulong - 1;

View file

@ -10,10 +10,14 @@ use std::{
pub use std::os::raw::{c_uchar, c_ulong, c_ushort};
pub fn get_window_x11(
window: &gtk4::Window,
pub fn get_window_x11<T: IsA<gtk4::Window>>(
window: &T,
) -> Option<(gdk4_x11::X11Display, gdk4_x11::X11Surface)> {
let surface = window.surface()?.downcast::<gdk4_x11::X11Surface>().ok()?;
let surface = window
.upcast_ref()
.surface()?
.downcast::<gdk4_x11::X11Surface>()
.ok()?;
let display = surface.display()?.downcast::<gdk4_x11::X11Display>().ok()?;
Some((display, surface))
}