summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-02-17 01:39:56 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-02-17 01:39:56 +0800
commit5603a1b3a35559a1208a8818ed97cdf2473839bd (patch)
tree2ae9426f9b5b853e1b4c22ae9ac5c3650f7ddd7f
parentaf4e7bc36f27b8908a150dd497752e85a8281b20 (diff)
downloadcompiz-with-glib-mainloop-5603a1b3a35559a1208a8818ed97cdf2473839bd.tar.gz
compiz-with-glib-mainloop-5603a1b3a35559a1208a8818ed97cdf2473839bd.tar.bz2
Added simple frames management system.
Right now this just keeps the frames in a private area and returns a pre-allocated frame, but it will be expanded to allow reference counting on frames and allocation on-demand
-rw-r--r--gtk/window-decorator/CMakeLists.txt1
-rw-r--r--gtk/window-decorator/actionmenu.c2
-rw-r--r--gtk/window-decorator/cairo.c8
-rw-r--r--gtk/window-decorator/decorator.c34
-rw-r--r--gtk/window-decorator/decorprops.c26
-rw-r--r--gtk/window-decorator/gtk-window-decorator.c4
-rw-r--r--gtk/window-decorator/gtk-window-decorator.h6
-rw-r--r--gtk/window-decorator/metacity.c32
-rw-r--r--gtk/window-decorator/settings.c6
-rw-r--r--gtk/window-decorator/switcher.c2
-rw-r--r--gtk/window-decorator/wnck.c2
11 files changed, 61 insertions, 62 deletions
diff --git a/gtk/window-decorator/CMakeLists.txt b/gtk/window-decorator/CMakeLists.txt
index 9cd5c96..3cb61a6 100644
--- a/gtk/window-decorator/CMakeLists.txt
+++ b/gtk/window-decorator/CMakeLists.txt
@@ -37,6 +37,7 @@ if (USE_GTK)
blurprops.c
decorprops.c
cairo.c
+ frames.c
gdk.c
switcher.c
metacity.c
diff --git a/gtk/window-decorator/actionmenu.c b/gtk/window-decorator/actionmenu.c
index 9d651d9..97637e6 100644
--- a/gtk/window-decorator/actionmenu.c
+++ b/gtk/window-decorator/actionmenu.c
@@ -15,7 +15,7 @@ position_action_menu (GtkMenu *menu,
{
WnckWindow *win = (WnckWindow *) user_data;
WnckWindowType win_type = wnck_window_get_window_type (win);
- decor_frame_t *frame = &decor_frames[get_frame_type (win_type)];
+ decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win_type));
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
gint bx, by, width, height;
diff --git a/gtk/window-decorator/cairo.c b/gtk/window-decorator/cairo.c
index 5bfcae9..fe9b857 100644
--- a/gtk/window-decorator/cairo.c
+++ b/gtk/window-decorator/cairo.c
@@ -830,7 +830,7 @@ get_event_window_position (decor_t *d,
gint *h)
{
WnckWindowType win_type = wnck_window_get_window_type (d->win);
- decor_frame_t *frame = &decor_frames[get_frame_type (win_type)];
+ decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win_type));
if (d->frame_window)
{
@@ -883,10 +883,10 @@ update_border_extents ()
for (i = 0; i < DECOR_FRAME_TYPE_SWITCHER; i++)
{
- decor_frame_t *frame = &decor_frames[i];
+ decor_frame_t *frame = gwd_get_decor_frame (i);
- frame->win_extents = decor_frames[DECOR_FRAME_TYPE_DEFAULT].win_extents;
- frame->max_win_extents = decor_frames[DECOR_FRAME_TYPE_DEFAULT].win_extents;
+ 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->titlebar_height = frame->max_titlebar_height =
(frame->text_height < 17) ? 17 : frame->text_height;
}
diff --git a/gtk/window-decorator/decorator.c b/gtk/window-decorator/decorator.c
index 9c3070f..2e3ea15 100644
--- a/gtk/window-decorator/decorator.c
+++ b/gtk/window-decorator/decorator.c
@@ -27,7 +27,7 @@ update_titlebar_font ()
for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
- decor_frame_t *frame = &decor_frames[i];
+ decor_frame_t *frame = gwd_get_decor_frame (i);
font_desc = get_titlebar_font (frame);
if (!font_desc)
{
@@ -444,7 +444,7 @@ draw_border_shape (Display *xdisplay,
if (info)
d.frame = info->frame;
else
- d.frame = &decor_frames[DECOR_FRAME_TYPE_DEFAULT];
+ d.frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT);
d.pixmap = gdk_pixmap_foreign_new_for_display (gdk_display_get_default (),
pixmap);
@@ -683,7 +683,7 @@ update_shadow (void)
for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
- decor_frame_t *frame = &decor_frames[i];
+ decor_frame_t *frame = gwd_get_decor_frame (i);
decor_shadow_info_t *info = malloc (sizeof (decor_shadow_info_t));
if (!info)
@@ -777,7 +777,7 @@ update_default_decorations (GdkScreen *screen)
decor_t d;
gint nQuad;
decor_quad_t quads[N_QUADS_MAX];
- decor_extents_t extents = decor_frames[DECOR_FRAME_TYPE_DEFAULT].win_extents;
+ decor_extents_t extents = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents;
xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen));
@@ -785,18 +785,18 @@ update_default_decorations (GdkScreen *screen)
normalAtom = XInternAtom (xdisplay, DECOR_NORMAL_ATOM_NAME, FALSE);
activeAtom = XInternAtom (xdisplay, DECOR_ACTIVE_ATOM_NAME, FALSE);
- if (decor_frames[DECOR_FRAME_TYPE_BARE].border_shadow)
+ if (gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->border_shadow)
{
decor_layout_t layout;
- decor_get_default_layout (&decor_frames[DECOR_FRAME_TYPE_BARE].window_context, 1, 1, &layout);
+ decor_get_default_layout (&gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->window_context, 1, 1, &layout);
- nQuad = decor_set_lSrStSbS_window_quads (quads, &decor_frames[DECOR_FRAME_TYPE_BARE].window_context,
+ nQuad = decor_set_lSrStSbS_window_quads (quads, &gwd_get_decor_frame (DECOR_FRAME_TYPE_BARE)->window_context,
&layout);
- decor_quads_to_property (data, decor_frames[DECOR_FRAME_TYPE_BARE].border_shadow->pixmap,
- &decor_frames[DECOR_FRAME_TYPE_BARE].win_extents, &decor_frames[DECOR_FRAME_TYPE_BARE].win_extents,
- &decor_frames[DECOR_FRAME_TYPE_BARE].win_extents, &decor_frames[DECOR_FRAME_TYPE_BARE].win_extents,
+ 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,
0, 0, quads, nQuad);
XChangeProperty (xdisplay, xroot,
@@ -835,18 +835,18 @@ update_default_decorations (GdkScreen *screen)
memset (&d, 0, sizeof (d));
- d.context = &decor_frames[DECOR_FRAME_TYPE_DEFAULT].window_context;
- d.shadow = decor_frames[DECOR_FRAME_TYPE_DEFAULT].border_shadow;
- d.layout = pango_layout_new (decor_frames[DECOR_FRAME_TYPE_DEFAULT].pango_context);
+ 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);
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 = &decor_frames[DECOR_FRAME_TYPE_DEFAULT];
+ d.frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT);
- extents.top += decor_frames[DECOR_FRAME_TYPE_DEFAULT].titlebar_height;
+ extents.top += gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->titlebar_height;
d.draw = theme_draw_window_decoration;
@@ -856,7 +856,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, decor_frames[DECOR_FRAME_TYPE_DEFAULT].style_window_rgba);
+ decor_normal_pixmap = create_pixmap (d.width, d.height, gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->style_window_rgba);
if (decor_normal_pixmap)
{
@@ -884,7 +884,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, decor_frames[DECOR_FRAME_TYPE_DEFAULT].style_window_rgba);
+ decor_active_pixmap = create_pixmap (d.width, d.height, gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->style_window_rgba);
if (decor_active_pixmap)
{
diff --git a/gtk/window-decorator/decorprops.c b/gtk/window-decorator/decorprops.c
index aed5380..5787d66 100644
--- a/gtk/window-decorator/decorprops.c
+++ b/gtk/window-decorator/decorprops.c
@@ -7,7 +7,7 @@ decor_update_window_property (decor_t *d)
Display *xdisplay =
GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
WnckWindowType win_type = wnck_window_get_window_type (d->win);
- decor_frame_t frame = decor_frames[get_frame_type (win_type)];
+ decor_extents_t extents = gwd_get_decor_frame (get_frame_type (win_type))->win_extents;
gint nQuad;
decor_quad_t quads[N_QUADS_MAX];
int w, h;
@@ -28,17 +28,17 @@ decor_update_window_property (decor_t *d)
&d->border_layout,
stretch_offset);
- frame.win_extents.top += frame.titlebar_height;
+ extents.top += gwd_get_decor_frame (get_frame_type (win_type))->titlebar_height;
if (d->frame_window)
{
- decor_gen_window_property (data, &frame.win_extents, &frame.win_extents, 20, 20);
+ decor_gen_window_property (data, &extents, &extents, 20, 20);
}
else
{
decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap),
- &frame.win_extents, &frame.win_extents,
- &frame.win_extents, &frame.win_extents,
+ &extents, &extents,
+ &extents, &extents,
ICON_SPACE + d->button_width,
0,
quads, nQuad);
@@ -56,23 +56,23 @@ decor_update_window_property (decor_t *d)
top.rects = &top.extents;
top.numRects = top.size = 1;
- top.extents.x1 = -frame.win_extents.left;
- top.extents.y1 = -frame.win_extents.top;
- top.extents.x2 = w + frame.win_extents.right;
+ top.extents.x1 = -extents.left;
+ top.extents.y1 = -extents.top;
+ top.extents.x2 = w + extents.right;
top.extents.y2 = 0;
bottom.rects = &bottom.extents;
bottom.numRects = bottom.size = 1;
- bottom.extents.x1 = -frame.win_extents.left;
+ bottom.extents.x1 = -extents.left;
bottom.extents.y1 = 0;
- bottom.extents.x2 = w + frame.win_extents.right;
- bottom.extents.y2 = frame.win_extents.bottom;
+ bottom.extents.x2 = w + extents.right;
+ bottom.extents.y2 = extents.bottom;
left.rects = &left.extents;
left.numRects = left.size = 1;
- left.extents.x1 = -frame.win_extents.left;
+ left.extents.x1 = -extents.left;
left.extents.y1 = 0;
left.extents.x2 = 0;
left.extents.y2 = h;
@@ -82,7 +82,7 @@ decor_update_window_property (decor_t *d)
right.extents.x1 = 0;
right.extents.y1 = 0;
- right.extents.x2 = frame.win_extents.right;
+ right.extents.x2 = extents.right;
right.extents.y2 = h;
decor_update_blur_property (d,
diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c
index e39253c..ba6b579 100644
--- a/gtk/window-decorator/gtk-window-decorator.c
+++ b/gtk/window-decorator/gtk-window-decorator.c
@@ -183,10 +183,6 @@ initialize_decorations ()
decor_frames[i].max_window_context = _switcher_context;
decor_frames[i].max_window_context_no_shadow = _switcher_context;
decor_frames[i].update_shadow = switcher_frame_update_shadow;
-
- decor_context_t *c = &decor_frames[i].window_context;
-
- fprintf (stderr, "init decor get default layout, context is space %i %i %i %i c space %i %i %i %i extents %i %i %i %i\n", c->left_space, c->right_space, c->top_space, c->bottom_space, c->left_corner_space, c->right_corner_space, c->top_corner_space, c->bottom_corner_space, c->extents.left, c->extents.right, c->extents.bottom, c->extents.top);
}
else if (i == DECOR_FRAME_TYPE_BARE)
{
diff --git a/gtk/window-decorator/gtk-window-decorator.h b/gtk/window-decorator/gtk-window-decorator.h
index 0c23c38..c7bd040 100644
--- a/gtk/window-decorator/gtk-window-decorator.h
+++ b/gtk/window-decorator/gtk-window-decorator.h
@@ -378,6 +378,9 @@ typedef void (*frame_update_shadow_proc) (Display *display,
decor_shadow_options_t *opt_shadow,
decor_shadow_options_t *opt_no_shadow);
+decor_frame_t *
+gwd_get_decor_frame (decor_frame_type type);
+
struct _decor_frame {
decor_extents_t win_extents;
decor_extents_t max_win_extents;
@@ -399,6 +402,7 @@ struct _decor_frame {
decor_frame_type type;
frame_update_shadow_proc update_shadow;
+ gint refcount;
};
typedef struct _decor {
@@ -502,8 +506,6 @@ extern Atom compiz_shadow_color_atom;
#define NUM_DECOR_FRAMES 8
-extern decor_frame_t decor_frames[NUM_DECOR_FRAMES];
-
/* gtk-window-decorator.c */
double
diff --git a/gtk/window-decorator/metacity.c b/gtk/window-decorator/metacity.c
index c50754d..e8e64b7 100644
--- a/gtk/window-decorator/metacity.c
+++ b/gtk/window-decorator/metacity.c
@@ -24,7 +24,7 @@ decor_update_meta_window_property (decor_t *d,
GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
gint nQuad;
WnckWindowType win_type = wnck_window_get_window_type (d->win);
- decor_frame_t *frame = &decor_frames[get_frame_type (win_type)];
+ decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win_type));
decor_extents_t win_extents = frame->win_extents;
decor_extents_t max_win_extents = frame->max_win_extents;
decor_quad_t quads[N_QUADS_MAX];
@@ -1083,7 +1083,7 @@ meta_get_button_position (decor_t *d,
if (d->frame_window)
{
- decor_frame_t *frame = &decor_frames[d_frame_type];
+ decor_frame_t *frame = gwd_get_decor_frame (d_frame_type);
*x += frame->win_extents.left + 4;
*y += frame->win_extents.top + 2;
}
@@ -1123,7 +1123,7 @@ meta_calc_decoration_size (decor_t *d,
WnckWindowType win_type;
win_type = wnck_window_get_window_type (d->win);
- frame = &decor_frames[get_frame_type (win_type)];
+ frame = gwd_get_decor_frame (get_frame_type (win_type));
if ((d->state & META_MAXIMIZED) == META_MAXIMIZED)
{
@@ -1242,7 +1242,7 @@ meta_get_event_window_position (decor_t *d,
win_type = wnck_window_get_window_type (d->win);
d_frame_type = get_frame_type (win_type);
frame_type = meta_get_frame_type_for_decor_type (d_frame_type);
- frame = &decor_frames[frame_type];
+ frame = gwd_get_decor_frame (frame_type);
meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout,
frame_type, &clip);
@@ -1633,35 +1633,35 @@ meta_update_border_extents ()
meta_theme_get_frame_borders (theme,
frame_type,
- decor_frames[d_frame_type].text_height,
+ gwd_get_decor_frame (d_frame_type)->text_height,
0,
&top_height,
&bottom_height,
&left_width,
&right_width);
- decor_frames[d_frame_type].win_extents.top = decor_frames[DECOR_FRAME_TYPE_DEFAULT].win_extents.top;
- decor_frames[d_frame_type].win_extents.bottom = bottom_height;
- decor_frames[d_frame_type].win_extents.left = left_width;
- decor_frames[d_frame_type].win_extents.right = right_width;
+ gwd_get_decor_frame (d_frame_type)->win_extents.top = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents.top;
+ gwd_get_decor_frame (d_frame_type)->win_extents.bottom = bottom_height;
+ gwd_get_decor_frame (d_frame_type)->win_extents.left = left_width;
+ gwd_get_decor_frame (d_frame_type)->win_extents.right = right_width;
- decor_frames[d_frame_type].titlebar_height = top_height - decor_frames[d_frame_type].win_extents.top;
+ gwd_get_decor_frame (d_frame_type)->titlebar_height = top_height - gwd_get_decor_frame (d_frame_type)->win_extents.top;
meta_theme_get_frame_borders (theme,
frame_type,
- decor_frames[d_frame_type].text_height,
+ gwd_get_decor_frame (d_frame_type)->text_height,
META_FRAME_MAXIMIZED,
&top_height,
&bottom_height,
&left_width,
&right_width);
- decor_frames[d_frame_type].max_win_extents.top = decor_frames[DECOR_FRAME_TYPE_DEFAULT].win_extents.top;
- decor_frames[d_frame_type].max_win_extents.bottom = bottom_height;
- decor_frames[d_frame_type].max_win_extents.left = left_width;
- decor_frames[d_frame_type].max_win_extents.right = right_width;
+ gwd_get_decor_frame (d_frame_type)->max_win_extents.top = gwd_get_decor_frame (DECOR_FRAME_TYPE_DEFAULT)->win_extents.top;
+ gwd_get_decor_frame (d_frame_type)->max_win_extents.bottom = bottom_height;
+ gwd_get_decor_frame (d_frame_type)->max_win_extents.left = left_width;
+ gwd_get_decor_frame (d_frame_type)->max_win_extents.right = right_width;
- decor_frames[d_frame_type].max_titlebar_height = top_height - decor_frames[d_frame_type].max_win_extents.top;
+ gwd_get_decor_frame (d_frame_type)->max_titlebar_height = top_height - gwd_get_decor_frame (d_frame_type)->max_win_extents.top;
}
}
diff --git a/gtk/window-decorator/settings.c b/gtk/window-decorator/settings.c
index 02c511f..5cdae28 100644
--- a/gtk/window-decorator/settings.c
+++ b/gtk/window-decorator/settings.c
@@ -301,7 +301,7 @@ titlebar_font_changed (GConfClient *client)
for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
- decor_frame_t *frame = &decor_frames[i];
+ decor_frame_t *frame = gwd_get_decor_frame (i);
gfloat scale = 1.0f;
if (frame->titlebar_font)
pango_font_description_free (frame->titlebar_font);
@@ -475,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 (decor_frames[DECOR_FRAME_TYPE_SWITCHER].style_window_rgba), switcher_label);
+ gtk_container_add (GTK_CONTAINER (gwd_get_decor_frame (DECOR_FRAME_TYPE_SWITCHER)->style_window_rgba), switcher_label);
#ifdef USE_GCONF
use_system_font = gconf_client_get_bool (gconf,
@@ -486,7 +486,7 @@ init_settings (WnckScreen *screen)
button_layout_changed (gconf);
#endif
- update_style (decor_frames[DECOR_FRAME_TYPE_SWITCHER].style_window_rgba);
+ update_style (gwd_get_decor_frame (DECOR_FRAME_TYPE_SWITCHER)->style_window_rgba);
#ifdef USE_GCONF
titlebar_font_changed (gconf);
#endif
diff --git a/gtk/window-decorator/switcher.c b/gtk/window-decorator/switcher.c
index e8d44d9..47a4a91 100644
--- a/gtk/window-decorator/switcher.c
+++ b/gtk/window-decorator/switcher.c
@@ -307,7 +307,7 @@ update_switcher_window (Window popup,
d->decorated = FALSE;
d->draw = draw_switcher_decoration;
- d->frame = &decor_frames[DECOR_FRAME_TYPE_SWITCHER];
+ d->frame = gwd_get_decor_frame (DECOR_FRAME_TYPE_SWITCHER);
decor_get_default_layout (&d->frame->window_context, width, 1, &d->border_layout);
diff --git a/gtk/window-decorator/wnck.c b/gtk/window-decorator/wnck.c
index cfd6745..4c145ef 100644
--- a/gtk/window-decorator/wnck.c
+++ b/gtk/window-decorator/wnck.c
@@ -236,7 +236,7 @@ add_frame_window (WnckWindow *win,
d->active = wnck_window_is_active (win);
d->win = win;
- d->frame = &decor_frames[get_frame_type (wnck_window_get_window_type (win))];
+ d->frame = gwd_get_decor_frame (get_frame_type (wnck_window_get_window_type (win)));
d->last_pos_entered = NULL;
attr.event_mask = ButtonPressMask | EnterWindowMask |