2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
2007-11-13 16:20:52 +00:00
|
|
|
Copyright (C) 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
|
2011-08-20 08:53:36 +00:00
|
|
|
Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "magnifier.h"
|
2012-09-13 20:25:18 +00:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "magnifierconfig.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-05-30 17:47:24 +00:00
|
|
|
#include <kwinconfig.h>
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <kaction.h>
|
|
|
|
#include <kactioncollection.h>
|
|
|
|
#include <kstandardaction.h>
|
|
|
|
|
2011-01-06 13:29:13 +00:00
|
|
|
#include <kwinglutils.h>
|
2012-05-26 07:05:05 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2012-03-09 01:20:01 +00:00
|
|
|
#include <kwinxrenderutils.h>
|
2013-01-28 18:54:27 +00:00
|
|
|
#include <xcb/render.h>
|
2012-05-26 07:05:05 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EFFECT(magnifier, MagnifierEffect)
|
2011-06-26 16:51:08 +00:00
|
|
|
KWIN_EFFECT_SUPPORTED(magnifier, MagnifierEffect::supported())
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
const int FRAME_WIDTH = 5;
|
|
|
|
|
|
|
|
MagnifierEffect::MagnifierEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
: zoom(1)
|
|
|
|
, target_zoom(1)
|
|
|
|
, polling(false)
|
2011-08-20 08:53:36 +00:00
|
|
|
, m_texture(0)
|
|
|
|
, m_fbo(0)
|
2013-01-28 18:54:27 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
|
|
, m_pixmap(XCB_PIXMAP_NONE)
|
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
KActionCollection* actionCollection = new KActionCollection(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
KAction* a;
|
2011-01-30 14:34:42 +00:00
|
|
|
a = static_cast< KAction* >(actionCollection->addAction(KStandardAction::ZoomIn, this, SLOT(zoomIn())));
|
2007-04-29 17:35:43 +00:00
|
|
|
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Equal));
|
2011-01-30 14:34:42 +00:00
|
|
|
a = static_cast< KAction* >(actionCollection->addAction(KStandardAction::ZoomOut, this, SLOT(zoomOut())));
|
2007-04-29 17:35:43 +00:00
|
|
|
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
|
2011-01-30 14:34:42 +00:00
|
|
|
a = static_cast< KAction* >(actionCollection->addAction(KStandardAction::ActualSize, this, SLOT(toggle())));
|
2007-04-29 17:35:43 +00:00
|
|
|
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
|
2011-03-12 13:37:30 +00:00
|
|
|
connect(effects, SIGNAL(mouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)),
|
|
|
|
this, SLOT(slotMouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)));
|
2011-01-30 14:34:42 +00:00
|
|
|
reconfigure(ReconfigureAll);
|
|
|
|
}
|
2007-11-13 16:20:52 +00:00
|
|
|
|
2011-08-20 08:53:36 +00:00
|
|
|
MagnifierEffect::~MagnifierEffect()
|
|
|
|
{
|
|
|
|
delete m_fbo;
|
|
|
|
delete m_texture;
|
2013-01-28 18:54:27 +00:00
|
|
|
destroyPixmap();
|
2012-04-13 10:05:23 +00:00
|
|
|
// Save the zoom value.
|
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("Magnifier");
|
|
|
|
conf.writeEntry("InitialZoom", target_zoom);
|
|
|
|
conf.sync();
|
2011-08-20 08:53:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-28 18:54:27 +00:00
|
|
|
void MagnifierEffect::destroyPixmap()
|
|
|
|
{
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
|
|
if (effects->compositingType() != XRenderCompositing) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_picture.reset();
|
|
|
|
if (m_pixmap != XCB_PIXMAP_NONE) {
|
|
|
|
xcb_free_pixmap(connection(), m_pixmap);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-06-26 16:51:08 +00:00
|
|
|
bool MagnifierEffect::supported()
|
|
|
|
{
|
2012-03-09 01:20:01 +00:00
|
|
|
return effects->compositingType() == XRenderCompositing ||
|
2012-09-20 09:33:32 +00:00
|
|
|
(effects->isOpenGLCompositing() && GLRenderTarget::blitSupported());
|
2011-06-26 16:51:08 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void MagnifierEffect::reconfigure(ReconfigureFlags)
|
|
|
|
{
|
2012-09-13 20:25:18 +00:00
|
|
|
MagnifierConfig::self()->readConfig();
|
2007-11-13 16:20:52 +00:00
|
|
|
int width, height;
|
2012-09-13 20:25:18 +00:00
|
|
|
width = MagnifierConfig::width();
|
|
|
|
height = MagnifierConfig::height();
|
2011-01-30 14:34:42 +00:00
|
|
|
magnifier_size = QSize(width, height);
|
2012-04-13 10:05:23 +00:00
|
|
|
// Load the saved zoom value.
|
2012-09-13 20:25:18 +00:00
|
|
|
target_zoom = MagnifierConfig::initialZoom();
|
2012-04-13 10:05:23 +00:00
|
|
|
if (target_zoom != zoom)
|
|
|
|
toggle();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void MagnifierEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (zoom != target_zoom) {
|
|
|
|
double diff = time / animationTime(500.0);
|
|
|
|
if (target_zoom > zoom)
|
|
|
|
zoom = qMin(zoom * qMax(1 + diff, 1.2), target_zoom);
|
2011-09-07 07:31:31 +00:00
|
|
|
else {
|
2011-01-30 14:34:42 +00:00
|
|
|
zoom = qMax(zoom * qMin(1 - diff, 0.8), target_zoom);
|
2011-09-07 07:31:31 +00:00
|
|
|
if (zoom == 1.0) {
|
|
|
|
// zoom ended - delete FBO and texture
|
|
|
|
delete m_fbo;
|
|
|
|
delete m_texture;
|
|
|
|
m_fbo = NULL;
|
|
|
|
m_texture = NULL;
|
2013-01-28 18:54:27 +00:00
|
|
|
destroyPixmap();
|
2011-09-07 07:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintScreen(data, time);
|
|
|
|
if (zoom != 1.0)
|
|
|
|
data.paint |= magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void MagnifierEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
|
|
|
effects->paintScreen(mask, region, data); // paint normal screen
|
|
|
|
if (zoom != 1.0) {
|
2011-08-20 08:53:36 +00:00
|
|
|
// get the right area from the current rendered screen
|
|
|
|
const QRect area = magnifierArea();
|
|
|
|
const QPoint cursor = cursorPos();
|
2012-03-09 01:20:01 +00:00
|
|
|
|
|
|
|
QRect srcArea(cursor.x() - (double)area.width() / (zoom*2),
|
|
|
|
cursor.y() - (double)area.height() / (zoom*2),
|
|
|
|
(double)area.width() / zoom, (double)area.height() / zoom);
|
2012-09-20 09:33:32 +00:00
|
|
|
if (effects->isOpenGLCompositing()) {
|
2012-03-09 01:20:01 +00:00
|
|
|
m_fbo->blitFromFramebuffer(srcArea);
|
|
|
|
// paint magnifier
|
|
|
|
m_texture->bind();
|
|
|
|
m_texture->render(infiniteRegion(), area);
|
|
|
|
m_texture->unbind();
|
|
|
|
QVector<float> verts;
|
|
|
|
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
|
|
|
|
vbo->reset();
|
|
|
|
vbo->setColor(QColor(0, 0, 0));
|
|
|
|
// top frame
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.top() - FRAME_WIDTH;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.top() - 1;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.top() - 1;
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.top() - 1;
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
|
|
|
|
// left frame
|
|
|
|
verts << area.left() - 1 << area.top() - FRAME_WIDTH;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.top() - FRAME_WIDTH;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.left() - 1 << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.left() - 1 << area.top() - FRAME_WIDTH;
|
|
|
|
// right frame
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
|
|
|
|
verts << area.right() + 1 << area.top() - FRAME_WIDTH;
|
|
|
|
verts << area.right() + 1 << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.right() + 1 << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.top() - FRAME_WIDTH;
|
|
|
|
// bottom frame
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.bottom() + 1;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.bottom() + 1;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.left() - FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.bottom() + FRAME_WIDTH;
|
|
|
|
verts << area.right() + FRAME_WIDTH << area.bottom() + 1;
|
|
|
|
vbo->setData(verts.size() / 2, 2, verts.constData(), NULL);
|
2012-09-21 09:25:08 +00:00
|
|
|
|
|
|
|
ShaderBinder binder(ShaderManager::ColorShader);
|
2012-03-09 01:20:01 +00:00
|
|
|
vbo->render(GL_TRIANGLES);
|
2011-01-06 13:29:13 +00:00
|
|
|
}
|
2012-03-09 01:20:01 +00:00
|
|
|
if (effects->compositingType() == XRenderCompositing) {
|
2012-05-26 07:05:05 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2013-01-28 18:54:27 +00:00
|
|
|
if (m_pixmap == XCB_PIXMAP_NONE || m_pixmapSize != srcArea.size()) {
|
|
|
|
destroyPixmap();
|
|
|
|
m_pixmap = xcb_generate_id(connection());
|
|
|
|
m_pixmapSize = srcArea.size();
|
|
|
|
xcb_create_pixmap(connection(), 32, m_pixmap, rootWindow(), m_pixmapSize.width(), m_pixmapSize.height());
|
|
|
|
m_picture.reset(new XRenderPicture(m_pixmap, 32));
|
2012-03-09 01:20:01 +00:00
|
|
|
}
|
2013-01-28 18:54:27 +00:00
|
|
|
#define DOUBLE_TO_FIXED(d) ((xcb_render_fixed_t) ((d) * 65536))
|
|
|
|
static xcb_render_transform_t identity = {
|
|
|
|
DOUBLE_TO_FIXED(1), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0),
|
|
|
|
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1), DOUBLE_TO_FIXED(0),
|
|
|
|
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1)
|
|
|
|
};
|
|
|
|
static xcb_render_transform_t xform = {
|
|
|
|
DOUBLE_TO_FIXED(1), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0),
|
|
|
|
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1), DOUBLE_TO_FIXED(0),
|
|
|
|
DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(0), DOUBLE_TO_FIXED(1)
|
2012-03-09 01:20:01 +00:00
|
|
|
};
|
2013-01-28 18:54:27 +00:00
|
|
|
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), 0, *m_picture,
|
|
|
|
srcArea.x(), srcArea.y(), 0, 0, 0, 0, srcArea.width(), srcArea.height());
|
|
|
|
xcb_flush(connection());
|
|
|
|
xform.matrix11 = DOUBLE_TO_FIXED(1.0/zoom);
|
|
|
|
xform.matrix22 = DOUBLE_TO_FIXED(1.0/zoom);
|
|
|
|
#undef DOUBLE_TO_FIXED
|
|
|
|
xcb_render_set_picture_transform(connection(), *m_picture, xform);
|
|
|
|
xcb_render_set_picture_filter(connection(), *m_picture, 4, const_cast<char*>("good"), 0, NULL);
|
|
|
|
xcb_render_composite(connection(), XCB_RENDER_PICT_OP_SRC, *m_picture, 0, effects->xrenderBufferPicture(),
|
|
|
|
0, 0, 0, 0, area.x(), area.y(), area.width(), area.height() );
|
|
|
|
xcb_render_set_picture_filter(connection(), *m_picture, 4, const_cast<char*>("fast"), 0, NULL);
|
|
|
|
xcb_render_set_picture_transform(connection(), *m_picture, identity);
|
|
|
|
const xcb_rectangle_t rects[4] = {
|
|
|
|
{ int16_t(area.x()+FRAME_WIDTH), int16_t(area.y()), uint16_t(area.width()-FRAME_WIDTH), uint16_t(FRAME_WIDTH)},
|
|
|
|
{ int16_t(area.right()-FRAME_WIDTH), int16_t(area.y()+FRAME_WIDTH), uint16_t(FRAME_WIDTH), uint16_t(area.height()-FRAME_WIDTH)},
|
|
|
|
{ int16_t(area.x()), int16_t(area.bottom()-FRAME_WIDTH), uint16_t(area.width()-FRAME_WIDTH), uint16_t(FRAME_WIDTH)},
|
|
|
|
{ int16_t(area.x()), int16_t(area.y()), uint16_t(FRAME_WIDTH), uint16_t(area.height()-FRAME_WIDTH)}
|
2012-03-09 01:20:01 +00:00
|
|
|
};
|
2013-01-28 18:54:27 +00:00
|
|
|
// TODO: remove XRenderColor
|
|
|
|
const XRenderColor xc = preMultiply(QColor(0,0,0,255));
|
|
|
|
const xcb_render_color_t c = {xc.red, xc.green, xc.blue, xc.alpha};
|
|
|
|
xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, effects->xrenderBufferPicture(), c, 4, rects);
|
2012-05-26 07:05:05 +00:00
|
|
|
#endif
|
2011-01-06 13:29:13 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void MagnifierEffect::postPaintScreen()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (zoom != target_zoom) {
|
|
|
|
QRect framedarea = magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH);
|
|
|
|
effects->addRepaint(framedarea);
|
2007-09-14 13:40:26 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
effects->postPaintScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect MagnifierEffect::magnifierArea(QPoint pos) const
|
|
|
|
{
|
|
|
|
return QRect(pos.x() - magnifier_size.width() / 2, pos.y() - magnifier_size.height() / 2,
|
|
|
|
magnifier_size.width(), magnifier_size.height());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void MagnifierEffect::zoomIn()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
target_zoom *= 1.2;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!polling) {
|
2009-02-01 15:16:52 +00:00
|
|
|
polling = true;
|
|
|
|
effects->startMousePolling();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-08-20 08:53:36 +00:00
|
|
|
if (!m_texture) {
|
|
|
|
m_texture = new GLTexture(magnifier_size);
|
|
|
|
m_texture->setYInverted(false);
|
2011-07-17 15:57:30 +00:00
|
|
|
m_fbo = new GLRenderTarget(*m_texture);
|
2011-08-20 08:53:36 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH));
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void MagnifierEffect::zoomOut()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
target_zoom /= 1.2;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (target_zoom < 1) {
|
2009-04-27 20:20:05 +00:00
|
|
|
target_zoom = 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (polling) {
|
2009-04-27 20:20:05 +00:00
|
|
|
polling = false;
|
|
|
|
effects->stopMousePolling();
|
2009-02-01 15:16:52 +00:00
|
|
|
}
|
2011-09-07 07:31:31 +00:00
|
|
|
if (zoom == target_zoom) {
|
|
|
|
delete m_fbo;
|
|
|
|
delete m_texture;
|
|
|
|
m_fbo = NULL;
|
|
|
|
m_texture = NULL;
|
2013-01-28 18:54:27 +00:00
|
|
|
destroyPixmap();
|
2011-09-07 07:31:31 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH));
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void MagnifierEffect::toggle()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-04-13 10:05:23 +00:00
|
|
|
if (zoom == 1.0) {
|
|
|
|
if (target_zoom == 1.0) {
|
|
|
|
target_zoom = 2;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!polling) {
|
2009-04-27 20:20:05 +00:00
|
|
|
polling = true;
|
|
|
|
effects->startMousePolling();
|
|
|
|
}
|
2011-08-20 08:53:36 +00:00
|
|
|
if (!m_texture) {
|
|
|
|
m_texture = new GLTexture(magnifier_size);
|
|
|
|
m_texture->setYInverted(false);
|
2011-07-17 15:57:30 +00:00
|
|
|
m_fbo = new GLRenderTarget(*m_texture);
|
2011-08-20 08:53:36 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
target_zoom = 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (polling) {
|
2009-04-27 20:20:05 +00:00
|
|
|
polling = false;
|
|
|
|
effects->stopMousePolling();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH));
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-03-12 13:37:30 +00:00
|
|
|
void MagnifierEffect::slotMouseChanged(const QPoint& pos, const QPoint& old,
|
2011-01-30 14:34:42 +00:00
|
|
|
Qt::MouseButtons, Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers)
|
|
|
|
{
|
|
|
|
if (pos != old && zoom != 1)
|
2009-04-27 17:36:20 +00:00
|
|
|
// need full repaint as we might lose some change events on fast mouse movements
|
|
|
|
// see Bug 187658
|
|
|
|
effects->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-08-27 09:21:31 +00:00
|
|
|
bool MagnifierEffect::isActive() const
|
|
|
|
{
|
|
|
|
return zoom != 1.0 || zoom != target_zoom;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "magnifier.moc"
|