2
* Copyright (C) 2013-2015 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#include "debughelpers.h"
18
#include <QTouchEvent>
20
#include <mir_toolkit/event.h>
23
#include <unity/shell/application/ApplicationInfoInterface.h>
25
const char *touchPointStateToString(Qt::TouchPointState state)
28
case Qt::TouchPointPressed:
30
case Qt::TouchPointMoved:
32
case Qt::TouchPointStationary:
34
case Qt::TouchPointReleased:
41
QString touchEventToString(const QTouchEvent *ev)
46
case QEvent::TouchBegin:
47
message.append("TouchBegin ");
49
case QEvent::TouchUpdate:
50
message.append("TouchUpdate ");
52
case QEvent::TouchEnd:
53
message.append("TouchEnd ");
55
case QEvent::TouchCancel:
56
message.append("TouchCancel ");
59
message.append("TouchUNKNOWN ");
62
for (int i=0; i < ev->touchPoints().size(); ++i) {
64
const QTouchEvent::TouchPoint& touchPoint = ev->touchPoints().at(i);
66
QStringLiteral("(id:%1, state:%2, scenePos:(%3,%4), pos:(%5,%6)) ")
68
.arg(touchPointStateToString(touchPoint.state()))
69
.arg(touchPoint.scenePos().x())
70
.arg(touchPoint.scenePos().y())
71
.arg(touchPoint.pos().x())
72
.arg(touchPoint.pos().y())
79
QString mirSurfaceAttribAndValueToString(MirSurfaceAttrib attrib, int value)
84
case mir_surface_attrib_type:
85
str = QStringLiteral("type=%1").arg(mirSurfaceTypeToStr(value));
88
case mir_surface_attrib_state:
89
str = QStringLiteral("state=%1").arg(mirSurfaceStateToStr(value));
92
case mir_surface_attrib_swapinterval:
93
str = QStringLiteral("swapinterval=%1").arg(value);
96
case mir_surface_attrib_focus:
97
str = QStringLiteral("focus=%1").arg(mirSurfaceFocusStateToStr(value));
100
case mir_surface_attrib_dpi:
101
str = QStringLiteral("dpi=%1").arg(value);
104
case mir_surface_attrib_visibility:
105
str = QStringLiteral("visibility=%1").arg(mirSurfaceVisibilityToStr(value));
108
str = QStringLiteral("type'%1'=%2").arg((int)attrib).arg(value);
114
const char *mirSurfaceTypeToStr(int value)
117
case mir_surface_type_normal:
119
case mir_surface_type_utility:
121
case mir_surface_type_dialog:
123
case mir_surface_type_overlay:
125
case mir_surface_type_freestyle:
127
case mir_surface_type_popover:
129
case mir_surface_type_inputmethod:
130
return "inputmethod";
136
const char *mirSurfaceStateToStr(int value)
139
case mir_surface_state_unknown:
141
case mir_surface_state_restored:
143
case mir_surface_state_minimized:
145
case mir_surface_state_maximized:
147
case mir_surface_state_vertmaximized:
148
return "vertmaximized";
149
case mir_surface_state_fullscreen:
156
const char *mirSurfaceFocusStateToStr(int value)
159
case mir_surface_unfocused:
161
case mir_surface_focused:
168
const char *mirSurfaceVisibilityToStr(int value)
171
case mir_surface_visibility_occluded:
173
case mir_surface_visibility_exposed:
180
const char *mirTouchActionToStr(MirTouchAction action)
183
case mir_touch_action_up:
185
case mir_touch_action_down:
187
case mir_touch_action_change:
194
using namespace unity::shell::application;
196
const char *applicationStateToStr(int state)
199
case ApplicationInfoInterface::Starting:
201
case ApplicationInfoInterface::Running:
203
case ApplicationInfoInterface::Suspended:
205
case ApplicationInfoInterface::Stopped:
212
QString mirPointerEventToString(MirPointerEvent const* event)
214
QString string = QStringLiteral("MirPointerEvent(x=%1,y=%2,relative_x=%3,relative_y=%4)")
215
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_x))
216
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_y))
217
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_relative_x))
218
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_relative_y));
223
QString mirTouchEventToString(MirTouchEvent const* event)
225
const int pointerCount = mir_touch_event_point_count(event);
227
QString string(QStringLiteral("MirTouchEvent("));
229
for (int i = 0; i < pointerCount; ++i) {
235
MirTouchAction touchAction = mir_touch_event_action(event, i);
237
QString touchStr = QStringLiteral("(id=%1,action=%2,x=%3,y=%4)")
238
.arg(mir_touch_event_id(event, i))
239
.arg(mirTouchActionToString(touchAction))
240
.arg(mir_touch_event_axis_value(event, i, mir_touch_axis_x))
241
.arg(mir_touch_event_axis_value(event, i, mir_touch_axis_y));
243
string.append(touchStr);
251
const char *mirTouchActionToString(MirTouchAction touchAction)
255
case mir_touch_action_up:
258
case mir_touch_action_down:
261
case mir_touch_action_change:
271
const char *mirKeyboardActionToString(MirKeyboardAction keyboardAction)
273
switch (keyboardAction)
275
case mir_keyboard_action_up:
277
case mir_keyboard_action_down:
279
case mir_keyboard_action_repeat:
288
QString mirKeyboardEventToString(MirKeyboardEvent const* event)
290
MirKeyboardAction keyboardAction = mir_keyboard_event_action(event);
292
xkb_keysym_t keyCode = mir_keyboard_event_key_code(event);
294
return QStringLiteral("MirKeyboardEvent(action=%1,key_code=0x%2)")
295
.arg(mirKeyboardActionToString(keyboardAction))
296
.arg(keyCode, 4, 16, QLatin1Char('0'));
299
const char *qtCursorShapeToStr(Qt::CursorShape shape)
302
case Qt::ArrowCursor:
304
case Qt::UpArrowCursor:
306
case Qt::CrossCursor:
310
case Qt::IBeamCursor:
312
case Qt::SizeVerCursor:
314
case Qt::SizeHorCursor:
316
case Qt::SizeBDiagCursor:
318
case Qt::SizeFDiagCursor:
320
case Qt::SizeAllCursor:
322
case Qt::BlankCursor:
324
case Qt::SplitVCursor:
326
case Qt::SplitHCursor:
328
case Qt::PointingHandCursor:
329
return "PointingHand";
330
case Qt::ForbiddenCursor:
332
case Qt::WhatsThisCursor:
336
case Qt::OpenHandCursor:
338
case Qt::ClosedHandCursor:
340
case Qt::DragCopyCursor:
342
case Qt::DragMoveCursor:
344
case Qt::DragLinkCursor:
346
case Qt::BitmapCursor: