Skip to content

Instantly share code, notes, and snippets.

@ClaireNeveu
Created April 16, 2024 14:35
Show Gist options
  • Save ClaireNeveu/ce1ae12ea4406cc611c9df600377cf0b to your computer and use it in GitHub Desktop.
Save ClaireNeveu/ce1ae12ea4406cc611c9df600377cf0b to your computer and use it in GitHub Desktop.
anyrun poc
diff --git a/anyrun/src/main.rs b/anyrun/src/main.rs
index fb9f62e..d4594da 100644
--- a/anyrun/src/main.rs
+++ b/anyrun/src/main.rs
@@ -294,9 +294,21 @@ fn main() {
}
fn activate(app: &gtk::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
+ let monitor = gdk::Screen::default()
+ .expect("Failed to get GDK screen for CSS provider!");
+
+ let screen_width = 1920 - 60;
+ let screen_height = 1080;
+
+ let launcher_width = runtime_data.borrow().config.width.to_val(u32::try_from(screen_width).unwrap());
+ let launcher_height = 10; //runtime_data.borrow().config.height.to_val(u32::try_from(screen_height).unwrap());
+
+ println!("screen {}x{} {}x{}", screen_width, screen_height, launcher_width, launcher_height);
// Create the main window
let window = gtk::ApplicationWindow::builder()
.application(app)
+ .default_width(launcher_width)
+ .default_height(launcher_height)
.name(style_names::WINDOW)
.build();
@@ -309,6 +321,13 @@ fn activate(app: &gtk::Application, runtime_data: Rc<RefCell<RuntimeData>>) {
gtk_layer_shell::set_anchor(&window, gtk_layer_shell::Edge::Left, true);
gtk_layer_shell::set_anchor(&window, gtk_layer_shell::Edge::Right, true);
+ let horizontal_margin = (screen_width - launcher_width) / 2;
+ let vertical_margin = (screen_height - launcher_height) / 2;
+ gtk_layer_shell::set_margin(&window, gtk_layer_shell::Edge::Top, 250);
+ gtk_layer_shell::set_margin(&window, gtk_layer_shell::Edge::Bottom, 1080 - 250 - 10);
+ gtk_layer_shell::set_margin(&window, gtk_layer_shell::Edge::Left, horizontal_margin);
+ gtk_layer_shell::set_margin(&window, gtk_layer_shell::Edge::Right, horizontal_margin);
+
gtk_layer_shell::set_namespace(&window, "anyrun");
if runtime_data.borrow().config.ignore_exclusive_zones {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment