Beispiel #1
0
/**
 * gdk_event_put:
 * @event: a #GdkEvent.
 *
 * Appends a copy of the given event onto the front of the event
 * queue for event->any.window's display, or the default event
 * queue if event->any.window is %NULL. See gdk_display_put_event().
 **/
void
gdk_event_put (const GdkEvent *event)
{
  GdkDisplay *display;
  
  g_return_if_fail (event != NULL);

  if (event->any.window)
    display = gdk_drawable_get_display (event->any.window);
  else
    {
      GDK_NOTE (MULTIHEAD,
		g_message ("Falling back to default display for gdk_event_put()"));
      display = gdk_display_get_default ();
    }

  gdk_display_put_event (display, event);
}
Beispiel #2
0
CaptureEvents::~CaptureEvents()
{
   gdk_event_handler_set((GdkEventFunc)gtk_main_do_event, NULL, NULL);

   // put all unprocessed GDK events back in the queue
   GdkDisplay* disp = gtk_widget_get_display(wxGetRootWindow());
   size_t cnt = queue.GetCount();
   for (size_t i = 0; i < cnt; i++) {
      GdkEvent* event = (GdkEvent*)queue[i];
      // NOTE: gdk_display_put_event makes a copy of the event passed to it
      gdk_display_put_event(disp, event);
      gdk_event_free(event);
   }

#if wxUSE_LOG
   // let the logs be flashed again
   wxLog::Resume();
#endif
}
Beispiel #3
0
bool wxGUIEventLoop::YieldFor(long eventsToProcess)
{
#if wxUSE_THREADS
    if ( !wxThread::IsMain() )
    {
        // can't call gtk_main_iteration() from other threads like this
        return true;
    }
#endif // wxUSE_THREADS

    m_isInsideYield = true;
    m_eventsToProcessInsideYield = eventsToProcess;

#if wxUSE_LOG
    // disable log flushing from here because a call to wxYield() shouldn't
    // normally result in message boxes popping up &c
    wxLog::Suspend();
#endif

    // temporarily replace the global GDK event handler with our function, which
    // categorizes the events and using m_eventsToProcessInsideYield decides
    // if an event should be processed immediately or not
    // NOTE: this approach is better than using gdk_display_get_event() because
    //       gtk_main_iteration() does more than just calling gdk_display_get_event()
    //       and then call gtk_main_do_event()!
    //       In particular in this way we also process input from sources like
    //       GIOChannels (this is needed for e.g. wxGUIAppTraits::WaitForChild).
    gdk_event_handler_set ((GdkEventFunc)wxgtk_main_do_event, this, NULL);
    while (Pending())   // avoid false positives from our idle source
        gtk_main_iteration();
    gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);

    if (eventsToProcess != wxEVT_CATEGORY_CLIPBOARD)
    {
        // It's necessary to call ProcessIdle() to update the frames sizes which
        // might have been changed (it also will update other things set from
        // OnUpdateUI() which is a nice (and desired) side effect). But we
        // call ProcessIdle() only once since this is not meant for longish
        // background jobs (controlled by wxIdleEvent::RequestMore() and the
        // return value of Processidle().
        ProcessIdle();      // ProcessIdle() also calls ProcessPendingEvents()
    }
    //else: if we are inside ~wxClipboardSync() and we call ProcessIdle() and
    //      the user app contains an UI update handler which calls wxClipboard::IsSupported,
    //      then we fall into a never-ending loop...

    // put all unprocessed GDK events back in the queue
    GdkDisplay* disp = gtk_widget_get_display(wxGetRootWindow());
    for (size_t i=0; i<m_arrGdkEvents.GetCount(); i++)
    {
        GdkEvent* ev = (GdkEvent*)m_arrGdkEvents[i];

        // NOTE: gdk_display_put_event makes a copy of the event passed to it
        gdk_display_put_event(disp, ev);
        gdk_event_free(ev);
    }

    m_arrGdkEvents.Clear();

#if wxUSE_LOG
    // let the logs be flashed again
    wxLog::Resume();
#endif

    m_isInsideYield = false;

    return true;
}
Beispiel #4
0
static VALUE
rg_put_event(VALUE self, VALUE event)
{
    gdk_display_put_event(_SELF(self), RVAL2GEV(event));
    return self;
}