emacs-devel
[Top][All Lists]
Advanced

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

Re: Whats the right way to add gtk components to Emacs?


From: Jan Djärv
Subject: Re: Whats the right way to add gtk components to Emacs?
Date: Sun, 03 Jul 2011 11:08:32 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110624 Thunderbird/5.0



address@hidden skrev 2011-07-02 17.53:
I the Xwidget branch I add gtk components to the buffer. It works mostly
well. Some cases dont work too well:

- If I create a new toplevel window and add a component to it, Emacs
   crashes.

Interesting.  I guess the assumtion is that Gtk top level windows are frames.
Tooltips are a special case.

- If I make an offscreen buffer and try to catch damage events, many
   events seemingly get lost.

Emacs does some kind of trickery with X events which I suspect is the
root cause. How does this work? How do I make my more complicated
components work in this scheme?

Hard to tell, since "this scheme" is not very detailed. But here is the big picture.

In x_term_init, we first make sure no extended input events are used:

        /* Emacs can only handle core input events, so make sure
           Gtk doesn't use Xinput or Xinput2 extensions.  */
        {
          static char fix_events[] = "GDK_CORE_DEVICE_EVENTS=1";
          putenv (fix_events);
        }

Then we install an event filter:
        /* NULL window -> events for all windows go to our function */
        gdk_window_add_filter (NULL, event_handler_gdk, NULL);

All events go to that function. It in turn calls handle_one_xevent which is the big event switch. handle_one_xevent may deside that it is inappropriate to forward some events to Gtk+, so it sets flags that event_handler_gdk inspects. Some events go to Gtk+, some are dropped. The reason for dropping events is that they conflict with what Emacs does (i.e. clears/redraws windows, takes actions on property notify, and more).

All this complication is because it was desided that the big event switch should be used for Gtk+ also, i.e. keep code duplication to a minimum.

        Jan D.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]