Add a config file, and size the grid to the display
Colours, border and thumbnail size come from ~/.config/wl-pick/config now, since ten more flags would have made a keybinding unreadable — the split the rofi setup this replaces already used: look in a file, behaviour on the command line. Flat `key = value` lines, so no TOML dependency for something with nothing to nest, and a flag still beats the file. Sizes take sway's units. `600px` is absolute; `70ppt` is a percentage of the display the grid appears on, resolved on every run rather than baked in, so one config suits monitors of different sizes. That needed the overlay to know which display it is on, so it now asks sway for the focused one and maps there explicitly, at that display's scale, instead of letting the compositor choose and taking the largest scale in use — which was wrong on any mixed-DPI setup. tile-width and tile-height are maxima. Given only a width, the height follows the display's aspect: a 16:9 cell, inherited from a rofi theme written for a landscape screen, wasted about half of every cell on a portrait monitor. And if the grid would outgrow the display, tiles now shrink together, keeping their shape, so thirty windows produce small tiles rather than a surface larger than the screen. The surface is capped at the display as a backstop, because on a small screen the padding and label rows can exceed it no matter how small the tiles get. Two bugs the tests caught while writing this: - Stripping comments at the first '#' ate colour values, so `selection = #d79921 # note` parsed as empty. A comment is now a '#' followed by whitespace or end of line; a colour is '#' then a hex digit, so the two cannot collide. - Twelve tiles at the old fixed size fit a 1280x800 screen, so the first version of the shrink test proved nothing. It now uses numbers that genuinely overflow. Also: failing to reach sway said only "No such file or directory", which tells a first-time user nothing; it now names sway and what it wanted.
This commit is contained in:
+8
-1
@@ -66,9 +66,16 @@ impl App {
|
||||
pub fn show(&mut self, qh: &QueueHandle<Self>) -> Result<(), Box<dyn Error>> {
|
||||
let (lw, lh) = (self.layout.width, self.layout.height);
|
||||
let surface = self.compositor.create_surface(qh, ());
|
||||
// Map on the display the layout was sized against, not wherever the
|
||||
// compositor would otherwise put it.
|
||||
let output = self
|
||||
.outputs
|
||||
.iter()
|
||||
.find(|(_, name)| *name == self.output)
|
||||
.map(|(output, _)| output);
|
||||
let layer = self.layer_shell.get_layer_surface(
|
||||
&surface,
|
||||
None, // let the compositor place it on the active output
|
||||
output,
|
||||
Layer::Overlay,
|
||||
"wl-pick".to_string(),
|
||||
qh,
|
||||
|
||||
Reference in New Issue
Block a user