summaryrefslogtreecommitdiff
path: root/src/nautilus-desktop-canvas-view.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-10-04 16:16:25 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-10-04 16:18:03 -0400
commit1292610b87be44fcd5a7d5a09738cd7f3287325f (patch)
treeed8facd734bf7d6f52050a281d4ed6cd92fd5d3e /src/nautilus-desktop-canvas-view.c
parentce80131177c0535cac03446213a50002a9d1d63a (diff)
downloadnautilus-1292610b87be44fcd5a7d5a09738cd7f3287325f.tar.gz
desktop-canvas: set margins according to the primary workarea
This ensures desktop icons are pinned to the primary monitor, instead of moving around when plugging in a new display. There's also a slight change in behavior introduced by this patch - that is for multihead configurations where the first monitor in visible order is not the primary one, it won't be possible to move desktop icons to monitors to the left, or to the top, of the primary monitor - in other words, desktop icons layout starts from the primary monitor and expands rightwards/downwards. https://bugzilla.gnome.org/show_bug.cgi?id=420624
Diffstat (limited to 'src/nautilus-desktop-canvas-view.c')
-rw-r--r--src/nautilus-desktop-canvas-view.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index e0c9ca587..71620559e 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -102,27 +102,27 @@ canvas_container_set_workarea (NautilusCanvasContainer *canvas_container,
int n_items)
{
int left, right, top, bottom;
- int screen_width, screen_height;
int i;
+ GdkRectangle geometry;
left = right = top = bottom = 0;
-
- screen_width = gdk_screen_get_width (screen);
- screen_height = gdk_screen_get_height (screen);
+ gdk_screen_get_monitor_geometry (screen, gdk_screen_get_primary_monitor (screen), &geometry);
for (i = 0; i < n_items; i += 4) {
- int x = workareas [i];
- int y = workareas [i + 1];
- int width = workareas [i + 2];
- int height = workareas [i + 3];
+ GdkRectangle workarea;
+
+ workarea.x = workareas[i];
+ workarea.y = workareas[i + 1];
+ workarea.width = workareas[i + 2];
+ workarea.height = workareas[i + 3];
- if ((x + width) > screen_width || (y + height) > screen_height)
+ if (!gdk_rectangle_intersect (&geometry, &workarea, &workarea))
continue;
- left = MAX (left, x);
- right = MAX (right, screen_width - width - x);
- top = MAX (top, y);
- bottom = MAX (bottom, screen_height - height - y);
+ left = MAX (left, workarea.x);
+ right = MAX (right, (geometry.x + geometry.width) - (workarea.x + workarea.width));
+ top = MAX (top, workarea.y);
+ bottom = MAX (bottom, (geometry.y + geometry.height) - (workarea.y + workarea.height));
}
nautilus_canvas_container_set_margins (canvas_container,