Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse switch-preset-column-width #1367

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mattkang
Copy link

@mattkang mattkang commented Mar 31, 2025

Support switch-preset-column-width in reverse order as well as switching presets without wraparound. Implements #1000

@mattkang
Copy link
Author

@YaLTeR I have added some methods to support this feature, but I'm now unclear as to how to implement this in the IPC interface. Help appreciated thanks.

Comment on lines +1676 to +1677
SwitchPresetColumnWidthNext,
SwitchPresetColumnWidthPrev,
Copy link
Owner

Choose a reason for hiding this comment

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

As we discussed, instead of two new commands it should be just SwitchPresetColumnWidthBack, and both of them should have a #[knuffel(property)] bool cycle argument.

Copy link
Owner

Choose a reason for hiding this comment

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

And on the ipc/lib.rs it would be --cycle false. See the recent --focus false on MoveWindowToMonitor

self.preset_width_idx = Some(preset_idx);
}

fn cycle_width(&mut self, steps: i32, tile_idx: Option<usize>, wraparound: bool) {
Copy link
Owner

Choose a reason for hiding this comment

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

Why did you make this generic by steps? This overcomplicates the logic below quite a bit. Just pass another back: bool or something

Copy link
Author

Choose a reason for hiding this comment

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

I will make an attempt to cleanup logic. Wasn't able to immediately find contributing guidelines. Do you want me to fix via squashing or keep everything as new commits?

Copy link
Owner

Choose a reason for hiding this comment

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

I prefer a clean commit history with self-contained changes. In practice most PRs don't do that, so I use squash-and-merge. So do as you prefer

@@ -4379,7 +4401,14 @@ impl<W: LayoutElement> Column<W> {
true
}

fn toggle_width(&mut self, tile_idx: Option<usize>) {
fn select_width(&mut self, preset_idx: usize, tile_idx: Option<usize>) {
Copy link
Owner

Choose a reason for hiding this comment

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

Why extract this?

Copy link
Author

@mattkang mattkang Mar 31, 2025

Choose a reason for hiding this comment

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

While not scoped for this PR, I think it might be useful to specify an exact preset width. For example, the user could bind a shortcut to immediately make the window half size (vs. cycling through all preset widths). This would behave similarly to what is possible right now with full width.

Copy link
Owner

Choose a reason for hiding this comment

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

It's already possible. set-column-width 50%

Copy link
Author

Choose a reason for hiding this comment

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

Yes, but is there some advantage that the column retains knowledge that it is at a preset width? And not just an arbitrary width value

Copy link
Owner

Choose a reason for hiding this comment

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

Not really. Switch preset will already start with the closest next (or previous) width.

Copy link
Author

@mattkang mattkang Mar 31, 2025

Choose a reason for hiding this comment

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

Is it possible there may be rounding issues? For example, the first Mod+R press (imperceptibly) applies a very similar preset width, and the user must then hit Mod+R again to actually increment the window width. I've had this exact experience coming from hyprscroller (or maybe it was PaperWM)

Copy link
Owner

Choose a reason for hiding this comment

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

Not really, no. Window sizes are quantized to logical integers on Wayland which makes this sort of stuff less likely

@@ -1068,6 +1068,22 @@ impl<W: LayoutElement> Workspace<W> {
}
}

pub fn increment_width(&mut self) {
if self.floating_is_active.get() {
self.floating.toggle_window_width(None);
Copy link
Owner

Choose a reason for hiding this comment

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

Should be implemented for floating too

@YaLTeR
Copy link
Owner

YaLTeR commented Mar 31, 2025

Don't forget to add the new action to src/layout/tests.rs Op enum

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