change the perapp settings "head" option to "monitor" i think its easier to understand.
some cleanup for perapp settings. make monitor and desktop be specified starting at 1, like elsewhere in the config file.
This commit is contained in:
parent
6cd5f7ea38
commit
7ffa091d5b
5 changed files with 99 additions and 77 deletions
|
@ -457,15 +457,16 @@
|
||||||
<!-- a number or 'center' to center on screen -->
|
<!-- a number or 'center' to center on screen -->
|
||||||
<y>200</y>
|
<y>200</y>
|
||||||
<!-- a number or 'center' to center on screen -->
|
<!-- a number or 'center' to center on screen -->
|
||||||
<head>0</head>
|
<monitor>1</monitor>
|
||||||
<!-- specifies the xinerama head, 'mouse' for wherever the mouse is -->
|
<!-- specifies the monitor in a xinerama setup.
|
||||||
|
1 is the first head, or 'mouse' for wherever the mouse is -->
|
||||||
</position>
|
</position>
|
||||||
|
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
<!-- if the window should try be given focus when it appears -->
|
<!-- if the window should try be given focus when it appears -->
|
||||||
|
|
||||||
<desktop>1</desktop>
|
<desktop>1</desktop>
|
||||||
<!-- 0 is the first desktop, 'all' for all desktops -->
|
<!-- 1 is the first desktop, 'all' for all desktops -->
|
||||||
|
|
||||||
<layer>normal</layer>
|
<layer>normal</layer>
|
||||||
<!-- 'above', 'normal', or 'below' -->
|
<!-- 'above', 'normal', or 'below' -->
|
||||||
|
|
|
@ -295,32 +295,6 @@ struct _ObClient
|
||||||
guint32 user_time;
|
guint32 user_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ObAppSettings
|
|
||||||
{
|
|
||||||
gchar *class;
|
|
||||||
gchar *name;
|
|
||||||
gchar *role;
|
|
||||||
|
|
||||||
Point position;
|
|
||||||
gboolean center_x;
|
|
||||||
gboolean center_y;
|
|
||||||
gboolean pos_given;
|
|
||||||
|
|
||||||
guint desktop;
|
|
||||||
gint shade;
|
|
||||||
gint decor;
|
|
||||||
gint focus;
|
|
||||||
gint head;
|
|
||||||
gint iconic;
|
|
||||||
gint skip_pager;
|
|
||||||
gint skip_taskbar;
|
|
||||||
gint max_horz;
|
|
||||||
gint max_vert;
|
|
||||||
gint fullscreen;
|
|
||||||
|
|
||||||
gint layer;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern GList *client_list;
|
extern GList *client_list;
|
||||||
|
|
||||||
void client_startup(gboolean reconfig);
|
void client_startup(gboolean reconfig);
|
||||||
|
|
|
@ -102,22 +102,23 @@ GSList *config_per_app_settings;
|
||||||
<position>
|
<position>
|
||||||
<x>700</x>
|
<x>700</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<head>1</head>
|
<monitor>1</monitor>
|
||||||
</position>
|
</position>
|
||||||
|
.. there is a lot more settings available
|
||||||
</application>
|
</application>
|
||||||
</applications>
|
</applications>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Manages settings for individual applications.
|
/* Manages settings for individual applications.
|
||||||
Some notes: head is the screen number in a multi monitor
|
Some notes: monitor 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.
|
monitor the pointer is on. Default: mouse.
|
||||||
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
|
||||||
center the window in the specified axis. Position is relative
|
center the window in the specified axis. Position is within
|
||||||
from head, so <position><x>center</x></position><head>1</head>
|
the monitor, so <position><x>center</x></position><monitor>2</monitor>
|
||||||
will center the window on the second head.
|
will center the window on the second monitor.
|
||||||
*/
|
*/
|
||||||
static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
|
static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
|
||||||
xmlNodePtr node, gpointer d)
|
xmlNodePtr node, gpointer d)
|
||||||
|
@ -176,7 +177,7 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x_pos_given && (c = parse_find_node("y", n->children)))
|
if (x_pos_given && (c = parse_find_node("y", n->children)))
|
||||||
if (!parse_contains("default", doc, )) {
|
if (!parse_contains("default", doc, c)) {
|
||||||
gchar *s = parse_string(doc, c);
|
gchar *s = parse_string(doc, c);
|
||||||
if (!strcmp(s, "center")) {
|
if (!strcmp(s, "center")) {
|
||||||
settings->center_y = TRUE;
|
settings->center_y = TRUE;
|
||||||
|
@ -189,13 +190,13 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->pos_given &&
|
if (settings->pos_given &&
|
||||||
(c = parse_find_node("head", n->children)))
|
(c = parse_find_node("monitor", n->children)))
|
||||||
if (!parse_contains("default", doc, n)) {
|
if (!parse_contains("default", doc, c)) {
|
||||||
gchar *s = parse_string(doc, n);
|
gchar *s = parse_string(doc, c);
|
||||||
if (!strcmp(s, "mouse"))
|
if (!strcmp(s, "mouse"))
|
||||||
settings->head = -1;
|
settings->monitor = 0;
|
||||||
else
|
else
|
||||||
settings->head = parse_int(doc, n);
|
settings->monitor = parse_int(doc, c) + 1;
|
||||||
g_free(s);
|
g_free(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,61 +206,69 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
|
||||||
if (!parse_contains("default", doc, n))
|
if (!parse_contains("default", doc, n))
|
||||||
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))) {
|
||||||
if (!parse_contains("default", doc, n)) {
|
if (!parse_contains("default", doc, n)) {
|
||||||
gchar *s = parse_string(doc, n);
|
gchar *s = parse_string(doc, n);
|
||||||
if (!strcmp(s, "all"))
|
if (!strcmp(s, "all"))
|
||||||
settings->desktop = DESKTOP_ALL;
|
settings->desktop = DESKTOP_ALL;
|
||||||
else
|
else {
|
||||||
settings->desktop = parse_int(doc, n);
|
gint i = parse_int(doc, n);
|
||||||
|
if (i > 0)
|
||||||
|
settings->desktop = i;
|
||||||
g_free(s);
|
g_free(s);
|
||||||
} else
|
} else
|
||||||
/* lets hope the user doesn't have 2^32 desktops */
|
settings->desktop = 0;
|
||||||
settings->desktop = DESKTOP_ALL - 1;
|
}
|
||||||
|
|
||||||
settings->layer = -2;
|
settings->layer = -2;
|
||||||
if ((n = parse_find_node("layer", app->children))) {
|
if ((n = parse_find_node("layer", app->children)))
|
||||||
gchar *s = parse_string(doc, n);
|
if (!parse_contains("default", doc, n)) {
|
||||||
if (!strcmp(s, "above"))
|
gchar *s = parse_string(doc, n);
|
||||||
settings->layer = 1;
|
if (!strcmp(s, "above"))
|
||||||
else if (!strcmp(s, "below"))
|
settings->layer = 1;
|
||||||
settings->layer = -1;
|
else if (!strcmp(s, "below"))
|
||||||
else
|
settings->layer = -1;
|
||||||
settings->layer = 0;
|
else
|
||||||
g_free(s);
|
settings->layer = 0;
|
||||||
}
|
g_free(s);
|
||||||
|
}
|
||||||
|
|
||||||
settings->iconic = -1;
|
settings->iconic = -1;
|
||||||
if ((n = parse_find_node("iconic", app->children)))
|
if ((n = parse_find_node("iconic", app->children)))
|
||||||
settings->iconic = parse_bool(doc, n);
|
if (!parse_contains("default", doc, n))
|
||||||
|
settings->iconic = parse_bool(doc, n);
|
||||||
|
|
||||||
settings->skip_pager = -1;
|
settings->skip_pager = -1;
|
||||||
if ((n = parse_find_node("skip_pager", app->children)))
|
if ((n = parse_find_node("skip_pager", app->children)))
|
||||||
settings->skip_pager = parse_bool(doc, n);
|
if (!parse_contains("default", doc, n))
|
||||||
|
settings->skip_pager = parse_bool(doc, n);
|
||||||
|
|
||||||
settings->skip_taskbar = -1;
|
settings->skip_taskbar = -1;
|
||||||
if ((n = parse_find_node("skip_taskbar", app->children)))
|
if ((n = parse_find_node("skip_taskbar", app->children)))
|
||||||
settings->skip_taskbar = parse_bool(doc, n);
|
if (!parse_contains("default", doc, n))
|
||||||
|
settings->skip_taskbar = parse_bool(doc, n);
|
||||||
|
|
||||||
settings->fullscreen = -1;
|
settings->fullscreen = -1;
|
||||||
if ((n = parse_find_node("fullscreen", app->children)))
|
if ((n = parse_find_node("fullscreen", app->children)))
|
||||||
settings->fullscreen = parse_bool(doc, n);
|
if (!parse_contains("default", doc, n))
|
||||||
|
settings->fullscreen = parse_bool(doc, n);
|
||||||
|
|
||||||
settings->max_horz = -1;
|
settings->max_horz = -1;
|
||||||
settings->max_vert = -1;
|
settings->max_vert = -1;
|
||||||
if ((n = parse_find_node("maximized", app->children))) {
|
if ((n = parse_find_node("maximized", app->children)))
|
||||||
gchar *s = parse_string(doc, n);
|
if (!parse_contains("default", doc, n)) {
|
||||||
if (!strcmp(s, "horizontal")) {
|
gchar *s = parse_string(doc, n);
|
||||||
settings->max_horz = TRUE;
|
if (!strcmp(s, "horizontal")) {
|
||||||
settings->max_vert = FALSE;
|
settings->max_horz = TRUE;
|
||||||
} else if (!strcmp(s, "vertical")) {
|
settings->max_vert = FALSE;
|
||||||
settings->max_horz = FALSE;
|
} else if (!strcmp(s, "vertical")) {
|
||||||
settings->max_vert = TRUE;
|
settings->max_horz = FALSE;
|
||||||
} else
|
settings->max_vert = TRUE;
|
||||||
settings->max_horz = settings->max_vert =
|
} else
|
||||||
parse_bool(doc, n);
|
settings->max_horz = settings->max_vert =
|
||||||
g_free(s);
|
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,
|
||||||
(gpointer) settings);
|
(gpointer) settings);
|
||||||
|
|
|
@ -23,12 +23,39 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "stacking.h"
|
#include "stacking.h"
|
||||||
#include "place.h"
|
#include "place.h"
|
||||||
|
#include "geom.h"
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
struct _ObParseInst;
|
struct _ObParseInst;
|
||||||
|
|
||||||
|
struct _ObAppSettings
|
||||||
|
{
|
||||||
|
gchar *class;
|
||||||
|
gchar *name;
|
||||||
|
gchar *role;
|
||||||
|
|
||||||
|
Point position;
|
||||||
|
gboolean center_x;
|
||||||
|
gboolean center_y;
|
||||||
|
gboolean pos_given;
|
||||||
|
|
||||||
|
guint desktop;
|
||||||
|
gint shade;
|
||||||
|
gint decor;
|
||||||
|
gint focus;
|
||||||
|
gint monitor;
|
||||||
|
gint iconic;
|
||||||
|
gint skip_pager;
|
||||||
|
gint skip_taskbar;
|
||||||
|
gint max_horz;
|
||||||
|
gint max_vert;
|
||||||
|
gint fullscreen;
|
||||||
|
|
||||||
|
gint layer;
|
||||||
|
};
|
||||||
|
|
||||||
/*! Should new windows be focused */
|
/*! Should new windows be focused */
|
||||||
extern gboolean config_focus_new;
|
extern gboolean config_focus_new;
|
||||||
/*! Focus windows when the mouse enters them */
|
/*! Focus windows when the mouse enters them */
|
||||||
|
|
|
@ -52,6 +52,9 @@ static Rect *pick_pointer_head(ObClient *c)
|
||||||
g_assert_not_reached();
|
g_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Pick a monitor to place a window on.
|
||||||
|
The returned array value should be freed with g_free. The areas within the
|
||||||
|
array should not be freed. */
|
||||||
static Rect **pick_head(ObClient *c)
|
static Rect **pick_head(ObClient *c)
|
||||||
{
|
{
|
||||||
Rect **area;
|
Rect **area;
|
||||||
|
@ -388,16 +391,24 @@ static gboolean place_under_mouse(ObClient *client, gint *x, gint *y)
|
||||||
static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
|
static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
|
||||||
ObAppSettings *settings)
|
ObAppSettings *settings)
|
||||||
{
|
{
|
||||||
Rect *screen;
|
Rect *screen = NULL;
|
||||||
|
|
||||||
if (!settings || (settings && !settings->pos_given))
|
if (!settings || (settings && !settings->pos_given))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Find which head the pointer is on */
|
/* Find which head the pointer is on */
|
||||||
if (settings->head == -1)
|
if (settings->monitor == 0)
|
||||||
screen = pick_pointer_head(client);
|
screen = pick_pointer_head(client);
|
||||||
else
|
else if (settings->monitor > 0 &&
|
||||||
screen = screen_area_monitor(client->desktop, settings->head);
|
(guint)settings->monitor <= screen_num_monitors)
|
||||||
|
screen = screen_area_monitor(client->desktop,
|
||||||
|
(guint)settings->monitor - 1);
|
||||||
|
else {
|
||||||
|
Rect **all = NULL;
|
||||||
|
all = pick_head(client);
|
||||||
|
screen = all[0];
|
||||||
|
g_free(all); /* the areas themselves don't need to be freed */
|
||||||
|
}
|
||||||
|
|
||||||
if (settings->center_x)
|
if (settings->center_x)
|
||||||
*x = screen->x + screen->width / 2 - client->area.width / 2;
|
*x = screen->x + screen->width / 2 - client->area.width / 2;
|
||||||
|
|
Loading…
Reference in a new issue