Re: [Q?] Gdk event loop - GSource



Erwann Chenede <Erwann Chenede ireland sun com> writes:

> Hi,
> 
> As part of the multiple display support, I need to modify the gdk event
> to check for events on different X displays.
> 
> I was wondering if I need to add a new GSource for each new display 
> connection opened (as done in gdk/x11/gtkevents-x11.c:gdk_events_init)
> and supply it with new GSourceFuncs.

New source, yes. New GSourceFuncs, no. You'll have to extend the
GSource structure to contain a pointer to the Display - like the
way that the GSource's in GLib extend the GSource -

struct _GTimeoutSource
{
  GSource     source;
  GTimeVal    expiration;
  gint        interval;
};

GSource *
g_timeout_source_new (guint interval)
{
  GSource *source = g_source_new (&timeout_funcs, sizeof (GTimeoutSource));
  GTimeoutSource *timeout_source = (GTimeoutSource *)source;
  GTimeVal current_time;

  timeout_source->interval = interval;

  [...]
}

> Should I just do an g_source_add_poll with a new GPollFD containing 
> the new X display connection and modify the GSourceFuncs fcts :
> gdk_event_prepare, gdk_event_check and gdk_event_dispatch 
> to check for a list of display instead of on display.
> (I, personally, think this is the better solution).

I think it is cleaner to have separate sources. A GSource is supposed
to correspond to a single source of input - so it seems strange
to me to have one source that multiplexes multiple file descriptors,
calls to XPending() and so forth.

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]