Implement QXcbIntegration::queryKeyboardModifiers()

Change-Id: Ifd2255362f5ef005e2a57f4001a72d932497b453
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
David Faure 2012-06-22 01:30:39 +02:00 committed by Qt by Nokia
parent 3506ee51b2
commit 9a16e14666
4 changed files with 19 additions and 3 deletions

View File

@ -506,7 +506,7 @@ xcb_cursor_t QXcbCursor::createBitmapCursor(QCursor *cursor)
return c;
}
static void getPosAndRoot(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos)
void QXcbCursor::queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos, int *keybMask)
{
if (pos)
*pos = QPoint();
@ -521,6 +521,8 @@ static void getPosAndRoot(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint
*pos = QPoint(reply->root_x, reply->root_y);
if (rootWin)
*rootWin = root;
if (keybMask)
*keybMask = reply->mask;
free(reply);
return;
}
@ -533,7 +535,7 @@ static void getPosAndRoot(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint
QPoint QXcbCursor::pos() const
{
QPoint p;
getPosAndRoot(xcb_connection(), 0, &p);
queryPointer(xcb_connection(), 0, &p);
return p;
}
@ -541,7 +543,7 @@ void QXcbCursor::setPos(const QPoint &pos)
{
xcb_connection_t *conn = xcb_connection();
xcb_window_t root;
getPosAndRoot(conn, &root, 0);
queryPointer(conn, &root, 0);
xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y());
xcb_flush(conn);
}

View File

@ -56,6 +56,8 @@ public:
QPoint pos() const;
void setPos(const QPoint &pos);
static void queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos, int *keybMask = 0);
private:
xcb_cursor_t createFontCursor(int cshape);
xcb_cursor_t createBitmapCursor(QCursor *cursor);

View File

@ -43,6 +43,8 @@
#include "qxcbconnection.h"
#include "qxcbscreen.h"
#include "qxcbwindow.h"
#include "qxcbcursor.h"
#include "qxcbkeyboard.h"
#include "qxcbbackingstore.h"
#include "qxcbnativeinterface.h"
#include "qxcbclipboard.h"
@ -257,6 +259,14 @@ QPlatformServices *QXcbIntegration::services() const
return m_services.data();
}
Qt::KeyboardModifiers QXcbIntegration::queryKeyboardModifiers() const
{
int keybMask = 0;
QXcbConnection* conn = m_connections.at(0);
QXcbCursor::queryPointer(conn->xcb_connection(), 0, 0, &keybMask);
return conn->keyboard()->translateModifiers(keybMask);
}
QStringList QXcbIntegration::themeNames() const
{
return QGenericUnixTheme::themeNames();

View File

@ -87,6 +87,8 @@ public:
QPlatformServices *services() const;
Qt::KeyboardModifiers queryKeyboardModifiers() const;
QStringList themeNames() const;
QPlatformTheme *createPlatformTheme(const QString &name) const;