Code cleanup and pretification.

This commit is contained in:
Tomas Frydrych 2008-08-20 09:33:39 +01:00
parent 8589eab403
commit b48f9ca907

View File

@ -43,20 +43,17 @@
#define DESTROY_TIMEOUT 300 #define DESTROY_TIMEOUT 300
#define MINIMIZE_TIMEOUT 600 #define MINIMIZE_TIMEOUT 600
ClutterActor* static ClutterActor* tidy_texture_frame_new (ClutterTexture *texture,
tidy_texture_frame_new (ClutterTexture *texture, gint left,
gint left, gint top,
gint top, gint right,
gint right, gint bottom);
gint bottom);
static unsigned char * static unsigned char* shadow_gaussian_make_tile (void);
shadow_gaussian_make_tile (void);
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
static inline gboolean static inline gboolean
composite_at_least_version (MetaDisplay *display, composite_at_least_version (MetaDisplay *display, int maj, int min)
int maj, int min)
{ {
static int major = -1; static int major = -1;
static int minor = -1; static int minor = -1;
@ -89,34 +86,32 @@ typedef enum _MetaCompWindowType
typedef struct _MetaCompositorClutter typedef struct _MetaCompositorClutter
{ {
MetaCompositor compositor; MetaCompositor compositor;
MetaDisplay *display;
MetaDisplay *display; Atom atom_x_root_pixmap;
Atom atom_x_set_root;
Atom atom_net_wm_window_opacity;
Atom atom_x_root_pixmap; gboolean show_redraw : 1;
Atom atom_x_set_root; gboolean debug : 1;
Atom atom_net_wm_window_opacity;
guint show_redraw : 1;
guint debug : 1;
} MetaCompositorClutter; } MetaCompositorClutter;
typedef struct _MetaCompScreen typedef struct _MetaCompScreen
{ {
MetaScreen *screen; MetaScreen *screen;
ClutterActor *stage; ClutterActor *stage;
GList *windows; GList *windows;
GHashTable *windows_by_xid; GHashTable *windows_by_xid;
MetaWindow *focus_window; MetaWindow *focus_window;
Window output; Window output;
GSList *dock_windows; GSList *dock_windows;
ClutterEffectTemplate *destroy_effect; ClutterEffectTemplate *destroy_effect;
ClutterEffectTemplate *minimize_effect; ClutterEffectTemplate *minimize_effect;
ClutterActor *shadow_src; ClutterActor *shadow_src;
} MetaCompScreen; } MetaCompScreen;
/* /*
@ -135,12 +130,12 @@ typedef struct _MetaCompWindowPrivate MetaCompWindowPrivate;
struct _MetaCompWindowClass struct _MetaCompWindowClass
{ {
ClutterGroupClass parent_class; ClutterGroupClass parent_class;
}; };
struct _MetaCompWindow struct _MetaCompWindow
{ {
ClutterGroup parent; ClutterGroup parent;
MetaCompWindowPrivate *priv; MetaCompWindowPrivate *priv;
}; };
@ -171,9 +166,9 @@ struct _MetaCompWindowPrivate
enum enum
{ {
PROP_META_WINDOW = 1, PROP_MCW_META_WINDOW = 1,
PROP_META_SCREEN, PROP_MCW_META_SCREEN,
PROP_X_WINDOW, PROP_MCW_X_WINDOW,
}; };
static void meta_comp_window_class_init (MetaCompWindowClass *klass); static void meta_comp_window_class_init (MetaCompWindowClass *klass);
@ -199,8 +194,8 @@ G_DEFINE_TYPE (MetaCompWindow, meta_comp_window, CLUTTER_TYPE_GROUP);
static void static void
meta_comp_window_class_init (MetaCompWindowClass *klass) meta_comp_window_class_init (MetaCompWindowClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec; GParamSpec *pspec;
g_type_class_add_private (klass, sizeof (MetaCompWindowPrivate)); g_type_class_add_private (klass, sizeof (MetaCompWindowPrivate));
@ -216,7 +211,7 @@ meta_comp_window_class_init (MetaCompWindowClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT); G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_META_WINDOW, PROP_MCW_META_WINDOW,
pspec); pspec);
pspec = g_param_spec_pointer ("meta-screen", pspec = g_param_spec_pointer ("meta-screen",
@ -225,7 +220,7 @@ meta_comp_window_class_init (MetaCompWindowClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT); G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_META_SCREEN, PROP_MCW_META_SCREEN,
pspec); pspec);
pspec = g_param_spec_ulong ("x-window", pspec = g_param_spec_ulong ("x-window",
@ -237,7 +232,7 @@ meta_comp_window_class_init (MetaCompWindowClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT); G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
PROP_X_WINDOW, PROP_MCW_X_WINDOW,
pspec); pspec);
} }
@ -258,15 +253,15 @@ static gboolean meta_comp_window_has_shadow (MetaCompWindow *self);
static void static void
meta_comp_window_constructed (GObject *object) meta_comp_window_constructed (GObject *object)
{ {
MetaCompWindow *self = META_COMP_WINDOW (object); MetaCompWindow *self = META_COMP_WINDOW (object);
MetaCompWindowPrivate *priv = self->priv; MetaCompWindowPrivate *priv = self->priv;
MetaScreen *screen = priv->screen; MetaScreen *screen = priv->screen;
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
Window xwindow = priv->xwindow; Window xwindow = priv->xwindow;
Display *xdisplay = meta_display_get_xdisplay (display); Display *xdisplay = meta_display_get_xdisplay (display);
gulong event_mask; gulong event_mask;
XRenderPictFormat *format; XRenderPictFormat *format;
MetaCompScreen *info = meta_screen_get_compositor_data (screen); MetaCompScreen *info = meta_screen_get_compositor_data (screen);
if (!XGetWindowAttributes (xdisplay, xwindow, &priv->attrs)) if (!XGetWindowAttributes (xdisplay, xwindow, &priv->attrs))
{ {
@ -277,10 +272,11 @@ meta_comp_window_constructed (GObject *object)
meta_comp_window_get_window_type (self); meta_comp_window_get_window_type (self);
/* If Metacity has decided not to manage this window then the input events /*
won't have been set on the window */ * If Metacity has decided not to manage this window then the input events
* won't have been set on the window
*/
event_mask = priv->attrs.your_event_mask | PropertyChangeMask; event_mask = priv->attrs.your_event_mask | PropertyChangeMask;
XSelectInput (xdisplay, xwindow, event_mask); XSelectInput (xdisplay, xwindow, event_mask);
priv->shaped = is_shaped (display, xwindow); priv->shaped = is_shaped (display, xwindow);
@ -292,11 +288,8 @@ meta_comp_window_constructed (GObject *object)
format = XRenderFindVisualFormat (xdisplay, priv->attrs.visual); format = XRenderFindVisualFormat (xdisplay, priv->attrs.visual);
if (format && format->type == PictTypeDirect && if (format && format->type == PictTypeDirect && format->direct.alphaMask)
format->direct.alphaMask) priv->argb32 = TRUE;
{
priv->argb32 = TRUE;
}
if (meta_comp_window_has_shadow (self)) if (meta_comp_window_has_shadow (self))
{ {
@ -362,29 +355,26 @@ meta_comp_window_dispose (GObject *object)
static void static void
meta_comp_window_finalize (GObject *object) meta_comp_window_finalize (GObject *object)
{ {
#if 0
MetaCompWindowPrivate *priv = META_COMP_WINDOW (object)->priv;
#endif
G_OBJECT_CLASS (meta_comp_window_parent_class)->finalize (object); G_OBJECT_CLASS (meta_comp_window_parent_class)->finalize (object);
} }
static void static void
meta_comp_window_set_property (GObject *object, meta_comp_window_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
MetaCompWindowPrivate *priv = META_COMP_WINDOW (object)->priv; MetaCompWindowPrivate *priv = META_COMP_WINDOW (object)->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_META_WINDOW: case PROP_MCW_META_WINDOW:
priv->window = g_value_get_pointer (value); priv->window = g_value_get_pointer (value);
break; break;
case PROP_META_SCREEN: case PROP_MCW_META_SCREEN:
priv->screen = g_value_get_pointer (value); priv->screen = g_value_get_pointer (value);
break; break;
case PROP_X_WINDOW: case PROP_MCW_X_WINDOW:
priv->xwindow = g_value_get_ulong (value); priv->xwindow = g_value_get_ulong (value);
break; break;
default: default:
@ -395,21 +385,21 @@ meta_comp_window_set_property (GObject *object,
static void static void
meta_comp_window_get_property (GObject *object, meta_comp_window_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
MetaCompWindowPrivate *priv = META_COMP_WINDOW (object)->priv; MetaCompWindowPrivate *priv = META_COMP_WINDOW (object)->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_META_WINDOW: case PROP_MCW_META_WINDOW:
g_value_set_pointer (value, priv->window); g_value_set_pointer (value, priv->window);
break; break;
case PROP_META_SCREEN: case PROP_MCW_META_SCREEN:
g_value_set_pointer (value, priv->screen); g_value_set_pointer (value, priv->screen);
break; break;
case PROP_X_WINDOW: case PROP_MCW_X_WINDOW:
g_value_set_ulong (value, priv->xwindow); g_value_set_ulong (value, priv->xwindow);
break; break;
default: default:
@ -419,8 +409,7 @@ meta_comp_window_get_property (GObject *object,
} }
static MetaCompWindow* static MetaCompWindow*
find_window_for_screen (MetaScreen *screen, find_window_for_screen (MetaScreen *screen, Window xwindow)
Window xwindow)
{ {
MetaCompScreen *info = meta_screen_get_compositor_data (screen); MetaCompScreen *info = meta_screen_get_compositor_data (screen);
@ -431,8 +420,7 @@ find_window_for_screen (MetaScreen *screen,
} }
static MetaCompWindow * static MetaCompWindow *
find_window_in_display (MetaDisplay *display, find_window_in_display (MetaDisplay *display, Window xwindow)
Window xwindow)
{ {
GSList *index; GSList *index;
@ -450,12 +438,10 @@ find_window_in_display (MetaDisplay *display,
} }
static MetaCompWindow * static MetaCompWindow *
find_window_for_child_window_in_display (MetaDisplay *display, find_window_for_child_window_in_display (MetaDisplay *display, Window xwindow)
Window xwindow)
{ {
Window ignored1, *ignored2; Window ignored1, *ignored2, parent;
Window parent; guint ignored_children;
guint ignored_children;
XQueryTree (meta_display_get_xdisplay (display), xwindow, &ignored1, XQueryTree (meta_display_get_xdisplay (display), xwindow, &ignored1,
&parent, &ignored2, &ignored_children); &parent, &ignored2, &ignored_children);
@ -469,23 +455,23 @@ find_window_for_child_window_in_display (MetaDisplay *display,
static void static void
meta_comp_window_get_window_type (MetaCompWindow *self) meta_comp_window_get_window_type (MetaCompWindow *self)
{ {
MetaCompWindowPrivate *priv = self->priv; MetaCompWindowPrivate *priv = self->priv;
MetaScreen *screen = priv->screen; MetaScreen *screen = priv->screen;
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
Window xwindow = priv->xwindow; Window xwindow = priv->xwindow;
gint n_atoms;
int n_atoms; Atom *atoms;
Atom *atoms; gint i;
int i;
/* /*
* If the window is managed by the WM, get the type from the WM, * If the window is managed by the WM, get the type from the WM,
* otherwise do it the hard way. * otherwise do it the hard way.
*/ */
if (priv->window && meta_window_get_type_atom (priv->window) != None) { if (priv->window && meta_window_get_type_atom (priv->window) != None)
priv->type = (MetaCompWindowType) meta_window_get_type (priv->window); {
return; priv->type = (MetaCompWindowType) meta_window_get_type (priv->window);
} return;
}
n_atoms = 0; n_atoms = 0;
atoms = NULL; atoms = NULL;
@ -523,24 +509,24 @@ meta_comp_window_get_window_type (MetaCompWindow *self)
priv->type = META_COMP_WINDOW_DOCK; priv->type = META_COMP_WINDOW_DOCK;
break; break;
} }
else if ( atoms[i] == else if (atoms[i] ==
meta_display_get_atom (display, meta_display_get_atom (display,
META_ATOM__NET_WM_WINDOW_TYPE_TOOLBAR) || META_ATOM__NET_WM_WINDOW_TYPE_TOOLBAR) ||
atoms[i] == atoms[i] ==
meta_display_get_atom (display, meta_display_get_atom (display,
META_ATOM__NET_WM_WINDOW_TYPE_MENU) || META_ATOM__NET_WM_WINDOW_TYPE_MENU) ||
atoms[i] == atoms[i] ==
meta_display_get_atom (display, meta_display_get_atom (display,
META_ATOM__NET_WM_WINDOW_TYPE_DIALOG) || META_ATOM__NET_WM_WINDOW_TYPE_DIALOG) ||
atoms[i] == atoms[i] ==
meta_display_get_atom (display, meta_display_get_atom (display,
META_ATOM__NET_WM_WINDOW_TYPE_NORMAL) || META_ATOM__NET_WM_WINDOW_TYPE_NORMAL) ||
atoms[i] == atoms[i] ==
meta_display_get_atom (display, meta_display_get_atom (display,
META_ATOM__NET_WM_WINDOW_TYPE_UTILITY) || META_ATOM__NET_WM_WINDOW_TYPE_UTILITY) ||
atoms[i] == atoms[i] ==
meta_display_get_atom (display, meta_display_get_atom (display,
META_ATOM__NET_WM_WINDOW_TYPE_SPLASH)) META_ATOM__NET_WM_WINDOW_TYPE_SPLASH))
{ {
priv->type = META_COMP_WINDOW_NORMAL; priv->type = META_COMP_WINDOW_NORMAL;
break; break;
@ -554,9 +540,9 @@ static gboolean
is_shaped (MetaDisplay *display, Window xwindow) is_shaped (MetaDisplay *display, Window xwindow)
{ {
Display *xdisplay = meta_display_get_xdisplay (display); Display *xdisplay = meta_display_get_xdisplay (display);
int xws, yws, xbs, ybs; gint xws, yws, xbs, ybs;
unsigned wws, hws, wbs, hbs; guint wws, hws, wbs, hbs;
int bounding_shaped, clip_shaped; gint bounding_shaped, clip_shaped;
if (meta_display_has_shape (display)) if (meta_display_has_shape (display))
{ {
@ -577,55 +563,70 @@ meta_comp_window_has_shadow (MetaCompWindow *self)
/* /*
* Do not add shadows to ARGB windows (since they are probably transparent * Do not add shadows to ARGB windows (since they are probably transparent
*/ */
if (priv->argb32 || priv->opacity != 0xff) { if (priv->argb32 || priv->opacity != 0xff)
meta_verbose ("Window has no shadow as it is ARGB\n"); {
return FALSE; meta_verbose ("Window has no shadow as it is ARGB\n");
} return FALSE;
}
/*
* Add shadows to override redirect windows (e.g., Gtk menus).
*/
if (priv->attrs.override_redirect) if (priv->attrs.override_redirect)
{ {
meta_verbose ("Window has shadow because it is override redirect.\n"); meta_verbose ("Window has shadow because it is override redirect.\n");
return TRUE; return TRUE;
} }
/* Always put a shadow around windows with a frame - This should override /*
the restriction about not putting a shadow around shaped windows * Always put a shadow around windows with a frame - This should override
as the frame might be the reason the window is shaped */ * the restriction about not putting a shadow around shaped windows
* as the frame might be the reason the window is shaped
*/
if (priv->window) if (priv->window)
{ {
if (meta_window_get_frame (priv->window)) { if (meta_window_get_frame (priv->window))
meta_verbose ("Window has shadow because it has a frame\n"); {
return TRUE; meta_verbose ("Window has shadow because it has a frame\n");
} return TRUE;
}
} }
/* Never put a shadow around shaped windows */ /*
if (priv->shaped) { * Never put a shadow around shaped windows
meta_verbose ("Window has no shadow as it is shaped\n"); */
return FALSE; if (priv->shaped)
} {
meta_verbose ("Window has no shadow as it is shaped\n");
return FALSE;
}
/* Don't put shadow around DND icon windows */ /*
* Don't put shadow around DND icon windows
*/
if (priv->type == META_COMP_WINDOW_DND || if (priv->type == META_COMP_WINDOW_DND ||
priv->type == META_COMP_WINDOW_DESKTOP) { priv->type == META_COMP_WINDOW_DESKTOP)
meta_verbose ("Window has no shadow as it is DND or Desktop\n"); {
return FALSE; meta_verbose ("Window has no shadow as it is DND or Desktop\n");
} return FALSE;
}
if (priv->type == META_COMP_WINDOW_MENU if (priv->type == META_COMP_WINDOW_MENU
#if 0 #if 0
|| priv->type == META_COMP_WINDOW_DROP_DOWN_MENU || priv->type == META_COMP_WINDOW_DROP_DOWN_MENU
#endif #endif
) { )
meta_verbose ("Window has shadow as it is a menu\n"); {
return TRUE; meta_verbose ("Window has shadow as it is a menu\n");
} return TRUE;
}
#if 0 #if 0
if (priv->type == META_COMP_WINDOW_TOOLTIP) { if (priv->type == META_COMP_WINDOW_TOOLTIP)
meta_verbose ("Window has shadow as it is a tooltip\n"); {
return TRUE; meta_verbose ("Window has shadow as it is a tooltip\n");
} return TRUE;
}
#endif #endif
meta_verbose ("Window has no shadow as it fell through\n"); meta_verbose ("Window has no shadow as it fell through\n");
@ -672,17 +673,13 @@ destroy_win (MetaDisplay *display, Window xwindow)
} }
static void static void
restack_win (MetaCompWindow *cw, restack_win (MetaCompWindow *cw, Window above)
Window above)
{ {
MetaCompWindowPrivate *priv = cw->priv; MetaCompWindowPrivate *priv = cw->priv;
MetaScreen *screen; MetaScreen *screen = priv->screen;
MetaCompScreen *info; MetaCompScreen *info = meta_screen_get_compositor_data (screen);
Window previous_above; Window previous_above;
GList *sibling, *next; GList *sibling, *next;
screen = priv->screen;
info = meta_screen_get_compositor_data (screen);
sibling = g_list_find (info->windows, (gconstpointer) cw); sibling = g_list_find (info->windows, (gconstpointer) cw);
next = g_list_next (sibling); next = g_list_next (sibling);
@ -690,7 +687,7 @@ restack_win (MetaCompWindow *cw,
if (next) if (next)
{ {
MetaCompWindow *ncw = (MetaCompWindow *) next->data; MetaCompWindow *ncw = next->data;
previous_above = ncw->priv->xwindow; previous_above = ncw->priv->xwindow;
} }
@ -709,20 +706,21 @@ restack_win (MetaCompWindow *cw,
{ {
GList *index; GList *index;
for (index = info->windows; index; index = index->next) { for (index = info->windows; index; index = index->next)
MetaCompWindow *cw2 = (MetaCompWindow *) index->data; {
if (cw2->priv->xwindow == above) MetaCompWindow *cw2 = (MetaCompWindow *) index->data;
break; if (cw2->priv->xwindow == above)
} break;
}
if (index != NULL) if (index != NULL)
{ {
MetaCompWindow *above_win = (MetaCompWindow *) index->data; ClutterActor *above_win = index->data;
info->windows = g_list_delete_link (info->windows, sibling); info->windows = g_list_delete_link (info->windows, sibling);
info->windows = g_list_insert_before (info->windows, index, cw); info->windows = g_list_insert_before (info->windows, index, cw);
clutter_actor_raise (CLUTTER_ACTOR (cw), CLUTTER_ACTOR (above_win)); clutter_actor_raise (CLUTTER_ACTOR (cw), above_win);
} }
} }
} }
@ -737,9 +735,6 @@ resize_win (MetaCompWindow *cw,
gboolean override_redirect) gboolean override_redirect)
{ {
MetaCompWindowPrivate *priv = cw->priv; MetaCompWindowPrivate *priv = cw->priv;
MetaScreen *screen = priv->screen;
MetaDisplay *display = meta_screen_get_display (screen);
Display *xdisplay = meta_display_get_xdisplay (display);
priv->attrs.x = x; priv->attrs.x = x;
priv->attrs.y = y; priv->attrs.y = y;
@ -749,27 +744,18 @@ resize_win (MetaCompWindow *cw,
/* Note, let named named pixmap resync actually resize actor */ /* Note, let named named pixmap resync actually resize actor */
if (priv->attrs.width != width || priv->attrs.height != height) if (priv->attrs.width != width || priv->attrs.height != height)
{ meta_comp_window_detach (cw);
if (priv->back_pixmap)
{
XFreePixmap (xdisplay, priv->back_pixmap);
priv->back_pixmap = None;
}
}
priv->attrs.width = width; priv->attrs.width = width;
priv->attrs.height = height; priv->attrs.height = height;
priv->attrs.border_width = border_width; priv->attrs.border_width = border_width;
priv->attrs.override_redirect = override_redirect; priv->attrs.override_redirect = override_redirect;
} }
static void static void
map_win (MetaDisplay *display, map_win (MetaDisplay *display, MetaScreen *screen, Window id)
MetaScreen *screen,
Window id)
{ {
MetaCompWindow *cw = find_window_for_screen (screen, id); MetaCompWindow *cw = find_window_for_screen (screen, id);
Display *xdisplay = meta_display_get_xdisplay (display);
MetaCompWindowPrivate *priv; MetaCompWindowPrivate *priv;
if (cw == NULL) if (cw == NULL)
@ -779,12 +765,6 @@ map_win (MetaDisplay *display,
priv->attrs.map_state = IsViewable; priv->attrs.map_state = IsViewable;
if (priv->back_pixmap)
{
XFreePixmap (xdisplay, priv->back_pixmap);
priv->back_pixmap = None;
}
priv->minimize_in_progress = FALSE; priv->minimize_in_progress = FALSE;
clutter_actor_show (CLUTTER_ACTOR (cw)); clutter_actor_show (CLUTTER_ACTOR (cw));
@ -792,12 +772,10 @@ map_win (MetaDisplay *display,
static void static void
unmap_win (MetaDisplay *display, unmap_win (MetaDisplay *display, MetaScreen *screen, Window id)
MetaScreen *screen,
Window id)
{ {
MetaCompWindow *cw = find_window_for_screen (screen, id); MetaCompWindow *cw = find_window_for_screen (screen, id);
MetaCompScreen *info = meta_screen_get_compositor_data (screen); MetaCompScreen *info = meta_screen_get_compositor_data (screen);
MetaCompWindowPrivate *priv; MetaCompWindowPrivate *priv;
if (cw == NULL) if (cw == NULL)
@ -813,20 +791,16 @@ unmap_win (MetaDisplay *display,
meta_comp_window_detach (cw); meta_comp_window_detach (cw);
if (!priv->minimize_in_progress) if (!priv->minimize_in_progress)
{ clutter_actor_hide (CLUTTER_ACTOR (cw));
clutter_actor_hide (CLUTTER_ACTOR (cw));
}
} }
static void static void
add_win (MetaScreen *screen, add_win (MetaScreen *screen, MetaWindow *window, Window xwindow)
MetaWindow *window,
Window xwindow)
{ {
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
MetaCompScreen *info = meta_screen_get_compositor_data (screen); MetaCompScreen *info = meta_screen_get_compositor_data (screen);
MetaCompWindow *cw; MetaCompWindow *cw;
MetaCompWindowPrivate *priv; MetaCompWindowPrivate *priv;
if (info == NULL) if (info == NULL)
@ -859,8 +833,6 @@ add_win (MetaScreen *screen,
} }
#if 0 #if 0
/* Add this to the list at the top of the stack
before it is mapped so that map_win can find it again */
printf ("added 0x%x (%p) type:", (guint)xwindow, cw); printf ("added 0x%x (%p) type:", (guint)xwindow, cw);
switch (cw->type) switch (cw->type)
@ -890,6 +862,10 @@ add_win (MetaScreen *screen,
printf("\n"); printf("\n");
#endif #endif
/*
* Add this to the list at the top of the stack before it is mapped so that
* map_win can find it again
*/
info->windows = g_list_prepend (info->windows, cw); info->windows = g_list_prepend (info->windows, cw);
g_hash_table_insert (info->windows_by_xid, (gpointer) xwindow, cw); g_hash_table_insert (info->windows_by_xid, (gpointer) xwindow, cw);
@ -900,12 +876,12 @@ add_win (MetaScreen *screen,
static void static void
repair_win (MetaCompWindow *cw) repair_win (MetaCompWindow *cw)
{ {
MetaCompWindowPrivate * priv = cw->priv; MetaCompWindowPrivate *priv = cw->priv;
MetaScreen *screen = priv->screen; MetaScreen *screen = priv->screen;
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
Display *xdisplay = meta_display_get_xdisplay (display); Display *xdisplay = meta_display_get_xdisplay (display);
MetaCompScreen *info = meta_screen_get_compositor_data (screen); MetaCompScreen *info = meta_screen_get_compositor_data (screen);
Window xwindow = priv->xwindow; Window xwindow = priv->xwindow;
if (xwindow == meta_screen_get_xroot (screen) || if (xwindow == meta_screen_get_xroot (screen) ||
xwindow == clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage))) xwindow == clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage)))
@ -938,8 +914,6 @@ repair_win (MetaCompWindow *cw)
if (priv->shadow) if (priv->shadow)
clutter_actor_set_size (priv->shadow, pxm_width, pxm_height); clutter_actor_set_size (priv->shadow, pxm_width, pxm_height);
clutter_actor_show (priv->actor);
} }
/* /*
@ -1006,16 +980,16 @@ process_create (MetaCompositorClutter *compositor,
MetaWindow *window) MetaWindow *window)
{ {
MetaScreen *screen; MetaScreen *screen;
/* We are only interested in top level windows, others will
be caught by normal metacity functions */
screen = meta_display_screen_for_root (compositor->display, event->parent); screen = meta_display_screen_for_root (compositor->display, event->parent);
if (screen == NULL) if (screen == NULL)
return; return;
/* This is quite silly as we end up creating windows as then immediatly /*
* This is quite silly as we end up creating windows as then immediatly
* destroying them as they (likely) become framed and thus reparented. * destroying them as they (likely) become framed and thus reparented.
*/ */
if (!find_window_in_display (compositor->display, event->window)) if (!find_window_in_display (compositor->display, event->window))
add_win (screen, window, event->window); add_win (screen, window, event->window);
} }
@ -1028,6 +1002,7 @@ process_reparent (MetaCompositorClutter *compositor,
MetaScreen *screen; MetaScreen *screen;
screen = meta_display_screen_for_root (compositor->display, event->parent); screen = meta_display_screen_for_root (compositor->display, event->parent);
if (screen != NULL) if (screen != NULL)
{ {
meta_verbose ("reparent: adding a new window 0x%x\n", meta_verbose ("reparent: adding a new window 0x%x\n",
@ -1105,9 +1080,7 @@ process_circulate_notify (MetaCompositorClutter *compositor,
event->window); event->window);
MetaCompWindow *top; MetaCompWindow *top;
MetaCompScreen *info; MetaCompScreen *info;
MetaScreen *screen; Window above;
GList *first;
Window above;
MetaCompWindowPrivate *priv; MetaCompWindowPrivate *priv;
if (!cw) if (!cw)
@ -1115,10 +1088,8 @@ process_circulate_notify (MetaCompositorClutter *compositor,
priv = cw->priv; priv = cw->priv;
screen = priv->screen; info = meta_screen_get_compositor_data (priv->screen);
info = meta_screen_get_compositor_data (screen); top = info->windows->data;
first = info->windows;
top = (MetaCompWindow *) first->data;
if ((event->place == PlaceOnTop) && top) if ((event->place == PlaceOnTop) && top)
above = top->priv->xwindow; above = top->priv->xwindow;
@ -1186,7 +1157,7 @@ process_property_notify (MetaCompositorClutter *compositor,
if (event->atom == compositor->atom_net_wm_window_opacity) if (event->atom == compositor->atom_net_wm_window_opacity)
{ {
MetaCompWindow *cw = find_window_in_display (display, event->window); MetaCompWindow *cw = find_window_in_display (display, event->window);
gulong value; gulong value;
if (!cw) if (!cw)
{ {
@ -1214,9 +1185,8 @@ process_property_notify (MetaCompositorClutter *compositor,
return; return;
} }
else if (event->atom == meta_display_get_atom (display,
if (event->atom == meta_display_get_atom (display, META_ATOM__NET_WM_WINDOW_TYPE))
META_ATOM__NET_WM_WINDOW_TYPE))
{ {
MetaCompWindow *cw = find_window_in_display (display, event->window); MetaCompWindow *cw = find_window_in_display (display, event->window);
@ -1224,18 +1194,16 @@ process_property_notify (MetaCompositorClutter *compositor,
return; return;
meta_comp_window_get_window_type (cw); meta_comp_window_get_window_type (cw);
//cw->needs_shadow = window_has_shadow (cw);
return; return;
} }
} }
static void static void
show_overlay_window (MetaScreen *screen, show_overlay_window (MetaScreen *screen, Window cow)
Window cow)
{ {
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
Display *xdisplay = meta_display_get_xdisplay (display); Display *xdisplay = meta_display_get_xdisplay (display);
XserverRegion region; XserverRegion region;
region = XFixesCreateRegion (xdisplay, NULL, 0); region = XFixesCreateRegion (xdisplay, NULL, 0);
@ -1249,8 +1217,8 @@ static Window
get_output_window (MetaScreen *screen) get_output_window (MetaScreen *screen)
{ {
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
Display *xdisplay = meta_display_get_xdisplay (display); Display *xdisplay = meta_display_get_xdisplay (display);
Window output, xroot; Window output, xroot;
xroot = meta_screen_get_xroot (screen); xroot = meta_screen_get_xroot (screen);
@ -1266,23 +1234,23 @@ clutter_cmp_manage_screen (MetaCompositor *compositor,
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
MetaCompScreen *info; MetaCompScreen *info;
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
Display *xdisplay = meta_display_get_xdisplay (display); Display *xdisplay = meta_display_get_xdisplay (display);
int screen_number = meta_screen_get_screen_number (screen); int screen_number = meta_screen_get_screen_number (screen);
Window xroot = meta_screen_get_xroot (screen); Window xroot = meta_screen_get_xroot (screen);
Window xwin; Window xwin;
gint width, height; gint width, height;
guchar *data; guchar *data;
/* Check if the screen is already managed */ /* Check if the screen is already managed */
if (meta_screen_get_compositor_data (screen)) if (meta_screen_get_compositor_data (screen))
return; return;
gdk_error_trap_push (); meta_error_trap_push_with_return (display);
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual); XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
XSync (xdisplay, FALSE); XSync (xdisplay, FALSE);
if (gdk_error_trap_pop ()) if (meta_error_trap_pop_with_return (display, FALSE))
{ {
g_warning ("Another compositing manager is running on screen %i", g_warning ("Another compositing manager is running on screen %i",
screen_number); screen_number);
@ -1366,7 +1334,7 @@ clutter_cmp_add_window (MetaCompositor *compositor,
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
MetaCompositorClutter *xrc = (MetaCompositorClutter *) compositor; MetaCompositorClutter *xrc = (MetaCompositorClutter *) compositor;
MetaScreen *screen = meta_screen_for_x_screen (attrs->screen); MetaScreen *screen = meta_screen_for_x_screen (attrs->screen);
meta_error_trap_push (xrc->display); meta_error_trap_push (xrc->display);
add_win (screen, window, xwindow); add_win (screen, window, xwindow);
@ -1500,13 +1468,10 @@ clutter_cmp_destroy_window (MetaCompositor *compositor,
MetaWindow *window) MetaWindow *window)
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
MetaCompWindow *cw = NULL; MetaCompWindow *cw = NULL;
MetaCompScreen *info; MetaScreen *screen = meta_window_get_screen (window);
MetaScreen *screen; MetaCompScreen *info = meta_screen_get_compositor_data (screen);
MetaFrame *f = meta_window_get_frame (window); MetaFrame *f = meta_window_get_frame (window);
screen = meta_window_get_screen (window);
info = meta_screen_get_compositor_data (screen);
/* Chances are we actually get the window frame here */ /* Chances are we actually get the window frame here */
cw = find_window_for_screen (screen, cw = find_window_for_screen (screen,
@ -1515,12 +1480,10 @@ clutter_cmp_destroy_window (MetaCompositor *compositor,
if (!cw) if (!cw)
return; return;
meta_verbose ("Animating destroy of 0x%x\n", /*
(guint)meta_window_get_xwindow (window)); * We remove the window from internal lookup hashes and thus any other
/* We remove the window from internal lookup hashes and thus any other
* unmap events etc fail * unmap events etc fail
*/ */
info->windows = g_list_remove (info->windows, (gconstpointer) cw); info->windows = g_list_remove (info->windows, (gconstpointer) cw);
g_hash_table_remove (info->windows_by_xid, g_hash_table_remove (info->windows_by_xid,
(gpointer) (f ? meta_frame_get_xwindow (f) : (gpointer) (f ? meta_frame_get_xwindow (f) :
@ -1561,14 +1524,13 @@ on_minimize_effect_complete (ClutterActor *actor,
} }
static void static void
clutter_cmp_minimize_window (MetaCompositor *compositor, clutter_cmp_minimize_window (MetaCompositor *compositor, MetaWindow *window)
MetaWindow *window)
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
MetaCompWindow *cw = NULL; MetaCompWindow *cw;
MetaCompScreen *info; MetaCompScreen *info;
MetaScreen *screen; MetaScreen *screen;
MetaFrame *f = meta_window_get_frame (window); MetaFrame *f = meta_window_get_frame (window);
screen = meta_window_get_screen (window); screen = meta_window_get_screen (window);
info = meta_screen_get_compositor_data (screen); info = meta_screen_get_compositor_data (screen);
@ -1626,10 +1588,10 @@ meta_compositor_clutter_new (MetaDisplay *display)
"_XSETROOT_ID", "_XSETROOT_ID",
"_NET_WM_WINDOW_OPACITY", "_NET_WM_WINDOW_OPACITY",
}; };
Atom atoms[G_N_ELEMENTS(atom_names)]; Atom atoms[G_N_ELEMENTS(atom_names)];
MetaCompositorClutter *clc; MetaCompositorClutter *clc;
MetaCompositor *compositor; MetaCompositor *compositor;
Display *xdisplay = meta_display_get_xdisplay (display); Display *xdisplay = meta_display_get_xdisplay (display);
if (!composite_at_least_version (display, 0, 3)) if (!composite_at_least_version (display, 0, 3))
return NULL; return NULL;
@ -2311,7 +2273,7 @@ tidy_texture_frame_init (TidyTextureFrame *self)
self->priv = priv = TIDY_TEXTURE_FRAME_GET_PRIVATE (self); self->priv = priv = TIDY_TEXTURE_FRAME_GET_PRIVATE (self);
} }
ClutterActor* static ClutterActor*
tidy_texture_frame_new (ClutterTexture *texture, tidy_texture_frame_new (ClutterTexture *texture,
gint left, gint left,
gint top, gint top,