Add "active" and "primary" options to the <monitor> placement option for per-app...
authorDana Jansens <danakj@orodu.net>
Fri, 14 Oct 2011 23:12:11 +0000 (19:12 -0400)
committerDana Jansens <danakj@orodu.net>
Fri, 14 Oct 2011 23:12:11 +0000 (19:12 -0400)
openbox/config.c
openbox/config.h
openbox/place.c

index be1e86e9effc8373d3aa2f9872d9b3ccc1d7c9ed..6860e69a30f1502e002abbde608bfd0e14190291 100644 (file)
@@ -114,6 +114,7 @@ ObAppSettings* config_create_app_settings(void)
     settings->type = -1;
     settings->decor = -1;
     settings->shade = -1;
+    settings->monitor_type = 0;
     settings->monitor = -1;
     settings->focus = -1;
     settings->desktop = 0;
@@ -138,6 +139,7 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
     copy_if(type, (ObClientType)-1);
     copy_if(decor, -1);
     copy_if(shade, -1);
+    copy_if(monitor_type, 0);
     copy_if(monitor, -1);
     copy_if(focus, -1);
     copy_if(desktop, 0);
@@ -176,8 +178,8 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
 
 /* Manages settings for individual applications.
    Some notes: monitor is the screen number in a multi monitor
-   (Xinerama) setup (starting from 0) or mouse, meaning the
-   monitor the pointer is on. Default: mouse.
+   (Xinerama) setup (starting from 0), or mouse: the monitor the pointer
+   is on, active: the active monitor, primary: the primary monitor.
    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
@@ -276,7 +278,14 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
                     if (!obt_xml_node_contains(c, "default")) {
                         gchar *s = obt_xml_node_string(c);
                         if (!g_ascii_strcasecmp(s, "mouse"))
-                            settings->monitor = 0;
+                            settings->monitor_type =
+                                    OB_APP_SETTINGS_MONITOR_MOUSE;
+                        else if (!g_ascii_strcasecmp(s, "active"))
+                            settings->monitor_type =
+                                    OB_APP_SETTINGS_MONITOR_ACTIVE;
+                        else if (!g_ascii_strcasecmp(s, "primary"))
+                            settings->monitor_type =
+                                    OB_APP_SETTINGS_MONITOR_PRIMARY;
                         else
                             settings->monitor = obt_xml_node_int(c);
                         g_free(s);
index 90b6581a0229de8550debf6582aa7254dc5c6f4e..dc27ab0b2f829db230ee5889130da2c91eba38f8 100644 (file)
 
 typedef struct _ObAppSettings ObAppSettings;
 
+typedef enum {
+    OB_APP_SETTINGS_MONITOR_FIXED,
+    OB_APP_SETTINGS_MONITOR_PRIMARY,
+    OB_APP_SETTINGS_MONITOR_ACTIVE,
+    OB_APP_SETTINGS_MONITOR_MOUSE
+} ObAppSettingsMonitor;
+
 struct _ObAppSettings
 {
     GPatternSpec *class;
@@ -49,6 +56,7 @@ struct _ObAppSettings
     gint shade;
     gint decor;
     gint focus;
+    ObAppSettingsMonitor monitor_type;
     gint monitor;
     gint iconic;
     gint skip_pager;
index a13bc2cbdbff41cdc7e3fe27994ad4ea4656e56a..8a4a42649b0569110c7b343892faccef2c98fd39 100644 (file)
@@ -451,7 +451,15 @@ static gboolean place_per_app_setting(ObClient *client, gint *x, gint *y,
     ob_debug("placing by per-app settings");
 
     /* Find which head the pointer is on */
-    if (settings->monitor == 0) {
+    if (settings->monitor_type == OB_APP_SETTINGS_MONITOR_PRIMARY) {
+        guint m = screen_monitor_primary(TRUE);
+        screen = screen_area(client->desktop, m, NULL);
+    }
+    else if (settings->monitor_type == OB_APP_SETTINGS_MONITOR_ACTIVE) {
+        guint m = screen_monitor_active();
+        screen = screen_area(client->desktop, m, NULL);
+    }
+    else if (settings->monitor_type == OB_APP_SETTINGS_MONITOR_MOUSE) {
         screen = pick_pointer_head(client);
         g_assert(screen);
     }