LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File use-xrandr-1.2.diff of Package qt3 (Project openSUSE:Factory)

qt-bugs@ issue :
bugs.kde.org number :
applied: no
author: Dirk Mueller <mueller@kde.org>

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;
@@ -119,30 +119,33 @@ void QDesktopWidgetPrivate::init()
     // get the screen count
 #ifndef QT_NO_XINERAMA
     XineramaScreenInfo *xinerama_screeninfo = 0;
-    int unused;
+    int unused, newScreenCount;
     use_xinerama = (XineramaQueryExtension(QPaintDevice::x11AppDisplay(),
 					   &unused, &unused) &&
 		    XineramaIsActive(QPaintDevice::x11AppDisplay()));
 
     if (use_xinerama) {
 	xinerama_screeninfo =
-	    XineramaQueryScreens(QPaintDevice::x11AppDisplay(), &screenCount);
+	    XineramaQueryScreens(QPaintDevice::x11AppDisplay(), &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 < screenCount; i++ ) {
+    int i, j, x, y, w, h;
+    for ( i = 0, j = 0; i < newScreenCount; i++ ) {
 
 #ifndef QT_NO_XINERAMA
 	if (use_xinerama) {
@@ -159,11 +162,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 > 0 && rects[j-1].intersects(rects[j])) {
+            // pick the bigger one, ignore the other
+            if ((rects[j].width()*rects[j].height()) >
+                (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 > screenCount)
+            memset(&screens[screenCount], 0, (j-screenCount) * sizeof(QWidget*));
+    }
+
+    screenCount = j;
+
 #ifndef QT_NO_XINERAMA
+    if (use_xinerama && screenCount == 1)
+        use_xinerama = false;
+
     if (xinerama_screeninfo)
 	XFree(xinerama_screeninfo);
 #endif // QT_NO_XINERAMA
@@ -216,8 +241,7 @@ QWidget *QDesktopWidget::screen( int scr
 	screen = d->defaultScreen;
 
     if ( ! d->screens ) {
-	d->screens = new QWidget*[ d->screenCount ];
-	memset( d->screens, 0, d->screenCount * sizeof( QWidget * ) );
+	d->screens = (QWidget**) calloc( d->screenCount, sizeof(QWidget*));
 	d->screens[ d->defaultScreen ] = this;
     }