get_window_type:
Streamlined to use the MetaWindow type where that is available; for unmanaged windows, query window props as before.
This commit is contained in:
parent
e6e6aecb93
commit
4134949d72
@ -30,7 +30,6 @@
|
||||
#include <clutter/glx/clutter-glx.h>
|
||||
|
||||
#include <cogl/cogl.h>
|
||||
|
||||
#define SHADOW_RADIUS 10
|
||||
#define SHADOW_OPACITY 0.9
|
||||
#define SHADOW_OFFSET_X (-SHADOW_RADIUS)
|
||||
@ -68,13 +67,20 @@ composite_at_least_version (MetaDisplay *display,
|
||||
|
||||
typedef enum _MetaCompWindowType
|
||||
{
|
||||
META_COMP_WINDOW_NORMAL,
|
||||
META_COMP_WINDOW_DND,
|
||||
META_COMP_WINDOW_DESKTOP,
|
||||
META_COMP_WINDOW_DOCK,
|
||||
META_COMP_WINDOW_MENU,
|
||||
/*
|
||||
* Types shared with MetaWindow
|
||||
*/
|
||||
META_COMP_WINDOW_NORMAL = META_WINDOW_NORMAL,
|
||||
META_COMP_WINDOW_DESKTOP = META_WINDOW_DESKTOP,
|
||||
META_COMP_WINDOW_DOCK = META_WINDOW_DOCK,
|
||||
META_COMP_WINDOW_MENU = META_WINDOW_MENU,
|
||||
|
||||
/*
|
||||
* Extended types that WM does not care about, but we do.
|
||||
*/
|
||||
META_COMP_WINDOW_TOOLTIP = 0xf000,
|
||||
META_COMP_WINDOW_DROP_DOWN_MENU,
|
||||
META_COMP_WINDOW_TOOLTIP,
|
||||
META_COMP_WINDOW_DND,
|
||||
} MetaCompWindowType;
|
||||
|
||||
typedef struct _MetaCompositorClutter
|
||||
@ -86,17 +92,6 @@ typedef struct _MetaCompositorClutter
|
||||
Atom atom_x_root_pixmap;
|
||||
Atom atom_x_set_root;
|
||||
Atom atom_net_wm_window_opacity;
|
||||
Atom atom_net_wm_window_type_dnd;
|
||||
|
||||
Atom atom_net_wm_window_type;
|
||||
Atom atom_net_wm_window_type_desktop;
|
||||
Atom atom_net_wm_window_type_dock;
|
||||
Atom atom_net_wm_window_type_menu;
|
||||
Atom atom_net_wm_window_type_dialog;
|
||||
Atom atom_net_wm_window_type_normal;
|
||||
Atom atom_net_wm_window_type_utility;
|
||||
Atom atom_net_wm_window_type_splash;
|
||||
Atom atom_net_wm_window_type_toolbar;
|
||||
|
||||
guint show_redraw : 1;
|
||||
guint debug : 1;
|
||||
@ -135,12 +130,11 @@ typedef struct _MetaCompWindow
|
||||
gboolean shaped;
|
||||
|
||||
MetaCompWindowType type;
|
||||
Damage damage;
|
||||
|
||||
Damage damage;
|
||||
gboolean needs_shadow;
|
||||
|
||||
gboolean needs_shadow;
|
||||
|
||||
XserverRegion extents;
|
||||
XserverRegion extents;
|
||||
|
||||
} MetaCompWindow;
|
||||
|
||||
@ -197,46 +191,80 @@ static void
|
||||
get_window_type (MetaDisplay *display,
|
||||
MetaCompWindow *cw)
|
||||
{
|
||||
MetaCompositorClutter *compositor = (MetaCompositorClutter *)display;
|
||||
int n_atoms;
|
||||
Atom *atoms, type_atom;
|
||||
Atom *atoms;
|
||||
int i;
|
||||
|
||||
type_atom = None;
|
||||
/*
|
||||
* If the window is managed by the WM, get the type from the WM,
|
||||
* otherwise do it the hard way.
|
||||
*/
|
||||
if (cw->window && meta_window_get_type_atom (cw->window) != None) {
|
||||
cw->type = (MetaCompWindowType) meta_window_get_type (cw->window);
|
||||
return;
|
||||
}
|
||||
|
||||
n_atoms = 0;
|
||||
atoms = NULL;
|
||||
|
||||
/*
|
||||
* Assume normal
|
||||
*/
|
||||
cw->type = META_COMP_WINDOW_NORMAL;
|
||||
|
||||
meta_prop_get_atom_list (display, cw->id,
|
||||
compositor->atom_net_wm_window_type,
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE),
|
||||
&atoms, &n_atoms);
|
||||
|
||||
for (i = 0; i < n_atoms; i++)
|
||||
{
|
||||
if (atoms[i] == compositor->atom_net_wm_window_type_dnd ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_desktop ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_dock ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_toolbar ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_menu ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_dialog ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_normal ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_utility ||
|
||||
atoms[i] == compositor->atom_net_wm_window_type_splash)
|
||||
if (atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_DND))
|
||||
{
|
||||
cw->type = META_COMP_WINDOW_DND;
|
||||
break;
|
||||
}
|
||||
else if (atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_DESKTOP))
|
||||
{
|
||||
cw->type = META_COMP_WINDOW_DESKTOP;
|
||||
break;
|
||||
}
|
||||
else if (atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_DOCK))
|
||||
{
|
||||
cw->type = META_COMP_WINDOW_DOCK;
|
||||
break;
|
||||
}
|
||||
else if ( atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_TOOLBAR) ||
|
||||
atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_MENU) ||
|
||||
atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_DIALOG) ||
|
||||
atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_NORMAL) ||
|
||||
atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_UTILITY) ||
|
||||
atoms[i] ==
|
||||
meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE_SPLASH))
|
||||
{
|
||||
type_atom = atoms[i];
|
||||
break;
|
||||
cw->type = META_COMP_WINDOW_NORMAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
meta_XFree (atoms);
|
||||
|
||||
if (type_atom == compositor->atom_net_wm_window_type_dnd)
|
||||
cw->type = META_COMP_WINDOW_DND;
|
||||
else if (type_atom == compositor->atom_net_wm_window_type_desktop)
|
||||
cw->type = META_COMP_WINDOW_DESKTOP;
|
||||
else if (type_atom == compositor->atom_net_wm_window_type_dock)
|
||||
cw->type = META_COMP_WINDOW_DOCK;
|
||||
else
|
||||
cw->type = META_COMP_WINDOW_NORMAL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -293,16 +321,21 @@ window_has_shadow (MetaCompWindow *cw)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cw->type == META_COMP_WINDOW_MENU ||
|
||||
cw->type == META_COMP_WINDOW_DROP_DOWN_MENU) {
|
||||
if (cw->type == META_COMP_WINDOW_MENU
|
||||
#if 0
|
||||
|| cw->type == META_COMP_WINDOW_DROP_DOWN_MENU
|
||||
#endif
|
||||
) {
|
||||
meta_verbose ("Window has shadow as it is a menu\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (cw->type == META_COMP_WINDOW_TOOLTIP) {
|
||||
meta_verbose ("Window has shadow as it is a tooltip\n");
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
meta_verbose ("Window has no shadow as it fell through\n");
|
||||
return FALSE;
|
||||
@ -386,6 +419,7 @@ free_win (MetaCompWindow *cw,
|
||||
|
||||
/* The window may not have been added to the list in this case,
|
||||
but we can check anyway */
|
||||
|
||||
if (cw->type == META_COMP_WINDOW_DOCK)
|
||||
info->dock_windows = g_slist_remove (info->dock_windows, cw);
|
||||
|
||||
@ -633,6 +667,8 @@ add_win (MetaScreen *screen,
|
||||
if (xwindow == info->output)
|
||||
return;
|
||||
|
||||
printf ("adding window\n");
|
||||
|
||||
cw = g_new0 (MetaCompWindow, 1);
|
||||
cw->screen = screen;
|
||||
cw->window = window;
|
||||
@ -1108,7 +1144,8 @@ process_property_notify (MetaCompositorClutter *compositor,
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->atom == compositor->atom_net_wm_window_type)
|
||||
if (event->atom == meta_display_get_atom (display,
|
||||
META_ATOM__NET_WM_WINDOW_TYPE))
|
||||
{
|
||||
MetaCompWindow *cw = find_window_in_display (display, event->window);
|
||||
|
||||
@ -1476,16 +1513,6 @@ meta_compositor_clutter_new (MetaDisplay *display)
|
||||
"_XROOTPMAP_ID",
|
||||
"_XSETROOT_ID",
|
||||
"_NET_WM_WINDOW_OPACITY",
|
||||
"_NET_WM_WINDOW_TYPE_DND",
|
||||
"_NET_WM_WINDOW_TYPE",
|
||||
"_NET_WM_WINDOW_TYPE_DESKTOP",
|
||||
"_NET_WM_WINDOW_TYPE_DOCK",
|
||||
"_NET_WM_WINDOW_TYPE_MENU",
|
||||
"_NET_WM_WINDOW_TYPE_DIALOG",
|
||||
"_NET_WM_WINDOW_TYPE_NORMAL",
|
||||
"_NET_WM_WINDOW_TYPE_UTILITY",
|
||||
"_NET_WM_WINDOW_TYPE_SPLASH",
|
||||
"_NET_WM_WINDOW_TYPE_TOOLBAR"
|
||||
};
|
||||
Atom atoms[G_N_ELEMENTS(atom_names)];
|
||||
MetaCompositorClutter *clc;
|
||||
@ -1513,16 +1540,6 @@ meta_compositor_clutter_new (MetaDisplay *display)
|
||||
clc->atom_x_root_pixmap = atoms[0];
|
||||
clc->atom_x_set_root = atoms[1];
|
||||
clc->atom_net_wm_window_opacity = atoms[2];
|
||||
clc->atom_net_wm_window_type_dnd = atoms[3];
|
||||
clc->atom_net_wm_window_type = atoms[4];
|
||||
clc->atom_net_wm_window_type_desktop = atoms[5];
|
||||
clc->atom_net_wm_window_type_dock = atoms[6];
|
||||
clc->atom_net_wm_window_type_menu = atoms[7];
|
||||
clc->atom_net_wm_window_type_dialog = atoms[8];
|
||||
clc->atom_net_wm_window_type_normal = atoms[9];
|
||||
clc->atom_net_wm_window_type_utility = atoms[10];
|
||||
clc->atom_net_wm_window_type_splash = atoms[11];
|
||||
clc->atom_net_wm_window_type_toolbar = atoms[12];
|
||||
|
||||
return compositor;
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user