]> Dogcows Code - chaz/openbox/blobdiff - openbox/dock.c
get the size for all the apps before positioning them
[chaz/openbox] / openbox / dock.c
index 02c6d8e7a8f80388e178e9d1df5030cfa5ee3a31..934d3d03bcd8072390b4bb587a2c153df06b5ad4 100644 (file)
@@ -1,5 +1,6 @@
 #include "dock.h"
 #include "screen.h"
+#include "prop.h"
 #include "config.h"
 #include "grab.h"
 #include "openbox.h"
@@ -16,7 +17,6 @@ Strut dock_strut;
 void dock_startup()
 {
     XSetWindowAttributes attrib;
-    int i;
 
     STRUT_SET(dock_strut, 0, 0, 0, 0);
 
@@ -36,8 +36,8 @@ void dock_startup()
     XSetWindowBorderWidth(ob_display, dock->frame, theme_bwidth);
 
     g_hash_table_insert(window_map, &dock->frame, dock);
-    stacking_add(DOCK_AS_WINDOW(&dock[i]));
-    stacking_raise(DOCK_AS_WINDOW(&dock[i]));
+    stacking_add(DOCK_AS_WINDOW(dock));
+    stacking_raise(DOCK_AS_WINDOW(dock));
 }
 
 void dock_shutdown()
@@ -52,12 +52,25 @@ void dock_add(Window win, XWMHints *wmhints)
 {
     DockApp *app;
     XWindowAttributes attrib;
+    char **data;
 
     app = g_new0(DockApp, 1);
     app->obwin.type = Window_DockApp;
     app->win = win;
     app->icon_win = (wmhints->flags & IconWindowHint) ?
         wmhints->icon_window : win;
+
+    if (PROP_GETSS(app->win, wm_class, locale, &data)) {
+        if (data[0]) {
+           app->name = g_strdup(data[0]);
+            if (data[1])
+                app->class = g_strdup(data[1]);
+        }
+        g_strfreev(data);     
+    }
+
+    if (app->name == NULL) app->name = g_strdup("");
+    if (app->class == NULL) app->class = g_strdup("");
     
     if (XGetWindowAttributes(ob_display, app->icon_win, &attrib)) {
         app->w = attrib.width;
@@ -99,7 +112,7 @@ void dock_add(Window win, XWMHints *wmhints)
 
     g_hash_table_insert(window_map, &app->icon_win, app);
 
-    g_message("Managed Dock App: 0x%lx", app->icon_win);
+    g_message("Managed Dock App: 0x%lx (%s)", app->icon_win, app->class);
 }
 
 void dock_remove_all()
@@ -124,8 +137,10 @@ void dock_remove(DockApp *app, gboolean reparent)
     dock->dock_apps = g_list_remove(dock->dock_apps, app);
     dock_configure();
 
-    g_message("Unmanaged Dock App: 0x%lx", app->icon_win);
+    g_message("Unmanaged Dock App: 0x%lx (%s)", app->icon_win, app->class);
 
+    g_free(app->name);
+    g_free(app->class);
     g_free(app);
 }
 
@@ -137,19 +152,28 @@ void dock_configure()
 
     dock->w = dock->h = spot = 0;
 
+    /* get the size */
     for (it = dock->dock_apps; it; it = it->next) {
         struct DockApp *app = it->data;
         if (config_dock_horz) {
-            app->x = spot;
-            app->y = 0;
             dock->w += app->w;
             dock->h = MAX(dock->h, app->h);
-            spot += app->w;
         } else {
-            app->x = 0;
-            app->y = spot;
             dock->w = MAX(dock->w, app->w);
             dock->h += app->h;
+        }
+    }
+
+    /* position the apps */
+    for (it = dock->dock_apps; it; it = it->next) {
+        struct DockApp *app = it->data;
+        if (config_dock_horz) {
+            app->x = spot;
+            app->y = (dock->h - app->h) / 2;
+            spot += app->w;
+        } else {
+            app->x = (dock->w - app->w) / 2;
+            app->y = spot;
             spot += app->h;
         }
 
This page took 0.023242 seconds and 4 git commands to generate.