summaryrefslogtreecommitdiff
path: root/src/xprops.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2002-08-10 18:12:36 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-08-10 18:12:36 +0000
commit02bcf068092edf5b0dc3530728ec47a02c086a9a (patch)
tree7671e390679bbad4bb8e6bfb007c5eda64a15b98 /src/xprops.c
parentc540438b913f60696e969b93d1bd9d1a5fef5af0 (diff)
downloadmetacity-02bcf068092edf5b0dc3530728ec47a02c086a9a.tar.gz
allow Motif hints to be smaller than expected; GLUT for example seems to
2002-08-10 Havoc Pennington <hp@pobox.com> * src/xprops.c (meta_prop_get_motif_hints): allow Motif hints to be smaller than expected; GLUT for example seems to set a smaller struct. #89841 * src/window.c (update_mwm_hints): use g_free on motif hints as we don't use the XGetWindowProperty return directly anymore
Diffstat (limited to 'src/xprops.c')
-rw-r--r--src/xprops.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/xprops.c b/src/xprops.c
index 3c54ebd1..7b4ba84a 100644
--- a/src/xprops.c
+++ b/src/xprops.c
@@ -166,14 +166,17 @@ meta_prop_get_motif_hints (MetaDisplay *display,
gulong bytes_after;
MotifWmHints *hints;
gulong n_items;
-
-#define EXPECTED_ITEMS sizeof (MotifWmHints)/sizeof (gulong)
+ int real_size, max_size;
- *hints_p = NULL;
+#define MAX_ITEMS sizeof (MotifWmHints)/sizeof (gulong)
+ *hints_p = NULL;
+
+ hints = NULL;
+ n_items = 0;
meta_error_trap_push (display);
if (XGetWindowProperty (display->xdisplay, xwindow, xatom,
- 0, EXPECTED_ITEMS,
+ 0, MAX_ITEMS,
False, AnyPropertyType, &type, &format, &n_items,
&bytes_after, (guchar **)&hints) != Success ||
type == None)
@@ -185,14 +188,25 @@ meta_prop_get_motif_hints (MetaDisplay *display,
if (meta_error_trap_pop (display) != Success)
return FALSE;
- if (type == None || n_items != EXPECTED_ITEMS)
+ if (type == None || n_items <= 0)
{
meta_verbose ("Motif hints had unexpected type or n_items\n");
XFree (hints);
return FALSE;
}
- *hints_p = hints;
+ g_assert (hints != NULL);
+
+ /* The issue here is that some old crufty code will set a smaller
+ * MotifWmHints than the one we expect, apparently. I'm not sure of
+ * the history behind it. See bug #89841 for example.
+ */
+ *hints_p = g_new0 (MotifWmHints, 1);
+ real_size = n_items * sizeof (gulong);
+ max_size = MAX_ITEMS * sizeof (gulong);
+ memcpy (*hints_p, hints, MIN (real_size, max_size));
+
+ XFree (hints);
return TRUE;
}