use the ObOrientation enum instead of a horz bool for configuring the dock's orientation

This commit is contained in:
Dana Jansens 2003-07-10 16:38:45 +00:00
parent d206303a9f
commit 5c2e4cced4
3 changed files with 87 additions and 41 deletions

View file

@ -15,14 +15,14 @@ GSList *config_desktops_names;
gboolean config_opaque_move; gboolean config_opaque_move;
gboolean config_opaque_resize; gboolean config_opaque_resize;
StackLayer config_dock_layer; StackLayer config_dock_layer;
gboolean config_dock_floating; gboolean config_dock_floating;
ObDirection config_dock_pos; ObDirection config_dock_pos;
int config_dock_x; int config_dock_x;
int config_dock_y; int config_dock_y;
gboolean config_dock_horz; ObOrientation config_dock_orient;
gboolean config_dock_hide; gboolean config_dock_hide;
guint config_dock_hide_timeout; guint config_dock_hide_timeout;
static void parse_focus(xmlDocPtr doc, xmlNodePtr node, void *d) 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 ((n = parse_find_node("direction", node))) {
if (parse_contains("horizontal", doc, n)) if (parse_contains("horizontal", doc, n))
config_dock_horz = TRUE; config_dock_orient = OB_ORIENTATION_HORZ;
else if (parse_contains("vertical", doc, n)) else if (parse_contains("vertical", doc, n))
config_dock_horz = FALSE; config_dock_orient = OB_ORIENTATION_VERT;
} }
if ((n = parse_find_node("autoHide", node))) if ((n = parse_find_node("autoHide", node)))
config_dock_hide = parse_bool(doc, n); config_dock_hide = parse_bool(doc, n);
@ -171,7 +171,7 @@ void config_startup()
config_dock_floating = FALSE; config_dock_floating = FALSE;
config_dock_x = 0; config_dock_x = 0;
config_dock_y = 0; config_dock_y = 0;
config_dock_horz = FALSE; config_dock_orient = OB_ORIENTATION_VERT;
config_dock_hide = FALSE; config_dock_hide = FALSE;
config_dock_hide_timeout = 3000; config_dock_hide_timeout = 3000;

View file

@ -39,7 +39,7 @@ extern int config_dock_x;
position */ position */
extern int config_dock_y; extern int config_dock_y;
/*! Whether the dock places the dockapps in it horizontally or vertically */ /*! 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 */ /*! Whether to auto-hide the dock when the pointer is not over it */
extern gboolean config_dock_hide; extern gboolean config_dock_hide;
/*! The number of milliseconds to wait before hiding the dock */ /*! The number of milliseconds to wait before hiding the dock */

View file

