Changeset View
Changeset View
Standalone View
Standalone View
plugins/mousepad/mousepadplugin.cpp
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | |||||
113 | #if HAVE_X11 | 113 | #if HAVE_X11 | ||
114 | if (m_fakekey) { | 114 | if (m_fakekey) { | ||
115 | free(m_fakekey); | 115 | free(m_fakekey); | ||
116 | m_fakekey = nullptr; | 116 | m_fakekey = nullptr; | ||
117 | } | 117 | } | ||
118 | #endif | 118 | #endif | ||
119 | } | 119 | } | ||
120 | 120 | | |||
121 | bool MousepadPlugin::receivePackage(const NetworkPackage& np) | 121 | bool MousepadPlugin::receivePacket(const NetworkPacket& np) | ||
122 | { | 122 | { | ||
123 | #if HAVE_X11 | 123 | #if HAVE_X11 | ||
124 | if (m_x11) { | 124 | if (m_x11) { | ||
125 | return handlePackageX11(np); | 125 | return handlePacketX11(np); | ||
126 | } | 126 | } | ||
127 | #endif | 127 | #endif | ||
128 | #if HAVE_WAYLAND | 128 | #if HAVE_WAYLAND | ||
129 | if (m_waylandInput) { | 129 | if (m_waylandInput) { | ||
130 | if (!m_waylandAuthenticationRequested) { | 130 | if (!m_waylandAuthenticationRequested) { | ||
131 | m_waylandInput->authenticate(i18n("KDE Connect"), i18n("Use your phone as a touchpad and keyboard")); | 131 | m_waylandInput->authenticate(i18n("KDE Connect"), i18n("Use your phone as a touchpad and keyboard")); | ||
132 | m_waylandAuthenticationRequested = true; | 132 | m_waylandAuthenticationRequested = true; | ||
133 | } | 133 | } | ||
134 | handPackageWayland(np); | 134 | handPacketWayland(np); | ||
135 | } | 135 | } | ||
136 | #endif | 136 | #endif | ||
137 | return false; | 137 | return false; | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | #if HAVE_X11 | 140 | #if HAVE_X11 | ||
141 | bool isLeftHanded(Display * display) | 141 | bool isLeftHanded(Display * display) | ||
142 | { | 142 | { | ||
143 | unsigned char map[20]; | 143 | unsigned char map[20]; | ||
144 | int num_buttons = XGetPointerMapping(display, map, 20); | 144 | int num_buttons = XGetPointerMapping(display, map, 20); | ||
145 | if( num_buttons == 1 ) { | 145 | if( num_buttons == 1 ) { | ||
146 | return false; | 146 | return false; | ||
147 | } else if( num_buttons == 2 ) { | 147 | } else if( num_buttons == 2 ) { | ||
148 | return ( (int)map[0] == 2 && (int)map[1] == 1 ); | 148 | return ( (int)map[0] == 2 && (int)map[1] == 1 ); | ||
149 | } else { | 149 | } else { | ||
150 | return ( (int)map[0] == 3 && (int)map[2] == 1 ); | 150 | return ( (int)map[0] == 3 && (int)map[2] == 1 ); | ||
151 | } | 151 | } | ||
152 | } | 152 | } | ||
153 | #endif | 153 | #endif | ||
154 | 154 | | |||
155 | #if HAVE_X11 | 155 | #if HAVE_X11 | ||
156 | bool MousepadPlugin::handlePackageX11(const NetworkPackage& np) | 156 | bool MousepadPlugin::handlePacketX11(const NetworkPacket& np) | ||
157 | { | 157 | { | ||
158 | //qDebug() << np.serialize(); | 158 | //qDebug() << np.serialize(); | ||
159 | 159 | | |||
160 | //TODO: Split mouse/keyboard in two different plugins to avoid this big if statement | 160 | //TODO: Split mouse/keyboard in two different plugins to avoid this big if statement | ||
161 | 161 | | |||
162 | float dx = np.get<float>(QStringLiteral("dx"), 0); | 162 | float dx = np.get<float>(QStringLiteral("dx"), 0); | ||
163 | float dy = np.get<float>(QStringLiteral("dy"), 0); | 163 | float dy = np.get<float>(QStringLiteral("dy"), 0); | ||
164 | 164 | | |||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 271 | { | |||
284 | connect(registry, &Registry::fakeInputAnnounced, this, | 284 | connect(registry, &Registry::fakeInputAnnounced, this, | ||
285 | [this, registry] (quint32 name, quint32 version) { | 285 | [this, registry] (quint32 name, quint32 version) { | ||
286 | m_waylandInput = registry->createFakeInput(name, version, this); | 286 | m_waylandInput = registry->createFakeInput(name, version, this); | ||
287 | } | 287 | } | ||
288 | ); | 288 | ); | ||
289 | registry->setup(); | 289 | registry->setup(); | ||
290 | } | 290 | } | ||
291 | 291 | | |||
292 | bool MousepadPlugin::handPackageWayland(const NetworkPackage& np) | 292 | bool MousepadPlugin::handPacketWayland(const NetworkPacket& np) | ||
293 | { | 293 | { | ||
294 | const float dx = np.get<float>(QStringLiteral("dx"), 0); | 294 | const float dx = np.get<float>(QStringLiteral("dx"), 0); | ||
295 | const float dy = np.get<float>(QStringLiteral("dy"), 0); | 295 | const float dy = np.get<float>(QStringLiteral("dy"), 0); | ||
296 | 296 | | |||
297 | const bool isSingleClick = np.get<bool>(QStringLiteral("singleclick"), false); | 297 | const bool isSingleClick = np.get<bool>(QStringLiteral("singleclick"), false); | ||
298 | const bool isDoubleClick = np.get<bool>(QStringLiteral("doubleclick"), false); | 298 | const bool isDoubleClick = np.get<bool>(QStringLiteral("doubleclick"), false); | ||
299 | const bool isMiddleClick = np.get<bool>(QStringLiteral("middleclick"), false); | 299 | const bool isMiddleClick = np.get<bool>(QStringLiteral("middleclick"), false); | ||
300 | const bool isRightClick = np.get<bool>(QStringLiteral("rightclick"), false); | 300 | const bool isRightClick = np.get<bool>(QStringLiteral("rightclick"), false); | ||
Show All 37 Lines |