diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-13 23:36:58 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-13 23:36:58 +0300 |
commit | fdb89d9b0744b98dcc8ceacd53fcdd255fbc0b1e (patch) | |
tree | 69ac2e950692f1c5b4f3b25d9b25865a15ced968 | |
parent | cc929087f90da5479152e26829e10af2c1c3b937 (diff) | |
download | sciteco-fdb89d9b0744b98dcc8ceacd53fcdd255fbc0b1e.tar.gz |
GTK: Support for Xembed protocol via --xembed
* This was surprisingly easy to implement as Gtk+ 3 already
supports it via GtkPlug.
* Allows embedding SciTECO into other Xembed-aware applications.
* Unfortunately there are very few generic Xembed hosts.
tabbed (https://tools.suckless.org/tabbed/) would be one of them.
It could be used to add tabs to SciTECO even on non-tiling window managers:
$ tabbed sciteco --xembed
* Unfortunately, it does not seem to be possible to use this feature
to let SciTECO replace the contents of a terminal window even though
many terminal emulators provide $WINDOWID.
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | src/interface-gtk/interface.c | 19 |
2 files changed, 22 insertions, 3 deletions
@@ -352,8 +352,10 @@ Features: rid of the attached console window. * On Unix/X11, it may be possible to draw the Gtk+ UI into the same window as the current terminal. - Urxvt has $WINDOWID for instance which could be automatically - passed into sciteco by wrapping it in a shell function/alias. + SciTECO now supports Xembed via the --xembed option. + Urxvt and many other terminal emulators have $WINDOWID. + But the two won't work together. Urxvt and XTerm are apparently + not real Xembed hosts. * Currently, you cannot pass UTF-8 parameters to SciTECO macros. This is not critical since we don't support Unicode anyway. Sooner or later however we should use g_win32_get_command_line(). diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index 58656b8..d8cc7cd 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -36,6 +36,10 @@ #include <gtk/gtk.h> +#ifdef GDK_WINDOWING_X11 +#include <gtk/gtkx.h> +#endif + #include <gio/gio.h> #include <Scintilla.h> @@ -173,6 +177,8 @@ static struct { teco_string_t info_current; gboolean no_csd; + gint xembed_id; + GtkWidget *info_bar_widget; GtkWidget *info_image; GtkWidget *info_type_widget; @@ -217,7 +223,13 @@ teco_interface_init(void) teco_interface.event_queue = g_queue_new(); +#ifdef GDK_WINDOWING_X11 + teco_interface.window = teco_interface.xembed_id ? gtk_plug_new(teco_interface.xembed_id) + : gtk_window_new(GTK_WINDOW_TOPLEVEL); +#else teco_interface.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); +#endif + g_signal_connect(teco_interface.window, "delete-event", G_CALLBACK(teco_interface_window_delete_cb), NULL); @@ -262,7 +274,7 @@ teco_interface_init(void) "type-label"); gtk_header_bar_pack_start(GTK_HEADER_BAR(teco_interface.info_bar_widget), teco_interface.info_type_widget); - if (teco_interface.no_csd) { + if (teco_interface.xembed_id || teco_interface.no_csd) { /* fall back to adding the info bar as an ordinary widget */ gtk_box_pack_start(GTK_BOX(vbox), teco_interface.info_bar_widget, FALSE, FALSE, 0); @@ -369,6 +381,11 @@ teco_interface_get_options(void) {"no-csd", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &teco_interface.no_csd, "Disable client-side decorations.", NULL}, +#ifdef GDK_WINDOWING_X11 + {"xembed", 0, G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_INT, &teco_interface.xembed_id, + "Embed into an existing X11 Window.", "ID"}, +#endif {NULL} }; |