/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
dock.c for the Openbox window manager
- Copyright (c) 2003 Ben Jansens
+ Copyright (c) 2006 Mikael Magnusson
+ Copyright (c) 2003-2007 Dana Jansens
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
GList *it;
XSetWindowBorder(ob_display, dock->frame,
- RrColorPixel(ob_rr_theme->b_color));
- XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->bwidth);
+ RrColorPixel(ob_rr_theme->osd_border_color));
+ XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->obwidth);
RrAppearanceFree(dock->a_frame);
- dock->a_frame = RrAppearanceCopy(ob_rr_theme->a_unfocused_title);
+ dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
stacking_add(DOCK_AS_WINDOW(dock));
RrVisual(ob_rr_inst),
CWOverrideRedirect | CWEventMask,
&attrib);
- dock->a_frame = RrAppearanceCopy(ob_rr_theme->a_unfocused_title);
+ dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
XSetWindowBorder(ob_display, dock->frame,
- RrColorPixel(ob_rr_theme->b_color));
- XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->bwidth);
+ RrColorPixel(ob_rr_theme->osd_border_color));
+ XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->obwidth);
+
+ /* Setting the window type so xcompmgr can tell what it is */
+ PROP_SET32(dock->frame, net_wm_window_type, atom,
+ prop_atoms.net_wm_window_type_dock);
g_hash_table_insert(window_map, &dock->frame, dock);
stacking_add(DOCK_AS_WINDOW(dock));
void dock_configure()
{
GList *it;
- gint spot;
+ gint hspot, vspot;
gint gravity;
- gint minw, minh;
+ gint l, r, t, b;
gint strw, strh;
Rect *a;
- RrMinsize(dock->a_frame, &minw, &minh);
+ RrMargins(dock->a_frame, &l, &t, &r, &b);
dock->w = dock->h = 0;
}
}
- spot = (config_dock_orient == OB_ORIENTATION_HORZ ? minw : minh) / 2;
+ dock->w += l + r;
+ dock->h += t + b;
+
+ hspot = l;
+ vspot = t;
/* position the apps */
for (it = dock->dock_apps; it; it = g_list_next(it)) {
ObDockApp *app = it->data;
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
- app->x = spot;
+ app->x = hspot;
app->y = (dock->h - app->h) / 2;
- spot += app->w;
+ hspot += app->w;
break;
case OB_ORIENTATION_VERT:
app->x = (dock->w - app->w) / 2;
- app->y = spot;
- spot += app->h;
+ app->y = vspot;
+ vspot += app->h;
break;
}
}
/* used for calculating offsets */
- dock->w += ob_rr_theme->bwidth * 2;
- dock->h += ob_rr_theme->bwidth * 2;
+ dock->w += ob_rr_theme->obwidth * 2;
+ dock->h += ob_rr_theme->obwidth * 2;
- a = screen_physical_area();
+ a = screen_physical_area_all_monitors();
/* calculate position */
if (config_dock_floating) {
dock->y = a->height;
gravity = SouthEastGravity;
break;
+ default:
+ g_assert_not_reached();
}
}
case OB_DIRECTION_NORTHWEST:
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
- dock->y -= dock->h - ob_rr_theme->bwidth;
+ dock->y -= dock->h - ob_rr_theme->obwidth;
break;
case OB_ORIENTATION_VERT:
- dock->x -= dock->w - ob_rr_theme->bwidth;
+ dock->x -= dock->w - ob_rr_theme->obwidth;
break;
}
break;
case OB_DIRECTION_NORTH:
- dock->y -= dock->h - ob_rr_theme->bwidth;
+ dock->y -= dock->h - ob_rr_theme->obwidth;
break;
case OB_DIRECTION_NORTHEAST:
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
- dock->y -= dock->h - ob_rr_theme->bwidth;
+ dock->y -= dock->h - ob_rr_theme->obwidth;
break;
case OB_ORIENTATION_VERT:
- dock->x += dock->w - ob_rr_theme->bwidth;
+ dock->x += dock->w - ob_rr_theme->obwidth;
break;
}
break;
case OB_DIRECTION_WEST:
- dock->x -= dock->w - ob_rr_theme->bwidth;
+ dock->x -= dock->w - ob_rr_theme->obwidth;
break;
case OB_DIRECTION_EAST:
- dock->x += dock->w - ob_rr_theme->bwidth;
+ dock->x += dock->w - ob_rr_theme->obwidth;
break;
case OB_DIRECTION_SOUTHWEST:
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
- dock->y += dock->h - ob_rr_theme->bwidth;
+ dock->y += dock->h - ob_rr_theme->obwidth;
break;
case OB_ORIENTATION_VERT:
- dock->x -= dock->w - ob_rr_theme->bwidth;
+ dock->x -= dock->w - ob_rr_theme->obwidth;
break;
} break;
case OB_DIRECTION_SOUTH:
- dock->y += dock->h - ob_rr_theme->bwidth;
+ dock->y += dock->h - ob_rr_theme->obwidth;
break;
case OB_DIRECTION_SOUTHEAST:
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
- dock->y += dock->h - ob_rr_theme->bwidth;
+ dock->y += dock->h - ob_rr_theme->obwidth;
break;
case OB_ORIENTATION_VERT:
- dock->x += dock->w - ob_rr_theme->bwidth;
+ dock->x += dock->w - ob_rr_theme->obwidth;
break;
}
break;
}
if (!config_dock_floating && config_dock_hide) {
- strw = ob_rr_theme->bwidth;
- strh = ob_rr_theme->bwidth;
+ strw = ob_rr_theme->obwidth;
+ strh = ob_rr_theme->obwidth;
} else {
strw = dock->w;
strh = dock->h;
if (!dock->dock_apps) {
STRUT_PARTIAL_SET(dock_strut, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0);
- } else if (config_dock_floating) {
+ } else if (config_dock_floating || config_dock_nostrut)
+ {
STRUT_PARTIAL_SET(dock_strut, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0);
} else {
break;
case OB_DIRECTION_NORTH:
STRUT_PARTIAL_SET(dock_strut, 0, strh, 0, 0,
- dock->x, dock->x + dock->w - 1,
- 0, 0, 0, 0, 0, 0);
+ 0, 0, dock->x, dock->x + dock->w - 1,
+ 0, 0, 0, 0);
break;
case OB_DIRECTION_NORTHEAST:
switch (config_dock_orient) {
}
}
- dock->w += minw;
- dock->h += minh;
-
/* not used for actually sizing shit */
- dock->w -= ob_rr_theme->bwidth * 2;
- dock->h -= ob_rr_theme->bwidth * 2;
+ dock->w -= ob_rr_theme->obwidth * 2;
+ dock->h -= ob_rr_theme->obwidth * 2;
if (dock->dock_apps) {
g_assert(dock->w > 0);
XUnmapWindow(ob_display, dock->frame);
/* but they are useful outside of this function! */
- dock->w += ob_rr_theme->bwidth * 2;
- dock->h += ob_rr_theme->bwidth * 2;
+ dock->w += ob_rr_theme->obwidth * 2;
+ dock->h += ob_rr_theme->obwidth * 2;
screen_update_areas();
+
+ g_free(a);
}
void dock_app_configure(ObDockApp *app, gint w, gint h)
case OB_ORIENTATION_VERT:
after = (y > over->h / 2);
break;
+ default:
+ g_assert_not_reached();
}
/* remove before doing the it->next! */
return FALSE; /* don't repeat */
}
+static gboolean show_timeout(gpointer data)
+{
+ /* hide */
+ dock->hidden = FALSE;
+ dock_configure();
+
+ return FALSE; /* don't repeat */
+}
+
void dock_hide(gboolean hide)
{
if (!hide) {
- /* show */
- dock->hidden = FALSE;
- dock_configure();
-
- /* if was hiding, stop it */
- ob_main_loop_timeout_remove(ob_main_loop, hide_timeout);
- } else if (!dock->hidden && config_dock_hide) {
- ob_main_loop_timeout_add(ob_main_loop, config_dock_hide_delay,
- hide_timeout, NULL, NULL);
+ if (dock->hidden && config_dock_hide) {
+ ob_main_loop_timeout_add(ob_main_loop, config_dock_show_delay,
+ show_timeout, NULL, g_direct_equal, NULL);
+ } else if (!dock->hidden && config_dock_hide) {
+ ob_main_loop_timeout_remove(ob_main_loop, hide_timeout);
+ }
+ } else {
+ if (!dock->hidden && config_dock_hide) {
+ ob_main_loop_timeout_add(ob_main_loop, config_dock_hide_delay,
+ hide_timeout, NULL, g_direct_equal, NULL);
+ } else if (dock->hidden && config_dock_hide) {
+ ob_main_loop_timeout_remove(ob_main_loop, show_timeout);
+ }
}
}
+
+void dock_get_area(Rect *a)
+{
+ RECT_SET(*a, dock->x, dock->y, dock->w, dock->h);
+}