window-props: Use the standard property type system for _NET_WM_WINDOW_TYPE

This commit is contained in:
Jasper St. Pierre 2014-07-10 15:00:38 -04:00
parent 031154a400
commit a7b7213017
3 changed files with 36 additions and 76 deletions

View File

@ -231,7 +231,41 @@ reload_net_wm_window_type (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
{
meta_window_x11_update_net_wm_type (window);
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = window_x11->priv;
if (value->type != META_PROP_VALUE_INVALID)
{
int i;
for (i = 0; i < value->v.atom_list.n_atoms; i++)
{
Atom atom = value->v.atom_list.atoms[i];
/* We break as soon as we find one we recognize,
* supposed to prefer those near the front of the list
*/
if (atom == window->display->atom__NET_WM_WINDOW_TYPE_DESKTOP ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_DOCK ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_TOOLBAR ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_MENU ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_UTILITY ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_SPLASH ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_DIALOG ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_DROPDOWN_MENU ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_POPUP_MENU ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_TOOLTIP ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_NOTIFICATION ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_COMBO ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_DND ||
atom == window->display->atom__NET_WM_WINDOW_TYPE_NORMAL)
{
priv->type_atom = atom;
meta_window_x11_recalc_window_type (window);
return;
}
}
}
}
static void
@ -1701,7 +1735,7 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
{ display->atom_WM_CLIENT_LEADER, META_PROP_VALUE_INVALID, complain_about_broken_client, FALSE, FALSE },
{ display->atom_SM_CLIENT_ID, META_PROP_VALUE_INVALID, complain_about_broken_client, FALSE, FALSE },
{ display->atom_WM_WINDOW_ROLE, META_PROP_VALUE_STRING, reload_wm_window_role, TRUE, FALSE },
{ display->atom__NET_WM_WINDOW_TYPE, META_PROP_VALUE_INVALID, reload_net_wm_window_type, TRUE, TRUE },
{ display->atom__NET_WM_WINDOW_TYPE, META_PROP_VALUE_ATOM_LIST, reload_net_wm_window_type, TRUE, TRUE },
{ display->atom__NET_WM_STRUT, META_PROP_VALUE_INVALID, reload_struts, FALSE, FALSE },
{ display->atom__NET_WM_STRUT_PARTIAL, META_PROP_VALUE_INVALID, reload_struts, FALSE, FALSE },
{ display->atom__NET_WM_BYPASS_COMPOSITOR, META_PROP_VALUE_CARDINAL, reload_bypass_compositor, FALSE, FALSE },

View File

@ -518,8 +518,6 @@ meta_window_x11_manage (MetaWindow *window)
if (!window->override_redirect)
update_sm_hints (window); /* must come after transient_for */
meta_window_x11_update_net_wm_type (window);
if (window->decorated)
meta_window_ensure_frame (window);
@ -1587,77 +1585,6 @@ meta_window_x11_set_net_wm_state (MetaWindow *window)
}
}
void
meta_window_x11_update_net_wm_type (MetaWindow *window)
{
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
int n_atoms;
Atom *atoms;
int i;
priv->type_atom = None;
n_atoms = 0;
atoms = NULL;
meta_prop_get_atom_list (window->display, window->xwindow,
window->display->atom__NET_WM_WINDOW_TYPE,
&atoms, &n_atoms);
i = 0;
while (i < n_atoms)
{
/* We break as soon as we find one we recognize,
* supposed to prefer those near the front of the list
*/
if (atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_DESKTOP ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_DOCK ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_TOOLBAR ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_MENU ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_UTILITY ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_SPLASH ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_DIALOG ||
atoms[i] ==
window->display->atom__NET_WM_WINDOW_TYPE_DROPDOWN_MENU ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_POPUP_MENU ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_TOOLTIP ||
atoms[i] ==
window->display->atom__NET_WM_WINDOW_TYPE_NOTIFICATION ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_COMBO ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_DND ||
atoms[i] == window->display->atom__NET_WM_WINDOW_TYPE_NORMAL)
{
priv->type_atom = atoms[i];
break;
}
++i;
}
meta_XFree (atoms);
if (meta_is_verbose ())
{
char *str;
str = NULL;
if (priv->type_atom != None)
{
meta_error_trap_push (window->display);
str = XGetAtomName (window->display->xdisplay, priv->type_atom);
meta_error_trap_pop (window->display);
}
meta_verbose ("Window %s type atom %s\n", window->desc,
str ? str : "(none)");
if (str)
meta_XFree (str);
}
meta_window_x11_recalc_window_type (window);
}
static void
meta_window_set_opaque_region (MetaWindow *window,
cairo_region_t *region)

View File

@ -55,7 +55,6 @@ void meta_window_x11_destroy_sync_request_alarm (MetaWindow *window);
void meta_window_x11_update_sync_request_counter (MetaWindow *window,
gint64 new_counter_value);
void meta_window_x11_update_net_wm_type (MetaWindow *window);
void meta_window_x11_update_opaque_region (MetaWindow *window);
void meta_window_x11_update_input_region (MetaWindow *window);
void meta_window_x11_update_shape_region (MetaWindow *window);