summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qdesktopwidget_x11.cpp26
-rw-r--r--tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp12
2 files changed, 28 insertions, 10 deletions
diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp
index 1555fc0..8b0c215 100644
--- a/src/gui/kernel/qdesktopwidget_x11.cpp
+++ b/src/gui/kernel/qdesktopwidget_x11.cpp
@@ -285,26 +285,36 @@ const QRect QDesktopWidget::availableGeometry(int screen) const
if (d->workareas[screen].isValid())
return d->workareas[screen];
- if ((d->screenCount == 1 || !isVirtualDesktop())
- && X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+ if (X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+ int x11Screen = isVirtualDesktop() ? DefaultScreen(X11->display) : screen;
+
Atom ret;
int format, e;
unsigned char *data = 0;
unsigned long nitems, after;
e = XGetWindowProperty(X11->display,
- QX11Info::appRootWindow(screen),
- ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
- &ret, &format, &nitems, &after, &data);
+ QX11Info::appRootWindow(x11Screen),
+ ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
+ &ret, &format, &nitems, &after, &data);
+ QRect workArea;
if (e == Success && ret == XA_CARDINAL &&
format == 32 && nitems == 4) {
long *workarea = (long *) data;
- d->workareas[screen].setRect(workarea[0], workarea[1],
- workarea[2], workarea[3]);
+ workArea = QRect(workarea[0], workarea[1], workarea[2], workarea[3]);
} else {
- d->workareas[screen] = screenGeometry(screen);
+ workArea = screenGeometry(screen);
+ }
+
+ if (isVirtualDesktop()) {
+ // intersect the workarea (which spawns all Xinerama screens) with the rect for the
+ // requested screen
+ workArea &= screenGeometry(screen);
}
+
+ d->workareas[screen] = workArea;
+
if (data)
XFree(data);
} else {
diff --git a/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp
index c6fac8d..d2b0d8a 100644
--- a/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp
+++ b/tests/auto/qdesktopwidget/tst_qdesktopwidget.cpp
@@ -99,9 +99,17 @@ void tst_QDesktopWidget::availableGeometry()
{
QDesktopWidget desktop;
- QRect total = desktop.screenGeometry();
- QRect available = desktop.availableGeometry();
+ QRect total;
+ QRect available;
+ for (int i = 0; i < desktop.screenCount(); ++i) {
+ total = desktop.screenGeometry(i);
+ available = desktop.availableGeometry(i);
+ QVERIFY(total.contains(available));
+ }
+
+ total = desktop.screenGeometry();
+ available = desktop.availableGeometry();
QVERIFY(total.contains(available));
QCOMPARE(desktop.availableGeometry(desktop.primaryScreen()), available);
QCOMPARE(desktop.screenGeometry(desktop.primaryScreen()), total);