Move func "helpers_border_width" to Rust
This commit is contained in:
parent
b2d677d39f
commit
6698c8a72f
4 changed files with 43 additions and 29 deletions
1
Makefile
1
Makefile
|
@ -22,7 +22,6 @@ MODULES_SRC = \
|
|||
src/drw.c \
|
||||
src/dwm.c \
|
||||
src/geom.c \
|
||||
src/helpers.c \
|
||||
src/layouts.c \
|
||||
src/logger.c \
|
||||
src/spawn.c \
|
||||
|
|
|
@ -185,6 +185,19 @@ unsafe extern "C" fn settings_set_swallow_floating(value: bool) {
|
|||
SETTINGS.unwrap().swallow_floating_set(value);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn helpers_border_width(
|
||||
displayed_clients: c_uint,
|
||||
selected_is_fullscreen: bool,
|
||||
any_is_fullscreen: bool,
|
||||
) -> c_int {
|
||||
SETTINGS.unwrap().border_width_helper(
|
||||
displayed_clients,
|
||||
selected_is_fullscreen,
|
||||
any_is_fullscreen,
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn helpers_gap_size(
|
||||
displayed_clients: c_uint,
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
#include "helpers.h"
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
int helpers_border_width(
|
||||
const unsigned int displayed_clients,
|
||||
const bool selected_is_fullscreen,
|
||||
const bool any_is_fullscreen
|
||||
) {
|
||||
const SettingsForSingleWindow border_for_single_window = settings_get_border_for_single_window();
|
||||
const int border_width = settings_get_border_width();
|
||||
|
||||
if (displayed_clients > 1) return border_width;
|
||||
|
||||
switch (border_for_single_window) {
|
||||
case SETTINGS_FOR_SINGLE_WINDOW_NEVER:
|
||||
return 0;
|
||||
case SETTINGS_FOR_SINGLE_WINDOW_ALWAYS:
|
||||
return border_width;
|
||||
case SETTINGS_FOR_SINGLE_WINDOW_NOT_IN_FULLSCREEN:
|
||||
return selected_is_fullscreen ? 0 : border_width;
|
||||
case SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN:
|
||||
return (selected_is_fullscreen || any_is_fullscreen) ? 0 : border_width;
|
||||
default:
|
||||
// TODO: maybe we should assert here
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -110,6 +110,36 @@ impl Settings {
|
|||
self.border_width = constraints::border_width(value);
|
||||
}
|
||||
|
||||
pub fn border_width_helper(
|
||||
&self,
|
||||
displayed_clients: c_uint,
|
||||
selected_is_fullscreen: bool,
|
||||
any_is_fullscreen: bool,
|
||||
) -> c_int {
|
||||
if displayed_clients > 1 {
|
||||
return self.border_width;
|
||||
}
|
||||
|
||||
match self.border_for_single_window {
|
||||
ForSingleWindow::Never => 0,
|
||||
ForSingleWindow::Always => self.border_width,
|
||||
ForSingleWindow::NotInFullscreen => {
|
||||
if selected_is_fullscreen {
|
||||
0
|
||||
} else {
|
||||
self.border_width
|
||||
}
|
||||
}
|
||||
ForSingleWindow::NobodyIsFullscreen => {
|
||||
if selected_is_fullscreen || any_is_fullscreen {
|
||||
0
|
||||
} else {
|
||||
self.border_width
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_clients_in_master(&self) -> c_int {
|
||||
self.default_clients_in_master
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue