refactor X and recenter app_library when size changes

This commit is contained in:
Ashley Wulber 2021-12-28 11:38:52 -05:00
parent f0542071d4
commit 6e318abf04
3 changed files with 101 additions and 19 deletions

View file

@ -8,9 +8,13 @@ use gtk::prelude::*;
use gtk4 as gtk;
use gtk4::CssProvider;
use gtk4::StyleContext;
use once_cell::sync::OnceCell;
use x11rb::rust_connection::RustConnection;
use window::Window;
static X11_CONN: OnceCell<RustConnection> = OnceCell::new();
fn main() {
let app = gtk::Application::new(Some("com.cosmic.app_library"), Default::default());
app.connect_startup(|app| {
@ -41,5 +45,10 @@ fn load_css() {
fn build_ui(app: &gtk::Application) {
// Create a new custom window and show it
let window = Window::new(app);
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);
};
window.show();
}