static void WaitEvent(KonohaContext *kctx, kbool_t (*consume)(KonohaContext *kctx, struct JsonBuf *, KTraceInfo *), KTraceInfo *trace) { int signo; sigset_t ss; sigemptyset(&ss); sigaddset(&ss, SIGCONT); sigaddset(&ss, SIGINT); // sigprocmask(SIG_BLOCK, &ss, NULL); // check this out while(PLATAPI eventContext != NULL) { int safePoint = *(PLATAPI eventContext->safePointRef); *(PLATAPI eventContext->safePointRef) ^= SafePoint_Event; // FIXME if((safePoint & SafePoint_Event) == SafePoint_Event) { DispatchEvent(kctx, consume, trace); } PLATAPI eventContext->isWaiting = true; sigwait(&ss, &signo); if(signo == SIGINT) break; } if(PLATAPI eventContext != NULL) { PLATAPI eventContext->isWaiting = false; } }
nsresult FileReader::DispatchProgressEvent(const nsAString& aType) { ProgressEventInit init; init.mBubbles = false; init.mCancelable = false; init.mLoaded = mTransferred; if (mTotal != kUnknownSize) { init.mLengthComputable = true; init.mTotal = mTotal; } else { init.mLengthComputable = false; init.mTotal = 0; } RefPtr<ProgressEvent> event = ProgressEvent::Constructor(this, aType, init); event->SetTrusted(true); ErrorResult rv; DispatchEvent(*event, rv); return rv.StealNSResult(); }
static void HandleXEvent() { int handled = 0, pending; ASEvent event; #if 0 while (XQLength(dpy)>0) #else while ((pending = XPending(dpy))>0) #endif { // show_debug (__FILE__,__FUNCTION__,__LINE__, "%d pending X events", pending); if( ASNextEvent (&(event.x), False) ){ event.client = NULL ; LOCAL_DEBUG_OUT("event = %d", event.x.type); setup_asevent_from_xevent( &event ); DispatchEvent( &event ); handled++; } } if (handled > 0) { addTimeout(); } }
void IDBFileHandle::HandleCompleteOrAbort(bool aAborted) { AssertIsOnOwningThread(); FileHandleBase::HandleCompleteOrAbort(aAborted); nsCOMPtr<nsIDOMEvent> event; if (aAborted) { event = CreateGenericEvent(this, nsDependentString(kAbortEventType), eDoesBubble, eNotCancelable); } else { event = CreateGenericEvent(this, nsDependentString(kCompleteEventType), eDoesNotBubble, eNotCancelable); } if (NS_WARN_IF(!event)) { return; } bool dummy; if (NS_FAILED(DispatchEvent(event, &dummy))) { NS_WARNING("DispatchEvent failed!"); } }
void CTouchDelegate::OnTouchMoved( unsigned int num, intptr_t* pTouchIdByDevice, float* xTouchPoint, float* yTouchPoint ) { if ( m_bEnableTouch ) { CTouchEvent event(EEventType::eET_EVENT_TOUCH_MOVED); for ( unsigned int index = 0; index < num ; ++index ) { intptr_t id = pTouchIdByDevice[ index ]; auto iter = m_currentTouchMap.find( id ); BEATS_ASSERT(iter != m_currentTouchMap.end(), _T("OnTouchMoved: touch id %d doesn't exists! have you called began?"), id); if ( iter != m_currentTouchMap.end() ) { CTouch* pTouch = m_pTouches[ iter->second ]; pTouch->UpdateTouchInfo( id, xTouchPoint[ index ], yTouchPoint[ index ] ); event.AddTouch(pTouch); } } if ( event.GetTouchNum() > 0 ) { CWindowManager::GetInstance()->OnTouchEvent( &event ); DispatchEvent(&event); } } }
nsresult IDBFileHandle::OnCompleteOrAbort(bool aAborted) { nsCOMPtr<nsIDOMEvent> event; if (aAborted) { event = CreateGenericEvent(this, nsDependentString(kAbortEventType), eDoesBubble, eNotCancelable); } else { event = CreateGenericEvent(this, nsDependentString(kCompleteEventType), eDoesNotBubble, eNotCancelable); } if (NS_WARN_IF(!event)) { return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR; } bool dummy; if (NS_FAILED(DispatchEvent(event, &dummy))) { NS_WARNING("Dispatch failed!"); } mMutableFile->Database()->OnFileHandleFinished(); return NS_OK; }
void IDBRequest::DispatchNonTransactionError(nsresult aErrorCode) { AssertIsOnOwningThread(); MOZ_ASSERT(NS_FAILED(aErrorCode)); MOZ_ASSERT(NS_ERROR_GET_MODULE(aErrorCode) == NS_ERROR_MODULE_DOM_INDEXEDDB); SetError(aErrorCode); // Make an error event and fire it at the target. nsCOMPtr<nsIDOMEvent> event = CreateGenericEvent(this, nsDependentString(kErrorEventType), eDoesBubble, eCancelable); if (NS_WARN_IF(!event)) { return; } bool ignored; if (NS_FAILED(DispatchEvent(event, &ignored))) { NS_WARNING("Failed to dispatch event!"); } }
void Platform_Windows::ApplyVideoModeChanges(VideoModeInfo* aVideoModeInfo) { //Cast the video mode info struct to the win32 video mode info struct VideoModeInfo_Win32* videoModeInfoWin32 = (VideoModeInfo_Win32*)aVideoModeInfo; //Will we need to dispatch a fullscreen event bool dispatchFullscreenEvent = m_IsFullScreen != videoModeInfoWin32->fullScreen; //Scale the resolution videoModeInfoWin32->width *= GetScale(); videoModeInfoWin32->height *= GetScale(); //Is fullscreen enabled? if(videoModeInfoWin32->fullScreen == true) { //Set the fullscreen flag to true m_IsFullScreen = true; //Update the window style for fullscreen display SetWindowLongPtr(m_GameWindow->GetWindowHandle(), GWL_STYLE, WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE); //Set the fullscreen display settings DEVMODE displaySettings; EnumDisplaySettings (NULL, 0, &displaySettings); displaySettings.dmPelsWidth = videoModeInfoWin32->width; displaySettings.dmPelsHeight = videoModeInfoWin32->height; displaySettings.dmBitsPerPel = 32; displaySettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; //Enable fullscreen mode, if the assert below is hit, the resolution passed in is NOT supported in fullscreen mode bool success = ChangeDisplaySettings(&displaySettings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL; assert(success == true); //Move the window into position MoveWindow(m_GameWindow->GetWindowHandle(), 0, 0, videoModeInfoWin32->width, videoModeInfoWin32->height, TRUE); } else { //Exit fullscreen mode bool success = ChangeDisplaySettings(0, 0) == DISP_CHANGE_SUCCESSFUL; assert(success == true); //Set the fullscreen flag to false m_IsFullScreen = false; //Set the window rect RECT rect; rect.left = 0; rect.top = 0; rect.right = videoModeInfoWin32->width; rect.bottom = videoModeInfoWin32->height; //Calculate the position of the window, centered on screen int monitorResolutionX = GetSystemMetrics(SM_CXSCREEN); int monitorResolutionY = GetSystemMetrics(SM_CYSCREEN); int x = (monitorResolutionX - videoModeInfoWin32->width) / 2; int y = (monitorResolutionY - videoModeInfoWin32->height) / 2; //Restore the window's 'windowed' style, then set the window's rect and position on screen SetWindowLongPtr(m_GameWindow->GetWindowHandle(), GWL_STYLE, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE); AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW, FALSE); MoveWindow(m_GameWindow->GetWindowHandle(), x, y, rect.right-rect.left, rect.bottom-rect.top, TRUE); } //Dispatch a fullscreen event if(dispatchFullscreenEvent == true) { DispatchEvent(new FullscreenEvent(m_IsFullScreen)); } }
void ElementDocument::Hide() { SetProperty(VISIBILITY, "hidden"); DispatchEvent("hide", Dictionary(), false); }
bool TextEventDispatcher::DispatchKeyboardEventInternal( uint32_t aMessage, const WidgetKeyboardEvent& aKeyboardEvent, nsEventStatus& aStatus, uint32_t aIndexOfKeypress) { MOZ_ASSERT(aMessage == NS_KEY_DOWN || aMessage == NS_KEY_UP || aMessage == NS_KEY_PRESS, "Invalid aMessage value"); nsresult rv = GetState(); if (NS_WARN_IF(NS_FAILED(rv))) { return false; } // If the key shouldn't cause keypress events, don't this patch them. if (aMessage == NS_KEY_PRESS && !aKeyboardEvent.ShouldCauseKeypressEvents()) { return false; } // Basically, key events shouldn't be dispatched during composition. if (IsComposing()) { // However, if we need to behave like other browsers, we need the keydown // and keyup events. Note that this behavior is also allowed by D3E spec. // FYI: keypress events must not be fired during composition. if (!sDispatchKeyEventsDuringComposition || aMessage == NS_KEY_PRESS) { return false; } // XXX If there was mOnlyContentDispatch for this case, it might be useful // because our chrome doesn't assume that key events are fired during // composition. } WidgetKeyboardEvent keyEvent(true, aMessage, mWidget); InitEvent(keyEvent); keyEvent.AssignKeyEventData(aKeyboardEvent, false); if (aStatus == nsEventStatus_eConsumeNoDefault) { // If the key event should be dispatched as consumed event, marking it here. // This is useful to prevent double action. E.g., when the key was already // handled by system, our chrome shouldn't handle it. keyEvent.mFlags.mDefaultPrevented = true; } // Corrects each member for the specific key event type. if (aMessage == NS_KEY_DOWN || aMessage == NS_KEY_UP) { MOZ_ASSERT(!aIndexOfKeypress, "aIndexOfKeypress must be 0 for either NS_KEY_DOWN or NS_KEY_UP"); // charCode of keydown and keyup should be 0. keyEvent.charCode = 0; } else if (keyEvent.mKeyNameIndex != KEY_NAME_INDEX_USE_STRING) { MOZ_ASSERT(!aIndexOfKeypress, "aIndexOfKeypress must be 0 for NS_KEY_PRESS of non-printable key"); // If keypress event isn't caused by printable key, its charCode should // be 0. keyEvent.charCode = 0; } else { MOZ_RELEASE_ASSERT( !aIndexOfKeypress || aIndexOfKeypress < keyEvent.mKeyValue.Length(), "aIndexOfKeypress must be 0 - mKeyValue.Length() - 1"); keyEvent.keyCode = 0; wchar_t ch = keyEvent.mKeyValue.IsEmpty() ? 0 : keyEvent.mKeyValue[aIndexOfKeypress]; keyEvent.charCode = static_cast<uint32_t>(ch); if (ch) { keyEvent.mKeyValue.Assign(ch); } else { keyEvent.mKeyValue.Truncate(); } } if (aMessage == NS_KEY_UP) { // mIsRepeat of keyup event must be false. keyEvent.mIsRepeat = false; } // mIsComposing should be initialized later. keyEvent.mIsComposing = false; // XXX Currently, we don't support to dispatch key event with native key // event information. keyEvent.mNativeKeyEvent = nullptr; // XXX Currently, we don't support to dispatch key events with data for // plugins. keyEvent.mPluginEvent.Clear(); // TODO: Manage mUniqueId here. DispatchEvent(mWidget, keyEvent, aStatus); return true; }
/* void disconnect (); */ nsresult sbMockDevice::DeviceSpecificDisconnect() { NS_ENSURE_STATE(mIsConnected); nsresult rv; nsRefPtr<sbBaseDeviceVolume> volume; { nsAutoLock autoVolumeLock(mVolumeLock); volume = mDefaultVolume; mDefaultVolume = nsnull; } if (volume) RemoveVolume(volume); mIsConnected = PR_FALSE; // Finalize the device content and device libraries if (mContent) { // Get a copy of the list of device libraries nsCOMArray<sbIDeviceLibrary> libraryListCopy; PRInt32 libraryListCopyCount; nsCOMPtr<nsIArray> libraryList; PRUint32 libraryCount; rv = mContent->GetLibraries(getter_AddRefs(libraryList)); if (NS_SUCCEEDED(rv)) rv = libraryList->GetLength(&libraryCount); if (NS_SUCCEEDED(rv)) { for (PRUint32 i = 0; i < libraryCount; i++) { nsCOMPtr<sbIDeviceLibrary> library = do_QueryElementAt(libraryList, i, &rv); if (NS_FAILED(rv)) continue; libraryListCopy.AppendObject(library); } } libraryListCopyCount = libraryListCopy.Count(); // Finalize each device library for (PRInt32 i = 0; i < libraryListCopyCount; i++) { RemoveLibrary(libraryListCopy[i]); FinalizeDeviceLibrary(libraryListCopy[i]); } // Finalize the device content mContent->Finalize(); mContent = nsnull; } PRUint32 state = sbIDevice::STATE_IDLE; nsCOMPtr<sbIDeviceManager2> manager = do_GetService("@songbirdnest.com/Songbird/DeviceManager;2", &rv); NS_ENSURE_SUCCESS(rv, rv); sbNewVariant data(static_cast<sbIDevice*>(static_cast<sbBaseDevice*>(this))); nsCOMPtr<sbIDeviceEvent> deviceEvent; rv = manager->CreateEvent(sbIDeviceEvent::EVENT_DEVICE_REMOVED, sbNewVariant(static_cast<sbIDevice*>(static_cast<sbBaseDevice*>(this))), data, state, state, getter_AddRefs(deviceEvent)); NS_ENSURE_SUCCESS(rv, rv); bool dispatched; rv = DispatchEvent(deviceEvent, PR_TRUE, &dispatched); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
void GUI::ProcessEvent() { TEvent E; E = NextEvent; if (E.What != evNone) { NextEvent.What = evNone; } if (E.What == evNone && (ConGetEvent(evMouse | evCommand | evKeyboard, &E, 0, 1, 0) == -1 || E.What == evNone) ) { frames->Update(); while (ConGetEvent(evMouse | evCommand | evKeyboard, &E, -1, 1, 0) == -1 || (E.What == evMouseMove && E.Mouse.Buttons == 0)); } if (E.What != evNone) { GView *view = frames->Active; if (E.What & evMouse) { if (E.What == evMouseDown && E.Mouse.Y == 0 && ShowMenuBar && MouseCapture == 0 && FocusCapture == 0) { frames->Update(); // sync before menu if (ExecMainMenu(E, 0) == -1) { if (E.What == evCommand && E.Msg.Command == cmResize) { int X, Y; ConQuerySize(&X, &Y); frames->Resize(X, Y); } E.What = evNone; } // fprintf(stderr, "Command got = %d\n", E.Msg.Command); } if (E.What == evMouseDown && MouseCapture == 0 && FocusCapture == 0) { GView *V = frames->Active; while (V) { if (E.Mouse.Y >= V->Peer->wY && E.Mouse.Y < V->Peer->wY + V->Peer->wH + (ShowHScroll ? 1 : 0)) { frames->SelectView(V); view = V; break; } V = V->Next; if (V == frames->Active) break; } } if (ShowVScroll && ShowHScroll && E.What == evMouseDown && MouseCapture == 0 && FocusCapture == 0 && E.Mouse.Y == view->Peer->wY + view->Peer->wH && E.Mouse.X == view->Peer->wX + view->Peer->wW) { } else { if (ShowVScroll && E.What == evMouseDown && MouseCapture == 0 && FocusCapture == 0 && E.Mouse.X == view->Peer->wX + view->Peer->wW) { HandleVScroll(view, E); return ; } if (ShowHScroll && E.What == evMouseDown && MouseCapture == 0 && FocusCapture == 0 && E.Mouse.Y == view->Peer->wY + view->Peer->wH) { HandleHScroll(view, E); return ; } } if (E.What & evMouse) { E.Mouse.Y -= view->Peer->wY; E.Mouse.X -= view->Peer->wX; } } if (E.What == evCommand) { switch (E.Msg.Command) { case cmResize: { int X, Y; ConQuerySize(&X, &Y); frames->Resize(X, Y); } break; case cmMainMenu: { char Sub = (char)E.Msg.Param1; frames->Update(); // sync before menu if (::ExecMainMenu(E, Sub) != 1) { ; if (E.What == evCommand && E.Msg.Command == cmResize) { int X, Y; ConQuerySize(&X, &Y); frames->Resize(X, Y); } E.What = evNone; } } break; case cmPopupMenu: { int id = E.Msg.Param1; int Cols, Rows; if (id == -1) return; frames->ConQuerySize(&Cols, &Rows); int x = Cols / 2, y = Rows / 2; ConQueryMousePos(&x, &y); frames->Update(); // sync before menu if (::ExecVertMenu(x, y, id, E, 0) != 1) { if (E.What == evCommand && E.Msg.Command == cmResize) { int X, Y; ConQuerySize(&X, &Y); frames->Resize(X, Y); } E.What = evNone; } } break; } } if (E.What != evNone) DispatchEvent(frames, view, E); } }
void CSteam::OnDeletePublishedFile(RemoteStorageDeletePublishedFileResult_t *result, bool failure) { // we can ignore result->m_nPublishedFileId, as it had to be passed // to the call to DeletePublishedFile anyway DispatchEvent(RESPONSE_OnDeletePublishedFile, result->m_eResult); }
void CSteam::OnGetPublishedItemVoteDetails(RemoteStorageGetPublishedItemVoteDetailsResult_t *result, bool failure) { if (!failure) m_PublishedItemVoteDetails.reset(new RemoteStorageGetPublishedItemVoteDetailsResult_t(*result)); DispatchEvent(RESPONSE_OnGetPublishedItemVoteDetails, result->m_eResult); }
void TextComposition::DispatchCompositionEvent( WidgetCompositionEvent* aCompositionEvent, nsEventStatus* aStatus, EventDispatchingCallback* aCallBack, bool aIsSynthesized) { mWasCompositionStringEmpty = mString.IsEmpty(); if (aCompositionEvent->IsFollowedByCompositionEnd()) { mHasReceivedCommitEvent = true; } // If this instance has requested to commit or cancel composition but // is not synthesizing commit event, that means that the IME commits or // cancels the composition asynchronously. Typically, iBus behaves so. // Then, synthesized events which were dispatched immediately after // the request has already committed our editor's composition string and // told it to web apps. Therefore, we should ignore the delayed events. if (mRequestedToCommitOrCancel && !aIsSynthesized) { *aStatus = nsEventStatus_eConsumeNoDefault; return; } // If the content is a container of TabParent, composition should be in the // remote process. if (mTabParent) { Unused << mTabParent->SendCompositionEvent(*aCompositionEvent); aCompositionEvent->StopPropagation(); if (aCompositionEvent->CausesDOMTextEvent()) { mLastData = aCompositionEvent->mData; mLastRanges = aCompositionEvent->mRanges; // Although, the composition event hasn't been actually handled yet, // emulate an editor to be handling the composition event. EditorWillHandleCompositionChangeEvent(aCompositionEvent); EditorDidHandleCompositionChangeEvent(); } return; } if (!mAllowControlCharacters) { RemoveControlCharactersFrom(aCompositionEvent->mData, aCompositionEvent->mRanges); } if (aCompositionEvent->mMessage == eCompositionCommitAsIs) { NS_ASSERTION(!aCompositionEvent->mRanges, "mRanges of eCompositionCommitAsIs should be null"); aCompositionEvent->mRanges = nullptr; NS_ASSERTION(aCompositionEvent->mData.IsEmpty(), "mData of eCompositionCommitAsIs should be empty string"); bool removePlaceholderCharacter = Preferences::GetBool("intl.ime.remove_placeholder_character_at_commit", false); if (removePlaceholderCharacter && mLastData == IDEOGRAPHIC_SPACE) { // If the last data is an ideographic space (FullWidth space), it might be // a placeholder character of some Chinese IME. So, committing with // this data might not be expected by users. Let's use empty string. aCompositionEvent->mData.Truncate(); } else { aCompositionEvent->mData = mLastData; } } else if (aCompositionEvent->mMessage == eCompositionCommit) { NS_ASSERTION(!aCompositionEvent->mRanges, "mRanges of eCompositionCommit should be null"); aCompositionEvent->mRanges = nullptr; } if (!IsValidStateForComposition(aCompositionEvent->mWidget)) { *aStatus = nsEventStatus_eConsumeNoDefault; return; } // IME may commit composition with empty string for a commit request or // with non-empty string for a cancel request. We should prevent such // unexpected result. E.g., web apps may be confused if they implement // autocomplete which attempts to commit composition forcibly when the user // selects one of suggestions but composition string is cleared by IME. // Note that most Chinese IMEs don't expose actual composition string to us. // They typically tell us an IDEOGRAPHIC SPACE or empty string as composition // string. Therefore, we should hack it only when: // 1. committing string is empty string at requesting commit but the last // data isn't IDEOGRAPHIC SPACE. // 2. non-empty string is committed at requesting cancel. if (!aIsSynthesized && (mIsRequestingCommit || mIsRequestingCancel)) { nsString* committingData = nullptr; switch (aCompositionEvent->mMessage) { case eCompositionEnd: case eCompositionChange: case eCompositionCommitAsIs: case eCompositionCommit: committingData = &aCompositionEvent->mData; break; default: NS_WARNING("Unexpected event comes during committing or " "canceling composition"); break; } if (committingData) { if (mIsRequestingCommit && committingData->IsEmpty() && mLastData != IDEOGRAPHIC_SPACE) { committingData->Assign(mLastData); } else if (mIsRequestingCancel && !committingData->IsEmpty()) { committingData->Truncate(); } } } bool dispatchEvent = true; bool dispatchDOMTextEvent = aCompositionEvent->CausesDOMTextEvent(); // When mIsComposing is false but the committing string is different from // the last data (E.g., previous eCompositionChange event made the // composition string empty or didn't have clause information), we don't // need to dispatch redundant DOM text event. (But note that we need to // dispatch eCompositionChange event if we have not dispatched // eCompositionChange event yet and commit string replaces selected string // with empty string since selected string hasn't been replaced with empty // string yet.) if (dispatchDOMTextEvent && aCompositionEvent->mMessage != eCompositionChange && !mIsComposing && mHasDispatchedDOMTextEvent && mLastData == aCompositionEvent->mData) { dispatchEvent = dispatchDOMTextEvent = false; } // widget may dispatch redundant eCompositionChange event // which modifies neither composition string, clauses nor caret // position. In such case, we shouldn't dispatch DOM events. if (dispatchDOMTextEvent && aCompositionEvent->mMessage == eCompositionChange && mLastData == aCompositionEvent->mData && mRanges && aCompositionEvent->mRanges && mRanges->Equals(*aCompositionEvent->mRanges)) { dispatchEvent = dispatchDOMTextEvent = false; } if (dispatchDOMTextEvent) { if (!MaybeDispatchCompositionUpdate(aCompositionEvent)) { return; } } if (dispatchEvent) { // If the composition event should cause a DOM text event, we should // overwrite the event message as eCompositionChange because due to // the limitation of mapping between event messages and DOM event types, // we cannot map multiple event messages to a DOM event type. if (dispatchDOMTextEvent && aCompositionEvent->mMessage != eCompositionChange) { mHasDispatchedDOMTextEvent = true; aCompositionEvent->mFlags = CloneAndDispatchAs(aCompositionEvent, eCompositionChange, aStatus, aCallBack); } else { if (aCompositionEvent->mMessage == eCompositionChange) { mHasDispatchedDOMTextEvent = true; } DispatchEvent(aCompositionEvent, aStatus, aCallBack); } } else { *aStatus = nsEventStatus_eConsumeNoDefault; } if (!IsValidStateForComposition(aCompositionEvent->mWidget)) { return; } // Emulate editor behavior of compositionchange event (DOM text event) handler // if no editor handles composition events. if (dispatchDOMTextEvent && !HasEditor()) { EditorWillHandleCompositionChangeEvent(aCompositionEvent); EditorDidHandleCompositionChangeEvent(); } if (aCompositionEvent->CausesDOMCompositionEndEvent()) { // Dispatch a compositionend event if it's necessary. if (aCompositionEvent->mMessage != eCompositionEnd) { CloneAndDispatchAs(aCompositionEvent, eCompositionEnd); } MOZ_ASSERT(!mIsComposing, "Why is the editor still composing?"); MOZ_ASSERT(!HasEditor(), "Why does the editor still keep to hold this?"); } MaybeNotifyIMEOfCompositionEventHandled(aCompositionEvent); }
void CSteam::OnCommitPublishedFileUpdate(RemoteStorageUpdatePublishedFileResult_t *result, bool failure) { // we can ignore m_nPublishedFileId again DispatchEvent(RESPONSE_OnCommitPublishedFileUpdate, result->m_eResult); }
void CSteam::OnUnsubscribePublishedFile(RemoteStorageUnsubscribePublishedFileResult_t *result, bool failure) { // ignoring m_nPublishedFileId DispatchEvent(RESPONSE_OnUnsubscribePublishedFile, result->m_eResult); }
void CSteam::OnEnumeratePublishedFilesByUserAction(RemoteStorageEnumeratePublishedFilesByUserActionResult_t *result, bool failure) { if (!failure) m_PublishedFilesByAction.reset(new RemoteStorageEnumeratePublishedFilesByUserActionResult_t(*result)); DispatchEvent(RESPONSE_OnEnumeratePublishedFilesByUserAction, result->m_eResult); }
void CSteam::OnEnumerateUserSharedWorkshopFiles(RemoteStorageEnumerateUserSharedWorkshopFilesResult_t *result, bool failure) { if (!failure) m_UserSharedFiles.reset(new RemoteStorageEnumerateUserSharedWorkshopFilesResult_t(*result)); DispatchEvent(RESPONSE_OnEnumerateUserSharedWorkshopFiles, result->m_eResult); }
void CSteam::OnGetPublishedFileDetails(RemoteStorageGetPublishedFileDetailsResult_t *result, bool failure) { // TODO: needs to be a map? if (!failure) m_PublishedFileDetails[result->m_nPublishedFileId] = *result; DispatchEvent(RESPONSE_OnGetPublishedFileDetails, result->m_eResult); }
/* virtual */ void BMediaEventLooper::ControlLoop() { CALLED(); bool is_realtime = false; status_t err; bigtime_t latency; bigtime_t waituntil; bigtime_t lateness; for (;;) { // while there are no events or it is not time for the earliest event, // process messages using WaitForMessages. Whenever this funtion times out, // we need to handle the next event for (;;) { if (RunState() == B_QUITTING) return; // BMediaEventLooper compensates your performance time by adding the event latency // (see SetEventLatency()) and the scheduling latency (or, for real-time events, // only the scheduling latency). latency = fEventLatency + fSchedulingLatency; waituntil = B_INFINITE_TIMEOUT; if (fEventQueue.HasEvents()) { const media_timed_event *firstEvent = fEventQueue.FirstEvent(); waituntil = TimeSource()->RealTimeFor(firstEvent->event_time, latency); is_realtime = false; lateness = firstEvent->queued_time - waituntil; if (lateness > 0) { // if (lateness > 1000) // printf("node %02ld handling %12Ld at %12Ld -- %Ld late, queued at %Ld now %12Ld \n", // ID(), fEventQueue.FirstEventTime(), TimeSource()->Now(), lateness, // firstEvent->queued_time, TimeSource()->RealTime()); is_realtime = false; break; } // printf("node %02ld waiting for %12Ld that will happen at %12Ld\n", ID(), fEventQueue.FirstEventTime(), waituntil); } if (fRealTimeQueue.HasEvents()) { const media_timed_event *firstEvent = fRealTimeQueue.FirstEvent(); bigtime_t temp; temp = firstEvent->event_time - fSchedulingLatency; lateness = firstEvent->queued_time - temp; if (lateness > 0) { is_realtime = true; break; } if (temp < waituntil) { waituntil = temp; is_realtime = true; } } lateness = 0; // remove any extraneous value if we get this far err = WaitForMessage(waituntil); if (err == B_TIMED_OUT) break; } /// we have timed out - so handle the next event media_timed_event event; if (is_realtime) err = fRealTimeQueue.RemoveFirstEvent(&event); else err = fEventQueue.RemoveFirstEvent(&event); // printf("node %02ld handling %12Ld at %12Ld\n", ID(), event.event_time, TimeSource()->Now()); if (err == B_OK) DispatchEvent(&event, lateness, is_realtime); } }
void CSteam::OnDownloadLeaderboardEntries(LeaderboardScoresDownloaded_t *result, bool failure) { if (!failure) m_ScoreDownloaded.reset(new LeaderboardScoresDownloaded_t(*result)); DispatchEvent(RESPONSE_OnDownloadLeaderboardEntries, result->m_cEntryCount ? k_EResultOK : k_EResultFail); }
/* virtual */ void BMediaEventLooper::ControlLoop() { CALLED(); status_t err = B_OK; bigtime_t waitUntil = B_INFINITE_TIMEOUT; bool hasRealtime = false; bool hasEvent = false; // While there are no events or it is not time for the earliest event, // process messages using WaitForMessages. Whenever this funtion times out, // we need to handle the next event fSchedulingLatency = estimate_max_scheduling_latency(fControlThread); while (RunState() != B_QUITTING) { if (err == B_TIMED_OUT || err == B_WOULD_BLOCK) { // NOTE: The reference for doing the lateness calculus this way can // be found in the BeBook article "A BMediaEventLooper Example". // The value which we are going to calculate, is referred there as // 'lateness'. media_timed_event event; if (hasEvent) err = fEventQueue.RemoveFirstEvent(&event); else if (hasRealtime) err = fRealTimeQueue.RemoveFirstEvent(&event); if (err == B_OK) { // The general idea of lateness is to allow // the client code to detect when the buffer // is handled late or early. bigtime_t lateness = TimeSource()->RealTime() - waitUntil; DispatchEvent(&event, lateness, hasRealtime); } } else if (err != B_OK) return; // BMediaEventLooper compensates your performance time by adding // the event latency (see SetEventLatency()) and the scheduling // latency (or, for real-time events, only the scheduling latency). hasRealtime = fRealTimeQueue.HasEvents(); hasEvent = fEventQueue.HasEvents(); if (hasEvent) { waitUntil = TimeSource()->RealTimeFor( fEventQueue.FirstEventTime(), fEventLatency + fSchedulingLatency); } else if (!hasRealtime) waitUntil = B_INFINITE_TIMEOUT; if (hasRealtime) { bigtime_t realtimeWait = fRealTimeQueue.FirstEventTime() - fSchedulingLatency; if (!hasEvent || realtimeWait <= waitUntil) { waitUntil = realtimeWait; hasEvent = false; } else hasRealtime = false; } if (waitUntil != B_INFINITE_TIMEOUT && TimeSource()->RealTime() >= waitUntil) { err = WaitForMessage(0); } else err = WaitForMessage(waitUntil); } }
void CSteam::OnUGCDownload(RemoteStorageDownloadUGCResult_t *result, bool failure) { // TODO: needs to be a map? if (!failure) m_DownloadResults[result->m_hFile] = *result; DispatchEvent(RESPONSE_OnUGCDownload, result->m_eResult); }
void PluginManager::DispatchEvent(wxObject* sender, const wxString& eventName, LuaHostTable& arguments) { int eventId = GetEventIdByName(eventName); DispatchEvent(sender, eventId, arguments); }
void CSteam::OnPublishWorkshopFile(RemoteStoragePublishFileResult_t *result, bool failure) { if (!failure) m_PublishedFileId = result->m_nPublishedFileId; DispatchEvent(RESPONSE_OnPublishWorkshopFile, result->m_eResult); }
void VDUIBaseWindowW32::Shutdown() { DispatchEvent(this, mID, IVDUICallback::kEventDestroy, 0); SetCallback(NULL, false); VDUICustomControlW32::Shutdown(); }
void CSteam::OnFileShare(RemoteStorageFileShareResult_t *result, bool failure) { if (!failure) m_FileHandle = result->m_hFile; DispatchEvent(RESPONSE_OnFileShared, result->m_eResult); }
NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsIView* aView, nsEventStatus *aStatus) { NS_ASSERTION(!aView || static_cast<nsView*>(aView)->GetViewManager() == this, "wrong view manager"); SAMPLE_LABEL("event", "nsViewManager::DispatchEvent"); *aStatus = nsEventStatus_eIgnore; switch(aEvent->message) { case NS_SIZE: { if (aView) { // client area dimensions are set on the view nscoord width = ((nsSizeEvent*)aEvent)->windowSize->width; nscoord height = ((nsSizeEvent*)aEvent)->windowSize->height; // The root view may not be set if this is the resize associated with // window creation if (aView == mRootView) { PRInt32 p2a = AppUnitsPerDevPixel(); SetWindowDimensions(NSIntPixelsToAppUnits(width, p2a), NSIntPixelsToAppUnits(height, p2a)); *aStatus = nsEventStatus_eConsumeNoDefault; } else if (IsViewForPopup(aView)) { nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); if (pm) { pm->PopupResized(aView->GetFrame(), nsIntSize(width, height)); *aStatus = nsEventStatus_eConsumeNoDefault; } } } } break; case NS_MOVE: { // A popup's parent view is the root view for the parent window, so when // a popup moves, the popup's frame and view position must be updated // to match. if (aView && IsViewForPopup(aView)) { nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); if (pm) { pm->PopupMoved(aView->GetFrame(), aEvent->refPoint); *aStatus = nsEventStatus_eConsumeNoDefault; } } break; } case NS_DONESIZEMOVE: { if (mPresShell) { nsPresContext* presContext = mPresShell->GetPresContext(); if (presContext) { nsEventStateManager::ClearGlobalActiveContent(nsnull); } } nsIPresShell::ClearMouseCapture(nsnull); } break; case NS_XUL_CLOSE: { // if this is a popup, make a request to hide it. Note that a popuphidden // event listener may cancel the event and the popup will not be hidden. nsIWidget* widget = aView->GetWidget(); if (widget) { nsWindowType type; widget->GetWindowType(type); if (type == eWindowType_popup) { nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); if (pm) { pm->HidePopup(aView->GetFrame()); *aStatus = nsEventStatus_eConsumeNoDefault; } } } } break; case NS_WILL_PAINT: { if (!aView || !mContext) break; *aStatus = nsEventStatus_eConsumeNoDefault; nsPaintEvent *event = static_cast<nsPaintEvent*>(aEvent); NS_ASSERTION(static_cast<nsView*>(aView) == nsView::GetViewFor(event->widget), "view/widget mismatch"); // If an ancestor widget was hidden and then shown, we could // have a delayed resize to handle. for (nsViewManager *vm = this; vm; vm = vm->mRootView->GetParent() ? vm->mRootView->GetParent()->GetViewManager() : nsnull) { if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && vm->mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) { vm->FlushDelayedResize(true); vm->InvalidateView(vm->mRootView); } } // Flush things like reflows and plugin widget geometry updates by // calling WillPaint on observer presShells. nsRefPtr<nsViewManager> rootVM = RootViewManager(); if (mPresShell) { rootVM->CallWillPaintOnObservers(event->willSendDidPaint); } // Flush view widget geometry updates and invalidations. rootVM->ProcessPendingUpdates(); } break; case NS_PAINT: { if (!aView || !mContext) break; *aStatus = nsEventStatus_eConsumeNoDefault; nsPaintEvent *event = static_cast<nsPaintEvent*>(aEvent); nsView* view = static_cast<nsView*>(aView); NS_ASSERTION(view == nsView::GetViewFor(event->widget), "view/widget mismatch"); NS_ASSERTION(IsPaintingAllowed(), "shouldn't be receiving paint events while painting is " "disallowed!"); if (!event->didSendWillPaint) { // Send NS_WILL_PAINT event ourselves. nsPaintEvent willPaintEvent(true, NS_WILL_PAINT, event->widget); willPaintEvent.willSendDidPaint = event->willSendDidPaint; DispatchEvent(&willPaintEvent, view, aStatus); // Get the view pointer again since NS_WILL_PAINT might have // destroyed it during CallWillPaintOnObservers (bug 378273). view = nsView::GetViewFor(event->widget); } if (!view || event->region.IsEmpty()) break; // Paint. Refresh(view, event->region, event->willSendDidPaint); break; } case NS_DID_PAINT: { nsRefPtr<nsViewManager> rootVM = RootViewManager(); rootVM->CallDidPaintOnObserver(); break; } case NS_CREATE: case NS_DESTROY: case NS_SETZLEVEL: /* Don't pass these events through. Passing them through causes performance problems on pages with lots of views/frames @see bug 112861 */ *aStatus = nsEventStatus_eConsumeNoDefault; break; case NS_DISPLAYCHANGED: //Destroy the cached backbuffer to force a new backbuffer //be constructed with the appropriate display depth. //@see bugzilla bug 6061 *aStatus = nsEventStatus_eConsumeDoDefault; break; case NS_SYSCOLORCHANGED: { if (mPresShell) { // Hold a refcount to the presshell. The continued existence of the observer will // delay deletion of this view hierarchy should the event want to cause its // destruction in, say, some JavaScript event handler. nsCOMPtr<nsIPresShell> presShell = mPresShell; presShell->HandleEvent(aView->GetFrame(), aEvent, false, aStatus); } } break; default: { if ((NS_IS_MOUSE_EVENT(aEvent) && // Ignore mouse events that we synthesize. static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal && // Ignore mouse exit and enter (we'll get moves if the user // is really moving the mouse) since we get them when we // create and destroy widgets. aEvent->message != NS_MOUSE_EXIT && aEvent->message != NS_MOUSE_ENTER) || NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent) || aEvent->message == NS_PLUGIN_INPUT_EVENT) { gLastUserEventTime = PR_IntervalToMicroseconds(PR_IntervalNow()); } if (aEvent->message == NS_DEACTIVATE) { // if a window is deactivated, clear the mouse capture regardless // of what is capturing nsIPresShell::ClearMouseCapture(nsnull); } // Find the view whose coordinates system we're in. nsIView* view = aView; bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent); if (dispatchUsingCoordinates) { // Will dispatch using coordinates. Pretty bogus but it's consistent // with what presshell does. view = GetDisplayRootFor(view); } // If the view has no frame, look for a view that does. nsIFrame* frame = view->GetFrame(); if (!frame && (dispatchUsingCoordinates || NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) || NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) || aEvent->message == NS_PLUGIN_ACTIVATE || aEvent->message == NS_PLUGIN_FOCUS)) { while (view && !view->GetFrame()) { view = view->GetParent(); } if (view) { frame = view->GetFrame(); } } if (nsnull != frame) { // Hold a refcount to the presshell. The continued existence of the // presshell will delay deletion of this view hierarchy should the event // want to cause its destruction in, say, some JavaScript event handler. nsCOMPtr<nsIPresShell> shell = view->GetViewManager()->GetPresShell(); if (shell) { shell->HandleEvent(frame, aEvent, false, aStatus); } } break; } } return NS_OK; }
LRESULT VDUIBaseWindowW32::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { RECT r; GetWindowRect(mhwnd, &r); MapWindowPoints(mhwnd, ::GetParent(mhwnd), (LPPOINT)&r, 2); mArea.left = r.left; mArea.top = r.top; mArea.right = r.right; mArea.bottom = r.bottom; DispatchEvent(this, mID, IVDUICallback::kEventCreate, 0); DWORD dwStyle = GetWindowLong(mhwnd, GWL_STYLE); if (dwStyle & WS_THICKFRAME) { EnumResourceNames(VDGetLocalModuleHandleW32(), RT_GROUP_ICON, SetApplicationIconOnDialog, (LONG_PTR)mhwnd); } if (!(dwStyle & DS_CONTROL)) Relayout(); ExecuteAllLinks(); } return FALSE; case WM_GETMINMAXINFO: { MINMAXINFO *pmmi = (MINMAXINFO *)lParam; pmmi->ptMinTrackSize.x = mLayoutSpecs.minsize.w; pmmi->ptMinTrackSize.y = mLayoutSpecs.minsize.h; if ((mAlignX & nsVDUI::kAlignTypeMask) != nsVDUI::kFill) pmmi->ptMaxTrackSize.x = mLayoutSpecs.minsize.w; if ((mAlignY & nsVDUI::kAlignTypeMask) != nsVDUI::kFill) pmmi->ptMaxTrackSize.y = mLayoutSpecs.minsize.h; } return 0; case WM_SIZE: if (!(GetWindowLong(mhwnd, GWL_STYLE) & WS_CHILD)) { vduirect r(GetClientArea()); if (r.size() != GetArea().size()) { r.left += mInsets.left; r.top += mInsets.top; r.right -= mInsets.right; r.bottom -= mInsets.bottom; tChildren::iterator it(mChildren.begin()), itEnd(mChildren.end()); for(; it!=itEnd; ++it) { IVDUIWindow *pWin = *it; pWin->PostLayout(r); } } } return 0; case WM_CLOSE: if (DispatchEvent(this, mID, IVDUICallback::kEventClose, 0)) return 0; goto handle_cancel; case WM_NOTIFYFORMAT: return VDIsWindowsNT() ? NFR_UNICODE : NFR_ANSI; case WM_COMMAND: // special handling for commands that have have keyboard equivalents in // the dialog manager; we never assign these native IDs so it's safe to // shortcut them if (LOWORD(wParam) == IDOK) { DispatchEvent(this, 10, IVDUICallback::kEventSelect, 0); return 0; } else if (LOWORD(wParam) == IDCANCEL) { handle_cancel: if (!DispatchEvent(this, 11, IVDUICallback::kEventSelect, 0)) { if (mpModal) EndModal(-1); else Shutdown(); } return 0; } else if (!lParam) { // dispatch menu/accelerator commands DispatchEvent(this, LOWORD(wParam), IVDUICallback::kEventSelect, 0); return 0; } break; } return VDUICustomControlW32::WndProc(msg, wParam, lParam); }