Added a basic centered mode

This commit is contained in:
Kirottu
2023-04-04 16:03:52 +03:00
parent 9ac2a9a2eb
commit 2adbaa58a4

View File

@@ -7,10 +7,17 @@ use nix::unistd;
use serde::Deserialize; use serde::Deserialize;
use wl_clipboard_rs::copy; use wl_clipboard_rs::copy;
#[derive(Deserialize)]
enum Position {
Top,
Center,
}
#[derive(Deserialize)] #[derive(Deserialize)]
struct Config { struct Config {
width: u32, width: u32,
plugins: Vec<PathBuf>, plugins: Vec<PathBuf>,
position: Position,
} }
/// A "view" of plugin's info and matches /// A "view" of plugin's info and matches
@@ -157,7 +164,13 @@ fn activate(app: &gtk::Application, runtime_data: Rc<RefCell<Option<RuntimeData>
// Init GTK layer shell // Init GTK layer shell
gtk_layer_shell::init_for_window(&window); gtk_layer_shell::init_for_window(&window);
gtk_layer_shell::set_anchor(&window, gtk_layer_shell::Edge::Top, true);
// Anchor based on configured position
match config.position {
Position::Top => gtk_layer_shell::set_anchor(&window, gtk_layer_shell::Edge::Top, true),
Position::Center => (),
}
gtk_layer_shell::set_keyboard_mode(&window, gtk_layer_shell::KeyboardMode::Exclusive); gtk_layer_shell::set_keyboard_mode(&window, gtk_layer_shell::KeyboardMode::Exclusive);
gtk_layer_shell::set_layer(&window, gtk_layer_shell::Layer::Overlay); gtk_layer_shell::set_layer(&window, gtk_layer_shell::Layer::Overlay);