diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/window.c | 2 | ||||
-rw-r--r-- | src/xprops.c | 26 |
3 files changed, 30 insertions, 7 deletions
@@ -1,5 +1,14 @@ 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 + +2002-08-10 Havoc Pennington <hp@pobox.com> + * src/window.c (meta_window_free): be sure window is mapped if we unmanage it and it's not withdrawn; bug #90369 diff --git a/src/window.c b/src/window.c index 95d7608f..259d8f54 100644 --- a/src/window.c +++ b/src/window.c @@ -4385,7 +4385,7 @@ update_mwm_hints (MetaWindow *window) else meta_verbose ("Functions flag unset\n"); - meta_XFree (hints); + g_free (hints); recalc_window_features (window); } 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; } |