void Events::pollEvents() { checkForNextFrameCounter(); Common::Event event; if (!g_system->getEventManager()->pollEvent(event)) return; switch (event.type) { case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; eventTarget()->mouseMove(_mousePos); break; case Common::EVENT_LBUTTONDOWN: _specialButtons |= MK_LBUTTON; _mousePos = event.mouse; eventTarget()->leftButtonDown(_mousePos); break; case Common::EVENT_LBUTTONUP: _specialButtons &= ~MK_LBUTTON; _mousePos = event.mouse; eventTarget()->leftButtonUp(_mousePos); break; case Common::EVENT_MBUTTONDOWN: _specialButtons |= MK_MBUTTON; _mousePos = event.mouse; eventTarget()->middleButtonDown(_mousePos); break; case Common::EVENT_MBUTTONUP: _specialButtons &= ~MK_MBUTTON; _mousePos = event.mouse; eventTarget()->middleButtonUp(_mousePos); break; case Common::EVENT_RBUTTONDOWN: _specialButtons |= MK_RBUTTON; _mousePos = event.mouse; eventTarget()->rightButtonDown(_mousePos); break; case Common::EVENT_RBUTTONUP: _specialButtons &= ~MK_RBUTTON; _mousePos = event.mouse; eventTarget()->rightButtonUp(_mousePos); break; case Common::EVENT_WHEELUP: case Common::EVENT_WHEELDOWN: _mousePos = event.mouse; eventTarget()->mouseWheel(_mousePos, event.type == Common::EVENT_WHEELUP); break; case Common::EVENT_KEYDOWN: handleKbdSpecial(event.kbd); eventTarget()->keyDown(event.kbd); break; case Common::EVENT_KEYUP: handleKbdSpecial(event.kbd); eventTarget()->keyUp(event.kbd); break; default: break; } }
void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType listenerType, const AtomicString& eventName, double elapsedTime) { if (m_animationTarget->document().hasListenerType(listenerType)) { RefPtrWillBeRawPtr<AnimationEvent> event = AnimationEvent::create(eventName, m_name, elapsedTime); event->setTarget(eventTarget()); document().enqueueAnimationFrameEvent(event); } }
void NotificationPresenter::cancel(const WebNotification& notification) { WebString identifier = identifierForNotification(notification); m_delegate->printMessage(string("DESKTOP NOTIFICATION CLOSED: ") + string(identifier.utf8()) + "\n"); WebNotification eventTarget(notification); eventTarget.dispatchCloseEvent(false); string id(identifier.utf8()); m_activeNotifications.erase(id); }
bool NotificationPresenter::simulateClick(const WebString& title) { string id(title.utf8()); if (m_activeNotifications.find(id) == m_activeNotifications.end()) return false; const WebNotification& notification = m_activeNotifications.find(id)->second; WebNotification eventTarget(notification); eventTarget.dispatchClickEvent(); return true; }
void Events::pollEvents() { checkForNextFrameCounter(); Common::Event event; if (!g_system->getEventManager()->pollEvent(event)) return; switch (event.type) { case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; eventTarget()->mouseMove(_mousePos); break; case Common::EVENT_LBUTTONDOWN: _mousePos = event.mouse; eventTarget()->leftButtonDown(_mousePos); break; case Common::EVENT_LBUTTONUP: _mousePos = event.mouse; eventTarget()->leftButtonUp(_mousePos); break; case Common::EVENT_MBUTTONDOWN: _mousePos = event.mouse; eventTarget()->middleButtonDown(_mousePos); break; case Common::EVENT_MBUTTONUP: _mousePos = event.mouse; eventTarget()->middleButtonUp(_mousePos); break; case Common::EVENT_RBUTTONDOWN: _mousePos = event.mouse; eventTarget()->rightButtonDown(_mousePos); break; case Common::EVENT_RBUTTONUP: _mousePos = event.mouse; eventTarget()->rightButtonUp(_mousePos); break; case Common::EVENT_KEYDOWN: eventTarget()->keyDown(event.kbd); break; case Common::EVENT_KEYUP: eventTarget()->keyUp(event.kbd); break; default: break; } }
nsresult BasePlatformInterface::DispatchDOMEvent(nsIDOMEvent *aEvent) { NS_ENSURE_ARG_POINTER(aEvent); nsresult rv = NS_ERROR_UNEXPECTED; nsCOMPtr<nsIDOMEventTarget> eventTarget(do_QueryInterface(mDocument, &rv )); NS_ENSURE_SUCCESS( rv, rv ); bool dummy = PR_FALSE; rv = eventTarget->DispatchEvent(aEvent, &dummy); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
void CSSAnimations::TransitionEventDelegate::onEventCondition(const AnimationEffect& animationNode) { const AnimationEffect::Phase currentPhase = animationNode.phase(); if (currentPhase == AnimationEffect::PhaseAfter && currentPhase != m_previousPhase && document().hasListenerType(Document::TRANSITIONEND_LISTENER)) { String propertyName = getPropertyNameString(m_property); const Timing& timing = animationNode.specifiedTiming(); double elapsedTime = timing.iterationDuration; const AtomicString& eventType = EventTypeNames::transitionend; String pseudoElement = PseudoElement::pseudoElementNameForEvents(pseudoId()); RefPtrWillBeRawPtr<TransitionEvent> event = TransitionEvent::create(eventType, propertyName, elapsedTime, pseudoElement); event->setTarget(eventTarget()); document().enqueueAnimationFrameEvent(event); } m_previousPhase = currentPhase; }
bool Events::checkForNextFrameCounter() { // Check for next game frame uint32 milli = g_system->getMillis(); if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { ++_frameCounter; _priorFrameTime = milli; // Handle any idle updates eventTarget()->onIdle(); // Give time to the debugger _vm->_debugger->onFrame(); // Display the frame _vm->_screen->update(); return true; } return false; }
LRESULT CALLBACK nsWindowUtil::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { bool handled = true; WNDPROC proc; nsWindowUtil* self = (nsWindowUtil*)GetProp(hwnd, S_PROPINST); if (self && self->mOldProc && self->mDOMWindow) { proc = self->mOldProc; } else { // property not found - we don't exist anymore // use the original window proc proc = (WNDPROC)GetProp(hwnd, S_PROPPROC); if (!proc) // can't find the right process... skip over to the default // (this will, at the minimum, totally break the app) proc = DefWindowProc; handled = false; } /* * For this next section, including all the switches, we are simply * collecting messages we feel are important to collect. Once we collect * all the windows messages that may be important to us, then these messages * are dispatched as DOM events to the window. */ nsAutoString typeArg; POINT clientPos = { 0, 0}; POINT screenPos = { 0, 0}; if (handled) { switch (uMsg) { case WM_NCLBUTTONDOWN: switch(wParam) { // these are the min, max, and close buttons for case HTMINBUTTON: typeArg = NS_LITERAL_STRING("minimizing"); break; case HTMAXBUTTON: typeArg = NS_LITERAL_STRING("maximizing"); break; case HTCLOSE: typeArg = NS_LITERAL_STRING("closing"); break; default: handled = false; } clientPos.x = screenPos.x = LOWORD(lParam); clientPos.y = screenPos.y = LOWORD(lParam); ::ClientToScreen(hwnd, &screenPos); break; case WM_ACTIVATE: switch (LOWORD(wParam)) { case WA_ACTIVE: case WA_CLICKACTIVE: // window is being activated typeArg = NS_LITERAL_STRING("activating"); break; default: handled = false; } break; case WM_SIZE: switch (wParam) { case SIZE_MINIMIZED: typeArg = NS_LITERAL_STRING("minimizing"); break; default: // for some reason this message is received with wParam == // SIZE_MAXIMIZED when the browser is shutting down, and calling // Restore() results in the maximized window being "restored" // (returned to non-maximized) size. This size is preserved // after restarting, which is annoying, so I'm commenting it out // until someone can prove that this is actually useful. // // we're resizing, but not minimized, so some part must be visible //typeArg = NS_LITERAL_STRING("activating"); break; } break; case WM_SYSCOMMAND: switch (wParam) { case SC_CLOSE: //The user has clicked on the top left window icon and selected close... //Or the user typed Alt+F4. typeArg = NS_LITERAL_STRING("closing"); break; default: handled = false; } break; default: handled = false; break; } } PRBool ctrlArg = PR_FALSE; PRBool altArg = PR_FALSE; PRBool shiftArg = PR_FALSE; if (handled) { // check modifier key states if (::GetKeyState(VK_CONTROL) & 0x8000) ctrlArg = PR_TRUE; if (::GetKeyState(VK_MENU) & 0x8000) altArg = PR_TRUE; if (::GetKeyState(VK_SHIFT) & 0x8000) shiftArg = PR_TRUE; // dispatch the event PRBool ret = TRUE; nsresult rv; nsCOMPtr<nsIDOMEventTarget> eventTarget(do_QueryInterface(self->mDOMWindow, &rv)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMDocument> document; rv = self->mDOMWindow->GetDocument(getter_AddRefs(document)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMDocumentEvent> documentEvent(do_QueryInterface(document, &rv)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMDocumentView> documentView(do_QueryInterface(document, &rv)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMAbstractView> abstractView; rv = documentView->GetDefaultView(getter_AddRefs(abstractView)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMEvent> event; rv = documentEvent->CreateEvent(NS_LITERAL_STRING("mouseevent"), getter_AddRefs(event)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(event, &rv)); NS_ENSURE_SUCCESS(rv, rv); rv = mouseEvent->InitMouseEvent(typeArg, PR_TRUE, PR_TRUE, abstractView, 1, screenPos.x, screenPos.y, clientPos.x, clientPos.y, ctrlArg, altArg, shiftArg, PR_FALSE, 0, nsnull); NS_ENSURE_SUCCESS(rv, rv); rv = eventTarget->DispatchEvent(mouseEvent, &ret); NS_ENSURE_SUCCESS(rv, rv); if (!ret) // event was hooked return FALSE; } return CallWindowProc(proc, hwnd, uMsg, wParam, lParam); }
void Events::setMousePos(const Common::Point &pt) { g_system->warpMouse(pt.x, pt.y); _mousePos = pt; eventTarget()->mouseMove(_mousePos); }