[Lazarus] Embedding an X11 server as a component

Kostas Michalopoulos badsectoracula at gmail.com
Wed Dec 27 06:08:35 CET 2017


On Tue, Dec 26, 2017 at 10:28 PM, Mark Morgan Lloyd via Lazarus <
lazarus at lists.lazarus-ide.org> wrote:
>
> Is it possible to embed the main window of another program into a pane in
something written using Lazarus, letting the Lazarus program provide the
"furniture" functionality that's usually handled by the window manager?
>
> The scenario I'm thinking about is putting multiple instances of
something non-trivial like Wireshark into an overall "wrapper".

Yes, and funny enough i was doing just that in a reddit argument i had
today (yes i spend my Christmas arguing with strangers on internet forums
:-P).

https://i.imgur.com/YvGyUVd.png

https://i.imgur.com/Rwp86U4.png

This is something X support natively, however you need to keep some things
in mind:

1. Your "container" need to have a proper X window. Some toolkits (like
recent versions of Gtk2) will "merge" child windows unless they are
necessary (very recent versions of Gtk2 will even use client side windows
and ignore X subwindows). Other toolkits ignore X subwindows altogether.
You need to somehow (ie. read the toolkit docs) ensure you have a native
window.

2. You need to ensure the embedded window gets the input focus when
necessary. Many toolkits implement and expect the XEmbed protocol (and you
need to implement the embedder/host side of this) to handle focus, tab
traversal, etc. Some older stuff might not need that though (XEmbed was
needed because many toolkits ignore how X handles input focus and
reimplement it themselves).

3. It should go without saying, but i'm gonna say it anyway: not everything
expects or is happy being embedded. Specifically applications using
client-side decorations expect to be in control and they can have
surprising behavior when you embed them. For example i could move gedit
around in the second shot using its "title bar" since that is implemented
by gedit itself instead of relying on the window manager to do it.

4. On the other hand some applications have an explicit mode for being
embedded into others, so look into that for the application you want to
embed (and perhaps ask the developers for help).

Kostas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171227/23503de9/attachment.html>


More information about the Lazarus mailing list