summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2024-03-29 21:15:59 +0300
committerAlexander Golubev <fatzer2@gmail.com>2024-03-29 21:40:10 +0300
commit1fd5897bf1c2286f05e914702b4be23c833dedf5 (patch)
tree4f10373f2a1195accb00d5f6faecd8da40929661
parentfb0d62eec811ab2d4d73550e455944cecbe7e091 (diff)
downloadtqt3-1fd5897bf1c2286f05e914702b4be23c833dedf5.tar.gz
tqt3-1fd5897bf1c2286f05e914702b4be23c833dedf5.zip
Remove dubious screen intersection checkfeat/delete-screen-intersect
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.cpp30
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;