remove x11rb as dependency
This commit is contained in:
parent
cc577b1367
commit
6ed9fdc9cd
6 changed files with 12 additions and 91 deletions
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cascade = "1.0.0"
|
cascade = "1.0.0"
|
||||||
derivative = "2.2.0"
|
derivative = "2.2.0"
|
||||||
gdk4 = "0.4.3"
|
gdk4 = "0.4.4"
|
||||||
gdk4-wayland = { version = "0.4.2", optional = true }
|
gdk4-wayland = { version = "0.4.2", optional = true }
|
||||||
gdk4-x11 = { version = "0.4.2", features = [ "xlib" ] }
|
gdk4-x11 = { version = "0.4.2", features = [ "xlib" ] }
|
||||||
gio = "0.15.2"
|
gio = "0.15.2"
|
||||||
|
|
@ -16,7 +16,7 @@ wayland-protocols = { version = "0.29.4", features = [ "client", "unstable_proto
|
||||||
x11 = { version = "2.19.1", features = ["xlib"] }
|
x11 = { version = "2.19.1", features = ["xlib"] }
|
||||||
|
|
||||||
# examples
|
# examples
|
||||||
gtk4 = { version = "0.4.3", features = ["v4_4"] }
|
gtk4 = { version = "0.4.4", features = ["v4_4"] }
|
||||||
gtk4-sys = "0.4.2"
|
gtk4-sys = "0.4.2"
|
||||||
glib-sys = "0.15.1"
|
glib-sys = "0.15.1"
|
||||||
relm4-macros = { git = "https://github.com/AaronErhardt/Relm4" }
|
relm4-macros = { git = "https://github.com/AaronErhardt/Relm4" }
|
||||||
|
|
@ -29,7 +29,6 @@ futures = "0.3.19"
|
||||||
futures-util = "0.3.19"
|
futures-util = "0.3.19"
|
||||||
once_cell = "1.9.0"
|
once_cell = "1.9.0"
|
||||||
xdg = "2.4.0"
|
xdg = "2.4.0"
|
||||||
x11rb = "0.9.0"
|
|
||||||
# zbus
|
# zbus
|
||||||
zbus = "2.0.1"
|
zbus = "2.0.1"
|
||||||
zvariant = "3.1.0"
|
zvariant = "3.1.0"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use crate::app_grid::AppGrid;
|
use crate::app_grid::AppGrid;
|
||||||
use crate::group_grid::GroupGrid;
|
use crate::group_grid::GroupGrid;
|
||||||
use cascade::cascade;
|
use cascade::cascade;
|
||||||
use gdk4_x11::X11Display;
|
use gdk4_x11::X11Display;
|
||||||
use gdk4_x11::X11Surface;
|
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
|
@ -17,9 +14,6 @@ use gtk4::SearchEntry;
|
||||||
use gtk4::Separator;
|
use gtk4::Separator;
|
||||||
use gtk4::{gio, glib};
|
use gtk4::{gio, glib};
|
||||||
use libcosmic::x;
|
use libcosmic::x;
|
||||||
use once_cell::sync::OnceCell;
|
|
||||||
use x11rb::connection::Connection;
|
|
||||||
use x11rb::protocol::xproto::*;
|
|
||||||
|
|
||||||
mod imp;
|
mod imp;
|
||||||
|
|
||||||
|
|
@ -147,10 +141,6 @@ impl AppLibraryWindow {
|
||||||
|
|
||||||
window.connect_realize(move |window| {
|
window.connect_realize(move |window| {
|
||||||
if let Some((display, surface)) = x::get_window_x11(window) {
|
if let Some((display, surface)) = x::get_window_x11(window) {
|
||||||
let (conn, _screen_num) = x11rb::connect(None).expect("Failed to connect to X");
|
|
||||||
let x11rb_conn = Rc::new(OnceCell::new());
|
|
||||||
x11rb_conn.set(conn).unwrap();
|
|
||||||
|
|
||||||
// ignore all x11 errors...
|
// ignore all x11 errors...
|
||||||
let xdisplay = display
|
let xdisplay = display
|
||||||
.clone()
|
.clone()
|
||||||
|
|
@ -166,8 +156,7 @@ impl AppLibraryWindow {
|
||||||
&[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DIALOG").unwrap()],
|
&[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DIALOG").unwrap()],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let resize = glib::clone!(@weak window, @strong x11rb_conn => move || {
|
let resize = glib::clone!(@weak window => move || {
|
||||||
let s = window.surface();
|
|
||||||
let height = window.height();
|
let height = window.height();
|
||||||
let width = window.width();
|
let width = window.width();
|
||||||
|
|
||||||
|
|
@ -182,21 +171,9 @@ impl AppLibraryWindow {
|
||||||
// dbg!(monitor_height);
|
// dbg!(monitor_height);
|
||||||
// dbg!(width);
|
// dbg!(width);
|
||||||
// dbg!(height);
|
// dbg!(height);
|
||||||
let w_conf = ConfigureWindowAux::default()
|
unsafe { x::set_position(&display, &surface,
|
||||||
.x(monitor_x + monitor_width / 2 - width / 2)
|
monitor_x + monitor_width / 2 - width / 2,
|
||||||
.y(monitor_y + monitor_height / 2 - height / 2);
|
monitor_y + monitor_height / 2 - height / 2)};
|
||||||
|
|
||||||
let x11surface = gdk4_x11::X11Surface::xid(
|
|
||||||
&s.clone().downcast::<X11Surface>()
|
|
||||||
.expect("Failed to downcast Surface to X11Surface"),
|
|
||||||
);
|
|
||||||
let conn = x11rb_conn.get().unwrap();
|
|
||||||
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 s = window.surface();
|
let s = window.surface();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ use once_cell::sync::{Lazy, OnceCell};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use x11rb::rust_connection::RustConnection;
|
|
||||||
use zbus::Connection;
|
use zbus::Connection;
|
||||||
use zvariant_derive::Type;
|
use zvariant_derive::Type;
|
||||||
|
|
||||||
|
|
@ -35,7 +34,6 @@ const DEST: &str = "com.System76.PopShell";
|
||||||
const PATH: &str = "/com/System76/PopShell";
|
const PATH: &str = "/com/System76/PopShell";
|
||||||
|
|
||||||
static TX: OnceCell<mpsc::Sender<Event>> = OnceCell::new();
|
static TX: OnceCell<mpsc::Sender<Event>> = OnceCell::new();
|
||||||
static X11_CONN: OnceCell<RustConnection> = OnceCell::new();
|
|
||||||
static PLUGINS: Lazy<Mutex<HashMap<String, libloading::Library>>> =
|
static PLUGINS: Lazy<Mutex<HashMap<String, libloading::Library>>> =
|
||||||
Lazy::new(|| Mutex::new(HashMap::new()));
|
Lazy::new(|| Mutex::new(HashMap::new()));
|
||||||
|
|
||||||
|
|
@ -133,11 +131,6 @@ fn main() {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
let (conn, _screen_num) = x11rb::connect(None).expect("Failed to connect to X");
|
|
||||||
if X11_CONN.set(conn).is_err() {
|
|
||||||
eprintln!("failed to set X11_CONN. Exiting");
|
|
||||||
std::process::exit(1);
|
|
||||||
};
|
|
||||||
let window = Window::new(app);
|
let window = Window::new(app);
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use cascade::cascade;
|
use cascade::cascade;
|
||||||
use gdk4_x11::X11Display;
|
use gdk4_x11::X11Display;
|
||||||
use gdk4_x11::X11Surface;
|
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use glib::Type;
|
use glib::Type;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
|
|
@ -15,15 +14,11 @@ use gtk4::Revealer;
|
||||||
use gtk4::RevealerTransitionType;
|
use gtk4::RevealerTransitionType;
|
||||||
use gtk4::Separator;
|
use gtk4::Separator;
|
||||||
use gtk4::{gio, glib};
|
use gtk4::{gio, glib};
|
||||||
use x11rb::connection::Connection;
|
|
||||||
use x11rb::protocol::xproto;
|
|
||||||
use x11rb::protocol::xproto::ConnectionExt;
|
|
||||||
|
|
||||||
use libcosmic::x;
|
use libcosmic::x;
|
||||||
|
|
||||||
use crate::dock_list::DockList;
|
use crate::dock_list::DockList;
|
||||||
use crate::dock_list::DockListType;
|
use crate::dock_list::DockListType;
|
||||||
use crate::X11_CONN;
|
|
||||||
|
|
||||||
mod imp;
|
mod imp;
|
||||||
|
|
||||||
|
|
@ -139,7 +134,6 @@ impl Window {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let resize = glib::clone!(@weak window, @weak revealer => move || {
|
let resize = glib::clone!(@weak window, @weak revealer => move || {
|
||||||
let s = window.surface();
|
|
||||||
let height = if revealer.reveals_child() { window.height() } else { 4 };
|
let height = if revealer.reveals_child() { window.height() } else { 4 };
|
||||||
let width = window.width();
|
let width = window.width();
|
||||||
|
|
||||||
|
|
@ -156,23 +150,9 @@ impl Window {
|
||||||
// dbg!(monitor_height);
|
// dbg!(monitor_height);
|
||||||
// dbg!(width);
|
// dbg!(width);
|
||||||
// dbg!(height);
|
// dbg!(height);
|
||||||
let w_conf = xproto::ConfigureWindowAux::default()
|
unsafe { x::set_position(&display, &surface,
|
||||||
.x((monitor_x + monitor_width / 2 - width / 2).clamp(0, monitor_x + monitor_width - 1))
|
(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));
|
(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...");
|
|
||||||
conn.flush().expect("failed to flush");
|
|
||||||
// fix (dock:294469): Gdk-CRITICAL **: 19:19:25.652: gdk_surface_request_layout: assertion 'frame_clock' failed
|
|
||||||
s.request_layout();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ use gtk4::StyleContext;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use pop_launcher_service::IpcClient;
|
use pop_launcher_service::IpcClient;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use x11rb::rust_connection::RustConnection;
|
|
||||||
|
|
||||||
use crate::utils::BoxedSearchResult;
|
use crate::utils::BoxedSearchResult;
|
||||||
|
|
||||||
|
|
@ -23,7 +22,6 @@ mod window;
|
||||||
|
|
||||||
const NUM_LAUNCHER_ITEMS: u8 = 10;
|
const NUM_LAUNCHER_ITEMS: u8 = 10;
|
||||||
static TX: OnceCell<mpsc::Sender<Event>> = OnceCell::new();
|
static TX: OnceCell<mpsc::Sender<Event>> = OnceCell::new();
|
||||||
static X11_CONN: OnceCell<RustConnection> = OnceCell::new();
|
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
Response(pop_launcher::Response),
|
Response(pop_launcher::Response),
|
||||||
|
|
@ -85,13 +83,6 @@ fn main() {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
let (conn, _screen_num) = x11rb::connect(None).expect("Failed to connect to X");
|
|
||||||
if X11_CONN.set(conn).is_err() {
|
|
||||||
println!("failed to set X11_CONN. Exiting");
|
|
||||||
std::process::exit(1);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
let window = Window::new(app);
|
let window = Window::new(app);
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use cascade::cascade;
|
use cascade::cascade;
|
||||||
use gdk4::Rectangle;
|
|
||||||
use gdk4_x11::X11Display;
|
use gdk4_x11::X11Display;
|
||||||
use gdk4_x11::X11Surface;
|
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk4::prelude::*;
|
use gtk4::prelude::*;
|
||||||
use gtk4::subclass::prelude::*;
|
use gtk4::subclass::prelude::*;
|
||||||
|
|
@ -11,16 +9,12 @@ use gtk4::ListView;
|
||||||
use gtk4::Orientation;
|
use gtk4::Orientation;
|
||||||
use gtk4::{gio, glib};
|
use gtk4::{gio, glib};
|
||||||
use gtk4::{Application, SignalListItemFactory};
|
use gtk4::{Application, SignalListItemFactory};
|
||||||
use x11rb::connection::Connection;
|
|
||||||
use x11rb::protocol::xproto;
|
|
||||||
use x11rb::protocol::xproto::ConnectionExt;
|
|
||||||
|
|
||||||
use libcosmic::x;
|
use libcosmic::x;
|
||||||
|
|
||||||
use crate::search_result_row::SearchResultRow;
|
use crate::search_result_row::SearchResultRow;
|
||||||
use crate::SearchResultObject;
|
use crate::SearchResultObject;
|
||||||
use crate::TX;
|
use crate::TX;
|
||||||
use crate::X11_CONN;
|
|
||||||
|
|
||||||
mod imp;
|
mod imp;
|
||||||
|
|
||||||
|
|
@ -198,7 +192,6 @@ impl Window {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let resize = glib::clone!(@weak window => move || {
|
let resize = glib::clone!(@weak window => move || {
|
||||||
let s = window.surface();
|
|
||||||
let height = window.height();
|
let height = window.height();
|
||||||
let width = window.width();
|
let width = window.width();
|
||||||
|
|
||||||
|
|
@ -213,21 +206,9 @@ impl Window {
|
||||||
// dbg!(monitor_height);
|
// dbg!(monitor_height);
|
||||||
// dbg!(width);
|
// dbg!(width);
|
||||||
// dbg!(height);
|
// dbg!(height);
|
||||||
let w_conf = xproto::ConfigureWindowAux::default()
|
unsafe { x::set_position(&display, &surface,
|
||||||
.x((monitor_x + monitor_width / 2 - width / 2).clamp(0, monitor_x + monitor_width - 1))
|
(monitor_x + monitor_width / 2 - width / 2).clamp(0, monitor_x + monitor_width - 1),
|
||||||
.y((monitor_y + monitor_height / 2 - height / 2).clamp(0, monitor_y + monitor_height - 1));
|
(monitor_y + monitor_height / 2 - height / 2).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...");
|
|
||||||
conn.flush().expect("failed to flush");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let s = window.surface();
|
let s = window.surface();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue