]> Dogcows Code - chaz/openbox/commitdiff
move stuff around some more
authorMikael Magnusson <mikachu@comhem.se>
Thu, 8 Jun 2006 11:36:43 +0000 (11:36 +0000)
committerMikael Magnusson <mikachu@comhem.se>
Thu, 8 Jun 2006 11:36:43 +0000 (11:36 +0000)
openbox/client.c
openbox/client.h
openbox/config.c
openbox/per_app_settings.c [deleted file]
openbox/per_app_settings.h [deleted file]
openbox/place.c

index e7af04b85270e97d115683a6c3b1f3bbd71fe338..ce1c417fd0f8f73303f4b243de8cb8c93123901b 100644 (file)
@@ -40,7 +40,6 @@
 #include "keyboard.h"
 #include "mouse.h"
 #include "render/render.h"
-#include "per_app_settings.h"
 
 #include <glib.h>
 #include <X11/Xutil.h>
@@ -205,6 +204,26 @@ void client_manage_all()
     XFree(children);
 }
 
+/* This should possibly do something more interesting than just match
+ * against WM_CLASS literally. */
+static ObAppSetting *get_settings(ObClient *client)
+{
+    GSList *a = config_per_app_settings;
+
+    while (a) {
+        ObAppSetting *app = (ObAppSetting *) a->data;
+        
+        if (!strcmp(app->name, client->name)) {
+            ob_debug("Window matching: %s\n", app->name);
+
+            return (ObAppSetting *) a->data;
+        }
+
+        a = a->next;
+    }
+    return NULL;
+}
+
 void client_manage(Window window)
 {
     ObClient *self;
@@ -295,8 +314,7 @@ void client_manage(Window window)
     client_apply_startup_state(self);
 
     /* get and set application level settings */
-    /* XXX move that function here */
-    settings = (ObAppSetting *) get_client_settings(self);
+    settings = get_settings(self);
 
     if (settings) {
         if (settings->shade && !settings->decor)
@@ -362,11 +380,7 @@ void client_manage(Window window)
         gint x = self->area.x, ox = x;
         gint y = self->area.y, oy = y;
 
-        if (settings)
-            /* XXX put this in place.c */
-            place_window_from_settings(settings, self, &x, &y);
-        else
-            place_client(self, &x, &y);
+        place_client(self, &x, &y, settings);
 
         /* make sure the window is visible. */
         client_find_onscreen(self, &x, &y,
index 22a7dd207183d02e381bd35a5ba34a100bb8982b..e2193e98e2ccd865ee0a14b1785d036e8e1c0ae1 100644 (file)
@@ -32,8 +32,9 @@ struct _ObFrame;
 struct _ObGroup;
 struct _ObSessionState;
 
-typedef struct _ObClient     ObClient;
-typedef struct _ObClientIcon ObClientIcon;
+typedef struct _ObClient      ObClient;
+typedef struct _ObClientIcon  ObClientIcon;
+typedef struct _ObAppSettings ObAppSettings;
 
 /* The value in client.transient_for indicating it is a transient for its
    group instead of for a single window */
@@ -269,6 +270,24 @@ struct _ObClient
     guint nicons;
 };
 
+struct _ObAppSettings
+{
+    gchar *name;
+    gboolean decor;
+    gboolean shade;
+    gboolean focus;
+
+    Point position;
+    gboolean center_x;
+    gboolean center_y;
+    gboolean pos_given;
+
+    guint desktop;
+    guint head;
+
+    guint layer;
+};
+
 extern GList *client_list;
 
 void client_startup(gboolean reconfig);
index fcff4a092e3fcd8ddf558b1c398cc84744ab6dc7..dd8d2b830b9314d6f570c20a0b8353117e45cd35 100644 (file)
@@ -22,7 +22,6 @@
 #include "mouse.h"
 #include "prop.h"
 #include "translate.h"
-#include "per_app_settings.h"
 #include "parser/parse.h"
 #include "openbox.h"
 
@@ -119,59 +118,65 @@ static void parse_per_app_settings(ObParseInst *i, xmlDocPtr doc,
     gchar *name;
 
     while (app) {
+        gboolean x_pos_given = FALSE;
         if (parse_attr_string("name", app, &name)) {
             xmlNodePtr n, c;
-            ObAppSetting *setting = g_new0(ObAppSetting, 1);
-            setting->name = name;
+            ObAppSettings *settings = g_new0(ObAppSetting, 1);
+            settings->name = name;
 
-            setting->decor = TRUE;
+            settings->decor = TRUE;
             if ((n = parse_find_node("decor", app->children)))
-                setting->decor = parse_bool(doc, n);
+                settings->decor = parse_bool(doc, n);
 
             if ((n = parse_find_node("shade", app->children)))
-                setting->shade = parse_bool(doc, n);
+                settings->shade = parse_bool(doc, n);
 
-            setting->position.x = setting->position.y = -1;
+            settings->position.x = settings->position.y = 0;
+            settings->pos_given = FALSE;
             if ((n = parse_find_node("position", app->children))) {
                 if ((c = parse_find_node("x", n->children))) {
                     if (!strcmp(parse_string(doc, c), "center")) {
-                        setting->center_x = TRUE;
+                        settings->center_x = TRUE;
+                        x_pos_given = TRUE;
+                    } else {
+                        settings->position.x = parse_int(doc, c);
+                        x_pos_given = TRUE;
                     }
-                    else
-                        setting->position.x = parse_int(doc, c);
                 }
 
-                if ((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")) {
-                        setting->center_y = TRUE;
+                        settings->center_y = TRUE;
+                        settings->pos_given;
+                    } else {
+                        settings->position.y = parse_int(doc, c);
+                        settings->pos_given;
                     }
-                    else
-                        setting->position.y = parse_int(doc, c);
                 }
             }
 
             if ((n = parse_find_node("focus", app->children)))
-                setting->focus = parse_bool(doc, n);
+                settings->focus = parse_bool(doc, n);
 
             if ((n = parse_find_node("desktop", app->children)))
-                setting->desktop = parse_int(doc, n);
+                settings->desktop = parse_int(doc, n);
             else
-                setting->desktop = -1;
+                settings->desktop = -1;
 
             if ((n = parse_find_node("head", app->children))) {
                 if (!strcmp(parse_string(doc, n), "mouse"))
-                    setting->head = -1;
+                    settings->head = -1;
                 else
-                    setting->head = parse_int(doc, n);
+                    settings->head = parse_int(doc, n);
             }
 
             if ((n = parse_find_node("layer", app->children))) {
                 if (!strcmp(parse_string(doc, n), "above"))
-                    setting->layer = 1;
+                    settings->layer = 1;
                 else if (!strcmp(parse_string(doc, n), "below"))
-                    setting->layer = -1;
+                    settings->layer = -1;
                 else
-                    setting->layer = 0;
+                    settings->layer = 0;
             }
 
             config_per_app_settings = g_slist_append(config_per_app_settings,
diff --git a/openbox/per_app_settings.c b/openbox/per_app_settings.c
deleted file mode 100644 (file)
index 73331cc..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
-   client.h for the Openbox window manager
-   Copyright (c) 2006        Mikael Magnusson
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#include "per_app_settings.h"
-#include "screen.h"
-#include "config.h"
-
-/* XXX put in client.c */
-/* This should possibly do something more interesting than just match
- * against WM_CLASS literally. */
-ObAppSetting *get_client_settings(ObClient *client)
-{
-    GSList *a = config_per_app_settings;
-
-    while (a) {
-        ObAppSetting *app = (ObAppSetting *) a->data;
-        
-        if (!strcmp(app->name, client->name)) {
-            ob_debug("Window matching: %s\n", app->name);
-
-            return (ObAppSetting *) a->data;
-        }
-
-        a = a->next;
-    }
-    return NULL;
-}
-
-/* XXX put in place.c */
-void place_window_from_settings(ObAppSetting *setting, ObClient *client, gint *x, gint *y)
-{
-    gint px, py, i;
-    Rect *screen;
-
-    /* Find which head the pointer is on, partly taken from place.c */
-    if (setting->head == -1) {
-        screen_pointer_pos(&px, &py);
-
-        for (i = 0; i < screen_num_monitors; i++) {
-            screen = screen_area_monitor(client->desktop, i);
-            if (RECT_CONTAINS(*screen, px, py))
-                break;
-        }
-
-        if (i == screen_num_monitors)
-            screen = screen_area_monitor(client->desktop, 0);
-    }
-    else
-        screen = screen_area_monitor(client->desktop, setting->head);
-
-    if (setting->position.x == -1 && setting->center_x)
-        *x = screen->x + screen->width / 2 - client->area.width / 2;
-    else if (setting->position.x != -1)
-        *x = screen->x + setting->position.x;
-
-    if (setting->position.y == -1 && setting->center_y)
-        *y = screen->y + screen->height / 2 - client->area.height / 2;
-    else if (setting->position.y != -1)
-        *y = screen->y + setting->position.y;
-
-}
diff --git a/openbox/per_app_settings.h b/openbox/per_app_settings.h
deleted file mode 100644 (file)
index 0b1bfca..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
-
-   client.h for the Openbox window manager
-   Copyright (c) 2006        Mikael Magnusson
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   See the COPYING file for a copy of the GNU General Public License.
-*/
-
-#ifndef __per_app_settings_h
-#define __per_app_settings_h
-
-#include "client.h"
-
-typedef struct _ObAppSetting ObAppSetting;
-
-struct _ObAppSetting
-{
-    gchar *name;
-    gboolean decor;
-    gboolean shade;
-    gboolean focus;
-
-    Point position;
-    gboolean center_x;
-    gboolean center_y;
-
-    guint desktop;
-    guint head;
-
-    guint layer;
-};
-
-ObAppSetting *get_client_settings(ObClient *client);
-void place_window_from_settings(ObAppSetting *setting, ObClient *client, gint *x, gint *y);
-
-#endif
index 6669a28e4c5fa42723c064e3acb527ed2c8f5ffc..78e94814fcb6f334510e3592f588d1d9171050a3 100644 (file)
@@ -331,6 +331,43 @@ static gboolean place_under_mouse(ObClient *client, gint *x, gint *y)
     return TRUE;
 }
 
+void place_window_from_settings(ObClient *client, gint *x, gint *y, ObAppSettings *settings)
+{
+    gint px, py, i;
+    Rect *screen;
+
+    if (!settings || (settings && !settings->pos_given))
+        return FALSE;
+
+    /* Find which head the pointer is on */
+    if (settings->head == -1 && screen_num_monitors > 1) {
+        screen_pointer_pos(&px, &py);
+
+        for (i = 0; i < screen_num_monitors; i++) {
+            screen = screen_area_monitor(client->desktop, i);
+            if (RECT_CONTAINS(*screen, px, py))
+                break;
+        }
+
+        if (i == screen_num_monitors)
+            screen = screen_area_monitor(client->desktop, 0);
+    }
+    else
+        screen = screen_area_monitor(client->desktop, settings->head);
+
+    if (settings->center_x)
+        *x = screen->x + screen->width / 2 - client->area.width / 2;
+    else
+        *x = screen->x + settings->position.x;
+
+    if (settings->center_y)
+        *y = screen->y + screen->height / 2 - client->area.height / 2;
+    else
+        *y = screen->y + settings->position.y;
+
+    return TRUE;
+}
+
 static gboolean place_transient(ObClient *client, gint *x, gint *y)
 {
     if (client->transient_for) {
@@ -373,11 +410,12 @@ static gboolean place_transient(ObClient *client, gint *x, gint *y)
     return FALSE;
 }
 
-void place_client(ObClient *client, gint *x, gint *y)
+void place_client(ObClient *client, gint *x, gint *y, ObAppSetting *settings)
 {
     if (client->positioned)
         return;
     if (place_transient(client, x, y)             ||
+        place_per_app_setting(client, x, y, settings) ||
         ((config_place_policy == OB_PLACE_POLICY_MOUSE) ?
          place_under_mouse(client, x, y) :
          place_smart(client, x, y, SMART_FULL)    ||
This page took 0.042806 seconds and 4 git commands to generate.