]> Dogcows Code - chaz/openbox/commitdiff
use the ObOrientation enum instead of a horz bool for configuring the dock's orientation
authorDana Jansens <danakj@orodu.net>
Thu, 10 Jul 2003 16:38:45 +0000 (16:38 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 10 Jul 2003 16:38:45 +0000 (16:38 +0000)
openbox/config.c
openbox/config.h
openbox/dock.c

index b8ffa9a6c488d2ff36833ec9ad7dcce8303ba914..4fd251dab415e6371904a163cedf7936136af289 100644 (file)
@@ -15,14 +15,14 @@ GSList *config_desktops_names;
 gboolean config_opaque_move;
 gboolean config_opaque_resize;
 
-StackLayer   config_dock_layer;
-gboolean     config_dock_floating;
-ObDirection  config_dock_pos;
-int          config_dock_x;
-int          config_dock_y;
-gboolean     config_dock_horz;
-gboolean     config_dock_hide;
-guint        config_dock_hide_timeout;
+StackLayer    config_dock_layer;
+gboolean      config_dock_floating;
+ObDirection   config_dock_pos;
+int           config_dock_x;
+int           config_dock_y;
+ObOrientation config_dock_orient;
+gboolean      config_dock_hide;
+guint         config_dock_hide_timeout;
 
 static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d)
 {
@@ -132,9 +132,9 @@ static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
     }
     if ((n = parse_find_node("direction", node))) {
         if (parse_contains("horizontal", doc, n))
-            config_dock_horz = TRUE;
+            config_dock_orient = OB_ORIENTATION_HORZ;
         else if (parse_contains("vertical", doc, n))
-            config_dock_horz = FALSE;
+            config_dock_orient = OB_ORIENTATION_VERT;
     }
     if ((n = parse_find_node("autoHide", node)))
         config_dock_hide = parse_bool(doc, n);
@@ -171,7 +171,7 @@ void config_startup()
     config_dock_floating = FALSE;
     config_dock_x = 0;
     config_dock_y = 0;
-    config_dock_horz = FALSE;
+    config_dock_orient = OB_ORIENTATION_VERT;
     config_dock_hide = FALSE;
     config_dock_hide_timeout = 3000;
 
index 6b0f3be5ed7588e22e1a0b69a41666ce6a6c4726..41e84fdec008e3427d7de74c0c16c9317157e442 100644 (file)
@@ -39,7 +39,7 @@ extern int config_dock_x;
   position */
 extern int config_dock_y;
 /*! Whether the dock places the dockapps in it horizontally or vertically */
-extern gboolean config_dock_horz;
+extern ObOrientation config_dock_orient;
 /*! Whether to auto-hide the dock when the pointer is not over it */
 extern gboolean config_dock_hide;
 /*! The number of milliseconds to wait before hiding the dock */
index 5a9e02ec7be0364955661889242e9fdb06e4e0af..cb41f7ee2d16454725d596cf96fc355f6e318d43 100644 (file)
@@ -161,28 +161,34 @@ void dock_configure()
     /* get the size */
     for (it = dock->dock_apps; it; it = it->next) {
         ObDockApp *app = it->data;
-        if (config_dock_horz) {
+        switch (config_dock_orient) {
+        case OB_ORIENTATION_HORZ:
             dock->w += app->w;
             dock->h = MAX(dock->h, app->h);
-        } else {
+            break;
+        case OB_ORIENTATION_VERT:
             dock->w = MAX(dock->w, app->w);
             dock->h += app->h;
+            break;
         }
     }
 
-    spot = (config_dock_horz ? minw : minh) / 2;
+    spot = (config_dock_orient == OB_ORIENTATION_HORZ ? minw : minh) / 2;
 
     /* position the apps */
     for (it = dock->dock_apps; it; it = it->next) {
         ObDockApp *app = it->data;
-        if (config_dock_horz) {
+        switch (config_dock_orient) {
+        case OB_ORIENTATION_HORZ:
             app->x = spot;
             app->y = (dock->h - app->h) / 2;
             spot += app->w;
-        } else {
+            break;
+        case OB_ORIENTATION_VERT:
             app->x = (dock->w - app->w) / 2;
             app->y = spot;
             spot += app->h;
+            break;
         }
 
         XMoveWindow(ob_display, app->icon_win, app->x, app->y);
@@ -273,19 +279,27 @@ void dock_configure()
         if (!config_dock_floating) {
             switch (config_dock_pos) {
             case OB_DIRECTION_NORTHWEST:
-                if (config_dock_horz)
+                switch (config_dock_orient) {
+                case OB_ORIENTATION_HORZ:
                     dock->y -= dock->h - ob_rr_theme->bwidth;
-                else
+                    break;
+                case OB_ORIENTATION_VERT:
                     dock->x -= dock->w - ob_rr_theme->bwidth;
+                    break;
+                }
                 break;
             case OB_DIRECTION_NORTH:
                 dock->y -= dock->h - ob_rr_theme->bwidth;
                 break;
             case OB_DIRECTION_NORTHEAST:
-                if (config_dock_horz)
+                switch (config_dock_orient) {
+                case OB_ORIENTATION_HORZ:
                     dock->y -= dock->h - ob_rr_theme->bwidth;
-                else
+                    break;
+                case OB_ORIENTATION_VERT:
                     dock->x += dock->w - ob_rr_theme->bwidth;
+                    break;
+                }
                 break;
             case OB_DIRECTION_WEST:
                 dock->x -= dock->w - ob_rr_theme->bwidth;
@@ -294,19 +308,26 @@ void dock_configure()
                 dock->x += dock->w - ob_rr_theme->bwidth;
                 break;
             case OB_DIRECTION_SOUTHWEST:
-                if (config_dock_horz)
+                switch (config_dock_orient) {
+                case OB_ORIENTATION_HORZ:
                     dock->y += dock->h - ob_rr_theme->bwidth;
-                else
+                    break;
+                case OB_ORIENTATION_VERT:
                     dock->x -= dock->w - ob_rr_theme->bwidth;
-                break;
+                    break;
+                } break;
             case OB_DIRECTION_SOUTH:
                 dock->y += dock->h - ob_rr_theme->bwidth;
                 break;
             case OB_DIRECTION_SOUTHEAST:
-                if (config_dock_horz)
+                switch (config_dock_orient) {
+                case OB_ORIENTATION_HORZ:
                     dock->y += dock->h - ob_rr_theme->bwidth;
-                else
+                    break;
+                case OB_ORIENTATION_VERT:
                     dock->x += dock->w - ob_rr_theme->bwidth;
+                    break;
+                }
                 break;
             }    
         }
@@ -325,19 +346,27 @@ void dock_configure()
     } else {
         switch (config_dock_pos) {
         case OB_DIRECTION_NORTHWEST:
-            if (config_dock_horz)
+            switch (config_dock_orient) {
+            case OB_ORIENTATION_HORZ:
                 STRUT_SET(dock_strut, 0, strh, 0, 0);
-            else
+                break;
+            case OB_ORIENTATION_VERT:
                 STRUT_SET(dock_strut, strw, 0, 0, 0);
+                break;
+            }
             break;
         case OB_DIRECTION_NORTH:
             STRUT_SET(dock_strut, 0, strh, 0, 0);
             break;
         case OB_DIRECTION_NORTHEAST:
-            if (config_dock_horz)
+            switch (config_dock_orient) {
+            case OB_ORIENTATION_HORZ:
                 STRUT_SET(dock_strut, 0, strh, 0, 0);
-            else
+                break;
+            case OB_ORIENTATION_VERT:
                 STRUT_SET(dock_strut, 0, 0, strw, 0);
+                break;
+            }
             break;
         case OB_DIRECTION_WEST:
             STRUT_SET(dock_strut, strw, 0, 0, 0);
@@ -346,19 +375,27 @@ void dock_configure()
             STRUT_SET(dock_strut, 0, 0, strw, 0);
             break;
         case OB_DIRECTION_SOUTHWEST:
-            if (config_dock_horz)
+            switch (config_dock_orient) {
+            case OB_ORIENTATION_HORZ:
                 STRUT_SET(dock_strut, 0, 0, 0, strh);
-            else
+                break;
+            case OB_ORIENTATION_VERT:
                 STRUT_SET(dock_strut, strw, 0, 0, 0);
+                break;
+            }
             break;
         case OB_DIRECTION_SOUTH:
             STRUT_SET(dock_strut, 0, 0, 0, strh);
             break;
         case OB_DIRECTION_SOUTHEAST:
-            if (config_dock_horz)
+            switch (config_dock_orient) {
+            case OB_ORIENTATION_HORZ:
                 STRUT_SET(dock_strut, 0, 0, 0, strh);
-            else
+                break;
+            case OB_ORIENTATION_VERT:
                 STRUT_SET(dock_strut, 0, 0, strw, 0);
+                break;
+            }
             break;
         }
     }
@@ -399,6 +436,7 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
     GList *it;
     gint x, y;
     gboolean after;
+    gboolean stop;
 
     x = e->x_root;
     y = e->y_root;
@@ -414,14 +452,18 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
     y -= dock->y;
 
     /* which dock app are we on top of? */
-    for (it = dock->dock_apps; it; it = it->next) {
+    stop = FALSE;
+    for (it = dock->dock_apps; it && !stop; it = it->next) {
         over = it->data;
-        if (config_dock_horz) {
+        switch (config_dock_orient) {
+        case OB_ORIENTATION_HORZ:
             if (x >= over->x && x < over->x + over->w)
-                break;
-        } else {
+                stop = TRUE;
+            break;
+        case OB_ORIENTATION_VERT:
             if (y >= over->y && y < over->y + over->h)
-                break;
+                stop = TRUE;
+            break;
         }
     }
     if (!it || app == over) return;
@@ -429,10 +471,14 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
     x -= over->x;
     y -= over->y;
 
-    if (config_dock_horz)
+    switch (config_dock_orient) {
+    case OB_ORIENTATION_HORZ:
         after = (x > over->w / 2);
-    else
+        break;
+    case OB_ORIENTATION_VERT:
         after = (y > over->h / 2);
+        break;
+    }
 
     /* remove before doing the it->next! */
     dock->dock_apps = g_list_remove(dock->dock_apps, app);
This page took 0.030049 seconds and 4 git commands to generate.