Changeset View
Changeset View
Standalone View
Standalone View
effects/presentwindows/presentwindows.cpp
Show First 20 Lines • Show All 1401 Lines • ▼ Show 20 Line(s) | 1401 | foreach (EffectWindow * w, windowlist) { | |||
---|---|---|---|---|---|
1402 | QRect oldRect; | 1402 | QRect oldRect; | ||
1403 | QRect *target = &targets[w]; | 1403 | QRect *target = &targets[w]; | ||
1404 | // This may cause some slight distortion if the windows are enlarged a large amount | 1404 | // This may cause some slight distortion if the windows are enlarged a large amount | ||
1405 | int widthDiff = m_accuracy; | 1405 | int widthDiff = m_accuracy; | ||
1406 | int heightDiff = heightForWidth(w, target->width() + widthDiff) - target->height(); | 1406 | int heightDiff = heightForWidth(w, target->width() + widthDiff) - target->height(); | ||
1407 | int xDiff = widthDiff / 2; // Also move a bit in the direction of the enlarge, allows the | 1407 | int xDiff = widthDiff / 2; // Also move a bit in the direction of the enlarge, allows the | ||
1408 | int yDiff = heightDiff / 2; // center windows to be enlarged if there is gaps on the side. | 1408 | int yDiff = heightDiff / 2; // center windows to be enlarged if there is gaps on the side. | ||
1409 | 1409 | | |||
1410 | // heightDiff (and yDiff) will be re-computed after each successfull enlargement attempt | ||||
1411 | // so that the error introduced in the window's aspect ratio is minimized | ||||
1412 | | ||||
1410 | // Attempt enlarging to the top-right | 1413 | // Attempt enlarging to the top-right | ||
1411 | oldRect = *target; | 1414 | oldRect = *target; | ||
1412 | target->setRect(target->x() + xDiff, | 1415 | target->setRect(target->x() + xDiff, | ||
1413 | target->y() - yDiff - heightDiff, | 1416 | target->y() - yDiff - heightDiff, | ||
1414 | target->width() + widthDiff, | 1417 | target->width() + widthDiff, | ||
1415 | target->height() + heightDiff | 1418 | target->height() + heightDiff | ||
1416 | ); | 1419 | ); | ||
1417 | if (isOverlappingAny(w, targets, borderRegion)) | 1420 | if (isOverlappingAny(w, targets, borderRegion)) | ||
1418 | *target = oldRect; | 1421 | *target = oldRect; | ||
1419 | else | 1422 | else { | ||
1420 | moved = true; | 1423 | moved = true; | ||
1424 | heightDiff = heightForWidth(w, target->width() + widthDiff) - target->height(); | ||||
1425 | yDiff = heightDiff / 2; | ||||
1426 | } | ||||
1421 | 1427 | | |||
1422 | // Attempt enlarging to the bottom-right | 1428 | // Attempt enlarging to the bottom-right | ||
1423 | oldRect = *target; | 1429 | oldRect = *target; | ||
1424 | target->setRect( | 1430 | target->setRect( | ||
1425 | target->x() + xDiff, | 1431 | target->x() + xDiff, | ||
1426 | target->y() + yDiff, | 1432 | target->y() + yDiff, | ||
1427 | target->width() + widthDiff, | 1433 | target->width() + widthDiff, | ||
1428 | target->height() + heightDiff | 1434 | target->height() + heightDiff | ||
1429 | ); | 1435 | ); | ||
1430 | if (isOverlappingAny(w, targets, borderRegion)) | 1436 | if (isOverlappingAny(w, targets, borderRegion)) | ||
1431 | *target = oldRect; | 1437 | *target = oldRect; | ||
1432 | else | 1438 | else { | ||
1433 | moved = true; | 1439 | moved = true; | ||
1440 | heightDiff = heightForWidth(w, target->width() + widthDiff) - target->height(); | ||||
1441 | yDiff = heightDiff / 2; | ||||
1442 | } | ||||
1434 | 1443 | | |||
1435 | // Attempt enlarging to the bottom-left | 1444 | // Attempt enlarging to the bottom-left | ||
1436 | oldRect = *target; | 1445 | oldRect = *target; | ||
1437 | target->setRect( | 1446 | target->setRect( | ||
1438 | target->x() - xDiff - widthDiff, | 1447 | target->x() - xDiff - widthDiff, | ||
1439 | target->y() + yDiff, | 1448 | target->y() + yDiff, | ||
1440 | target->width() + widthDiff, | 1449 | target->width() + widthDiff, | ||
1441 | target->height() + heightDiff | 1450 | target->height() + heightDiff | ||
1442 | ); | 1451 | ); | ||
1443 | if (isOverlappingAny(w, targets, borderRegion)) | 1452 | if (isOverlappingAny(w, targets, borderRegion)) | ||
1444 | *target = oldRect; | 1453 | *target = oldRect; | ||
1445 | else | 1454 | else { | ||
1446 | moved = true; | 1455 | moved = true; | ||
1456 | heightDiff = heightForWidth(w, target->width() + widthDiff) - target->height(); | ||||
1457 | yDiff = heightDiff / 2; | ||||
1458 | } | ||||
1447 | 1459 | | |||
1448 | // Attempt enlarging to the top-left | 1460 | // Attempt enlarging to the top-left | ||
1449 | oldRect = *target; | 1461 | oldRect = *target; | ||
1450 | target->setRect( | 1462 | target->setRect( | ||
1451 | target->x() - xDiff - widthDiff, | 1463 | target->x() - xDiff - widthDiff, | ||
1452 | target->y() - yDiff - heightDiff, | 1464 | target->y() - yDiff - heightDiff, | ||
1453 | target->width() + widthDiff, | 1465 | target->width() + widthDiff, | ||
1454 | target->height() + heightDiff | 1466 | target->height() + heightDiff | ||
1455 | ); | 1467 | ); | ||
1456 | if (isOverlappingAny(w, targets, borderRegion)) | 1468 | if (isOverlappingAny(w, targets, borderRegion)) | ||
1457 | *target = oldRect; | 1469 | *target = oldRect; | ||
1458 | else | 1470 | else | ||
1459 | moved = true; | 1471 | moved = true; | ||
1460 | } | 1472 | } | ||
1461 | } while (moved); | 1473 | } while (moved); | ||
zzag: This one is redundant. | |||||
1462 | 1474 | | |||
1463 | // The expanding code above can actually enlarge windows over 1.0/2.0 scale, we don't like this | 1475 | // The expanding code above can actually enlarge windows over 1.0/2.0 scale, we don't like this | ||
1464 | // We can't add this to the loop above as it would cause a never-ending loop so we have to make | 1476 | // We can't add this to the loop above as it would cause a never-ending loop so we have to make | ||
1465 | // do with the less-than-optimal space usage with using this method. | 1477 | // do with the less-than-optimal space usage with using this method. | ||
1466 | foreach (EffectWindow * w, windowlist) { | 1478 | foreach (EffectWindow * w, windowlist) { | ||
1467 | QRect *target = &targets[w]; | 1479 | QRect *target = &targets[w]; | ||
1468 | double scale = target->width() / double(w->width()); | 1480 | double scale = target->width() / double(w->width()); | ||
1469 | if (scale > 2.0 || (scale > 1.0 && (w->width() > 300 || w->height() > 300))) { | 1481 | if (scale > 2.0 || (scale > 1.0 && (w->width() > 300 || w->height() > 300))) { | ||
▲ Show 20 Lines • Show All 586 Lines • Show Last 20 Lines |
This one is redundant.