Beispiel #1
0
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
    // We'll send a Cancel message by default,
    // which may close the dialog.
    // Check for looping if the Cancel event handler calls Close().

    // Note that if a cancel button and handler aren't present in the dialog,
    // nothing will happen when you close the dialog via the window manager, or
    // via Close().
    // We wouldn't want to destroy the dialog by default, since the dialog may have been
    // created on the stack.
    // However, this does mean that calling dialog->Close() won't delete the dialog
    // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
    // sure to destroy the dialog.
    // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.

    static wxList closing;

    if ( closing.Member(this) )
        return;

    closing.Append(this);

    wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
    cancelEvent.SetEventObject( this );
    GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog

    closing.DeleteObject(this);
}
Beispiel #2
0
void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
    // We'll send a Cancel message by default, which may close the dialog.
    // Check for looping if the Cancel event handler calls Close().

    // Note that if a cancel button and handler aren't present in the dialog,
    // nothing will happen when you close the dialog via the window manager, or
    // via Close(). We wouldn't want to destroy the dialog by default, since
    // the dialog may have been created on the stack. However, this does mean
    // that calling dialog->Close() won't delete the dialog unless the handler
    // for wxID_CANCEL does so. So use Destroy() if you want to be sure to
    // destroy the dialog. The default OnCancel (above) simply ends a modal
    // dialog, and hides a modeless dialog.

    int idCancel = GetEscapeId();
    if ( idCancel == wxID_NONE )
        return;
    if ( idCancel == wxID_ANY )
        idCancel = wxID_CANCEL;

    // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
    //     lists here? don't dare to change it now, but should be done later!
    static wxList closing;

    if ( closing.Member(this) )
        return;

    closing.Append(this);

    wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, idCancel);
    cancelEvent.SetEventObject( this );
    GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog

    closing.DeleteObject(this);
}
// --------------------------------------------------------------
// CTmTimer::cancelRMRetryEvent
// Purpose : Cancel the RMRetry Event
// --------------------------------------------------------------
void CTmTimer::cancelRMRetryEvent()
{
   TMTIME_TRACE (2, XATM_TraceTimerExit, ("CTmTimer::cancelRMRetryEvent : ENTRY, timer event %p\n", 
      (void *) ip_RMRetry_event));

   if (ip_RMRetry_event != NULL)
      cancelEvent(ip_RMRetry_event);
} //CTmTimer::cancelRMRetryEvent
// --------------------------------------------------------------
// CTmTimer::cancelControlpointEvent
// Purpose : Cancel the Controlpoint event.  This should only be
// called in the Lead TM and only when changing the control point
// interval.
// --------------------------------------------------------------
void CTmTimer::cancelControlpointEvent()
{
   TMTIME_TRACE (2, XATM_TraceTimerExit, ("CTmTimer::cancelControlpointEvent : ENTRY, timer event %p\n", 
      (void *) ip_cp_event));

   if (ip_cp_event != NULL)
      cancelEvent(ip_cp_event);
} //CTmTimer::cancelControlpointEvent
Beispiel #5
0
void Erik::idle(Uint16 dt) {
    Player::idle(dt);
    //TODO: this is an ugly hack...
    if (!input->keyState(KEY_SP2)) {
        dense_types&=~OTYPE_MONSTER;
        if (state&STATE_RUN) cancelEvent();
    } else if (state&STATE_RUN) {
        dense_types|=OTYPE_MONSTER;
        if (state&STATE_FALL) cancelEvent();
        if ((!state&STATE_MRIGHT) && run_right) cancelEvent();
        if ((!state&STATE_MLEFT) && (!run_right)) cancelEvent();
    } else {
        //TODO: check STATE_WATER
        if (state&(STATE_MLEFT|STATE_MRIGHT)) {
            if (state&STATE_MRIGHT) run_right=true;
            else run_right=false;
            setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,(state&STATE_LEFT) ? anim_erik_run_left : anim_erik_run_right));
        }
    }
}
Beispiel #6
0
void Erik::in_right(Uint16 dt) {
    if (state&STATE_RUN) {
        if (!(state&STATE_LEFT)) event->reset();
        //changed directions, TODO: play decelerate animation
        else cancelEvent();
    } else if (input->keyState(KEY_SP2)) {
        run_right=true;
        setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,anim_erik_run_right));
    }
    Player::in_right(dt);
}
Beispiel #7
0
// By default, pressing escape cancels the dialog
void wxDialog::OnCharHook(wxKeyEvent& event)
{
    if (event.m_keyCode == WXK_ESCAPE)
    {
        // Behaviour changed in 2.0: we'll send a Cancel message
        // to the dialog instead of Close.
        wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
        cancelEvent.SetEventObject( this );
        GetEventHandler()->ProcessEvent(cancelEvent);

        return;
    }
    // We didn't process this event.
    event.Skip();
}
Beispiel #8
0
	void OnPaneClose(wxAuiManagerEvent& event)
	{
		// For now just pretend cancel was clicked. This is sufficient to fool
		// dialogmanager into closing the window it would seem
		wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
		wxWindow * pWindow = NULL;
		if (event.GetPane() && event.GetPane()->IsOk() )
			pWindow = event.GetPane()->window;
		if (pWindow && !pWindow->IsBeingDeleted())
		{
			cancelEvent.SetEventObject( pWindow );
			pWindow->GetEventHandler()->AddPendingEvent(cancelEvent);
		}
	
		event.Veto(); // Stop wxAUI doing anything about it
	}
