For those of you who've tried them, Metacity generates some "interesting" images on the screen when painting the frame for an ARGB window. I discovered the root cause and have kludged a partial fix. The basic problem is that Metacity shares one single "widget" to hold the style for every frame. A cheap hack, which works as long as every frame uses the same visual and colormap, which of course they do except for ARGB windows. I think the correct solution is to give each frame its own style using gtk_style_attach from the shared frames style. However, the problem is that the theme drawing code all passes around the frames widget as a handle to the style and (separately) the GdkDrawable representing the individual frame itself. Instead of rewriting all of the drawing code, I kludged things by replacing the style in the shared frames widget with the frame's style. This actually worked, but it sure looks wrong in the code. Here's the patches; I sent necessary fixes for gdk to gtk-devel-list. This patch is almost certainly missing code necessary to get the per-frame styles updated when the shared frames style is changed. I fear attempting that though. -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 18 Jun 2004 23:09:38 -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 18 Jun 2004 23:09:38 -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->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->style, frame->window, GTK_STATE_NORMAL); gdk_window_invalidate_rect (frame->window, NULL, FALSE); } @@ -476,12 +476,13 @@ frame->window = window; + frame->style = gtk_style_attach (GTK_WIDGET(frames)->style, frame->window); + gdk_window_set_user_data (frame->window, frames); - gtk_style_set_background (GTK_WIDGET (frames)->style, + gtk_style_set_background (frame->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; @@ -613,7 +614,7 @@ frame = meta_frames_lookup_window (frames, xwindow); - gtk_style_set_background (widget->style, frame->window, GTK_STATE_NORMAL); + gtk_style_set_background (frame->style, frame->window, GTK_STATE_NORMAL); } static void @@ -1734,9 +1735,14 @@ int screen_width, screen_height; MetaButtonLayout button_layout; MetaGrabOp grab_op; + + GtkStyle *save_style; widget = GTK_WIDGET (frames); + save_style = widget->style; + widget->style = frame->style; + i = 0; while (i < META_BUTTON_TYPE_LAST) { @@ -1888,6 +1894,8 @@ ++i; } + + widget->style = save_style; gdk_region_destroy (edges); g_free (areas); 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 18 Jun 2004 23:09:38 -0000 @@ -67,6 +67,8 @@ { Window xwindow; GdkWindow *window; + GtkStyle *style; + /* style of frame */ MetaFrameStyle *cache_style; PangoLayout *layout; int text_height; 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 18 Jun 2004 23:09:39 -0000 @@ -183,7 +183,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 +191,16 @@ * visual as the client. */ if (!xvisual) + { visual = gdk_screen_get_system_visual (screen); + cmap = gdk_colormap_ref (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 = gdk_colormap_new (visual, FALSE); + } attrs.title = NULL; @@ -224,6 +227,8 @@ window = gdk_window_new (gdk_screen_get_root_window(screen), &attrs, attributes_mask); + + g_object_unref (cmap); gdk_window_resize (window, width, height);
Attachment:
pgpG1Mcst2yxN.pgp
Description: PGP signature