]> Dogcows Code - chaz/openbox/commitdiff
change the perapp settings "head" option to "monitor" i think its easier to understand.
authorDana Jansens <danakj@orodu.net>
Sun, 6 May 2007 22:57:49 +0000 (22:57 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 6 May 2007 22:57:49 +0000 (22:57 +0000)
some cleanup for perapp settings.
make monitor and desktop be specified starting at 1, like elsewhere in the config file.

data/rc.xml.in
openbox/client.h
openbox/config.c
openbox/config.h
openbox/place.c

index 45e144a32dae3f4dc40b06e3b50b2788c2f492ba..ca4c7764568653f661a3ef05200540e42ea3ae1b 100644 (file)
       <!-- a number or 'center' to center on screen -->
       <y>200</y>
       <!-- a number or 'center' to center on screen -->
-      <head>0</head>
-      <!-- specifies the xinerama head, 'mouse' for wherever the mouse is -->
+      <monitor>1</monitor>
+      <!-- specifies the monitor in a xinerama setup.
+           1 is the first head, or 'mouse' for wherever the mouse is -->
     </position>
 
     <focus>yes</focus>
     <!-- if the window should try be given focus when it appears -->
 
     <desktop>1</desktop>
-    <!-- 0 is the first desktop, 'all' for all desktops -->
+    <!-- 1 is the first desktop, 'all' for all desktops -->
 
     <layer>normal</layer>
     <!-- 'above', 'normal', or 'below' -->
index 6b28d457e781fb2443a4a9bf84b18c0b0c1797fd..2863a98f5dde5a1d7059c506a74664303e8c631f 100644 (file)
@@ -295,32 +295,6 @@ struct _ObClient
     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;
 
 void client_startup(gboolean reconfig);
index f18b77c9aa38618f1dac36bc844dbf8c728ef9ef..d6adb9751331c7de6205ad7759ce8fabb2840976 100644 (file)
@@ -102,22 +102,23 @@ GSList *config_per_app_settings;
       <position>
         <x>700</x>
         <y>0</y>
-        <head>1</head>
+        <monitor>1</monitor>
       </position>
+      .. there is a lot more settings available
     </application>
   </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
-   head the pointer is on. Default: mouse.
+   monitor the pointer is on. Default: mouse.
    Layer can be three values, above (Always on top), below
    (Always on bottom) and everything else (normal behaviour).
    Positions can be an integer value or center, which will
-   center the window in the specified axis. Position is relative
-   from head, so <position><x>center</x></position><head>1</head>
-   will center the window on the second head.
+   center the window in the specified axis. Position is within
+   the monitor, so <position><x>center</x></position><monitor>2</monitor>
+   will center the window on the second monitor.
 */
 static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
                                    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 (!parse_contains("default", doc, )) {
+                    if (!parse_contains("default", doc, c)) {
                         gchar *s = parse_string(doc, c);
                         if (!strcmp(s, "center")) {
                             settings->center_y = TRUE;
@@ -189,13 +190,13 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
                     }
 
                 if (settings->pos_given &&
-                    (c = parse_find_node("head", n->children)))
-                    if (!parse_contains("default", doc, n)) {
-                        gchar *s = parse_string(doc, n);
+                    (c = parse_find_node("monitor", n->children)))
+                    if (!parse_contains("default", doc, c)) {
+                        gchar *s = parse_string(doc, c);
                         if (!strcmp(s, "mouse"))
-                            settings->head = -1;
+                            settings->monitor = 0;
                         else
-                            settings->head = parse_int(doc, n);
+                            settings->monitor = parse_int(doc, c) + 1;
                         g_free(s);
                     }
             }
@@ -205,61 +206,69 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
                 if (!parse_contains("default", 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)) {
                     gchar *s = parse_string(doc, n);
                     if (!strcmp(s, "all"))
                         settings->desktop = DESKTOP_ALL;
-                    else
-                        settings->desktop = parse_int(doc, n);
+                    else {
+                        gint i = parse_int(doc, n);
+                        if (i > 0)
+                            settings->desktop = i;
                     g_free(s);
                 } else
-                    /* lets hope the user doesn't have 2^32 desktops */
-                    settings->desktop = DESKTOP_ALL - 1;
+                    settings->desktop = 0;
+            }
 
             settings->layer = -2;
-            if ((n = parse_find_node("layer", app->children))) {
-                gchar *s = parse_string(doc, n);
-                if (!strcmp(s, "above"))
-                    settings->layer = 1;
-                else if (!strcmp(s, "below"))
-                    settings->layer = -1;
-                else
-                    settings->layer = 0;
-                g_free(s);
-            }
+            if ((n = parse_find_node("layer", app->children)))
+                if (!parse_contains("default", doc, n)) {
+                    gchar *s = parse_string(doc, n);
+                    if (!strcmp(s, "above"))
+                        settings->layer = 1;
+                    else if (!strcmp(s, "below"))
+                        settings->layer = -1;
+                    else
+                        settings->layer = 0;
+                    g_free(s);
+                }
 
             settings->iconic = -1;
             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;
             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;
             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;
             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_vert = -1;
-            if ((n = parse_find_node("maximized", app->children))) {
-                gchar *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);
-            }
+            if ((n = parse_find_node("maximized", app->children)))
+                if (!parse_contains("default", doc, n)) {
+                    gchar *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,
                                               (gpointer) settings);
index f85f4f115e500e2064e3e6a3e994ddb05155170f..41cf74823afb4a1fbf36f56ef729fc1878ab6c6b 100644 (file)
 #include "misc.h"
 #include "stacking.h"
 #include "place.h"
+#include "geom.h"
 #include "render/render.h"
 
 #include <glib.h>
 
 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 */
 extern gboolean config_focus_new;
 /*! Focus windows when the mouse enters them */
index ac902d2d4e218277c60418c9d147cf415b0bed38..f37973b3ed9bfce0298c5f4bc9985b9163abd131 100644 (file)
@@ -52,6 +52,9 @@ static Rect *pick_pointer_head(ObClient *c)
     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)
 {
     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,
                                       ObAppSettings *settings)
 {
-    Rect *screen;
+    Rect *screen = NULL;
 
     if (!settings || (settings && !settings->pos_given))
         return FALSE;
 
     /* Find which head the pointer is on */
-    if (settings->head == -1)
+    if (settings->monitor == 0)
         screen = pick_pointer_head(client);
-    else
-        screen = screen_area_monitor(client->desktop, settings->head);
+    else if (settings->monitor > 0 &&
+             (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)
         *x = screen->x + screen->width / 2 - client->area.width / 2;
This page took 0.034426 seconds and 4 git commands to generate.