Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QVNCCursor Class Reference

#include <qscreenvnc_p.h>

Inheritance diagram for QVNCCursor:
QPlatformSoftwareCursor QProxyScreenCursor QPlatformCursor QScreenCursor QObject

Public Functions

void changeCursor (QCursor *widgetCursor, QWidget *widget)
 This method is called by Qt whenever the cursor graphic should be changed. More...
 
void clearClientCursor ()
 
QRect drawCursor (QPainter &)
 
void hide ()
 Reimplemented Function More...
 
void move (int x, int y)
 Reimplemented Function More...
 
 QVNCCursor (QVNCServer *, QVNCScreen *)
 
 QVNCCursor (QVNCScreen *s)
 
void sendClientCursor ()
 
void set (const QImage &image, int hotx, int hoty)
 Reimplemented Function More...
 
void setCursorMode (bool vnc)
 
void show ()
 Reimplemented Function More...
 
 ~QVNCCursor ()
 
- Public Functions inherited from QPlatformSoftwareCursor
QRect dirtyRect ()
 
virtual bool isDirty ()
 
virtual bool isOnScreen ()
 
virtual QRect lastPainted ()
 
virtual void pointerEvent (const QMouseEvent &event)
 This method is called by Qt whenever a QMouseEvent is generated by the underlying pointer input. More...
 
 QPlatformSoftwareCursor (QPlatformScreen *scr)
 
virtual void setDirty ()
 
- Public Functions inherited from QPlatformCursor
virtual QPoint pos () const
 
 QPlatformCursor (QPlatformScreen *)
 Constructs a QPlatformCursor for the given screen. More...
 
virtual void setPos (const QPoint &pos)
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QProxyScreenCursor
 QProxyScreenCursor ()
 Constructs a proxy screen cursor. More...
 
QScreenCursorscreenCursor () const
 Returns the real screen cursor used by the proxy screen cursor. More...
 
void setScreenCursor (QScreenCursor *cursor)
 Sets the real screen cursor to be used for the proxy screen cursor to the cursor specified. More...
 
 ~QProxyScreenCursor ()
 Destroys the proxy screen cursor. More...
 
- Public Functions inherited from QScreenCursor
QRect boundingRect () const
 Returns the cursor's bounding rectangle. More...
 
QImage image () const
 Returns the cursor's image. More...
 
bool isAccelerated () const
 Returns true if the cursor is accelerated; otherwise false. More...
 
bool isVisible () const
 Returns true if the cursor is visible; otherwise false. More...
 
 QScreenCursor ()
 Constructs a screen cursor. More...
 
bool supportsAlphaCursor () const
 
virtual ~QScreenCursor ()
 Destroys the screen cursor. More...
 

Private Functions

void setDirty (const QRect &r) const
 

Properties

QVNCScreenscreen
 
QVNCServerserver
 
bool useVncCursor
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
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 receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
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. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QScreenCursor
static bool enabled ()
 
static void initSoftwareCursor ()
 Initializes the screen cursor. More...
 
static QScreenCursorinstance ()
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QPlatformSoftwareCursor
QPlatformCursorImagegraphic
 
- Protected Variables inherited from QPlatformCursor
QPlatformScreenscreen
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QScreenCursor
QImage cursor
 
uint enable: 1
 
QPoint hotspot
 
uint hwaccel: 1
 
QPoint pos
 
QSize size
 
uint supportsAlpha: 1
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 70 of file qscreenvnc_p.h.

Constructors and Destructors

◆ QVNCCursor() [1/2]

QVNCCursor::QVNCCursor ( QVNCScreen s)

Definition at line 71 of file qscreenvnc_qws.cpp.

72  : screen(s)
73 {
74  if (qt_screencursor)
76  else
77  hwaccel = true;
78 }
void setScreenCursor(QScreenCursor *cursor)
Sets the real screen cursor to be used for the proxy screen cursor to the cursor specified.
QVNCScreen * screen
Definition: qscreenvnc_p.h:83
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67

◆ ~QVNCCursor()

QVNCCursor::~QVNCCursor ( )

Definition at line 80 of file qscreenvnc_qws.cpp.

81 {
82  if (screenCursor())
84 }
QScreenCursor * screenCursor() const
Returns the real screen cursor used by the proxy screen cursor.
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67

◆ QVNCCursor() [2/2]

QVNCCursor::QVNCCursor ( QVNCServer srvr,
QVNCScreen scr 
)

Definition at line 56 of file qvnccursor.cpp.

57  :QPlatformSoftwareCursor(scr), useVncCursor(false), server(srvr)
58 {
59 }
QPlatformSoftwareCursor(QPlatformScreen *scr)
Definition: fb_base.cpp:49
bool useVncCursor
Definition: qvnccursor.h:69
QVNCServer * server
Definition: qvnccursor.h:71

Functions

◆ changeCursor()

void QVNCCursor::changeCursor ( QCursor widgetCursor,
QWidget widget 
)
virtual

This method is called by Qt whenever the cursor graphic should be changed.

Implementation of this method is mandatory for a subclass of QPlatformCursor.

widgetCursor is a pointer to the QCursor that should be displayed.

widget is a pointer to the widget currently displayed at QCursor::pos(). Note that this may be 0 if the current position is not occupied by a displayed widget.

See also
QCursor::pos()

Reimplemented from QPlatformSoftwareCursor.

Definition at line 61 of file qvnccursor.cpp.

62 {
63  QPlatformSoftwareCursor::changeCursor(widgetCursor, widget);
64  if (useVncCursor) {
66  } else {
67  setDirty();
68  }
69 }
bool useVncCursor
Definition: qvnccursor.h:69
virtual void changeCursor(QCursor *widgetCursor, QWidget *widget)
This method is called by Qt whenever the cursor graphic should be changed.
Definition: fb_base.cpp:120
void setDirtyCursor()
Definition: qscreenvnc_p.h:440
QVNCServer * server
Definition: qvnccursor.h:71
virtual void setDirty()
Definition: fb_base.h:73

◆ clearClientCursor()

void QVNCCursor::clearClientCursor ( )

Definition at line 90 of file qvnccursor.cpp.

Referenced by sendClientCursor().

91 {
92  QTcpSocket *socket = server->clientSocket();
93  if (!socket) {
94  return;
95  }
96  // FramebufferUpdate header
97  {
98  const quint16 tmp[6] = { htons(0),
99  htons(1),
100  htons(0), htons(0),
101  htons(0),
102  htons(0) };
103  socket->write((char*)tmp, sizeof(tmp));
104 
105  const quint32 encoding = htonl(-239);
106  socket->write((char*)(&encoding), sizeof(encoding));
107  }
108 }
unsigned short quint16
Definition: qglobal.h:936
The QTcpSocket class provides a TCP socket.
Definition: qtcpsocket.h:56
QTcpSocket * clientSocket() const
Definition: qscreenvnc_p.h:463
QVNCServer * server
Definition: qvnccursor.h:71
unsigned int quint32
Definition: qglobal.h:938
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ drawCursor()

QRect QVNCCursor::drawCursor ( QPainter painter)
virtual

Reimplemented from QPlatformSoftwareCursor.

Definition at line 82 of file qvnccursor.cpp.

83 {
84  if (useVncCursor)
85  return QRect();
86 
88 }
bool useVncCursor
Definition: qvnccursor.h:69
virtual QRect drawCursor(QPainter &painter)
Definition: fb_base.cpp:78
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ hide()

void QVNCCursor::hide ( )
virtual

Reimplemented Function

Reimplemented from QProxyScreenCursor.

Definition at line 91 of file qscreenvnc_qws.cpp.

92 {
94  if (enable)
96 }
void hide()
Reimplemented Function
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
virtual void setDirty()
Definition: fb_base.h:73

◆ move()

void QVNCCursor::move ( int  x,
int  y 
)
virtual

Reimplemented Function

Reimplemented from QProxyScreenCursor.

Definition at line 117 of file qscreenvnc_qws.cpp.

118 {
122  dirty |= boundingRect();
123  if (enable) {
124  const QVector<QRect> rects = dirty.rects();
125  for (int i = 0; i < rects.size(); ++i)
126  setDirty(rects.at(i));
127  }
128  } else {
130  }
131 }
bool hasClientCursor() const
Definition: qscreenvnc_p.h:467
QVNCScreen * screen
Definition: qscreenvnc_p.h:83
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
virtual void setDirty()
Definition: fb_base.h:73
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVNCScreenPrivate * d_ptr
void move(int x, int y)
Reimplemented Function
QVNCServer * vncServer
Definition: qscreenvnc_p.h:255

◆ sendClientCursor()

void QVNCCursor::sendClientCursor ( )

Definition at line 110 of file qvnccursor.cpp.

111 {
112  if (useVncCursor == false) {
114  return;
115  }
116  QImage *image = graphic->image();
117  if (image->isNull())
118  return;
119  QTcpSocket *socket = server->clientSocket();
120  if (!socket) {
121  return;
122  }
123  // FramebufferUpdate header
124  {
125  const quint16 tmp[6] = { htons(0),
126  htons(1),
127  htons(graphic->hotspot().x()), htons(graphic->hotspot().y()),
128  htons(image->width()),
129  htons(image->height()) };
130  socket->write((char*)tmp, sizeof(tmp));
131 
132  const quint32 encoding = htonl(-239);
133  socket->write((char*)(&encoding), sizeof(encoding));
134  }
135 
136  // write pixels
137  //Q_ASSERT(cursor->hasAlphaChannel());
138  const QImage img = image->convertToFormat(QImage::Format_RGB32);
139  const int n = server->clientBytesPerPixel() * img.width();
140  char *buffer = new char[n];
141  for (int i = 0; i < img.height(); ++i) {
142  server->convertPixels(buffer, (const char*)img.scanLine(i), img.width());
143  socket->write(buffer, n);
144  }
145  delete[] buffer;
146 
147  // write mask
149  Q_ASSERT(bitmap.depth() == 1);
150  Q_ASSERT(bitmap.size() == img.size());
151  const int width = (bitmap.width() + 7) / 8;
152  for (int i = 0; i < bitmap.height(); ++i)
153  socket->write((const char*)bitmap.scanLine(i), width);
154 }
void convertPixels(char *dst, const char *src, int count) const
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
void clearClientCursor()
Definition: qvnccursor.cpp:90
bool useVncCursor
Definition: qvnccursor.h:69
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QImage image() const
Returns the cursor&#39;s image.
Definition: qscreen_qws.h:151
unsigned short quint16
Definition: qglobal.h:936
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QImage createAlphaMask(Qt::ImageConversionFlags flags=Qt::AutoColor) const
Builds and returns a 1-bpp mask from the alpha buffer in this image.
Definition: qimage.cpp:4720
The QTcpSocket class provides a TCP socket.
Definition: qtcpsocket.h:56
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
QImage * image()
Return the cursor graphic as a pointer to a QImage.
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
QTcpSocket * clientSocket() const
Definition: qscreenvnc_p.h:463
QPoint hotspot()
Return the cursor&#39;s hotspot.
QVNCServer * server
Definition: qvnccursor.h:71
unsigned int quint32
Definition: qglobal.h:938
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
QPlatformCursorImage * graphic
Definition: fb_base.h:79
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
int clientBytesPerPixel() const
Definition: qscreenvnc_p.h:457

◆ set()

void QVNCCursor::set ( const QImage image,
int  hotx,
int  hoty 
)
virtual

Reimplemented Function

Reimplemented from QProxyScreenCursor.

Definition at line 105 of file qscreenvnc_qws.cpp.

106 {
108  QProxyScreenCursor::set(image, hotx, hoty);
109  dirty |= boundingRect();
111  const QVector<QRect> rects = dirty.rects();
112  for (int i = 0; i < rects.size(); ++i)
113  setDirty(rects.at(i));
114  }
115 }
bool hasClientCursor() const
Definition: qscreenvnc_p.h:467
QVNCScreen * screen
Definition: qscreenvnc_p.h:83
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void set(const QImage &image, int hotx, int hoty)
Reimplemented Function
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
virtual void setDirty()
Definition: fb_base.h:73
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVNCScreenPrivate * d_ptr
QVNCServer * vncServer
Definition: qscreenvnc_p.h:255

◆ setCursorMode()

void QVNCCursor::setCursorMode ( bool  vnc)

Definition at line 71 of file qvnccursor.cpp.

72 {
73  if (vnc) {
74  setDirty();
76  } else {
78  }
79  useVncCursor = vnc;
80 }
bool useVncCursor
Definition: qvnccursor.h:69
void setDirtyCursor()
Definition: qscreenvnc_p.h:440
QVNCServer * server
Definition: qvnccursor.h:71
virtual void setDirty()
Definition: fb_base.h:73

◆ setDirty()

void QVNCCursor::setDirty ( const QRect r) const
private

Definition at line 86 of file qscreenvnc_qws.cpp.

87 {
88  screen->d_ptr->setDirty(r, true);
89 }
void setDirty(const QRect &rect, bool force=false)
QVNCScreen * screen
Definition: qscreenvnc_p.h:83
QVNCScreenPrivate * d_ptr

◆ show()

void QVNCCursor::show ( )
virtual

Reimplemented Function

Reimplemented from QProxyScreenCursor.

Definition at line 98 of file qscreenvnc_qws.cpp.

99 {
101  if (enable)
103 }
void show()
Reimplemented Function
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
virtual void setDirty()
Definition: fb_base.h:73

Properties

◆ screen

QVNCScreen* QVNCCursor::screen
private

Definition at line 83 of file qscreenvnc_p.h.

Referenced by move(), set(), and setDirty().

◆ server

QVNCServer* QVNCCursor::server
private

◆ useVncCursor

bool QVNCCursor::useVncCursor
private

Definition at line 69 of file qvnccursor.h.

Referenced by changeCursor(), drawCursor(), sendClientCursor(), and setCursorMode().


The documentation for this class was generated from the following files: