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>
24
#include <unity/shell/application/Mir.h>
26
const char *touchPointStateToString(Qt::TouchPointState state)
29
case Qt::TouchPointPressed:
31
case Qt::TouchPointMoved:
33
case Qt::TouchPointStationary:
35
case Qt::TouchPointReleased:
42
QString touchEventToString(const QTouchEvent *ev)
47
case QEvent::TouchBegin:
48
message.append("TouchBegin ");
50
case QEvent::TouchUpdate:
51
message.append("TouchUpdate ");
53
case QEvent::TouchEnd:
54
message.append("TouchEnd ");
56
case QEvent::TouchCancel:
57
message.append("TouchCancel ");
60
message.append("TouchUNKNOWN ");
63
for (int i=0; i < ev->touchPoints().size(); ++i) {
65
const QTouchEvent::TouchPoint& touchPoint = ev->touchPoints().at(i);
67
QStringLiteral("(id:%1, state:%2, scenePos:(%3,%4), pos:(%5,%6)) ")
69
.arg(touchPointStateToString(touchPoint.state()))
70
.arg(touchPoint.scenePos().x())
71
.arg(touchPoint.scenePos().y())
72
.arg(touchPoint.pos().x())
73
.arg(touchPoint.pos().y())
80
QString mirSurfaceAttribAndValueToString(MirSurfaceAttrib attrib, int value)
85
case mir_surface_attrib_type:
86
str = QStringLiteral("type=%1").arg(mirSurfaceTypeToStr(value));
89
case mir_surface_attrib_state:
90
str = QStringLiteral("state=%1").arg(mirSurfaceStateToStr(value));
93
case mir_surface_attrib_swapinterval:
94
str = QStringLiteral("swapinterval=%1").arg(value);
97
case mir_surface_attrib_focus:
98
str = QStringLiteral("focus=%1").arg(mirSurfaceFocusStateToStr(value));
101
case mir_surface_attrib_dpi:
102
str = QStringLiteral("dpi=%1").arg(value);
105
case mir_surface_attrib_visibility:
106
str = QStringLiteral("visibility=%1").arg(mirSurfaceVisibilityToStr(value));
109
str = QStringLiteral("type'%1'=%2").arg((int)attrib).arg(value);
115
const char *mirSurfaceTypeToStr(int value)
118
case mir_surface_type_normal:
120
case mir_surface_type_utility:
122
case mir_surface_type_dialog:
124
case mir_surface_type_overlay:
126
case mir_surface_type_freestyle:
128
case mir_surface_type_popover:
130
case mir_surface_type_inputmethod:
131
return "inputmethod";
137
const char *mirSurfaceStateToStr(int value)
140
case mir_surface_state_unknown:
142
case mir_surface_state_restored:
144
case mir_surface_state_minimized:
146
case mir_surface_state_maximized:
148
case mir_surface_state_vertmaximized:
149
return "vertmaximized";
150
case mir_surface_state_fullscreen:
152
case mir_surface_state_hidden:
159
const char *mirSurfaceFocusStateToStr(int value)
162
case mir_surface_unfocused:
164
case mir_surface_focused:
171
const char *mirSurfaceVisibilityToStr(int value)
174
case mir_surface_visibility_occluded:
176
case mir_surface_visibility_exposed:
183
const char *mirTouchActionToStr(MirTouchAction action)
186
case mir_touch_action_up:
188
case mir_touch_action_down:
190
case mir_touch_action_change:
197
using namespace unity::shell::application;
199
const char *applicationStateToStr(int state)
202
case ApplicationInfoInterface::Starting:
204
case ApplicationInfoInterface::Running:
206
case ApplicationInfoInterface::Suspended:
208
case ApplicationInfoInterface::Stopped:
215
QString mirPointerEventToString(MirPointerEvent const* event)
217
QString string = QStringLiteral("MirPointerEvent(x=%1,y=%2,relative_x=%3,relative_y=%4)")
218
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_x))
219
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_y))
220
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_relative_x))
221
.arg(mir_pointer_event_axis_value(event, mir_pointer_axis_relative_y));
226
QString mirTouchEventToString(MirTouchEvent const* event)
228
const int pointerCount = mir_touch_event_point_count(event);
230
QString string(QStringLiteral("MirTouchEvent("));
232
for (int i = 0; i < pointerCount; ++i) {
238
MirTouchAction touchAction = mir_touch_event_action(event, i);
240
QString touchStr = QStringLiteral("(id=%1,action=%2,x=%3,y=%4)")
241
.arg(mir_touch_event_id(event, i))
242
.arg(mirTouchActionToString(touchAction))
243
.arg(mir_touch_event_axis_value(event, i, mir_touch_axis_x))
244
.arg(mir_touch_event_axis_value(event, i, mir_touch_axis_y));
246
string.append(touchStr);
254
const char *mirTouchActionToString(MirTouchAction touchAction)
258
case mir_touch_action_up:
261
case mir_touch_action_down:
264
case mir_touch_action_change:
274
const char *mirKeyboardActionToString(MirKeyboardAction keyboardAction)
276
switch (keyboardAction)
278
case mir_keyboard_action_up:
280
case mir_keyboard_action_down:
282
case mir_keyboard_action_repeat:
291
QString mirKeyboardEventToString(MirKeyboardEvent const* event)
293
MirKeyboardAction keyboardAction = mir_keyboard_event_action(event);
295
xkb_keysym_t keyCode = mir_keyboard_event_key_code(event);
297
return QStringLiteral("MirKeyboardEvent(action=%1,key_code=0x%2)")
298
.arg(mirKeyboardActionToString(keyboardAction))
299
.arg(keyCode, 4, 16, QLatin1Char('0'));
302
const char *qtCursorShapeToStr(Qt::CursorShape shape)
305
case Qt::ArrowCursor:
307
case Qt::UpArrowCursor:
309
case Qt::CrossCursor:
313
case Qt::IBeamCursor:
315
case Qt::SizeVerCursor:
317
case Qt::SizeHorCursor:
319
case Qt::SizeBDiagCursor:
321
case Qt::SizeFDiagCursor:
323
case Qt::SizeAllCursor:
325
case Qt::BlankCursor:
327
case Qt::SplitVCursor:
329
case Qt::SplitHCursor:
331
case Qt::PointingHandCursor:
332
return "PointingHand";
333
case Qt::ForbiddenCursor:
335
case Qt::WhatsThisCursor:
339
case Qt::OpenHandCursor:
341
case Qt::ClosedHandCursor:
343
case Qt::DragCopyCursor:
345
case Qt::DragMoveCursor:
347
case Qt::DragLinkCursor:
349
case Qt::BitmapCursor:
356
const char *unityapiMirStateToStr(int state)
359
case Mir::UnknownState:
361
case Mir::RestoredState:
363
case Mir::MinimizedState:
365
case Mir::MaximizedState:
367
case Mir::VertMaximizedState:
368
return "vertMaximized";
369
case Mir::FullscreenState:
371
case Mir::HorizMaximizedState:
372
return "horizMaximized";
373
case Mir::MaximizedLeftState:
374
return "maximizedLeft";
375
case Mir::MaximizedRightState:
376
return "maximizedRight";
377
case Mir::MaximizedTopLeftState:
378
return "maximizedTopLeft";
379
case Mir::MaximizedTopRightState:
380
return "maximizedTopRight";
381
case Mir::MaximizedBottomLeftState:
382
return "maximizedBottomLeft";
383
case Mir::MaximizedBottomRightState:
384
return "maximizedBottomRight";
385
case Mir::HiddenState: