summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/defs.h1
-rw-r--r--src/parser.c25
-rw-r--r--src/sxwm.c40
3 files changed, 59 insertions, 7 deletions
diff --git a/src/defs.h b/src/defs.h
index 7267b11..6861262 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -87,6 +87,7 @@ typedef struct {
int snap_distance;
int bindsn;
Binding binds[256];
+ char *should_float[256];
} Config;
typedef struct {
diff --git a/src/parser.c b/src/parser.c
index de63e8d..1ceb7e0 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -169,6 +169,12 @@ found:
char line[512];
int lineno = 0;
+ int should_floatn = 0;
+
+ for (int i = 0; i < 256; i++) {
+ cfg->should_float[i] = NULL;
+ }
+
while (fgets(line, sizeof line, f)) {
lineno++;
char *s = strip(line);
@@ -221,6 +227,25 @@ found:
else if (!strcmp(key, "snap_distance")) {
cfg->snap_distance = atoi(rest);
}
+ else if (!strcmp(key, "should_float")) {
+ // should_float: <window>
+
+ if (should_floatn >= 256) {
+ fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno);
+ continue;
+ }
+
+ char *win = strip(rest);
+
+ cfg->should_float[should_floatn] = malloc(strlen(win) + 1);
+ if (!cfg->should_float[should_floatn]) {
+ fprintf(stderr, "sxwmrc:%d: out of memory\n", lineno);
+ break;
+ }
+
+ strcpy(cfg->should_float[should_floatn], win);
+ should_floatn++;
+ }
else if (!strcmp(key, "call") || !strcmp(key, "bind")) {
char *mid = strchr(rest, ':');
if (!mid) {
diff --git a/src/sxwm.c b/src/sxwm.c
index 40194a9..a2dfdcd 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -193,7 +193,7 @@ Client *add_client(Window w, int ws)
c->fullscreen = False;
- if (global_floating || next_should_float) {
+ if (global_floating) {
c->floating = True;
}
@@ -591,11 +591,12 @@ void hdl_keypress(XEvent *xev)
switch (b->type) {
case TYPE_CMD:
spawn(b->action.cmd);
- if (!strcmp(b->action.cmd[0], "firefox")) {
- next_should_float = True;
- printf("next will float\n");
+ for (int j = 0; j < 256; j++) {
+ if (user_config.should_float[j] && !strcmp(user_config.should_float[j], b->action.cmd[0])) {
+ next_should_float = True;
+ break;
+ }
}
- printf("spawn %s\n", b->action.cmd[0]);
break;
case TYPE_FUNC:
if (b->action.fn)
@@ -732,9 +733,34 @@ void hdl_map_req(XEvent *xev)
c->fixed = True;
}
- if (next_should_float || should_float || global_floating) {
+ if (should_float || global_floating || next_should_float) {
c->floating = True;
+
+ if (next_should_float) {
+ if (c->floating) {
+ XWindowAttributes wa;
+ XGetWindowAttributes(dpy, c->win, &wa);
+ c->x = wa.x;
+ c->y = wa.y;
+ c->w = wa.width;
+ c->h = wa.height;
+
+ XConfigureWindow(
+ dpy, c->win, CWX | CWY | CWWidth | CWHeight,
+ &(XWindowChanges){.x = c->x, .y = c->y, .width = c->w, .height = c->h});
+ }
+
+ tile();
+ update_borders();
+
+ if (c->floating) {
+ XRaiseWindow(dpy, c->win);
+ XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+ }
+ next_should_float = False;
+ }
}
+
/* center floating windows & set border */
if (c->floating && !c->fullscreen) {
@@ -753,7 +779,7 @@ void hdl_map_req(XEvent *xev)
/* map & borders */
XMapWindow(dpy, w);
update_net_client_list();
- if (!global_floating && !c->floating && !next_should_float)
+ if (!global_floating && !c->floating)
tile();
else if (c->floating)
XRaiseWindow(dpy, w);