Qt 4.8
Public Functions | Static Private Functions | Properties | Static Private Attributes | List of all members
QWaylandInputDevice Class Reference

#include <qwaylandinputdevice.h>

Inheritance diagram for QWaylandInputDevice:

Public Functions

void attach (QWaylandBuffer *buffer, int x, int y)
 
void handleWindowDestroyed (QWaylandWindow *window)
 
 QWaylandInputDevice (struct wl_display *display, uint32_t id)
 
struct wl_input_device * wl_input_device () const
 

Static Private Functions

static void inputHandleButton (void *data, struct wl_input_device *input_device, uint32_t time, uint32_t button, uint32_t state)
 
static void inputHandleKey (void *data, struct wl_input_device *input_device, uint32_t time, uint32_t key, uint32_t state)
 
static void inputHandleKeyboardFocus (void *data, struct wl_input_device *input_device, uint32_t time, struct wl_surface *surface, struct wl_array *keys)
 
static void inputHandleMotion (void *data, struct wl_input_device *input_device, uint32_t time, int32_t x, int32_t y, int32_t sx, int32_t sy)
 
static void inputHandlePointerFocus (void *data, struct wl_input_device *input_device, uint32_t time, struct wl_surface *surface, int32_t x, int32_t y, int32_t sx, int32_t sy)
 

Properties

Qt::MouseButtons mButtons
 
struct wl_display * mDisplay
 
QPoint mGlobalPos
 
struct wl_input_devicemInputDevice
 
QWaylandWindowmKeyboardFocus
 
Qt::KeyboardModifiers mModifiers
 
QWaylandWindowmPointerFocus
 
QPoint mSurfacePos
 
uint32_t mTime
 
struct xkb_desc * mXkb
 

Static Private Attributes

static const struct wl_input_device_listener inputDeviceListener
 

Detailed Description

Definition at line 341 of file qwaylandinputdevice.cpp.

Constructors and Destructors

◆ QWaylandInputDevice()

QWaylandInputDevice::QWaylandInputDevice ( struct wl_display *  display,
uint32_t  id 
)

Definition at line 61 of file qwaylandinputdevice.cpp.

63  : mDisplay(display)
64  , mInputDevice(wl_input_device_create(display, id, 1))
65  , mPointerFocus(NULL)
66  , mKeyboardFocus(NULL)
67  , mButtons(0)
68 {
69  wl_input_device_add_listener(mInputDevice,
71  this);
72  wl_input_device_set_user_data(mInputDevice, this);
73 
74 #ifndef QT_NO_WAYLAND_XKB
75  struct xkb_rule_names names;
76  names.rules = "evdev";
77  names.model = "pc105";
78  names.layout = "us";
79  names.variant = "";
80  names.options = "";
81 
82  mXkb = xkb_compile_keymap_from_rules(&names);
83 #endif
84 }
QWaylandWindow * mPointerFocus
struct wl_input_device * mInputDevice
Qt::MouseButtons mButtons
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
QWaylandWindow * mKeyboardFocus
struct wl_display * mDisplay
struct xkb_desc * mXkb
static const struct wl_input_device_listener inputDeviceListener

Functions

◆ attach()

void QWaylandInputDevice::attach ( QWaylandBuffer buffer,
int  x,
int  y 
)

Definition at line 349 of file qwaylandinputdevice.cpp.

Referenced by QWaylandDisplay::setCursor().

350 {
351  wl_input_device_attach(mInputDevice, mTime, buffer->buffer(), x, y);
352 }
struct wl_input_device * mInputDevice
wl_buffer * buffer()

◆ handleWindowDestroyed()

void QWaylandInputDevice::handleWindowDestroyed ( QWaylandWindow window)

Definition at line 86 of file qwaylandinputdevice.cpp.

Referenced by QWaylandWindow::~QWaylandWindow().

87 {
88  if (window == mPointerFocus)
89  mPointerFocus = 0;
90  if (window == mKeyboardFocus)
91  mKeyboardFocus = 0;
92 }
QWaylandWindow * mPointerFocus
QWaylandWindow * mKeyboardFocus

◆ inputHandleButton()

void QWaylandInputDevice::inputHandleButton ( void *  data,
struct wl_input_device input_device,
uint32_t  time,
uint32_t  button,
uint32_t  state 
)
staticprivate

Definition at line 120 of file qwaylandinputdevice.cpp.

