Dummy implementation in RemoteView for scaleResize, so there will be no 'slot not...
[kdenetwork.git] / krfb / qtframebuffer.cpp
blob69c1d4877139e5618b4310e42e96e4f2ed22be1a
1 /* This file is part of the KDE project
2 Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8 */
10 #include "qtframebuffer.h"
11 #include "qtframebuffer.moc"
13 #include <QTimer>
14 #include <QRegion>
15 #include <QPixmap>
16 #include <QBitmap>
19 const int UPDATE_TIME = 500;
21 QtFrameBuffer::QtFrameBuffer(WId id, QObject *parent)
22 : FrameBuffer(id, parent)
24 fbImage = QPixmap::grabWindow(win).toImage();
25 fb = new char[fbImage.numBytes()];
26 t = new QTimer(this);
27 connect(t, SIGNAL(timeout()), SLOT(updateFrameBuffer()));
31 QtFrameBuffer::~QtFrameBuffer()
35 int QtFrameBuffer::depth()
37 return fbImage.depth();
40 int QtFrameBuffer::height()
42 return fbImage.height();
45 int QtFrameBuffer::width()
47 return fbImage.width();
50 void QtFrameBuffer::getServerFormat(rfbPixelFormat& format)
52 format.bitsPerPixel = 32;
53 format.depth = 32;
54 format.trueColour = true;
56 format.bigEndian = false;
57 format.redShift = 16;
58 format.greenShift = 8;
59 format.blueShift = 0;
60 format.redMax = 0xff;
61 format.greenMax = 0xff;
62 format.blueMax = 0xff;
65 void QtFrameBuffer::updateFrameBuffer()
67 QImage img = QPixmap::grabWindow(win).toImage();
68 QSize imgSize = img.size();
71 // verify what part of the image need to be marked as changed
72 // fbImage is the previous version of the image,
73 // img is the current one
75 #if 0 // This is actually slower than updating the whole desktop...
77 QImage map(imgSize, QImage::Format_Mono);
78 map.fill(0);
80 for (int x = 0; x < imgSize.width(); x++) {
81 for (int y = 0; y < imgSize.height(); y++) {
82 if (img.pixel(x,y) != fbImage.pixel(x,y)) {
83 map.setPixel(x,y,1);
88 QRegion r(QBitmap::fromImage(map));
89 tiles = tiles + r.rects();
91 #else
92 tiles.append(img.rect());
93 #endif
95 memcpy(fb, (const char*)img.bits(), img.numBytes());
96 fbImage = img;
100 int QtFrameBuffer::paddedWidth()
102 return fbImage.width() * 4;
105 void QtFrameBuffer::startMonitor()
107 t->start(UPDATE_TIME);
110 void QtFrameBuffer::stopMonitor()
112 t->stop();