Move funcs "settings_(get|set)_bar_on_top_by_default" to Rust
This commit is contained in:
parent
363cbfc894
commit
ed910c1fff
6 changed files with 100 additions and 11 deletions
48
Cargo.lock
generated
48
Cargo.lock
generated
|
@ -2,6 +2,54 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdffe87e1d521a10f9696f833fe502293ea446d7f256c06128293a4119bdf4cb"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polytreewm"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"ctor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.99"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
|
||||
|
|
|
@ -15,3 +15,6 @@ publish = false
|
|||
[lib]
|
||||
name = "polytreewm"
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[dependencies]
|
||||
ctor = "0.1.23"
|
||||
|
|
23
src/api.rs
23
src/api.rs
|
@ -2,6 +2,29 @@ use crate::*;
|
|||
|
||||
use std::os::raw::*;
|
||||
|
||||
use ctor::ctor;
|
||||
|
||||
/************
|
||||
* Settings *
|
||||
************/
|
||||
|
||||
static mut SETTINGS: Option<Settings> = None;
|
||||
|
||||
#[ctor]
|
||||
unsafe fn ctor() {
|
||||
SETTINGS = Some(Default::default());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn settings_get_bar_on_top_by_default() -> bool {
|
||||
SETTINGS.unwrap().bar_on_top_by_default()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn settings_set_bar_on_top_by_default(value: bool) {
|
||||
SETTINGS.unwrap().bar_on_top_by_default_set(value);
|
||||
}
|
||||
|
||||
/***************
|
||||
* Constraints *
|
||||
***************/
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
mod api;
|
||||
mod constraints;
|
||||
mod settings;
|
||||
|
||||
pub mod geom;
|
||||
|
||||
pub use settings::Settings;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "constraints.h"
|
||||
|
||||
static bool bar_on_top_by_default = true;
|
||||
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;
|
||||
|
@ -19,16 +18,6 @@ static UnitKind show_bar_per_unit = UNIT_MONITOR;
|
|||
static unsigned int snap_distance = 32;
|
||||
static bool swallow_floating = false;
|
||||
|
||||
bool settings_get_bar_on_top_by_default()
|
||||
{
|
||||
return bar_on_top_by_default;
|
||||
}
|
||||
|
||||
void settings_set_bar_on_top_by_default(bool new_bar_on_top_by_default)
|
||||
{
|
||||
bar_on_top_by_default = new_bar_on_top_by_default;
|
||||
}
|
||||
|
||||
SettingsForSingleWindow settings_get_border_for_single_window()
|
||||
{
|
||||
return border_for_single_window;
|
||||
|
|
22
src/settings.rs
Normal file
22
src/settings.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Settings {
|
||||
bar_on_top_by_default: bool,
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
bar_on_top_by_default: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn bar_on_top_by_default(&self) -> bool {
|
||||
self.bar_on_top_by_default
|
||||
}
|
||||
|
||||
pub fn bar_on_top_by_default_set(&mut self, bar_on_top_by_default: bool) {
|
||||
self.bar_on_top_by_default = bar_on_top_by_default;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue