diff options
author | Alexander Golubev <fatzer2@gmail.com> | 2024-03-29 21:15:59 +0300 |
---|---|---|
committer | Alexander Golubev <fatzer2@gmail.com> | 2024-03-29 21:31:02 +0300 |
commit | 99490486e4c3ed8548e82f6c2d55a3cbc95d7cbc (patch) | |
tree | b06e30617d334784207d2ce9c26c114b65ea08f0 | |
parent | 65f9e94fca17d1c412ed944af328ae14871078b3 (diff) | |
download | tqt3-fix/various.tar.gz tqt3-fix/various.zip |
Remove dubious screen intersection checkfix/various
On a non-xinerama (user-side) configuration it is straight up wrong, as
in such case each screen's coordinates start at 0:0. Which makes the
apps on the smaller screen assume incorrect screen size.
And on a xinerama config it is incorrect as well as it results in access
past allocated data in rects and screen arrays.
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
-rw-r--r-- | src/kernel/qdesktopwidget_x11.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/kernel/qdesktopwidget_x11.cpp b/src/kernel/qdesktopwidget_x11.cpp index 449af4ffc..ecfa7e277 100644 --- a/src/kernel/qdesktopwidget_x11.cpp +++ b/src/kernel/qdesktopwidget_x11.cpp @@ -147,8 +147,8 @@ void TQDesktopWidgetPrivate::init() workareas = new TQRect[ newScreenCount ]; // get the geometry of each screen - int i, j, x, y, w, h; - for ( i = 0, j = 0; i < newScreenCount; i++ ) { + int i, x, y, w, h; + for ( i = 0; i < newScreenCount; i++ ) { #ifndef TQT_NO_XINERAMA if (use_xinerama) { @@ -166,27 +166,17 @@ void TQDesktopWidgetPrivate::init() } 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++; + rects[i].setRect(x, y, w, h); } 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*)); + screens = (TQWidget**) realloc(screens, newScreenCount * sizeof(TQWidget*)); + if (newScreenCount > screenCount) + memset(&screens[screenCount], 0, (newScreenCount-screenCount) * sizeof(TQWidget*)); } - screenCount = j; + screenCount = newScreenCount; #ifndef TQT_NO_XINERAMA if (use_xinerama && screenCount == 1) @@ -341,8 +331,12 @@ int TQDesktopWidget::screenNumber( TQWidget *widget ) const int TQDesktopWidget::screenNumber( const TQPoint &point ) const { + // check the default screen first + if ( d->rects[d->defaultScreen].contains( point ) ) + return d->defaultScreen; + for ( int i = 0; i < d->screenCount; ++i ) { - if ( d->rects[i].contains( point ) ) + if ( i != d->defaultScreen && d->rects[i].contains( point ) ) return i; } return -1; |