|
| 1 | +From 21449a1dbe4c0ed10e5ff5270b1a69b601dd40c7 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Tue, 5 Nov 2024 16:15:53 +0000 |
| 4 | +Subject: [PATCH] add XEmbed support |
| 5 | + |
| 6 | +add a -window <ID> argument which is used as the X parent window ID, for |
| 7 | +use with things like tabbed. |
| 8 | +--- |
| 9 | + default.c | 2 ++ |
| 10 | + drivers.c | 8 ++++---- |
| 11 | + links.h | 5 +++-- |
| 12 | + main.c | 2 +- |
| 13 | + x.c | 17 ++++++++++++++--- |
| 14 | + 5 files changed, 24 insertions(+), 10 deletions(-) |
| 15 | + |
| 16 | +diff --git a/default.c b/default.c |
| 17 | +index caf7b2e..0984ac8 100644 |
| 18 | +--- a/default.c |
| 19 | ++++ b/default.c |
| 20 | +@@ -2089,6 +2089,7 @@ int force_g = 0; |
| 21 | + unsigned char ggr_drv[MAX_STR_LEN] = ""; |
| 22 | + unsigned char ggr_mode[MAX_STR_LEN] = ""; |
| 23 | + unsigned char ggr_display[MAX_STR_LEN] = ""; |
| 24 | ++unsigned char ggr_window[MAX_STR_LEN] = ""; |
| 25 | + |
| 26 | + int anonymous = 0; |
| 27 | + |
| 28 | +@@ -2237,6 +2238,7 @@ static struct option links_options[] = { |
| 29 | + {1, setstr_cmd, NULL, NULL, 0, MAX_STR_LEN, default_target, NULL, "target"}, |
| 30 | + {1, setstr_cmd, NULL, NULL, 0, MAX_STR_LEN, ggr_mode, NULL, "mode"}, |
| 31 | + {1, setstr_cmd, NULL, NULL, 0, MAX_STR_LEN, ggr_display, NULL, "display"}, |
| 32 | ++ {1, setstr_cmd, NULL, NULL, 0, MAX_STR_LEN, ggr_window, NULL, "window"}, |
| 33 | + {1, gen_cmd, num_rd, NULL, 0, MAXINT, &base_session, NULL, "base-session"}, |
| 34 | + {1, set_cmd, NULL, NULL, 0, 0, &force_html, NULL, "force-html"}, |
| 35 | + {1, dump_cmd, NULL, NULL, D_SOURCE, 0, NULL, NULL, "source"}, |
| 36 | +diff --git a/drivers.c b/drivers.c |
| 37 | +index ee86df1..429d80e 100644 |
| 38 | +--- a/drivers.c |
| 39 | ++++ b/drivers.c |
| 40 | +@@ -105,7 +105,7 @@ static unsigned char *list_graphics_drivers(void) |
| 41 | + * ukoncenim grafickeho driveru se nastavi default_driver_param podle |
| 42 | + * drv->get_driver_param. |
| 43 | + */ |
| 44 | +-static unsigned char *init_graphics_driver(struct graphics_driver *gd, unsigned char *param, unsigned char *display) |
| 45 | ++static unsigned char *init_graphics_driver(struct graphics_driver *gd, unsigned char *param, unsigned char *display, unsigned char *window) |
| 46 | + { |
| 47 | + unsigned char *r; |
| 48 | + unsigned char *p = param; |
| 49 | +@@ -113,7 +113,7 @@ static unsigned char *init_graphics_driver(struct graphics_driver *gd, unsigned |
| 50 | + if (!param || !*param) p = dp->param; |
| 51 | + gd->param = dp; |
| 52 | + drv = gd; |
| 53 | +- r = gd->init_driver(p,display); |
| 54 | ++ r = gd->init_driver(p,display,window); |
| 55 | + if (r) drv = NULL; |
| 56 | + else F = 1; |
| 57 | + return r; |
| 58 | +@@ -129,7 +129,7 @@ void add_graphics_drivers(unsigned char **s, int *l) |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | +-unsigned char *init_graphics(unsigned char *driver, unsigned char *param, unsigned char *display) |
| 63 | ++unsigned char *init_graphics(unsigned char *driver, unsigned char *param, unsigned char *display, unsigned char *window) |
| 64 | + { |
| 65 | + unsigned char *s = init_str(); |
| 66 | + int l = 0; |
| 67 | +@@ -150,7 +150,7 @@ unsigned char *init_graphics(unsigned char *driver, unsigned char *param, unsign |
| 68 | + if (!driver || !*driver || !casestrcmp((*gd)->name, driver)) { |
| 69 | + unsigned char *r; |
| 70 | + if ((!driver || !*driver) && (*gd)->flags & GD_NOAUTO) continue; |
| 71 | +- if (!(r = init_graphics_driver(*gd, param, display))) { |
| 72 | ++ if (!(r = init_graphics_driver(*gd, param, display, window))) { |
| 73 | + mem_free(s); |
| 74 | + return NULL; |
| 75 | + } |
| 76 | +diff --git a/links.h b/links.h |
| 77 | +index 3a29a08..afc2c8e 100644 |
| 78 | +--- a/links.h |
| 79 | ++++ b/links.h |
| 80 | +@@ -1920,7 +1920,7 @@ struct driver_param; |
| 81 | + |
| 82 | + struct graphics_driver { |
| 83 | + unsigned char *name; |
| 84 | +- unsigned char *(*init_driver)(unsigned char *param, unsigned char *display); /* param is get from get_driver_param and saved into configure file */ |
| 85 | ++ unsigned char *(*init_driver)(unsigned char *param, unsigned char *display, unsigned char *window); /* param is get from get_driver_param and saved into configure file */ |
| 86 | + |
| 87 | + /* Creates new device and returns pointer to it */ |
| 88 | + struct graphics_device *(*init_device)(void); |
| 89 | +@@ -2074,7 +2074,7 @@ extern struct graphics_driver *drv; |
| 90 | + if (y1 >= y2) return; \ |
| 91 | + |
| 92 | + void add_graphics_drivers(unsigned char **s, int *l); |
| 93 | +-unsigned char *init_graphics(unsigned char *, unsigned char *, unsigned char *); |
| 94 | ++unsigned char *init_graphics(unsigned char *, unsigned char *, unsigned char *, unsigned char *); |
| 95 | + void shutdown_graphics(void); |
| 96 | + void update_driver_param(void); |
| 97 | + int g_kbd_codepage(struct graphics_driver *drv); |
| 98 | +@@ -4885,6 +4885,7 @@ extern int force_g; |
| 99 | + extern unsigned char ggr_drv[MAX_STR_LEN]; |
| 100 | + extern unsigned char ggr_mode[MAX_STR_LEN]; |
| 101 | + extern unsigned char ggr_display[MAX_STR_LEN]; |
| 102 | ++extern unsigned char ggr_window[MAX_STR_LEN]; |
| 103 | + |
| 104 | + extern unsigned char default_target[MAX_STR_LEN]; |
| 105 | + |
| 106 | +diff --git a/main.c b/main.c |
| 107 | +index bb51594..b5f500d 100644 |
| 108 | +--- a/main.c |
| 109 | ++++ b/main.c |
| 110 | +@@ -393,7 +393,7 @@ static void init(void) |
| 111 | + #ifdef G |
| 112 | + { |
| 113 | + unsigned char *r; |
| 114 | +- if ((r = init_graphics(ggr_drv, ggr_mode, ggr_display))) { |
| 115 | ++ if ((r = init_graphics(ggr_drv, ggr_mode, ggr_display, ggr_window))) { |
| 116 | + fprintf(stderr, "%s", r); |
| 117 | + mem_free(r); |
| 118 | + retval = RET_SYNTAX; |
| 119 | +diff --git a/x.c b/x.c |
| 120 | +index 2feeb03..7e8c20b 100644 |
| 121 | +--- a/x.c |
| 122 | ++++ b/x.c |
| 123 | +@@ -1597,7 +1597,7 @@ static XIC x_open_xic(Window w); |
| 124 | + #endif |
| 125 | + |
| 126 | + /* initiate connection with X server */ |
| 127 | +-static unsigned char *x_init_driver(unsigned char *param, unsigned char *display) |
| 128 | ++static unsigned char *x_init_driver(unsigned char *param, unsigned char *display, unsigned char *window) |
| 129 | + { |
| 130 | + unsigned char *err; |
| 131 | + int l; |
| 132 | +@@ -1614,7 +1614,7 @@ static unsigned char *x_init_driver(unsigned char *param, unsigned char *display |
| 133 | + #ifdef X_DEBUG |
| 134 | + { |
| 135 | + char txt[256]; |
| 136 | +- sprintf(txt,"x_init_driver(%s, %s)\n", param, display); |
| 137 | ++ sprintf(txt,"x_init_driver(%s, %s, %s)\n", param, display, window); |
| 138 | + MESSAGE(txt); |
| 139 | + } |
| 140 | + #endif |
| 141 | +@@ -1627,6 +1627,7 @@ static unsigned char *x_init_driver(unsigned char *param, unsigned char *display |
| 142 | + } |
| 143 | + #endif |
| 144 | + if (!display || !(*display)) display = NULL; |
| 145 | ++ if (!window || !(*window)) window = NULL; |
| 146 | + |
| 147 | + /* |
| 148 | + X documentation says on XOpenDisplay(display_name) : |
| 149 | +@@ -1672,9 +1673,15 @@ static unsigned char *x_init_driver(unsigned char *param, unsigned char *display |
| 150 | + x_screen = DefaultScreen(x_display); |
| 151 | + x_display_height = DisplayHeight(x_display, x_screen); |
| 152 | + x_display_width = DisplayWidth(x_display, x_screen); |
| 153 | +- x_root_window = RootWindow(x_display, x_screen); |
| 154 | + x_default_colormap = XDefaultColormap(x_display, x_screen); |
| 155 | + |
| 156 | ++ if (window) { |
| 157 | ++ x_root_window = strtol(window, NULL, 0); |
| 158 | ++ } else { |
| 159 | ++ x_root_window = RootWindow(x_display, x_screen); |
| 160 | ++ } |
| 161 | ++ |
| 162 | ++ |
| 163 | + x_default_window_width = x_display_width; |
| 164 | + if (x_default_window_width >= 100) |
| 165 | + x_default_window_width -= 50; |
| 166 | +@@ -1888,6 +1895,9 @@ visual_found: |
| 167 | + skip_wm_name: |
| 168 | + #endif |
| 169 | + |
| 170 | ++ if (window) { |
| 171 | ++ fake_window = x_root_window; |
| 172 | ++ } else { |
| 173 | + fake_window = XCreateWindow( |
| 174 | + x_display, |
| 175 | + x_root_window, |
| 176 | +@@ -1904,6 +1914,7 @@ skip_wm_name: |
| 177 | + ); |
| 178 | + |
| 179 | + fake_window_initialized = 1; |
| 180 | ++ } |
| 181 | + |
| 182 | + x_normal_gc = XCreateGC(x_display, fake_window, GCFillStyle|GCBackground, &gcv); |
| 183 | + if (!x_normal_gc) { |
| 184 | +-- |
| 185 | +2.47.0 |
| 186 | + |
0 commit comments