summaryrefslogtreecommitdiff
path: root/src/frames.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2001-09-16 00:30:45 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-09-16 00:30:45 +0000
commit39df21227d00fa4c2d37b413a5432c6a36b61d98 (patch)
tree010a3c220b7c184889aacf973fe8d8aa265d2150 /src/frames.c
parent2830c9d74862700fdecd19675e8e5d4432afac38 (diff)
downloadmetacity-39df21227d00fa4c2d37b413a5432c6a36b61d98.tar.gz
metacity-39df21227d00fa4c2d37b413a5432c6a36b61d98.tar.bz2
add support for a mini icon in the titlebar (update_icon): re-enable
2001-09-15 Havoc Pennington <hp@pobox.com> * src/window.c: add support for a mini icon in the titlebar (update_icon): re-enable support for _NET_WM_ICON * src/session.c (save_state): add an ferror check when writing session file
Diffstat (limited to 'src/frames.c')
-rw-r--r--src/frames.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/src/frames.c b/src/frames.c
index cf006f5..22d5fd0 100644
--- a/src/frames.c
+++ b/src/frames.c
@@ -1740,11 +1740,78 @@ meta_frames_expose_event (GtkWidget *widget,
if (frame->layout)
{
+ PangoRectangle layout_rect;
+ int x, y, icon_x, icon_y;
+ GdkPixbuf *icon;
+ int icon_w, icon_h;
+ int area_w, area_h;
+
+#define ICON_TEXT_SPACING 2
+
+ icon = meta_core_get_mini_icon (gdk_display,
+ frame->xwindow);
+
+ icon_w = gdk_pixbuf_get_width (icon);
+ icon_h = gdk_pixbuf_get_height (icon);
+
+ pango_layout_get_pixel_extents (frame->layout,
+ NULL,
+ &layout_rect);
+
+ /* corner of whole title area */
+ x = fgeom.title_rect.x + frames->props->text_border.left;
+ y = fgeom.title_rect.y + frames->props->text_border.top;
+
+ area_w = fgeom.title_rect.width -
+ frames->props->text_border.left -
+ frames->props->text_border.right;
+
+ area_h = fgeom.title_rect.height -
+ frames->props->text_border.top -
+ frames->props->text_border.bottom;
+
+ /* center icon vertically */
+ icon_y = y + MAX ((area_h - icon_h) / 2, 0);
+ /* center text vertically */
+ y = y + MAX ((area_h - layout_rect.height) / 2, 0);
+
+ /* Center icon + text combo */
+ icon_x = x + MAX ((area_w - layout_rect.width - icon_w - ICON_TEXT_SPACING) / 2, 0);
+ x = icon_x + icon_w + ICON_TEXT_SPACING;
+
gdk_gc_set_clip_rectangle (layout_gc, &clip);
+
+ {
+ /* grumble, render_to_drawable_alpha does not accept a clip
+ * mask, so we have to go through some BS
+ */
+ GdkRectangle pixbuf_rect;
+ GdkRectangle draw_rect;
+
+ pixbuf_rect.x = icon_x;
+ pixbuf_rect.y = icon_y;
+ pixbuf_rect.width = icon_w;
+ pixbuf_rect.height = icon_h;
+
+ if (gdk_rectangle_intersect (&clip, &pixbuf_rect, &draw_rect))
+ {
+ gdk_pixbuf_render_to_drawable_alpha (icon,
+ frame->window,
+ draw_rect.x - pixbuf_rect.x,
+ draw_rect.y - pixbuf_rect.y,
+ draw_rect.x, draw_rect.y,
+ draw_rect.width,
+ draw_rect.height,
+ GDK_PIXBUF_ALPHA_FULL,
+ 128,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ }
+ }
+
gdk_draw_layout (frame->window,
layout_gc,
- fgeom.title_rect.x + frames->props->text_border.left,
- fgeom.title_rect.y + frames->props->text_border.top,
+ x, y,
frame->layout);
gdk_gc_set_clip_rectangle (layout_gc, NULL);
}