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:
Tomas Frydrych 2008-08-18 15:44:26 +01:00
parent e6e6aecb93
commit 4134949d72

View File

@ -30,7 +30,6 @@
#include <clutter/glx/clutter-glx.h> #include <clutter/glx/clutter-glx.h>
#include <cogl/cogl.h> #include <cogl/cogl.h>
#define SHADOW_RADIUS 10 #define SHADOW_RADIUS 10
#define SHADOW_OPACITY 0.9 #define SHADOW_OPACITY 0.9
#define SHADOW_OFFSET_X (-SHADOW_RADIUS) #define SHADOW_OFFSET_X (-SHADOW_RADIUS)
@ -68,13 +67,20 @@ composite_at_least_version (MetaDisplay *display,
typedef enum _MetaCompWindowType typedef enum _MetaCompWindowType
{ {
META_COMP_WINDOW_NORMAL, /*
META_COMP_WINDOW_DND, * Types shared with MetaWindow
META_COMP_WINDOW_DESKTOP, */
META_COMP_WINDOW_DOCK, META_COMP_WINDOW_NORMAL = META_WINDOW_NORMAL,
META_COMP_WINDOW_MENU, 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_DROP_DOWN_MENU,
META_COMP_WINDOW_TOOLTIP, META_COMP_WINDOW_DND,
} MetaCompWindowType; } MetaCompWindowType;
typedef struct _MetaCompositorClutter typedef struct _MetaCompositorClutter
@ -86,17 +92,6 @@ typedef struct _MetaCompositorClutter
Atom atom_x_root_pixmap; Atom atom_x_root_pixmap;
Atom atom_x_set_root; Atom atom_x_set_root;
Atom atom_net_wm_window_opacity; 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 show_redraw : 1;
guint debug : 1; guint debug : 1;
@ -135,7 +130,6 @@ typedef struct _MetaCompWindow
gboolean shaped; gboolean shaped;
MetaCompWindowType type; MetaCompWindowType type;
Damage damage; Damage damage;
gboolean needs_shadow; gboolean needs_shadow;
@ -197,46 +191,80 @@ static void
get_window_type (MetaDisplay *display, get_window_type (MetaDisplay *display,
MetaCompWindow *cw) MetaCompWindow *cw)
{ {
MetaCompositorClutter *compositor = (MetaCompositorClutter *)display;
int n_atoms; int n_atoms;
Atom *atoms, type_atom; Atom *atoms;
int i; 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; n_atoms = 0;
atoms = NULL; atoms = NULL;
/*
* Assume normal
*/
cw->type = META_COMP_WINDOW_NORMAL;
meta_prop_get_atom_list (display, cw->id, 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); &atoms, &n_atoms);
for (i = 0; i < n_atoms; i++) for (i = 0; i < n_atoms; i++)
{ {
if (atoms[i] == compositor->atom_net_wm_window_type_dnd || if (atoms[i] ==
atoms[i] == compositor->atom_net_wm_window_type_desktop || meta_display_get_atom (display,
atoms[i] == compositor->atom_net_wm_window_type_dock || META_ATOM__NET_WM_WINDOW_TYPE_DND))
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)
{ {
type_atom = atoms[i]; 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))
{
cw->type = META_COMP_WINDOW_NORMAL;
break; break;
} }
} }
meta_XFree (atoms); 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 static gboolean
@ -293,16 +321,21 @@ window_has_shadow (MetaCompWindow *cw)
} }
#endif #endif
if (cw->type == META_COMP_WINDOW_MENU || if (cw->type == META_COMP_WINDOW_MENU
cw->type == META_COMP_WINDOW_DROP_DOWN_MENU) { #if 0
|| cw->type == META_COMP_WINDOW_DROP_DOWN_MENU
#endif
) {
meta_verbose ("Window has shadow as it is a menu\n"); meta_verbose ("Window has shadow as it is a menu\n");
return TRUE; return TRUE;
} }
#if 0
if (cw->type == META_COMP_WINDOW_TOOLTIP) { if (cw->type == META_COMP_WINDOW_TOOLTIP) {
meta_verbose ("Window has shadow as it is a tooltip\n"); meta_verbose ("Window has shadow as it is a tooltip\n");
return TRUE; return TRUE;
} }
#endif
meta_verbose ("Window has no shadow as it fell through\n"); meta_verbose ("Window has no shadow as it fell through\n");
return FALSE; return FALSE;
@ -386,6 +419,7 @@ free_win (MetaCompWindow *cw,
/* The window may not have been added to the list in this case, /* The window may not have been added to the list in this case,
but we can check anyway */ but we can check anyway */
if (cw->type == META_COMP_WINDOW_DOCK) if (cw->type == META_COMP_WINDOW_DOCK)
info->dock_windows = g_slist_remove (info->dock_windows, cw); info->dock_windows = g_slist_remove (info->dock_windows, cw);
@ -633,6 +667,8 @@ add_win (MetaScreen *screen,
if (xwindow == info->output) if (xwindow == info->output)
return; return;
printf ("adding window\n");
cw = g_new0 (MetaCompWindow, 1); cw = g_new0 (MetaCompWindow, 1);
cw->screen = screen; cw->screen = screen;
cw->window = window; cw->window = window;
@ -1108,7 +1144,8 @@ process_property_notify (MetaCompositorClutter *compositor,
return; 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); MetaCompWindow *cw = find_window_in_display (display, event->window);
@ -1476,16 +1513,6 @@ meta_compositor_clutter_new (MetaDisplay *display)
"_XROOTPMAP_ID", "_XROOTPMAP_ID",
"_XSETROOT_ID", "_XSETROOT_ID",
"_NET_WM_WINDOW_OPACITY", "_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)]; Atom atoms[G_N_ELEMENTS(atom_names)];
MetaCompositorClutter *clc; MetaCompositorClutter *clc;
@ -1513,16 +1540,6 @@ meta_compositor_clutter_new (MetaDisplay *display)
clc->atom_x_root_pixmap = atoms[0]; clc->atom_x_root_pixmap = atoms[0];
clc->atom_x_set_root = atoms[1]; clc->atom_x_set_root = atoms[1];
clc->atom_net_wm_window_opacity = atoms[2]; 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; return compositor;
#else #else