summaryrefslogtreecommitdiff
path: root/gtk/window-decorator
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-02-15 23:35:06 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-02-15 23:35:06 +0800
commit634d13819298ae359713a1664e520e74ad82f2d6 (patch)
treef8bcf0052d602681eef0054f429da389f83e0180 /gtk/window-decorator
parent5f94d553e900a4cd51dee850df26ac5856d65c15 (diff)
downloadcompiz-with-glib-mainloop-634d13819298ae359713a1664e520e74ad82f2d6.tar.gz
compiz-with-glib-mainloop-634d13819298ae359713a1664e520e74ad82f2d6.tar.bz2
Make the switcher a decoration frame.
It is still separate to the normal "window type" decoration, but at least now it has access to everything it needs
Diffstat (limited to 'gtk/window-decorator')
-rw-r--r--gtk/window-decorator/decorator.c4
-rw-r--r--gtk/window-decorator/decorprops.c2
-rw-r--r--gtk/window-decorator/gtk-window-decorator.c5
-rw-r--r--gtk/window-decorator/gtk-window-decorator.h21
-rw-r--r--gtk/window-decorator/metacity.c6
-rw-r--r--gtk/window-decorator/settings.c31
-rw-r--r--gtk/window-decorator/switcher.c42
-rw-r--r--gtk/window-decorator/wnck.c1
8 files changed, 27 insertions, 85 deletions
diff --git a/gtk/window-decorator/decorator.c b/gtk/window-decorator/decorator.c
index d2dab4d..000c353 100644
--- a/gtk/window-decorator/decorator.c
+++ b/gtk/window-decorator/decorator.c
@@ -19,7 +19,7 @@ update_titlebar_font ()
PangoLanguage *lang;
unsigned int i = 0;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
decor_frame_t *frame = &decor_frames[i];
font_desc = get_titlebar_font (frame);
@@ -515,7 +515,7 @@ update_shadow (void)
decor_draw_simple,
0);
- for (i = 0; i < 5; i++)
+ for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
decor_frame_t *frame = &decor_frames[i];
diff --git a/gtk/window-decorator/decorprops.c b/gtk/window-decorator/decorprops.c
index cb47a3f..a72290c 100644
--- a/gtk/window-decorator/decorprops.c
+++ b/gtk/window-decorator/decorprops.c
@@ -116,7 +116,7 @@ decor_update_switcher_property (decor_t *d)
&_switcher_extents, &_switcher_extents,
0, 0, quads, nQuad);
- style = gtk_widget_get_style (switcher_style_window_rgba);
+ style = gtk_widget_get_style (d->frame->style_window_rgba);
fgColor[0] = style->fg[GTK_STATE_NORMAL].red;
fgColor[1] = style->fg[GTK_STATE_NORMAL].green;
diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c
index 28e6527..1cc2039 100644
--- a/gtk/window-decorator/gtk-window-decorator.c
+++ b/gtk/window-decorator/gtk-window-decorator.c
@@ -26,8 +26,9 @@ gboolean minimal = FALSE;
double decoration_alpha = 0.5;
#define SWITCHER_SPACE 40
+#define DECOR_FRAMES_NUM 6
-decor_frame_t decor_frames[5];
+decor_frame_t decor_frames[DECOR_FRAMES_NUM];
decor_frame_t _default_decoration;
decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
@@ -178,7 +179,7 @@ initialize_decorations ()
unsigned int i;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
decor_frames[i].win_extents = _win_extents;
decor_frames[i].max_win_extents = _max_win_extents;
diff --git a/gtk/window-decorator/gtk-window-decorator.h b/gtk/window-decorator/gtk-window-decorator.h
index 7aa07e5..0ef0a0e 100644
--- a/gtk/window-decorator/gtk-window-decorator.h
+++ b/gtk/window-decorator/gtk-window-decorator.h
@@ -342,7 +342,8 @@ typedef enum _decor_frame_type {
DECOR_FRAME_TYPE_DIALOG = 1,
DECOR_FRAME_TYPE_MENU = 2,
DECOR_FRAME_TYPE_UTILITY = 3,
- DECOR_FRAME_TYPE_UNDECORATED = 4
+ DECOR_FRAME_TYPE_SWITCHER = 4,
+ DECOR_FRAME_TYPE_UNDECORATED = 5
} decor_frame_type;
typedef struct _decor_frame {
@@ -433,11 +434,6 @@ gfloat (*theme_get_title_scale) (decor_frame_t *frame);
extern char *program_name;
-extern GtkWidget *switcher_style_window_rgba;
-extern GtkWidget *switcher_style_window_rgb;
-extern PangoContext *switcher_pango_context;
-extern GtkWidget *switcher_label;
-
extern GHashTable *frame_table;
extern GtkWidget *action_menu;
extern gboolean action_menu_mapped;
@@ -460,12 +456,9 @@ extern gboolean use_system_font;
extern gint blur_type;
-extern GdkPixmap *switcher_pixmap;
-extern GdkPixmap *switcher_buffer_pixmap;
-extern gint switcher_width;
-extern gint switcher_height;
-extern Window switcher_selected_window;
-extern decor_t *switcher_window;
+extern Window switcher_selected_window;
+extern GtkWidget *switcher_label;
+extern decor_t *switcher_window;
extern XRenderPictFormat *xformat_rgba;
extern XRenderPictFormat *xformat_rgb;
@@ -473,7 +466,9 @@ extern XRenderPictFormat *xformat_rgb;
extern Atom compiz_shadow_info_atom;
extern Atom compiz_shadow_color_atom;
-extern decor_frame_t decor_frames[5];
+#define NUM_DECOR_FRAMES 6
+
+extern decor_frame_t decor_frames[NUM_DECOR_FRAMES];
extern decor_frame_t _default_decoration;
/* gtk-window-decorator.c */
diff --git a/gtk/window-decorator/metacity.c b/gtk/window-decorator/metacity.c
index be9bab3..2ff62c5 100644
--- a/gtk/window-decorator/metacity.c
+++ b/gtk/window-decorator/metacity.c
@@ -1101,7 +1101,7 @@ meta_get_title_scale (decor_frame_t *frame)
MetaFrameType type;
MetaFrameFlags flags = 0xc33;
- if (frame->type == DECOR_FRAME_TYPE_UNDECORATED)
+ if (frame->type >= DECOR_FRAME_TYPE_SWITCHER)
return 1.0f;
type = meta_get_frame_type_for_decor_type (frame->type);
@@ -1618,14 +1618,14 @@ meta_update_border_extents ()
WnckWindowType win_types[] = { WNCK_WINDOW_NORMAL, WNCK_WINDOW_DIALOG,
WNCK_WINDOW_MENU, WNCK_WINDOW_UTILITY,
- WNCK_WINDOW_SPLASHSCREEN };
+ WNCK_WINDOW_SPLASHSCREEN, WNCK_WINDOW_SPLASHSCREEN };
gint top_height, bottom_height, left_width, right_width;
unsigned int i;
theme = meta_theme_get_current ();
- for (i = 0; i < 5; i++)
+ for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
d_frame_type = get_frame_type (win_types[i]);
diff --git a/gtk/window-decorator/settings.c b/gtk/window-decorator/settings.c
index 0063b73..d22baa4 100644
--- a/gtk/window-decorator/settings.c
+++ b/gtk/window-decorator/settings.c
@@ -299,8 +299,9 @@ titlebar_font_changed (GConfClient *client)
if (!str)
str = g_strdup ("Sans Bold 12");
- for (i = 0; i < 5; i++)
+ for (i = 0; i < NUM_DECOR_FRAMES; i++)
{
+ fprintf (stderr, "i is %i\n", i);
decor_frame_t *frame = &decor_frames[i];
gfloat scale = 1.0f;
if (frame->titlebar_font)
@@ -472,34 +473,10 @@ init_settings (WnckScreen *screen)
screen);
#endif
- switcher_style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP);
-
- gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ());
- colormap = gdk_screen_get_rgba_colormap (gdkscreen);
- if (colormap)
- gtk_widget_set_colormap (switcher_style_window_rgba, colormap);
-
- gtk_widget_realize (switcher_style_window_rgba);
-
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 (switcher_style_window_rgba), switcher_label);
-
- gtk_widget_set_size_request (switcher_style_window_rgba, 0, 0);
- gtk_window_move (GTK_WINDOW (switcher_style_window_rgba), -100, -100);
- gtk_widget_show_all (switcher_style_window_rgba);
-
- g_signal_connect_object (switcher_style_window_rgba, "style-set",
- G_CALLBACK (style_changed),
- 0, 0);
-
- settings = gtk_widget_get_settings (switcher_style_window_rgba);
-
- g_object_get (G_OBJECT (settings), "gtk-double-click-time",
- &double_click_timeout, NULL);
-
- switcher_pango_context = gtk_widget_create_pango_context (switcher_style_window_rgba);
+ gtk_container_add (GTK_CONTAINER (decor_frames[DECOR_FRAME_TYPE_SWITCHER].style_window_rgba), switcher_label);
#ifdef USE_GCONF
use_system_font = gconf_client_get_bool (gconf,
@@ -510,7 +487,7 @@ init_settings (WnckScreen *screen)
button_layout_changed (gconf);
#endif
- update_style (switcher_style_window_rgba);
+ update_style (decor_frames[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 2962999..b6ec0ff 100644
--- a/gtk/window-decorator/switcher.c
+++ b/gtk/window-decorator/switcher.c
@@ -16,7 +16,7 @@ draw_switcher_background (decor_t *d)
if (!d->buffer_pixmap)
return;
- style = gtk_widget_get_style (switcher_style_window_rgba);
+ style = gtk_widget_get_style (d->frame->style_window_rgba);
color.r = style->bg[GTK_STATE_NORMAL].red / 65535.0;
color.g = style->bg[GTK_STATE_NORMAL].green / 65535.0;
@@ -207,7 +207,7 @@ draw_switcher_foreground (decor_t *d)
if (!d->pixmap || !d->buffer_pixmap)
return;
- style = gtk_widget_get_style (switcher_style_window_rgba);
+ style = gtk_widget_get_style (d->frame->style_window_rgba);
cr = gdk_cairo_create (GDK_DRAWABLE (d->buffer_pixmap));
@@ -308,25 +308,7 @@ update_switcher_window (Window popup,
d->decorated = FALSE;
d->draw = draw_switcher_decoration;
-
- if (!d->pixmap && switcher_pixmap)
- {
- g_object_ref (G_OBJECT (switcher_pixmap));
-
- d->pixmap = switcher_pixmap;
- }
-
- if (!d->buffer_pixmap && switcher_buffer_pixmap)
- {
- g_object_ref (G_OBJECT (switcher_buffer_pixmap));
- d->buffer_pixmap = switcher_buffer_pixmap;
- }
-
- if (!d->width)
- d->width = switcher_width;
-
- if (!d->height)
- d->height = switcher_height;
+ d->frame = &decor_frames[DECOR_FRAME_TYPE_SWITCHER];
selected_win = wnck_window_get (selected);
if (selected_win)
@@ -346,7 +328,7 @@ update_switcher_window (Window popup,
{
if (!d->layout)
{
- d->layout = pango_layout_new (switcher_pango_context);
+ d->layout = pango_layout_new (d->frame->pango_context);
if (d->layout)
pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR);
}
@@ -399,23 +381,17 @@ update_switcher_window (Window popup,
switcher_selected_window = selected;
}
- pixmap = create_pixmap (width, height, switcher_style_window_rgba);
+ pixmap = create_pixmap (width, height, d->frame->style_window_rgba);
if (!pixmap)
return FALSE;
- buffer_pixmap = create_pixmap (width, height, switcher_style_window_rgb);
+ buffer_pixmap = create_pixmap (width, height, d->frame->style_window_rgba);
if (!buffer_pixmap)
{
g_object_unref (G_OBJECT (pixmap));
return FALSE;
}
- if (switcher_pixmap)
- g_object_unref (G_OBJECT (switcher_pixmap));
-
- if (switcher_buffer_pixmap)
- g_object_unref (G_OBJECT (switcher_buffer_pixmap));
-
if (d->pixmap)
g_object_unref (G_OBJECT (d->pixmap));
@@ -428,12 +404,6 @@ update_switcher_window (Window popup,
if (d->picture)
XRenderFreePicture (xdisplay, d->picture);
- switcher_pixmap = pixmap;
- switcher_buffer_pixmap = buffer_pixmap;
-
- switcher_width = width;
- switcher_height = height;
-
g_object_ref (G_OBJECT (pixmap));
g_object_ref (G_OBJECT (buffer_pixmap));
diff --git a/gtk/window-decorator/wnck.c b/gtk/window-decorator/wnck.c
index 1080b1d..cfd6745 100644
--- a/gtk/window-decorator/wnck.c
+++ b/gtk/window-decorator/wnck.c
@@ -156,7 +156,6 @@ decorations_changed (WnckScreen *screen)
/* force size update */
d->context = NULL;
d->width = d->height = 0;
- switcher_width = switcher_height = 0;
update_switcher_window (d->prop_xid, select);
}