emacs part and QXEmbed

Bernd Gehrmann bernd at physik.hu-berlin.de
Sun Sep 16 09:34:59 UTC 2001

On Sat, 15 Sep 2001, Marcus Gruendler wrote:
> Whenever a document is opened, emacs starts up and when it gets embedded into 
> the qxembed widget it disappears and no emacs is visible anymore. Why? 

As you not saying what you did, that's hard to tell...

One way to use it is to run emacs with a specific caption and listen
for a window with that caption to appear on the screen. Then you can
find out its window id and embed that. In order to avoid flicker, you
create the window outside of the screen. The following code snippet
works with kwin:

XEmacs::XEmacs(QWidget *parent, const char *name)
    : QXEmbed(parent, name)
    kwm = new KWinModule(this);
    connect( kwm, SIGNAL(windowAdded(WId)),
             this, SLOT(windowAdded(WId)) );

    swallowedName = KApplication::randomString(8);

    KProcess *proc = new KProcess();
    *proc << "emacs";
    *proc << "-geometry";
    *proc << "-2000-2000";
    *proc << "-title";
    *proc << swallowedName;
    delete proc;

void XEmacs::windowAdded(WId id)
    KWin::Info info = KWin::info(id);

    if (info.name == swallowedName) {
        disconnect( kwm, SIGNAL(windowAdded(WId)),
                    this, SLOT(windowAdded(WId)) );

You won't be happy with this though, because focus doesn't work.
QXEmbed use a protocol based on X client messages in order to 
guarantee that focus changes inside the composite application 
only happen on mouse press events, not already when you move the
mouse cursor. Of course, this protocol (XEMBED) requires the cooperation
of the embedded program. AFAIK, Gtk 2.0 implements it for the plug
and socket classes. So maybe once XEmacs is ported to Gtk2, you
have more luck :-) 

BTW, William Perry, the author of the Gtk XEmacs port, is also a Qt
programmer, so maybe you could ask him for help.


to unsubscribe from this list send an email to kdevelop-devel-request at kdevelop.org with the following body:
unsubscribe »your-email-address«

More information about the KDevelop-devel mailing list