123 {
124  Q_UNUSED(input_device);
125  QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
126  QWaylandWindow *window = inputDevice->mPointerFocus;
127  Qt::MouseButton qt_button;
128 
129  if (window == NULL) {
130  /* We destroyed the pointer focus surface, but the server
131  * didn't get the message yet. */
132  return;
133  }
134 
135  switch (button) {
136  case 272:
137  qt_button = Qt::LeftButton;
138  break;
139  case 273:
140  qt_button = Qt::RightButton;
141  break;
142  case 274:
143  qt_button = Qt::MiddleButton;
144  break;
145  default:
146  return;
147  }
148 
149  if (state)
150  inputDevice->mButtons |= qt_button;
151  else
152  inputDevice->mButtons &= ~qt_button;
153 
154  inputDevice->mTime = time;
156  time,
157  inputDevice->mSurfacePos,
158  inputDevice->mGlobalPos,
159  inputDevice->mButtons);
160 }
QWaylandWindow * mPointerFocus
Qt::MouseButtons mButtons
NSWindow * window
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
static const char * data(const QByteArray &arr)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.
MouseButton
Definition: qnamespace.h:150

◆ inputHandleKey()

void QWaylandInputDevice::inputHandleKey ( void *  data,
struct wl_input_device input_device,
uint32_t  time,
uint32_t  key,
uint32_t  state 
)
staticprivate

Definition at line 231 of file qwaylandinputdevice.cpp.

234 {
235 #ifndef QT_NO_WAYLAND_XKB
236  Q_UNUSED(input_device);
237  QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
238  QWaylandWindow *window = inputDevice->mKeyboardFocus;
239  uint32_t code, sym, level;
240  Qt::KeyboardModifiers modifiers;
242  char s[2];
243 
244  if (window == NULL) {
245  /* We destroyed the keyboard focus surface, but the server
246  * didn't get the message yet. */
247  return;
248  }
249 
250  code = key + inputDevice->mXkb->min_key_code;
251 
252  level = 0;
253  if (inputDevice->mModifiers & Qt::ShiftModifier &&
254  XkbKeyGroupWidth(inputDevice->mXkb, code, 0) > 1)
255  level = 1;
256 
257  sym = XkbKeySymEntry(inputDevice->mXkb, code, level, 0);
258 
259  modifiers = translateModifiers(inputDevice->mXkb->map->modmap[code]);
260 
261  if (state) {
262  inputDevice->mModifiers |= modifiers;
263  type = QEvent::KeyPress;
264  } else {
265  inputDevice->mModifiers &= ~modifiers;
266  type = QEvent::KeyRelease;
267  }
268 
269  sym = translateKey(sym, s, sizeof s);
270 
271  if (window) {
273  time, type, sym,
274  inputDevice->mModifiers,
276  }
277 #endif
278 }
int type
Definition: qmetatype.cpp:239
static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
static Qt::KeyboardModifiers translateModifiers(int s)
NSWindow * window
static const char * data(const QByteArray &arr)
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
QWaylandWindow * mKeyboardFocus
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
static uint32_t translateKey(uint32_t sym, char *string, size_t size)
int key
struct xkb_desc * mXkb
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
Qt::KeyboardModifiers mModifiers
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ inputHandleKeyboardFocus()

void QWaylandInputDevice::inputHandleKeyboardFocus ( void *  data,
struct wl_input_device input_device,
uint32_t  time,
struct wl_surface *  surface,
struct wl_array *  keys 
)
staticprivate

Definition at line 308 of file qwaylandinputdevice.cpp.

313 {
314 #ifndef QT_NO_WAYLAND_XKB
315  Q_UNUSED(input_device);
316  Q_UNUSED(time);
317  QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
319  uint32_t *k, *end;
320  uint32_t code;
321 
322  end = (uint32_t *) ((char *) keys->data + keys->size);
323  inputDevice->mModifiers = 0;
324  for (k = (uint32_t *) keys->data; k < end; k++) {
325  code = *k + inputDevice->mXkb->min_key_code;
326  inputDevice->mModifiers |=
327  translateModifiers(inputDevice->mXkb->map->modmap[code]);
328  }
329 
330  if (surface) {
331  window = (QWaylandWindow *) wl_surface_get_user_data(surface);
332  inputDevice->mKeyboardFocus = window;
334  } else {
335  inputDevice->mKeyboardFocus = NULL;
337  }
338 #endif
339 }
QStringList keys
static Qt::KeyboardModifiers translateModifiers(int s)
NSWindow * window
static void handleWindowActivated(QWidget *w)
static const char * data(const QByteArray &arr)
QWaylandWindow * mKeyboardFocus
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
struct xkb_desc * mXkb
static const KeyPair *const end
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
Qt::KeyboardModifiers mModifiers
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ inputHandleMotion()

