Allow to disable dynamic fullscreen borders and gaps

When there are some fullscreen windows in monocle layout,
it may be annoying than borders and gaps are changed when you
change focus.
This commit is contained in:
Alex Kotov 2021-11-16 07:12:27 +05:00
parent 8dff8c8ed1
commit 709a30d70b
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
5 changed files with 33 additions and 12 deletions

View file

@ -22,8 +22,8 @@ centeredmaster(Monitor *m)
const bool is_fullscreen = m->sel == NULL ? false : m->sel->isfullscreen;
const int gap_size = helpers_gap_size(n, is_fullscreen);
const int border_width = helpers_border_width(n, is_fullscreen);
const int gap_size = helpers_gap_size(n, is_fullscreen, is_fullscreen);
const int border_width = helpers_border_width(n, is_fullscreen, is_fullscreen);
const int top_left_half_gap = gap_size / 2;
const int bottom_right_half_gap = gap_size - top_left_half_gap;
@ -101,10 +101,15 @@ centeredmaster(Monitor *m)
void
monocle(Monitor *m)
{
bool any_is_fullscreen = false;
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
any_is_fullscreen = any_is_fullscreen || c->isfullscreen;
}
const bool is_fullscreen = m->sel == NULL ? false : m->sel->isfullscreen;
const int gap_size = helpers_gap_size(1, is_fullscreen);
const int border_width = helpers_border_width(1, is_fullscreen);
const int gap_size = helpers_gap_size(1, is_fullscreen, any_is_fullscreen);
const int border_width = helpers_border_width(1, is_fullscreen, any_is_fullscreen);
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
resize(
@ -128,8 +133,8 @@ tile(Monitor *m)
const bool is_fullscreen = m->sel == NULL ? false : m->sel->isfullscreen;
const int gap_size = helpers_gap_size(n, is_fullscreen);
const int border_width = helpers_border_width(n, is_fullscreen);
const int gap_size = helpers_gap_size(n, is_fullscreen, is_fullscreen);
const int border_width = helpers_border_width(n, is_fullscreen, is_fullscreen);
const int top_left_half_gap = gap_size / 2;
const int bottom_right_half_gap = gap_size - top_left_half_gap;

View file

@ -4,7 +4,8 @@
int helpers_gap_size(
const unsigned int displayed_clients,
const bool selected_is_fullscreen
const bool selected_is_fullscreen,
const bool any_is_fullscreen
) {
const SettingsForSingleWindow gap_for_single_window = settings_get_gap_for_single_window();
const int gap_size = settings_get_gap_size();
@ -18,6 +19,8 @@ int helpers_gap_size(
return gap_size;
case SETTINGS_FOR_SINGLE_WINDOW_NOT_IN_FULLSCREEN:
return selected_is_fullscreen ? 0 : gap_size;
case SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN:
return (selected_is_fullscreen || any_is_fullscreen) ? 0 : gap_size;
default:
// TODO: maybe we should assert here
return 0;
@ -26,7 +29,8 @@ int helpers_gap_size(
int helpers_border_width(
const unsigned int displayed_clients,
const bool selected_is_fullscreen
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();
@ -40,6 +44,8 @@ int helpers_border_width(
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;

View file

@ -3,7 +3,16 @@
#include <stdbool.h>
int helpers_gap_size(unsigned int displayed_clients, bool selected_is_fullscreen);
int helpers_border_width(unsigned int displayed_clients, bool selected_is_fullscreen);
int helpers_gap_size(
unsigned int displayed_clients,
bool selected_is_fullscreen,
bool any_is_fullscreen
);
int helpers_border_width(
unsigned int displayed_clients,
bool selected_is_fullscreen,
bool any_is_fullscreen
);
#endif // _HELPERS_H

View file

@ -13,8 +13,8 @@
static int border_width = 2;
static int default_clients_in_master = 1;
static SettingsForSingleWindow border_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOT_IN_FULLSCREEN;
static SettingsForSingleWindow gap_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOT_IN_FULLSCREEN;
static SettingsForSingleWindow border_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
static SettingsForSingleWindow gap_for_single_window = SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN;
static bool enable_swallowing = true;
static bool focus_on_wheel = true;
static int gap_size = 10;

View file

@ -7,6 +7,7 @@ typedef enum {
SETTINGS_FOR_SINGLE_WINDOW_NEVER,
SETTINGS_FOR_SINGLE_WINDOW_ALWAYS,
SETTINGS_FOR_SINGLE_WINDOW_NOT_IN_FULLSCREEN,
SETTINGS_FOR_SINGLE_WINDOW_NOBODY_IS_FULLSCREEN,
} SettingsForSingleWindow;
int settings_get_border_width();