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

This commit is contained in:
Alex Kotov 2022-09-08 15:58:08 +04:00
parent 275076396e
commit a3696a40f1
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 21 additions and 19 deletions

View file

@ -2,13 +2,6 @@ use crate::*;
use std::os::raw::*;
#[no_mangle]
extern "C" fn constraints_default_clients_in_master(
default_clients_in_master: c_int,
) -> c_int {
constraints::default_clients_in_master(default_clients_in_master)
}
#[no_mangle]
extern "C" fn constraints_default_master_area_factor(
default_master_area_factor: c_float,

View file

@ -30,3 +30,13 @@ unsafe extern "C" fn settings_get_border_width() -> c_int {
unsafe extern "C" fn settings_set_border_width(value: c_int) {
SETTINGS.unwrap().border_width_set(value);
}
#[no_mangle]
unsafe extern "C" fn settings_get_default_clients_in_master() -> c_int {
SETTINGS.unwrap().default_clients_in_master()
}
#[no_mangle]
unsafe extern "C" fn settings_set_default_clients_in_master(value: c_int) {
SETTINGS.unwrap().default_clients_in_master_set(value);
}

View file

@ -1,7 +1,6 @@
#ifndef _CONSTRAINTS_H
#define _CONSTRAINTS_H
int constraints_default_clients_in_master(int default_clients_in_master);
float constraints_default_master_area_factor(float default_master_area_factor);
int constraints_gap_size(int gap_size);
float constraints_master_area_factor(float master_area_factor);

View file

@ -3,7 +3,6 @@
#include "constraints.h"
static SettingsForSingleWindow border_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
static int default_clients_in_master = 1;
static float default_master_area_factor = 0.6;
static SettingsForSingleWindow gap_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
static bool enable_swallowing = true;
@ -28,16 +27,6 @@ void settings_set_border_for_single_window(const SettingsForSingleWindow new_bor
// TODO: notify WM to rearrange clients
}
int settings_get_default_clients_in_master()
{
return default_clients_in_master;
}
void settings_set_default_clients_in_master(const int new_default_clients_in_master)
{
default_clients_in_master = constraints_default_clients_in_master(new_default_clients_in_master);
}
float settings_get_default_master_area_factor()
{
return default_master_area_factor;

View file

@ -6,6 +6,7 @@ use std::os::raw::*;
pub struct Settings {
bar_on_top_by_default: bool,
border_width: c_int,
default_clients_in_master: c_int,
}
impl Default for Settings {
@ -13,6 +14,7 @@ impl Default for Settings {
Self {
bar_on_top_by_default: true,
border_width: 2,
default_clients_in_master: 1,
}
}
}
@ -34,4 +36,13 @@ impl Settings {
pub fn border_width_set(&mut self, value: c_int) {
self.border_width = constraints::border_width(value);
}
pub fn default_clients_in_master(&self) -> c_int {
self.default_clients_in_master
}
pub fn default_clients_in_master_set(&mut self, value: c_int) {
self.default_clients_in_master =
constraints::default_clients_in_master(value);
}
}