Add setting "status_on_all_monitors"

This commit is contained in:
Alex Kotov 2021-11-17 06:38:27 +05:00
parent 347441a806
commit a0f3f1000e
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 26 additions and 8 deletions

View file

@ -741,9 +741,11 @@ drawbar(Monitor *m)
stw = getsystraywidth();
/* draw status first so it can be overdrawn by tags later */
drw_setscheme(drw, scheme[SchemeNorm]);
tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px extra right padding */
drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
if (m == selmon || settings_get_status_on_all_monitors()) {
drw_setscheme(drw, scheme[SchemeNorm]);
tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px extra right padding */
drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
}
resizebarwin(m);
for (c = m->clients; c; c = c->next) {
@ -783,10 +785,9 @@ drawbar(Monitor *m)
void
drawbars(void)
{
Monitor *m;
for (m = mons; m; m = m->next)
for (Monitor *m = mons; m; m = m->next) {
drawbar(m);
}
}
void
@ -2186,8 +2187,10 @@ updatestatus(void)
strcpy(stext, "polytreewm-"VERSION);
}
for (Monitor *m = mons; m; m = m->next) {
drawbar(m);
if (settings_get_status_on_all_monitors()) {
drawbars();
} else {
drawbar(selmon);
}
updatesystray();

View file

@ -23,6 +23,7 @@ static bool respect_resize_hints_in_floating_layout = false;
static bool show_bar_by_default = true;
static bool show_bar_per_tag = false;
static unsigned int snap_distance = 32;
static bool status_on_all_monitors = false;
static bool swallow_floating = false;
int settings_get_border_width()
@ -162,6 +163,17 @@ void settings_set_snap_distance(unsigned int new_snap_distance)
snap_distance = new_snap_distance;
}
bool settings_get_status_on_all_monitors()
{
return status_on_all_monitors;
}
void settings_set_status_on_all_monitors(bool new_status_on_all_monitors)
{
status_on_all_monitors = new_status_on_all_monitors;
// TODO: notify WM to rearrange clients
}
bool settings_get_swallow_floating()
{
return swallow_floating;

View file

@ -46,6 +46,9 @@ void settings_set_show_bar_per_tag(bool new_show_bar_per_tag);
unsigned int settings_get_snap_distance();
void settings_set_snap_distance(unsigned int new_snap_distance);
bool settings_get_status_on_all_monitors();
void settings_set_status_on_all_monitors(bool new_status_on_all_monitors);
bool settings_get_swallow_floating();
void settings_set_swallow_floating(bool new_swallow_floating);