Beispiel #9
0
void DelayedEventQueue::addEvent(std::string eventId, void (*callback)(void*, const std::string eventId), uint32_t delayMs, void* userData, bool persist) {
	if(_callbackData.find(eventId) != _callbackData.end()) {
		cancelEvent(eventId);
	}

	struct timeval delay = {delayMs / 1000, (delayMs % 1000) * 1000};
	struct event* event = event_new(_eventLoop, -1, (persist ? EV_PERSIST : 0), DelayedEventQueue::timerCallback, &_callbackData[eventId]);

	_callbackData[eventId].eventId = eventId;
	_callbackData[eventId].userData = userData;
	_callbackData[eventId].eventQueue = this;
	_callbackData[eventId].callback = callback;
	_callbackData[eventId].event = event;
	_callbackData[eventId].persist = persist;

	event_add(event, &delay);
}
Beispiel #10
0
void DelayedEventQueue::addEvent(std::string eventId, int fd, short opMask, void (*callback)(void*, const std::string eventId), void* userData, bool persist) {
	if(_callbackData.find(eventId) != _callbackData.end()) {
		cancelEvent(eventId);
	}

	if (persist)
		opMask |= EV_PERSIST;

	struct event* event = event_new(_eventLoop, fd, opMask, DelayedEventQueue::fileCallback, &_callbackData[eventId]);

	_callbackData[eventId].eventId = eventId;
	_callbackData[eventId].userData = userData;
	_callbackData[eventId].eventQueue = this;
	_callbackData[eventId].callback = callback;
	_callbackData[eventId].event = event;
	_callbackData[eventId].persist = false;

	event_add(event, NULL);

}
Beispiel #11
0
Uint16 Erik::hit(Uint16 dir, Weapon& weap) {
    if (weap.getType()==W_WATER) {
        cancelEvent();
        return health;
    } else return Player::hit(dir,weap);
}
Beispiel #12
0
void
APZEventState::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
                                 const ScrollableLayerGuid& aGuid,
                                 uint64_t aInputBlockId,
                                 nsEventStatus aApzResponse)
{
  if (aEvent.message == NS_TOUCH_START && aEvent.touches.Length() > 0) {
    mActiveElementManager->SetTargetElement(aEvent.touches[0]->GetTarget());
  }

  bool isTouchPrevented = TouchManager::gPreventMouseEvents ||
      aEvent.mFlags.mMultipleActionsPrevented;
  bool sentContentResponse = false;
  switch (aEvent.message) {
  case NS_TOUCH_START: {
    mTouchEndCancelled = false;
    if (mPendingTouchPreventedResponse) {
      // We can enter here if we get two TOUCH_STARTs in a row and didn't
      // respond to the first one. Respond to it now.
      mContentReceivedInputBlockCallback->Run(mPendingTouchPreventedGuid,
          mPendingTouchPreventedBlockId, false);
      sentContentResponse = true;
      mPendingTouchPreventedResponse = false;
    }
    if (isTouchPrevented) {
      mContentReceivedInputBlockCallback->Run(aGuid, aInputBlockId, isTouchPrevented);
      sentContentResponse = true;
    } else {
      mPendingTouchPreventedResponse = true;
      mPendingTouchPreventedGuid = aGuid;
      mPendingTouchPreventedBlockId = aInputBlockId;
    }
    break;
  }

  case NS_TOUCH_END:
    if (isTouchPrevented) {
      mTouchEndCancelled = true;
      mEndTouchIsClick = false;
    }
    // fall through
  case NS_TOUCH_CANCEL:
    mActiveElementManager->HandleTouchEndEvent(mEndTouchIsClick);
    // fall through
  case NS_TOUCH_MOVE: {
    sentContentResponse = SendPendingTouchPreventedResponse(isTouchPrevented, aGuid);
    break;
  }

  default:
    NS_WARNING("Unknown touch event type");
  }

  if (sentContentResponse &&
        aApzResponse == nsEventStatus_eConsumeDoDefault &&
        gfxPrefs::PointerEventsEnabled()) {
    WidgetTouchEvent cancelEvent(aEvent);
    cancelEvent.message = NS_TOUCH_CANCEL;
    cancelEvent.mFlags.mCancelable = false; // message != NS_TOUCH_CANCEL;
    for (uint32_t i = 0; i < cancelEvent.touches.Length(); ++i) {
      if (mozilla::dom::Touch* touch = cancelEvent.touches[i]) {
        touch->convertToPointer = true;
      }
    }
    nsEventStatus status;
    cancelEvent.widget->DispatchEvent(&cancelEvent, status);
  }
}
Beispiel #13
0
void tst_Events::cancelAllEvents()
{
    foreach (const uint &cookie, queryEvents())
        if (!cancelEvent(cookie))
            qWarning() << "Failed to cancel event";
}
void UT_CMceStateOffering::UT_CMceStateOffering_EntryL_WithOtherEventsL()
    {
    TMceIds ids;
    CMceMsgBase* msg = NULL;   
    
    // user cancel (not ready)
    iSipSession->iSubState = CMceSipSession::EOffering;
    iSipSession->PendingTransactions()[0]->iState = CSIPTransactionBase::ETrying;
    TMceStateTransitionEvent cancelEvent( *iSipSession, EMceItcCancel, ids, *msg );
    iState->EntryL( cancelEvent );
   
    MCE_ASSERT_STUBS( CMCETls::ECloseSession, //mmaction 
                      CMCETls::ENone, //mmsdpaction 
                      SipStrConsts::EEmpty, //sentMethod 
                      KErrNotFound ); //sentResponse
    
    EUNIT_ASSERT_EQUALS( 1, iSipSession->PendingTransactions().Count() );
    EUNIT_ASSERT_EQUALS( EMceItcCancel , cancelEvent.Code() );
    MCE_RESET_STUBS();

    // user cancel (ready)
    iSipSession->iSubState = CMceSipSession::EOffering;
    iSipSession->InviteTransaction()->iState = CSIPTransactionBase::EProceeding;
    TMceStateTransitionEvent cancelEvent2( *iSipSession, EMceItcCancel, ids, *msg );
    iState->EntryL( cancelEvent2 );
    
    MCE_ASSERT_STUBS( CMCETls::ECloseSession, //mmaction 
                      CMCETls::ENone, //mmsdpaction
                      SipStrConsts::ECancel, //sentMethod 
                      KErrNotFound ); //sentResponse
    
    EUNIT_ASSERT_EQUALS( 2, iSipSession->PendingTransactions().Count() )
    MCE_RESET_STUBS();

    iSipSession->iSubState = CMceSipSession::EOffering;
    TMceStateTransitionEvent updatedEvent( *iSipSession, EMceMediaUpdated );
    iState->EntryL( updatedEvent );
    
    MCE_ASSERT_STUBS( CMCETls::ENone, //mmaction 
                      CMCETls::ENone, //mmsdpaction 
                      SipStrConsts::EEmpty, //sentMethod, 
                      KErrNotFound ); //sentResponse
    
    EUNIT_ASSERT_EQUALS( 2, iSipSession->PendingTransactions().Count() )

    iSipSession->iSubState = CMceSipSession::EOffering;
    
    updatedEvent.ParamStatus() = KErrGeneral;
    iState->EntryL( updatedEvent );// NOP
    
    MCE_ASSERT_STUBS( CMCETls::ENone, //mmaction 
                      CMCETls::ENone, //mmsdpaction 
                      SipStrConsts::EEmpty, //sentMethod 
                      KErrNotFound );  //sentResponse
    
    EUNIT_ASSERT_EQUALS( 2, iSipSession->PendingTransactions().Count() )
    MCE_RESET_STUBS();

    // update and ready
    iStorage->iMediaManagerUpdateStatus = KMceReady;
    iSipSession->iSubState = CMceSipSession::EUpdating;
    iSipSession->iNewBodyCandidate = iSipSession->iBody->CloneL();
    iSipSession->iResponse = iSipSession->PendingTransactions()[0];
    MCETestHelper::SetResponseL( 
        *iSipSession->iResponse, 
        KMceSipOK, SipStrConsts::EPhraseOk, ETrue );
      
    TMceStateTransitionEvent okResponseEvent( *iSipSession, EMceResponse );
    iState->EntryL( okResponseEvent );
    
    MCE_CHECK_MEMORY_LEAVE( iStorage->iMediaManagerSdpAction != CMCETls::EDecode )
    MCE_ASSERT_STUBS( CMCETls::ECloseSession, //mmaction 
                      CMCETls::EDecode, //mmsdpaction 
                      SipStrConsts::EAck, //sentMethod 
                      KErrNotFound ); //sentResponse
    
    EUNIT_ASSERT ( iStorage->iAckSent );
    EUNIT_ASSERT_EQUALS( 2, iSipSession->PendingTransactions().Count() )
    EUNIT_ASSERT ( okResponseEvent.Code() == EMceMediaUpdated );

    // refresing with bad SDP
    iSipSession->iSubState = CMceSipSession::ERefreshing;
    MCE_RESET_STUBS();
    iSipSession->iResponse = iSipSession->PendingTransactions()[0];
    MCETestHelper::SetResponseBADL( *iSipSession->iResponse, KMceSipOK, SipStrConsts::EPhraseOk );
    
    TMceStateTransitionEvent badResponseEvent( *iSipSession, EMceResponse );
    iState->EntryL( badResponseEvent );
    
    EUNIT_ASSERT ( iStorage->iMediaManagerAction == CMCETls::ENone );
    EUNIT_ASSERT ( iStorage->iSipSentMethod == SIPStrings::StringF( SipStrConsts::EAck ) );
    EUNIT_ASSERT ( iStorage->iAckSent );
    EUNIT_ASSERT_EQUALS( 2, iSipSession->PendingTransactions().Count() )   
    }
