qevdevmousemanager.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5extern const QLoggingCategory &qLcEvdevMouse();-
6-
7QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent)-
8 : QObject(parent), m_x(0), m_y(0), m_xoffset(0), m_yoffset(0)-
9{-
10 (void)key;;-
11-
12 QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_MOUSE_PARAMETERS"));-
13-
14 if (spec.isEmpty()
spec.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
15 spec = specification;
never executed: spec = specification;
0
16-
17 QStringList args = spec.split(QLatin1Char(':'));-
18 QStringList devices;-
19-
20 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(args)>::type> _container_((args)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &arg = *_container_.i; _container_.control; _container_.control = 0) {-
21 if (arg.startsWith(QLatin1String("/dev/"))
arg.startsWith...ring("/dev/"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
22-
23 devices.append(arg);-
24 args.removeAll(arg);-
25 }
never executed: end of block
else if (arg.startsWith(QLatin1String("xoffset="))
arg.startsWith...g("xoffset="))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
26 m_xoffset = arg.mid(8).toInt();-
27 }
never executed: end of block
else if (arg.startsWith(QLatin1String("yoffset="))
arg.startsWith...g("yoffset="))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
28 m_yoffset = arg.mid(8).toInt();-
29 }
never executed: end of block
0
30 }
never executed: end of block
0
31-
32-
33 m_spec = args.join(QLatin1Char(':'));-
34-
35-
36 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(devices)>::type> _container_((devices)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &device = *_container_.i; _container_.control; _container_.control = 0)-
37 addMouse(device);
never executed: addMouse(device);
0
38-
39 if (devices.isEmpty()
devices.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
40 for (bool qt_category_enabled = qLcEvdevMouse().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 89, __PRETTY_FUNCTION__, qLcEvdevMouse().categoryName()).debug() << "evdevmouse: Using device discovery";
never executed: QMessageLogger(__FILE__, 89, __PRETTY_FUNCTION__, qLcEvdevMouse().categoryName()).debug() << "evdevmouse: Using device discovery";
0
41 m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this);-
42 if (m_deviceDiscovery
m_deviceDiscoveryDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
43-
44 QStringList devices = m_deviceDiscovery->scanConnectedDevices();-
45 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(devices)>::type> _container_((devices)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &device = *_container_.i; _container_.control; _container_.control = 0) {-
46 addMouse(device);-
47 }
never executed: end of block
0
48-
49 connect(m_deviceDiscovery, qFlagLocation("2""deviceDetected(QString)" "\0" __FILE__ ":" "98"), this, qFlagLocation("1""addMouse(QString)" "\0" __FILE__ ":" "98"));-
50 connect(m_deviceDiscovery, qFlagLocation("2""deviceRemoved(QString)" "\0" __FILE__ ":" "99"), this, qFlagLocation("1""removeMouse(QString)" "\0" __FILE__ ":" "99"));-
51 }
never executed: end of block
0
52 }
never executed: end of block
0
53-
54 connect(QGuiApplicationPrivate::inputDeviceManager(), qFlagLocation("2""cursorPositionChangeRequested(QPoint)" "\0" __FILE__ ":" "103"),-
55 this, qFlagLocation("1""handleCursorPositionChange(QPoint)" "\0" __FILE__ ":" "104"));-
56}
never executed: end of block
0
57-
58QEvdevMouseManager::~QEvdevMouseManager()-
59{-
60 qDeleteAll(m_mice);-
61 m_mice.clear();-
62}
never executed: end of block
0
63-
64void QEvdevMouseManager::clampPosition()-
65{-
66-
67 QScreen *primaryScreen = QGuiApplication::primaryScreen();-
68 QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);-
69 if (m_x + m_xoffset < g.left()
m_x + m_xoffset < g.left()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
70 m_x = g.left() - m_xoffset;
never executed: m_x = g.left() - m_xoffset;
0
71 else if (m_x + m_xoffset > g.right()
m_x + m_xoffset > g.right()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
72 m_x = g.right() - m_xoffset;
never executed: m_x = g.right() - m_xoffset;
0
73-
74 if (m_y + m_yoffset < g.top()
m_y + m_yoffset < g.top()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
75 m_y = g.top() - m_yoffset;
never executed: m_y = g.top() - m_yoffset;
0
76 else if (m_y + m_yoffset > g.bottom()
m_y + m_yoffset > g.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
77 m_y = g.bottom() - m_yoffset;
never executed: m_y = g.bottom() - m_yoffset;
0
78}
never executed: end of block
0
79-
80void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons)-
81{-
82-
83 if (!abs
!absDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
84 m_x += x;-
85 m_y += y;-
86 }
never executed: end of block
else {
0
87 m_x = x;-
88 m_y = y;-
89 }
never executed: end of block
0
90-
91 clampPosition();-
92-
93 QPoint pos(m_x + m_xoffset, m_y + m_yoffset);-
94-
95-
96 QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, QGuiApplication::keyboardModifiers());-
97}
never executed: end of block
0
98-
99void QEvdevMouseManager::handleWheelEvent(int delta, Qt::Orientation orientation)-
100{-
101 QPoint pos(m_x + m_xoffset, m_y + m_yoffset);-
102 QWindowSystemInterface::handleWheelEvent(0, pos, pos, delta, orientation, QGuiApplication::keyboardModifiers());-
103}
never executed: end of block
0
104-
105void QEvdevMouseManager::addMouse(const QString &deviceNode)-
106{-
107 for (bool qt_category_enabled = qLcEvdevMouse().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 156, __PRETTY_FUNCTION__, qLcEvdevMouse().categoryName()).debug() << "Adding mouse at" << deviceNode;
never executed: QMessageLogger(__FILE__, 156, __PRETTY_FUNCTION__, qLcEvdevMouse().categoryName()).debug() << "Adding mouse at" << deviceNode;
0
108 QEvdevMouseHandler *handler;-
109 handler = QEvdevMouseHandler::create(deviceNode, m_spec);-
110 if (handler
handlerDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
111 connect(handler, qFlagLocation("2""handleMouseEvent(int,int,bool,Qt::MouseButtons)" "\0" __FILE__ ":" "160"), this, qFlagLocation("1""handleMouseEvent(int,int,bool,Qt::MouseButtons)" "\0" __FILE__ ":" "160"));-
112 connect(handler, qFlagLocation("2""handleWheelEvent(int,Qt::Orientation)" "\0" __FILE__ ":" "161"), this, qFlagLocation("1""handleWheelEvent(int,Qt::Orientation)" "\0" __FILE__ ":" "161"));-
113 m_mice.insert(deviceNode, handler);-
114 QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(-
115 QInputDeviceManager::DeviceTypePointer, m_mice.count());-
116 }
never executed: end of block
else {
0
117 QMessageLogger(__FILE__, 166, __PRETTY_FUNCTION__).warning("evdevmouse: Failed to open mouse device %s", QString(deviceNode).toLocal8Bit().constData());-
118 }
never executed: end of block
0
119}-
120-
121void QEvdevMouseManager::removeMouse(const QString &deviceNode)-
122{-
123 if (m_mice.contains(deviceNode)
m_mice.contains(deviceNode)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
124 for (bool qt_category_enabled = qLcEvdevMouse().isDebugEnabled(); qt_category_enabled
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
; qt_category_enabled = false) QMessageLogger(__FILE__, 173, __PRETTY_FUNCTION__, qLcEvdevMouse().categoryName()).debug() << "Removing mouse at" << deviceNode;
never executed: QMessageLogger(__FILE__, 173, __PRETTY_FUNCTION__, qLcEvdevMouse().categoryName()).debug() << "Removing mouse at" << deviceNode;
0
125 QEvdevMouseHandler *handler = m_mice.value(deviceNode);-
126 m_mice.remove(deviceNode);-
127 QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(-
128 QInputDeviceManager::DeviceTypePointer, m_mice.count());-
129 delete handler;-
130 }
never executed: end of block
0
131}
never executed: end of block
0
132-
133void QEvdevMouseManager::handleCursorPositionChange(const QPoint &pos)-
134{-
135 m_x = pos.x();-
136 m_y = pos.y();-
137 clampPosition();-
138}
never executed: end of block
0
139-
140-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9