Skip to content

Commit

Permalink
Add setting: ignore_ewmh_fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Mar 14, 2018
1 parent 14d575a commit 59a9785
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 9 deletions.
2 changes: 1 addition & 1 deletion contrib/bash_completion
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_bspc() {
local commands='node desktop monitor query rule wm subscribe config quit'

local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus ignore_ewmh_fullscreen center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'

COMPREPLY=()

Expand Down
2 changes: 1 addition & 1 deletion contrib/fish_completion
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ function __fish_bspc_using_command
end

complete -f -c bspc -n '__fish_bspc_needs_command' -a 'node desktop monitor query rule wm subscribe config quit'
complete -f -c bspc -n '__fish_bspc_using_command config' -a 'external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
complete -f -c bspc -n '__fish_bspc_using_command config' -a 'external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity directional_focus_tightness borderless_monocle gapless_monocle single_monocle pointer_motion_interval pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus swallow_first_click focus_follows_pointer pointer_follows_focus pointer_follows_monitor mapping_events_count ignore_ewmh_focus ignore_ewmh_fullscreen center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
2 changes: 1 addition & 1 deletion contrib/zsh_completion
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ _bspc() {
local -a look behaviour input
# Boolean settings are identified by index!
look=(borderless_monocle gapless_monocle {normal,active,focused}_border_color {top,right,bottom,left}_padding presel_feedback_color border_width window_gap)
behaviour=(single_monocle mapping_events_count ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors status_prefix external_rules_command split_ratio initial_polarity directional_focus_tightness status_prefix)
behaviour=(single_monocle mapping_events_count ignore_ewmh_focus ignore_ewmh_fullscreen center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors status_prefix external_rules_command split_ratio initial_polarity directional_focus_tightness status_prefix)
input=({swallow_first_click,focus_follows_pointer,pointer_follows_{focus,monitor}} click_to_focus pointer_motion_interval pointer_modifier pointer_action{1,2,3} )
if [[ "$CURRENT" == (2|3) ]];then
_arguments \
Expand Down
15 changes: 12 additions & 3 deletions doc/bspwm.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 03/07/2018
.\" Date: 03/14/2018
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9.3-57-g582a843
.\" Source: Bspwm 0.9.3-59-g14d575a
.\" Language: English
.\"
.TH "BSPWM" "1" "03/07/2018" "Bspwm 0\&.9\&.3\-57\-g582a843" "Bspwm Manual"
.TH "BSPWM" "1" "03/14/2018" "Bspwm 0\&.9\&.3\-59\-g14d575a" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -1266,6 +1266,15 @@ mapping notify events\&. A negative value implies that every event needs to be h
Ignore EWMH focus requests coming from applications\&.
.RE
.PP
\fIignore_ewmh_fullscreen\fR
.RS 4
Block the fullscreen state transitions that originate from an EWMH request\&. The possible values are:
\fBnone\fR,
\fBall\fR, or a comma separated list of the following values:
\fBenter\fR,
\fBexit\fR\&.
.RE
.PP
\fIcenter_pseudo_tiled\fR
.RS 4
Center pseudo tiled windows into their tiling rectangles\&. Defaults to
Expand Down
3 changes: 3 additions & 0 deletions doc/bspwm.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,9 @@ Global Settings
'ignore_ewmh_focus'::
Ignore EWMH focus requests coming from applications.
'ignore_ewmh_fullscreen'::
Block the fullscreen state transitions that originate from an EWMH request. The possible values are: *none*, *all*, or a comma separated list of the following values: *enter*, *exit*.
'center_pseudo_tiled'::
Center pseudo tiled windows into their tiling rectangles. Defaults to 'true'.
Expand Down
10 changes: 7 additions & 3 deletions src/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,18 @@ void motion_notify(xcb_generic_event_t *evt)
void handle_state(monitor_t *m, desktop_t *d, node_t *n, xcb_atom_t state, unsigned int action)
{
if (state == ewmh->_NET_WM_STATE_FULLSCREEN) {
if (action == XCB_EWMH_WM_STATE_ADD) {
if (action == XCB_EWMH_WM_STATE_ADD && (ignore_ewmh_fullscreen & STATE_TRANSITION_ENTER) == 0) {
set_state(m, d, n, STATE_FULLSCREEN);
} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
} else if (action == XCB_EWMH_WM_STATE_REMOVE && (ignore_ewmh_fullscreen & STATE_TRANSITION_EXIT) == 0) {
if (n->client->state == STATE_FULLSCREEN) {
set_state(m, d, n, n->client->last_state);
}
} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
set_state(m, d, n, IS_FULLSCREEN(n->client) ? n->client->last_state : STATE_FULLSCREEN);
client_state_t next_state = IS_FULLSCREEN(n->client) ? n->client->last_state : STATE_FULLSCREEN;
if ((next_state == STATE_FULLSCREEN && (ignore_ewmh_fullscreen & STATE_TRANSITION_ENTER) == 0) ||
(next_state != STATE_FULLSCREEN && (ignore_ewmh_fullscreen & STATE_TRANSITION_EXIT) == 0)) {
set_state(m, d, n, next_state);
}
}
arrange(m, d);
} else if (state == ewmh->_NET_WM_STATE_BELOW) {
Expand Down
10 changes: 10 additions & 0 deletions src/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,14 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
return;
}
} else if (streq("ignore_ewmh_fullscreen", name)) {
state_transition_t m;
if (parse_state_transition(value, &m)) {
ignore_ewmh_fullscreen = m;
} else {
fail(rsp, "config: %s: Invalid value: '%s'.\n", name, value);
return;
}
} else if (streq("pointer_modifier", name)) {
if (parse_modifier_mask(value, &pointer_modifier)) {
ungrab_buttons();
Expand Down Expand Up @@ -1727,6 +1735,8 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
fprintf(rsp, "%" PRIi8, mapping_events_count);
} else if (streq("directional_focus_tightness", name)) {
fprintf(rsp, "%s", TIGHTNESS_STR(directional_focus_tightness));
} else if (streq("ignore_ewmh_fullscreen", name)) {
print_ignore_request(ignore_ewmh_fullscreen, rsp);
} else if (streq("pointer_modifier", name)) {
print_modifier_mask(pointer_modifier, rsp);
} else if (streq("click_to_focus", name)) {
Expand Down
34 changes: 34 additions & 0 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,40 @@ bool parse_child_polarity(char *s, child_polarity_t *p)
return false;
}

bool parse_state_transition(char *s, state_transition_t *m)
{
if (streq("none", s)) {
*m = 0;
return true;
} else if (streq("all", s)) {
*m = STATE_TRANSITION_ENTER | STATE_TRANSITION_EXIT;
return true;
} else {
state_transition_t w = 0;
char *x = copy_string(s, strlen(s));
char *key = strtok(x, ",");
while (key != NULL) {
if (streq("enter", key)) {
w |= STATE_TRANSITION_ENTER;
} else if (streq("exit", key)) {
w |= STATE_TRANSITION_EXIT;
} else {
free(x);
return false;
}
key = strtok(NULL, ",");
}
free(x);
if (w != 0) {
*m = w;
return true;
} else {
return false;
}
}
return false;
}

bool parse_tightness(char *s, tightness_t *t)
{
if (streq("high", s)) {
Expand Down
1 change: 1 addition & 0 deletions src/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bool parse_modifier_mask(char *s, uint16_t *m);
bool parse_button_index(char *s, int8_t *b);
bool parse_pointer_action(char *s, pointer_action_t *a);
bool parse_child_polarity(char *s, child_polarity_t *p);
bool parse_state_transition(char *s, state_transition_t *m);
bool parse_tightness(char *s, tightness_t *t);
bool parse_degree(char *s, int *d);
bool parse_id(char *s, uint32_t *id);
Expand Down
16 changes: 16 additions & 0 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,22 @@ void fprint_desktop_name(desktop_t *d, FILE *rsp)
fprintf(rsp, "%s\n", d->name);
}

void print_ignore_request(state_transition_t st, FILE *rsp)
{
if (st == 0) {
fprintf(rsp, "none");
} else {
unsigned int cnt = 0;
if (st & STATE_TRANSITION_ENTER) {
fprintf(rsp, "enter");
cnt++;
}
if (st & STATE_TRANSITION_EXIT) {
fprintf(rsp, "%sexit", cnt > 0 ? "," : "");
}
}
}

void print_modifier_mask(uint16_t m, FILE *rsp)
{
switch (m) {
Expand Down
1 change: 1 addition & 0 deletions src/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void fprint_monitor_id(monitor_t *m, FILE *rsp);
void fprint_monitor_name(monitor_t *m, FILE *rsp);
void fprint_desktop_id(desktop_t *d, FILE *rsp);
void fprint_desktop_name(desktop_t *d, FILE *rsp);
void print_ignore_request(state_transition_t st, FILE *rsp);
void print_modifier_mask(uint16_t m, FILE *rsp);
void print_button_index(int8_t b, FILE *rsp);
void print_pointer_action(pointer_action_t a, FILE *rsp);
Expand Down
1 change: 1 addition & 0 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void load_settings(void)
click_to_focus = CLICK_TO_FOCUS;
swallow_first_click = SWALLOW_FIRST_CLICK;
ignore_ewmh_focus = IGNORE_EWMH_FOCUS;
ignore_ewmh_fullscreen = IGNORE_EWMH_FULLSCREEN;

center_pseudo_tiled = CENTER_PSEUDO_TILED;
honor_size_hints = HONOR_SIZE_HINTS;
Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#define CLICK_TO_FOCUS -1
#define SWALLOW_FIRST_CLICK false
#define IGNORE_EWMH_FOCUS false
#define IGNORE_EWMH_FULLSCREEN 0

#define CENTER_PSEUDO_TILED true
#define HONOR_SIZE_HINTS false
Expand Down Expand Up @@ -93,6 +94,7 @@ bool pointer_follows_monitor;
int8_t click_to_focus;
bool swallow_first_click;
bool ignore_ewmh_focus;
state_transition_t ignore_ewmh_fullscreen;

bool center_pseudo_tiled;
bool honor_size_hints;
Expand Down
5 changes: 5 additions & 0 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ typedef enum {
TIGHTNESS_HIGH,
} tightness_t;

typedef enum {
STATE_TRANSITION_ENTER = 1 << 0,
STATE_TRANSITION_EXIT = 1 << 1,
} state_transition_t;

typedef struct {
option_bool_t automatic;
option_bool_t focused;
Expand Down

0 comments on commit 59a9785

Please sign in to comment.