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: joakim
Subject: Re: Whats the right way to add gtk components to Emacs?
Date: Sun, 03 Jul 2011 20:04:56 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Jan Djärv <address@hidden> writes:

> 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.

Sorry, this turned out to be brain damage on my side.

>
>> - 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.

Thanks for all this information!

I've implemented event forwarding now in the xwidget branch to an
offscreen webkit instance. It works supiciously well so far. I can
split a webkit view in several emacs windows, forward mouseclicks and
motion events, and damage events are received to the onscreen webkit
views. So far so good...

>       Jan D.

-- 
Joakim Verona



reply via email to

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