File compiz-0.8.6-ubuntu.patch of Package compiz

diff -Naur compiz-0.8.6-orig//configure.ac compiz-0.8.6//configure.ac
--- compiz-0.8.6-orig//configure.ac	2010-03-28 19:21:08.000000000 +0700
+++ compiz-0.8.6//configure.ac	2010-10-01 21:39:30.000000000 +0700
@@ -125,6 +125,7 @@
 		 xdamage    \
 		 xrandr	    \
 		 xinerama   \
+		 xcursor    \
 		 ice	    \
 		 sm	    \
 		 libxml-2.0 \
diff -Naur compiz-0.8.6-orig//gtk/window-decorator/gtk-window-decorator.c compiz-0.8.6//gtk/window-decorator/gtk-window-decorator.c
--- compiz-0.8.6-orig//gtk/window-decorator/gtk-window-decorator.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//gtk/window-decorator/gtk-window-decorator.c	2010-10-01 21:40:35.000000000 +0700
@@ -30,14 +30,7 @@
 #include <X11/cursorfont.h>
 #include <X11/extensions/Xrender.h>
 #include <X11/Xregion.h>
-
-#ifndef GDK_DISABLE_DEPRECATED
-#define GDK_DISABLE_DEPRECATED
-#endif
-
-#ifndef GTK_DISABLE_DEPRECATED
-#define GTK_DISABLE_DEPRECATED
-#endif
+#include <X11/Xcursor/Xcursor.h>
 
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
@@ -83,6 +76,14 @@
 #include <metacity-private/theme.h>
 #endif
 
+#define GNOME_MOUSE_DIR "/desktop/gnome/peripherals/mouse"
+
+#define GNOME_CURSOR_THEME_KEY		\
+    GNOME_MOUSE_DIR "/cursor_theme"
+
+#define GNOME_CURSOR_SIZE_KEY		\
+    GNOME_MOUSE_DIR "/cursor_size"
+
 #define METACITY_GCONF_DIR "/apps/metacity/general"
 
 #define COMPIZ_USE_SYSTEM_FONT_KEY		    \
@@ -146,6 +147,16 @@
 #define WHEEL_ACTION_KEY   \
     GCONF_DIR "/mouse_wheel_action"
 
+#define COMPIZ_GCONF_DIR2 "/apps/compiz/general/allscreens/options"
+#define COMPIZ_CURSOR_THEME_KEY          \
+    COMPIZ_GCONF_DIR2 "/cursor_theme"
+
+#define COMPIZ_CURSOR_SIZE_KEY           \
+    COMPIZ_GCONF_DIR2 "/cursor_size"
+
+#define INTERFACE_GCONF_DIR		"/desktop/gnome/interface"
+#define HIDE_DECORATOR_TOOLTIP_KEY	INTERFACE_GCONF_DIR "/hide_decorator_tooltip"
+
 #define DBUS_DEST       "org.freedesktop.compiz"
 #define DBUS_PATH       "/org/freedesktop/compiz/decoration/allscreens"
 #define DBUS_INTERFACE  "org.freedesktop.compiz"
@@ -456,6 +467,8 @@
 static gboolean		    use_system_font = FALSE;
 static gint		    text_height;
 
+static gboolean		    hide_decorator_tooltip = FALSE;
+
 #define BLUR_TYPE_NONE     0
 #define BLUR_TYPE_TITLEBAR 1
 #define BLUR_TYPE_ALL      2
@@ -1902,10 +1915,8 @@
 
     size = MAX (fgeom.top_height, fgeom.bottom_height);
 
-    if (rect.width && size)
+    if (rect.width && size && (pixmap = create_pixmap (rect.width, size)))
     {
-	pixmap = create_pixmap (rect.width, size);
-
 	cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
 	gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
@@ -2004,10 +2015,8 @@
 
     size = MAX (fgeom.left_width, fgeom.right_width);
 
-    if (size && rect.height)
+    if (size && rect.height && (pixmap = create_pixmap (size, rect.height)))
     {
-	pixmap = create_pixmap (size, rect.height);
-
 	cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
 	gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
@@ -3304,9 +3313,12 @@
 	g_object_ref (G_OBJECT (d->icon_pixbuf));
 
 	d->icon_pixmap = pixmap_new_from_pixbuf (d->icon_pixbuf);
-	cr = gdk_cairo_create (GDK_DRAWABLE (d->icon_pixmap));
-	d->icon = cairo_pattern_create_for_surface (cairo_get_target (cr));
-	cairo_destroy (cr);
+	if (d->icon_pixmap)
+	{
+	    cr = gdk_cairo_create (GDK_DRAWABLE (d->icon_pixmap));
+	    d->icon = cairo_pattern_create_for_surface (cairo_get_target (cr));
+	    cairo_destroy (cr);
+	}
     }
 }
 
