summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2006-06-11 20:53:26 -0400
committerKristian Høgsberg <krh@redhat.com>2006-06-11 20:53:26 -0400
commit0bd80b990015d21fd866cf9c221aa86f855d531a (patch)
tree6ccf66c70c996c47edb09831707db1db25917cce
parent05af0909cc976c183e82d8392107ef11d77bb4ec (diff)
Get rid of 1024x768 screen size assumption.
-rw-r--r--dock.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/dock.c b/dock.c
index c981ae8..f462406 100644
--- a/dock.c
+++ b/dock.c
@@ -20,8 +20,8 @@ struct Closure {
int num_icons;
GdkWindow **windows;
int drag_offset_x, drag_offset_y;
- int anchor_x, anchor_y;
int spacing;
+ int height;
};
static gint
@@ -73,7 +73,8 @@ create_window (GdkScreen *screen, int x, int y, int width, int height)
}
static void
-model_init_dock (Model *model, int num_items, int x, int y, int spacing)
+model_init_dock (Model *model, int num_items,
+ int width, int height, int spacing)
{
const int num_objects = num_items + 1;
const int num_spacers = (num_objects - 1) * (num_objects - 2) / 2;
@@ -97,21 +98,24 @@ model_init_dock (Model *model, int num_items, int x, int y, int spacing)
model->polygons = g_new (Polygon, 1);
model->num_polygons = 1;
- polygon_init_enclosing_rectangle (&model->polygons[0], 0, 0, 1024 - 50, y);
+ polygon_init_enclosing_rectangle (&model->polygons[0],
+ 0, 0, width - 50, height - 50);
- model->anchors[0].x = x;
- model->anchors[0].y = y;
+ model->anchors[0].x = width / 2;
+ model->anchors[0].y = height - 50;
model->anchors[0].object = &model->objects[0];
- object_init (&model->objects[0], x, y, 0);
+ object_init (&model->objects[0],
+ model->anchors[0].x, model->anchors[0].y, 0);
object = &model->objects[1];
spring = model->springs;
spacer = model->spacers;
- left_edge = (1024 - (num_items - 1) * spread) / 2;
+ left_edge = (width - (num_items - 1) * spread) / 2;
for (i = 1; i < num_objects; i++, object++) {
- object_init (&model->objects[i], left_edge + (i - 1) * spread, y - 100, 1);
+ object_init (&model->objects[i],
+ left_edge + (i - 1) * spread, height - 100, 1);
spring_init (spring++, &model->objects[0], object, spacing);
for (j = 1; j < num_objects - i; j++) {
spacer_init (spacer++, object, object + j, spacing);
@@ -150,8 +154,8 @@ window_event (GdkXEvent *xevent, GdkEvent *event, gpointer data)
gdk_window_get_pointer (gdk_get_default_root_window(), &x, &y, &state);
closure->model.mouse_anchor.x = x - closure->drag_offset_x;
closure->model.mouse_anchor.y = y - closure->drag_offset_y;
- if (closure->model.mouse_anchor.y > closure->anchor_y)
- closure->model.mouse_anchor.y = closure->anchor_y;
+ if (closure->model.mouse_anchor.y > closure->height)
+ closure->model.mouse_anchor.y = closure->height;
break;
default:
@@ -181,22 +185,22 @@ int main (int argc, char *argv[])
RsvgHandle *handle;
RsvgDimensionData dimension;
cairo_t *cr;
- const int screen_width = 1024, screen_height = 768, spacing = 50;
+ const int spacing = 50;
gtk_init (&argc, &argv);
rsvg_init ();
screen = gdk_screen_get_default ();
+ width = gdk_screen_get_width (screen);
+ height = gdk_screen_get_height (screen);
- closure.anchor_x = screen_width / 2;
- closure.anchor_y = screen_height - 50;
closure.spacing = spacing;
+ closure.height = height - 50;
closure.num_icons = num_icons;
closure.windows = g_new (GdkWindow *, num_icons);
- model_init_dock (&closure.model, num_icons,
- closure.anchor_x, closure.anchor_y, spacing);
+ model_init_dock (&closure.model, num_icons, width, height, spacing);
for (i = 0; i < num_icons; i++) {
@@ -205,9 +209,8 @@ int main (int argc, char *argv[])
x = closure.model.objects[i + 1].position.x;
y = closure.model.objects[i + 1].position.y;
- width = dimension.width;
- height = dimension.height;
- closure.windows[i] = create_window (screen, x, y, width, height);
+ closure.windows[i] =
+ create_window (screen, x, y, dimension.width, dimension.height);
gdk_window_show (closure.windows[i]);