xprops: More Xlib / long cleanliness with Motif WM hints

Fixes some CSD windows sometimes getting frames when they totes
shouldn't.
This commit is contained in:
Jasper St. Pierre 2015-06-24 14:34:48 -07:00
parent 2cbaa6660c
commit 6dbec6f81b
3 changed files with 11 additions and 33 deletions

View File

@ -862,7 +862,7 @@ reload_mwm_hints (MetaWindow *window,
if (hints->flags & MWM_HINTS_DECORATIONS) if (hints->flags & MWM_HINTS_DECORATIONS)
{ {
meta_verbose ("Window %s sets MWM_HINTS_DECORATIONS 0x%lx\n", meta_verbose ("Window %s sets MWM_HINTS_DECORATIONS 0x%x\n",
window->desc, hints->decorations); window->desc, hints->decorations);
if (hints->decorations == 0) if (hints->decorations == 0)
@ -878,7 +878,7 @@ reload_mwm_hints (MetaWindow *window,
{ {
gboolean toggle_value; gboolean toggle_value;
meta_verbose ("Window %s sets MWM_HINTS_FUNCTIONS 0x%lx\n", meta_verbose ("Window %s sets MWM_HINTS_FUNCTIONS 0x%x\n",
window->desc, hints->functions); window->desc, hints->functions);
/* If _ALL is specified, then other flags indicate what to turn off; /* If _ALL is specified, then other flags indicate what to turn off;

View File

@ -292,19 +292,11 @@ static gboolean
motif_hints_from_results (GetPropertyResults *results, motif_hints_from_results (GetPropertyResults *results,
MotifWmHints **hints_p) MotifWmHints **hints_p)
{ {
int real_size, max_size;
#define MAX_ITEMS sizeof (MotifWmHints)/sizeof (gulong)
*hints_p = NULL; *hints_p = NULL;
if (results->type == None || results->n_items <= 0) if (results->type == None || results->n_items <= 0)
{ {
meta_verbose ("Motif hints had unexpected type or n_items\n"); meta_verbose ("Motif hints had unexpected type or n_items\n");
if (results->prop)
{
g_free (results->prop);
results->prop = NULL;
}
return FALSE; return FALSE;
} }
@ -312,26 +304,12 @@ motif_hints_from_results (GetPropertyResults *results,
* MotifWmHints than the one we expect, apparently. I'm not sure of * MotifWmHints than the one we expect, apparently. I'm not sure of
* the history behind it. See bug #89841 for example. * the history behind it. See bug #89841 for example.
*/ */
*hints_p = malloc (sizeof (MotifWmHints)); *hints_p = calloc (1, sizeof (MotifWmHints));
if (*hints_p == NULL) if (*hints_p == NULL)
{ return FALSE;
if (results->prop)
{
g_free (results->prop);
results->prop = NULL;
}
return FALSE;
}
real_size = results->n_items * sizeof (gulong);
max_size = MAX_ITEMS * sizeof (gulong);
memcpy (*hints_p, results->prop, MIN (real_size, max_size));
if (results->prop)
{
g_free (results->prop);
results->prop = NULL;
}
memcpy(*hints_p, results->prop, MIN (sizeof (MotifWmHints),
results->n_items * sizeof (uint32_t)));
return TRUE; return TRUE;
} }

View File

@ -33,11 +33,11 @@
* found in some Motif reference guides online. * found in some Motif reference guides online.
*/ */
typedef struct { typedef struct {
unsigned long flags; uint32_t flags;
unsigned long functions; uint32_t functions;
unsigned long decorations; uint32_t decorations;
long input_mode; uint32_t input_mode;
unsigned long status; uint32_t status;
} MotifWmHints, MwmHints; } MotifWmHints, MwmHints;
#define MWM_HINTS_FUNCTIONS (1L << 0) #define MWM_HINTS_FUNCTIONS (1L << 0)