43 #include <sys/types.h> 50 #include <private/qcore_unix_p.h> 57 #include <QtGui/private/qpixmap_raster_p.h> 58 #include <QtCore/qdebug.h> 59 #include <QMouseEvent> 62 #include <QApplication> 63 #include <QWindowSystemInterface> 101 perror(
"QVFbScreenKeyboardHandler");
102 qWarning(
"QVFbScreenKeyboardHandler: Unable to open device %s",
138 qWarning(
"Instructed to quit by Virtual Keyboard");
156 int surplus =
kbdIdx - idx;
157 for (
int i = 0; i < surplus; i++)
173 void readMouseData();
178 enum {mouseBufSize = 128};
192 perror(
"QVFbMouseHandler::QVFbMouseHandler");
193 qWarning(
"QVFbMouseHander: Unable to open device %s",
200 while (
QT_READ(mouseFD, buf, 1) > 0) { }
219 n =
QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
225 static const int packetsize =
sizeof(
QPoint) + 2*
sizeof(
int);
226 while (mouseIdx-idx >= packetsize) {
227 uchar *mb = mouseBuf+idx;
230 int bstate = *
reinterpret_cast<int *
>(mb);
234 int button = bstate ^ oldButtonState;
244 oldButtonState = bstate;
249 int surplus = mouseIdx - idx;
250 for (
int i = 0; i < surplus; i++)
251 mouseBuf[i] = mouseBuf[idx+i];
261 : shmrgn(0), hdr(0),
data(0), mouseHandler(0), keyboardHandler(0)
268 void setDirty(
const QRect &r);
276 int depth()
const {
return img.depth(); }
280 unsigned char *shmrgn;
294 hdr->update = hdr->update.united(r);
300 qDebug() <<
"QVFbScreenPrivate::connect" << displayId;
307 int shmId = shmget(key, 0, 0);
309 shmrgn = (
unsigned char *)shmat(shmId, 0, 0);
313 if ((
long)shmrgn == -1 || shmrgn == 0) {
314 qDebug(
"No shmrgn %ld", (
long)shmrgn);
319 data = shmrgn + hdr->dataoffset;
324 int lstep = hdr->linestep;
340 qDebug(
"connected %dx%d %d bpp", w, h, d);
350 if ((
long)shmrgn != -1 && shmrgn) {
351 shmdt((
char*)shmrgn);
356 delete keyboardHandler;
374 d_ptr->setDirty(rect);
386 return d_ptr->depth();
391 return d_ptr->format();
395 return (
d_ptr->screenSize()*254)/720;
400 return d_ptr->screenImage() ?
d_ptr->screenImage()->bytesPerLine() : 0;
404 return d_ptr->screenImage() ?
d_ptr->screenImage()->bits() : 0;
410 return d_ptr->screenImage();
417 if (paramList.
length() > 0)
418 displayId = paramList.
at(0).
toInt();
448 #include "qvfbintegration.moc" QPixmapData * createPixmapData(QPixmapData::PixelType type) const
Factory function for QPixmapData.
QPlatformFontDatabase * fontDatabase() const
Accessor for the platform integrations fontdatabase.
QImage::Format format() const
Reimplement in subclass to return the image format which corresponds to the screen format...
QVFbScreenKeyboardHandler * keyboardHandler
Format
The following image formats are available in Qt.
~QVFbScreenKeyboardHandler()
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
QVFbScreenKeyboardHandler(int displayId)
QRect geometry() const
Reimplement in subclass to return the pixel geometry of the screen.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
int length() const
Returns the number of characters in this string.
The QVFbScreen class implements a screen driver for the virtual framebuffer.
static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
The QString class provides a Unicode character string.
QVFbIntegration(const QStringList ¶mList)
QVFbScreen * mPrimaryScreen
The QObject class is the base class of all Qt objects.
The QChar class provides a 16-bit Unicode character.
QPlatformFontDatabase * mFontDb
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
QSocketNotifier * keyNotifier
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
int linestep() const
Returns the length of each scanline of the framebuffer in bytes.
QSize physicalSize() const
Reimplement this function in subclass to return the physical size of the screen.
#define QT_VFB_KEYBOARD_PIPE(DISPLAY)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
static const char * data(const QByteArray &arr)
QVFbScreen(int display_id)
Constructs a QVNCScreen object.
QVFbScreenPrivate(int id)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
QVFbScreenMouseHandler(int displayId)
bool connect(int displayId)
The QWindowSurface class provides the drawing area for top-level windows.
~QVFbScreenMouseHandler()
const char * constData() const
Returns a pointer to the data stored in the byte array.
QPlatformWindow * createPlatformWindow(QWidget *widget, WId winId) const
Factory function for QPlatformWindow.
QWindowSurface * createWindowSurface(QWidget *widget, WId winId) const
Factory function for QWindowSurface.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
virtual ~QVFbScreen()
Destroys this QVFbScreen object.
#define QT_VFB_MOUSE_PIPE(DISPLAY)
uchar * base() const
Returns a pointer to the beginning of the framebuffer.
QList< QPlatformScreen * > mScreens
QSocketNotifier * mouseNotifier
Type
This enum type defines the valid event types in Qt.
int length() const
This function is identical to count().
The QPoint class defines a point in the plane using integer precision.
The QRect class defines a rectangle in the plane using integer precision.
unsigned short int unicode
QScopedPointer< QObjectData > d_ptr
int depth() const
Reimplement in subclass to return current depth of the screen.
The QSize class defines the size of a two-dimensional object using integer point precision.
QImage::Format format() const
void setDirty(const QRect &r)
#define qPrintable(string)
virtual void setDirty(const QRect &r)
Reimplemented Function
Qt::KeyboardModifiers modifiers
QVFbScreenMouseHandler * mouseHandler
unsigned char * kbdBuffer