Move func "settings_(get|set)_border_width" to Rust
This commit is contained in:
parent
1357b10495
commit
275076396e
5 changed files with 29 additions and 20 deletions
|
@ -2,11 +2,6 @@ use crate::*;
|
||||||
|
|
||||||
use std::os::raw::*;
|
use std::os::raw::*;
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
extern "C" fn constraints_border_width(border_width: c_int) -> c_int {
|
|
||||||
constraints::border_width(border_width)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn constraints_default_clients_in_master(
|
extern "C" fn constraints_default_clients_in_master(
|
||||||
default_clients_in_master: c_int,
|
default_clients_in_master: c_int,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
use std::os::raw::*;
|
||||||
|
|
||||||
use ctor::ctor;
|
use ctor::ctor;
|
||||||
|
|
||||||
static mut SETTINGS: Option<Settings> = None;
|
static mut SETTINGS: Option<Settings> = None;
|
||||||
|
@ -18,3 +20,13 @@ unsafe extern "C" fn settings_get_bar_on_top_by_default() -> bool {
|
||||||
unsafe extern "C" fn settings_set_bar_on_top_by_default(value: bool) {
|
unsafe extern "C" fn settings_set_bar_on_top_by_default(value: bool) {
|
||||||
SETTINGS.unwrap().bar_on_top_by_default_set(value);
|
SETTINGS.unwrap().bar_on_top_by_default_set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn settings_get_border_width() -> c_int {
|
||||||
|
SETTINGS.unwrap().border_width()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
unsafe extern "C" fn settings_set_border_width(value: c_int) {
|
||||||
|
SETTINGS.unwrap().border_width_set(value);
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef _CONSTRAINTS_H
|
#ifndef _CONSTRAINTS_H
|
||||||
#define _CONSTRAINTS_H
|
#define _CONSTRAINTS_H
|
||||||
|
|
||||||
int constraints_border_width(int border_width);
|
|
||||||
int constraints_default_clients_in_master(int default_clients_in_master);
|
int constraints_default_clients_in_master(int default_clients_in_master);
|
||||||
float constraints_default_master_area_factor(float default_master_area_factor);
|
float constraints_default_master_area_factor(float default_master_area_factor);
|
||||||
int constraints_gap_size(int gap_size);
|
int constraints_gap_size(int gap_size);
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "constraints.h"
|
#include "constraints.h"
|
||||||
|
|
||||||
static SettingsForSingleWindow border_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
|
static SettingsForSingleWindow border_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
|
||||||
static int border_width = 2;
|
|
||||||
static int default_clients_in_master = 1;
|
static int default_clients_in_master = 1;
|
||||||
static float default_master_area_factor = 0.6;
|
static float default_master_area_factor = 0.6;
|
||||||
static SettingsForSingleWindow gap_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
|
static SettingsForSingleWindow gap_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
|
||||||
|
@ -29,17 +28,6 @@ void settings_set_border_for_single_window(const SettingsForSingleWindow new_bor
|
||||||
// TODO: notify WM to rearrange clients
|
// TODO: notify WM to rearrange clients
|
||||||
}
|
}
|
||||||
|
|
||||||
int settings_get_border_width()
|
|
||||||
{
|
|
||||||
return border_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
void settings_set_border_width(const int new_border_width)
|
|
||||||
{
|
|
||||||
border_width = constraints_border_width(new_border_width);
|
|
||||||
// TODO: notify WM to rearrange clients
|
|
||||||
}
|
|
||||||
|
|
||||||
int settings_get_default_clients_in_master()
|
int settings_get_default_clients_in_master()
|
||||||
{
|
{
|
||||||
return default_clients_in_master;
|
return default_clients_in_master;
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
|
use crate::constraints;
|
||||||
|
|
||||||
|
use std::os::raw::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
bar_on_top_by_default: bool,
|
bar_on_top_by_default: bool,
|
||||||
|
border_width: c_int,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Settings {
|
impl Default for Settings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
bar_on_top_by_default: true,
|
bar_on_top_by_default: true,
|
||||||
|
border_width: 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +22,16 @@ impl Settings {
|
||||||
self.bar_on_top_by_default
|
self.bar_on_top_by_default
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bar_on_top_by_default_set(&mut self, bar_on_top_by_default: bool) {
|
pub fn bar_on_top_by_default_set(&mut self, value: bool) {
|
||||||
self.bar_on_top_by_default = bar_on_top_by_default;
|
self.bar_on_top_by_default = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn border_width(&self) -> c_int {
|
||||||
|
self.border_width
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: notify WM to rearrange clients
|
||||||
|
pub fn border_width_set(&mut self, value: c_int) {
|
||||||
|
self.border_width = constraints::border_width(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue