all repos — openbox @ 5c2e4cced43e59fbe2bd974aabde9d0b1c9f5748

openbox fork - make it a bit more like ryudo

use the ObOrientation enum instead of a horz bool for configuring the dock's orientation
Dana Jansens danakj@orodu.net
commit

5c2e4cced43e59fbe2bd974aabde9d0b1c9f5748

parent

d206303a9f0742ff330aebe8129d6044ade30a94

3 files changed, 87 insertions(+), 41 deletions(-)

jump to
M openbox/config.copenbox/config.c

@@ -15,14 +15,14 @@

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 @@ config_dock_layer = Layer_Below;

} 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 @@ config_dock_pos = OB_DIRECTION_NORTHEAST;

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;
M openbox/config.hopenbox/config.h

@@ -39,7 +39,7 @@ /*! If config_dock_pos is DockPos_Floating, this is the top-left corner's

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 */
M openbox/dock.copenbox/dock.c

@@ -161,28 +161,34 @@

/* 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 @@ if (config_dock_hide && dock->hidden) {

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 @@ case OB_DIRECTION_EAST:

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 @@ STRUT_SET(dock_strut, 0, 0, 0, 0);

} 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 @@ case OB_DIRECTION_EAST:

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 @@ ObDockApp *over = NULL;

GList *it; gint x, y; gboolean after; + gboolean stop; x = e->x_root; y = e->y_root;

@@ -414,14 +452,18 @@ x -= dock->x;

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 @@

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);