@ -161,28 +161,34 @@ void dock_configure()
/* get the size */ /* get the size */
for (it = dock->dock_apps; it; it = it->next) { for (it = dock->dock_apps; it; it = it->next) {
ObDockApp *app = it->data; ObDockApp *app = it->data;
if (config_dock_horz) { switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->w += app->w; dock->w += app->w;
dock->h = MAX(dock->h, app->h); dock->h = MAX(dock->h, app->h);
} else { break;
case OB_ORIENTATION_VERT:
dock->w = MAX(dock->w, app->w); dock->w = MAX(dock->w, app->w);
dock->h += app->h; 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 */ /* position the apps */
for (it = dock->dock_apps; it; it = it->next) { for (it = dock->dock_apps; it; it = it->next) {
ObDockApp *app = it->data; ObDockApp *app = it->data;
if (config_dock_horz) { switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
app->x = spot; app->x = spot;
app->y = (dock->h - app->h) / 2; app->y = (dock->h - app->h) / 2;
spot += app->w; spot += app->w;
} else { break;
case OB_ORIENTATION_VERT:
app->x = (dock->w - app->w) / 2; app->x = (dock->w - app->w) / 2;
app->y = spot; app->y = spot;
spot += app->h; spot += app->h;
break;
} }
XMoveWindow(ob_display, app->icon_win, app->x, app->y); XMoveWindow(ob_display, app->icon_win, app->x, app->y);
@ -273,19 +279,27 @@ void dock_configure()
if (!config_dock_floating) { if (!config_dock_floating) {
switch (config_dock_pos) { switch (config_dock_pos) {
case OB_DIRECTION_NORTHWEST: case OB_DIRECTION_NORTHWEST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y -= dock->h - ob_rr_theme->bwidth; dock->y -= dock->h - ob_rr_theme->bwidth;
else break;
case OB_ORIENTATION_VERT:
dock->x -= dock->w - ob_rr_theme->bwidth; dock->x -= dock->w - ob_rr_theme->bwidth;
break;
}
break; break;
case OB_DIRECTION_NORTH: case OB_DIRECTION_NORTH:
dock->y -= dock->h - ob_rr_theme->bwidth; dock->y -= dock->h - ob_rr_theme->bwidth;
break; break;
case OB_DIRECTION_NORTHEAST: case OB_DIRECTION_NORTHEAST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y -= dock->h - ob_rr_theme->bwidth; dock->y -= dock->h - ob_rr_theme->bwidth;
else break;
case OB_ORIENTATION_VERT:
dock->x += dock->w - ob_rr_theme->bwidth; dock->x += dock->w - ob_rr_theme->bwidth;
break;
}
break; break;
case OB_DIRECTION_WEST: case OB_DIRECTION_WEST:
dock->x -= dock->w - ob_rr_theme->bwidth; dock->x -= dock->w - ob_rr_theme->bwidth;
@ -294,19 +308,26 @@ void dock_configure()
dock->x += dock->w - ob_rr_theme->bwidth; dock->x += dock->w - ob_rr_theme->bwidth;
break; break;
case OB_DIRECTION_SOUTHWEST: case OB_DIRECTION_SOUTHWEST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y += dock->h - ob_rr_theme->bwidth; dock->y += dock->h - ob_rr_theme->bwidth;
else break;
case OB_ORIENTATION_VERT:
dock->x -= dock->w - ob_rr_theme->bwidth; dock->x -= dock->w - ob_rr_theme->bwidth;
break; break;
} break;
case OB_DIRECTION_SOUTH: case OB_DIRECTION_SOUTH:
dock->y += dock->h - ob_rr_theme->bwidth; dock->y += dock->h - ob_rr_theme->bwidth;
break; break;
case OB_DIRECTION_SOUTHEAST: case OB_DIRECTION_SOUTHEAST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y += dock->h - ob_rr_theme->bwidth; dock->y += dock->h - ob_rr_theme->bwidth;
else break;
case OB_ORIENTATION_VERT:
dock->x += dock->w - ob_rr_theme->bwidth; dock->x += dock->w - ob_rr_theme->bwidth;
break;
}
break; break;
} }
} }
@ -325,19 +346,27 @@ void dock_configure()
} else { } else {
switch (config_dock_pos) { switch (config_dock_pos) {
case OB_DIRECTION_NORTHWEST: case OB_DIRECTION_NORTHWEST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, strh, 0, 0); STRUT_SET(dock_strut, 0, strh, 0, 0);
else break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, strw, 0, 0, 0); STRUT_SET(dock_strut, strw, 0, 0, 0);
break;
}
break; break;
case OB_DIRECTION_NORTH: case OB_DIRECTION_NORTH:
STRUT_SET(dock_strut, 0, strh, 0, 0); STRUT_SET(dock_strut, 0, strh, 0, 0);
break; break;
case OB_DIRECTION_NORTHEAST: case OB_DIRECTION_NORTHEAST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, strh, 0, 0); STRUT_SET(dock_strut, 0, strh, 0, 0);
else break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, 0, 0, strw, 0); STRUT_SET(dock_strut, 0, 0, strw, 0);
break;
}
break; break;
case OB_DIRECTION_WEST: case OB_DIRECTION_WEST:
STRUT_SET(dock_strut, strw, 0, 0, 0); STRUT_SET(dock_strut, strw, 0, 0, 0);
@ -346,19 +375,27 @@ void dock_configure()
STRUT_SET(dock_strut, 0, 0, strw, 0); STRUT_SET(dock_strut, 0, 0, strw, 0);
break; break;
case OB_DIRECTION_SOUTHWEST: case OB_DIRECTION_SOUTHWEST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, 0, 0, strh); STRUT_SET(dock_strut, 0, 0, 0, strh);
else break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, strw, 0, 0, 0); STRUT_SET(dock_strut, strw, 0, 0, 0);
break;
}
break; break;
case OB_DIRECTION_SOUTH: case OB_DIRECTION_SOUTH:
STRUT_SET(dock_strut, 0, 0, 0, strh); STRUT_SET(dock_strut, 0, 0, 0, strh);
break; break;
case OB_DIRECTION_SOUTHEAST: case OB_DIRECTION_SOUTHEAST:
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, 0, 0, strh); STRUT_SET(dock_strut, 0, 0, 0, strh);
else break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, 0, 0, strw, 0); STRUT_SET(dock_strut, 0, 0, strw, 0);
break;
}
break; break;
} }
} }
@ -399,6 +436,7 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
GList *it; GList *it;
gint x, y; gint x, y;
gboolean after; gboolean after;
gboolean stop;
x = e->x_root; x = e->x_root;
y = e->y_root; y = e->y_root;
@ -414,14 +452,18 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
y -= dock->y; y -= dock->y;
/* which dock app are we on top of? */ /* 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; over = it->data;
if (config_dock_horz) { switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
if (x >= over->x && x < over->x + over->w) if (x >= over->x && x < over->x + over->w)
break; stop = TRUE;
} else { break;
case OB_ORIENTATION_VERT:
if (y >= over->y && y < over->y + over->h) if (y >= over->y && y < over->y + over->h)
break; stop = TRUE;
break;
} }
} }
if (!it || app == over) return; if (!it || app == over) return;
@ -429,10 +471,14 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
x -= over->x; x -= over->x;
y -= over->y; y -= over->y;
if (config_dock_horz) switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
after = (x > over->w / 2); after = (x > over->w / 2);
else break;
case OB_ORIENTATION_VERT:
after = (y > over->h / 2); after = (y > over->h / 2);
break;
}
/* remove before doing the it->next! */ /* remove before doing the it->next! */
dock->dock_apps = g_list_remove(dock->dock_apps, app); dock->dock_apps = g_list_remove(dock->dock_apps, app);