@@ -4341,6 +4353,9 @@
 		      guint	 state,
 		      const char *tip)
 {
+    if (hide_decorator_tooltip)
+        return;
+
     switch (xevent->type) {
     case ButtonPress:
 	hide_tooltip ();
@@ -6491,6 +6506,44 @@
     return FALSE;
 }
 
+ static void
+cursor_theme_changed (GConfClient *client)
+{
+    gchar *theme;
+    gint size;
+
+    theme = gconf_client_get_string(client, GNOME_CURSOR_THEME_KEY, NULL);
+    size = gconf_client_get_int(client, GNOME_CURSOR_SIZE_KEY, NULL);
+
+    gconf_client_set_string(client, COMPIZ_CURSOR_THEME_KEY, theme, NULL);
+
+    gconf_client_set_int(client, COMPIZ_CURSOR_SIZE_KEY, size, NULL);
+
+    if (theme && strlen(theme))
+    {
+	gint i, j;
+	GdkDisplay *gdkdisplay = gdk_display_get_default ();
+	Display *xdisplay   = gdk_x11_display_get_xdisplay (gdkdisplay);
+
+
+	XcursorSetTheme (xdisplay, theme);
+	XcursorSetDefaultSize (xdisplay, size);
+
+	for (i = 0; i < 3; i++)
+	{
+	    for (j = 0; j < 3; j++)
+	    {
+		if (cursor[i][j].shape != XC_left_ptr)
+		{
+		    XFreeCursor (xdisplay, cursor[i][j].cursor);
+		    cursor[i][j].cursor =
+			XCreateFontCursor (xdisplay, cursor[i][j].shape);
+		}
+	    }
+	}
+    }
+}
+
 static void
 value_changed (GConfClient *client,
 	       const gchar *key,
@@ -6569,6 +6622,17 @@
 	if (theme_opacity_changed (client))
 	    changed = TRUE;
     }
+    else if (strcmp (key, GNOME_CURSOR_THEME_KEY) == 0 ||
+	     strcmp (key, GNOME_CURSOR_SIZE_KEY) == 0)
+    {
+	cursor_theme_changed (client);
+    }
+    else if (strcmp (key, HIDE_DECORATOR_TOOLTIP_KEY) == 0)
+    {
+        hide_decorator_tooltip = gconf_client_get_bool (client,
+							HIDE_DECORATOR_TOOLTIP_KEY,
+ 							NULL);
+    }
 
     if (changed)
 	decorations_changed (data);
@@ -6732,14 +6796,27 @@
 			  NULL);
 
     gconf_client_add_dir (gconf,
+			  GNOME_MOUSE_DIR,
+			  GCONF_CLIENT_PRELOAD_ONELEVEL,
+			  NULL);
+
+    gconf_client_add_dir (gconf,
 			  COMPIZ_GCONF_DIR1,
 			  GCONF_CLIENT_PRELOAD_ONELEVEL,
 			  NULL);
 
+    gconf_client_add_dir (gconf,
+			  INTERFACE_GCONF_DIR,
+			  GCONF_CLIENT_PRELOAD_NONE,
+			  NULL);
+
     g_signal_connect (G_OBJECT (gconf),
 		      "value_changed",
 		      G_CALLBACK (value_changed),
 		      screen);
+
+    cursor_theme_changed(gconf);
+
 #elif USE_DBUS_GLIB
     DBusConnection *connection;
     DBusMessage	   *reply;
@@ -6893,6 +6970,11 @@
     wheel_action_changed (gconf);
     shadow_settings_changed (gconf);
     blur_settings_changed (gconf);
+
+    hide_decorator_tooltip = gconf_client_get_bool (gconf,
+						    HIDE_DECORATOR_TOOLTIP_KEY,
+						    NULL);
+
 #endif
 
     (*theme_update_border_extents) (text_height);
diff -Naur compiz-0.8.6-orig//include/compiz-core.h compiz-0.8.6//include/compiz-core.h
--- compiz-0.8.6-orig//include/compiz-core.h	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//include/compiz-core.h	2010-10-01 21:39:58.000000000 +0700
@@ -219,6 +219,7 @@
 extern Bool       noDetection;
 extern Bool	  useDesktopHints;
 extern Bool       onlyCurrentScreen;
+extern Bool       noFBO;
 
 extern char	**initialPlugins;
 extern int 	nInitialPlugins;
@@ -775,7 +776,10 @@
 #define COMP_DISPLAY_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED      31
 #define COMP_DISPLAY_OPTION_PING_DELAY			     32
 #define COMP_DISPLAY_OPTION_EDGE_DELAY                       33
-#define COMP_DISPLAY_OPTION_NUM				     34
+#define COMP_DISPLAY_OPTION_CURSOR_THEME                     34
+#define COMP_DISPLAY_OPTION_CURSOR_SIZE                      35
+#define COMP_DISPLAY_OPTION_NUM				     36
+
 
 typedef void (*HandleEventProc) (CompDisplay *display,
 				 XEvent	     *event);
@@ -1027,6 +1031,8 @@
 
     GLenum textureFilter;
 
+    Window glIncludeInferiorsOwner;
+
     Window activeWindow;
     Window nextActiveWindow;
 
diff -Naur compiz-0.8.6-orig//kde/window-decorator-kde4/window.h compiz-0.8.6//kde/window-decorator-kde4/window.h
--- compiz-0.8.6-orig//kde/window-decorator-kde4/window.h	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//kde/window-decorator-kde4/window.h	2010-10-01 21:41:31.000000000 +0700
@@ -51,7 +51,7 @@
 
 namespace KWD
 {
-class Window: public QObject, public KDecorationBridgeUnstable {
+class Window: public QObject, public KDecorationBridge {
     Q_OBJECT public:
 
 	enum Type
diff -Naur compiz-0.8.6-orig//libdecoration/decoration.c compiz-0.8.6//libdecoration/decoration.c
--- compiz-0.8.6-orig//libdecoration/decoration.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//libdecoration/decoration.c	2010-10-01 21:39:43.000000000 +0700
@@ -1243,7 +1243,9 @@
     }
 
     /* create pixmap for temporary decorations */
-    d_pixmap = XCreatePixmap (xdisplay, xroot, d_width, d_height, 32);
+    d_pixmap = XCreatePixmap (xdisplay, xroot, 
+                              (d_width % 32) ? d_width : d_width + 1, 
+                              d_height, 32);
     if (!d_pixmap)
     {
 	XFreePixmap (xdisplay, pixmap);
diff -Naur compiz-0.8.6-orig//metadata/core.xml.in.in compiz-0.8.6//metadata/core.xml.in.in
--- compiz-0.8.6-orig//metadata/core.xml.in.in	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//metadata/core.xml.in.in	2010-10-01 21:40:45.000000000 +0700
@@ -35,6 +35,18 @@
 		<min>0</min>
 		<max>10000</max>
 	    </option>
+	    <option name="cursor_theme" type="string">
+		<_short>Cursor theme</_short>
+		<_long>Cursor theme name</_long>
+		<default></default>
+	    </option>
+	    <option name="cursor_size" type="int">
+		<_short>Cursor size</_short>
+		<_long>Size of the cursor</_long>
+		<default>18</default>
+		<min>8</min>
+		<max>128</max>
+	    </option>
 	    <option name="ping_delay" type="int">
 		<_short>Ping Delay</_short>
 		<_long>Interval between ping messages</_long>
@@ -215,7 +227,7 @@
 		    <_long>Number of virtual desktops</_long>
 		    <default>1</default>
 		    <min>1</min>
-		    <max>36</max>
+		    <max>1</max>
 		</option>
 	    </group>
 	    <group>
diff -Naur compiz-0.8.6-orig//metadata/wobbly.xml.in compiz-0.8.6//metadata/wobbly.xml.in
--- compiz-0.8.6-orig//metadata/wobbly.xml.in	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//metadata/wobbly.xml.in	2010-10-01 21:39:25.000000000 +0700
@@ -20,7 +20,7 @@
 	    <option name="snap_inverted" type="bool">
 		<_short>Snap Inverted</_short>
 		<_long>Inverted window snapping</_long>
-		<default>false</default>
+		<default>true</default>
 	    </option>
 	    <option name="shiver" type="bell">
 		<_short>Shiver</_short>
diff -Naur compiz-0.8.6-orig//plugins/decoration.c compiz-0.8.6//plugins/decoration.c
--- compiz-0.8.6-orig//plugins/decoration.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//plugins/decoration.c	2010-10-01 21:39:54.000000000 +0700
@@ -190,6 +190,11 @@
     status = (*w->screen->drawWindow) (w, transform, attrib, region, mask);
     WRAP (ds, w->screen, drawWindow, decorDrawWindow);
 
+    /* we wait to draw dock shadows until we get to the lowest
+       desktop window in the stack */
+    if (w->type & CompWindowTypeDockMask)
+	return status;
+
     if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
 	region = &infiniteRegion;
 
@@ -226,6 +231,65 @@
 					     attrib, mask);
     }
 
+    if (w->type & CompWindowTypeDesktopMask)
+    {
+	/* we only want to draw on the lowest desktop window, find it and see
+	   if we the window we have is it */
+	CompWindow *window = w->screen->windows;
+	for (window = w->screen->windows; window; window = window->next)
+	{
+	    if (window->type & CompWindowTypeDesktopMask)
+	    {
+		if (window == w)
+		    break;
+		else
+		    return status;
+	    }
+	}
+
+	/* drawing dock shadows now */
+	for (window = w->screen->windows; window; window = window->next)
+	{
+	    if (window->type & CompWindowTypeDockMask && !window->destroyed && !window->invisible)
+	    {
+		DECOR_WINDOW (window);
+
+		if (dw->wd && region->numRects)
+		{
+		    WindowDecoration *wd = dw->wd;
+		    REGION	     box;
+		    int		     i;
+
+		    mask |= PAINT_WINDOW_BLEND_MASK;
+
+		    box.rects	 = &box.extents;
+		    box.numRects = 1;
+
+		    window->vCount = window->indexCount = 0;
+
+		    for (i = 0; i < wd->nQuad; i++)
+		    {
+			box.extents = wd->quad[i].box;
+
+			if (box.extents.x1 < box.extents.x2 &&
+			    box.extents.y1 < box.extents.y2)
+			{
+			    (*window->screen->addWindowGeometry) (window,
+								  &wd->quad[i].matrix, 1,
+								  &box,
+								  region);
+			}
+		    }
+
+		    if (window->vCount)
+			(*window->screen->drawWindowTexture) (window,
+							      &wd->decor->texture->texture,
+							      attrib, mask);
+		}
+	    }
+	}
+    }
+
     return status;
 }
 
