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>
feat/delete-screen-intersect
Alexander Golubev 2 months ago
parent fb0d62eec8
commit 1fd5897bf1

@ -147,8 +147,8 @@ void TQDesktopWidgetPrivate::init()
workareas = new TQRect[ newScreenCount ]; workareas = new TQRect[ newScreenCount ];
// get the geometry of each screen // get the geometry of each screen
int i, j, x, y, w, h; int i, x, y, w, h;
for ( i = 0, j = 0; i < newScreenCount; i++ ) { for ( i = 0; i < newScreenCount; i++ ) {
#ifndef TQT_NO_XINERAMA #ifndef TQT_NO_XINERAMA
if (use_xinerama) { if (use_xinerama) {
@ -166,27 +166,17 @@ void TQDesktopWidgetPrivate::init()
} }
workareas[i] = TQRect(); workareas[i] = TQRect();
rects[j].setRect(x, y, w, h); rects[i].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) { if (screens) {
// leaks TQWidget* pointers on purpose, can't delete them as pointer escapes // leaks TQWidget* pointers on purpose, can't delete them as pointer escapes
screens = (TQWidget**) realloc(screens, j * sizeof(TQWidget*)); screens = (TQWidget**) realloc(screens, newScreenCount * sizeof(TQWidget*));
if (j > screenCount) if (newScreenCount > screenCount)
memset(&screens[screenCount], 0, (j-screenCount) * sizeof(TQWidget*)); memset(&screens[screenCount], 0, (newScreenCount-screenCount) * sizeof(TQWidget*));
} }
screenCount = j; screenCount = newScreenCount;
#ifndef TQT_NO_XINERAMA #ifndef TQT_NO_XINERAMA
if (use_xinerama && screenCount == 1) if (use_xinerama && screenCount == 1)
@ -341,8 +331,12 @@ int TQDesktopWidget::screenNumber( TQWidget *widget ) const
int TQDesktopWidget::screenNumber( const TQPoint &point ) 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 ) { 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 i;
} }
return -1; return -1;

Loading…
Cancel
Save