]> git.cworth.org Git - akamaru/commitdiff
Get rid of 1024x768 screen size assumption.
authorKristian Høgsberg <krh@redhat.com>
Mon, 12 Jun 2006 00:53:26 +0000 (20:53 -0400)
committerKristian Høgsberg <krh@redhat.com>
Mon, 12 Jun 2006 00:53:26 +0000 (20:53 -0400)
dock.c

diff --git a/dock.c b/dock.c
index c981ae8a87ad8d871ee0d4124c1fc581c7466dfe..f46240686a3f77be586f5923d4a5251f3e6b4a93 100644 (file)
--- 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 num_icons;
   GdkWindow **windows;
   int drag_offset_x, drag_offset_y;
-  int anchor_x, anchor_y;
   int spacing;
   int spacing;
+  int height;
 };
 
 static gint
 };
 
 static gint
@@ -73,7 +73,8 @@ create_window (GdkScreen *screen, int x, int y, int width, int height)
 }
 
 static void
 }
 
 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;
 {
   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;
 
   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];
 
   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;
 
   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++) {
 
   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);
     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;
     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:
     break;
 
   default:
@@ -181,22 +185,22 @@ int main (int argc, char *argv[])
     RsvgHandle *handle;
     RsvgDimensionData dimension;
     cairo_t *cr;
     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 ();
 
     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.spacing = spacing;
+    closure.height = height - 50;
     closure.num_icons = num_icons;
     closure.windows = g_new (GdkWindow *, num_icons);
 
     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++) {
 
 
     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;
 
       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]);
 
 
       gdk_window_show (closure.windows[i]);