Пример #1
0
// defined in nsWindowBase, called from shared module WinMouseScrollHandler.
bool
MetroWidget::DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent)
{
  WidgetGUIEvent* newEvent = nullptr;
  switch(aEvent->eventStructType) {
    case NS_WHEEL_EVENT:
    {
      WidgetWheelEvent* oldEvent = aEvent->AsWheelEvent();
      WidgetWheelEvent* wheelEvent =
        new WidgetWheelEvent(oldEvent->mFlags.mIsTrusted, oldEvent->message, oldEvent->widget);
      wheelEvent->AssignWheelEventData(*oldEvent, true);
      newEvent = static_cast<WidgetGUIEvent*>(wheelEvent);
    }
    break;
    case NS_CONTENT_COMMAND_EVENT:
    {
      WidgetContentCommandEvent* oldEvent = aEvent->AsContentCommandEvent();
      WidgetContentCommandEvent* cmdEvent =
        new WidgetContentCommandEvent(oldEvent->mFlags.mIsTrusted, oldEvent->message, oldEvent->widget);
      cmdEvent->AssignContentCommandEventData(*oldEvent, true);
      newEvent = static_cast<WidgetGUIEvent*>(cmdEvent);
    }
    break;
    default:
      MOZ_CRASH("unknown event in DispatchScrollEvent");
    break;
  }
  mEventQueue.Push(newEvent);
  nsCOMPtr<nsIRunnable> runnable =
    NS_NewRunnableMethod(this, &MetroWidget::DeliverNextScrollEvent);
  NS_DispatchToCurrentThread(runnable);
  return false;
}
Пример #2
0
bool
MetroWidget::DispatchContentCommandEvent(mozilla::WidgetGUIEvent* aEvent)
{
  WidgetContentCommandEvent* cmdEvent =
    new WidgetContentCommandEvent(aEvent->mFlags.mIsTrusted, aEvent->message, aEvent->widget);
  cmdEvent->AssignContentCommandEventData(*aEvent, true);
  mEventQueue.Push(cmdEvent);
  nsCOMPtr<nsIRunnable> runnable =
    NS_NewRunnableMethod(this, &MetroWidget::DeliverNextScrollEvent);
  NS_DispatchToCurrentThread(runnable);
  return false;
}