summaryrefslogtreecommitdiffstats
path: root/opensuse/core/qt3/use-xrandr-1.2.diff
blob: 4ec4174e7f06b87ea251c94f2ec4cc927f718908 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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;
     }