diff -Naur compiz-0.8.6-orig//plugins/move.c compiz-0.8.6//plugins/move.c
--- compiz-0.8.6-orig//plugins/move.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//plugins/move.c	2010-10-01 21:40:50.000000000 +0700
@@ -124,6 +124,11 @@
     xid = getIntOptionNamed (option, nOption, "window", 0);
 
     w = findWindowAtDisplay (d, xid);
+
+    /* make window stay above fullscreen windows while moving */
+    if (w)
+	updateWindowAttributes (w, CompStackingUpdateModeAboveFullscreen);
+
     if (w && (w->actions & CompWindowActionMoveMask))
     {
 	XRectangle   workArea;
diff -Naur compiz-0.8.6-orig//src/display.c compiz-0.8.6//src/display.c
--- compiz-0.8.6-orig//src/display.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//src/display.c	2010-10-01 21:42:03.000000000 +0700
@@ -41,6 +41,8 @@
 #include <X11/extensions/Xcomposite.h>
 #include <X11/extensions/Xrandr.h>
 #include <X11/extensions/shape.h>
+#include <X11/Xcursor/Xcursor.h>
+#include <X11/cursorfont.h>
 
 #include <compiz-core.h>
 
@@ -474,6 +476,32 @@
     return TRUE;
 }
 
+static void
+compDisplaySetCursorTheme (CompDisplay *display)
+{
+    char *theme = display->opt[COMP_DISPLAY_OPTION_CURSOR_THEME].value.s;
+    int size = display->opt[COMP_DISPLAY_OPTION_CURSOR_SIZE].value.i;
+
+    if (theme && strlen(theme))
+    {
+	CompScreen *s;
+
+	XcursorSetTheme (display->display, theme);
+	XcursorSetDefaultSize (display->display, size);
+	for (s = display->screens; s; s = s->next)
+	{
+	    XFreeCursor (display->display, s->normalCursor);
+	    s->busyCursor = XCreateFontCursor (display->display, XC_watch);
+	    XFlush (display->display);
+
+	    XFreeCursor (display->display, s->normalCursor);
+	    s->normalCursor = XCreateFontCursor (display->display, XC_left_ptr);
+	    XDefineCursor (display->display, s->root, s->normalCursor);
+	    XFlush (display->display);
+	}
+    }
+}
+
 const CompMetadataOptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] = {
     { "abi", "int", 0, 0, 0 },
     { "active_plugins", "list", "<type>string</type>", 0, 0 },
@@ -510,7 +538,9 @@
     { "toggle_window_shaded_key", "key", 0, shade, 0 },
     { "ignore_hints_when_maximized", "bool", 0, 0, 0 },
     { "ping_delay", "int", "<min>1000</min>", 0, 0 },
-    { "edge_delay", "int", "<min>0</min>", 0, 0 }
+    { "edge_delay", "int", "<min>0</min>", 0, 0 },
+    { "cursor_theme", "string", 0, 0, 0 },
+    { "cursor_size", "int", 0, 0, 0 }
 };
 
 CompOption *
