GTK+ Modules and GDK



Right now, one outstanding issue with GTK+ HEAD is that there
is no way to initialize GTK+ without immediately opening a 
display ... see:

 http://bugzilla.gnome.org/show_bug.cgi?id=85705

The obvious thing to do is to parallel the GDK API and have:

 gtk_parse_args()

That does everything that gtk_init() does _except_ for 
actually opening a display.

gtk_init_check would then look like:

  if (!gtk_parse_args (argc, argv))
    return FALSE;

  if (gdk_get_default_display ())
    return TRUE;

  display = gdk_open_display (gdk_get_display_arg_name ());

  if (display)
    {
      gdk_set_default_display (display);
      return TRUE;
    }
  else
    return FALSE;

The trouble here is that modules may well assume there is an
active display connection already open when they are intialized.
But initialization occurs at the end of gtk_parse_args().

Various possible resolutions:

 A) Don't add gtk_parse_args(), require applications to 
    wait and set a default display before they initialize
    GTK+.

    This feel very ugly to me, and still doesn't really
    solve all problems because modules that want to 
    work in a multihead setup can't rely on the default
    display.

 B) Add gtk_parse_args(), let modules break. We can
    handle this fairly cleanly by changing the directory
    for module installation to $libdir/gtk-2.0/2.2.0/modules/.

    Modules are expected to be tied more closely to the
    GTK+ version than normal apps.

 C) Special case things so that when gtk_init() so when gtk_init() 
    or gtk_init_check() are called, module initialization
    happens after the display is open, but when gtk_parse_args()
    is called, it happens immediately.

    I don't particularly like this since it means that 
    old modules "sort of work", until someone uses gtk_parse_args().

 D) Defer module initialiation until after there is a default
    display; we'd notification on setting the default display
    for this to work.

    This doesn't handle modules that actaully want to do stuf
    with non-default displays.

 E) Make modules export a special entry point indicating 
    that they are "multihead aware". If they don't export
    it, then don't initializate them until a default
    display has been set up.

    (This entry point could be 'gtk_module_init2()', a cleaner
    looking way to do it would be to say that if a module exports
    gtk_module_init_display(), then the gtk_module_init()
    will be called initially, and gtk_module_init_display()
    for each display.)

Of these, I think I like E) best. Existing modules continue
to work for non-multihead apps, and are cleanly ignore
for multihead apps.

A related problem is that modules should have the ability to do
per-display setup:

 http://bugzilla.gnome.org/show_bug.cgi?id=85696

Solution E) would solve it from a module point of view, 
but we'd still have to add a hook for it in GDK.

Regards,
                                        Owen



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