src/core/display.c (meta_display_open), fetch & use composite version, for

2008-01-28  Michael Meeks  <michael.meeks@novell.com>

        * src/core/display.c (meta_display_open),
        * src/core/compositor.c: fetch & use composite
        version, for remote screens that don't match the
        compile system's version.
        (meta_compositor_manage_screen): bin erroneous FIXME.
        (add_win): remove common warning churn for (very)
        transient windows


svn path=/trunk/; revision=3550
This commit is contained in:
Michael Meeks 2008-02-04 15:57:07 +00:00 committed by Michael Meeks
parent a9a69ac807
commit 2f43d436c8
4 changed files with 154 additions and 82 deletions

View File

@ -1,3 +1,13 @@
2008-01-28 Michael Meeks <michael.meeks@novell.com>
* src/core/display.c (meta_display_open),
* src/core/compositor.c: fetch & use composite
version, for remote screens that don't match the
compile system's version.
(meta_compositor_manage_screen): bin erroneous FIXME.
(add_win): remove common warning churn for (very)
transient windows
2008-02-03 Thomas Thurman <tthurman@gnome.org> 2008-02-03 Thomas Thurman <tthurman@gnome.org>
* tools/patch-wrangler.py: another program I use for maintenance * tools/patch-wrangler.py: another program I use for maintenance

View File