void QWaylandInputDevice::inputHandleMotion ( void *  data,
struct wl_input_device input_device,
uint32_t  time,
int32_t  x,
int32_t  y,
int32_t  sx,
int32_t  sy 
)
staticprivate

Definition at line 94 of file qwaylandinputdevice.cpp.

99 {
100  Q_UNUSED(input_device);
101  QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
102  QWaylandWindow *window = inputDevice->mPointerFocus;
103 
104  if (window == NULL) {
105  /* We destroyed the pointer focus surface, but the server
106  * didn't get the message yet. */
107  return;
108  }
109 
110  inputDevice->mSurfacePos = QPoint(surface_x, surface_y);
111  inputDevice->mGlobalPos = QPoint(x, y);
112  inputDevice->mTime = time;
114  time,
115  inputDevice->mSurfacePos,
116  inputDevice->mGlobalPos,
117  inputDevice->mButtons);
118 }
QWaylandWindow * mPointerFocus
Qt::MouseButtons mButtons
NSWindow * window
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
static const char * data(const QByteArray &arr)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ inputHandlePointerFocus()

void QWaylandInputDevice::inputHandlePointerFocus ( void *  data,
struct wl_input_device input_device,
uint32_t  time,
struct wl_surface *  surface,
int32_t  x,
int32_t  y,
int32_t  sx,
int32_t  sy 
)
staticprivate

Definition at line 280 of file qwaylandinputdevice.cpp.

284 {
285  Q_UNUSED(input_device);
286  Q_UNUSED(x);
287  Q_UNUSED(y);
288  Q_UNUSED(sx);
289  Q_UNUSED(sy);
290  QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
292 
293  if (inputDevice->mPointerFocus) {
294  window = inputDevice->mPointerFocus;
296  inputDevice->mPointerFocus = NULL;
297  }
298 
299  if (surface) {
300  window = (QWaylandWindow *) wl_surface_get_user_data(surface);
302  inputDevice->mPointerFocus = window;
303  }
304 
305  inputDevice->mTime = time;
306 }
QWaylandWindow * mPointerFocus
NSWindow * window
static const char * data(const QByteArray &arr)
static void handleEnterEvent(QWidget *w)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static void handleLeaveEvent(QWidget *w)
QWidget * widget() const
Returnes the widget which belongs to the QPlatformWindow.

◆ wl_input_device()

struct wl_input_device* QWaylandInputDevice::wl_input_device ( ) const
inline

Definition at line 63 of file qwaylandinputdevice.h.

Referenced by QWaylandSelection::QWaylandSelection().

63 { return mInputDevice; }
struct wl_input_device * mInputDevice

Properties

◆ inputDeviceListener

const struct wl_input_device_listener QWaylandInputDevice::inputDeviceListener
staticprivate

Definition at line 70 of file qwaylandinputdevice.h.

Referenced by QWaylandInputDevice().

◆ mButtons

Qt::MouseButtons QWaylandInputDevice::mButtons
private

Definition at line 71 of file qwaylandinputdevice.h.

Referenced by inputHandleButton(), and inputHandleMotion().

◆ mDisplay

struct wl_display* QWaylandInputDevice::mDisplay
private

Definition at line 66 of file qwaylandinputdevice.h.

◆ mGlobalPos

QPoint QWaylandInputDevice::mGlobalPos
private

Definition at line 73 of file qwaylandinputdevice.h.

Referenced by inputHandleButton(), and inputHandleMotion().

◆ mInputDevice

struct wl_input_device* QWaylandInputDevice::mInputDevice
private

Definition at line 67 of file qwaylandinputdevice.h.

Referenced by attach(), QWaylandInputDevice(), and wl_input_device().

◆ mKeyboardFocus

QWaylandWindow* QWaylandInputDevice::mKeyboardFocus
private

◆ mModifiers

Qt::KeyboardModifiers QWaylandInputDevice::mModifiers
private

Definition at line 75 of file qwaylandinputdevice.h.

Referenced by inputHandleKey(), and inputHandleKeyboardFocus().

◆ mPointerFocus

QWaylandWindow* QWaylandInputDevice::mPointerFocus
private

◆ mSurfacePos

QPoint QWaylandInputDevice::mSurfacePos
private

Definition at line 72 of file qwaylandinputdevice.h.

Referenced by inputHandleButton(), and inputHandleMotion().

◆ mTime

uint32_t QWaylandInputDevice::mTime
private

◆ mXkb

struct xkb_desc* QWaylandInputDevice::mXkb
private

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