From c51ff3d81cfb80c3e8d6af26a1659ffad6961ae7 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 24 Dec 2021 18:37:19 -0500 Subject: [PATCH] ignore X11 errors --- Cargo.toml | 1 + examples/dock/window/mod.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 717c78f2..74eb54d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ zbus = "2.0.0-beta.7" zvariant = "2.10.0" zvariant_derive = "2.10.0" futures-util = "0.3.19" +gdk4-x11-sys = "0.3.1" [dependencies.gtk4] package = "gtk4" diff --git a/examples/dock/window/mod.rs b/examples/dock/window/mod.rs index 66ca2b42..348d4dba 100644 --- a/examples/dock/window/mod.rs +++ b/examples/dock/window/mod.rs @@ -8,7 +8,10 @@ use crate::TX; use crate::X11_CONN; use gdk4::Rectangle; use gdk4::Surface; +use gdk4_x11::X11Display; use gdk4_x11::X11Surface; +use gdk4_x11_sys::gdk_x11_display_error_trap_push; +use gdk4_x11_sys::GdkX11Display; use gio::DesktopAppInfo; use glib::Type; use gtk4 as gtk; @@ -19,7 +22,6 @@ use postage::prelude::Sink; use std::path::Path; use x11rb::connection::Connection; use x11rb::protocol::xproto::ConnectionExt; - // use crate::application_row::ApplicationRow; use glib::Object; use gtk::prelude::*; @@ -197,6 +199,9 @@ impl Window { ); window.connect_realize(glib::clone!(@weak revealer, @weak cursor_event_controller => move |window| { if let Some((display, surface)) = x::get_window_x11(window) { + // ignore all x11 errors... + let xdisplay = display.clone().downcast::().expect("Failed to downgrade X11 Display."); + xdisplay.error_trap_push(); unsafe { x::change_property( &display, @@ -243,7 +248,6 @@ impl Window { ) .expect("failed to configure window..."); conn.flush().expect("failed to flush"); - s.request_layout(); } }); glib::source::idle_add_local_once(resize); @@ -284,7 +288,6 @@ impl Window { ) .expect("failed to configure window..."); conn.flush().expect("failed to flush"); - s.request_layout(); } else { println!("failed to get X11 window"); } @@ -329,7 +332,6 @@ impl Window { ) .expect("failed to configure window..."); conn.flush().expect("failed to flush"); - s.request_layout(); } else { println!("failed to get X11 window"); }