Fix build with -no-feature-cursor

Change-Id: I971dbe7827adf0cf06337348a0d011632c364725
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Paul Olav Tvete 2017-02-16 14:58:13 +01:00 committed by Stephan Binner
parent 0684f28984
commit 1399cacb6b
5 changed files with 19 additions and 9 deletions

View File

@ -531,13 +531,12 @@ void QRfbRawEncoder::write()
socket->flush();
}
#if QT_CONFIG(cursor)
QVncClientCursor::QVncClientCursor()
{
#ifndef QT_NO_CURSOR
QWindow *w = QGuiApplication::focusWindow();
QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor);
changeCursor(&c, 0);
#endif
}
QVncClientCursor::~QVncClientCursor()
@ -587,7 +586,6 @@ void QVncClientCursor::write(QVncClient *client) const
void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
{
Q_UNUSED(window);
#ifndef QT_NO_CURSOR
const Qt::CursorShape shape = widgetCursor ? widgetCursor->shape() : Qt::ArrowCursor;
if (shape == Qt::BitmapCursor) {
@ -601,9 +599,6 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
cursor = *platformImage.image();
hotspot = platformImage.hotspot();
}
#else // !QT_NO_CURSOR
Q_UNUSED(widgetCursor);
#endif
for (auto client : clients)
client->setDirtyCursor();
}
@ -619,6 +614,7 @@ uint QVncClientCursor::removeClient(QVncClient *client)
clients.removeOne(client);
return clients.count();
}
#endif // QT_CONFIG(cursor)
QVncServer::QVncServer(QVncScreen *screen, quint16 port)
: qvnc_screen(screen)

View File

@ -364,6 +364,7 @@ private:
friend class QRfbMultiColorHextile<SRC>;
};
#if QT_CONFIG(cursor)
class QVncClientCursor : public QPlatformCursor
{
public:
@ -381,7 +382,7 @@ public:
QPoint hotspot;
QVector<QVncClient *> clients;
};
#endif // QT_CONFIG(cursor)
class QVncServer : public QObject
{

View File

@ -425,14 +425,14 @@ void QVncClient::checkUpdate()
{
if (!m_wantUpdate)
return;
#if QT_CONFIG(cursor)
if (m_dirtyCursor) {
m_server->screen()->clientCursor->write(this);
m_dirtyCursor = false;
m_wantUpdate = false;
return;
}
#endif
if (!m_dirtyRegion.isEmpty()) {
if (m_encoder)
m_encoder->write();

View File

@ -58,8 +58,10 @@ QVncScreen::QVncScreen(const QStringList &args)
QVncScreen::~QVncScreen()
{
#if QT_CONFIG(cursor)
if (clientCursor)
delete clientCursor;
#endif
}
bool QVncScreen::initialize()
@ -120,17 +122,21 @@ QRegion QVncScreen::doRedraw()
return touched;
}
void QVncScreen::enableClientCursor(QVncClient *client)
{
#if QT_CONFIG(cursor)
delete mCursor;
mCursor = nullptr;
if (!clientCursor)
clientCursor = new QVncClientCursor();
clientCursor->addClient(client);
#endif
}
void QVncScreen::disableClientCursor(QVncClient *client)
{
#if QT_CONFIG(cursor)
uint clientCount = clientCursor->removeClient(client);
if (clientCount == 0) {
delete clientCursor;
@ -138,11 +144,16 @@ void QVncScreen::disableClientCursor(QVncClient *client)
}
mCursor = new QFbCursor(this);
#endif
}
QPlatformCursor *QVncScreen::cursor() const
{
#if QT_CONFIG(cursor)
return mCursor ? static_cast<QPlatformCursor *>(mCursor) : static_cast<QPlatformCursor *>(clientCursor);
#else
return nullptr;
#endif
}
// grabWindow() grabs "from the screen" not from the backingstores.

View File

@ -86,7 +86,9 @@ public:
QRegion dirtyRegion;
int refreshRate = 30;
QVncServer *vncServer = 0;
#if QT_CONFIG(cursor)
QVncClientCursor *clientCursor = 0;
#endif
};
QT_END_NAMESPACE