Around 17 o'clock on Jun 19, Havoc Pennington wrote: > So I think we need to go per-visual. There are two ways I can see to do > that, maybe there are more. (actually, it's per-colormap, so I had to be careful to create only one colormap per visual)... I created a colormap per visual and then attached the frames style to each frame. Reading the gtk_attach_style code, this should create only one style per visual. I also noticed that the gtk_attach_style code did some "funky" things with reference counts, so I had to make sure they stayed correct with an extra ref/unref per frame. Things seem a lot more stable now; I was getting crashes without that; one in front of a rather large group of people watching a presentation. (Uh, sorry, but I don't have a window manager any longer) Oh, and I think I've got the style switching working too; I figured I should re-attach the style to each frame. Seems to work. Here's the current patch; it's a lot less ugly than the last one. Again, it needs the GDK patch I posted to gtk-devel-list to work right. -keith
? changes Index: src/compositor.c =================================================================== RCS file: /cvs/gnome/metacity/src/compositor.c,v retrieving revision 1.8 diff -u -r1.8 compositor.c --- src/compositor.c 26 Dec 2003 02:42:38 -0000 1.8 +++ src/compositor.c 26 Jun 2004 18:28:39 -0000 @@ -194,7 +194,11 @@ if (!(compositor->have_composite && compositor->have_fixes && compositor->have_render && - compositor->have_damage)) + compositor->have_damage && +#ifndef ENABLE_COMPOSITOR + 0 +#endif + )) { meta_topic (META_DEBUG_COMPOSITOR, "Failed to find all extensions needed for compositing manager, disabling compositing manager\n"); g_assert (!compositor->enabled); Index: src/frames.c =================================================================== RCS file: /cvs/gnome/metacity/src/frames.c,v retrieving revision 1.75 diff -u -r1.75 frames.c --- src/frames.c 24 Nov 2003 18:09:47 -0000 1.75 +++ src/frames.c 26 Jun 2004 18:28:40 -0000 @@ -270,7 +270,7 @@ * resize may not actually be needed so we always redraw * in case of color change. */ - gtk_style_set_background (GTK_WIDGET (frames)->style, + gtk_style_set_background (frame->drawable.style, frame->window, GTK_STATE_NORMAL); gdk_window_invalidate_rect (frame->window, NULL, FALSE); meta_core_queue_frame_resize (gdk_display, @@ -315,7 +315,7 @@ * resize may not actually be needed so we always redraw * in case of color change. */ - gtk_style_set_background (GTK_WIDGET (frames)->style, + gtk_style_set_background (frame->drawable.style, frame->window, GTK_STATE_NORMAL); gdk_window_invalidate_rect (frame->window, NULL, FALSE); } @@ -332,11 +332,43 @@ GtkStyle *prev_style) { MetaFrames *frames; + MetaUIFrame *frame; + GSList *winlist; + GSList *tmp; frames = META_FRAMES (widget); meta_frames_font_changed (frames); + winlist = NULL; + g_hash_table_foreach (frames->frames, + listify_func, + &winlist); + /* Copy new style to all frames */ + tmp = winlist; + while (tmp != NULL) + { + MetaUIFrame *frame; + + frame = tmp->data; + + /* + * Detach and deref old style + */ + gtk_style_detach (frame->drawable.style); + g_object_unref (frame->drawable.style); + + /* + * ref and attach new style + */ + frame->drawable.style = g_object_ref (GTK_WIDGET(frames)->style); + frame->drawable.style = gtk_style_attach (frame->drawable.style, + frame->window); + + tmp = tmp->next; + } + g_slist_free (winlist); + GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); } @@ -388,8 +420,8 @@ frame->layout = gtk_widget_create_pango_layout (widget, frame->title); - font_desc = meta_gtk_widget_get_font_desc (widget, scale, - meta_prefs_get_titlebar_font ()); + font_desc = meta_gtk_style_get_font_desc (frame->drawable.style, scale, + meta_prefs_get_titlebar_font ()); size = pango_font_description_get_size (font_desc); @@ -476,12 +508,24 @@ frame->window = window; + frame->drawable.drawable = GDK_DRAWABLE(window); + /* + * Reference the parent style + */ + frame->drawable.style = g_object_ref (GTK_WIDGET(frames)->style); + /* + * Re-realize the style for this visual + * (or not, if the two visuals are the same) + */ + frame->drawable.style = gtk_style_attach (frame->drawable.style, + frame->window); + frame->drawable.widget = GTK_WIDGET(frames); + gdk_window_set_user_data (frame->window, frames); - gtk_style_set_background (GTK_WIDGET (frames)->style, + gtk_style_set_background (frame->drawable.style, frame->window, GTK_STATE_NORMAL); /* Don't set event mask here, it's in frame.c */ - frame->xwindow = xwindow; frame->cache_style = NULL; frame->layout = NULL; @@ -520,6 +564,10 @@ g_hash_table_remove (frames->frames, &frame->xwindow); + gtk_style_detach (frame->drawable.style); + + g_object_unref (frame->drawable.style); + gdk_window_destroy (frame->window); if (frame->layout) @@ -613,7 +661,7 @@ frame = meta_frames_lookup_window (frames, xwindow); - gtk_style_set_background (widget->style, frame->window, GTK_STATE_NORMAL); + gtk_style_set_background (frame->drawable.style, frame->window, GTK_STATE_NORMAL); } static void @@ -1870,8 +1918,7 @@ gdk_window_begin_paint_rect (drawable, &areas[i]); meta_theme_draw_frame (meta_theme_get_current (), - widget, - drawable, + &frame->drawable, &areas[i], 0, 0, type, Index: src/frames.h =================================================================== RCS file: /cvs/gnome/metacity/src/frames.h,v retrieving revision 1.27 diff -u -r1.27 frames.h --- src/frames.h 16 Aug 2003 16:32:10 -0000 1.27 +++ src/frames.h 26 Jun 2004 18:28:40 -0000 @@ -67,6 +67,7 @@ { Window xwindow; GdkWindow *window; + MetaDrawable drawable; MetaFrameStyle *cache_style; PangoLayout *layout; int text_height; Index: src/preview-widget.c =================================================================== RCS file: /cvs/gnome/metacity/src/preview-widget.c,v retrieving revision 1.3 diff -u -r1.3 preview-widget.c --- src/preview-widget.c 4 Oct 2002 02:28:57 -0000 1.3 +++ src/preview-widget.c 26 Jun 2004 18:28:40 -0000 @@ -159,7 +159,7 @@ preview->layout = gtk_widget_create_pango_layout (widget, preview->title); - font_desc = meta_gtk_widget_get_font_desc (widget, scale, NULL); + font_desc = meta_gtk_style_get_font_desc (widget->style, scale, NULL); preview->text_height = meta_pango_font_desc_get_text_height (font_desc, @@ -218,6 +218,7 @@ META_BUTTON_STATE_NORMAL, META_BUTTON_STATE_NORMAL }; + MetaDrawable drawable; g_return_val_if_fail (META_IS_PREVIEW (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -240,9 +241,11 @@ { border_width = GTK_CONTAINER (widget)->border_width; + drawable.drawable = GDK_DRAWABLE(widget->window); + drawable.style = widget->style; + drawable.widget = widget; meta_theme_draw_frame (preview->theme, - widget, - widget->window, + &drawable, &event->area, widget->allocation.x + border_width, widget->allocation.y + border_width, Index: src/theme-viewer.c =================================================================== RCS file: /cvs/gnome/metacity/src/theme-viewer.c,v retrieving revision 1.16 diff -u -r1.16 theme-viewer.c --- src/theme-viewer.c 15 Oct 2003 16:04:12 -0000 1.16 +++ src/theme-viewer.c 26 Jun 2004 18:28:40 -0000 @@ -974,6 +974,7 @@ i = 0; while (i < ITERATIONS) { + MetaDrawable drawable; /* Creating the pixmap in the loop is right, since * GDK does the same with its double buffering. */ @@ -982,9 +983,11 @@ client_height + top_height + bottom_height, -1); + drawable.drawable = GDK_DRAWABLE(pixmap); + drawable.style = widget->style; + drawable.widget = widget; meta_theme_draw_frame (global_theme, - widget, - pixmap, + &drawable, NULL, 0, 0, META_FRAME_TYPE_NORMAL, Index: src/theme.c =================================================================== RCS file: /cvs/gnome/metacity/src/theme.c,v retrieving revision 1.70 diff -u -r1.70 theme.c --- src/theme.c 10 Jan 2004 17:16:06 -0000 1.70 +++ src/theme.c 26 Jun 2004 18:28:42 -0000 @@ -800,7 +800,7 @@ GdkPixbuf* meta_gradient_spec_render (const MetaGradientSpec *spec, - GtkWidget *widget, + MetaDrawable *drawable, int width, int height) { @@ -821,7 +821,7 @@ tmp = spec->color_specs; while (tmp != NULL) { - meta_color_spec_render (tmp->data, widget, &colors[i]); + meta_color_spec_render (tmp->data, drawable, &colors[i]); tmp = tmp->next; ++i; @@ -1186,12 +1186,11 @@ void meta_color_spec_render (MetaColorSpec *spec, - GtkWidget *widget, + MetaDrawable *drawable, GdkColor *color) { g_return_if_fail (spec != NULL); - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (widget->style != NULL); + g_return_if_fail (drawable->style != NULL); switch (spec->type) { @@ -1203,28 +1202,28 @@ switch (spec->data.gtk.component) { case META_GTK_COLOR_BG: - *color = widget->style->bg[spec->data.gtk.state]; + *color = drawable->style->bg[spec->data.gtk.state]; break; case META_GTK_COLOR_FG: - *color = widget->style->fg[spec->data.gtk.state]; + *color = drawable->style->fg[spec->data.gtk.state]; break; case META_GTK_COLOR_BASE: - *color = widget->style->base[spec->data.gtk.state]; + *color = drawable->style->base[spec->data.gtk.state]; break; case META_GTK_COLOR_TEXT: - *color = widget->style->text[spec->data.gtk.state]; + *color = drawable->style->text[spec->data.gtk.state]; break; case META_GTK_COLOR_LIGHT: - *color = widget->style->light[spec->data.gtk.state]; + *color = drawable->style->light[spec->data.gtk.state]; break; case META_GTK_COLOR_DARK: - *color = widget->style->dark[spec->data.gtk.state]; + *color = drawable->style->dark[spec->data.gtk.state]; break; case META_GTK_COLOR_MID: - *color = widget->style->mid[spec->data.gtk.state]; + *color = drawable->style->mid[spec->data.gtk.state]; break; case META_GTK_COLOR_TEXT_AA: - *color = widget->style->text_aa[spec->data.gtk.state]; + *color = drawable->style->text_aa[spec->data.gtk.state]; break; case META_GTK_COLOR_LAST: g_assert_not_reached (); @@ -1236,8 +1235,8 @@ { GdkColor bg, fg; - meta_color_spec_render (spec->data.blend.background, widget, &bg); - meta_color_spec_render (spec->data.blend.foreground, widget, &fg); + meta_color_spec_render (spec->data.blend.background, drawable, &bg); + meta_color_spec_render (spec->data.blend.foreground, drawable, &fg); color_composite (&bg, &fg, spec->data.blend.alpha, color); } @@ -1247,7 +1246,7 @@ { GdkColor base; - meta_color_spec_render (spec->data.shade.base, widget, &base); + meta_color_spec_render (spec->data.shade.base, drawable, &base); gtk_style_shade (&base, &base, spec->data.shade.factor); @@ -2650,8 +2649,7 @@ } static GdkGC* -get_gc_for_primitive (GtkWidget *widget, - GdkDrawable *drawable, +get_gc_for_primitive (MetaDrawable *drawable, MetaColorSpec *color_spec, const GdkRectangle *clip, int line_width) @@ -2660,13 +2658,13 @@ GdkGCValues values; GdkColor color; - meta_color_spec_render (color_spec, widget, &color); + meta_color_spec_render (color_spec, drawable, &color); values.foreground = color; - gdk_rgb_find_color (widget->style->colormap, &values.foreground); + gdk_rgb_find_color (drawable->style->colormap, &values.foreground); values.line_width = line_width; - gc = gdk_gc_new_with_values (drawable, &values, + gc = gdk_gc_new_with_values (drawable->drawable, &values, GDK_GC_FOREGROUND | GDK_GC_LINE_WIDTH); if (clip) @@ -2982,7 +2980,7 @@ static GdkPixbuf* draw_op_as_pixbuf (const MetaDrawOp *op, - GtkWidget *widget, + MetaDrawable *drawable, const MetaDrawInfo *info, int width, int height) @@ -3006,7 +3004,7 @@ GdkColor color; meta_color_spec_render (op->data.rectangle.color_spec, - widget, + drawable, &color); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, @@ -3030,7 +3028,7 @@ gboolean has_alpha; meta_color_spec_render (op->data.rectangle.color_spec, - widget, + drawable, &color); has_alpha = @@ -3073,7 +3071,7 @@ case META_DRAW_GRADIENT: { pixbuf = meta_gradient_spec_render (op->data.gradient.gradient_spec, - widget, width, height); + drawable, width, height); pixbuf = apply_alpha (pixbuf, op->data.gradient.alpha_spec, @@ -3089,7 +3087,7 @@ GdkColor color; meta_color_spec_render (op->data.image.colorize_spec, - widget, &color); + drawable, &color); if (op->data.image.colorize_cache_pixbuf == NULL || op->data.image.colorize_cache_pixel != GDK_COLOR_RGB (color)) @@ -3205,8 +3203,7 @@ static void meta_draw_op_draw_with_env (const MetaDrawOp *op, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, const MetaDrawInfo *info, int x, @@ -3223,7 +3220,7 @@ { int x1, x2, y1, y2; - gc = get_gc_for_primitive (widget, drawable, + gc = get_gc_for_primitive (drawable, op->data.line.color_spec, clip, op->data.line.width); @@ -3242,7 +3239,7 @@ x2 = parse_x_position_unchecked (op->data.line.x2, env); y2 = parse_y_position_unchecked (op->data.line.y2, env); - gdk_draw_line (drawable, gc, x1, y1, x2, y2); + gdk_draw_line (drawable->drawable, gc, x1, y1, x2, y2); g_object_unref (G_OBJECT (gc)); } @@ -3252,7 +3249,7 @@ { int rx, ry, rwidth, rheight; - gc = get_gc_for_primitive (widget, drawable, + gc = get_gc_for_primitive (drawable, op->data.rectangle.color_spec, clip, 0); @@ -3261,7 +3258,7 @@ rwidth = parse_size_unchecked (op->data.rectangle.width, env); rheight = parse_size_unchecked (op->data.rectangle.height, env); - gdk_draw_rectangle (drawable, gc, + gdk_draw_rectangle (drawable->drawable, gc, op->data.rectangle.filled, rx, ry, rwidth, rheight); @@ -3273,7 +3270,7 @@ { int rx, ry, rwidth, rheight; - gc = get_gc_for_primitive (widget, drawable, + gc = get_gc_for_primitive (drawable, op->data.arc.color_spec, clip, 0); @@ -3282,7 +3279,7 @@ rwidth = parse_size_unchecked (op->data.arc.width, env); rheight = parse_size_unchecked (op->data.arc.height, env); - gdk_draw_arc (drawable, + gdk_draw_arc (drawable->drawable, gc, op->data.arc.filled, rx, ry, rwidth, rheight, @@ -3313,11 +3310,11 @@ if (!needs_alpha) { - gc = get_gc_for_primitive (widget, drawable, + gc = get_gc_for_primitive (drawable, op->data.tint.color_spec, clip, 0); - gdk_draw_rectangle (drawable, gc, + gdk_draw_rectangle (drawable->drawable, gc, TRUE, rx, ry, rwidth, rheight); @@ -3327,12 +3324,12 @@ { GdkPixbuf *pixbuf; - pixbuf = draw_op_as_pixbuf (op, widget, info, + pixbuf = draw_op_as_pixbuf (op, drawable, info, rwidth, rheight); if (pixbuf) { - render_pixbuf (drawable, clip, pixbuf, rx, ry); + render_pixbuf (drawable->drawable, clip, pixbuf, rx, ry); g_object_unref (G_OBJECT (pixbuf)); } @@ -3350,12 +3347,12 @@ rwidth = parse_size_unchecked (op->data.gradient.width, env); rheight = parse_size_unchecked (op->data.gradient.height, env); - pixbuf = draw_op_as_pixbuf (op, widget, info, + pixbuf = draw_op_as_pixbuf (op, drawable, info, rwidth, rheight); if (pixbuf) { - render_pixbuf (drawable, clip, pixbuf, rx, ry); + render_pixbuf (drawable->drawable, clip, pixbuf, rx, ry); g_object_unref (G_OBJECT (pixbuf)); } @@ -3376,7 +3373,7 @@ rwidth = parse_size_unchecked (op->data.image.width, env); rheight = parse_size_unchecked (op->data.image.height, env); - pixbuf = draw_op_as_pixbuf (op, widget, info, + pixbuf = draw_op_as_pixbuf (op, drawable, info, rwidth, rheight); if (pixbuf) @@ -3384,7 +3381,7 @@ rx = parse_x_position_unchecked (op->data.image.x, env); ry = parse_y_position_unchecked (op->data.image.y, env); - render_pixbuf (drawable, clip, pixbuf, rx, ry); + render_pixbuf (drawable->drawable, clip, pixbuf, rx, ry); g_object_unref (G_OBJECT (pixbuf)); } @@ -3400,12 +3397,12 @@ rwidth = parse_size_unchecked (op->data.gtk_arrow.width, env); rheight = parse_size_unchecked (op->data.gtk_arrow.height, env); - gtk_paint_arrow (widget->style, - drawable, + gtk_paint_arrow (drawable->style, + drawable->drawable, op->data.gtk_arrow.state, op->data.gtk_arrow.shadow, (GdkRectangle*) clip, - widget, + drawable->widget, "metacity", op->data.gtk_arrow.arrow, op->data.gtk_arrow.filled, @@ -3422,12 +3419,12 @@ rwidth = parse_size_unchecked (op->data.gtk_box.width, env); rheight = parse_size_unchecked (op->data.gtk_box.height, env); - gtk_paint_box (widget->style, - drawable, + gtk_paint_box (drawable->style, + drawable->drawable, op->data.gtk_box.state, op->data.gtk_box.shadow, (GdkRectangle*) clip, - widget, + drawable->widget, "metacity", rx, ry, rwidth, rheight); } @@ -3441,11 +3438,11 @@ ry1 = parse_y_position_unchecked (op->data.gtk_vline.y1, env); ry2 = parse_y_position_unchecked (op->data.gtk_vline.y2, env); - gtk_paint_vline (widget->style, - drawable, + gtk_paint_vline (drawable->style, + drawable->drawable, op->data.gtk_vline.state, (GdkRectangle*) clip, - widget, + drawable->widget, "metacity", ry1, ry2, rx); } @@ -3459,7 +3456,7 @@ rwidth = parse_size_unchecked (op->data.icon.width, env); rheight = parse_size_unchecked (op->data.icon.height, env); - pixbuf = draw_op_as_pixbuf (op, widget, info, + pixbuf = draw_op_as_pixbuf (op, drawable, info, rwidth, rheight); if (pixbuf) @@ -3467,7 +3464,7 @@ rx = parse_x_position_unchecked (op->data.icon.x, env); ry = parse_y_position_unchecked (op->data.icon.y, env); - render_pixbuf (drawable, clip, pixbuf, rx, ry); + render_pixbuf (drawable->drawable, clip, pixbuf, rx, ry); g_object_unref (G_OBJECT (pixbuf)); } @@ -3479,14 +3476,14 @@ { int rx, ry; - gc = get_gc_for_primitive (widget, drawable, + gc = get_gc_for_primitive (drawable, op->data.title.color_spec, clip, 0); rx = parse_x_position_unchecked (op->data.title.x, env); ry = parse_y_position_unchecked (op->data.title.y, env); - gdk_draw_layout (drawable, gc, + gdk_draw_layout (drawable->drawable, gc, rx, ry, info->title_layout); @@ -3504,7 +3501,7 @@ rheight = parse_size_unchecked (op->data.op_list.height, env); meta_draw_op_list_draw (op->data.op_list.op_list, - widget, drawable, clip, info, + drawable, clip, info, rx, ry, rwidth, rheight); } break; @@ -3546,7 +3543,7 @@ while (tile_y < (ry + rheight)) { meta_draw_op_list_draw (op->data.tile.op_list, - widget, drawable, &new_clip, info, + drawable, &new_clip, info, tile_x, tile_y, tile_width, tile_height); tile_y += tile_height; @@ -3562,8 +3559,7 @@ void meta_draw_op_draw (const MetaDrawOp *op, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, const MetaDrawInfo *info, int x, @@ -3575,7 +3571,7 @@ fill_env (&env, info, x, y, width, height); - meta_draw_op_draw_with_env (op, widget, drawable, clip, + meta_draw_op_draw_with_env (op, drawable, clip, info, x, y, width, height, &env); } @@ -3633,8 +3629,7 @@ void meta_draw_op_list_draw (const MetaDrawOpList *op_list, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, const MetaDrawInfo *info, int x, @@ -3693,7 +3688,7 @@ active_clip.height > 0) { meta_draw_op_draw_with_env (op, - widget, drawable, &active_clip, info, + drawable, &active_clip, info, x, y, width, height, &env); } @@ -3981,8 +3976,7 @@ void meta_frame_style_draw (MetaFrameStyle *style, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, int x_offset, int y_offset, const GdkRectangle *clip, @@ -4153,7 +4147,6 @@ if (op_list) meta_draw_op_list_draw (op_list, - widget, drawable, &combined_clip, &draw_info, @@ -4190,7 +4183,6 @@ if (op_list) meta_draw_op_list_draw (op_list, - widget, drawable, &combined_clip, &draw_info, @@ -4807,8 +4799,7 @@ void meta_theme_draw_frame (MetaTheme *theme, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, int x_offset, int y_offset, @@ -4842,7 +4833,6 @@ &fgeom); meta_frame_style_draw (style, - widget, drawable, x_offset, y_offset, clip, @@ -4856,8 +4846,7 @@ void meta_theme_draw_menu_icon (MetaTheme *theme, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, int x_offset, int y_offset, @@ -4871,7 +4860,7 @@ g_return_if_fail (type < META_BUTTON_TYPE_LAST); op_list = get_menu_icon (theme, type, - GTK_WIDGET_STATE (widget)); + GTK_WIDGET_STATE (drawable->widget)); info.mini_icon = NULL; info.icon = NULL; @@ -4881,7 +4870,6 @@ info.fgeom = NULL; meta_draw_op_list_draw (op_list, - widget, drawable, clip, &info, @@ -5148,15 +5136,13 @@ } PangoFontDescription* -meta_gtk_widget_get_font_desc (GtkWidget *widget, +meta_gtk_style_get_font_desc (GtkStyle *style, double scale, const PangoFontDescription *override) { PangoFontDescription *font_desc; - g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), 0); - - font_desc = pango_font_description_copy (widget->style->font_desc); + font_desc = pango_font_description_copy (style->font_desc); if (override) pango_font_description_merge (font_desc, override, TRUE); Index: src/theme.h =================================================================== RCS file: /cvs/gnome/metacity/src/theme.h,v retrieving revision 1.37 diff -u -r1.37 theme.h --- src/theme.h 10 Jan 2004 17:16:07 -0000 1.37 +++ src/theme.h 26 Jun 2004 18:28:42 -0000 @@ -103,6 +103,14 @@ guint bottom_right_corner_rounded : 1; }; +/* Target for drawing */ +typedef struct _MetaDrawable +{ + GdkDrawable *drawable; + GtkStyle *style; + GtkWidget *widget; +} MetaDrawable; + /* Calculated actual geometry of the frame */ struct _MetaFrameGeometry { @@ -626,15 +634,14 @@ GtkStateType state); void meta_color_spec_free (MetaColorSpec *spec); void meta_color_spec_render (MetaColorSpec *spec, - GtkWidget *widget, + MetaDrawable *drawable, GdkColor *color); MetaDrawOp* meta_draw_op_new (MetaDrawType type); void meta_draw_op_free (MetaDrawOp *op); void meta_draw_op_draw (const MetaDrawOp *op, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, const MetaDrawInfo *info, /* logical region being drawn */ @@ -648,8 +655,7 @@ void meta_draw_op_list_ref (MetaDrawOpList *op_list); void meta_draw_op_list_unref (MetaDrawOpList *op_list); void meta_draw_op_list_draw (const MetaDrawOpList *op_list, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, const MetaDrawInfo *info, int x, @@ -666,7 +672,7 @@ MetaGradientSpec* meta_gradient_spec_new (MetaGradientType type); void meta_gradient_spec_free (MetaGradientSpec *desc); GdkPixbuf* meta_gradient_spec_render (const MetaGradientSpec *desc, - GtkWidget *widget, + MetaDrawable *drawable, int width, int height); gboolean meta_gradient_spec_validate (MetaGradientSpec *spec, @@ -682,8 +688,7 @@ void meta_frame_style_unref (MetaFrameStyle *style); void meta_frame_style_draw (MetaFrameStyle *style, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, int x_offset, int y_offset, const GdkRectangle *clip, @@ -728,8 +733,7 @@ MetaFrameFlags flags); void meta_theme_draw_frame (MetaTheme *theme, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, int x_offset, int y_offset, @@ -745,8 +749,7 @@ GdkPixbuf *icon); void meta_theme_draw_menu_icon (MetaTheme *theme, - GtkWidget *widget, - GdkDrawable *drawable, + MetaDrawable *drawable, const GdkRectangle *clip, int x_offset, int y_offset, @@ -813,6 +816,9 @@ /* random stuff */ PangoFontDescription* meta_gtk_widget_get_font_desc (GtkWidget *widget, + double scale, + const PangoFontDescription *override); +PangoFontDescription* meta_gtk_style_get_font_desc (GtkStyle *style, double scale, const PangoFontDescription *override); int meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc, Index: src/ui.c =================================================================== RCS file: /cvs/gnome/metacity/src/ui.c,v retrieving revision 1.56 diff -u -r1.56 ui.c --- src/ui.c 10 Jan 2004 17:16:07 -0000 1.56 +++ src/ui.c 26 Jun 2004 18:28:42 -0000 @@ -39,13 +39,39 @@ static void meta_stock_icons_init (void); +typedef struct _MetaUIColormap +{ + struct _MetaUIColormap *next; + GdkScreen *screen; + GdkVisual *visual; + GdkColormap *cmap; +} MetaUIColormap; + struct _MetaUI { Display *xdisplay; Screen *xscreen; MetaFrames *frames; + MetaUIColormap *cmaps; }; +static GdkColormap * +meta_ui_get_colormap (MetaUI *ui, GdkScreen *screen, GdkVisual *visual) +{ + MetaUIColormap *cmap; + + for (cmap = ui->cmaps; cmap; cmap = cmap->next) + if (cmap->screen == screen && cmap->visual == visual) + return cmap->cmap; + cmap = g_new (MetaUIColormap, 1); + cmap->screen = screen; + cmap->visual = visual; + cmap->cmap = gdk_colormap_new (visual, FALSE); + cmap->next = ui->cmaps; + ui->cmaps = cmap; + return cmap->cmap; +} + void meta_ui_init (int *argc, char ***argv) { @@ -140,6 +166,7 @@ ui = g_new (MetaUI, 1); ui->xdisplay = xdisplay; ui->xscreen = screen; + ui->cmaps = 0; g_assert (xdisplay == gdk_display); ui->frames = meta_frames_new (XScreenNumberOfScreen (screen)); @@ -151,7 +178,16 @@ void meta_ui_free (MetaUI *ui) { + MetaUIColormap *cmap; + gtk_widget_destroy (GTK_WIDGET (ui->frames)); + + while ((cmap = ui->cmaps)) + { + ui->cmaps = cmap->next; + g_object_unref (cmap->cmap); + g_free (cmap); + } g_free (ui); } @@ -183,7 +219,7 @@ gint attributes_mask; GdkWindow *window; GdkVisual *visual; - GdkColormap *cmap = gdk_screen_get_default_colormap (screen); + GdkColormap *cmap; /* Default depth/visual handles clients with weird visuals; they can * always be children of the root depth/visual obviously, but @@ -191,13 +227,16 @@ * visual as the client. */ if (!xvisual) + { visual = gdk_screen_get_system_visual (screen); + cmap = gdk_screen_get_default_colormap (screen); + } else - { - visual = gdk_x11_screen_lookup_visual (screen, - XVisualIDFromVisual (xvisual)); - cmap = gdk_colormap_new (visual, FALSE); - } + { + visual = gdk_x11_screen_lookup_visual (screen, + XVisualIDFromVisual (xvisual)); + cmap = meta_ui_get_colormap (ui, screen, visual); + } attrs.title = NULL;
Attachment:
pgpyLEvmposIT.pgp
Description: PGP signature