mirror of
https://github.com/vale981/bspwm
synced 2025-03-05 09:51:38 -05:00
Fix "alternate" command, min width,height is 1,1
This commit is contained in:
parent
dbf16cee32
commit
0bd88d9824
7 changed files with 32 additions and 33 deletions
7
events.c
7
events.c
|
@ -70,9 +70,9 @@ void map_request(xcb_generic_event_t *evt)
|
|||
c->rectangle = (xcb_rectangle_t) {0, 0, 320, 240};
|
||||
}
|
||||
|
||||
bool floating = false, transient = false, takes_focus = true;
|
||||
bool floating = false, transient = false, fullscreen = false, takes_focus = true;
|
||||
|
||||
handle_rules(win, &floating, &transient, &takes_focus);
|
||||
handle_rules(win, &floating, &transient, &fullscreen, &takes_focus);
|
||||
|
||||
if (c->transient)
|
||||
floating = true;
|
||||
|
@ -87,6 +87,9 @@ void map_request(xcb_generic_event_t *evt)
|
|||
if (desk->focus != NULL && desk->focus->client->fullscreen)
|
||||
toggle_fullscreen(desk->focus->client);
|
||||
|
||||
if (fullscreen)
|
||||
toggle_fullscreen(birth->client);
|
||||
|
||||
c->transient = transient;
|
||||
|
||||
if (takes_focus)
|
||||
|
|
14
messages.c
14
messages.c
|
@ -55,12 +55,6 @@ void process_message(char *msg, char *rsp)
|
|||
desk->layout = l;
|
||||
}
|
||||
}
|
||||
/* } else if (strcmp(cmd, "insert") == 0) { */
|
||||
/* static unsigned int fake_id = 1; */
|
||||
/* client_t *c = make_client((xcb_window_t) fake_id++); */
|
||||
/* node_t *n = make_node(); */
|
||||
/* n->client = c; */
|
||||
/* insert_node(desk, n); */
|
||||
} else if (strcmp(cmd, "shift") == 0) {
|
||||
char *dir = strtok(NULL, TOKEN_SEP);
|
||||
if (dir != NULL) {
|
||||
|
@ -74,12 +68,15 @@ void process_message(char *msg, char *rsp)
|
|||
toggle_fullscreen(desk->focus->client);
|
||||
return;
|
||||
} else if (strcmp(cmd, "toggle_floating") == 0) {
|
||||
split_mode = MODE_AUTOMATIC;
|
||||
toggle_floating(desk->focus);
|
||||
} else if (strcmp(cmd, "ratio") == 0) {
|
||||
char *value = strtok(NULL, TOKEN_SEP);
|
||||
if (value != NULL && desk->focus != NULL)
|
||||
sscanf(value, "%lf", &desk->focus->split_ratio);
|
||||
} else if (strcmp(cmd, "presel") == 0) {
|
||||
if (desk->focus == NULL || !is_tiled(desk->focus->client) || desk->layout != LAYOUT_TILED)
|
||||
return;
|
||||
char *dir = strtok(NULL, TOKEN_SEP);
|
||||
if (dir != NULL) {
|
||||
direction_t d;
|
||||
|
@ -119,9 +116,7 @@ void process_message(char *msg, char *rsp)
|
|||
if (name != NULL) {
|
||||
desktop_t *d = find_desktop(name);
|
||||
select_desktop(d);
|
||||
apply_layout(d, d->root, root_rect);
|
||||
}
|
||||
return;
|
||||
} else if (strcmp(cmd, "cycle_desktop") == 0) {
|
||||
char *dir = strtok(NULL, TOKEN_SEP);
|
||||
if (dir != NULL) {
|
||||
|
@ -162,7 +157,7 @@ void process_message(char *msg, char *rsp)
|
|||
}
|
||||
return;
|
||||
} else if (strcmp(cmd, "alternate") == 0) {
|
||||
alternate_desktop();
|
||||
select_desktop(last_desk);
|
||||
} else if (strcmp(cmd, "add") == 0) {
|
||||
char *name = strtok(NULL, TOKEN_SEP);
|
||||
if (name != NULL) {
|
||||
|
@ -189,6 +184,7 @@ void process_message(char *msg, char *rsp)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
apply_layout(desk, desk->root, root_rect);
|
||||
}
|
||||
|
||||
|
|
13
rules.c
13
rules.c
|
@ -32,7 +32,7 @@ bool is_match(rule_t *r, xcb_window_t win)
|
|||
return false;
|
||||
}
|
||||
|
||||
void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *takes_focus)
|
||||
void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *fullscreen, bool *takes_focus)
|
||||
{
|
||||
xcb_ewmh_get_atoms_reply_t win_type;
|
||||
|
||||
|
@ -48,6 +48,17 @@ void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *takes
|
|||
}
|
||||
}
|
||||
|
||||
xcb_ewmh_get_atoms_reply_t win_state;
|
||||
|
||||
if (xcb_ewmh_get_wm_state_reply(ewmh, xcb_ewmh_get_wm_state(ewmh, win), &win_state, NULL) == 1) {
|
||||
for (unsigned int i = 0; i < win_state.atoms_len; i++) {
|
||||
xcb_atom_t a = win_state.atoms[i];
|
||||
if (a == ewmh->_NET_WM_STATE_FULLSCREEN) {
|
||||
*fullscreen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* xcb_ewmh_get_atoms_reply_wipe(&win_type); */
|
||||
|
||||
xcb_window_t transient_for = XCB_NONE;
|
||||
|
|
2
rules.h
2
rules.h
|
@ -5,6 +5,6 @@
|
|||
|
||||
rule_t *next_match(rule_t *, xcb_window_t);
|
||||
bool is_match(rule_t *, xcb_window_t);
|
||||
void handle_rules(xcb_window_t, bool *, bool *, bool *);
|
||||
void handle_rules(xcb_window_t, bool *, bool *, bool *, bool *);
|
||||
|
||||
#endif
|
||||
|
|
25
tree.c
25
tree.c
|
@ -242,15 +242,12 @@ void apply_layout(desktop_t *d, node_t *n, xcb_rectangle_t rect)
|
|||
else if (d->layout == LAYOUT_MONOCLE)
|
||||
r = root_rect;
|
||||
int bleed = window_gap + 2 * border_width;
|
||||
r.width = (bleed < r.width ? r.width - bleed : MIN_WIDTH);
|
||||
r.height = (bleed < r.height ? r.height - bleed : MIN_HEIGHT);
|
||||
r.width = (bleed < r.width ? r.width - bleed : 1);
|
||||
r.height = (bleed < r.height ? r.height - bleed : 1);
|
||||
} else {
|
||||
r = n->client->rectangle;
|
||||
}
|
||||
|
||||
r.width = MAX(r.width, MIN_WIDTH);
|
||||
r.height = MAX(r.height, MIN_HEIGHT);
|
||||
|
||||
window_move_resize(n->client->window, r.x, r.y, r.width, r.height);
|
||||
window_border_width(n->client->window, border_width);
|
||||
draw_triple_border(n, (n == d->focus ? active_border_color_pxl : normal_border_color_pxl));
|
||||
|
@ -562,7 +559,6 @@ void select_desktop(desktop_t *d)
|
|||
desk = d;
|
||||
|
||||
update_current();
|
||||
|
||||
ewmh_update_current_desktop();
|
||||
}
|
||||
|
||||
|
@ -591,6 +587,13 @@ void cycle_leaf(desktop_t *d, node_t *n, cycle_dir_t dir, skip_client_t skip)
|
|||
}
|
||||
f = (dir == DIR_PREV ? prev_leaf(f) : next_leaf(f));
|
||||
}
|
||||
|
||||
if (skip == SKIP_NONE && f == NULL) {
|
||||
if (dir == DIR_PREV)
|
||||
focus_node(d, second_extrema(d->root), true);
|
||||
else
|
||||
focus_node(d, first_extrema(d->root), true);
|
||||
}
|
||||
}
|
||||
|
||||
void toggle_floating(node_t *n)
|
||||
|
@ -645,13 +648,3 @@ void add_desktop(char *name)
|
|||
ewmh_update_number_of_desktops();
|
||||
ewmh_update_desktop_names();
|
||||
}
|
||||
|
||||
void alternate_desktop(void)
|
||||
{
|
||||
if (last_desk == NULL)
|
||||
return;
|
||||
desktop_t *tmp = desk;
|
||||
desk = last_desk;
|
||||
last_desk = tmp;
|
||||
select_desktop(desk);
|
||||
}
|
||||
|
|
1
tree.h
1
tree.h
|
@ -36,6 +36,5 @@ void toggle_floating(node_t *);
|
|||
void update_vacant_state(node_t *);
|
||||
desktop_t *find_desktop(char *);
|
||||
void add_desktop(char *);
|
||||
void alternate_desktop(void);
|
||||
|
||||
#endif
|
||||
|
|
3
window.h
3
window.h
|
@ -6,9 +6,6 @@
|
|||
#include <xcb/xcb_event.h>
|
||||
#include "types.h"
|
||||
|
||||
#define MIN_WIDTH 32
|
||||
#define MIN_HEIGHT 32
|
||||
|
||||
bool locate_window(xcb_window_t, window_location_t *);
|
||||
void draw_triple_border(node_t *, uint32_t);
|
||||
void close_window(desktop_t *, node_t *);
|
||||
|
|
Loading…
Add table
Reference in a new issue