Remove dubious screen intersection check

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>
fix/various
Alexander Golubev 1 month ago
parent 65f9e94fca
commit 99490486e4

@ -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;

Loading…
Cancel
Save