summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@gnome.org>2007-04-29 10:08:11 +0000
committerVincent Untz <vuntz@src.gnome.org>2007-04-29 10:08:11 +0000
commitec0efe390e22b1cd34bbc3201f8ab5ebc1de4dc5 (patch)
treea9d2809dfdad179b374088e1203643cb83c11943
parent4b320779bab3228f792d267678078f1416e817b8 (diff)
downloadlibwnck-ec0efe390e22b1cd34bbc3201f8ab5ebc1de4dc5.tar.gz
make sure the width and the height of the rectangle are strictly positive
2007-04-29 Vincent Untz <vuntz@gnome.org> * libwnck/pager.c: (wnck_update_drag_icon): make sure the width and the height of the rectangle are strictly positive (so we don't try to draw in a non-existing rectangle) Fix a crash when dragging really small windows (bug #428280) svn path=/trunk/; revision=1206
-rw-r--r--ChangeLog7
-rw-r--r--libwnck/pager.c12
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 103cb27..8b1d75d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-04-29 Vincent Untz <vuntz@gnome.org>
+
+ * libwnck/pager.c: (wnck_update_drag_icon): make sure the width and
+ the height of the rectangle are strictly positive (so we don't try to
+ draw in a non-existing rectangle)
+ Fix a crash when dragging really small windows (bug #428280)
+
2007-04-15 Elijah Newren <newren gmail com>
Patch from Kim Woelders to fix #403377 (crash on startup).
diff --git a/libwnck/pager.c b/libwnck/pager.c
index 8884c9d..1a63070 100644
--- a/libwnck/pager.c
+++ b/libwnck/pager.c
@@ -1427,6 +1427,8 @@ wnck_update_drag_icon (WnckWindow *window,
if (!gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (widget),
GTK_ICON_SIZE_DND, &dnd_w, &dnd_h))
dnd_w = dnd_h = 32;
+ /* windows are huge, so let's make this huge */
+ dnd_w *= 3;
workspace = wnck_window_get_workspace (window);
if (workspace == NULL)
@@ -1437,11 +1439,13 @@ wnck_update_drag_icon (WnckWindow *window,
wnck_window_get_geometry (window, NULL, NULL, &org_w, &org_h);
rect.x = rect.y = 0;
- /* windows are huge, so let's make this huge */
- dnd_w *= 3;
- rect.width = (dnd_w * org_w) / wnck_workspace_get_width (workspace);
+ rect.width = 0.5 + ((double) (dnd_w * org_w) / (double) wnck_workspace_get_width (workspace));
rect.width = MIN (org_w, rect.width);
- rect.height = (rect.width * org_h) / org_w;
+ rect.height = 0.5 + ((double) (rect.width * org_h) / (double) org_w);
+
+ /* we need at least three pixels to draw the smallest window */
+ rect.width = MAX (rect.width, 3);
+ rect.height = MAX (rect.width, 3);
pixmap = gdk_pixmap_new (GTK_WIDGET (widget)->window,
rect.width, rect.height, -1);