Skip to content

config: add absolute size / position getters / setters and window rules - #1069

Open
Ktrompfl wants to merge 1 commit into
mahkoh:masterfrom
Ktrompfl:size-and-position
Open

config: add absolute size / position getters / setters and window rules#1069
Ktrompfl wants to merge 1 commit into
mahkoh:masterfrom
Ktrompfl:size-and-position

Conversation

@Ktrompfl

@Ktrompfl Ktrompfl commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Implements #1052.

Comment thread jay-config/src/_private/ipc.rs Outdated
Comment thread jay-config/src/_private/ipc.rs Outdated
Comment thread jay-config/src/_private/ipc.rs Outdated
Comment thread src/ifs/wl_surface/x_surface/xwindow.rs Outdated
@mahkoh

mahkoh commented Jul 8, 2026

Copy link
Copy Markdown
Owner

I'd prefer for this to be a single action set-position that takes the following arguments:

  • x1
  • y1
  • x2
  • y2
  • width
  • height

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.

@Ktrompfl
Ktrompfl force-pushed the size-and-position branch 3 times, most recently from 669b0d4 to 560737d Compare July 10, 2026 09:09
@Ktrompfl

Copy link
Copy Markdown
Contributor Author

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?

@mahkoh

mahkoh commented Jul 10, 2026

Copy link
Copy Markdown
Owner

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.

@Ktrompfl
Ktrompfl force-pushed the size-and-position branch from 560737d to 999a8f4 Compare July 17, 2026 20:44
@Ktrompfl

Copy link
Copy Markdown
Contributor Author

Alright, I've extended the set-position parameters to distinguish these cases. For ambiguous situations I defined the following behavior:

  • If for an axis only one coordinate constraint is provided, the second coordinate is preserved and the size changes accordingly on this axis.
  • If for an axis only a size constraint is provided, the first coordinate is preserved and the second coordinate is updated on this axis.
  • If for an axis three constraints are provided but unsatisfiable, the changes to the other axis are not applied either and entire action is a no-op.

@Ktrompfl
Ktrompfl force-pushed the size-and-position branch from 664b90f to 5b43246 Compare July 26, 2026 12:44
@Ktrompfl
Ktrompfl force-pushed the size-and-position branch from 5b43246 to 013e5ce Compare July 28, 2026 11:11
Comment thread jay-config/src/input.rs
Comment on lines +725 to +730
x1: Option<Coordinate>,
y1: Option<Coordinate>,
x2: Option<Coordinate>,
y2: Option<Coordinate>,
width: Option<Coordinate>,
height: Option<Coordinate>,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be better as

#[derive(Default)]
struct Position {
    x1: Option<Coordinate>,
    ...
}

Comment thread jay-config/src/video.rs
Comment on lines +205 to +206
///
/// This is a shortcut for `(width(), height())` that only performs a single round-trip.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary.

Comment thread jay-config/src/video.rs
Comment on lines +208 to +211
if !self.exists() {
return (0, 0);
}
get!((0, 0)).connector_size(self)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just get!().connector_size(self)?

Comment thread jay-config/src/window.rs
Comment on lines +69 to +76
/// 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),
}

@mahkoh mahkoh Jul 30, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be something like

enum Adjustment {
    #[default]
    Recalculate,
    Preserve,
    Set(i32),
}

@mahkoh

mahkoh commented Jul 30, 2026

Copy link
Copy Markdown
Owner

This PR does several independent things. Please split it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants