Implement putting clients into floating mode at a specific workspace
This changes syntax of the assign command a bit. Old configurations will continue to work. See the userguide.
This commit is contained in:
parent
008a2665c1
commit
ffcc8bbc3a
|
@ -259,13 +259,14 @@ i3 will get the title as soon as the application maps the window (mapping means
|
||||||
actually displaying it on the screen), you’d need to have to match on Firefox
|
actually displaying it on the screen), you’d need to have to match on Firefox
|
||||||
in this case.
|
in this case.
|
||||||
|
|
||||||
You can use the special workspace +~+ to specify that matching clients should
|
You can prefix or suffix workspaces with a +~+ to specify that matching clients
|
||||||
be put into floating mode.
|
should be put into floating mode. If you specify only a +~+, the client will
|
||||||
|
not be put onto any workspace, but will be set floating on the current one.
|
||||||
|
|
||||||
*Syntax*:
|
*Syntax*:
|
||||||
----------------------------------------------------
|
------------------------------------------------------------
|
||||||
assign ["]window class[/window title]["] [→] workspace
|
assign ["]window class[/window title]["] [→] [~ | workspace]
|
||||||
----------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
*Examples*:
|
*Examples*:
|
||||||
----------------------
|
----------------------
|
||||||
|
@ -273,7 +274,8 @@ assign urxvt 2
|
||||||
assign urxvt → 2
|
assign urxvt → 2
|
||||||
assign "urxvt" → 2
|
assign "urxvt" → 2
|
||||||
assign "urxvt/VIM" → 3
|
assign "urxvt/VIM" → 3
|
||||||
assign "gecko" → ~
|
assign "gecko" → ~4
|
||||||
|
assign "xv/MPlayer" → ~
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
=== Automatically starting applications on startup
|
=== Automatically starting applications on startup
|
||||||
|
|
|
@ -250,7 +250,12 @@ struct Assignment {
|
||||||
/** floating is true if this was an assignment to the special
|
/** floating is true if this was an assignment to the special
|
||||||
* workspace "~". Matching clients will be put into floating mode
|
* workspace "~". Matching clients will be put into floating mode
|
||||||
* automatically. */
|
* automatically. */
|
||||||
bool floating;
|
enum {
|
||||||
|
ASSIGN_FLOATING_NO, /* don’t float, but put on a workspace */
|
||||||
|
ASSIGN_FLOATING_ONLY, /* float, but don’t assign on a workspace */
|
||||||
|
ASSIGN_FLOATING /* float and put on a workspace */
|
||||||
|
} floating;
|
||||||
|
|
||||||
/** The number of the workspace to assign to. */
|
/** The number of the workspace to assign to. */
|
||||||
int workspace;
|
int workspace;
|
||||||
TAILQ_ENTRY(Assignment) assignments;
|
TAILQ_ENTRY(Assignment) assignments;
|
||||||
|
|
24
src/config.c
24
src/config.c
|
@ -269,17 +269,33 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath)
|
||||||
die("Malformed assignment, couldn't find target\n");
|
die("Malformed assignment, couldn't find target\n");
|
||||||
target++;
|
target++;
|
||||||
|
|
||||||
if (*target != '~' && (atoi(target) < 1 || atoi(target) > 10))
|
if (strchr(target, '~') == NULL && (atoi(target) < 1 || atoi(target) > 10))
|
||||||
die("Malformed assignment, invalid workspace number\n");
|
die("Malformed assignment, invalid workspace number\n");
|
||||||
|
|
||||||
LOG("assignment parsed: \"%s\" to \"%s\"\n", class_title, target);
|
LOG("assignment parsed: \"%s\" to \"%s\"\n", class_title, target);
|
||||||
|
|
||||||
struct Assignment *new = scalloc(sizeof(struct Assignment));
|
struct Assignment *new = scalloc(sizeof(struct Assignment));
|
||||||
new->windowclass_title = class_title;
|
new->windowclass_title = class_title;
|
||||||
if (*target == '~')
|
if (strchr(target, '~') != NULL)
|
||||||
new->floating = true;
|
new->floating = ASSIGN_FLOATING_ONLY;
|
||||||
else new->workspace = atoi(target);
|
|
||||||
|
while (*target == '~')
|
||||||
|
target++;
|
||||||
|
|
||||||
|
if (atoi(target) >= 1 && atoi(target) <= 10) {
|
||||||
|
if (new->floating == ASSIGN_FLOATING_ONLY)
|
||||||
|
new->floating = ASSIGN_FLOATING;
|
||||||
|
new->workspace = atoi(target);
|
||||||
|
}
|
||||||
TAILQ_INSERT_TAIL(&assignments, new, assignments);
|
TAILQ_INSERT_TAIL(&assignments, new, assignments);
|
||||||
|
|
||||||
|
LOG("Assignment loaded: \"%s\":\n", class_title);
|
||||||
|
if (new->floating != ASSIGN_FLOATING_ONLY)
|
||||||
|
LOG(" to workspace %d\n", new->workspace);
|
||||||
|
|
||||||
|
if (new->floating != ASSIGN_FLOATING_NO)
|
||||||
|
LOG(" will be floating\n");
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -311,10 +311,12 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
|
||||||
if (get_matching_client(conn, assign->windowclass_title, new) == NULL)
|
if (get_matching_client(conn, assign->windowclass_title, new) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (assign->floating) {
|
if (assign->floating == ASSIGN_FLOATING_ONLY ||
|
||||||
|
assign->floating == ASSIGN_FLOATING) {
|
||||||
new->floating = FLOATING_AUTO_ON;
|
new->floating = FLOATING_AUTO_ON;
|
||||||
LOG("Assignment matches, putting client into floating mode\n");
|
LOG("Assignment matches, putting client into floating mode\n");
|
||||||
break;
|
if (assign->floating == ASSIGN_FLOATING_ONLY)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("Assignment \"%s\" matches, so putting it on workspace %d\n",
|
LOG("Assignment \"%s\" matches, so putting it on workspace %d\n",
|
||||||
|
|
Loading…
Reference in New Issue