config: add absolute size / position getters / setters and window rules - #1069
config: add absolute size / position getters / setters and window rules#1069Ktrompfl wants to merge 1 commit into
Conversation
|
I'd prefer for this to be a single action
All fields take numbers as arguments but also the string "keep", to indicate that this value should be preserved. Naturally not all combinations are valid. For example, it would not make sense to set x1=0, x2=100, width=keep, since you cannot follow all three instructions in general. |
669b0d4 to
560737d
Compare
|
Is this what you have in mind or should I keep the size / position setters as separate functions in jay-config and only expose them as a combined action in toml-config? |
|
I've only looked at the SetPosition data structure for now, not at the business logic, but I don't think it can be correct as is. The three states number/"keep"/omitted must be distinguished. Currently it seems that you conflate "keep" and omitted. If a user sets x1=2, then I'd expect x2 to stay as is, so the window width might increase or decrease. However, if a user sets x1=2,width="keep", then x2 should be adjusted dynamically to preserve the width. |
560737d to
999a8f4
Compare
|
Alright, I've extended the set-position parameters to distinguish these cases. For ambiguous situations I defined the following behavior:
|
664b90f to
5b43246
Compare
5b43246 to
013e5ce
Compare
| x1: Option<Coordinate>, | ||
| y1: Option<Coordinate>, | ||
| x2: Option<Coordinate>, | ||
| y2: Option<Coordinate>, | ||
| width: Option<Coordinate>, | ||
| height: Option<Coordinate>, |
There was a problem hiding this comment.
I think this might be better as
#[derive(Default)]
struct Position {
x1: Option<Coordinate>,
...
}| /// | ||
| /// This is a shortcut for `(width(), height())` that only performs a single round-trip. |
| if !self.exists() { | ||
| return (0, 0); | ||
| } | ||
| get!((0, 0)).connector_size(self) |
There was a problem hiding this comment.
Why not just get!().connector_size(self)?
| /// A constraint on a coordinate or size passed to [`Window::set_position`]. | ||
| #[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)] | ||
| pub enum Coordinate { | ||
| /// Constrain this field to the window's current value for it. | ||
| Keep, | ||
| /// Constrain this field to this value. | ||
| Set(i32), | ||
| } |
There was a problem hiding this comment.
I think this should be something like
enum Adjustment {
#[default]
Recalculate,
Preserve,
Set(i32),
}|
This PR does several independent things. Please split it up. |
Implements #1052.