Skip to content

Commit 4e0ebf9

Browse files
authored
anyrun: full-screen window when close_on_click is set (#240)
1 parent 3deda34 commit 4e0ebf9

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

anyrun/src/main.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ impl Component for App {
143143
}
144144
},
145145

146+
#[name = "main"]
146147
gtk::Box {
147148
set_orientation: gtk::Orientation::Vertical,
148149
set_halign: gtk::Align::Center,
@@ -325,10 +326,25 @@ impl Component for App {
325326
let height = self.config.height.to_val(mon_height);
326327
let y = self.config.y.to_val(mon_height) - height / 2;
327328

328-
window.set_default_size(width, height);
329-
window.child().unwrap().set_size_request(width, height);
330-
window.set_margin(Edge::Left, x);
331-
window.set_margin(Edge::Top, y);
329+
if self.config.close_on_click {
330+
window.set_anchor(Edge::Bottom, true);
331+
window.set_anchor(Edge::Right, true);
332+
widgets.main.set_halign(gtk::Align::Fill);
333+
widgets.main.set_margin_start(x);
334+
widgets.main.set_margin_top(y);
335+
widgets
336+
.main
337+
.set_margin_end(mon_width as i32 - x - width);
338+
widgets
339+
.main
340+
.set_margin_bottom(mon_height as i32 - y - height);
341+
} else {
342+
window.set_default_size(width, height);
343+
window.child().unwrap().set_size_request(width, height);
344+
window.set_margin(Edge::Left, x);
345+
window.set_margin(Edge::Top, y);
346+
}
347+
332348
window.show();
333349
}
334350
AppMsg::KeyPressed { key, modifier } => {

0 commit comments

Comments
 (0)