mirror of
https://github.com/vale981/bspwm
synced 2025-03-04 17:31:39 -05:00
New argument for the rule
message: follow
This commit is contained in:
parent
67e57260dd
commit
b273b9c9bd
8 changed files with 18 additions and 7 deletions
|
@ -173,7 +173,7 @@ The following messages are handled:
|
|||
|
||||
- `balance` — Adjust the split ratios so that all windows occupy the same area.
|
||||
|
||||
- `rule PATTERN [DESKTOP_NAME] [floating]` — Create a new rule (`PATTERN` must match the class or instance name).
|
||||
- `rule PATTERN [DESKTOP_NAME] [floating] [follow]` — Create a new rule (`PATTERN` must match the class or instance name).
|
||||
|
||||
- `remove_rule UID ...` — Remove the rules with the given UIDs.
|
||||
|
||||
|
|
2
bspwm.1
2
bspwm.1
|
@ -248,7 +248,7 @@ Flip the window tree.
|
|||
.B balance
|
||||
Adjust the split ratios so that all windows occupy the same area.
|
||||
.TP
|
||||
.BI rule " PATTERN [DESKTOP_NAME] [floating]"
|
||||
.BI rule " PATTERN [DESKTOP_NAME] [floating] [follow]"
|
||||
Create a new rule (PATTERN must match the class or instance name).
|
||||
.TP
|
||||
.BI remove_rule " UID ..."
|
||||
|
|
|
@ -367,6 +367,8 @@ void process_message(char *msg, char *rsp)
|
|||
while (arg != NULL) {
|
||||
if (strcmp(arg, "floating") == 0) {
|
||||
rule->effect.floating = true;
|
||||
} else if (strcmp(arg, "follow") == 0) {
|
||||
rule->effect.follow = true;
|
||||
} else {
|
||||
desktop_location_t loc;
|
||||
if (locate_desktop(arg, &loc)) {
|
||||
|
|
6
rules.c
6
rules.c
|
@ -60,7 +60,7 @@ bool is_match(rule_t *r, xcb_window_t win)
|
|||
return false;
|
||||
}
|
||||
|
||||
void handle_rules(xcb_window_t win, monitor_t **m, desktop_t **d, bool *floating, bool *transient, bool *fullscreen, bool *takes_focus, bool *manage)
|
||||
void handle_rules(xcb_window_t win, monitor_t **m, desktop_t **d, bool *floating, bool *follow, bool *transient, bool *fullscreen, bool *takes_focus, bool *manage)
|
||||
{
|
||||
xcb_ewmh_get_atoms_reply_t win_type;
|
||||
|
||||
|
@ -113,6 +113,8 @@ void handle_rules(xcb_window_t win, monitor_t **m, desktop_t **d, bool *floating
|
|||
rule_effect_t efc = rule->effect;
|
||||
if (efc.floating)
|
||||
*floating = true;
|
||||
if (efc.follow)
|
||||
*follow = true;
|
||||
if (efc.monitor != NULL && efc.desktop != NULL) {
|
||||
*m = efc.monitor;
|
||||
*d = efc.desktop;
|
||||
|
@ -127,7 +129,7 @@ void list_rules(char *rsp)
|
|||
char line[MAXLEN];
|
||||
|
||||
for (rule_t *r = rule_head; r != NULL; r = r->next) {
|
||||
snprintf(line, sizeof(line), "%02X %s %s %s\n", r->uid, r->cause.name, (r->effect.desktop != NULL ? r->effect.desktop->name : "\b"), (r->effect.floating ? "floating" : "\b"));
|
||||
snprintf(line, sizeof(line), "%2X %s %s %s %s\n", r->uid, r->cause.name, (r->effect.desktop != NULL ? r->effect.desktop->name : "\b"), (r->effect.floating ? "floating" : "\b"), (r->effect.follow ? "follow" : "\b"));
|
||||
strncat(rsp, line, REMLEN(rsp));
|
||||
}
|
||||
}
|
||||
|
|
2
rules.h
2
rules.h
|
@ -6,7 +6,7 @@ void remove_rule(rule_t *);
|
|||
void remove_rule_by_uid(unsigned int);
|
||||
rule_t *find_rule(unsigned int);
|
||||
bool is_match(rule_t *, xcb_window_t);
|
||||
void handle_rules(xcb_window_t, monitor_t **, desktop_t **, bool *, bool *, bool *, bool *, bool *);
|
||||
void handle_rules(xcb_window_t, monitor_t **, desktop_t **, bool *, bool *, bool *, bool *, bool *, bool *);
|
||||
void list_rules(char *);
|
||||
|
||||
#endif
|
||||
|
|
1
types.c
1
types.c
|
@ -144,6 +144,7 @@ rule_t *make_rule(void)
|
|||
rule_t *r = malloc(sizeof(rule_t));
|
||||
r->uid = ++rule_uid;
|
||||
r->effect.floating = false;
|
||||
r->effect.follow = false;
|
||||
r->effect.monitor = NULL;
|
||||
r->effect.desktop = NULL;
|
||||
r->prev = NULL;
|
||||
|
|
1
types.h
1
types.h
|
@ -175,6 +175,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
bool floating;
|
||||
bool follow;
|
||||
monitor_t *monitor;
|
||||
desktop_t *desktop;
|
||||
} rule_effect_t;
|
||||
|
|
9
window.c
9
window.c
|
@ -96,9 +96,9 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
|
|||
if (override_redirect || locate_window(win, &loc))
|
||||
return;
|
||||
|
||||
bool floating = false, transient = false, fullscreen = false, takes_focus = true, manage = true;
|
||||
bool floating = false, follow = false, transient = false, fullscreen = false, takes_focus = true, manage = true;
|
||||
|
||||
handle_rules(win, &m, &d, &floating, &transient, &fullscreen, &takes_focus, &manage);
|
||||
handle_rules(win, &m, &d, &floating, &follow, &transient, &fullscreen, &takes_focus, &manage);
|
||||
|
||||
if (!manage) {
|
||||
disable_shadow(win);
|
||||
|
@ -162,6 +162,11 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
|
|||
uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK_FFP : CLIENT_EVENT_MASK)};
|
||||
xcb_change_window_attributes(dpy, c->window, XCB_CW_EVENT_MASK, values);
|
||||
|
||||
if (follow) {
|
||||
select_monitor(m);
|
||||
select_desktop(d);
|
||||
}
|
||||
|
||||
num_clients++;
|
||||
ewmh_set_wm_desktop(birth, d);
|
||||
ewmh_update_client_list();
|
||||
|
|
Loading…
Add table
Reference in a new issue