summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2006-07-09 02:26:33 -0400
committerKristian Høgsberg <krh@redhat.com>2006-07-09 02:26:33 -0400
commitb8958ea8248d4067830b0770bd7d39b33d6aad5d (patch)
tree15c80bec499c78223b9985b437e14e981f6a0aa1
parent17ddf22b324b38125d2ae51a86f7e5b4aa3b1eef (diff)
Only use geometry for first screen.
-rw-r--r--dock.c85
1 files changed, 25 insertions, 60 deletions
diff --git a/dock.c b/dock.c
index 5676f63..c7336c6 100644
--- a/dock.c
+++ b/dock.c
@@ -65,6 +65,7 @@ struct _KibaDock
Anchor *anchor;
Anchor *mouse_anchor;
+ GdkRectangle geometry;
int spacing;
int num_launchers;
GList *launchers;
@@ -126,10 +127,6 @@ static void kiba_dock_drag_data_received (GtkWidget *widget,
guint info,
guint time);
-static void kiba_dock_init_model (KibaDock *dock,
- int width,
- int height);
-
static KibaLauncher *kiba_launcher_new (KibaDock *dock,
const char *gconf_path);
static void kiba_launcher_create_window (KibaLauncher *launcher);
@@ -183,7 +180,7 @@ static void
kiba_dock_init (KibaDock *dock)
{
GdkScreen *screen;
- int width, height;
+ Object *object;
static const GtkTargetEntry targets[] = {
{ "text/plain", 0, 0 }
};
@@ -194,13 +191,21 @@ kiba_dock_init (KibaDock *dock)
GTK_PRIVATE_SET_FLAG (GTK_WIDGET (dock), GTK_ANCHORED);
screen = gdk_screen_get_default ();
- width = gdk_screen_get_width (screen);
- height = gdk_screen_get_height (screen);
+ gdk_screen_get_monitor_geometry(screen, 0, &dock->geometry);
dock->position = KIBA_DOCK_POSITION_BOTTOM_EDGE_CENTER;
dock->spacing = ICON_SIZE;
- kiba_dock_init_model (dock, width, height);
+ model_init (&dock->model);
+ dock->model.constrain_iterations = 1;
+
+ model_add_enclosing_rectangle (&dock->model, ICON_SIZE / 2, ICON_SIZE / 2,
+ dock->geometry.width - ICON_SIZE / 2,
+ dock->geometry.height - ICON_SIZE / 2);
+
+ object = model_add_object (&dock->model, 0, 0, 0, NULL);
+ dock->anchor = model_add_anchor (&dock->model, object, 0, 0 );
+ dock->mouse_anchor = model_add_anchor (&dock->model, NULL, 0, 0);
gtk_drag_dest_set (GTK_WIDGET (dock),
GTK_DEST_DEFAULT_ALL,
@@ -364,14 +369,8 @@ kiba_dock_layout (KibaDock *dock)
{
const KibaDockLayoutData *d;
GtkAllocation allocation;
- GdkScreen *screen;
- int width, height;
const int cap_size = 20;
- screen = gdk_screen_get_default ();
- width = gdk_screen_get_width (screen);
- height = gdk_screen_get_height (screen);
-
d = &kiba_dock_layout_data[dock->position];
if (d->orientation == GTK_ORIENTATION_VERTICAL)
@@ -387,8 +386,10 @@ kiba_dock_layout (KibaDock *dock)
allocation.height = 2 * ICON_SIZE / 3;
}
- allocation.x = d->halignment * (width - allocation.width) / 2;
- allocation.y = d->valignment * (height - allocation.height) / 2;
+ allocation.x =
+ d->halignment * (dock->geometry.width - allocation.width) / 2;
+ allocation.y =
+ d->valignment * (dock->geometry.height - allocation.height) / 2;
dock->anchor->x = allocation.x + allocation.width / 2;
dock->anchor->y = allocation.y + allocation.height / 2;
@@ -502,26 +503,6 @@ kiba_dock_add_launcher (KibaDock *dock, KibaLauncher *launcher, int x, int y)
kiba_dock_layout (dock);
}
-static void
-kiba_dock_init_model (KibaDock *dock, int width, int height)
-{
- Object *object;
-
- model_init (&dock->model);
-
- dock->model.elasticity = 0.9;
- dock->model.friction = 150;
- dock->model.k = 0.8;
- dock->model.constrain_iterations = 1;
-
- model_add_enclosing_rectangle (&dock->model, ICON_SIZE / 2, ICON_SIZE / 2,
- width - ICON_SIZE / 2, height - ICON_SIZE / 2);
-
- object = model_add_object (&dock->model, 0, 0, 0, NULL);
- dock->anchor = model_add_anchor (&dock->model, object, 0, 0 );
- dock->mouse_anchor = model_add_anchor (&dock->model, NULL, 0, 0);
-}
-
static gboolean
kiba_dock_button_press_event (GtkWidget *widget,
GdkEventButton *event)
@@ -602,12 +583,6 @@ kiba_dock_motion_notify_event (GtkWidget *widget,
KibaDock *dock = KIBA_DOCK (widget);
GdkModifierType state;
int x, y, new_x, new_y, dx, dy;
- GdkScreen *screen;
- int width, height;
-
- screen = gdk_screen_get_default ();
- width = gdk_screen_get_width (screen);
- height = gdk_screen_get_height (screen);
gdk_window_get_pointer (gdk_get_default_root_window(), &x, &y, &state);
new_x = x - dock->drag_offset_x + ICON_SIZE / 2;
@@ -615,8 +590,10 @@ kiba_dock_motion_notify_event (GtkWidget *widget,
dx = new_x - dock->mouse_anchor->x;
dy = new_y - dock->mouse_anchor->y;
- dock->mouse_anchor->x = CLAMP (new_x, ICON_SIZE / 2, width - ICON_SIZE /2 );
- dock->mouse_anchor->y = CLAMP (new_y, ICON_SIZE / 2, height - ICON_SIZE / 2);
+ dock->mouse_anchor->x =
+ CLAMP (new_x, ICON_SIZE / 2, dock->geometry.width - ICON_SIZE /2 );
+ dock->mouse_anchor->y =
+ CLAMP (new_y, ICON_SIZE / 2, dock->geometry.height - ICON_SIZE / 2);
dock->drag_distance += sqrt (dx * dx + dy * dy);
return TRUE;
@@ -913,12 +890,6 @@ launchers_changed_callback(GConfClient *client,
KibaDock *dock;
KibaLauncher *launcher;
char *path, *last_slash;
- GdkScreen *screen;
- int width, height;
-
- screen = gdk_screen_get_default ();
- width = gdk_screen_get_width (screen);
- height = gdk_screen_get_height (screen);
dock = KIBA_DOCK (user_data);
@@ -939,8 +910,8 @@ launchers_changed_callback(GConfClient *client,
return;
kiba_dock_add_launcher (dock, launcher,
- g_random_int_range (0, width),
- g_random_int_range (0, height));
+ g_random_int_range (0, dock->geometry.width),
+ g_random_int_range (0, dock->geometry.height));
}
static void
@@ -948,12 +919,6 @@ init_from_gconf (KibaDock *dock, GConfClient *gconf_client, GError **error)
{
GSList *launchers, *options, *l;
KibaLauncher *launcher;
- GdkScreen *screen;
- int width, height;
-
- screen = gdk_screen_get_default ();
- width = gdk_screen_get_width (screen);
- height = gdk_screen_get_height (screen);
launchers = gconf_client_all_dirs (gconf_client,
KIBA_GCONF_PATH "/launchers",
@@ -969,8 +934,8 @@ init_from_gconf (KibaDock *dock, GConfClient *gconf_client, GError **error)
continue;
kiba_dock_add_launcher (dock, launcher,
- g_random_int_range (0, width),
- g_random_int_range (0, height));
+ g_random_int_range (0, dock->geometry.width),
+ g_random_int_range (0, dock->geometry.height));
}
options = gconf_client_all_entries (gconf_client,