summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-02-17 12:11:04 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-02-17 12:11:04 +0800
commit1db97de770f44c3e4a1b3e373d2e639f16288498 (patch)
treec2b8dd363dc8aad44de3bf8dfc519ab12530f9c1
parent71b95f83661d1bee5a4f2588e1d7e41afed4de35 (diff)
downloadcompiz-with-glib-mainloop-1db97de770f44c3e4a1b3e373d2e639f16288498.tar.gz
compiz-with-glib-mainloop-1db97de770f44c3e4a1b3e373d2e639f16288498.tar.bz2
Add frames refcounting system
-rw-r--r--gtk/window-decorator/actionmenu.c2
-rw-r--r--gtk/window-decorator/cairo.c8
-rw-r--r--gtk/window-decorator/decorator.c44
-rw-r--r--gtk/window-decorator/events.c7
-rw-r--r--gtk/window-decorator/gtk-window-decorator.h10
-rw-r--r--gtk/window-decorator/metacity.c11
-rw-r--r--gtk/window-decorator/settings.c9
-rw-r--r--gtk/window-decorator/switcher.c1
-rw-r--r--gtk/window-decorator/wnck.c6
9 files changed, 74 insertions, 24 deletions
diff --git a/gtk/window-decorator/actionmenu.c b/gtk/window-decorator/actionmenu.c
index 97637e6..627b766 100644
--- a/gtk/window-decorator/actionmenu.c
+++ b/gtk/window-decorator/actionmenu.c
@@ -25,6 +25,8 @@ position_action_menu (GtkMenu *menu,
&bx, &by, &width, &height))
*x = *x - frame->win_extents.left + bx;
+ gwd_decor_frame_unref (frame);
+
if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
{
GtkRequisition req;
diff --git a/gtk/window-decorator/cairo.c b/gtk/window-decorator/cairo.c
index 5f29901..8f56d0c 100644
--- a/gtk/window-decorator/cairo.c
+++ b/gtk/window-decorator/cairo.c
@@ -881,10 +881,14 @@ update_border_extents ()
for (i = 0; i < DECOR_FRAME_TYPE_SWITCHER; i++)
{
decor_frame_t *frame = gwd_get_decor_frame (i);
+ decor_frame_t *default_frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT);
- frame->win_extents = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents;
- frame->max_win_extents = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents;
+ frame->win_extents = default_frame->win_extents;
+ frame->max_win_extents = default_frame->win_extents;
frame->titlebar_height = frame->max_titlebar_height =
(frame->text_height < 17) ? 17 : frame->text_height;
+
+ gwd_decor_frame_unref (frame);
+ gwd_decor_frame_unref (default_frame);
}
}
diff --git a/gtk/window-decorator/decorator.c b/gtk/window-decorator/decorator.c
index 2e3ea15..f35c40f 100644
--- a/gtk/window-decorator/decorator.c
+++ b/gtk/window-decorator/decorator.c
@@ -45,6 +45,8 @@ update_titlebar_font ()
frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
+ gwd_decor_frame_unref (frame);
+
pango_font_metrics_unref (metrics);
}
@@ -480,6 +482,9 @@ draw_border_shape (Display *xdisplay,
width - c->left_space - c->right_space,
height - c->top_space - c->bottom_space);
+ if (!info)
+ gwd_decor_frame_unref (d.frame);
+
g_object_unref (G_OBJECT (d.pixmap));
}
@@ -695,6 +700,8 @@ update_shadow (void)
(*frame->update_shadow) (xdisplay, gdk_x11_screen_get_xscreen (screen),
frame, info, &opt_shadow, &opt_no_shadow);
+ gwd_decor_frame_unref (frame);
+
free (info);
info = NULL;
}
@@ -777,7 +784,9 @@ update_default_decorations (GdkScreen *screen)
decor_t d;
gint nQuad;
decor_quad_t quads[N_QUADS_MAX];
- decor_extents_t extents = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents;
+ decor_frame_t *frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT);
+ decor_frame_t *bare_frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE);
+ decor_extents_t extents = frame->win_extents;
xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen));
@@ -785,18 +794,18 @@ update_default_decorations (GdkScreen *screen)
normalAtom = XInternAtom (xdisplay, DECOR_NORMAL_ATOM_NAME, FALSE);
activeAtom = XInternAtom (xdisplay, DECOR_ACTIVE_ATOM_NAME, FALSE);
- if (gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->border_shadow)
+ if (bare_frame->border_shadow)
{
decor_layout_t layout;
- decor_get_default_layout (&gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->window_context, 1, 1, &layout);
+ decor_get_default_layout (&bare_frame->window_context, 1, 1, &layout);
- nQuad = decor_set_lSrStSbS_window_quads (quads, &gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->window_context,
+ nQuad = decor_set_lSrStSbS_window_quads (quads, &bare_frame->window_context,
&layout);
- decor_quads_to_property (data, gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->border_shadow->pixmap,
- &gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->win_extents, &gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->win_extents,
- &gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->win_extents, &gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->win_extents,
+ decor_quads_to_property (data, bare_frame->border_shadow->pixmap,
+ &bare_frame->win_extents, &bare_frame->win_extents,
+ &bare_frame->win_extents, &bare_frame->win_extents,
0, 0, quads, nQuad);
XChangeProperty (xdisplay, xroot,
@@ -831,22 +840,26 @@ update_default_decorations (GdkScreen *screen)
}
if (minimal)
+ {
+ gwd_decor_frame_unref (frame);
+ gwd_decor_frame_unref (bare_frame);
return;
+ }
memset (&d, 0, sizeof (d));
- d.context = &gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->window_context;
- d.shadow = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->border_shadow;
- d.layout = pango_layout_new (gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->pango_context);
+ d.context = &frame->window_context;
+ d.shadow = frame->border_shadow;
+ d.layout = pango_layout_new (frame->pango_context);
decor_get_default_layout (d.context, 1, 1, &d.border_layout);
d.width = d.border_layout.width;
d.height = d.border_layout.height;
- d.frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT);
+ d.frame = frame;
- extents.top += gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->titlebar_height;
+ extents.top += frame->titlebar_height;
d.draw = theme_draw_window_decoration;
@@ -856,7 +869,7 @@ update_default_decorations (GdkScreen *screen)
nQuad = decor_set_lSrStSbS_window_quads (quads, d.context,
&d.border_layout);
- decor_normal_pixmap = create_pixmap (d.width, d.height, gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->style_window_rgba);
+ decor_normal_pixmap = create_pixmap (d.width, d.height, frame->style_window_rgba);
if (decor_normal_pixmap)
{
@@ -884,7 +897,7 @@ update_default_decorations (GdkScreen *screen)
if (decor_active_pixmap)
g_object_unref (G_OBJECT (decor_active_pixmap));
- decor_active_pixmap = create_pixmap (d.width, d.height, gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->style_window_rgba);
+ decor_active_pixmap = create_pixmap (d.width, d.height, frame->style_window_rgba);
if (decor_active_pixmap)
{
@@ -909,6 +922,9 @@ update_default_decorations (GdkScreen *screen)
BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad);
}
+ gwd_decor_frame_unref (frame);
+ gwd_decor_frame_unref (bare_frame);
+
if (d.layout)
g_object_unref (G_OBJECT (d.layout));
}
diff --git a/gtk/window-decorator/events.c b/gtk/window-decorator/events.c
index 1faec8b..8953478 100644
--- a/gtk/window-decorator/events.c
+++ b/gtk/window-decorator/events.c
@@ -1138,7 +1138,14 @@ selection_event_filter_func (GdkXEvent *gdkxevent,
case SelectionClear:
status = decor_handle_selection_clear (xdisplay, xevent, 0);
if (status == DECOR_SELECTION_GIVE_UP)
+ {
+ unsigned int i = 0;
+ for (i = 0; i < NUM_DECOR_FRAMES; i++)
+ {
+ fprintf (stderr, "rcount for %i is %i\n", i, decor_frames[i].refcount);
+ }
exit (0);
+ }
default:
break;
}
diff --git a/gtk/window-decorator/gtk-window-decorator.h b/gtk/window-decorator/gtk-window-decorator.h
index 12a4f2c..45f856d 100644
--- a/gtk/window-decorator/gtk-window-decorator.h
+++ b/gtk/window-decorator/gtk-window-decorator.h
@@ -333,6 +333,8 @@ typedef struct {
event_callback callback;
} event_window;
+#define NUM_DECOR_FRAMES 8
+
typedef enum _decor_frame_type {
DECOR_FRAME_TYPE_NORMAL = 0,
DECOR_FRAME_TYPE_DIALOG = 1,
@@ -381,6 +383,12 @@ typedef void (*frame_update_shadow_proc) (Display *display,
decor_frame_t *
gwd_get_decor_frame (decor_frame_type type);
+decor_frame_t *
+gwd_decor_frame_ref (decor_frame_t *);
+
+decor_frame_t *
+gwd_decor_frame_unref (decor_frame_t *);
+
struct _decor_frame {
decor_extents_t win_extents;
decor_extents_t max_win_extents;
@@ -504,8 +512,6 @@ extern XRenderPictFormat *xformat_rgb;
extern Atom compiz_shadow_info_atom;
extern Atom compiz_shadow_color_atom;
-#define NUM_DECOR_FRAMES 8
-
/* gtk-window-decorator.c */
double
diff --git a/gtk/window-decorator/metacity.c b/gtk/window-decorator/metacity.c
index 02d9bda..42f03ad 100644
--- a/gtk/window-decorator/metacity.c
+++ b/gtk/window-decorator/metacity.c
@@ -1594,8 +1594,7 @@ meta_update_border_extents ()
{
MetaTheme *theme;
MetaFrameType frame_type;
- decor_frame_t *frame;
- decor_frame_type d_frame_type;
+ decor_frame_t *frame, *default_frame;
gint top_height, bottom_height, left_width, right_width;
unsigned int i;
@@ -1605,6 +1604,7 @@ meta_update_border_extents ()
for (i = 0; i < DECOR_FRAME_TYPE_SWITCHER; i++)
{
frame = gwd_get_decor_frame (i);
+ default_frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT);
frame_type = meta_get_frame_type_for_decor_type (i);
meta_theme_get_frame_borders (theme,
@@ -1616,7 +1616,7 @@ meta_update_border_extents ()
&left_width,
&right_width);
- frame->win_extents.top = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents.top;
+ frame->win_extents.top = default_frame->win_extents.top;
frame->win_extents.bottom = bottom_height;
frame->win_extents.left = left_width;
frame->win_extents.right = right_width;
@@ -1632,13 +1632,16 @@ meta_update_border_extents ()
&left_width,
&right_width);
- frame->max_win_extents.top = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents.top;
+ frame->max_win_extents.top = default_frame->win_extents.top;
frame->max_win_extents.bottom = bottom_height;
frame->max_win_extents.left = left_width;
frame->max_win_extents.right = right_width;
frame->max_titlebar_height = top_height - frame->max_win_extents.top;
+ gwd_decor_frame_unref (frame);
+ gwd_decor_frame_unref (default_frame);
+
}
}
diff --git a/gtk/window-decorator/settings.c b/gtk/window-decorator/settings.c
index 206397e..dc9dc07 100644
--- a/gtk/window-decorator/settings.c
+++ b/gtk/window-decorator/settings.c
@@ -312,6 +312,8 @@ titlebar_font_changed (GConfClient *client)
pango_font_description_set_size (frame->titlebar_font,
MAX (pango_font_description_get_size (frame->titlebar_font) * scale, 1));
+
+ gwd_decor_frame_unref (frame);
}
g_free (str);
@@ -447,6 +449,7 @@ gboolean
init_settings (WnckScreen *screen)
{
AtkObject *switcher_label_obj;
+ decor_frame_t *switcher_frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_SWITCHER);
#ifdef USE_GCONF
GConfClient *gconf;
@@ -472,7 +475,7 @@ init_settings (WnckScreen *screen)
switcher_label = gtk_label_new ("");
switcher_label_obj = gtk_widget_get_accessible (switcher_label);
atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR);
- gtk_container_add (GTK_CONTAINER (gwd_get_decor_frame (DECOR_FRAME_TYPE_SWITCHER)->style_window_rgba), switcher_label);
+ gtk_container_add (GTK_CONTAINER (switcher_frame->style_window_rgba), switcher_label);
#ifdef USE_GCONF
use_system_font = gconf_client_get_bool (gconf,
@@ -483,7 +486,7 @@ init_settings (WnckScreen *screen)
button_layout_changed (gconf);
#endif
- update_style (gwd_get_decor_frame (DECOR_FRAME_TYPE_SWITCHER)->style_window_rgba);
+ update_style (switcher_frame->style_window_rgba);
#ifdef USE_GCONF
titlebar_font_changed (gconf);
#endif
@@ -513,5 +516,7 @@ init_settings (WnckScreen *screen)
update_shadow ();
+ gwd_decor_frame_unref (switcher_frame);
+
return TRUE;
}
diff --git a/gtk/window-decorator/switcher.c b/gtk/window-decorator/switcher.c
index 47a4a91..102678d 100644
--- a/gtk/window-decorator/switcher.c
+++ b/gtk/window-decorator/switcher.c
@@ -264,6 +264,7 @@ draw_switcher_decoration (decor_t *d)
void
switcher_window_closed ()
{
+ gwd_decor_frame_unref (switcher_window->frame);
g_free (switcher_window);
switcher_window = NULL;
}
diff --git a/gtk/window-decorator/wnck.c b/gtk/window-decorator/wnck.c
index 4c145ef..321f7fe 100644
--- a/gtk/window-decorator/wnck.c
+++ b/gtk/window-decorator/wnck.c
@@ -469,6 +469,12 @@ remove_frame_window (WnckWindow *win)
d->decor_window = NULL;
}
+ if (d->frame)
+ {
+ gwd_decor_frame_unref (d->frame);
+ d->frame = NULL;
+ }
+
d->width = 0;
d->height = 0;