diff --git a/crates/ewwii/src/app.rs b/crates/ewwii/src/app.rs index 0460cdc..60a1e44 100644 --- a/crates/ewwii/src/app.rs +++ b/crates/ewwii/src/app.rs @@ -3,7 +3,7 @@ use crate::{ display_backend::DisplayBackend, error_handling_ctx, gtk4::prelude::{ - ApplicationExt, Cast, CastNone, CellAreaExt, DisplayExt, GskRendererExt, GtkWindowExt, + Cast, CastNone, DisplayExt, GtkWindowExt, ListModelExt, MonitorExt, NativeExt, ObjectExt, StyleContextExt, WidgetExt, }, paths::EwwiiPaths, @@ -30,7 +30,7 @@ use rhai::Dynamic; use rhai_impl::ast::WidgetNode; use serde::{de::Error as SerdeError, Deserialize, Deserializer}; use std::{ - cell::{Cell, RefCell}, + cell::{Cell}, collections::{HashMap, HashSet}, marker::PhantomData, rc::Rc, @@ -873,7 +873,7 @@ fn initialize_window( #[cfg(feature = "x11")] if B::IS_X11 { if let Some(geometry) = window_init.geometry { - let (conn, screen_num) = x11rb::rust_connection::RustConnection::connect(None)?; + let (conn, _) = x11rb::rust_connection::RustConnection::connect(None)?; let x11_conn = Rc::new(conn); let gdk_surface = @@ -983,6 +983,7 @@ fn apply_window_position( window: &Window, ) -> Result<()> { use x11rb::protocol::xproto::{ConfigureWindowAux, ConnectionExt, Window as XWindow}; + use x11rb::connection::Connection; let gdk_surface = window.surface().context("Failed to get gdk surface from gtk window")?; @@ -997,7 +998,8 @@ fn apply_window_position( .x(actual_window_rect.x() as i32) .y(actual_window_rect.y() as i32); - conn.configure_window(xid as XWindow, &aux)?; + conn.as_ref().configure_window(xid as XWindow, &aux)?; + conn.as_ref().flush()?; } Ok(()) diff --git a/crates/ewwii/src/display_backend.rs b/crates/ewwii/src/display_backend.rs index 9cff37a..3e4c36d 100644 --- a/crates/ewwii/src/display_backend.rs +++ b/crates/ewwii/src/display_backend.rs @@ -321,28 +321,55 @@ mod platform_x11 { .check()?; // apply the stickiness and fg/bg thingy - let mut win_states = vec![]; - if window_init.backend_options.x11.sticky { - win_states.push(self.atoms._NET_WM_STATE_STICKY); - } - if matches!(window_init.stacking, WindowStacking::Foreground) { - win_states.push(self.atoms._NET_WM_STATE_ABOVE); - } else if matches!(window_init.stacking, WindowStacking::Background) { - win_states.push(self.atoms._NET_WM_STATE_BELOW); - } - - x11rb::wrapper::ConnectionExt::change_property32( + Self::set_window_states( &self.conn, - PropMode::REPLACE, win_id, - self.atoms._NET_WM_STATE, - self.atoms.ATOM, - &win_states, - )? - .check()?; + &self.atoms, + window_init.backend_options.x11.sticky, + window_init.stacking, + )?; self.conn.flush().context("Failed to send requests to X server") } + + fn set_window_states( + conn: &impl Connection, + win: u32, + atoms: &AtomCollection, + sticky: bool, + stacking: WindowStacking, + ) -> Result<()> { + let mut states = Vec::new(); + if sticky { + states.push(atoms._NET_WM_STATE_STICKY); + } + match stacking { + WindowStacking::Foreground => states.push(atoms._NET_WM_STATE_ABOVE), + WindowStacking::Background => states.push(atoms._NET_WM_STATE_BELOW), + _ => {} + } + + for state in states { + let event = ClientMessageEvent { + response_type: CLIENT_MESSAGE_EVENT, + format: 32, + sequence: 0, + window: win, + type_: atoms._NET_WM_STATE, + data: ClientMessageData::from([state, 0, 0, 0, 0]) + }; + + conn.send_event( + false, + conn.setup().roots[0].root, + EventMask::SUBSTRUCTURE_REDIRECT | EventMask::SUBSTRUCTURE_NOTIFY, + event, + )?; + } + + conn.flush()?; + Ok(()) + } } x11rb::atom_manager! { diff --git a/crates/ewwii/src/server.rs b/crates/ewwii/src/server.rs index 6d7064e..a6abfb1 100644 --- a/crates/ewwii/src/server.rs +++ b/crates/ewwii/src/server.rs @@ -5,7 +5,7 @@ use crate::{ error_handling_ctx, ipc_server, EwwiiPaths, }; use anyhow::{Context, Result}; -use gtk4::prelude::{ApplicationExt, ApplicationExtManual, DisplayExt, ListModelExt}; +use gtk4::prelude::{DisplayExt, ListModelExt}; use std::{ // cell::RefCell, collections::{HashMap, HashSet}, @@ -14,7 +14,7 @@ use std::{ os::unix::io::AsRawFd, path::Path, // rc::Rc, - sync::{atomic::Ordering, Arc, Mutex}, + sync::{atomic::Ordering, Arc}, }; use tokio::sync::mpsc::*; diff --git a/crates/ewwii/src/widgets/widget_definitions.rs b/crates/ewwii/src/widgets/widget_definitions.rs index 107b34d..b212980 100644 --- a/crates/ewwii/src/widgets/widget_definitions.rs +++ b/crates/ewwii/src/widgets/widget_definitions.rs @@ -3,7 +3,6 @@ use crate::util; use crate::widgets::build_widget::{build_gtk_widget, WidgetInput}; use anyhow::{anyhow, bail, Result}; -use gdk::{ModifierType, NotifyType}; use gtk4::gdk::DragAction; use gtk4::glib::translate::FromGlib; use gtk4::glib::Type;