Move func "settings_(get|set)_show_bar_per_unit" to Rust

This commit is contained in:
Alex Kotov 2022-09-09 00:14:46 +04:00
parent 2f07381331
commit 7f719017a6
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 23 additions and 18 deletions

View file

@ -24,7 +24,6 @@ MODULES_SRC = \
src/helpers.c \
src/layouts.c \
src/logger.c \
src/settings.c \
src/spawn.c \
src/state.c \
src/unit.c \
@ -45,7 +44,7 @@ TEST_SRC = \
MAIN_SRC = $(MODULES_SRC) src/main.c
MODULES_HDR = $(MODULES_SRC:.c=.h) src/constraints.h
MODULES_HDR = $(MODULES_SRC:.c=.h) src/constraints.h src/settings.h
DWM_HDR = $(DWM_SRC:.c=.h)
MAIN_HDR = $(MODULES_HDR) src/main.h

View file

@ -155,6 +155,16 @@ unsafe extern "C" fn settings_set_show_bar_by_default(value: bool) {
SETTINGS.unwrap().show_bar_by_default_set(value);
}
#[no_mangle]
unsafe extern "C" fn settings_get_show_bar_per_unit() -> c_uchar {
SETTINGS.unwrap().show_bar_per_unit().into()
}
#[no_mangle]
unsafe extern "C" fn settings_set_show_bar_per_unit(value: c_uchar) {
SETTINGS.unwrap().show_bar_per_unit_set(value.into());
}
#[no_mangle]
unsafe extern "C" fn settings_get_snap_distance() -> c_uint {
SETTINGS.unwrap().snap_distance()

View file

@ -1,16 +0,0 @@
#include "settings.h"
#include "constraints.h"
static UnitKind show_bar_per_unit = UNIT_MONITOR;
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
}

View file

@ -18,6 +18,7 @@ pub struct Settings {
max_clients_in_master: Option<c_int>,
respect_resize_hints_in_floating_layout: bool,
show_bar_by_default: bool,
show_bar_per_unit: unit::Kind,
snap_distance: c_uint,
swallow_floating: bool,
}
@ -46,6 +47,7 @@ impl Default for Settings {
max_clients_in_master: None,
respect_resize_hints_in_floating_layout: false,
show_bar_by_default: true,
show_bar_per_unit: unit::Kind::Monitor,
snap_distance: 32,
swallow_floating: false,
}
@ -164,6 +166,7 @@ impl Settings {
self.master_area_factor_per_unit
}
// TODO: notify WM to rearrange clients
pub fn master_area_factor_per_unit_set(&mut self, value: unit::Kind) {
self.master_area_factor_per_unit = value;
}
@ -195,6 +198,15 @@ impl Settings {
self.show_bar_by_default = value;
}
pub fn show_bar_per_unit(&self) -> unit::Kind {
self.show_bar_per_unit
}
// TODO: notify WM to rearrange clients
pub fn show_bar_per_unit_set(&mut self, value: unit::Kind) {
self.show_bar_per_unit = value;
}
pub fn snap_distance(&self) -> c_uint {
self.snap_distance
}