diff options
Diffstat (limited to 'experimental/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp')
-rw-r--r-- | experimental/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/experimental/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp b/experimental/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp index e2bd9f97e..84da179a0 100644 --- a/experimental/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp +++ b/experimental/tqtinterface/qt4/src/kernel/tqdesktopwidget_x11.cpp @@ -111,7 +111,7 @@ TQDesktopWidgetPrivate::~TQDesktopWidgetPrivate() screens[i] = 0; } - delete [] screens; + free(screens); } if ( rects ) delete [] rects; @@ -121,6 +121,8 @@ TQDesktopWidgetPrivate::~TQDesktopWidgetPrivate() void TQDesktopWidgetPrivate::init() { // get the screen count + int newScreenCount; + #ifndef TQT_NO_XINERAMA XineramaScreenInfo *xinerama_screeninfo = 0; int unused; @@ -130,23 +132,26 @@ void TQDesktopWidgetPrivate::init() if (use_xinerama) { xinerama_screeninfo = - XineramaQueryScreens(TQPaintDevice::x11AppDisplay(), &screenCount); + XineramaQueryScreens(TQPaintDevice::x11AppDisplay(), &newScreenCount); + + if (xinerama_screeninfo) defaultScreen = 0; } else #endif // TQT_NO_XINERAMA { defaultScreen = DefaultScreen(TQPaintDevice::x11AppDisplay()); - screenCount = ScreenCount(TQPaintDevice::x11AppDisplay()); + newScreenCount = ScreenCount(TQPaintDevice::x11AppDisplay()); + use_xinerama = false; } delete [] rects; - rects = new TQRect[ screenCount ]; + rects = new TQRect[ newScreenCount ]; delete [] workareas; - workareas = new TQRect[ screenCount ]; + workareas = new TQRect[ newScreenCount ]; // get the tqgeometry 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 TQT_NO_XINERAMA if (use_xinerama) { @@ -163,11 +168,33 @@ void TQDesktopWidgetPrivate::init() h = HeightOfScreen(ScreenOfDisplay(TQPaintDevice::x11AppDisplay(), i)); } - rects[i].setRect(x, y, w, h); workareas[i] = TQRect(); + 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 TQWidget* pointers on purpose, can't delete them as pointer escapes + screens = (TQWidget**) realloc(screens, j * sizeof(TQWidget*)); + if (j > screenCount) + memset(&screens[screenCount], 0, (j-screenCount) * sizeof(TQWidget*)); + } + + screenCount = j; + #ifndef TQT_NO_XINERAMA + if (use_xinerama && screenCount == 1) + use_xinerama = false; + if (xinerama_screeninfo) XFree(xinerama_screeninfo); #endif // TQT_NO_XINERAMA @@ -220,8 +247,7 @@ TQWidget *TQDesktopWidget::screen( int screen ) screen = d->defaultScreen; if ( ! d->screens ) { - d->screens = new TQWidget*[ d->screenCount ]; - memset( d->screens, 0, d->screenCount * sizeof( TQWidget * ) ); + d->screens = (TQWidget**) calloc( d->screenCount, sizeof(TQWidget*)); d->screens[ d->defaultScreen ] = this; } |