Beispiel #15
0
void
APZEventState::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
                                 const ScrollableLayerGuid& aGuid,
                                 uint64_t aInputBlockId,
                                 nsEventStatus aApzResponse,
                                 nsEventStatus aContentResponse)
{
  if (aEvent.mMessage == eTouchStart && aEvent.mTouches.Length() > 0) {
    mActiveElementManager->SetTargetElement(aEvent.mTouches[0]->GetTarget());
    mLastTouchIdentifier = aEvent.mTouches[0]->Identifier();
  }

  bool isTouchPrevented = aContentResponse == nsEventStatus_eConsumeNoDefault;
  bool sentContentResponse = false;
  APZES_LOG("Handling event type %d\n", aEvent.mMessage);
  switch (aEvent.mMessage) {
  case eTouchStart: {
    mTouchEndCancelled = false;
    sentContentResponse = SendPendingTouchPreventedResponse(false);
    // sentContentResponse can be true here if we get two TOUCH_STARTs in a row
    // and just responded to the first one.

    // We're about to send a response back to APZ, but we should only do it
    // for events that went through APZ (which should be all of them).
    MOZ_ASSERT(aEvent.mFlags.mHandledByAPZ);

    if (isTouchPrevented) {
      mContentReceivedInputBlockCallback(aGuid, aInputBlockId, isTouchPrevented);
      sentContentResponse = true;
    } else {
      APZES_LOG("Event not prevented; pending response for %" PRIu64 " %s\n",
        aInputBlockId, Stringify(aGuid).c_str());
      mPendingTouchPreventedResponse = true;
      mPendingTouchPreventedGuid = aGuid;
      mPendingTouchPreventedBlockId = aInputBlockId;
    }
    break;
  }

  case eTouchEnd:
    if (isTouchPrevented) {
      mTouchEndCancelled = true;
      mEndTouchIsClick = false;
    }
    MOZ_FALLTHROUGH;
  case eTouchCancel:
    mActiveElementManager->HandleTouchEndEvent(mEndTouchIsClick);
    MOZ_FALLTHROUGH;
  case eTouchMove: {
    if (mPendingTouchPreventedResponse) {
      MOZ_ASSERT(aGuid == mPendingTouchPreventedGuid);
    }
    sentContentResponse = SendPendingTouchPreventedResponse(isTouchPrevented);
    break;
  }

  default:
    NS_WARNING("Unknown touch event type");
  }

  if (sentContentResponse &&
        aApzResponse == nsEventStatus_eConsumeDoDefault &&
        gfxPrefs::PointerEventsEnabled()) {
    WidgetTouchEvent cancelEvent(aEvent);
    cancelEvent.mMessage = eTouchCancel;
    cancelEvent.mFlags.mCancelable = false; // mMessage != eTouchCancel;
    for (uint32_t i = 0; i < cancelEvent.mTouches.Length(); ++i) {
      if (mozilla::dom::Touch* touch = cancelEvent.mTouches[i]) {
        touch->convertToPointer = true;
      }
    }
    nsEventStatus status;
    cancelEvent.mWidget->DispatchEvent(&cancelEvent, status);
  }
}
Beispiel #16
0
void
APZEventState::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
                                 const ScrollableLayerGuid& aGuid,
                                 uint64_t aInputBlockId,
                                 nsEventStatus aApzResponse,
                                 nsEventStatus aContentResponse)
{
  if (aEvent.mMessage == eTouchStart && aEvent.mTouches.Length() > 0) {
    mActiveElementManager->SetTargetElement(aEvent.mTouches[0]->GetTarget());
  }

  bool isTouchPrevented = aContentResponse == nsEventStatus_eConsumeNoDefault;
  bool sentContentResponse = false;
  APZES_LOG("Handling event type %d\n", aEvent.mMessage);
  switch (aEvent.mMessage) {
  case eTouchStart: {
    mTouchEndCancelled = false;
    sentContentResponse = SendPendingTouchPreventedResponse(false);
    // sentContentResponse can be true here if we get two TOUCH_STARTs in a row
    // and just responded to the first one.
    if (!aEvent.mFlags.mHandledByAPZ) {
      // This condition being true means this touchstart is synthetic and is
      // coming from TabParent.injectTouchEvent.
      // Since APZ doesn't know about it we don't want to send a response for
      // this block; we want to just skip over it from the point of view of
      // prevent-default notifications.
      APZES_LOG("Got a synthetic touch-start!\n");
      break;
    }
    if (isTouchPrevented) {
      mContentReceivedInputBlockCallback(aGuid, aInputBlockId, isTouchPrevented);
      sentContentResponse = true;
    } else {
      APZES_LOG("Event not prevented; pending response for %" PRIu64 " %s\n",
        aInputBlockId, Stringify(aGuid).c_str());
      mPendingTouchPreventedResponse = true;
      mPendingTouchPreventedGuid = aGuid;
      mPendingTouchPreventedBlockId = aInputBlockId;
    }
    break;
  }

  case eTouchEnd:
    if (isTouchPrevented) {
      mTouchEndCancelled = true;
      mEndTouchIsClick = false;
    }
    MOZ_FALLTHROUGH;
  case eTouchCancel:
    mActiveElementManager->HandleTouchEndEvent(mEndTouchIsClick);
    MOZ_FALLTHROUGH;
  case eTouchMove: {
    if (mPendingTouchPreventedResponse) {
      MOZ_ASSERT(aGuid == mPendingTouchPreventedGuid);
    }
    sentContentResponse = SendPendingTouchPreventedResponse(isTouchPrevented);
    break;
  }

  default:
    NS_WARNING("Unknown touch event type");
  }

  if (sentContentResponse &&
        aApzResponse == nsEventStatus_eConsumeDoDefault &&
        gfxPrefs::PointerEventsEnabled()) {
    WidgetTouchEvent cancelEvent(aEvent);
    cancelEvent.mMessage = eTouchCancel;
    cancelEvent.mFlags.mCancelable = false; // mMessage != eTouchCancel;
    for (uint32_t i = 0; i < cancelEvent.mTouches.Length(); ++i) {
      if (mozilla::dom::Touch* touch = cancelEvent.mTouches[i]) {
        touch->convertToPointer = true;
      }
    }
    nsEventStatus status;
    cancelEvent.widget->DispatchEvent(&cancelEvent, status);
  }
}