Add setting "show_bar_per_unit"
This commit is contained in:
parent
2130af8de8
commit
557cf656b6
3 changed files with 38 additions and 3 deletions
|
@ -21,6 +21,7 @@ static int gap_size = 10;
|
|||
static int max_clients_in_master = 0; // 0 for no maximum
|
||||
static bool respect_resize_hints_in_floating_layout = false;
|
||||
static bool show_bar_by_default = true;
|
||||
static bool show_bar_per_unit = UNIT_MONITOR;
|
||||
static unsigned int snap_distance = 32;
|
||||
static bool status_on_all_monitors = false;
|
||||
static bool swallow_floating = false;
|
||||
|
@ -140,6 +141,17 @@ void settings_set_show_bar_by_default(bool new_show_bar_by_default)
|
|||
show_bar_by_default = new_show_bar_by_default;
|
||||
}
|
||||
|
||||
UnitKind settings_get_show_bar_per_unit()
|
||||
{
|
||||
return show_bar_per_unit;
|
||||
}
|
||||
|
||||
void settings_set_show_bar_per_unit(const UnitKind new_show_bar_per_unit)
|
||||
{
|
||||
show_bar_per_unit = new_show_bar_per_unit;
|
||||
// TODO: notify WM to rearrange clients
|
||||
}
|
||||
|
||||
unsigned int settings_get_snap_distance()
|
||||
{
|
||||
return snap_distance;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef _SETTINGS_H
|
||||
#define _SETTINGS_H
|
||||
|
||||
#include "unit.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum {
|
||||
|
@ -40,6 +42,9 @@ void settings_set_respect_resize_hints_in_floating_layout(bool new_respect_resiz
|
|||
bool settings_get_show_bar_by_default();
|
||||
void settings_set_show_bar_by_default(bool new_show_bar_by_default);
|
||||
|
||||
UnitKind settings_get_show_bar_per_unit();
|
||||
void settings_set_show_bar_per_unit(UnitKind new_show_bar_per_unit);
|
||||
|
||||
unsigned int settings_get_snap_distance();
|
||||
void settings_set_snap_distance(unsigned int new_snap_distance);
|
||||
|
||||
|
|
20
src/unit.c
20
src/unit.c
|
@ -7,7 +7,7 @@
|
|||
|
||||
struct Unit {
|
||||
UnitKind kind;
|
||||
const struct Unit *parent;
|
||||
struct Unit *parent;
|
||||
bool show_bar;
|
||||
};
|
||||
|
||||
|
@ -49,10 +49,28 @@ void unit_delete(const Unit unit)
|
|||
|
||||
bool unit_get_show_bar(const Unit unit)
|
||||
{
|
||||
const UnitKind show_bar_per_unit = settings_get_show_bar_per_unit();
|
||||
|
||||
if (unit->kind == show_bar_per_unit) {
|
||||
return unit->show_bar;
|
||||
} else if (unit->kind > show_bar_per_unit) {
|
||||
return unit_get_show_bar(unit->parent);
|
||||
} else {
|
||||
// TODO: maybe we should assert here
|
||||
return settings_get_show_bar_by_default();
|
||||
}
|
||||
}
|
||||
|
||||
bool unit_toggle_show_bar(const Unit unit)
|
||||
{
|
||||
const UnitKind show_bar_per_unit = settings_get_show_bar_per_unit();
|
||||
|
||||
if (unit->kind == show_bar_per_unit) {
|
||||
return unit->show_bar = !unit->show_bar;
|
||||
} else if (unit->kind > show_bar_per_unit) {
|
||||
return unit_toggle_show_bar(unit->parent);
|
||||
} else {
|
||||
// TODO: maybe we should assert here
|
||||
return settings_get_show_bar_by_default();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue