--- gdk/gdkscreen.c.predag 2009-03-22 16:58:18.000000000 +0000 +++ gdk/gdkscreen.c 2009-03-22 17:04:36.000000000 +0000 @@ -29,6 +29,8 @@ #include "gdkintl.h" #include "gdkalias.h" +#include + static void gdk_screen_dispose (GObject *object); static void gdk_screen_finalize (GObject *object); static void gdk_screen_set_property (GObject *object, @@ -221,7 +223,7 @@ for (i = 0; i < num_monitors; i++) { GdkRectangle monitor; - gint dist_x, dist_y; + gint dist_x, dist_y, dist_total; gdk_screen_get_monitor_geometry (screen, i, &monitor); @@ -239,9 +241,28 @@ else dist_y = 0; - if (MIN (dist_x, dist_y) < nearest_dist) + /* Calculate distance from an edge (or corner) */ + if (dist_y > 0) + { + if (dist_x > 0) + { + dist_total = (int)sqrt((double)(dist_x*dist_x + dist_y*dist_y)); + if (dist_total == 0) + dist_total = 1; + } + else + { + dist_total = dist_y; + } + } + else + { + dist_total = dist_x; + } + + if (dist_total < nearest_dist) { - nearest_dist = MIN (dist_x, dist_y); + nearest_dist = dist_total; nearest_monitor = i; } }