@ -55,6 +55,20 @@
#define USE_IDLE_REPAINT 1 #define USE_IDLE_REPAINT 1
static inline gboolean
composite_at_least_version (MetaDisplay *display,
int maj, int minor)
{
return (display->composite_major_version > maj
|| (display->composite_major_version == maj
&& display->composite_minor_version >= minor));
}
#define have_name_window_pixmap(display) \
composite_at_least_version (display, 0, 2)
#define have_cow(display) \
composite_at_least_version (display, 0, 3)
typedef enum _MetaCompWindowType typedef enum _MetaCompWindowType
{ {
META_COMP_WINDOW_NORMAL, META_COMP_WINDOW_NORMAL,
@ -893,11 +907,14 @@ get_window_picture (MetaCompWindow *cw)
meta_error_trap_push (display); meta_error_trap_push (display);
#ifdef HAVE_NAME_WINDOW_PIXMAP #ifdef HAVE_NAME_WINDOW_PIXMAP
if (cw->back_pixmap == None) if (have_name_window_pixmap (display))
cw->back_pixmap = XCompositeNameWindowPixmap (display->xdisplay, cw->id); {
if (cw->back_pixmap == None)
if (cw->back_pixmap != None) cw->back_pixmap = XCompositeNameWindowPixmap (display->xdisplay, cw->id);
draw = cw->back_pixmap;
if (cw->back_pixmap != None)
draw = cw->back_pixmap;
}
#endif #endif
format = get_window_format (cw); format = get_window_format (cw);
@ -1049,16 +1066,21 @@ paint_windows (MetaScreen *screen,
int x, y, wid, hei; int x, y, wid, hei;
#ifdef HAVE_NAME_WINDOW_PIXMAP #ifdef HAVE_NAME_WINDOW_PIXMAP
x = cw->attrs.x; if (have_name_window_pixmap (display))
y = cw->attrs.y; {
wid = cw->attrs.width + cw->attrs.border_width * 2; x = cw->attrs.x;
hei = cw->attrs.height + cw->attrs.border_width * 2; y = cw->attrs.y;
#else wid = cw->attrs.width + cw->attrs.border_width * 2;
x = cw->attrs.x + cw->attrs.border_width; hei = cw->attrs.height + cw->attrs.border_width * 2;
y = cw->attrs.y + cw->attrs.border_width; }
wid = cw->attrs.width; else
hei = cw->attrs.height;
#endif #endif
{
x = cw->attrs.x + cw->attrs.border_width;
y = cw->attrs.y + cw->attrs.border_width;
wid = cw->attrs.width;
hei = cw->attrs.height;
}
XFixesSetPictureClipRegion (xdisplay, root_buffer, XFixesSetPictureClipRegion (xdisplay, root_buffer,
0, 0, paint_region); 0, 0, paint_region);
@ -1135,16 +1157,21 @@ paint_windows (MetaScreen *screen,
{ {
int x, y, wid, hei; int x, y, wid, hei;
#ifdef HAVE_NAME_WINDOW_PIXMAP #ifdef HAVE_NAME_WINDOW_PIXMAP
x = cw->attrs.x; if (have_name_window_pixmap (display))
y = cw->attrs.y; {
wid = cw->attrs.width + cw->attrs.border_width * 2; x = cw->attrs.x;
hei = cw->attrs.height + cw->attrs.border_width * 2; y = cw->attrs.y;
#else wid = cw->attrs.width + cw->attrs.border_width * 2;
x = cw->attrs.x + cw->attrs.border_width; hei = cw->attrs.height + cw->attrs.border_width * 2;
y = cw->attrs.y + cw->attrs.border_width; }
wid = cw->attrs.width; else
hei = cw->attrs.height;
#endif #endif
{
x = cw->attrs.x + cw->attrs.border_width;
y = cw->attrs.y + cw->attrs.border_width;
wid = cw->attrs.width;
hei = cw->attrs.height;
}
XRenderComposite (xdisplay, PictOpOver, cw->picture, XRenderComposite (xdisplay, PictOpOver, cw->picture,
cw->alpha_pict, root_buffer, 0, 0, 0, 0, cw->alpha_pict, root_buffer, 0, 0, 0, 0,
@ -1350,17 +1377,20 @@ free_win (MetaCompWindow *cw,
MetaCompScreen *info = cw->screen->compositor_data; MetaCompScreen *info = cw->screen->compositor_data;
#ifdef HAVE_NAME_WINDOW_PIXMAP #ifdef HAVE_NAME_WINDOW_PIXMAP
/* See comment in map_win */ if (have_name_window_pixmap (display))
if (cw->back_pixmap && destroy)
{ {
XFreePixmap (display->xdisplay, cw->back_pixmap); /* See comment in map_win */
cw->back_pixmap = None; if (cw->back_pixmap && destroy)
} {
XFreePixmap (display->xdisplay, cw->back_pixmap);
if (cw->shaded_back_pixmap && destroy) cw->back_pixmap = None;
{ }
XFreePixmap (display->xdisplay, cw->shaded_back_pixmap);
cw->shaded_back_pixmap = None; if (cw->shaded_back_pixmap && destroy)
{
XFreePixmap (display->xdisplay, cw->shaded_back_pixmap);
cw->shaded_back_pixmap = None;
}
} }
#endif #endif
@ -1615,7 +1645,6 @@ add_win (MetaScreen *screen,
if (!XGetWindowAttributes (display->xdisplay, xwindow, &cw->attrs)) if (!XGetWindowAttributes (display->xdisplay, xwindow, &cw->attrs))
{ {
g_warning ("Could not get attrs");
g_free (cw); g_free (cw);
return; return;
} }
@ -1807,25 +1836,28 @@ resize_win (MetaCompWindow *cw,
if (cw->attrs.width != width || cw->attrs.height != height) if (cw->attrs.width != width || cw->attrs.height != height)
{ {
#ifdef HAVE_NAME_WINDOW_PIXMAP #ifdef HAVE_NAME_WINDOW_PIXMAP
if (cw->shaded_back_pixmap) if (have_name_window_pixmap (display))
{ {
XFreePixmap (xdisplay, cw->shaded_back_pixmap); if (cw->shaded_back_pixmap)
cw->shaded_back_pixmap = None;
}
if (cw->back_pixmap)
{
/* If the window is shaded, we store the old backing pixmap
so we can return a proper image of the window */
if (cw->window && cw->window->shaded)
{ {
cw->shaded_back_pixmap = cw->back_pixmap; XFreePixmap (xdisplay, cw->shaded_back_pixmap);
cw->back_pixmap = None; cw->shaded_back_pixmap = None;
} }
else
if (cw->back_pixmap)
{ {
XFreePixmap (xdisplay, cw->back_pixmap); /* If the window is shaded, we store the old backing pixmap
cw->back_pixmap = None; so we can return a proper image of the window */
if (cw->window && cw->window->shaded)
{
cw->shaded_back_pixmap = cw->back_pixmap;
cw->back_pixmap = None;
}
else
{
XFreePixmap (xdisplay, cw->back_pixmap);
cw->back_pixmap = None;
}
} }
} }
#endif #endif
@ -2271,24 +2303,31 @@ meta_compositor_remove_window (MetaCompositor *compositor,
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
#endif #endif
} }
#ifdef HAVE_COW
static void static void
show_overlay_window (MetaScreen *screen, show_overlay_window (MetaScreen *screen,
Window cow) Window cow)
{ {
MetaDisplay *display = screen->display; MetaDisplay *display = screen->display;
XserverRegion region;
region = XFixesCreateRegion (display->xdisplay, NULL, 0); #ifdef HAVE_COW
if (have_cow (display))
{
XserverRegion region;
XFixesSetWindowShapeRegion (display->xdisplay, cow, ShapeBounding, 0, 0, 0); region = XFixesCreateRegion (display->xdisplay, NULL, 0);
XFixesSetWindowShapeRegion (display->xdisplay, cow, ShapeInput, 0, 0, region);
XFixesSetWindowShapeRegion (display->xdisplay, cow, ShapeBounding, 0, 0, 0);
XFixesDestroyRegion (display->xdisplay, region); XFixesSetWindowShapeRegion (display->xdisplay, cow, ShapeInput, 0, 0, region);
damage_screen (screen); XFixesDestroyRegion (display->xdisplay, region);
damage_screen (screen);
}
#endif
} }
#if 0
static void static void
hide_overlay_window (MetaScreen *screen, hide_overlay_window (MetaScreen *screen,
Window cow) Window cow)
@ -2302,19 +2341,28 @@ hide_overlay_window (MetaScreen *screen,
0, 0, region); 0, 0, region);
XFixesDestroyRegion (display->xdisplay, region); XFixesDestroyRegion (display->xdisplay, region);
} }
#endif
static Window static Window
get_overlay_window (MetaScreen *screen) get_output_window (MetaScreen *screen)
{ {
MetaDisplay *display = screen->display; MetaDisplay *display = screen->display;
Window cow; Window output;
cow = XCompositeGetOverlayWindow (display->xdisplay, screen->xroot); #ifdef HAVE_COW
XSelectInput (display->xdisplay, cow, ExposureMask); if (have_cow (display))
{
return cow; output = XCompositeGetOverlayWindow (display->xdisplay, screen->xroot);
} XSelectInput (display->xdisplay, output, ExposureMask);
}
else
#endif #endif
{
output = screen->xroot;
}
return output;
}
void void
meta_compositor_manage_screen (MetaCompositor *compositor, meta_compositor_manage_screen (MetaCompositor *compositor,
@ -2331,7 +2379,6 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
return; return;
gdk_error_trap_push (); gdk_error_trap_push ();
/* FIXME: Use correct composite mode */
XCompositeRedirectSubwindows (display->xdisplay, screen->xroot, XCompositeRedirectSubwindows (display->xdisplay, screen->xroot,
CompositeRedirectManual); CompositeRedirectManual);
XSync (display->xdisplay, FALSE); XSync (display->xdisplay, FALSE);
@ -2357,11 +2404,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
return; return;
} }
#ifdef HAVE_COW info->output = get_output_window (screen);
info->output = get_overlay_window (screen);
#else
info->output = screen->xroot;
#endif
pa.subwindow_mode = IncludeInferiors; pa.subwindow_mode = IncludeInferiors;
info->root_picture = XRenderCreatePicture (display->xdisplay, info->output, info->root_picture = XRenderCreatePicture (display->xdisplay, info->output,
@ -2394,12 +2437,9 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
meta_screen_set_cm_selection (screen); meta_screen_set_cm_selection (screen);
#ifdef HAVE_COW
/* Now we're up and running we can show the output if needed */ /* Now we're up and running we can show the output if needed */
show_overlay_window (screen, info->output); show_overlay_window (screen, info->output);
#endif #endif
#endif
} }
void void
@ -2596,12 +2636,15 @@ meta_compositor_get_window_pixmap (MetaCompositor *compositor,
return None; return None;
#ifdef HAVE_NAME_WINDOW_PIXMAP #ifdef HAVE_NAME_WINDOW_PIXMAP
if (window->shaded) if (have_name_window_pixmap (window->display))
return cw->shaded_back_pixmap; {
if (window->shaded)
return cw->shaded_back_pixmap;
else
return cw->back_pixmap;
}
else else
return cw->back_pixmap;
#else
return None;
#endif #endif
return None;
#endif #endif
} }

View File

@ -752,11 +752,28 @@ meta_display_open (void)
display->composite_event_base = 0; display->composite_event_base = 0;
} }
else else
display->have_composite = TRUE; {
display->composite_major_version = 0;
display->composite_minor_version = 0;
if (XCompositeQueryVersion (display->xdisplay,
&display->composite_major_version,
&display->composite_minor_version))
{
display->have_composite = TRUE;
}
else
{
display->composite_major_version = 0;
display->composite_minor_version = 0;
}
}
meta_verbose ("Attempted to init Composite, found error base %d event base %d\n", meta_verbose ("Attempted to init Composite, found error base %d event base %d "
"extn ver %d %d\n",
display->composite_error_base, display->composite_error_base,
display->composite_event_base); display->composite_event_base,
display->composite_major_version,
display->composite_minor_version);
display->have_damage = FALSE; display->have_damage = FALSE;

View File

@ -357,6 +357,8 @@ struct _MetaDisplay
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
int composite_event_base; int composite_event_base;
int composite_error_base; int composite_error_base;
int composite_major_version;
int composite_minor_version;
int damage_event_base; int damage_event_base;
int damage_error_base; int damage_error_base;
int xfixes_event_base; int xfixes_event_base;