diff options
author | Sam Spilsbury <sam.spilsbury@canonical.com> | 2011-02-18 17:26:27 +0800 |
---|---|---|
committer | Sam Spilsbury <sam.spilsbury@canonical.com> | 2011-02-18 17:26:27 +0800 |
commit | 6e84b89fbcd93997dd6e80cdc9b318c3c8e07059 (patch) | |
tree | 17d603bc117d155445dba6a0cebf45a0299b45b6 /gtk/window-decorator/switcher.c | |
parent | cdcec665a4fc7e340282bd1d8eaeac8e76b2ef43 (diff) | |
download | compiz-with-glib-mainloop-6e84b89fbcd93997dd6e80cdc9b318c3c8e07059.tar.gz compiz-with-glib-mainloop-6e84b89fbcd93997dd6e80cdc9b318c3c8e07059.tar.bz2 |
Add memory management to frames
We don't need to keep all the frame definitions around in memory all the
time, so refcount them and only add them if we actually need them.
Diffstat (limited to 'gtk/window-decorator/switcher.c')
-rw-r--r-- | gtk/window-decorator/switcher.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/gtk/window-decorator/switcher.c b/gtk/window-decorator/switcher.c index 102678d..1c4254e 100644 --- a/gtk/window-decorator/switcher.c +++ b/gtk/window-decorator/switcher.c @@ -1,5 +1,40 @@ #include "gtk-window-decorator.h" +decor_frame_t * +create_switcher_frame (const gchar *type) +{ + decor_frame_t *frame = decor_frame_new (type); + decor_extents_t _switcher_extents = { 6, 6, 6, 6 + SWITCHER_SPACE }; + + decor_context_t _switcher_context = { + { 0, 0, 0, 0 }, + 6, 6, 6, 6 + SWITCHER_SPACE, + 0, 0, 0, 0 + }; + + frame->win_extents = _switcher_extents; + frame->max_win_extents = _switcher_extents; + frame->win_extents = _switcher_extents; + frame->window_context = _switcher_context; + frame->window_context_no_shadow = _switcher_context; + frame->max_window_context = _switcher_context; + frame->max_window_context_no_shadow = _switcher_context; + frame->update_shadow = switcher_frame_update_shadow; + + /* keep the switcher frame around since we need to keep its + * contents */ + + gwd_decor_frame_ref (frame); + + return frame; +} + +void +destroy_switcher_frame (decor_frame_t *frame) +{ + decor_frame_destroy (frame); +} + static void draw_switcher_background (decor_t *d) { @@ -308,7 +343,7 @@ update_switcher_window (Window popup, d->decorated = FALSE; d->draw = draw_switcher_decoration; - d->frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_SWITCHER); + d->frame = gwd_get_decor_frame ("switcher"); decor_get_default_layout (&d->frame->window_context, width, 1, &d->border_layout); |