First step of cleaning up PointerEvents
Showing the changes to interface/src/Application.cpp (1 of 13 files). Show all
Unified · Split
| @@ -692,7 +692,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 691 unmodified lines | ||
| 692 | 692 | DependencyManager::set<CloseEventSender>(); |
| 693 | 693 | DependencyManager::set<ResourceManager>(); |
| 694 | 694 | DependencyManager::set<SelectionScriptingInterface>(); |
| 695 | − DependencyManager::set<ContextOverlayInterface>(); | |
| 696 | 695 | DependencyManager::set<Ledger>(); |
| 697 | 696 | DependencyManager::set<Wallet>(); |
| 698 | 697 | DependencyManager::set<WalletScriptingInterface>(); |
| @@ -1188,7 +1187,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 489 unmodified lines | ||
| 1188 | 1187 | // allow you to move an entity around in your hand |
| 1189 | 1188 | _entityEditSender.setPacketsPerSecond(3000); // super high!! |
| 1190 | 1189 | |
| 1190 | + // Overlays need to exist before we set the ContextOverlayInterface dependency | |
| 1191 | 1191 | _overlays.init(); // do this before scripts load |
| 1192 | + DependencyManager::set<ContextOverlayInterface>(); | |
| 1193 | + | |
| 1192 | 1194 | // Make sure we don't time out during slow operations at startup |
| 1193 | 1195 | updateHeartbeat(); |
| 1194 | 1196 | |
| @@ -1478,53 +1480,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 283 unmodified lines | ||
| 1478 | 1480 | } |
| 1479 | 1481 | }); |
| 1480 | 1482 | |
| 1481 | − // If the user clicks somewhere where there is NO entity at all, we will release focus | |
| 1482 | − connect(getEntities().data(), &EntityTreeRenderer::mousePressOffEntity, [=]() { | |
| 1483 | − setKeyboardFocusEntity(UNKNOWN_ENTITY_ID); | |
| 1484 | − }); | |
| 1485 | − | |
| 1486 | 1483 | // Keyboard focus handling for Web overlays. |
| 1487 | 1484 | auto overlays = &(qApp->getOverlays()); |
| 1488 | − | |
| 1489 | − connect(overlays, &Overlays::mousePressOnOverlay, [=](const OverlayID& overlayID, const PointerEvent& event) { | |
| 1490 | − auto thisOverlay = std::dynamic_pointer_cast<Web3DOverlay>(overlays->getOverlay(overlayID)); | |
| 1491 | − // Only Web overlays can have keyboard focus. | |
| 1492 | − if (thisOverlay) { | |
| 1493 | − setKeyboardFocusEntity(UNKNOWN_ENTITY_ID); | |
| 1494 | − setKeyboardFocusOverlay(overlayID); | |
| 1495 | − } | |
| 1496 | − }); | |
| 1497 | − | |
| 1498 | 1485 | connect(overlays, &Overlays::overlayDeleted, [=](const OverlayID& overlayID) { |
| 1499 | 1486 | if (overlayID == _keyboardFocusedOverlay.get()) { |
| 1500 | 1487 | setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); |
| 1501 | 1488 | } |
| 1502 | 1489 | }); |
| 1503 | 1490 | |
| 1504 | − connect(overlays, &Overlays::mousePressOffOverlay, [=]() { | |
| 1505 | − setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); | |
| 1506 | − }); | |
| 1507 | − | |
| 1508 | 1491 | connect(this, &Application::aboutToQuit, [=]() { |
| 1509 | 1492 | setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); |
| 1510 | 1493 | setKeyboardFocusEntity(UNKNOWN_ENTITY_ID); |
| 1511 | 1494 | }); |
| 1512 | 1495 | |
| 1513 | − connect(overlays, | |
| 1514 | − SIGNAL(mousePressOnOverlay(const OverlayID&, const PointerEvent&)), | |
| 1515 | − DependencyManager::get<ContextOverlayInterface>().data(), | |
| 1516 | − SLOT(contextOverlays_mousePressOnOverlay(const OverlayID&, const PointerEvent&))); | |
| 1517 | − | |
| 1518 | − connect(overlays, | |
| 1519 | − SIGNAL(hoverEnterOverlay(const OverlayID&, const PointerEvent&)), | |
| 1520 | − DependencyManager::get<ContextOverlayInterface>().data(), | |
| 1521 | − SLOT(contextOverlays_hoverEnterOverlay(const OverlayID&, const PointerEvent&))); | |
| 1522 | − | |
| 1523 | − connect(overlays, | |
| 1524 | − SIGNAL(hoverLeaveOverlay(const OverlayID&, const PointerEvent&)), | |
| 1525 | − DependencyManager::get<ContextOverlayInterface>().data(), | |
| 1526 | − SLOT(contextOverlays_hoverLeaveOverlay(const OverlayID&, const PointerEvent&))); | |
| 1527 | − | |
| 1528 | 1496 | // Add periodic checks to send user activity data |
| 1529 | 1497 | static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000; |
| 1530 | 1498 | static int NEARBY_AVATAR_RADIUS_METERS = 10; |
| @@ -4561,14 +4529,9 @@ QUuid Application::getKeyboardFocusEntity() const { · 3030 unmodified lines | ||
| 4561 | 4529 | return _keyboardFocusedEntity.get(); |
| 4562 | 4530 | } |
| 4563 | 4531 | |
| 4564 | −void Application::setKeyboardFocusEntity(QUuid id) { | |
| 4565 | − EntityItemID entityItemID(id); | |
| 4566 | − setKeyboardFocusEntity(entityItemID); | |
| 4567 | −} | |
| 4568 | − | |
| 4569 | 4532 | static const float FOCUS_HIGHLIGHT_EXPANSION_FACTOR = 1.05f; |
| 4570 | 4533 | |
| 4571 | −void Application::setKeyboardFocusEntity(EntityItemID entityItemID) { | |
| 4534 | +void Application::setKeyboardFocusEntity(const EntityItemID& entityItemID) { | |
| 4572 | 4535 | if (_keyboardFocusedEntity.get() != entityItemID) { |
| 4573 | 4536 | _keyboardFocusedEntity.set(entityItemID); |
| 4574 | 4537 | |
| @@ -4605,7 +4568,7 @@ OverlayID Application::getKeyboardFocusOverlay() { · 30 unmodified lines | ||
| 4605 | 4568 | return _keyboardFocusedOverlay.get(); |
| 4606 | 4569 | } |
| 4607 | 4570 | |
| 4608 | −void Application::setKeyboardFocusOverlay(OverlayID overlayID) { | |
| 4571 | +void Application::setKeyboardFocusOverlay(const OverlayID& overlayID) { | |
| 4609 | 4572 | if (overlayID != _keyboardFocusedOverlay.get()) { |
| 4610 | 4573 | _keyboardFocusedOverlay.set(overlayID); |
| 4611 | 4574 | |
| @@ -7443,51 +7406,6 @@ bool Application::isForeground() const { · 2831 unmodified lines | ||
| 7443 | 7406 | return _isForeground && !_window->isMinimized(); |
| 7444 | 7407 | } |
| 7445 | 7408 | |
| 7446 | −void Application::sendMousePressOnEntity(QUuid id, PointerEvent event) { | |
| 7447 | − EntityItemID entityItemID(id); | |
| 7448 | − emit getEntities()->mousePressOnEntity(entityItemID, event); | |
| 7449 | −} | |
| 7450 | − | |
| 7451 | −void Application::sendMouseMoveOnEntity(QUuid id, PointerEvent event) { | |
| 7452 | − EntityItemID entityItemID(id); | |
| 7453 | − emit getEntities()->mouseMoveOnEntity(entityItemID, event); | |
| 7454 | −} | |
| 7455 | − | |
| 7456 | −void Application::sendMouseReleaseOnEntity(QUuid id, PointerEvent event) { | |
| 7457 | − EntityItemID entityItemID(id); | |
| 7458 | − emit getEntities()->mouseReleaseOnEntity(entityItemID, event); | |
| 7459 | −} | |
| 7460 | − | |
| 7461 | −void Application::sendClickDownOnEntity(QUuid id, PointerEvent event) { | |
| 7462 | − EntityItemID entityItemID(id); | |
| 7463 | − emit getEntities()->clickDownOnEntity(entityItemID, event); | |
| 7464 | −} | |
| 7465 | − | |
| 7466 | −void Application::sendHoldingClickOnEntity(QUuid id, PointerEvent event) { | |
| 7467 | − EntityItemID entityItemID(id); | |
| 7468 | − emit getEntities()->holdingClickOnEntity(entityItemID, event); | |
| 7469 | −} | |
| 7470 | − | |
| 7471 | −void Application::sendClickReleaseOnEntity(QUuid id, PointerEvent event) { | |
| 7472 | − EntityItemID entityItemID(id); | |
| 7473 | − emit getEntities()->clickReleaseOnEntity(entityItemID, event); | |
| 7474 | −} | |
| 7475 | − | |
| 7476 | −void Application::sendHoverEnterEntity(QUuid id, PointerEvent event) { | |
| 7477 | − EntityItemID entityItemID(id); | |
| 7478 | − emit getEntities()->hoverEnterEntity(entityItemID, event); | |
| 7479 | −} | |
| 7480 | − | |
| 7481 | −void Application::sendHoverOverEntity(QUuid id, PointerEvent event) { | |
| 7482 | − EntityItemID entityItemID(id); | |
| 7483 | − emit getEntities()->hoverOverEntity(entityItemID, event); | |
| 7484 | −} | |
| 7485 | − | |
| 7486 | −void Application::sendHoverLeaveEntity(QUuid id, PointerEvent event) { | |
| 7487 | − EntityItemID entityItemID(id); | |
| 7488 | − emit getEntities()->hoverLeaveEntity(entityItemID, event); | |
| 7489 | −} | |
| 7490 | − | |
| 7491 | 7409 | // FIXME? perhaps two, one for the main thread and one for the offscreen UI rendering thread? |
| 7492 | 7410 | static const int UI_RESERVED_THREADS = 1; |
| 7493 | 7411 | // Windows won't let you have all the cores |