diff options
author | Sam Spilsbury <sam.spilsbury@canonical.com> | 2011-02-15 22:24:41 +0800 |
---|---|---|
committer | Sam Spilsbury <sam.spilsbury@canonical.com> | 2011-02-15 22:24:41 +0800 |
commit | 5f94d553e900a4cd51dee850df26ac5856d65c15 (patch) | |
tree | 6bc3125438f34bc99ad7fee54d17921b780782c6 | |
parent | 552af63a1a5b2be7d3eb599ca95aa5ef58ed6d68 (diff) | |
download | compiz-with-glib-mainloop-5f94d553e900a4cd51dee850df26ac5856d65c15.tar.gz compiz-with-glib-mainloop-5f94d553e900a4cd51dee850df26ac5856d65c15.tar.bz2 |
Allow different font types in frames.
Currently we used a single PangoContext and PangoFontDescription for
everything ... this resulted in custom frames having the same titlebar
size which wasn't any good. This commit changes a lot, namely:
* Frame is now linked to the decoration object itself
* Moved style windows into the frame
* Moved font context and font description into the frame
* Added API for getting the titlebar font size: obviously with the
cairo decorations there isn't supposed to be any kind of visual
difference here but with the metacity decorations we need to get that
directly from libmetacity.
It should be noted that these commits are in need of a cleanup ... which
is coming in the next few commits.
-rw-r--r-- | gtk/window-decorator/cairo.c | 16 | ||||
-rw-r--r-- | gtk/window-decorator/decorator.c | 63 | ||||
-rw-r--r-- | gtk/window-decorator/decorprops.c | 2 | ||||
-rw-r--r-- | gtk/window-decorator/gdk.c | 18 | ||||
-rw-r--r-- | gtk/window-decorator/gtk-window-decorator.c | 96 | ||||
-rw-r--r-- | gtk/window-decorator/gtk-window-decorator.h | 51 | ||||
-rw-r--r-- | gtk/window-decorator/metacity.c | 58 | ||||
-rw-r--r-- | gtk/window-decorator/settings.c | 74 | ||||
-rw-r--r-- | gtk/window-decorator/style.c | 5 | ||||
-rw-r--r-- | gtk/window-decorator/switcher.c | 12 | ||||
-rw-r--r-- | gtk/window-decorator/wnck.c | 3 |
11 files changed, 253 insertions, 145 deletions
diff --git a/gtk/window-decorator/cairo.c b/gtk/window-decorator/cairo.c index 48b7c36..6881ea5 100644 --- a/gtk/window-decorator/cairo.c +++ b/gtk/window-decorator/cairo.c @@ -282,7 +282,7 @@ draw_window_decoration (decor_t *d) if (!d->pixmap) return; - style = gtk_widget_get_style (style_window_rgba); + style = gtk_widget_get_style (d->frame->style_window_rgba); if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) @@ -629,7 +629,7 @@ draw_window_decoration (decor_t *d) { cairo_move_to (cr, d->context->left_space + 21.0, - y1 + 2.0 + (frame->titlebar_height - text_height) / 2.0); + y1 + 2.0 + (frame->titlebar_height - frame->text_height) / 2.0); gdk_cairo_set_source_color_alpha (cr, &style->fg[GTK_STATE_NORMAL], @@ -649,7 +649,7 @@ draw_window_decoration (decor_t *d) cairo_move_to (cr, d->context->left_space + 21.0, - y1 + 2.0 + (frame->titlebar_height - text_height) / 2.0); + y1 + 2.0 + (frame->titlebar_height - frame->text_height) / 2.0); pango_cairo_show_layout (cr, d->layout); } @@ -876,8 +876,14 @@ get_event_window_position (decor_t *d, } } +gfloat +get_title_scale (decor_frame_t *frame) +{ + return 1.0f; +} + void -update_border_extents (gint text_height) +update_border_extents () { unsigned int i; @@ -888,6 +894,6 @@ update_border_extents (gint text_height) frame->win_extents = _default_decoration.win_extents; frame->max_win_extents = _default_decoration.win_extents; frame->titlebar_height = frame->max_titlebar_height = - (text_height < 17) ? 17 : text_height; + (frame->text_height < 17) ? 17 : frame->text_height; } } diff --git a/gtk/window-decorator/decorator.c b/gtk/window-decorator/decorator.c index 64f4fa5..d2dab4d 100644 --- a/gtk/window-decorator/decorator.c +++ b/gtk/window-decorator/decorator.c @@ -1,41 +1,47 @@ #include "gtk-window-decorator.h" static const PangoFontDescription * -get_titlebar_font (void) +get_titlebar_font (decor_frame_t *frame) { if (use_system_font) { return NULL; } else - return titlebar_font; + return frame->titlebar_font; } void -update_titlebar_font (void) +update_titlebar_font () { const PangoFontDescription *font_desc; PangoFontMetrics *metrics; PangoLanguage *lang; + unsigned int i = 0; - font_desc = get_titlebar_font (); - if (!font_desc) + for (i = 0; i < 5; i++) { - GtkStyle *default_style; + decor_frame_t *frame = &decor_frames[i]; + font_desc = get_titlebar_font (frame); + if (!font_desc) + { + GtkStyle *default_style; - default_style = gtk_widget_get_default_style (); - font_desc = default_style->font_desc; - } + default_style = gtk_widget_get_default_style (); + font_desc = default_style->font_desc; + } - pango_context_set_font_description (pango_context, font_desc); + pango_context_set_font_description (frame->pango_context, font_desc); - lang = pango_context_get_language (pango_context); - metrics = pango_context_get_metrics (pango_context, font_desc, lang); + lang = pango_context_get_language (frame->pango_context); + metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang); - text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + - pango_font_metrics_get_descent (metrics)); + frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + + pango_font_metrics_get_descent (metrics)); + + pango_font_metrics_unref (metrics); + } - pango_font_metrics_unref (metrics); } void @@ -198,7 +204,7 @@ max_window_name_width (WnckWindow *win) if (!d->layout) { - d->layout = pango_layout_new (pango_context); + d->layout = pango_layout_new (d->frame->pango_context); if (!d->layout) return 0; @@ -309,10 +315,10 @@ update_window_decoration_icon (WnckWindow *win) if (d->frame_window) d->icon_pixmap = pixmap_new_from_pixbuf (d->icon_pixbuf, - 24); + d->frame->style_window_rgba); else d->icon_pixmap = pixmap_new_from_pixbuf (d->icon_pixbuf, - 32); + d->frame->style_window_rgb); cr = gdk_cairo_create (GDK_DRAWABLE (d->icon_pixmap)); d->icon = cairo_pattern_create_for_surface (cairo_get_target (cr)); cairo_destroy (cr); @@ -331,7 +337,6 @@ update_window_decoration_size (WnckWindow *win) gint x, y, w, h, name_width; Display *xdisplay; XRenderPictFormat *format; - int depth; xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); @@ -348,11 +353,9 @@ update_window_decoration_size (WnckWindow *win) gdk_error_trap_push (); if (d->frame_window) - depth = gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)); + pixmap = create_pixmap (width, height, d->frame->style_window_rgb); else - depth = 32; - - pixmap = create_pixmap (width, height, depth); + pixmap = create_pixmap (width, height, d->frame->style_window_rgba); gdk_flush (); @@ -364,7 +367,10 @@ update_window_decoration_size (WnckWindow *win) gdk_error_trap_push (); - buffer_pixmap = create_pixmap (width, height, depth); + if (d->frame_window) + buffer_pixmap = create_pixmap (width, height, d->frame->style_window_rgb); + else + buffer_pixmap = create_pixmap (width, height, d->frame->style_window_rgba); gdk_flush (); @@ -428,6 +434,7 @@ draw_border_shape (Display *xdisplay, memset (&d, 0, sizeof (d)); + d.frame = &_default_decoration; d.pixmap = gdk_pixmap_foreign_new_for_display (gdk_display_get_default (), pixmap); d.width = width; @@ -777,13 +784,15 @@ update_default_decorations (GdkScreen *screen) d.context = &_default_decoration.window_context; d.shadow = _default_decoration.border_shadow; - d.layout = pango_layout_new (pango_context); + d.layout = pango_layout_new (_default_decoration.pango_context); /* FIXME */ 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 = &_default_decoration; + extents.top += _default_decoration.titlebar_height; d.draw = theme_draw_window_decoration; @@ -794,7 +803,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, 32); + decor_normal_pixmap = create_pixmap (d.width, d.height, _default_decoration.style_window_rgba); /* FIXME */ if (decor_normal_pixmap) { @@ -822,7 +831,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, 32); + decor_active_pixmap = create_pixmap (d.width, d.height, _default_decoration.style_window_rgba); /* FIXME */ if (decor_active_pixmap) { diff --git a/gtk/window-decorator/decorprops.c b/gtk/window-decorator/decorprops.c index 2b161a2..cb47a3f 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 (style_window_rgba); + style = gtk_widget_get_style (switcher_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/gdk.c b/gtk/window-decorator/gdk.c index fe7d63a..1851a7b 100644 --- a/gtk/window-decorator/gdk.c +++ b/gtk/window-decorator/gdk.c @@ -1,7 +1,7 @@ #include "gtk-window-decorator.h" GdkPixmap * -pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, int depth) +pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, GtkWidget *parent) { GdkPixmap *pixmap; guint width, height; @@ -10,7 +10,7 @@ pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, int depth) width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); - pixmap = create_pixmap (width, height, depth); + pixmap = create_pixmap (width, height, parent); if (!pixmap) return NULL; @@ -71,17 +71,15 @@ get_format_for_drawable (decor_t *d, GdkDrawable *drawable) } GdkPixmap * -create_pixmap (int w, - int h, - int depth) +create_pixmap (int w, + int h, + GtkWidget *parent_style_window) { - GtkWidget *widget; GdkWindow *window; if (w == 0 || h == 0) abort (); - widget = (depth > 24) ? style_window_rgba : style_window_rgb; - window = gtk_widget_get_window (widget); - return gdk_pixmap_new (GDK_DRAWABLE (window), w, h, depth); -}
\ No newline at end of file + window = gtk_widget_get_window (parent_style_window); + return gdk_pixmap_new (GDK_DRAWABLE (window), w, h, -1 /* CopyFromParent */); +} diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c index 05f53cb..28e6527 100644 --- a/gtk/window-decorator/gtk-window-decorator.c +++ b/gtk/window-decorator/gtk-window-decorator.c @@ -112,15 +112,15 @@ struct _pos pos[3][3] = { char *program_name; -GtkWidget *style_window_rgba; -GtkWidget *style_window_rgb; +GtkWidget *switcher_style_window_rgba; +GtkWidget *switcher_style_window_rgb; GtkWidget *switcher_label; GHashTable *frame_table; GtkWidget *action_menu = NULL; gboolean action_menu_mapped = FALSE; decor_color_t _title_color[2]; -PangoContext *pango_context; +PangoContext *switcher_pango_context; gint double_click_timeout = 250; GtkWidget *tip_window; @@ -131,9 +131,7 @@ gint tooltip_timer_tag = 0; GSList *draw_list = NULL; guint draw_idle_id = 0; -PangoFontDescription *titlebar_font = NULL; gboolean use_system_font = FALSE; -gint text_height; gint blur_type = BLUR_TYPE_NONE; @@ -150,6 +148,8 @@ XRenderPictFormat *xformat_rgb; void initialize_decorations () { + GdkScreen *gdkscreen = gdk_screen_get_default (); + GdkColormap *colormap; decor_extents_t _win_extents = { 6, 6, 6, 6 }; decor_extents_t _max_win_extents = { 6, 6, 4, 6 }; decor_context_t _window_context = { @@ -175,16 +175,11 @@ initialize_decorations () 6, 6, 4, 6, 0, 0, 0, 0 }; - WnckWindowType win_types[] = { - WNCK_WINDOW_NORMAL, WNCK_WINDOW_DIALOG, WNCK_WINDOW_MENU, - WNCK_WINDOW_UTILITY, WNCK_WINDOW_SPLASHSCREEN - }; unsigned int i; for (i = 0; i < 5; i++) { - fprintf (stderr, "i is %i\n", i); decor_frames[i].win_extents = _win_extents; decor_frames[i].max_win_extents = _max_win_extents; decor_frames[i].titlebar_height = 17; @@ -197,6 +192,45 @@ initialize_decorations () decor_frames[i].border_no_shadow = NULL; decor_frames[i].max_border_no_shadow = NULL; decor_frames[i].max_border_shadow = NULL; + decor_frames[i].titlebar_font = NULL; + decor_frames[i].type = i; + + decor_frames[i].style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP); + + colormap = gdk_screen_get_rgba_colormap (gdkscreen); + if (colormap) + gtk_widget_set_colormap (decor_frames[i].style_window_rgba, colormap); + + gtk_widget_realize (decor_frames[i].style_window_rgba); + + gtk_widget_set_size_request (decor_frames[i].style_window_rgba, 0, 0); + gtk_window_move (GTK_WINDOW (decor_frames[i].style_window_rgba), -100, -100); + gtk_widget_show_all (decor_frames[i].style_window_rgba); + + g_signal_connect_object (decor_frames[i].style_window_rgba, "style-set", + G_CALLBACK (style_changed), + 0, 0); + + decor_frames[i].pango_context = gtk_widget_create_pango_context (decor_frames[i].style_window_rgba); + + decor_frames[i].style_window_rgb = gtk_window_new (GTK_WINDOW_POPUP); + + colormap = gdk_screen_get_rgb_colormap (gdkscreen); + if (colormap) + gtk_widget_set_colormap (decor_frames[i].style_window_rgb, colormap); + + gtk_widget_realize (decor_frames[i].style_window_rgb); + + gtk_widget_set_size_request (decor_frames[i].style_window_rgb, 0, 0); + gtk_window_move (GTK_WINDOW (decor_frames[i].style_window_rgb), -100, -100); + gtk_widget_show_all (decor_frames[i].style_window_rgb); + + g_signal_connect_object (decor_frames[i].style_window_rgb, "style-set", + G_CALLBACK (style_changed), + 0, 0); + + update_style (decor_frames[i].style_window_rgba); + update_style (decor_frames[i].style_window_rgb); } _default_decoration.win_extents = _win_extents; @@ -211,6 +245,48 @@ initialize_decorations () _default_decoration.border_no_shadow = NULL; _default_decoration.max_border_no_shadow = NULL; _default_decoration.max_border_shadow = NULL; + _default_decoration.titlebar_font = NULL; + _default_decoration.style_window_rgba = NULL; + _default_decoration.style_window_rgb = NULL; + _default_decoration.pango_context = NULL; + _default_decoration.type = 0; + + _default_decoration.style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP); + + colormap = gdk_screen_get_rgba_colormap (gdkscreen); + if (colormap) + gtk_widget_set_colormap (_default_decoration.style_window_rgba, colormap); + + gtk_widget_realize (_default_decoration.style_window_rgba); + + gtk_widget_set_size_request (_default_decoration.style_window_rgba, 0, 0); + gtk_window_move (GTK_WINDOW (_default_decoration.style_window_rgba), -100, -100); + gtk_widget_show_all (_default_decoration.style_window_rgba); + + g_signal_connect_object (_default_decoration.style_window_rgba, "style-set", + G_CALLBACK (style_changed), + 0, 0); + + _default_decoration.pango_context = gtk_widget_create_pango_context (_default_decoration.style_window_rgba); + + _default_decoration.style_window_rgb = gtk_window_new (GTK_WINDOW_POPUP); + + colormap = gdk_screen_get_rgb_colormap (gdkscreen); + if (colormap) + gtk_widget_set_colormap (_default_decoration.style_window_rgb, colormap); + + gtk_widget_realize (_default_decoration.style_window_rgb); + + gtk_widget_set_size_request (_default_decoration.style_window_rgb, 0, 0); + gtk_window_move (GTK_WINDOW (_default_decoration.style_window_rgb), -100, -100); + gtk_widget_show_all (_default_decoration.style_window_rgb); + + g_signal_connect_object (_default_decoration.style_window_rgb, "style-set", + G_CALLBACK (style_changed), + 0, 0); + + update_style (_default_decoration.style_window_rgba); + update_style (_default_decoration.style_window_rgb); } int diff --git a/gtk/window-decorator/gtk-window-decorator.h b/gtk/window-decorator/gtk-window-decorator.h index bde48b7..7aa07e5 100644 --- a/gtk/window-decorator/gtk-window-decorator.h +++ b/gtk/window-decorator/gtk-window-decorator.h @@ -338,11 +338,11 @@ typedef struct { } event_window; typedef enum _decor_frame_type { - DECOR_FRAME_TYPE_NORMAL, - DECOR_FRAME_TYPE_DIALOG, - DECOR_FRAME_TYPE_MENU, - DECOR_FRAME_TYPE_UTILITY, - DECOR_FRAME_TYPE_UNDECORATED + DECOR_FRAME_TYPE_NORMAL = 0, + DECOR_FRAME_TYPE_DIALOG = 1, + DECOR_FRAME_TYPE_MENU = 2, + DECOR_FRAME_TYPE_UTILITY = 3, + DECOR_FRAME_TYPE_UNDECORATED = 4 } decor_frame_type; typedef struct _decor_frame { @@ -358,10 +358,17 @@ typedef struct _decor_frame { decor_context_t window_context_no_shadow; decor_context_t max_window_context; decor_context_t max_window_context_no_shadow; + PangoFontDescription *titlebar_font; + PangoContext *pango_context; + GtkWidget *style_window_rgba; + GtkWidget *style_window_rgb; + gint text_height; + decor_frame_type type; } decor_frame_t; typedef struct _decor { WnckWindow *win; + decor_frame_t *frame; event_window event_windows[3][3]; event_window button_windows[BUTTON_NUM]; Box *last_pos_entered; @@ -404,7 +411,7 @@ gboolean (*theme_calc_decoration_size) (decor_t *d, int text_width, int *width, int *height); -void (*theme_update_border_extents) (gint text_height); +void (*theme_update_border_extents) (); void (*theme_get_event_window_position) (decor_t *d, gint i, gint j, @@ -422,18 +429,19 @@ gboolean (*theme_get_button_position) (decor_t *d, gint *y, gint *w, gint *h); +gfloat (*theme_get_title_scale) (decor_frame_t *frame); extern char *program_name; -extern GtkWidget *style_window_rgba; -extern GtkWidget *style_window_rgb; +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; extern decor_color_t _title_color[2]; -extern PangoContext *pango_context; extern gint double_click_timeout; extern GtkWidget *tip_window; @@ -444,9 +452,7 @@ extern gint tooltip_timer_tag; extern GSList *draw_list; extern guint draw_idle_id; -extern PangoFontDescription *titlebar_font; extern gboolean use_system_font; -extern gint text_height; #define BLUR_TYPE_NONE 0 #define BLUR_TYPE_TITLEBAR 1 @@ -509,7 +515,7 @@ void shadow_property_changed (WnckScreen *screen); void -update_titlebar_font (void); +update_titlebar_font (); void update_window_decoration_name (WnckWindow *win); @@ -626,7 +632,7 @@ calc_decoration_size (decor_t *d, gint *height); void -update_border_extents (gint text_height); +update_border_extents (); gboolean get_button_position (decor_t *d, @@ -649,6 +655,9 @@ get_event_window_position (decor_t *d, gint *w, gint *h); +gfloat +get_title_scale (decor_frame_t *); + /* gdk.c */ void @@ -666,12 +675,12 @@ XRenderPictFormat * get_format_for_drawable (decor_t *d, GdkDrawable *drawable); GdkPixmap * -create_pixmap (int w, - int h, - int depth); +create_pixmap (int w, + int h, + GtkWidget *parent_style_window); GdkPixmap * -pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, int depth); +pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, GtkWidget *parent); /* metacity.c */ #ifdef USE_METACITY @@ -726,8 +735,12 @@ meta_get_event_window_position (decor_t *d, gint *y, gint *w, gint *h); + +gfloat +meta_get_title_scale (decor_frame_t *); + void -meta_update_border_extents (gint text_height); +meta_update_border_extents (); void meta_update_button_layout (const char *value); @@ -968,7 +981,7 @@ void update_style (GtkWidget *widget); void -style_changed (GtkWidget *widget); +style_changed (PangoContext *context, GtkWidget *widget); /* settings.c */ diff --git a/gtk/window-decorator/metacity.c b/gtk/window-decorator/metacity.c index 8d9cd22..be9bab3 100644 --- a/gtk/window-decorator/metacity.c +++ b/gtk/window-decorator/metacity.c @@ -485,7 +485,7 @@ meta_get_decoration_geometry (decor_t *d, meta_theme_get_frame_borders (theme, frame_type, - text_height, + d->frame->text_height, *flags, &top_height, &bottom_height, @@ -505,7 +505,7 @@ meta_get_decoration_geometry (decor_t *d, meta_theme_calc_geometry (theme, frame_type, - text_height, + d->frame->text_height, *flags, clip->width, clip->height, @@ -591,13 +591,13 @@ meta_draw_window_decoration (decor_t *d) if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32) { - style = gtk_widget_get_style (style_window_rgba); - style_window = style_window_rgba; + style = gtk_widget_get_style (d->frame->style_window_rgba); + style_window = d->frame->style_window_rgba; } else { - style = gtk_widget_get_style (style_window_rgb); - style_window = style_window_rgb; + style = gtk_widget_get_style (d->frame->style_window_rgb); + style_window = d->frame->style_window_rgb; } drawable = d->buffer_pixmap ? d->buffer_pixmap : d->pixmap; @@ -607,6 +607,7 @@ meta_draw_window_decoration (decor_t *d) cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); theme = meta_theme_get_current (); + if (d->win) { win_type = wnck_window_get_window_type (d->win); @@ -663,11 +664,11 @@ meta_draw_window_decoration (decor_t *d) cmap = get_colormap_for_drawable (GDK_DRAWABLE (d->pixmap)); depth = gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)); - pixmap = create_pixmap (rect.width, size, depth); + pixmap = create_pixmap (rect.width, size, d->frame->style_window_rgb); gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap); } else - pixmap = create_pixmap (rect.width, size, 32); + pixmap = create_pixmap (rect.width, size, d->frame->style_window_rgba); cr = gdk_cairo_create (GDK_DRAWABLE (pixmap)); gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha); @@ -695,7 +696,7 @@ meta_draw_window_decoration (decor_t *d) clip.height - fgeom.top_height - fgeom.bottom_height, d->layout, - text_height, + d->frame->text_height, &button_layout, button_states, d->icon_pixbuf, @@ -735,7 +736,7 @@ meta_draw_window_decoration (decor_t *d) clip.height - fgeom.top_height - fgeom.bottom_height, d->layout, - text_height, + d->frame->text_height, &button_layout, button_states, d->icon_pixbuf, @@ -779,11 +780,11 @@ meta_draw_window_decoration (decor_t *d) cmap = get_colormap_for_drawable (GDK_DRAWABLE (d->pixmap)); depth = gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)); - pixmap = create_pixmap (size, rect.height, depth); + pixmap = create_pixmap (size, rect.height, d->frame->style_window_rgb); gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap); } else - pixmap = create_pixmap (size, rect.height, 32); + pixmap = create_pixmap (size, rect.height, d->frame->style_window_rgba); cr = gdk_cairo_create (GDK_DRAWABLE (pixmap)); gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha); @@ -812,7 +813,7 @@ meta_draw_window_decoration (decor_t *d) clip.height - fgeom.top_height - fgeom.bottom_height, d->layout, - text_height, + d->frame->text_height, &button_layout, button_states, d->icon_pixbuf, @@ -852,7 +853,7 @@ meta_draw_window_decoration (decor_t *d) clip.height - fgeom.top_height - fgeom.bottom_height, d->layout, - text_height, + d->frame->text_height, &button_layout, button_states, d->icon_pixbuf, @@ -1086,13 +1087,30 @@ meta_get_button_position (decor_t *d, if (d->frame_window) { decor_frame_t *frame = &decor_frames[d_frame_type]; - *x += frame.win_extents.left + 4; - *y += frame.win_extents.top + 2; + *x += frame->win_extents.left + 4; + *y += frame->win_extents.top + 2; } return TRUE; } +gfloat +meta_get_title_scale (decor_frame_t *frame) +{ + MetaTheme *theme = meta_theme_get_current (); + MetaFrameType type; + MetaFrameFlags flags = 0xc33; + + if (frame->type == DECOR_FRAME_TYPE_UNDECORATED) + return 1.0f; + + type = meta_get_frame_type_for_decor_type (frame->type); + + gfloat scale = meta_theme_get_title_scale (theme, type, flags); + + return scale; +} + gboolean meta_calc_decoration_size (decor_t *d, gint w, @@ -1592,7 +1610,7 @@ meta_update_button_layout (const char *value) } void -meta_update_border_extents (gint text_height) +meta_update_border_extents () { MetaTheme *theme; MetaFrameType frame_type; @@ -1618,7 +1636,8 @@ meta_update_border_extents (gint text_height) meta_theme_get_frame_borders (theme, frame_type, - text_height, 0, + decor_frames[d_frame_type].text_height, + 0, &top_height, &bottom_height, &left_width, @@ -1633,7 +1652,8 @@ meta_update_border_extents (gint text_height) meta_theme_get_frame_borders (theme, frame_type, - text_height, META_FRAME_MAXIMIZED, + decor_frames[d_frame_type].text_height, + META_FRAME_MAXIMIZED, &top_height, &bottom_height, &left_width, diff --git a/gtk/window-decorator/settings.c b/gtk/window-decorator/settings.c index 31cc3e9..0063b73 100644 --- a/gtk/window-decorator/settings.c +++ b/gtk/window-decorator/settings.c @@ -163,6 +163,7 @@ theme_changed (GConfClient *client) theme_update_border_extents = meta_update_border_extents; theme_get_event_window_position = meta_get_event_window_position; theme_get_button_position = meta_get_button_position; + theme_get_title_scale = meta_get_title_scale; } else { @@ -171,6 +172,7 @@ theme_changed (GConfClient *client) theme_update_border_extents = update_border_extents; theme_get_event_window_position = get_event_window_position; theme_get_button_position = get_button_position; + theme_get_title_scale = get_title_scale; } return TRUE; @@ -180,6 +182,7 @@ theme_changed (GConfClient *client) theme_update_border_extents = update_border_extents; theme_get_event_window_position = get_event_window_position; theme_get_button_position = get_button_position; + theme_get_title_scale = get_title_scale; return FALSE; #endif @@ -288,6 +291,7 @@ static void titlebar_font_changed (GConfClient *client) { gchar *str; + gint i; str = gconf_client_get_string (client, COMPIZ_TITLEBAR_FONT_KEY, @@ -295,10 +299,20 @@ titlebar_font_changed (GConfClient *client) if (!str) str = g_strdup ("Sans Bold 12"); - if (titlebar_font) - pango_font_description_free (titlebar_font); + for (i = 0; i < 5; i++) + { + decor_frame_t *frame = &decor_frames[i]; + gfloat scale = 1.0f; + if (frame->titlebar_font) + pango_font_description_free (frame->titlebar_font); + + frame->titlebar_font = pango_font_description_from_string (str); + + scale = (*theme_get_title_scale) (frame); - titlebar_font = pango_font_description_from_string (str); + pango_font_description_set_size (frame->titlebar_font, + MAX (pango_font_description_get_size (frame->titlebar_font) * scale, 1)); + } g_free (str); } @@ -458,63 +472,34 @@ init_settings (WnckScreen *screen) screen); #endif - style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP); + 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 (style_window_rgba, colormap); - - gtk_widget_realize (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 (style_window_rgba), switcher_label); - - gtk_widget_set_size_request (style_window_rgba, 0, 0); - gtk_window_move (GTK_WINDOW (style_window_rgba), -100, -100); - gtk_widget_show_all (style_window_rgba); - - g_signal_connect_object (style_window_rgba, "style-set", - G_CALLBACK (style_changed), - 0, 0); - - settings = gtk_widget_get_settings (style_window_rgba); - - g_object_get (G_OBJECT (settings), "gtk-double-click-time", - &double_click_timeout, NULL); - - pango_context = gtk_widget_create_pango_context (style_window_rgba); - - style_window_rgb = gtk_window_new (GTK_WINDOW_POPUP); - - gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ()); - colormap = gdk_screen_get_rgb_colormap (gdkscreen); - if (colormap) - gtk_widget_set_colormap (style_window_rgb, colormap); + gtk_widget_set_colormap (switcher_style_window_rgba, colormap); - gtk_widget_realize (style_window_rgb); + 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 (style_window_rgb), switcher_label); + gtk_container_add (GTK_CONTAINER (switcher_style_window_rgba), switcher_label); - gtk_widget_set_size_request (style_window_rgb, 0, 0); - gtk_window_move (GTK_WINDOW (style_window_rgb), -100, -100); - gtk_widget_show_all (style_window_rgb); + 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 (style_window_rgb, "style-set", + g_signal_connect_object (switcher_style_window_rgba, "style-set", G_CALLBACK (style_changed), 0, 0); - settings = gtk_widget_get_settings (style_window_rgb); + settings = gtk_widget_get_settings (switcher_style_window_rgba); g_object_get (G_OBJECT (settings), "gtk-double-click-time", &double_click_timeout, NULL); - pango_context = gtk_widget_create_pango_context (style_window_rgb); + switcher_pango_context = gtk_widget_create_pango_context (switcher_style_window_rgba); #ifdef USE_GCONF use_system_font = gconf_client_get_bool (gconf, @@ -525,8 +510,7 @@ init_settings (WnckScreen *screen) button_layout_changed (gconf); #endif - update_style (style_window_rgba); - update_style (style_window_rgb); + update_style (switcher_style_window_rgba); #ifdef USE_GCONF titlebar_font_changed (gconf); #endif @@ -550,7 +534,7 @@ init_settings (WnckScreen *screen) blur_settings_changed (gconf); #endif - (*theme_update_border_extents) (text_height); + (*theme_update_border_extents) (); shadow_property_changed (screen); diff --git a/gtk/window-decorator/style.c b/gtk/window-decorator/style.c index 5090ff6..d25a884 100644 --- a/gtk/window-decorator/style.c +++ b/gtk/window-decorator/style.c @@ -23,7 +23,8 @@ update_style (GtkWidget *widget) } void -style_changed (GtkWidget *widget) +style_changed (PangoContext *context, + GtkWidget *widget) { GdkDisplay *gdkdisplay; GdkScreen *gdkscreen; @@ -35,7 +36,7 @@ style_changed (GtkWidget *widget) update_style (widget); - pango_cairo_context_set_resolution (pango_context, + pango_cairo_context_set_resolution (context, gdk_screen_get_resolution (gdkscreen)); decorations_changed (screen); diff --git a/gtk/window-decorator/switcher.c b/gtk/window-decorator/switcher.c index 6da0475..2962999 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 (style_window_rgba); + style = gtk_widget_get_style (switcher_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 (style_window_rgba); + style = gtk_widget_get_style (switcher_style_window_rgba); cr = gdk_cairo_create (GDK_DRAWABLE (d->buffer_pixmap)); @@ -238,7 +238,7 @@ draw_switcher_foreground (decor_t *d) cairo_move_to (cr, d->width / 2 - w / 2, d->height - switcher_context.bottom_space + - SWITCHER_SPACE / 2 - text_height / 2); + SWITCHER_SPACE / 2 - d->frame->text_height / 2); pango_cairo_show_layout (cr, d->layout); } @@ -346,7 +346,7 @@ update_switcher_window (Window popup, { if (!d->layout) { - d->layout = pango_layout_new (pango_context); + d->layout = pango_layout_new (switcher_pango_context); if (d->layout) pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR); } @@ -399,11 +399,11 @@ update_switcher_window (Window popup, switcher_selected_window = selected; } - pixmap = create_pixmap (width, height, 32); + pixmap = create_pixmap (width, height, switcher_style_window_rgba); if (!pixmap) return FALSE; - buffer_pixmap = create_pixmap (width, height, 32); + buffer_pixmap = create_pixmap (width, height, switcher_style_window_rgb); if (!buffer_pixmap) { g_object_unref (G_OBJECT (pixmap)); diff --git a/gtk/window-decorator/wnck.c b/gtk/window-decorator/wnck.c index 87b2c13..1080b1d 100644 --- a/gtk/window-decorator/wnck.c +++ b/gtk/window-decorator/wnck.c @@ -116,7 +116,7 @@ decorations_changed (WnckScreen *screen) gdkscreen = gdk_display_get_default_screen (gdkdisplay); update_titlebar_font (); - (*theme_update_border_extents) (text_height); + (*theme_update_border_extents) (); update_shadow (); update_default_decorations (gdkscreen); @@ -237,6 +237,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->last_pos_entered = NULL; attr.event_mask = ButtonPressMask | EnterWindowMask | |