1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 1992-2006 TROLLTECH ASA. All rights reserved.
|
---|
4 | **
|
---|
5 | ** This file is part of the Phone Edition of the Qt Toolkit.
|
---|
6 | **
|
---|
7 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
8 | ** Commercial Usage
|
---|
9 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
10 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
11 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
12 | ** a written agreement between you and Nokia.
|
---|
13 | **
|
---|
14 | ** GNU Lesser General Public License Usage
|
---|
15 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
16 | ** General Public License version 2.1 as published by the Free Software
|
---|
17 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
18 | ** packaging of this file. Please review the following information to
|
---|
19 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
20 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
21 | **
|
---|
22 | ** In addition, as a special exception, Nokia gives you certain
|
---|
23 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
24 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
25 | ** package.
|
---|
26 | **
|
---|
27 | ** GNU General Public License Usage
|
---|
28 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
29 | ** General Public License version 3.0 as published by the Free Software
|
---|
30 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
31 | ** packaging of this file. Please review the following information to
|
---|
32 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
33 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
34 | **
|
---|
35 | ** If you are unsure which license is appropriate for your use, please
|
---|
36 | ** contact the sales department at [email protected].
|
---|
37 | ** $QT_END_LICENSE$
|
---|
38 | **
|
---|
39 | ****************************************************************************/
|
---|
40 |
|
---|
41 | #include "qvfbx11view.h"
|
---|
42 | #include "x11keyfaker.h"
|
---|
43 | #include <qevent.h>
|
---|
44 | #include <QX11Info>
|
---|
45 | #include <QTimer>
|
---|
46 | #include <QProcess>
|
---|
47 | #include <QDebug>
|
---|
48 | #include <QUuid>
|
---|
49 | #include <QDataStream>
|
---|
50 | #include <QTemporaryFile>
|
---|
51 | #include <X11/Xlib.h>
|
---|
52 |
|
---|
53 | QT_BEGIN_NAMESPACE
|
---|
54 |
|
---|
55 | QVFbX11View::QVFbX11View
|
---|
56 | (int id, int w, int h, int d, Rotation r, QWidget *parent)
|
---|
57 | : QVFbAbstractView(parent)
|
---|
58 | {
|
---|
59 | this->id = id;
|
---|
60 | this->w = w;
|
---|
61 | this->h = h;
|
---|
62 | this->d = d;
|
---|
63 | this->rotation = r;
|
---|
64 | this->gr = 1.0;
|
---|
65 | this->gg = 1.0;
|
---|
66 | this->gb = 1.0;
|
---|
67 | this->touchscreen = false;
|
---|
68 | this->lcd = false;
|
---|
69 | this->keyFaker = 0;
|
---|
70 | this->xnest = 0;
|
---|
71 | this->serverAuthFile = 0;
|
---|
72 | this->shutdown = false;
|
---|
73 |
|
---|
74 | // Try to find Xephyr, as it is better than Xnest in many ways.
|
---|
75 | if (QFile::exists("/usr/bin/Xephyr"))
|
---|
76 | xserver = "/usr/bin/Xephyr";
|
---|
77 | else if (QFile::exists("/usr/local/bin/Xephyr"))
|
---|
78 | xserver = "/usr/local/bin/Xephyr";
|
---|
79 | else if (QFile::exists("/usr/X11R6/bin/Xephyr"))
|
---|
80 | xserver = "/usr/X11R6/bin/Xephyr";
|
---|
81 | else
|
---|
82 | xserver = "Xnest";
|
---|
83 | }
|
---|
84 |
|
---|
85 | QVFbX11View::~QVFbX11View()
|
---|
86 | {
|
---|
87 | shutdown = true;
|
---|
88 | if (xnest) {
|
---|
89 | xnest->terminate();
|
---|
90 | xnestStopped();
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | int QVFbX11View::displayId() const
|
---|
95 | {
|
---|
96 | return id;
|
---|
97 | }
|
---|
98 |
|
---|
99 | int QVFbX11View::displayWidth() const
|
---|
100 | {
|
---|
101 | return ( (int)rotation & 0x01 ) ? h : w;
|
---|
102 | }
|
---|
103 |
|
---|
104 | int QVFbX11View::displayHeight() const
|
---|
105 | {
|
---|
106 | return ( (int)rotation & 0x01 ) ? w : h;
|
---|
107 | }
|
---|
108 |
|
---|
109 | int QVFbX11View::displayDepth() const
|
---|
110 | {
|
---|
111 | return d;
|
---|
112 | }
|
---|
113 |
|
---|
114 | QVFbX11View::Rotation QVFbX11View::displayRotation() const
|
---|
115 | {
|
---|
116 | return rotation;
|
---|
117 | }
|
---|
118 |
|
---|
119 | void QVFbX11View::skinKeyPressEvent(int code, const QString&, bool)
|
---|
120 | {
|
---|
121 | if (keyFaker)
|
---|
122 | keyFaker->sendKeyEvent(code, true);
|
---|
123 | }
|
---|
124 |
|
---|
125 | void QVFbX11View::skinKeyReleaseEvent(int code, const QString&, bool)
|
---|
126 | {
|
---|
127 | if (keyFaker)
|
---|
128 | keyFaker->sendKeyEvent(code, false);
|
---|
129 | }
|
---|
130 |
|
---|
131 | void QVFbX11View::setGamma(double gr, double gg, double gb)
|
---|
132 | {
|
---|
133 | // We remember the values, but don't do anything with them.
|
---|
134 | this->gr = gr;
|
---|
135 | this->gg = gg;
|
---|
136 | this->gb = gb;
|
---|
137 | }
|
---|
138 |
|
---|
139 | double QVFbX11View::gammaRed() const
|
---|
140 | {
|
---|
141 | return gr;
|
---|
142 | }
|
---|
143 |
|
---|
144 | double QVFbX11View::gammaGreen() const
|
---|
145 | {
|
---|
146 | return gg;
|
---|
147 | }
|
---|
148 |
|
---|
149 | double QVFbX11View::gammaBlue() const
|
---|
150 | {
|
---|
151 | return gb;
|
---|
152 | }
|
---|
153 |
|
---|
154 | void QVFbX11View::getGamma(int, QRgb& rgb)
|
---|
155 | {
|
---|
156 | rgb = qRgb(255, 255, 255);
|
---|
157 | }
|
---|
158 |
|
---|
159 | bool QVFbX11View::touchScreenEmulation() const
|
---|
160 | {
|
---|
161 | return touchscreen;
|
---|
162 | }
|
---|
163 |
|
---|
164 | bool QVFbX11View::lcdScreenEmulation() const
|
---|
165 | {
|
---|
166 | return lcd;
|
---|
167 | }
|
---|
168 |
|
---|
169 | int QVFbX11View::rate()
|
---|
170 | {
|
---|
171 | // We don't support refresh rates, so return a default value.
|
---|
172 | return 30;
|
---|
|
---|