Diffstat (limited to 'noncore/comm/keypebble/krfbbuffer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/comm/keypebble/krfbbuffer.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/noncore/comm/keypebble/krfbbuffer.cpp b/noncore/comm/keypebble/krfbbuffer.cpp index 4cec0c2..4b29612 100644 --- a/noncore/comm/keypebble/krfbbuffer.cpp +++ b/noncore/comm/keypebble/krfbbuffer.cpp | |||
@@ -1,109 +1,117 @@ | |||
1 | #include <assert.h> | ||
2 | #include <qimage.h> | ||
3 | #include <qpainter.h> | ||
4 | #include <qapplication.h> | ||
5 | #include "krfbdecoder.h" | 1 | #include "krfbdecoder.h" |
6 | #include "krfbbuffer.h" | 2 | #include "krfbbuffer.h" |
7 | #include "krfbconnection.h" | 3 | #include "krfbconnection.h" |
8 | #include "krfbserverinfo.h" | 4 | #include "krfbserverinfo.h" |
9 | 5 | ||
6 | /* OPIE */ | ||
7 | #include <opie2/odebug.h> | ||
8 | using namespace Opie::Core; | ||
9 | |||
10 | /* QT */ | ||
11 | #include <qimage.h> | ||
12 | #include <qpainter.h> | ||
13 | #include <qapplication.h> | ||
14 | |||
15 | /* STD */ | ||
16 | #include <assert.h> | ||
17 | |||
10 | // | 18 | // |
11 | // Endian stuff | 19 | // Endian stuff |
12 | // | 20 | // |
13 | #ifndef KDE_USE_FINAL | 21 | #ifndef OPIE_NO_DEBUG |
14 | const int endianTest = 1; | 22 | const int endianTest = 1; |
15 | #endif | 23 | #endif |
16 | 24 | ||
17 | #define Swap16IfLE(s) \ | 25 | #define Swap16IfLE(s) \ |
18 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) | 26 | (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) |
19 | 27 | ||
20 | #define Swap32IfLE(l) \ | 28 | #define Swap32IfLE(l) \ |
21 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ | 29 | (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \ |
22 | (((l) & 0x00ff0000) >> 8) | \ | 30 | (((l) & 0x00ff0000) >> 8) | \ |
23 | (((l) & 0x0000ff00) << 8) | \ | 31 | (((l) & 0x0000ff00) << 8) | \ |
24 | (((l) & 0x000000ff) << 24)) : (l)) | 32 | (((l) & 0x000000ff) << 24)) : (l)) |
25 | 33 | ||
26 | KRFBBuffer::KRFBBuffer( KRFBDecoder *decoder, | 34 | KRFBBuffer::KRFBBuffer( KRFBDecoder *decoder, |
27 | QObject *parent, const char *name ) | 35 | QObject *parent, const char *name ) |
28 | : QObject( parent, name ) | 36 | : QObject( parent, name ) |
29 | { | 37 | { |
30 | assert( decoder ); | 38 | assert( decoder ); |
31 | this->decoder = decoder; | 39 | this->decoder = decoder; |
32 | pix = new QPixmap(); | 40 | pix = new QPixmap(); |
33 | } | 41 | } |
34 | 42 | ||
35 | KRFBBuffer::~KRFBBuffer() | 43 | KRFBBuffer::~KRFBBuffer() |
36 | { | 44 | { |
37 | delete pix; | 45 | delete pix; |
38 | } | 46 | } |
39 | 47 | ||
40 | void KRFBBuffer::resize( int w, int h ) | 48 | void KRFBBuffer::resize( int w, int h ) |
41 | { | 49 | { |
42 | qWarning( "Resizing buffer" ); | 50 | owarn << "Resizing buffer" << oendl; |
43 | 51 | ||
44 | pix->resize( w, h ); | 52 | pix->resize( w, h ); |
45 | 53 | ||
46 | QPalette pal = qApp->palette(); | 54 | QPalette pal = qApp->palette(); |
47 | pix->fill( pal.active().base() ); | 55 | pix->fill( pal.active().base() ); |
48 | 56 | ||
49 | emit sizeChanged( w, h ); | 57 | emit sizeChanged( w, h ); |
50 | } | 58 | } |
51 | 59 | ||
52 | void KRFBBuffer::soundBell() | 60 | void KRFBBuffer::soundBell() |
53 | { | 61 | { |
54 | emit bell(); | 62 | emit bell(); |
55 | } | 63 | } |
56 | 64 | ||
57 | void KRFBBuffer::mouseEvent( QMouseEvent *e ) | 65 | void KRFBBuffer::mouseEvent( QMouseEvent *e ) |
58 | { | 66 | { |
59 | decoder->sendMouseEvent( e ); | 67 | decoder->sendMouseEvent( e ); |
60 | } | 68 | } |
61 | 69 | ||
62 | void KRFBBuffer::keyPressEvent( QKeyEvent *e ) | 70 | void KRFBBuffer::keyPressEvent( QKeyEvent *e ) |
63 | { | 71 | { |
64 | qWarning( "Buffer got a key" ); | 72 | owarn << "Buffer got a key" << oendl; |
65 | 73 | ||
66 | decoder->sendKeyPressEvent( e ); | 74 | decoder->sendKeyPressEvent( e ); |
67 | } | 75 | } |
68 | 76 | ||
69 | void KRFBBuffer::keyReleaseEvent( QKeyEvent *e ) | 77 | void KRFBBuffer::keyReleaseEvent( QKeyEvent *e ) |
70 | { | 78 | { |
71 | decoder->sendKeyReleaseEvent( e ); | 79 | decoder->sendKeyReleaseEvent( e ); |
72 | } | 80 | } |
73 | 81 | ||
74 | void KRFBBuffer::copyRect( int srcX, int srcY, | 82 | void KRFBBuffer::copyRect( int srcX, int srcY, |
75 | int destX, int destY, int w, int h ) | 83 | int destX, int destY, int w, int h ) |
76 | { | 84 | { |
77 | // qWarning( "Got copy rect" ); | 85 | // owarn << "Got copy rect" << oendl; |
78 | bitBlt( pix, destX, destY, pix, srcX, srcY, w, h, CopyROP ); | 86 | bitBlt( pix, destX, destY, pix, srcX, srcY, w, h, CopyROP ); |
79 | 87 | ||
80 | emit updated( destX, destY, w, h ); | 88 | emit updated( destX, destY, w, h ); |
81 | } | 89 | } |
82 | 90 | ||
83 | void KRFBBuffer::drawRawRectChunk( void *data, | 91 | void KRFBBuffer::drawRawRectChunk( void *data, |
84 | int x, int y, int w, int h ) | 92 | int x, int y, int w, int h ) |
85 | { | 93 | { |
86 | QImage img( w, h, 32 ); | 94 | QImage img( w, h, 32 ); |
87 | 95 | ||
88 | int scaleFactor=decoder->con->options()->scaleFactor; | 96 | int scaleFactor=decoder->con->options()->scaleFactor; |
89 | int redMax = Swap16IfLE( decoder->format->redMax ); | 97 | int redMax = Swap16IfLE( decoder->format->redMax ); |
90 | int greenMax = Swap16IfLE( decoder->format->greenMax ); | 98 | int greenMax = Swap16IfLE( decoder->format->greenMax ); |
91 | int blueMax = Swap16IfLE( decoder->format->blueMax ); | 99 | int blueMax = Swap16IfLE( decoder->format->blueMax ); |
92 | 100 | ||
93 | QPainter p( pix ); | 101 | QPainter p( pix ); |
94 | 102 | ||
95 | if ( decoder->format->bpp == 8 ) { | 103 | if ( decoder->format->bpp == 8 ) { |
96 | uchar *d = (unsigned char *) data; | 104 | uchar *d = (unsigned char *) data; |
97 | 105 | ||
98 | uint r,g,b; | 106 | uint r,g,b; |
99 | 107 | ||
100 | 108 | ||
101 | for ( int j = 0; j < h; j++) { | 109 | for ( int j = 0; j < h; j++) { |
102 | for ( int i = 0; i < w ; i++ ) { | 110 | for ( int i = 0; i < w ; i++ ) { |
103 | r = d[ j * w + i ]; | 111 | r = d[ j * w + i ]; |
104 | r = r >> decoder->format->redShift; | 112 | r = r >> decoder->format->redShift; |
105 | r = r & redMax; | 113 | r = r & redMax; |
106 | 114 | ||
107 | g = d[ j * w + i ]; | 115 | g = d[ j * w + i ]; |
108 | g = g >> decoder->format->greenShift; | 116 | g = g >> decoder->format->greenShift; |
109 | g = g & greenMax; | 117 | g = g & greenMax; |