Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show First 20 Lines • Show All 485 Lines • ▼ Show 20 Line(s) | 485 | if (e.isAccepted()) { | |||
---|---|---|---|---|---|
486 | return true; | 486 | return true; | ||
487 | } | 487 | } | ||
488 | if ((orientation == Qt::Vertical) && decoration->client()->titlebarPositionUnderMouse()) { | 488 | if ((orientation == Qt::Vertical) && decoration->client()->titlebarPositionUnderMouse()) { | ||
489 | decoration->client()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1), | 489 | decoration->client()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1), | ||
490 | event->globalPosF().toPoint()); | 490 | event->globalPosF().toPoint()); | ||
491 | } | 491 | } | ||
492 | return true; | 492 | return true; | ||
493 | } | 493 | } | ||
494 | bool touchDown(quint32 id, const QPointF &pos, quint32 time) override { | ||||
495 | auto seat = waylandServer()->seat(); | ||||
496 | if (seat->isTouchSequence()) { | ||||
497 | return false; | ||||
498 | } | ||||
499 | if (input()->touch()->decorationPressId() != -1) { | ||||
500 | // already on a decoration, ignore further touch points, but filter out | ||||
501 | return true; | ||||
502 | } | ||||
503 | seat->setTimestamp(time); | ||||
504 | input()->touch()->update(pos); | ||||
505 | auto decoration = input()->touch()->decoration(); | ||||
506 | if (!decoration) { | ||||
507 | return false; | ||||
508 | } | ||||
509 | input()->touch()->setDecorationPressId(id); | ||||
510 | m_lastGlobalTouchPos = pos; | ||||
511 | m_lastLocalTouchPos = pos - decoration->client()->pos(); | ||||
512 | QMouseEvent e(QEvent::MouseButtonPress, m_lastLocalTouchPos, pos, Qt::LeftButton, Qt::LeftButton, input()->keyboardModifiers()); | ||||
513 | e.setAccepted(false); | ||||
514 | QCoreApplication::sendEvent(decoration->decoration(), &e); | ||||
515 | if (!e.isAccepted()) { | ||||
516 | decoration->client()->processDecorationButtonPress(&e); | ||||
517 | } | ||||
518 | return true; | ||||
519 | } | ||||
520 | bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override { | ||||
521 | Q_UNUSED(time) | ||||
522 | auto decoration = input()->touch()->decoration(); | ||||
523 | if (!decoration) { | ||||
524 | return false; | ||||
525 | } | ||||
526 | if (input()->touch()->decorationPressId() == -1) { | ||||
527 | return false; | ||||
528 | } | ||||
529 | if (input()->touch()->decorationPressId() != id) { | ||||
530 | // ignore, but filter out | ||||
531 | return true; | ||||
532 | } | ||||
533 | m_lastGlobalTouchPos = pos; | ||||
534 | m_lastLocalTouchPos = pos - decoration->client()->pos(); | ||||
535 | QHoverEvent e(QEvent::HoverMove, m_lastLocalTouchPos, m_lastLocalTouchPos); | ||||
536 | QCoreApplication::instance()->sendEvent(decoration->decoration(), &e); | ||||
537 | decoration->client()->processDecorationMove(m_lastLocalTouchPos.toPoint(), pos.toPoint()); | ||||
538 | return true; | ||||
539 | } | ||||
540 | bool touchUp(quint32 id, quint32 time) override { | ||||
541 | Q_UNUSED(time); | ||||
542 | auto decoration = input()->touch()->decoration(); | ||||
543 | if (!decoration) { | ||||
544 | return false; | ||||
545 | } | ||||
546 | if (input()->touch()->decorationPressId() == -1) { | ||||
547 | return false; | ||||
548 | } | ||||
549 | if (input()->touch()->decorationPressId() != id) { | ||||
550 | // ignore, but filter out | ||||
551 | return true; | ||||
552 | } | ||||
553 | // send mouse up | ||||
554 | QMouseEvent e(QEvent::MouseButtonRelease, m_lastLocalTouchPos, m_lastGlobalTouchPos, Qt::LeftButton, Qt::MouseButtons(), input()->keyboardModifiers()); | ||||
555 | e.setAccepted(false); | ||||
556 | QCoreApplication::sendEvent(decoration->decoration(), &e); | ||||
557 | decoration->client()->processDecorationButtonRelease(&e); | ||||
558 | | ||||
559 | m_lastGlobalTouchPos = QPointF(); | ||||
560 | m_lastLocalTouchPos = QPointF(); | ||||
561 | input()->touch()->setDecorationPressId(-1); | ||||
562 | return true; | ||||
563 | } | ||||
564 | private: | ||||
565 | QPointF m_lastGlobalTouchPos; | ||||
566 | QPointF m_lastLocalTouchPos; | ||||
494 | }; | 567 | }; | ||
495 | 568 | | |||
496 | #ifdef KWIN_BUILD_TABBOX | 569 | #ifdef KWIN_BUILD_TABBOX | ||
497 | class TabBoxInputFilter : public InputEventFilter | 570 | class TabBoxInputFilter : public InputEventFilter | ||
498 | { | 571 | { | ||
499 | public: | 572 | public: | ||
500 | bool pointerEvent(QMouseEvent *event, quint32 button) override { | 573 | bool pointerEvent(QMouseEvent *event, quint32 button) override { | ||
501 | Q_UNUSED(button) | 574 | Q_UNUSED(button) | ||
▲ Show 20 Lines • Show All 699 Lines • ▼ Show 20 Line(s) | |||||
1201 | } | 1274 | } | ||
1202 | 1275 | | |||
1203 | 1276 | | |||
1204 | QPointF InputRedirection::globalPointer() const | 1277 | QPointF InputRedirection::globalPointer() const | ||
1205 | { | 1278 | { | ||
1206 | return m_pointer->pos(); | 1279 | return m_pointer->pos(); | ||
1207 | } | 1280 | } | ||
1208 | 1281 | | |||
1282 | InputDeviceHandler::InputDeviceHandler(InputRedirection *input) | ||||
1283 | : QObject(input) | ||||
1284 | , m_input(input) | ||||
1285 | { | ||||
1286 | } | ||||
1287 | | ||||
1288 | InputDeviceHandler::~InputDeviceHandler() = default; | ||||
1289 | | ||||
1290 | void InputDeviceHandler::updateDecoration(Toplevel *t, const QPointF &pos) | ||||
1291 | { | ||||
1292 | const auto oldDeco = m_decoration; | ||||
1293 | bool needsReset = waylandServer()->isScreenLocked(); | ||||
1294 | if (AbstractClient *c = dynamic_cast<AbstractClient*>(t)) { | ||||
1295 | // check whether it's on a Decoration | ||||
1296 | if (c->decoratedClient()) { | ||||
1297 | const QRect clientRect = QRect(c->clientPos(), c->clientSize()).translated(c->pos()); | ||||
1298 | if (!clientRect.contains(pos.toPoint())) { | ||||
1299 | m_decoration = c->decoratedClient(); | ||||
1300 | } else { | ||||
1301 | needsReset = true; | ||||
1302 | } | ||||
1303 | } else { | ||||
1304 | needsReset = true; | ||||
1305 | } | ||||
1306 | } else { | ||||
1307 | needsReset = true; | ||||
1308 | } | ||||
1309 | if (needsReset) { | ||||
1310 | m_decoration.clear(); | ||||
1311 | } | ||||
1312 | | ||||
1313 | bool leftSend = false; | ||||
1314 | auto oldWindow = qobject_cast<AbstractClient*>(m_window.data()); | ||||
1315 | if (oldWindow && (m_decoration && m_decoration->client() != oldWindow)) { | ||||
1316 | leftSend = true; | ||||
1317 | oldWindow->leaveEvent(); | ||||
1318 | } | ||||
1319 | | ||||
1320 | if (oldDeco && oldDeco != m_decoration) { | ||||
1321 | if (oldDeco->client() != t && !leftSend) { | ||||
1322 | leftSend = true; | ||||
1323 | oldDeco->client()->leaveEvent(); | ||||
1324 | } | ||||
1325 | // send leave | ||||
1326 | QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF()); | ||||
1327 | QCoreApplication::instance()->sendEvent(oldDeco->decoration(), &event); | ||||
1328 | } | ||||
1329 | if (m_decoration) { | ||||
1330 | if (m_decoration->client() != oldWindow) { | ||||
1331 | m_decoration->client()->enterEvent(pos.toPoint()); | ||||
1332 | workspace()->updateFocusMousePosition(pos.toPoint()); | ||||
1333 | } | ||||
1334 | const QPointF p = pos - t->pos(); | ||||
1335 | QHoverEvent event(QEvent::HoverMove, p, p); | ||||
1336 | QCoreApplication::instance()->sendEvent(m_decoration->decoration(), &event); | ||||
1337 | m_decoration->client()->processDecorationMove(p.toPoint(), pos.toPoint()); | ||||
1338 | } | ||||
1339 | } | ||||
1340 | | ||||
1209 | } // namespace | 1341 | } // namespace |