Compare commits
3 Commits
1bf97dab72
...
7f719017a6
Author | SHA1 | Date |
---|---|---|
Alex Kotov | 7f719017a6 | |
Alex Kotov | 2f07381331 | |
Alex Kotov | 23c415dcde |
3
Makefile
3
Makefile
|
@ -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
|
||||
|
||||
|
|
|
@ -101,6 +101,18 @@ unsafe extern "C" fn settings_set_gap_size(value: c_int) {
|
|||
SETTINGS.unwrap().gap_size_set(value);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn settings_get_master_area_factor_per_unit() -> c_uchar {
|
||||
SETTINGS.unwrap().master_area_factor_per_unit().into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn settings_set_master_area_factor_per_unit(value: c_uchar) {
|
||||
SETTINGS
|
||||
.unwrap()
|
||||
.master_area_factor_per_unit_set(value.into());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn settings_get_max_clients_in_master() -> c_int {
|
||||
match SETTINGS.unwrap().max_clients_in_master() {
|
||||
|
@ -143,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()
|
||||
|
|
|
@ -3,5 +3,6 @@ mod constraints;
|
|||
|
||||
pub mod geom;
|
||||
pub mod settings;
|
||||
pub mod unit;
|
||||
|
||||
pub use settings::Settings;
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
#include "settings.h"
|
||||
|
||||
#include "constraints.h"
|
||||
|
||||
static UnitKind master_area_factor_per_unit = UNIT_MONITOR;
|
||||
static UnitKind show_bar_per_unit = UNIT_MONITOR;
|
||||
|
||||
UnitKind settings_get_master_area_factor_per_unit()
|
||||
{
|
||||
return master_area_factor_per_unit;
|
||||
}
|
||||
|
||||
void settings_set_master_area_factor_per_unit(const UnitKind new_master_area_factor_per_unit)
|
||||
{
|
||||
master_area_factor_per_unit = new_master_area_factor_per_unit;
|
||||
// TODO: notify WM to rearrange clients
|
||||
}
|
||||
|
||||
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
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
use crate::constraints;
|
||||
use crate::unit;
|
||||
|
||||
use std::os::raw::*;
|
||||
|
||||
|
@ -13,9 +14,11 @@ pub struct Settings {
|
|||
focus_on_wheel: bool,
|
||||
gap_for_single_window: ForSingleWindow,
|
||||
gap_size: c_int,
|
||||
master_area_factor_per_unit: unit::Kind,
|
||||
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,
|
||||
}
|
||||
|
@ -40,9 +43,11 @@ impl Default for Settings {
|
|||
focus_on_wheel: true,
|
||||
gap_for_single_window: Default::default(),
|
||||
gap_size: 10,
|
||||
master_area_factor_per_unit: unit::Kind::Monitor,
|
||||
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,
|
||||
}
|
||||
|
@ -157,6 +162,15 @@ impl Settings {
|
|||
self.gap_size = constraints::gap_size(value);
|
||||
}
|
||||
|
||||
pub fn master_area_factor_per_unit(&self) -> unit::Kind {
|
||||
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;
|
||||
}
|
||||
|
||||
pub fn max_clients_in_master(&self) -> Option<c_int> {
|
||||
self.max_clients_in_master
|
||||
}
|
||||
|
@ -184,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
|
||||
}
|
||||
|
|
10
src/unit.h
10
src/unit.h
|
@ -9,11 +9,11 @@
|
|||
unit = NULL; \
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
UNIT_GLOBAL = 0,
|
||||
UNIT_MONITOR = 1,
|
||||
UNIT_TAG = 2,
|
||||
} UnitKind;
|
||||
typedef unsigned char UnitKind;
|
||||
|
||||
#define UNIT_GLOBAL 0
|
||||
#define UNIT_MONITOR 1
|
||||
#define UNIT_TAG 2
|
||||
|
||||
typedef struct Unit *Unit;
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
use std::os::raw::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Kind {
|
||||
Global,
|
||||
Monitor,
|
||||
Tag,
|
||||
}
|
||||
|
||||
impl Into<c_uchar> for Kind {
|
||||
fn into(self) -> c_uchar {
|
||||
match self {
|
||||
Self::Global => 0,
|
||||
Self::Monitor => 1,
|
||||
Self::Tag => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<c_uchar> for Kind {
|
||||
fn from(value: c_uchar) -> Self {
|
||||
match value {
|
||||
0 => Self::Global,
|
||||
1 => Self::Monitor,
|
||||
2 => Self::Tag,
|
||||
_ => panic!("invalid value for type Kind"),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue