<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">qt-bugs@ issue :
bugs.kde.org number :
applied: no
author: Dirk Mueller &lt;mueller@kde.org&gt;

support xrandr 1.2 configurations. same patch like for trunk qt-copy,
please see there for details.


--- src/kernel/qdesktopwidget_x11.cpp
+++ src/kernel/qdesktopwidget_x11.cpp
@@ -107,7 +107,7 @@ QDesktopWidgetPrivate::~QDesktopWidgetPr
 	    screens[i] = 0;
 	}
 
-	delete [] screens;
+	free(screens);
     }
 
     if ( rects )     delete [] rects;
@@ -117,6 +117,8 @@ QDesktopWidgetPrivate::~QDesktopWidgetPr
 void QDesktopWidgetPrivate::init()
 {
     // get the screen count
+    int newScreenCount;
+
 #ifndef QT_NO_XINERAMA
     XineramaScreenInfo *xinerama_screeninfo = 0;
     int unused;
@@ -126,23 +128,26 @@ void QDesktopWidgetPrivate::init()
 
     if (use_xinerama) {
 	xinerama_screeninfo =
-	    XineramaQueryScreens(QPaintDevice::x11AppDisplay(), &amp;screenCount);
+	    XineramaQueryScreens(QPaintDevice::x11AppDisplay(), &amp;newScreenCount);
+
+    if (xinerama_screeninfo)
 	defaultScreen = 0;
     } else
 #endif // QT_NO_XINERAMA
     {
 	defaultScreen = DefaultScreen(QPaintDevice::x11AppDisplay());
-	screenCount = ScreenCount(QPaintDevice::x11AppDisplay());
+	newScreenCount = ScreenCount(QPaintDevice::x11AppDisplay());
+        use_xinerama = false;
     }
 
     delete [] rects;
-    rects     = new QRect[ screenCount ];
+    rects     = new QRect[ newScreenCount ];
     delete [] workareas;
-    workareas = new QRect[ screenCount ];
+    workareas = new QRect[ newScreenCount ];
 
     // get the geometry of each screen
-    int i, x, y, w, h;
-    for ( i = 0; i &lt; screenCount; i++ ) {
+    int i, j, x, y, w, h;
+    for ( i = 0, j = 0; i &lt; newScreenCount; i++ ) {
 
 #ifndef QT_NO_XINERAMA
 	if (use_xinerama) {
@@ -159,11 +164,33 @@ void QDesktopWidgetPrivate::init()
 		h = HeightOfScreen(ScreenOfDisplay(QPaintDevice::x11AppDisplay(), i));
 	    }
 
-	rects[i].setRect(x, y, w, h);
 	workareas[i] = QRect();
+	rects[j].setRect(x, y, w, h);
+
+        // overlapping?
+        if (j &gt; 0 &amp;&amp; rects[j-1].intersects(rects[j])) {
+            // pick the bigger one, ignore the other
+            if ((rects[j].width()*rects[j].height()) &gt;
+                (rects[j-1].width()*rects[j-1].height()))
+            rects[j-1] = rects[j];
+        }
+        else
+            j++;
     }
 
+    if (screens) {
+        // leaks QWidget* pointers on purpose, can't delete them as pointer escapes
+        screens = (QWidget**) realloc(screens, j * sizeof(QWidget*));
+        if (j &gt; screenCount)
+            memset(&amp;screens[screenCount], 0, (j-screenCount) * sizeof(QWidget*));
+    }
+
+    screenCount = j;
+
 #ifndef QT_NO_XINERAMA
+    if (use_xinerama &amp;&amp; screenCount == 1)
+        use_xinerama = false;
+
     if (xinerama_screeninfo)
 	XFree(xinerama_screeninfo);
 #endif // QT_NO_XINERAMA
@@ -216,8 +243,7 @@ QWidget *QDesktopWidget::screen( int scr
 	screen = d-&gt;defaultScreen;
 
     if ( ! d-&gt;screens ) {
-	d-&gt;screens = new QWidget*[ d-&gt;screenCount ];
-	memset( d-&gt;screens, 0, d-&gt;screenCount * sizeof( QWidget * ) );
+	d-&gt;screens = (QWidget**) calloc( d-&gt;screenCount, sizeof(QWidget*));
 	d-&gt;screens[ d-&gt;defaultScreen ] = this;
     }
 
</pre></body></html>