Skip to content

Commit

Permalink
options: monitor_options, added column_widths and window_heights
Browse files Browse the repository at this point in the history
  • Loading branch information
dawsers committed Dec 21, 2024
1 parent e7f6ab3 commit 992c77e
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 322 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,7 @@ by Chen-Yulin provides code to use *hyprscroller's* IPC messages with
Determines the width of new columns in *row* mode.
Possible arguments are: `oneeighth`, `onesixth`, `onefourth`, `onethird`,
`threeeighths`, `onehalf` (default), `fiveeighths`, `twothirds`, `threequarters`,
`fivesixths`, `seveneighths`, `maximized`, `floating` (uses the
default width set by the application).
`fivesixths`, `seveneighths`, `one`.

### `window_default_height`

Expand Down Expand Up @@ -777,6 +776,8 @@ monitor. Currently, the supported options are:
`column_default_width` option.
3. `window_default_height`: Possible values are the same as the global
`window_default_height` option.
4. `column_widths`: Similar to the global option.
5. `window_heights`: Similar to the global option.

When you create a workspace in any monitor, instead of defaulting to the
global options, it will read them from this configuration value. For any
Expand All @@ -797,7 +798,7 @@ means the name you need to use is HDMI-A-1.
`monitor_options` is a list with the following format:

```
monitor_options = (DP-2 = (mode = row; column_default_width = onehalf; window_default_height = one), HDMI-A-1 = (mode = col; column_default_width = one; window_default_height = onehalf))
monitor_options = (DP-2 = (mode = row; column_default_width = onehalf; column_widths = onethird onehalf twothirds; window_default_height = one), HDMI-A-1 = (mode = col; column_default_width = one; window_default_height = onehalf))
```

The list of monitors is encapsulated by `()` and separated by `,`. Each
Expand All @@ -807,7 +808,8 @@ example above. Spaces are allowed anywhere for better readability.

This option is useful to configure ultra-wide monitors or those in non-standard
orientations (for example portrait instead of landscape). You can define any
combination.
combination. You can also use a configuration per monitor when you have very
different geometries, for example a laptop and an external, bigger monitor.

### `gesture_scroll_enable`

