From: Patrick Steinhardt Date: Thu, 3 Nov 2016 13:33:38 +0000 (+0100) Subject: Allow conditional compilation of xembed X-Git-Url: https://git.owens.tech/git.owens.tech/git.owens.tech/git?a=commitdiff_plain;h=27580fadc266438b97db10a03c8d230bc95f5ed1;p=vimb.git Allow conditional compilation of xembed In order to make use of the xembed feature, we require functionality native to the X11 windowing environment to get a window's X identifier. Obviously, this requires us to compile with a Gtk+ library which has support for X, restricting us from working on Wayland-only platforms. The issue can be fixed by making the Xembed feature optional. As it is the only feature requiring platform-specific features, this neatly allows us to build for a Wayland-only platform when XEMBED is disabled. --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 1ad0105..35aebf3 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -845,7 +845,7 @@ feature and started with `--socket' option. .TP .B VIMB_XID Holds the X-Window id of the Vimb window or of the embedding window if Vimb is -started with the -e option. +compiled with XEMBED and started with the -e option. .PD .PP Example: diff --git a/src/config.def.h b/src/config.def.h index e84f347..bd0497e 100644 --- a/src/config.def.h +++ b/src/config.def.h @@ -28,6 +28,8 @@ #define FEATURE_SEARCH_HIGHLIGHT /* disable scrollbars */ #define FEATURE_NO_SCROLLBARS +/* disable X window embedding */ +/* #define FEATURE_NO_XEMBED */ /* show page title in url completions */ #define FEATURE_TITLE_IN_COMPLETION /* enable the read it later queue */ diff --git a/src/main.c b/src/main.c index e32a06a..0a6622a 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "main.h" #include "util.h" #include "command.h" @@ -358,7 +357,9 @@ gboolean vb_load_uri(const Arg *arg) /* memory allocation */ char **cmd = g_malloc_n( 3 /* basename + uri + ending NULL */ +#ifndef FEATURE_NO_XEMBED + (vb.embed ? 2 : 0) +#endif + (vb.config.file ? 2 : 0) + (vb.config.profile ? 2 : 0) + (vb.config.kioskmode ? 1 : 0) @@ -371,12 +372,14 @@ gboolean vb_load_uri(const Arg *arg) /* build commandline */ cmd[i++] = argv0; +#ifndef FEATURE_NO_XEMBED if (vb.embed) { char xid[64]; snprintf(xid, LENGTH(xid), "%u", (int)vb.embed); cmd[i++] = "-e"; cmd[i++] = xid; } +#endif if (vb.config.file) { cmd[i++] = "-c"; cmd[i++] = vb.config.file; @@ -983,6 +986,7 @@ static void set_status(const StatusType status) static void init_core(void) { Gui *gui = &vb.gui; +#ifndef FEATURE_NO_XEMBED char *xid; if (vb.embed) { @@ -1000,6 +1004,12 @@ static void init_core(void) g_setenv("VIMB_XID", xid, true); g_free(xid); +#else + gui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_role(GTK_WINDOW(gui->window), PROJECT_UCFIRST); + + gtk_widget_realize(GTK_WIDGET(gui->window)); +#endif GdkGeometry hints = {10, 10}; gtk_window_set_default_size(GTK_WINDOW(gui->window), WIN_WIDTH, WIN_HEIGHT); @@ -1823,7 +1833,9 @@ static gboolean autocmdOptionArgFunc(const gchar *option_name, const gchar *valu int main(int argc, char *argv[]) { +#ifndef FEATURE_NO_XEMBED static char *winid = NULL; +#endif static gboolean ver = false; #ifdef FEATURE_SOCKET static gboolean dump = false; @@ -1834,7 +1846,9 @@ int main(int argc, char *argv[]) {"cmd", 'C', 0, G_OPTION_ARG_CALLBACK, autocmdOptionArgFunc, "Ex command run before first page is loaded", NULL}, {"config", 'c', 0, G_OPTION_ARG_FILENAME, &vb.config.file, "Custom configuration file", NULL}, {"profile", 'p', 0, G_OPTION_ARG_STRING, &vb.config.profile, "Profile name", NULL}, +#ifndef FEATURE_NO_XEMBED {"embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "Reparents to window specified by xid", NULL}, +#endif #ifdef FEATURE_SOCKET {"dump", 'd', 0, G_OPTION_ARG_NONE, &dump, "Dump the socket path to stdout", NULL}, {"socket", 's', 0, G_OPTION_ARG_NONE, &vb.config.socket, "Create control socket", NULL}, @@ -1863,9 +1877,11 @@ int main(int argc, char *argv[]) /* save vimb basename */ argv0 = argv[0]; +#ifndef FEATURE_NO_XEMBED if (winid) { vb.embed = strtol(winid, NULL, 0); } +#endif vb.state.pid_str = g_strdup_printf("%d", (int)getpid()); g_setenv("VIMB_PID", vb.state.pid_str, true); diff --git a/src/main.h b/src/main.h index 0ba07c5..3fd761e 100644 --- a/src/main.h +++ b/src/main.h @@ -27,10 +27,12 @@ #include #include #include +#ifndef FEATURE_NO_XEMBED #ifdef HAS_GTK3 #include #include #endif +#endif #include "config.h" #ifdef FEATURE_HSTS #include "hsts.h" @@ -373,10 +375,12 @@ typedef struct { Config config; VbStyle style; SoupSession *session; +#ifndef FEATURE_NO_XEMBED #ifdef HAS_GTK3 Window embed; #else GdkNativeWindow embed; +#endif #endif GHashTable *modes; /* all available browser main modes */ } VbCore;