feat(xworkspaces): Add group-by-monitor flag
By default, we group workspaces by monitor with the help of _NET_DESKTOP_VIEWPORT. However, some users may experience this as an unpredictable "shuffling" of workspaces. While WMs could disable advertising the property itself, it seems more sensible to handle this at the level of polybar. Hence, introduce a new group-by-monitor flag—defaulting to true—which can be used to disable this behaviour. Closes: https://github.com/polybar/polybar/issues/2603 Related: https://github.com/xmonad/xmonad-contrib/pull/791 Related: https://github.com/qtile/qtile/issues/3375 Co-authored-by: scaramangado <scaramangado@gmail.com>
This commit is contained in:
parent
0a19c5e3d7
commit
f7a755799c
@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `wm-restack`:
|
||||
- `bottom`: lowers polybar to the bottom of the window stack (same as the previous behavior of `generic`) ([`#2961`](https://github.com/polybar/polybar/pull/2961))
|
||||
- `ewmh`: Tries to use the `_NET_SUPPORTING_WM_CHECK` hint to position the bar ([`#2961`](https://github.com/polybar/polybar/pull/2961))
|
||||
- `internal/xworkspaces`: `group-by-monitor` setting to decide whether `_NET_DESKTOP_VIEWPORT` should be used to group workspaces by monitor; ([`#2603`](https://github.com/polybar/polybar/issues/2603), [`#2926`](https://github.com/polybar/polybar/pull/2926)) by [@slotThe](https://github.com/slotThe/).
|
||||
|
||||
### Changed
|
||||
- `custom/script`:
|
||||
|
@ -105,6 +105,7 @@ namespace modules {
|
||||
bool m_click{true};
|
||||
bool m_scroll{true};
|
||||
bool m_revscroll{false};
|
||||
bool m_group_by_monitor{true};
|
||||
size_t m_index{0};
|
||||
};
|
||||
} // namespace modules
|
||||
|
@ -40,12 +40,16 @@ namespace modules {
|
||||
m_click = m_conf.get(name(), "enable-click", m_click);
|
||||
m_scroll = m_conf.get(name(), "enable-scroll", m_scroll);
|
||||
m_revscroll = m_conf.get(name(), "reverse-scroll", m_revscroll);
|
||||
m_group_by_monitor = m_conf.get(name(), "group-by-monitor", m_group_by_monitor);
|
||||
|
||||
// Add formats and elements
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE, TAG_LABEL_MONITOR});
|
||||
|
||||
if (m_formatter->has(TAG_LABEL_MONITOR)) {
|
||||
m_monitorlabel = load_optional_label(m_conf, name(), "label-monitor", DEFAULT_LABEL_MONITOR);
|
||||
if (m_monitorlabel && !m_group_by_monitor) {
|
||||
throw module_error("Cannot use label-monitor when not grouping by monitor");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_formatter->has(TAG_LABEL_STATE)) {
|
||||
@ -188,7 +192,9 @@ namespace modules {
|
||||
/*
|
||||
* Stores the _NET_DESKTOP_VIEWPORT hint
|
||||
*
|
||||
* For WMs that don't support that hint, we store an empty vector
|
||||
* For WMs that don't support that hint, or if the user explicitly
|
||||
* disables support via the configuration file, we store an empty
|
||||
* vector.
|
||||
*
|
||||
* The vector will be padded/reduced to _NET_NUMBER_OF_DESKTOPS.
|
||||
* All desktops which aren't explicitly assigned a postion will be
|
||||
@ -197,7 +203,7 @@ namespace modules {
|
||||
* We use this to map workspaces to viewports, desktop i is at position
|
||||
* ws_positions[i].
|
||||
*/
|
||||
vector<position> ws_positions = ewmh_util::get_desktop_viewports();
|
||||
vector<position> ws_positions = m_group_by_monitor ? ewmh_util::get_desktop_viewports() : vector<position>();
|
||||
|
||||
auto num_desktops = m_desktop_names.size();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user