Expand Down Expand Up @@ -900,7 +902,7 @@ plugin {
# ultra-wide monitor
column_widths = onefourth onethird onehalf onesixth
# portrait mode monitors
monitor_options = (DP-2 = (mode = row; column_default_width = onehalf; window_default_height = one), HDMI-A-1 = (mode = col; column_default_width = one; window_default_height = onehalf))
monitor_options = (DP-2 = (mode = row; column_default_width = onehalf; column_widths = onethird onehalf twothirds one; window_default_height = one), HDMI-A-1 = (mode = col; column_default_width = one; window_default_height = onehalf))
}
}
```
Expand Down
54 changes: 5 additions & 49 deletions src/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,11 @@
extern HANDLE PHANDLE;
extern std::function<SDispatchResult(std::string)> orig_moveFocusTo;
extern ScrollerSizes scroller_sizes;
extern CycleSizes window_heights;

Column::Column(PHLWINDOW cwindow, double maxw, const Row *row)
: height(StandardSize::One), reorder(Reorder::Auto), row(row)
{
ConfigurationSize column_width =
scroller_sizes.get_column_default_width(cwindow);
if (column_width == ConfigurationSize::OneHalf) {
width = StandardSize::OneHalf;
} else if (column_width == ConfigurationSize::OneEighth) {
width = StandardSize::OneEighth;
} else if (column_width == ConfigurationSize::OneSixth) {
width = StandardSize::OneSixth;
} else if (column_width == ConfigurationSize::OneFourth) {
width = StandardSize::OneFourth;
} else if (column_width == ConfigurationSize::OneThird) {
width = StandardSize::OneThird;
} else if (column_width == ConfigurationSize::ThreeEighths) {
width = StandardSize::ThreeEighths;
} else if (column_width == ConfigurationSize::FiveEighths) {
width = StandardSize::FiveEighths;
} else if (column_width == ConfigurationSize::TwoThirds) {
width = StandardSize::TwoThirds;
} else if (column_width == ConfigurationSize::ThreeQuarters) {
width = StandardSize::ThreeQuarters;
} else if (column_width == ConfigurationSize::FiveSixths) {
width = StandardSize::FiveSixths;
} else if (column_width == ConfigurationSize::SevenEighths) {
width = StandardSize::SevenEighths;
} else if (column_width == ConfigurationSize::One) {
width = StandardSize::One;
} else if (column_width == ConfigurationSize::Maximized) {
width = StandardSize::Free;
} else if (column_width == ConfigurationSize::Floating) {
if (cwindow->m_vLastFloatingSize.y > 0) {
width = StandardSize::Free;
maxw = cwindow->m_vLastFloatingSize.x;
} else {
width = StandardSize::OneHalf;
}
} else {
width = StandardSize::OneHalf;
}
width = scroller_sizes.get_column_default_width(cwindow);
const Box &max = row->get_max();
Window *window = new Window(cwindow, max.y, max.h);
windows.push_back(window);
Expand Down Expand Up @@ -500,28 +462,22 @@ void Column::fit_size(FitSize fitsize, const Vector2D &gap_x, double gap)

void Column::cycle_size_active_window(int step, const Vector2D &gap_x, double gap)
{
static auto const *window_heights_str = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:scroller:window_heights")->getDataStaticPtr();
window_heights.update(*window_heights_str);

reorder = Reorder::Auto;
StandardSize height = active->data()->get_height();
if (height == StandardSize::Free) {
// When cycle-resizing from Free mode, always move back to first
height = window_heights.get_default();
// When cycle-resizing from Free mode, always move back to default
height = scroller_sizes.get_window_default_height(active->data()->get_window());
} else {
height = window_heights.get_next(height, step);
height = scroller_sizes.get_next_window_height(height, step);
}
active->data()->update_height(height, row->get_max().h);
recalculate_col_geometry(gap_x, gap);
}

void Column::size_active_window(int index, const Vector2D &gap_x, double gap)
{
static auto const *window_heights_str = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:scroller:window_heights")->getDataStaticPtr();
window_heights.update(*window_heights_str);

reorder = Reorder::Auto;
StandardSize height = window_heights.get_size(index);
StandardSize height = scroller_sizes.get_window_height(index);
active->data()->update_height(height, row->get_max().h);
recalculate_col_geometry(gap_x, gap);
}
Expand Down
15 changes: 4 additions & 11 deletions src/row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
extern HANDLE PHANDLE;
extern Overview *overviews;
extern std::function<SDispatchResult(std::string)> orig_moveFocusTo;
extern CycleSizes column_widths;
extern ScrollerSizes scroller_sizes;

Row::Row(WORKSPACEID workspace)
Expand Down Expand Up @@ -231,15 +230,12 @@ void Row::resize_active_column(int step)
if (mode == Mode::Column) {
active->data()->cycle_size_active_window(step, calculate_gap_x(active), gap);
} else {
static auto const *column_widths_str = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:scroller:column_widths")->getDataStaticPtr();
column_widths.update(*column_widths_str);

StandardSize width = active->data()->get_width();
if (width == StandardSize::Free) {
// When cycle-resizing from Free mode, always move back to first
width = column_widths.get_default();
// When cycle-resizing from Free mode, always move back to default
width = scroller_sizes.get_column_default_width(get_active_window());
} else {
width = column_widths.get_next(width, step);
width = scroller_sizes.get_next_column_width(width, step);
}
active->data()->update_width(width, max.w);
reorder = Reorder::Auto;
Expand All @@ -261,10 +257,7 @@ void Row::size_active_column(int index)
if (mode == Mode::Column) {
active->data()->size_active_window(index, calculate_gap_x(active), gap);
} else {
static auto const *column_widths_str = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:scroller:column_widths")->getDataStaticPtr();
column_widths.update(*column_widths_str);

StandardSize width = column_widths.get_size(index);
StandardSize width = scroller_sizes.get_column_width(index);
active->data()->update_width(width, max.w);
reorder = Reorder::Auto;
recalculate_row_geometry();
Expand Down
Loading

0 comments on commit 992c77e

Please sign in to comment.