for (i = 0; i < closure->num_icons; i++) {
gdk_window_move (closure->windows[i],
- closure->model.objects[i + 1].position.x,
- closure->model.objects[i + 1].position.y);
+ closure->model.objects[i + 1].position.x + 0.5,
+ closure->model.objects[i + 1].position.y + 0.5);
}
model_step (&closure->model, 0.1);
const int num_objects = num_items + 1;
const int num_spacers = (num_objects - 1) * (num_objects - 2) / 2;
const int num_springs = num_objects - 1;
- int i, j;
+ const int spread = spacing + 20;
+ int i, j, left_edge;
Object *object;
Spring *spring;
Spacer *spacer;
model->anchors[0].y = y;
model->anchors[0].object = &model->objects[0];
- object_init (&model->objects[0], x, y, 20);
+ object_init (&model->objects[0], x, y, 0);
object = &model->objects[1];
spring = model->springs;
spacer = model->spacers;
+ left_edge = (1024 - (num_items - 1) * spread) / 2;
for (i = 1; i < num_objects; i++, object++) {
- object_init (&model->objects[i], 200 + i * spacing / 2, 300, 3);
+ object_init (&model->objects[i], left_edge + (i - 1) * spread, y - 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);
case MotionNotify:
gdk_window_get_pointer (gdk_get_default_root_window(), &x, &y, &state);
- closure->model.mouse_anchor.x = x + 0.5 - closure->drag_offset_x;
- closure->model.mouse_anchor.y = y + 0.5 - closure->drag_offset_y;
+ 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;
break;
closure.spacing = spacing;
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);
+
for (i = 0; i < num_icons; i++) {
handle = rsvg_handle_new_from_file (icons[i], NULL);
rsvg_handle_get_dimensions (handle, &dimension);
- x = (screen_width - spacing * num_icons) / 2 + i * spacing;
- y = closure.anchor_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);
gdk_window_add_filter (closure.windows[i], window_event, &closure);
}
- model_init_dock (&closure.model, num_icons,
- closure.anchor_x, closure.anchor_y, spacing);
g_timeout_add (20, timeout_callback, &closure);
gtk_main ();