@@ -661,6 +691,20 @@
 	    return TRUE;
 	}
 	break;
+    case COMP_DISPLAY_OPTION_CURSOR_THEME:
+	if (compSetStringOption(o, value))
+	{
+	    compDisplaySetCursorTheme(display);
+	    return TRUE;
+	}
+	break;
+    case COMP_DISPLAY_OPTION_CURSOR_SIZE:
+	if (compSetIntOption(o, value))
+	{
+	    compDisplaySetCursorTheme(display);
+	    return TRUE;
+	}
+	break;
     default:
 	if (compSetDisplayOption (display, o, value))
 	    return TRUE;
@@ -1493,6 +1537,8 @@
 			    timeDiff = 0;
 
 			makeScreenCurrent (s);
+			/* make sure X is ready for us to draw */
+			glXWaitX ();
 
 			if (s->slowAnimations)
 			{
@@ -2234,6 +2280,23 @@
 	lastScreen  = ScreenCount (dpy) - 1;
     }
 
+    {
+	XSetWindowAttributes attr;
+	Atom atom;
+
+	attr.override_redirect = TRUE;
+	d->glIncludeInferiorsOwner =
+	    XCreateWindow (dpy, XRootWindow (dpy, 0),
+			   -100, -100, 1, 1, 0,
+			   CopyFromParent, CopyFromParent,
+			   CopyFromParent,
+			   CWOverrideRedirect,
+			   &attr);
+
+	atom = XInternAtom (dpy, "_COMPIZ_GL_INCLUDE_INFERIORS", False);
+	XSetSelectionOwner(dpy, atom, d->glIncludeInferiorsOwner, CurrentTime);
+    }
+
     for (i = firstScreen; i <= lastScreen; i++)
     {
 	Window		     newWmSnOwner = None, newCmSnOwner = None;
diff -Naur compiz-0.8.6-orig//src/event.c compiz-0.8.6//src/event.c
--- compiz-0.8.6-orig//src/event.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//src/event.c	2010-10-01 21:41:06.000000000 +0700
@@ -2073,7 +2073,7 @@
 		focus = allowWindowFocus (w, NO_FOCUS_MASK,
 					  w->screen->x, w->screen->y, 0);
 
-		if (focus == CompFocusDenied)
+		if ((focus == CompFocusDenied || focus == CompFocusPrevent) && (w->type & ~NO_FOCUS_MASK))
 		    stackingMode = CompStackingUpdateModeInitialMapDeniedFocus;
 		else
 		    stackingMode = CompStackingUpdateModeInitialMap;
@@ -2297,32 +2297,50 @@
 
 	    if (w)
 	    {
+		XserverRegion parts = XFixesCreateRegion(de->display, NULL, 0);
+		XRectangle *rects;
+		int nRects;
+
 		w->texture->oldMipmaps = TRUE;
 
+		// Get the damage region
+		XDamageSubtract(de->display, de->damage, None, parts);
+		rects = XFixesFetchRegion(de->display, parts, &nRects);
+		XFixesDestroyRegion(de->display, parts);
+
 		if (w->syncWait)
 		{
-		    if (w->nDamage == w->sizeDamage)
+		    int i;
+
+		    if (w->nDamage + nRects - 1 >= w->sizeDamage)
 		    {
 			w->damageRects = realloc (w->damageRects,
-						  (w->sizeDamage + 1) *
+						  (w->sizeDamage + nRects) *
 						  sizeof (XRectangle));
-			w->sizeDamage += 1;
+			w->sizeDamage += nRects;
 		    }
 
-		    w->damageRects[w->nDamage].x      = de->area.x;
-		    w->damageRects[w->nDamage].y      = de->area.y;
-		    w->damageRects[w->nDamage].width  = de->area.width;
-		    w->damageRects[w->nDamage].height = de->area.height;
-		    w->nDamage++;
+		    for (i = 0; i < nRects; i++)
+		    {
+			w->damageRects[w->nDamage] = rects[i];
+			w->nDamage++;
+		    }
 		}
 		else
 		{
-		    handleWindowDamageRect (w,
-					    de->area.x,
-					    de->area.y,
-					    de->area.width,
-					    de->area.height);
+		    int i;
+
+		    for (i = 0; i < nRects; i++)
+		    {
+			handleWindowDamageRect (w,
+						rects[i].x,
+						rects[i].y,
+						rects[i].width,
+						rects[i].height);
+		    }
 		}
+
+		XFree(rects);
 	    }
 	}
 	else if (d->shapeExtension &&
diff -Naur compiz-0.8.6-orig//src/main.c compiz-0.8.6//src/main.c
--- compiz-0.8.6-orig//src/main.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//src/main.c	2010-10-01 21:42:03.000000000 +0700
@@ -66,6 +66,7 @@
 Bool noDetection = FALSE;
 Bool useDesktopHints = FALSE;
 Bool onlyCurrentScreen = FALSE;
+Bool noFBO = FALSE;
 static Bool debugOutput = FALSE;
 
 #ifdef USE_COW
@@ -74,6 +75,20 @@
 
 CompMetadata coreMetadata;
 
+char *blacklist[] = {
+	"8086:3577", /* Intel 830MG, 845G (LP: #259385) */
+	"8086:2562",
+	"8086:0102", /* Intel Sandybridge Desktop Chipsets (LP: #633376) */
+	"8086:0112",
+	"8086:0122",
+	"8086:0106", /* Intel Sandybridge Mobile Chipsets */
+	"8086:0116",
+	"8086:0126",
+	"8086:010A", /* Intel Sandybridge Server Chipsets */
+
+	NULL
+};
+
 static void
 usage (void)
 {
@@ -87,6 +102,7 @@
 	    "[--keep-desktop-hints] "
 	    "[--loose-binding] "
 	    "[--replace]\n       "
+	    "[--no-fbo] "
 	    "[--sm-disable] "
 	    "[--sm-client-id ID] "
 	    "[--only-current-screen]\n      "
@@ -157,6 +173,28 @@
     return "Unknown";
 }
 
+void
+launchFallbackWM (void)
+{
+    char *fallback = NULL;
+
+    if (getenv ("KDE_FULL_SESSION") != NULL)
+	fallback = "kwin";
+    else if (getenv ("GNOME_DESKTOP_SESSION_ID") != NULL)
+	fallback = "metacity";
+    else if (access ("/usr/bin/xfwm4", F_OK) == 0)
+	fallback = "xfwm4";
+
+    printf ("\nLaunching fallback window manager\n");
+    if (fallback != NULL)
+	execlp (fallback, fallback, "--replace", (char *)NULL);
+    else
+	execlp ("xterm", "xterm", (char *)NULL);
+
+    /* we should never get here but if we do just exit */
+    exit (EXIT_FAILURE);
+}
+
 static void
 signalHandler (int sig)
 {
@@ -166,6 +204,9 @@
     case SIGCHLD:
 	waitpid (-1, &status, WNOHANG | WUNTRACED);
 	break;
+    case SIGSEGV:
+	launchFallbackWM ();
+	break;
     case SIGHUP:
 	restartSignal = TRUE;
 	break;
@@ -259,15 +300,35 @@
     Bool      disableSm = FALSE;
     char      *clientId = NULL;
     char      *refreshRateArg = NULL;
+    char      *command;
 
     programName = argv[0];
     programArgc = argc;
     programArgv = argv;
 
+    if (getenv ("GNOME_DESKTOP_SESSION_ID") != NULL &&
+	strcmp (getenv ("GNOME_DESKTOP_SESSION_ID"), "Failsafe") == 0)
+    {
+	printf ("Detected GNOME failsafe session.\n");
+	launchFallbackWM ();
+    }
+
+    for (i = 0; blacklist[i] != NULL; i++)
+    {
+	asprintf (&command, "lspci -n | grep -q %s", blacklist[i]);
+	if (system(command) == 0)
+	{
+	    printf ("Blacklisted PCI ID %s detected\n", blacklist[i]);
+	    launchFallbackWM ();
+	}
+	free (command);
+    }
+
     signal (SIGHUP, signalHandler);
     signal (SIGCHLD, signalHandler);
     signal (SIGINT, signalHandler);
     signal (SIGTERM, signalHandler);
+    signal (SIGSEGV, signalHandler);
 
     emptyRegion.rects = &emptyRegion.extents;
     emptyRegion.numRects = 0;
@@ -286,6 +347,13 @@
 
     memset (&ctx, 0, sizeof (ctx));
 
+    /* if no options are passed run with defaults */
+    if (argc == 1)
+    {
+	useDesktopHints = FALSE;
+	replaceCurrentWm = TRUE;
+    }
+
     for (i = 1; i < argc; i++)
     {
 	if (!strcmp (argv[i], "--help"))
@@ -346,6 +414,10 @@
 	{
 	    onlyCurrentScreen = TRUE;
 	}
+	else if (!strcmp (argv[i], "--no-fbo"))
+	{
+		noFBO = TRUE;
+	}
 
 #ifdef USE_COW
 	else if (!strcmp (argv[i], "--use-root-window"))
@@ -388,6 +460,16 @@
 	}
     }
 
+    /* add in default plugins if none are given */
+    if (nPlugin == 0)
+    {
+        plugin[nPlugin++] = "ccp";
+        plugin[nPlugin++] = "move";
+        plugin[nPlugin++] = "resize";
+        plugin[nPlugin++] = "place";
+        plugin[nPlugin++] = "decoration";
+    }
+
     if (refreshRateArg)
     {
 	ctx.refreshRateData = malloc (strlen (refreshRateArg) + 256);
@@ -459,10 +541,20 @@
     coreInitialized = TRUE;
 
     if (!disableSm)
+    {
+	if (clientId == NULL)
+	{
+	    char *desktop_autostart_id = getenv ("DESKTOP_AUTOSTART_ID");
+	    if (desktop_autostart_id != NULL)
+		clientId = strdup (desktop_autostart_id);
+	    unsetenv ("DESKTOP_AUTOSTART_ID");
+	}
+
 	initSession (clientId);
+    }
 
     if (!addDisplay (displayName))
-	return 1;
+	launchFallbackWM ();
 
     eventLoop ();
 
diff -Naur compiz-0.8.6-orig//src/paint.c compiz-0.8.6//src/paint.c
--- compiz-0.8.6-orig//src/paint.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//src/paint.c	2010-10-01 21:40:15.000000000 +0700
@@ -262,6 +262,7 @@
     CompTransform vTransform;
     int           offX, offY;
     Region        clip = region;
+    int           dontcare;
 
     if (!tmpRegion)
     {
@@ -341,8 +342,14 @@
 		    XSubtractRegion (tmpRegion, w->region, tmpRegion);
 
 		/* unredirect top most fullscreen windows. */
+		/* if the fullscreen window is gnome-screensaver and we're
+		   on nvidia we want to always unredirect even if this
+		   option is disabled to work around LP #160264 */
 		if (count == 0 &&
-		    screen->opt[COMP_SCREEN_OPTION_UNREDIRECT_FS].value.b)
+		    (screen->opt[COMP_SCREEN_OPTION_UNREDIRECT_FS].value.b ||
+		    (w->resName && !strcmp(w->resName, "gnome-screensaver") &&
+		    XQueryExtension (screen->display->display, "NV-GLX",
+				     &dontcare, &dontcare, &dontcare))))
 		{
 		    if (XEqualRegion (w->region, &screen->region) &&
 			!REGION_NOT_EMPTY (tmpRegion))
diff -Naur compiz-0.8.6-orig//src/screen.c compiz-0.8.6//src/screen.c
--- compiz-0.8.6-orig//src/screen.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//src/screen.c	2010-10-01 21:41:19.000000000 +0700
@@ -1722,7 +1722,7 @@
     Window		 *children;
     unsigned int	 nchildren;
     int			 defaultDepth, nvisinfo, nElements, value, i;
-    const char		 *glxExtensions, *glExtensions;
+    const char		 *glxExtensions, *glExtensions, *glRenderer;
     XSetWindowAttributes attrib;
     GLfloat		 globalAmbient[]  = { 0.1f, 0.1f,  0.1f, 0.1f };
     GLfloat		 ambientLight[]   = { 0.0f, 0.0f,  0.0f, 0.0f };
@@ -1989,6 +1989,34 @@
     glxExtensions = glXQueryExtensionsString (dpy, screenNum);
     if (!strstr (glxExtensions, "GLX_EXT_texture_from_pixmap"))
     {
+	/* try again with indirect rendering */
+	if (!indirectRendering)
+	{
+	    char **copy;
+
+	    copy = (char **)malloc ((programArgc + 2) * sizeof (char *));
+	    for (i = 0; i < programArgc; i++)
+	    {
+		copy[i] = strdup (programArgv[i]);
+	    }
+	    copy[i++] = "--indirect-rendering";
+	    copy[i] = NULL;
+	    execvp (programName, copy);
+
+	    /* if we made it here execvp failed */
+	    for (i = 0; copy[i] != NULL; i++)
+	    {
+		free (copy[i]);
+	    }
+	    free (copy);
+
+	    compLogMessage ("core", CompLogLevelFatal,
+			    "Failed to launch with --indirect-rendering");
+	    XFree (visinfo);
+
+	    return FALSE;
+	}
+
 	compLogMessage ("core", CompLogLevelFatal,
 			"GLX_EXT_texture_from_pixmap is missing");
 	XFree (visinfo);
@@ -2074,6 +2102,16 @@
 	return FALSE;
     }
 
+    glRenderer = (const char *) glGetString (GL_RENDERER);
+    if (glRenderer != NULL &&
+	(strcmp (glRenderer, "Software Rasterizer") == 0 ||
+	 strcmp (glRenderer, "Mesa X11") == 0))
+    {
+	compLogMessage ("core", CompLogLevelFatal,
+			"Software rendering detected.");
+	return FALSE;
+    }
+
     s->textureNonPowerOfTwo = 0;
     if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
 	s->textureNonPowerOfTwo = 1;
@@ -2183,7 +2221,7 @@
     s->generateMipmap         = NULL;
 
     s->fbo = 0;
-    if (strstr (glExtensions, "GL_EXT_framebuffer_object"))
+    if (!noFBO && strstr (glExtensions, "GL_EXT_framebuffer_object"))
     {
 	s->genFramebuffers = (GLGenFramebuffersProc)
 	    getProcAddress (s, "glGenFramebuffersEXT");
diff -Naur compiz-0.8.6-orig//src/texture.c compiz-0.8.6//src/texture.c
--- compiz-0.8.6-orig//src/texture.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//src/texture.c	2010-10-01 21:41:19.000000000 +0700
@@ -33,6 +33,8 @@
 
 #include <compiz-core.h>
 
+void launchFallbackWM (void);
+
 static CompMatrix _identity_matrix = {
     1.0f, 0.0f,
     0.0f, 1.0f,
@@ -244,13 +246,21 @@
     CompFBConfig *config = &screen->glxPixmapFBConfigs[depth];
     int          attribs[7], i = 0;
 
+    if (width > screen->maxTextureSize || height > screen->maxTextureSize)
+    {
+	compLogMessage ("core", CompLogLevelWarn,
+			"Exceeded max texture size");
+
+	launchFallbackWM ();
+    }
+
     if (!config->fbConfig)
     {
 	compLogMessage ("core", CompLogLevelWarn,
 			"No GLXFBConfig for depth %d",
 			depth);
 
-	return FALSE;
+	launchFallbackWM ();
     }
 
     attribs[i++] = GLX_TEXTURE_FORMAT_EXT;
@@ -295,7 +305,7 @@
 	compLogMessage ("core", CompLogLevelWarn,
 			"glXCreatePixmap failed");
 
-	return FALSE;
+	launchFallbackWM ();
     }
 
     if (!target)
@@ -345,7 +355,7 @@
 	(*screen->destroyPixmap) (screen->display->display, texture->pixmap);
 	texture->pixmap = None;
 
-	return FALSE;
+	launchFallbackWM ();
     }
 
     if (!texture->name)
diff -Naur compiz-0.8.6-orig//src/window.c compiz-0.8.6//src/window.c
--- compiz-0.8.6-orig//src/window.c	2010-03-28 19:15:35.000000000 +0700
+++ compiz-0.8.6//src/window.c	2010-10-01 21:41:01.000000000 +0700
@@ -2207,7 +2207,7 @@
 	XUnionRegion (&rect, w->region, w->region);
 
 	w->damage = XDamageCreate (d->display, id,
-				   XDamageReportRawRectangles);
+				   XDamageReportNonEmpty);
 
 	/* need to check for DisplayModal state on all windows */
 	w->state = getWindowState (d, w->id);
openSUSE Build Service is sponsored by