diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp index 8de5c5d076..8f30d714b4 100644 --- a/effects/backgroundcontrast/contrast.cpp +++ b/effects/backgroundcontrast/contrast.cpp @@ -184,7 +184,8 @@ bool ContrastEffect::supported() int maxTexSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); - if (displayWidth() > maxTexSize || displayHeight() > maxTexSize) + const QSize screenSize = effects->virtualScreenSize(); + if (screenSize.width() > maxTexSize || screenSize.height() > maxTexSize) supported = false; } return supported; @@ -278,7 +279,7 @@ void ContrastEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, i } // in case this window has regions to be blurred - const QRect screen(0, 0, displayWidth(), displayHeight()); + const QRect screen = effects->virtualScreenGeometry(); const QRegion contrastArea = contrastRegion(w).translated(w->pos()) & screen; // we are not caching the window @@ -328,7 +329,7 @@ bool ContrastEffect::shouldContrast(const EffectWindow *w, int mask, const Windo void ContrastEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { - const QRect screen(0, 0, displayWidth(), displayHeight()); + const QRect screen = effects->virtualScreenGeometry(); if (shouldContrast(w, mask, data)) { QRegion shape = region & contrastRegion(w).translated(w->pos()) & screen; diff --git a/effects/backgroundcontrast/contrastshader.cpp b/effects/backgroundcontrast/contrastshader.cpp index 890842d73d..99325526c3 100644 --- a/effects/backgroundcontrast/contrastshader.cpp +++ b/effects/backgroundcontrast/contrastshader.cpp @@ -222,7 +222,8 @@ void ContrastShader::init() opacityLocation = shader->uniformLocation("opacity"); QMatrix4x4 modelViewProjection; - modelViewProjection.ortho(0, displayWidth(), displayHeight(), 0, 0, 65535); + const QSize screenSize = effects->virtualScreenSize(); + modelViewProjection.ortho(0, screenSize.width(), screenSize.height(), 0, 0, 65535); ShaderManager::instance()->pushShader(shader); shader->setUniform(colorMatrixLocation, QMatrix4x4()); shader->setUniform(textureMatrixLocation, QMatrix4x4()); diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index 7983002eb4..ea89f02fae 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -35,7 +35,7 @@ BlurEffect::BlurEffect() // Offscreen texture that's used as the target for the horizontal blur pass // and the source for the vertical pass. - tex = GLTexture(displayWidth(), displayHeight()); + tex = GLTexture(effects->virtualScreenSize()); tex.setFilter(GL_LINEAR); tex.setWrapMode(GL_CLAMP_TO_EDGE); @@ -134,7 +134,7 @@ void BlurEffect::slotPropertyNotify(EffectWindow *w, long atom) updateBlurRegion(w); CacheEntry it = windows.find(w); if (it != windows.end()) { - const QRect screen(0, 0, displayWidth(), displayHeight()); + const QRect screen = effects->virtualScreenGeometry(); it->damagedRegion = expand(blurRegion(w).translated(w->pos())) & screen; } } @@ -167,7 +167,8 @@ bool BlurEffect::supported() int maxTexSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); - if (displayWidth() > maxTexSize || displayHeight() > maxTexSize) + const QSize screenSize = effects->virtualScreenSize(); + if (screenSize.width() > maxTexSize || screenSize.height() > maxTexSize) supported = false; } return supported; @@ -298,7 +299,7 @@ void BlurEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int t } // in case this window has regions to be blurred - const QRect screen(0, 0, displayWidth(), displayHeight()); + const QRect screen = effects->virtualScreenGeometry(); const QRegion blurArea = blurRegion(w).translated(w->pos()) & screen; const QRegion expandedBlur = expand(blurArea) & screen; @@ -397,7 +398,7 @@ bool BlurEffect::shouldBlur(const EffectWindow *w, int mask, const WindowPaintDa void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { - const QRect screen(0, 0, displayWidth(), displayHeight()); + const QRect screen = effects->virtualScreenGeometry(); if (shouldBlur(w, mask, data)) { QRegion shape = region & blurRegion(w).translated(w->pos()) & screen; @@ -423,7 +424,7 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai void BlurEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity) { - const QRect screen(0, 0, displayWidth(), displayHeight()); + const QRect screen = effects->virtualScreenGeometry(); bool valid = target->valid() && shader && shader->isValid(); QRegion shape = frame->geometry().adjusted(-5, -5, 5, 5) & screen; if (valid && !shape.isEmpty() && region.intersects(shape.boundingRect()) && frame->style() != EffectFrameNone) { @@ -522,7 +523,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const float opacity) { - const QRect screen(0, 0, displayWidth(), displayHeight()); + const QRect screen = effects->virtualScreenGeometry(); const QRegion blurredRegion = blurRegion(w).translated(w->pos()) & screen; const QRegion expanded = expand(blurredRegion) & screen; const QRect r = expanded.boundingRect(); @@ -670,7 +671,8 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa } modelViewProjectionMatrix.setToIdentity(); - modelViewProjectionMatrix.ortho(0, displayWidth(), displayHeight(), 0, 0, 65535); + const QSize screenSize = effects->virtualScreenSize(); + modelViewProjectionMatrix.ortho(0, screenSize.width(), screenSize.height(), 0, 0, 65535); loadMatrix(modelViewProjectionMatrix); shader->setModelViewProjectionMatrix(modelViewProjectionMatrix); diff --git a/effects/blur/blurshader.cpp b/effects/blur/blurshader.cpp index 2172a05717..f86ca0567b 100644 --- a/effects/blur/blurshader.cpp +++ b/effects/blur/blurshader.cpp @@ -323,7 +323,8 @@ void GLSLBlurShader::init() mvpMatrixLocation = shader->uniformLocation("modelViewProjectionMatrix"); QMatrix4x4 modelViewProjection; - modelViewProjection.ortho(0, displayWidth(), displayHeight(), 0, 0, 65535); + const QSize screenSize = effects->virtualScreenSize(); + modelViewProjection.ortho(0, screenSize.width(), screenSize.height(), 0, 0, 65535); ShaderManager::instance()->pushShader(shader); shader->setUniform(textureMatrixLocation, QMatrix4x4()); shader->setUniform(mvpMatrixLocation, modelViewProjection); diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index a174069d78..022580ece5 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -545,16 +545,17 @@ void CoverSwitchEffect::slotTabBoxAdded(int mode) // Calculation of correct area area = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop()); - scaleFactor = (zPosition + 1100) * 2.0 * tan(60.0 * M_PI / 360.0f) / displayWidth(); - if (displayWidth() - area.width() != 0) { + const QSize screenSize = effects->virtualScreenSize(); + scaleFactor = (zPosition + 1100) * 2.0 * tan(60.0 * M_PI / 360.0f) / screenSize.width(); + if (screenSize.width() - area.width() != 0) { // one of the screens is smaller than the other (horizontal) - if (area.width() < displayWidth() - area.width()) - scaleFactor *= (float)area.width() / (float)(displayWidth() - area.width()); - else if (area.width() != displayWidth() - area.width()) { + if (area.width() < screenSize.width() - area.width()) + scaleFactor *= (float)area.width() / (float)(screenSize.width() - area.width()); + else if (area.width() != screenSize.width() - area.width()) { // vertical layout with different width // but we don't want to catch screens with same width and different height - if (displayHeight() != area.height()) - scaleFactor *= (float)area.width() / (float)(displayWidth()); + if (screenSize.height() != area.height()) + scaleFactor *= (float)area.width() / (float)(screenSize.width()); } } @@ -778,10 +779,11 @@ void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, i } if (animation) { float distance = 0.0; + const QSize screenSize = effects->virtualScreenSize(); if (direction == Right) { // move to right distance = -frontWindow->geometry().width() * 0.5f + area.width() * 0.5f + - (((float)displayWidth() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows; + (((float)screenSize.width() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows; data.translate(distance * timeLine.currentValue()); data.setRotationAxis(Qt::YAxis); data.setRotationAngle(-angle * timeLine.currentValue()); @@ -789,7 +791,7 @@ void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, i } else { // move to left distance = frontWindow->geometry().width() * 0.5f - area.width() * 0.5f + - ((float)width * 0.5f - ((float)displayWidth() * 0.5 * scaleFactor)) / leftWindows; + ((float)width * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)) / leftWindows; float factor = 1.0; if (specialHandlingForward) factor = 2.0; @@ -816,9 +818,10 @@ void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left, rotateFactor = -1; } - float xTranslate = -((float)(width) * 0.5f - ((float)displayWidth() * 0.5 * scaleFactor)); + const QSize screenSize = effects->virtualScreenSize(); + float xTranslate = -((float)(width) * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)); if (!left) - xTranslate = ((float)displayWidth() * 0.5 * scaleFactor) - (float)width * 0.5f; + xTranslate = ((float)screenSize.width() * 0.5 * scaleFactor) - (float)width * 0.5f; // handling for additional window from other side // has to appear on this side after half of the time if (animation && timeLine.currentValue() >= 0.5 && additionalWindow != NULL) { diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 7b80dde5a3..1ef798a9bd 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -332,7 +332,8 @@ bool CubeEffect::loadShader() QMatrix4x4 modelview; float scaleFactor = 1.1 * tan(fovy * M_PI / 360.0f) / ymax; modelview.translate(xmin * scaleFactor, ymax * scaleFactor, -1.1); - modelview.scale((xmax - xmin)*scaleFactor / displayWidth(), -(ymax - ymin)*scaleFactor / displayHeight(), 0.001); + const QSize screenSize = effects->virtualScreenSize(); + modelview.scale((xmax - xmin)*scaleFactor / screenSize.width(), -(ymax - ymin)*scaleFactor / screenSize.height(), 0.001); cylinderShader->setUniform(GLShader::ModelViewMatrix, modelview); const QMatrix4x4 identity; cylinderShader->setUniform(GLShader::ScreenTransformation, identity); @@ -361,7 +362,8 @@ bool CubeEffect::loadShader() QMatrix4x4 modelview; float scaleFactor = 1.1 * tan(fovy * M_PI / 360.0f) / ymax; modelview.translate(xmin * scaleFactor, ymax * scaleFactor, -1.1); - modelview.scale((xmax - xmin)*scaleFactor / displayWidth(), -(ymax - ymin)*scaleFactor / displayHeight(), 0.001); + const QSize screenSize = effects->virtualScreenSize(); + modelview.scale((xmax - xmin)*scaleFactor / screenSize.width(), -(ymax - ymin)*scaleFactor / screenSize.height(), 0.001); sphereShader->setUniform(GLShader::ModelViewMatrix, modelview); const QMatrix4x4 identity; sphereShader->setUniform(GLShader::ScreenTransformation, identity); @@ -1985,7 +1987,7 @@ void CubeEffect::windowInputMouseEvent(QEvent* e) if (deltaX == 0) { if (pos.x() == 0) deltaDegrees = 5.0f; - if (pos.x() == displayWidth() - 1) + if (pos.x() == rect.width() - 1) deltaDegrees = -5.0f; } if (invertMouse) diff --git a/effects/cube/cubeslide.cpp b/effects/cube/cubeslide.cpp index c86d2572af..fddb48f264 100644 --- a/effects/cube/cubeslide.cpp +++ b/effects/cube/cubeslide.cpp @@ -524,25 +524,26 @@ void CubeSlideEffect::slotWindowStepUserMovedResized(EffectWindow* w) return; if (w->isUserResize()) return; + const QSize screenSize = effects->virtualScreenSize(); const QPoint cursor = effects->cursorPos(); - const int horizontal = displayWidth() * 0.1; - const int vertical = displayHeight() * 0.1; - const QRect leftRect(0, displayHeight() * 0.1, horizontal, displayHeight() * 0.8); - const QRect rightRect(displayWidth() - horizontal, displayHeight() * 0.1, horizontal, displayHeight() * 0.8); - const QRect topRect(horizontal, 0, displayWidth() * 0.8, vertical); - const QRect bottomRect(horizontal, displayHeight() - vertical, displayWidth() - horizontal * 2, vertical); + const int horizontal = screenSize.width() * 0.1; + const int vertical = screenSize.height() * 0.1; + const QRect leftRect(0, screenSize.height() * 0.1, horizontal, screenSize.height() * 0.8); + const QRect rightRect(screenSize.width() - horizontal, screenSize.height() * 0.1, horizontal, screenSize.height() * 0.8); + const QRect topRect(horizontal, 0, screenSize.width() * 0.8, vertical); + const QRect bottomRect(horizontal, screenSize.height() - vertical, screenSize.width() - horizontal * 2, vertical); if (leftRect.contains(cursor)) { if (effects->desktopToLeft(effects->currentDesktop()) != effects->currentDesktop()) windowMovingChanged(0.3 *(float)(horizontal - cursor.x()) / (float)horizontal, Left); } else if (rightRect.contains(cursor)) { if (effects->desktopToRight(effects->currentDesktop()) != effects->currentDesktop()) - windowMovingChanged(0.3 *(float)(cursor.x() - displayWidth() + horizontal) / (float)horizontal, Right); + windowMovingChanged(0.3 *(float)(cursor.x() - screenSize.width() + horizontal) / (float)horizontal, Right); } else if (topRect.contains(cursor)) { if (effects->desktopAbove(effects->currentDesktop()) != effects->currentDesktop()) windowMovingChanged(0.3 *(float)(vertical - cursor.y()) / (float)vertical, Upwards); } else if (bottomRect.contains(cursor)) { if (effects->desktopBelow(effects->currentDesktop()) != effects->currentDesktop()) - windowMovingChanged(0.3 *(float)(cursor.y() - displayHeight() + vertical) / (float)vertical, Downwards); + windowMovingChanged(0.3 *(float)(cursor.y() - screenSize.height() + vertical) / (float)vertical, Downwards); } else { // not in one of the areas windowMoving = false; diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index 998355ff3f..d50293d69d 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -116,7 +116,7 @@ void LogoutEffect::prePaintScreen(ScreenPrePaintData& data, int time) // TODO: It seems that it is not possible to create a GLRenderTarget that has // a different size than the display right now. Most likely a KWin core bug. // Create texture and render target - blurTexture = new GLTexture(displayWidth(), displayHeight()); + blurTexture = new GLTexture(effects->virtualScreenSize()); blurTexture->setFilter(GL_LINEAR_MIPMAP_LINEAR); blurTexture->setWrapMode(GL_CLAMP_TO_EDGE); @@ -401,7 +401,7 @@ void LogoutEffect::renderBlurTexture() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); blurTexture->bind(); - blurTexture->render(infiniteRegion(), QRect(0, 0, displayWidth(), displayHeight())); + blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry()); blurTexture->unbind(); glDisable(GL_BLEND); checkGLError("Render blur texture"); @@ -413,7 +413,7 @@ void LogoutEffect::renderBlurTextureLegacy() glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT); // Unmodified base image blurTexture->bind(); - blurTexture->render(infiniteRegion(), QRect(0, 0, displayWidth(), displayHeight())); + blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry()); // Blurred image GLfloat bias[1]; @@ -424,7 +424,7 @@ void LogoutEffect::renderBlurTextureLegacy() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1.0f, 1.0f, 1.0f, progress * 0.4); - blurTexture->render(infiniteRegion(), QRect(0, 0, displayWidth(), displayHeight())); + blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry()); glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias[0]); blurTexture->unbind(); diff --git a/effects/lookingglass/lookingglass.cpp b/effects/lookingglass/lookingglass.cpp index f7387547ee..4f779c43ed 100644 --- a/effects/lookingglass/lookingglass.cpp +++ b/effects/lookingglass/lookingglass.cpp @@ -94,8 +94,9 @@ bool LookingGlassEffect::loadData() // If NPOT textures are not supported, use nearest power-of-two sized // texture. It wastes memory, but it's possible to support systems without // NPOT textures that way - int texw = displayWidth(); - int texh = displayHeight(); + const QSize screenSize = effects->virtualScreenSize(); + int texw = screenSize.width(); + int texh = screenSize.height(); if (!GLTexture::NPOTTextureSupported()) { qWarning() << "NPOT textures not supported, wasting some memory" ; texw = nearestPowerOfTwo(texw); @@ -123,7 +124,7 @@ bool LookingGlassEffect::loadData() m_shader = ShaderManager::instance()->loadFragmentShader(ShaderManager::SimpleShader, fragmentshader); if (m_shader->isValid()) { ShaderBinder binder(m_shader); - m_shader->setUniform("u_textureSize", QVector2D(displayWidth(), displayHeight())); + m_shader->setUniform("u_textureSize", QVector2D(screenSize.width(), screenSize.height())); } else { qCritical() << "The shader failed to load!" << endl; return false; @@ -132,18 +133,18 @@ bool LookingGlassEffect::loadData() m_vbo = new GLVertexBuffer(GLVertexBuffer::Static); QVector verts; QVector texcoords; - texcoords << displayWidth() << 0.0; - verts << displayWidth() << 0.0; + texcoords << screenSize.width() << 0.0; + verts << screenSize.width() << 0.0; texcoords << 0.0 << 0.0; verts << 0.0 << 0.0; - texcoords << 0.0 << displayHeight(); - verts << 0.0 << displayHeight(); - texcoords << 0.0 << displayHeight(); - verts << 0.0 << displayHeight(); - texcoords << displayWidth() << displayHeight(); - verts << displayWidth() << displayHeight(); - texcoords << displayWidth() << 0.0; - verts << displayWidth() << 0.0; + texcoords << 0.0 << screenSize.height(); + verts << 0.0 << screenSize.height(); + texcoords << 0.0 << screenSize.height(); + verts << 0.0 << screenSize.height(); + texcoords << screenSize.width() << screenSize.height(); + verts << screenSize.width() << screenSize.height(); + texcoords << screenSize.width() << 0.0; + verts << screenSize.width() << 0.0; m_vbo->setData(6, 2, verts.constData(), texcoords.constData()); return true; } diff --git a/effects/minimizeanimation/minimizeanimation.cpp b/effects/minimizeanimation/minimizeanimation.cpp index 4546cf88cc..fdbb3da281 100644 --- a/effects/minimizeanimation/minimizeanimation.cpp +++ b/effects/minimizeanimation/minimizeanimation.cpp @@ -88,7 +88,7 @@ void MinimizeAnimationEffect::paintWindow(EffectWindow* w, int mask, QRegion reg QRect icon = w->iconGeometry(); // If there's no icon geometry, minimize to the center of the screen if (!icon.isValid()) - icon = QRect(displayWidth() / 2, displayHeight() / 2, 0, 0); + icon = QRect(effects->virtualScreenGeometry().center(), QSize(0, 0)); data *= QVector2D(interpolate(1.0, icon.width() / (double)geo.width(), progress), interpolate(1.0, icon.height() / (double)geo.height(), progress)); diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index 5b30fd5e0f..f0a36887a7 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -254,7 +254,7 @@ void ScreenShotEffect::screenshotForWindow(qulonglong winid, int mask) QString ScreenShotEffect::screenshotFullscreen() { - return blitScreenshot(QRect(0, 0, displayWidth(), displayHeight())); + return blitScreenshot(effects->virtualScreenGeometry()); } QString ScreenShotEffect::screenshotScreen(int screen) diff --git a/effects/showfps/showfps.cpp b/effects/showfps/showfps.cpp index cea7d540f4..a02fd0956d 100644 --- a/effects/showfps/showfps.cpp +++ b/effects/showfps/showfps.cpp @@ -68,14 +68,15 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags) alpha = ShowFpsConfig::alpha(); x = ShowFpsConfig::x(); y = ShowFpsConfig::y(); + const QSize screenSize = effects->virtualScreenSize(); if (x == -10000) // there's no -0 :( - x = displayWidth() - 2 * NUM_PAINTS - FPS_WIDTH; + x = screenSize.width() - 2 * NUM_PAINTS - FPS_WIDTH; else if (x < 0) - x = displayWidth() - 2 * NUM_PAINTS - FPS_WIDTH - x; + x = screenSize.width() - 2 * NUM_PAINTS - FPS_WIDTH - x; if (y == -10000) - y = displayHeight() - MAX_TIME; + y = screenSize.height() - MAX_TIME; else if (y < 0) - y = displayHeight() - MAX_TIME - y; + y = screenSize.height() - MAX_TIME - y; fps_rect = QRect(x, y, FPS_WIDTH + 2 * NUM_PAINTS, MAX_TIME); m_noBenchmark->setPosition(fps_rect.bottomRight() + QPoint(-6, 6)); @@ -94,15 +95,15 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags) textAlign = Qt::AlignTop | Qt::AlignLeft; break; case TOP_RIGHT: - fpsTextRect = QRect(displayWidth() - 100, 0, 100, 100); + fpsTextRect = QRect(screenSize.width() - 100, 0, 100, 100); textAlign = Qt::AlignTop | Qt::AlignRight; break; case BOTTOM_LEFT: - fpsTextRect = QRect(0, displayHeight() - 100, 100, 100); + fpsTextRect = QRect(0, screenSize.height() - 100, 100, 100); textAlign = Qt::AlignBottom | Qt::AlignLeft; break; case BOTTOM_RIGHT: - fpsTextRect = QRect(displayWidth() - 100, displayHeight() - 100, 100, 100); + fpsTextRect = QRect(screenSize.width() - 100, screenSize.height() - 100, 100, 100); textAlign = Qt::AlignBottom | Qt::AlignRight; break; case NOWHERE: diff --git a/effects/slide/slide.cpp b/effects/slide/slide.cpp index b31c833f47..e6a8d588fe 100644 --- a/effects/slide/slide.cpp +++ b/effects/slide/slide.cpp @@ -117,8 +117,7 @@ void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) diffPos.setY(diffPos.y() + h); } QPoint currentPos = slide_start_pos + mTimeLine.currentValue() * diffPos; - QSize displaySize(displayWidth(), displayHeight()); - QRegion currentRegion = QRect(currentPos, displaySize); + QRegion currentRegion = QRect(currentPos, effects->virtualScreenSize()); if (effects->optionRollOverDesktops()) { currentRegion |= (currentRegion & QRect(-w, 0, w, h)).translated(w, 0); currentRegion |= (currentRegion & QRect(0, -h, w, h)).translated(0, h); @@ -150,14 +149,15 @@ void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) slide_painting_sticky = do_sticky; slide_painting_keep_above = (last_desktop == desktop); slide_painting_diff = rect.topLeft() - currentPos; + const QSize screenSize = effects->virtualScreenSize(); if (effects->optionRollOverDesktops()) { - if (slide_painting_diff.x() > displayWidth()) + if (slide_painting_diff.x() > screenSize.width()) slide_painting_diff.setX(slide_painting_diff.x() - w); - if (slide_painting_diff.x() < -displayWidth()) + if (slide_painting_diff.x() < -screenSize.width()) slide_painting_diff.setX(slide_painting_diff.x() + w); - if (slide_painting_diff.y() > displayHeight()) + if (slide_painting_diff.y() > screenSize.height()) slide_painting_diff.setY(slide_painting_diff.y() - h); - if (slide_painting_diff.y() < -displayHeight()) + if (slide_painting_diff.y() < -screenSize.height()) slide_painting_diff.setY(slide_painting_diff.y() + h); } do_sticky = false; // paint on-all-desktop windows only once @@ -188,7 +188,7 @@ void SlideEffect::postPaintScreen() // Gives a position of the given desktop when all desktops are arranged in a grid QRect SlideEffect::desktopRect(int desktop) const { - QRect rect(0, 0, displayWidth(), displayHeight()); + QRect rect = effects->virtualScreenGeometry(); rect.translate(effects->desktopCoords(desktop)); return rect; } @@ -216,7 +216,8 @@ void SlideEffect::slotDesktopChanged(int old, int current) diffPos.setY(diffPos.y() + h); } QPoint currentPos = slide_start_pos + mTimeLine.currentValue() * diffPos; - QRegion currentRegion = QRect(currentPos, QSize(displayWidth(), displayHeight())); + const QSize screenSize = effects->virtualScreenSize(); + QRegion currentRegion = QRect(currentPos, screenSize); if (effects->optionRollOverDesktops()) { currentRegion |= (currentRegion & QRect(-w, 0, w, h)).translated(w, 0); currentRegion |= (currentRegion & QRect(0, -h, w, h)).translated(0, h); @@ -228,9 +229,9 @@ void SlideEffect::slotDesktopChanged(int old, int current) // current position is in new current desktop (e.g. quickly changing back), // don't do full progress if (abs(currentPos.x() - rect.x()) > abs(currentPos.y() - rect.y())) - mTimeLine.setCurrentTime((1.0 - abs(currentPos.x() - rect.x()) / double(displayWidth()))*(qreal)mTimeLine.currentValue()); + mTimeLine.setCurrentTime((1.0 - abs(currentPos.x() - rect.x()) / double(screenSize.width()))*(qreal)mTimeLine.currentValue()); else - mTimeLine.setCurrentTime((1.0 - abs(currentPos.y() - rect.y()) / double(displayHeight()))*(qreal)mTimeLine.currentValue()); + mTimeLine.setCurrentTime((1.0 - abs(currentPos.y() - rect.y()) / double(screenSize.height()))*(qreal)mTimeLine.currentValue()); } else // current position is not on current desktop, do full progress mTimeLine.setCurrentTime(0); diffPos = rect.topLeft() - currentPos; diff --git a/effects/zoom/zoom.cpp b/effects/zoom/zoom.cpp index 96d6a04a57..84c100d890 100644 --- a/effects/zoom/zoom.cpp +++ b/effects/zoom/zoom.cpp @@ -285,6 +285,7 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) { if (zoom != 1.0) { data *= QVector2D(zoom, zoom); + const QSize screenSize = effects->virtualScreenSize(); // mouse-tracking allows navigation of the zoom-area using the mouse. switch(mouseTracking) { @@ -297,8 +298,8 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) prevPoint = cursorPoint; // fall through case MouseTrackingDisabled: - data.setXTranslation(qMin(0, qMax(int(displayWidth() - displayWidth() * zoom), int(displayWidth() / 2 - prevPoint.x() * zoom)))); - data.setYTranslation(qMin(0, qMax(int(displayHeight() - displayHeight() * zoom), int(displayHeight() / 2 - prevPoint.y() * zoom)))); + data.setXTranslation(qMin(0, qMax(int(screenSize.width() - screenSize.width() * zoom), int(screenSize.width() / 2 - prevPoint.x() * zoom)))); + data.setYTranslation(qMin(0, qMax(int(screenSize.height() - screenSize.height() * zoom), int(screenSize.height() / 2 - prevPoint.y() * zoom)))); break; case MouseTrackingPush: { // touching an edge of the screen moves the zoom-area in that direction. @@ -308,16 +309,16 @@ void ZoomEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) xMove = yMove = 0; if (x < threshold) xMove = (x - threshold) / zoom; - else if (x + threshold > displayWidth()) - xMove = (x + threshold - displayWidth()) / zoom; + else if (x + threshold > screenSize.width()) + xMove = (x + threshold - screenSize.width()) / zoom; if (y < threshold) yMove = (y - threshold) / zoom; - else if (y + threshold > displayHeight()) - yMove = (y + threshold - displayHeight()) / zoom; + else if (y + threshold > screenSize.height()) + yMove = (y + threshold - screenSize.height()) / zoom; if (xMove) - prevPoint.setX(qMax(0, qMin(displayWidth(), prevPoint.x() + xMove))); + prevPoint.setX(qMax(0, qMin(screenSize.width(), prevPoint.x() + xMove))); if (yMove) - prevPoint.setY(qMax(0, qMin(displayHeight(), prevPoint.y() + yMove))); + prevPoint.setY(qMax(0, qMin(screenSize.height(), prevPoint.y() + yMove))); data.setXTranslation(- int(prevPoint.x() * (zoom - 1.0))); data.setYTranslation(- int(prevPoint.y() * (zoom - 1.0))); break; @@ -444,8 +445,9 @@ void ZoomEffect::actualSize() void ZoomEffect::timelineFrameChanged(int /* frame */) { - prevPoint.setX(qMax(0, qMin(displayWidth(), prevPoint.x() + xMove))); - prevPoint.setY(qMax(0, qMin(displayHeight(), prevPoint.y() + yMove))); + const QSize screenSize = effects->virtualScreenSize(); + prevPoint.setX(qMax(0, qMin(screenSize.width(), prevPoint.x() + xMove))); + prevPoint.setY(qMax(0, qMin(screenSize.height(), prevPoint.y() + yMove))); cursorPoint = prevPoint; effects->addRepaintFull(); } @@ -455,17 +457,18 @@ void ZoomEffect::moveZoom(int x, int y) if (timeline.state() == QTimeLine::Running) timeline.stop(); + const QSize screenSize = effects->virtualScreenSize(); if (x < 0) - xMove = - qMax(1.0, displayWidth() / zoom / moveFactor); + xMove = - qMax(1.0, screenSize.width() / zoom / moveFactor); else if (x > 0) - xMove = qMax(1.0, displayWidth() / zoom / moveFactor); + xMove = qMax(1.0, screenSize.width() / zoom / moveFactor); else xMove = 0; if (y < 0) - yMove = - qMax(1.0, displayHeight() / zoom / moveFactor); + yMove = - qMax(1.0, screenSize.height() / zoom / moveFactor); else if (y > 0) - yMove = qMax(1.0, displayHeight() / zoom / moveFactor); + yMove = qMax(1.0, screenSize.height() / zoom / moveFactor); else yMove = 0; @@ -499,7 +502,7 @@ void ZoomEffect::moveMouseToFocus() void ZoomEffect::moveMouseToCenter() { - QRect r(0, 0, displayWidth(), displayHeight()); + const QRect r = effects->virtualScreenGeometry(); QCursor::setPos(r.x() + r.width() / 2, r.y() + r.height() / 2); } @@ -519,7 +522,8 @@ void ZoomEffect::focusChanged(int px, int py, int rx, int ry, int rwidth, int rh { if (zoom == 1.0) return; - focusPoint = (px >= 0 && py >= 0) ? QPoint(px, py) : QPoint(rx + qMax(0, (qMin(displayWidth(), rwidth) / 2) - 60), ry + qMax(0, (qMin(displayHeight(), rheight) / 2) - 60)); + const QSize screenSize = effects->virtualScreenSize(); + focusPoint = (px >= 0 && py >= 0) ? QPoint(px, py) : QPoint(rx + qMax(0, (qMin(screenSize.width(), rwidth) / 2) - 60), ry + qMax(0, (qMin(screenSize.height(), rheight) / 2) - 60)); if (enableFocusTracking) { lastFocusEvent = QTime::currentTime(); effects->addRepaintFull(); diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index c4586c0ce3..0c33146603 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -584,16 +584,6 @@ void Effect::setPositionTransformations(WindowPaintData& data, QRect& region, Ef data.setYTranslation(y - w->y()); } -int Effect::displayWidth() -{ - return KWin::displayWidth(); -} - -int Effect::displayHeight() -{ - return KWin::displayHeight(); -} - QPoint Effect::cursorPos() { return effects->cursorPos(); diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 4da48cc55e..d37535f970 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -528,8 +528,6 @@ public: */ virtual QString debug(const QString ¶meter) const; - static int displayWidth(); - static int displayHeight(); static QPoint cursorPos(); /** diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp index d0fc674071..3eba9c4bc8 100644 --- a/scripting/scriptedeffect.cpp +++ b/scripting/scriptedeffect.cpp @@ -73,14 +73,14 @@ QScriptValue kwinEffectDisplayWidth(QScriptContext *context, QScriptEngine *engi { Q_UNUSED(context) Q_UNUSED(engine) - return Effect::displayWidth(); + return displayWidth(); } QScriptValue kwinEffectDisplayHeight(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(context) Q_UNUSED(engine) - return Effect::displayHeight(); + return displayHeight(); } QScriptValue kwinScriptGlobalShortcut(QScriptContext *context, QScriptEngine *engine)