]> Dogcows Code - chaz/openbox/commitdiff
add an <active> option for window placement, to try force new windows on the active...
authorDana Jansens <danakj@orodu.net>
Sat, 12 Jan 2008 00:32:45 +0000 (19:32 -0500)
committerDana Jansens <danakj@orodu.net>
Sat, 12 Jan 2008 00:32:45 +0000 (19:32 -0500)
data/rc.xml
data/rc.xsd
openbox/config.c
openbox/config.h
openbox/place.c

index e3a59eb2f1c2d3b205f6374b0f23679f673a551c..efbd8a9ca35684ab598f24628b7e27e7b3a7d958 100644 (file)
@@ -35,6 +35,9 @@
   <center>yes</center>
   <!-- whether to place windows in the center of the free area found or
        the top left corner -->
+  <active>no</active>
+  <!-- force new windows ont the active monitor on a multi-head system, unless
+       they are part of an application already on another monitor -->
 </placement>
 
 <theme>
index adafc5f498b528bcdbd861e45d254b9a564a1e39..ef610bfa1e3554dd05afe02f17ea738d48cd786e 100644 (file)
@@ -54,6 +54,7 @@
         </xsd:annotation>
         <xsd:element name="policy" type="ob:placementpolicy"/>
         <xsd:element name="center" type="ob:bool"/>
+        <xsd:element name="active" type="ob:bool"/>
     </xsd:complexType>
     <xsd:complexType name="margins">
         <xsd:annotation>
index ff4c542b13fb17b78b7883731efda36c3a61a257..25e30fff4c6e4b7a19a4c3cff2a80804cb80434d 100644 (file)
@@ -38,6 +38,7 @@ gboolean config_focus_under_mouse;
 
 ObPlacePolicy config_place_policy;
 gboolean      config_place_center;
+gboolean      config_place_active;
 
 StrutPartial config_margins;
 
@@ -500,6 +501,8 @@ static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
             config_place_policy = OB_PLACE_POLICY_MOUSE;
     if ((n = parse_find_node("center", node)))
         config_place_center = parse_bool(doc, n);
+    if ((n = parse_find_node("active", node)))
+        config_place_active = parse_bool(doc, n);
 }
 
 static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
@@ -880,6 +883,7 @@ void config_startup(ObParseInst *i)
 
     config_place_policy = OB_PLACE_POLICY_SMART;
     config_place_center = TRUE;
+    config_place_active = FALSE;
 
     parse_register(i, "placement", parse_placement, NULL);
 
index 9d0602e28b13b62630c742a146cf949ff584f370..2c4b4dba3aaa1a163b7783a6f4b3b4071cbadf00 100644 (file)
@@ -75,9 +75,13 @@ extern gboolean config_focus_last;
  */
 extern gboolean config_focus_under_mouse;
 
+/*! The algorithm to use for placing new windows */
 extern ObPlacePolicy config_place_policy;
 /*! Place windows in the center of the free area */
 extern gboolean config_place_center;
+/*! Place windows on the active monitor (unless they are part of an application
+  already on another monitor) */
+extern gboolean config_place_active;
 
 /*! User-specified margins around the edge of the screen(s) */
 extern StrutPartial config_margins;
index aa572db2aff2a34eb804bdffc15eff0a79b0657f..276d9288c71ac1ff434e9c480d3417406b1e82e7 100644 (file)
@@ -108,9 +108,9 @@ static Rect **pick_head(ObClient *c)
         }
     }
 
-    if (focus_client) {
+    if (focus_client && client_normal(focus_client)) {
         add_choice(choice, client_monitor(focus_client));
-        ob_debug("placement adding choice %d for focused window\n",
+        ob_debug("placement adding choice %d for normal focused window\n",
                  client_monitor(focus_client));
     }
 
@@ -146,7 +146,7 @@ static gboolean place_random(ObClient *client, gint *x, gint *y)
     guint i;
 
     areas = pick_head(client);
-    i = g_random_int_range(0, screen_num_monitors);
+    i = config_place_active ? 0 : g_random_int_range(0, screen_num_monitors);
 
     l = areas[i]->x;
     t = areas[i]->y;
@@ -254,8 +254,11 @@ static gboolean place_nooverlap(ObClient *c, gint *x, gint *y)
 
     /* try ignoring different things to find empty space */
     for (ignore = 0; ignore < IGNORE_END && !ret; ignore++) {
-        /* try all monitors in order of preference */
-        for (i = 0; i < screen_num_monitors && !ret; ++i) {
+        /* try all monitors in order of preference, but only the first one
+           if config_place_active is true */
+        for (i = 0; (i < (config_place_active ? 1 : screen_num_monitors) &&
+                     !ret); ++i)
+        {
             GList *it;
 
             /* add the whole monitor */
This page took 0.029404 seconds and 4 git commands to generate.