diff -ur qt-everywhere-opensource-src-4.7.1/src/gui/kernel/qt_x11_p.h qt-everywhere-opensource-src-4.7.1-patched/src/gui/kernel/qt_x11_p.h
--- qt-everywhere-opensource-src-4.7.1/src/gui/kernel/qt_x11_p.h        2010-11-06 12:55:17.000000000 +1100
+++ qt-everywhere-opensource-src-4.7.1-patched/src/gui/kernel/qt_x11_p.h        2011-01-03 22:20:55.000000000 +1100
@@ -60,6 +60,17 @@
 // the following is necessary to work around breakage in many versions
 // of XFree86's Xlib.h still in use
 // ### which versions?
+// NOTE: This issue has been reported against the latest LSB packages (LSB 4.1 beta).
+//       For details, see http://bugs.linuxbase.org/show_bug.cgi?id=3145
+//       The prevalent implementations of XRegisterIMInstantiateCallback and
+//       XUnregisterIMInstantiateCallback are actually consistent with the
+//       function prototypes that LSB's Xlib.h defines, even though this is
+//       inconsistent with the Xlib specification. We therefore must keep
+//       the LSB-defined function prototypes or else client code will pass
+//       invalid data to the fifth and sixth parameters of these two functions.
+#if defined(__LSB_VERSION__)
+#include <X11/Xlib.h>
+#else
 #if defined(_XLIB_H_) // crude hack, but...
 #error "cannot include <X11/Xlib.h> before this file"
 #endif
@@ -70,6 +81,7 @@
 #undef XRegisterIMInstantiateCallback
 #undef XUnregisterIMInstantiateCallback
 #undef XSetIMValues
+#endif
 
 #include <X11/Xutil.h>
 #include <X11/Xos.h>
@@ -253,6 +265,8 @@
 //######### Many old X11R6 header files lack XSetIMValues.
 //######### Therefore, we have to declare these functions ourselves.
 
+// NOTE: LSB versions need to be kept as they are. See comments near top of this file.
+#if !defined(__LSB_VERSION__)
 extern "C" Bool XRegisterIMInstantiateCallback(
     Display*,
     struct _XrmHashBucketRec*,
@@ -272,7 +286,7 @@
 );
 
 extern "C" char *XSetIMValues(XIM /* im */, ...);
-
+#endif  // __LSB_VERSION__
 #endif
 
 #ifndef QT_NO_FONTCONFIG
diff -ur qt-everywhere-opensource-src-4.7.1/src/gui/kernel/qapplication_p.h qt-everywhere-opensource-src-4.7.1-patched/src/gui/kernel/qapplication_p.h
--- qt-everywhere-opensource-src-4.7.1/src/gui/kernel/qapplication_p.h  2010-11-06 12:55:17.000000000 +1100
+++ qt-everywhere-opensource-src-4.7.1-patched/src/gui/kernel/qapplication_p.h  2011-01-04 15:25:38.000000000 +1100
@@ -540,7 +540,18 @@
 #if defined(Q_WS_WIN)
     QPixmap *ignore_cursor;
 #endif
+
+// CursorShape is defined in X11/X.h
+#ifdef CursorShape
+#ifndef X_CursorShape
+#define X_CursorShape 0   // This value is defined in LSB
+#endif
+#undef CursorShape
+#endif
     QPixmap getPixmapCursor(Qt::CursorShape cshape);
+#ifdef X_CursorShape
+#define CursorShape X_CursorShape
+#endif
 
     QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId;
     QMap<int, QTouchEvent::TouchPoint> appCurrentTouchPoints;
diff -ru qt-everywhere-opensource-src-4.7.1/src/corelib/io/qtextstream.h qt-everywhere-opensource-src-4.7.1-patched/src/corelib/io/qtextstream.h
--- qt-everywhere-opensource-src-4.7.1/src/corelib/io/qtextstream.h     2010-11-06 12:55:18.000000000 +1100
+++ qt-everywhere-opensource-src-4.7.1-patched/src/corelib/io/qtextstream.h     2011-01-03 13:42:05.000000000 +1100
@@ -56,7 +56,14 @@

 #include <stdio.h>

+#if defined(__LSB_VERSION__)
+// The X11/Xlib.h LSB header defines Status as an int, but
+// we need to undefine that here since we (unfortunately)
+// re-use that symbol name within QTextStream as an enum type.
 #ifdef Status
+#undef Status
+#endif
+#elif defined(Status)
 #error qtextstream.h must be included before any header file that defines Status
 #endif

@@ -373,4 +380,9 @@

 QT_END_HEADER

+// Ensure we put back the definition of Status if we removed it
+#if defined(__LSB_VERSION__) && defined(_X11_XLIB_H_)
+#define Status  int
+#endif
+
 #endif // QTEXTSTREAM_H
diff -ur qt-everywhere-opensource-src-4.7.1/src/corelib/io/qurl.h qt-everywhere-opensource-src-4.7.1-patched/src/corelib/io/qurl.h
--- qt-everywhere-opensource-src-4.7.1/src/corelib/io/qurl.h    2010-11-06 12:55:18.000000000 +1100
+++ qt-everywhere-opensource-src-4.7.1-patched/src/corelib/io/qurl.h    2011-01-04 16:52:56.000000000 +1100
@@ -65,6 +65,13 @@
         StrictMode
     };
 
+// None is defined in X11/X.h
+#ifdef None
+#if !defined(X_None)
+#define X_None 0L   // This value is defined in both the LSB and Xlib specs
+#endif
+#undef None
+#endif
     // encoding / toString values
     enum FormattingOption {
         None = 0x0,
@@ -81,6 +88,9 @@
         StripTrailingSlash = 0x10000
     };
     Q_DECLARE_FLAGS(FormattingOptions, FormattingOption)
+#if defined(X_None)
+#define None X_None
+#endif
 
     QUrl();
 #ifdef QT_NO_URL_CAST_FROM_STRING
