add the rest of the possible states to per app settings, and fix some mem leaks in the code that _set_ the per app list
This commit is contained in:
parent
8af51d8a1b
commit
ff04e2c9a9
3 changed files with 109 additions and 27 deletions
|
@ -215,7 +215,10 @@ static ObAppSettings *get_settings(ObClient *client)
|
||||||
|
|
||||||
if (!strcmp(app->name, client->name)) {
|
if (!strcmp(app->name, client->name)) {
|
||||||
ob_debug("Window matching: %s\n", app->name);
|
ob_debug("Window matching: %s\n", app->name);
|
||||||
if (!app->role || !strcmp(app->role, client->role))
|
/* Match if no role was specified in the per app setting, or if the string
|
||||||
|
* matches the beginning of the role, since apps like to set the role to
|
||||||
|
* things like browser-window-23c4b2f */
|
||||||
|
if (!app->role || !strncmp(app->role, client->role, strlen(app->role)))
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,16 +320,41 @@ void client_manage(Window window)
|
||||||
settings = get_settings(self);
|
settings = get_settings(self);
|
||||||
|
|
||||||
if (settings) {
|
if (settings) {
|
||||||
if (settings->shade && !settings->decor)
|
/* Don't worry, we won't actually both shade and undecorate the
|
||||||
settings->decor = TRUE;
|
* window when push comes to shove. */
|
||||||
|
if (settings->shade != -1)
|
||||||
client_shade(self, settings->shade);
|
client_shade(self, settings->shade);
|
||||||
client_set_undecorated(self, !settings->decor);
|
if (settings->decor != -1)
|
||||||
|
client_set_undecorated(self, !settings->decor);
|
||||||
if (settings->desktop != -1)
|
if (settings->iconic != -1)
|
||||||
|
client_iconify(self, settings->iconic);
|
||||||
|
if (settings->skip_pager != -1)
|
||||||
|
client->skip_pager = !!settings->skip_pager;
|
||||||
|
if (settings->skip_taskbar != -1)
|
||||||
|
client->skip_taskbar = !!settings->skip_taskbar;
|
||||||
|
|
||||||
|
/* 1 && -1 shouldn't be possible by the code in config.c */
|
||||||
|
if (settings->max_vert == 1 && self->max_horz == 1)
|
||||||
|
client_maximize(self, TRUE, 0, TRUE);
|
||||||
|
else if (settings->max_vert == 0 && self->max_horz == 0)
|
||||||
|
client_maximize(self, FALSE, 0, TRUE);
|
||||||
|
else if (settings->max_vert == 1 && self->max_horz == 0) {
|
||||||
|
client_maximize(self, TRUE, 2, TRUE);
|
||||||
|
client_maximize(self, FALSE, 1, TRUE);
|
||||||
|
} else if (settings->max_vert == 0 && self->max_horz == 1) {
|
||||||
|
client_maximize(self, TRUE, 1, TRUE);
|
||||||
|
client_maximize(self, FALSE, 2, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings->fullscreen != -1)
|
||||||
|
client_fullscreen(self, !!settings->fullscreen, TRUE);
|
||||||
|
|
||||||
|
if (settings->desktop < screen_num_desktops)
|
||||||
client_set_desktop(self, settings->desktop, FALSE);
|
client_set_desktop(self, settings->desktop, FALSE);
|
||||||
|
|
||||||
client_set_layer(self, settings->layer);
|
if (settings->layer > -2 && settings->layer < 2)
|
||||||
|
client_set_layer(self, settings->layer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stacking_add(CLIENT_AS_WINDOW(self));
|
stacking_add(CLIENT_AS_WINDOW(self));
|
||||||
|
@ -335,7 +363,7 @@ void client_manage(Window window)
|
||||||
/* focus the new window? */
|
/* focus the new window? */
|
||||||
if (ob_state() != OB_STATE_STARTING &&
|
if (ob_state() != OB_STATE_STARTING &&
|
||||||
(config_focus_new || client_search_focus_parent(self)) ||
|
(config_focus_new || client_search_focus_parent(self)) ||
|
||||||
(settings && settings->focus) &&
|
(settings && settings->focus == TRUE) &&
|
||||||
/* note the check against Type_Normal/Dialog, not client_normal(self),
|
/* note the check against Type_Normal/Dialog, not client_normal(self),
|
||||||
which would also include other types. in this case we want more
|
which would also include other types. in this case we want more
|
||||||
strict rules for focus */
|
strict rules for focus */
|
||||||
|
|
|
@ -274,9 +274,6 @@ struct _ObAppSettings
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gchar *role;
|
gchar *role;
|
||||||
gboolean decor;
|
|
||||||
gboolean shade;
|
|
||||||
gboolean focus;
|
|
||||||
|
|
||||||
Point position;
|
Point position;
|
||||||
gboolean center_x;
|
gboolean center_x;
|
||||||
|
@ -284,9 +281,18 @@ struct _ObAppSettings
|
||||||
gboolean pos_given;
|
gboolean pos_given;
|
||||||
|
|
||||||
guint desktop;
|
guint desktop;
|
||||||
guint head;
|
gint shade;
|
||||||
|
gint decor;
|
||||||
|
gint focus;
|
||||||
|
gint head;
|
||||||
|
gint iconic;
|
||||||
|
gint skip_pager;
|
||||||
|
gint skip_taskbar;
|
||||||
|
gint max_horz;
|
||||||
|
gint max_vert;
|
||||||
|
gint fullscreen;
|
||||||
|
|
||||||
guint layer;
|
gint layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GList *client_list;
|
extern GList *client_list;
|
||||||
|
|
|
@ -103,8 +103,6 @@ GSList *config_per_app_settings;
|
||||||
Some notes: head is the screen number in a multi monitor
|
Some notes: head is the screen number in a multi monitor
|
||||||
(Xinerama) setup (starting from 0) or mouse, meaning the
|
(Xinerama) setup (starting from 0) or mouse, meaning the
|
||||||
head the pointer is on. Default: mouse.
|
head the pointer is on. Default: mouse.
|
||||||
If decor is false and shade is true, the decor will be
|
|
||||||
set to true (otherwise we will have an invisible window).
|
|
||||||
Layer can be three values, above (Always on top), below
|
Layer can be three values, above (Always on top), below
|
||||||
(Always on bottom) and everything else (normal behaviour).
|
(Always on bottom) and everything else (normal behaviour).
|
||||||
Positions can be an integer value or center, which will
|
Positions can be an integer value or center, which will
|
||||||
|
@ -127,10 +125,11 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
|
||||||
if (!parse_attr_string("role", app, &settings->role))
|
if (!parse_attr_string("role", app, &settings->role))
|
||||||
settings->role = NULL;
|
settings->role = NULL;
|
||||||
|
|
||||||
settings->decor = TRUE;
|
settings->decor = -1;
|
||||||
if ((n = parse_find_node("decor", app->children)))
|
if ((n = parse_find_node("decor", app->children)))
|
||||||
settings->decor = parse_bool(doc, n);
|
settings->decor = parse_bool(doc, n);
|
||||||
|
|
||||||
|
settings->shade = -1;
|
||||||
if ((n = parse_find_node("shade", app->children)))
|
if ((n = parse_find_node("shade", app->children)))
|
||||||
settings->shade = parse_bool(doc, n);
|
settings->shade = parse_bool(doc, n);
|
||||||
|
|
||||||
|
@ -138,48 +137,97 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
|
||||||
settings->pos_given = FALSE;
|
settings->pos_given = FALSE;
|
||||||
if ((n = parse_find_node("position", app->children))) {
|
if ((n = parse_find_node("position", app->children))) {
|
||||||
if ((c = parse_find_node("x", n->children))) {
|
if ((c = parse_find_node("x", n->children))) {
|
||||||
if (!strcmp(parse_string(doc, c), "center")) {
|
str *s = parse_string(doc, c);
|
||||||
|
if (!strcmp(s, "center")) {
|
||||||
settings->center_x = TRUE;
|
settings->center_x = TRUE;
|
||||||
x_pos_given = TRUE;
|
x_pos_given = TRUE;
|
||||||
} else {
|
} else {
|
||||||
settings->position.x = parse_int(doc, c);
|
settings->position.x = parse_int(doc, c);
|
||||||
x_pos_given = TRUE;
|
x_pos_given = TRUE;
|
||||||
}
|
}
|
||||||
|
g_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x_pos_given && (c = parse_find_node("y", n->children))) {
|
if (x_pos_given && (c = parse_find_node("y", n->children))) {
|
||||||
if (!strcmp(parse_string(doc, c), "center")) {
|
str *s = parse_string(doc, c);
|
||||||
|
if (!strcmp(s, "center")) {
|
||||||
settings->center_y = TRUE;
|
settings->center_y = TRUE;
|
||||||
settings->pos_given = TRUE;
|
settings->pos_given = TRUE;
|
||||||
} else {
|
} else {
|
||||||
settings->position.y = parse_int(doc, c);
|
settings->position.y = parse_int(doc, c);
|
||||||
settings->pos_given = TRUE;
|
settings->pos_given = TRUE;
|
||||||
}
|
}
|
||||||
|
g_free(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings->focus = -1;
|
||||||
if ((n = parse_find_node("focus", app->children)))
|
if ((n = parse_find_node("focus", app->children)))
|
||||||
settings->focus = parse_bool(doc, n);
|
settings->focus = parse_bool(doc, n);
|
||||||
|
|
||||||
if ((n = parse_find_node("desktop", app->children)))
|
if ((n = parse_find_node("desktop", app->children))) {
|
||||||
settings->desktop = parse_int(doc, n);
|
str *s = parse_string(doc, n);
|
||||||
else
|
if (!strcmp(s, "all"))
|
||||||
settings->desktop = -1;
|
settings->desktop = DESKTOP_ALL;
|
||||||
|
else
|
||||||
|
settings->desktop = parse_int(doc, n);
|
||||||
|
g_free(s);
|
||||||
|
} else
|
||||||
|
settings->desktop = DESKTOP_ALL - 1; /* lets hope the user
|
||||||
|
* doesn't have 2^32
|
||||||
|
* desktops */
|
||||||
|
|
||||||
if ((n = parse_find_node("head", app->children))) {
|
if ((n = parse_find_node("head", app->children))) {
|
||||||
if (!strcmp(parse_string(doc, n), "mouse"))
|
str *s = parse_string(doc, n);
|
||||||
|
if (!strcmp(s, "mouse"))
|
||||||
settings->head = -1;
|
settings->head = -1;
|
||||||
else
|
else
|
||||||
settings->head = parse_int(doc, n);
|
settings->head = parse_int(doc, n);
|
||||||
|
g_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings->layer = -2;
|
||||||
if ((n = parse_find_node("layer", app->children))) {
|
if ((n = parse_find_node("layer", app->children))) {
|
||||||
if (!strcmp(parse_string(doc, n), "above"))
|
str *s = parse_string(doc, n);
|
||||||
|
if (!strcmp(s, "above"))
|
||||||
settings->layer = 1;
|
settings->layer = 1;
|
||||||
else if (!strcmp(parse_string(doc, n), "below"))
|
else if (!strcmp(s, "below"))
|
||||||
settings->layer = -1;
|
settings->layer = -1;
|
||||||
else
|
else
|
||||||
settings->layer = 0;
|
settings->layer = 0;
|
||||||
|
g_free(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
settings->iconic = -1;
|
||||||
|
if ((n = parse_find_node("iconic", app->children)))
|
||||||
|
settings->iconic = parse_bool(doc, n);
|
||||||
|
|
||||||
|
settings->skip_pager = -1;
|
||||||
|
if ((n = parse_find_node("skip_pager", app->children)))
|
||||||
|
settings->skip_pager = parse_bool(doc, n);
|
||||||
|
|
||||||
|
settings->skip_taskbar = -1;
|
||||||
|
if ((n = parse_find_node("skip_taskbar", app->children)))
|
||||||
|
settings->skip_taskbar = parse_bool(doc, n);
|
||||||
|
|
||||||
|
settings->fullscreen = -1;
|
||||||
|
if ((n = parse_find_node("fullscreen", app->children)))
|
||||||
|
settings->fullscreen = parse_bool(doc, n);
|
||||||
|
|
||||||
|
settings->max_horz = -1;
|
||||||
|
settings->max_vert = -1;
|
||||||
|
if ((n = parse_find_node("maximized", app->children))) {
|
||||||
|
str *s = parse_string(doc, n);
|
||||||
|
if (!strcmp(s, "horizontal")) {
|
||||||
|
settings->max_horz = TRUE;
|
||||||
|
settings->max_vert = FALSE;
|
||||||
|
} else if (!strcmp(s, "vertical")) {
|
||||||
|
settings->max_horz = FALSE;
|
||||||
|
settings->max_vert = TRUE;
|
||||||
|
} else
|
||||||
|
settings->max_horz = settings->max_vert =
|
||||||
|
parse_bool(doc, n);
|
||||||
|
g_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
config_per_app_settings = g_slist_append(config_per_app_settings,
|
config_per_app_settings = g_slist_append(config_per_app_settings,
|
||||||
|
|
Loading…
Reference in a new issue