merge from trunk
[emacs.git] / README.xwidget
blobff060bf6b49ebe62025a1abe3ad673cc2b9c2bfa
1 -*-org-*-
2 * Xwidgets
4 This is an experimental branch to enable embedding of GTK widgets
5 inside an Emacs window. The Emacs abstraction is called an Xwidget,
6 for eXternal widget, and also in reference to the Xembed protocoll.
8 There is a demo file called xwidget-test.el which shows some of the
9 possibilities. There are some screnshots at the emacswiki.
11 Currently its possible to insert buttons, sliders, xembed widgets, and
12 webkit in the buffer. It works similar to the support for images in
13 Emacs.  Adding more types of widgets should be fairly straightforward,
14 but will require adapter code for each type.
16 A difference from images is that xwidgets live their own life. You
17 create them with an api, get a reference, and tie them to a particular
18 buffer with a display spec. 
20 Each xwidget can have several views. In MVC terms, an xwidget is the
21 model, and an xwidget-view is a view of the xwidget in a particular
22 Emacs window.
24 The xwidget code attempts to keep the visual appearance of the views
25 in sync with through an Observer pattern implementation. This is
26 necessary to support the Emacs window paradigm.
28 ** building
29 bzr co bzr+ssh://bzr.savannah.gnu.org/emacs/xwidget/
30 #or:
31 #git clone https://github.com/jave/xwidget-emacs.git
32 #the below compiler flags shouldn't be strictly necessary
33 export CFLAGS=" -g"
34 ./configure --with-xwidgets --enable-asserts --with-x-toolkit=gtk3
35 make -j4
36 gdb -ex run src/emacs
38 ** try it out
39 If you have GTK3 and gtk-webkit installed, you should be able to
40 start the embedded webkit browser now:
42 M-X xwidget-webkit-browse-url
44 If that didnt work out try the minimal demonstration instead:
46 (load-library "xwidget-test")
47 (xwidget-demo-a-button)
49 It looks unimpressive, but it's a gtk button inside an Emacs buffer!
50 *** webkit hints
51 If you got webkit working, great! Please note, though, that the
52 current support is far from a full fledged browser. My focus is on
53 delivering a component that can be used to build a full emacs based
54 browser on. Since I implement a browse-url function you can get quite
55 far just by:
57 (setq browse-url-browser-function 'xwidget-webkit-browse-url)
59 then all Emacs browser interface systems work to a degree.
60 heres stuff I use currenly
62 - m-x anything-surfraw interfaces to search engines
63 - C-o in org mode opens links inside org
64 - m-x ffap opens links anywhere in a buffer
65 - m-x gtk-lookup-symbol searches gtk docs
66 - m-x bookmark-jump
67 etc..
69 I'll add more examples as I go along.
71 However theres lots of support missing, see TODO list for
72 information. Briefly:
73 - download handling
74 - keyboard field navigation
75 - isearch
76 - history
77 - sites that use flash. I dont really care about this issue so its
78 unlikely to be fixed. Just a heads up.
80 ** Stability
81 Beginning with Summer 2011 I am now able to use Xwidget Emacs as my
82 primary Emacs. That is good for the project and the stability of the
83 code.
85 At the time of writing I have 24 hour Emacs uptime with several
86 embedded webkit browsers, Gnus, org-mode, tramp, etc. etc.
88 That said, there are still many improvements that needs to be done,
89 particularily in memory management. Expect xwidget emacs to leak
90 heavily for now.
92 ** timeline for inclusion in trunk
93 The Emacs 24 feature freeze is passed, so xwidgets won't probably be merged
94 until Emacs 25. OTOH since I now use xwidget emacs as my primary
95 emacs, I will merge from trunk much more often than in the past.
97 ** reporting bugs
98 Emacs xwidgets uses the same tracker as mainline emacs, but a
99 different package. To report a bug:
100 M-x report-xwidget-bug
103 browse bugs:
104 http://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs-xwidgets
105 ** Thanks
106 emacs-devel@gnu.org. There are very helpful people there. When I
107 started the xwidget project I had no clue about the Emacs internals. 
109 * Brief overview of how xwidgets work
110 Xwidgets work in one way like images in Emacs. You bind a display spec very
111 similar to an image display spec to buffer contents. The display engine will
112 notice the display spec and try to display the xwidget there. The display engine
113 prepares space at the right place for the xwidget and so on for free, as long as
114 we provide proper sizes and so on back to the redisplay engine.
116 ** Issues
117 The problem is that Emacs cant actually draw the widgets, as it can with
118 images. Emacs must notify GTK about where the widgets should be, and how they
119 should be clipped and so on, and this information must be given to GTK
120 synchronous with Emacs display changes. Ok, so why is that difficult then?
122 - How do we know when a widget is NOT to be drawn? The only way I found so far
123   is having a flag for each xwdiget, that is reset before a redisplay. When an
124   xwidget is encountered during display, the flag is set. After redisplay,
125   iterate all xwidgets and hide those which hasnt been displayed. 
127 - The gtk socket type for embedding external applications is desirable
128   but presents a lot of difficulties of its own. One difficulty is
129   deciding which input events to forward, and when and how to do it.
131 ** placement and clipping
132 the entire emacs frame is a gtk window. we use the fixed layout
133 manager to place xwidgets on the frame. coordinates are supplied by
134 the emacs display engine. widgets are placed inside an intermediate
135 window, called the widgetwindow. the widgetwindows are placed on the
136 emacs frame.
138 this way was chosen to simplify clipping of the widgets against emacs
139 window borders.
142 ** different strategies
143 Integrating toolkit widgets(gtk in this case) and the emacs display
144 engine is more difficult than your plain average gui application, and
145 different strategies has been tested and will continue to be tested.
147 There was a distinction between live xwidgets and
148 phantom xwidgets, previous to the change to MVC.
150 - the first aproach was to have the live xwidget on-screen, and move
151   them about. the phantoms were generated by snapshoting the live
152   xwidget. 
154 the drawback of that aproach was that the gtk toolkit is admirably
155 lazy and doesnt draw the widget if its not actualy shown, meaning that
156 the snapshots for the phantoms will show garbage.
158 - the second aproach was to use composition support. that tells gtk
159   that the widget should be drawn in an off-screen buffer and drawn on
160   screen by the application.
162 this has the primary advantage that the snapshot is always
163 available, and enables the possibility of more eye-candy like drawing
164 live and phantom widgets in different colors.
166 the drawback is that its our own responsibility to handle drawing,
167 which puts more of the display optimization burden on us.
169 this is aproach worked so-so.
171 - another aproach is to have both live and phantom widgets drawn
172   on-screen by proxy gtk objects. the live xwidget will be entirely
173   handled in an off-screen window, and the proxy objects will redirect
174   events there.
176 - combine on-screen and off-screen aproaches. maybe composition is the
177   way to go for most cases, but on-screen xembeding is the way to go
178   for particular special cases, like showing video in a
179   window. off-screen rendering and whatnot, is not efficient in that
180   particular case, and the user will simply have to accept that the
181   phantom of a video widget isnt particularily beautiful.
183 - The current and seemingly sanest aproach implements a MVC pattern.
185 ** Testing
186 ;;test like:
187 ;; cd /path/to/xwidgets-emacs-dir
188 ;; make   all&&  src/emacs -q --eval "(progn (load \"`pwd`/lisp/xwidget-test.el\") (xwidget-demo-basic))"
190 ** MVC and Xembedd
191 The MVC approach appears to be at least in principle robust for plain gtk
192 widgets. For the interesting case of gtk sockets which implements an
193 xembed host widget that allows for embedding other applications inside
194 an Emacs window, the story gets more complex.
196 The problem is that xembed is designed to plug an application window
197 inside a socket and thats it. You can't move a plug between
198 sockets. I tried numerous hacks to get around this but there is
199 nothing that works really well.
201 Therefore the Emacs part of the code will only expose well-defined
202 interfaces. cooperating applications will be able to use the interface
203 in a well defined manner. The problem is that there is no known xembeddable
204 application that implement the needed type of functionality, which is
205 allowing for creating new windows on the fly that plug into new
206 sockets.
208 Therefore I will attempt to provide an external application that wraps
209 another application and through hacks attempts to provide the needed
210 multi view xembed function. That way Emacs is sane and the insanity
211 contained.
213 This app will work by providing a socket that an app plugs into. The
214 socket window is copied efficiently by means of composition to a
215 number of other windows, that are then plugged into the different
216 Emacs sockets. 
217 ** old notes from x_draw_xwidget_glyph_string
219     BUG it seems this method for some reason is called with bad s->x and s->y sometimes.
220     When this happens the xwidget doesnt move on screen as it should.
221     This might be because of x_scroll_run. Emacs decides to scroll the screen by blitting sometimes.
222     then emacs doesnt try to actualy call the paint routines, which means this here code will never
223     run so the xwidget wont know it has been moved.
225     Solved temporarily by never optimizing in try_window_reusing_current_matrix().
227     BUG the phantoming code doesnt work very well when the live xwidget is off screen.
228     you will get weirdo display artefacts. Composition ought to solve this, since that means the live window is
229     always available in an off-screen buffer. My current attempt at composition doesnt work properly however.
231     //allocation debugging. the correct values cant be expected to show upp immediately, but eventually they should get to be ok
232     // this is because we dont know when the container gets around to do layout
233     //GtkAllocation galloc;
234     //gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc);
235     //printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height);
238 *** old notes about the old live/phantom scheme
240    //TODO:
241    // 1) always draw live xwidget in selected window
242    // (2) if there were no live instances of the xwidget in selected window, also draw it live)
243    // 3) if there was a live xwidget previously, now phantom it.
245    else
246      {
247        //ok, we are painting the xwidgets in non-selected window, so draw a phantom
248        //printf("draw phantom xwidget at:%d %d\n",x,y);
249        //xwidget_composite_draw_phantom (xw, x, y, clipx, clipy); //TODO MVC there will be very few cases of phantoming
250      }
253    atm this works as follows: only check if xwidgets are displayed in the
254    "selected window". if not, hide them or phantom them.
256    this means valid cases like xwidgets being displayed only once in
257    non-selected windows, does not work well. they should also be visible
258    in that case not phantomed.
260 * ToDo:s
261 ** TODO webkit crash
262 [2013-04-13 Sat] seems to crash a lot on http://www.dilbert.com
263 Not always, but enough to be annoying.
265 ** TODO optimize drawing off large offscreen widgets
266 Currently I just allocate as large an area as the offscreen webkit
267 widget desires. This works well most of the time. But a HTML page
268 might in principle be of infinite height so there are cases where this
269 doesn't work too well.
271 Heres a proposed strategy:
272 - never grow the offscreen webkit over xwidget-webkit-max-height
273 - allow for webkit to handle its own scrolling internally as well
274 - be more clever about when you have more than one emacs window
275   showing the same webkit instance. 
276 - allow to grow the offscreen instance in steps rather than just
277   allocate the entire height at once
279 ** DONE again a trace
280    CLOSED: [2011-10-28 Fri 13:48]
281 [2011-08-23 Tue]
282 the hunch is that since I still hand-wave the view storage the array
283 can get out of synchronous. so maybe switching to a lisp structure
284 will help as it did for the model. Anyway, doesnt happen at all often.
285 *** the trace
286 (gdb) bt
287 #0  0x0000000000685304 in xwidget_touch (xv=0x0) at xwidget.c:1225
288 #1  0x00000000006853e7 in xwidget_end_redisplay (w=0x11b42ca0, matrix=
289     0xff9bf40) at xwidget.c:1272
290 #2  0x000000000041cc31 in update_window (w=0x11b42ca0, force_p=0)
291     at dispnew.c:3705
292 #3  0x000000000041c0e5 in update_window_tree (w=0x11b42ca0, force_p=0)
293     at dispnew.c:3331
294 #4  0x000000000041be8b in update_frame (f=0x1682a50, force_p=0, 
295     inhibit_hairy_id_p=0) at dispnew.c:3258
296 #5  0x000000000045066f in redisplay_internal () at xdisp.c:12931
297 #6  0x000000000044e210 in redisplay () at xdisp.c:12110
298 #7  0x0000000000567e65 in read_char (commandflag=1, nmaps=7, maps=
299     0x7fffffffc040, prev_event=12708226, used_mouse_menu=0x7fffffffc254, 
300     end_time=0x0) at keyboard.c:2447
301 #8  0x000000000057613c in read_key_sequence (keybuf=0x7fffffffc4a0, bufsize=
302     30, prompt=12708226, dont_downcase_last=0, can_return_switch_frame=1, 
303     fix_current_buffer=1) at keyboard.c:9299
304 #9  0x0000000000565d45 in command_loop_1 () at keyboard.c:1448
305 #10 0x0000000000601008 in internal_condition_case (bfun=
306     0x565962 <command_loop_1>, handlers=12760466, hfun=0x565259 <cmd_error>)
307     at eval.c:1490
308 #11 0x0000000000565659 in command_loop_2 (ignore=12708226) at keyboard.c:1159
309 #12 0x0000000000600992 in internal_catch (tag=12873826, func=
310 ---Type <return> to continue, or q <return> to quit---
311     0x565633 <command_loop_2>, arg=12708226) at eval.c:1247
312 #13 0x00000000005655bd in command_loop () at keyboard.c:1124
313 #14 0x0000000000564da7 in recursive_edit_1 () at keyboard.c:759
314 #15 0x0000000000564f43 in Frecursive_edit () at keyboard.c:823
315 #16 0x000000000060444f in Ffuncall (nargs=1, args=0x7fffffffca20)
316     at eval.c:2986
317 #17 0x00000000006507f8 in exec_byte_code (bytestr=145172929, vector=145179445, 
318     maxdepth=116, args_template=12708226, nargs=0, args=0x0) at bytecode.c:785
319 #18 0x0000000000604eec in funcall_lambda (fun=140575909, nargs=2, arg_vector=
320     0x7fffffffcfe8) at eval.c:3220
321 #19 0x000000000060467e in Ffuncall (nargs=3, args=0x7fffffffcfe0)
322     at eval.c:3038
323 #20 0x00000000006035fc in Fapply (nargs=2, args=0x7fffffffd0b0) at eval.c:2494
324 #21 0x0000000000603b43 in apply1 (fn=12874242, arg=301666310) at eval.c:2732
325 #22 0x00000000005feb25 in call_debugger (arg=301666310) at eval.c:220
326 #23 0x0000000000601ca9 in maybe_call_debugger (conditions=9431542, sig=
327     12761282, data=301666742) at eval.c:1893
328 #24 0x0000000000601785 in Fsignal (error_symbol=12761282, data=301666742)
329     at eval.c:1714
330 #25 0x0000000000601898 in xsignal (error_symbol=12761282, data=301666742)
331     at eval.c:1749
332 #26 0x0000000000601926 in xsignal2 (error_symbol=12761282, arg1=102756373, 
333     arg2=0) at eval.c:1770
334 ---Type <return> to continue, or q <return> to quit---
335 #27 0x0000000000604d6e in funcall_lambda (fun=102756373, nargs=0, arg_vector=
336     0x7fffffffd398) at eval.c:3189
337 #28 0x000000000060467e in Ffuncall (nargs=1, args=0x7fffffffd390)
338     at eval.c:3038
339 #29 0x00000000006507f8 in exec_byte_code (bytestr=54783137, vector=109656229, 
340     maxdepth=12, args_template=12708226, nargs=0, args=0x0) at bytecode.c:785
341 #30 0x0000000000604eec in funcall_lambda (fun=109656517, nargs=0, arg_vector=
342     0x7fffffffd890) at eval.c:3220
343 #31 0x000000000060467e in Ffuncall (nargs=1, args=0x7fffffffd888)
344     at eval.c:3038
345 #32 0x0000000000603b08 in apply1 (fn=109656517, arg=12708226) at eval.c:2725
346 #33 0x00000000005fc8c9 in Fcall_interactively (function=109656517, record_flag=
347     12708226, keys=12754549) at callint.c:379
348 #34 0x00000000006044c2 in Ffuncall (nargs=4, args=0x7fffffffdc60)
349     at eval.c:2996
350 #35 0x0000000000603c57 in call3 (fn=12893554, arg1=109656517, arg2=12708226, 
351     arg3=12708226) at eval.c:2789
352 #36 0x00000000005784cd in Fcommand_execute (cmd=109656517, record_flag=
353     12708226, keys=12708226, special=12708226) at keyboard.c:10290
354 #37 0x00000000005661fb in command_loop_1 () at keyboard.c:1575
355 #38 0x0000000000601008 in internal_condition_case (bfun=
356     0x565962 <command_loop_1>, handlers=12760466, hfun=0x565259 <cmd_error>)
357     at eval.c:1490
358 ---Type <return> to continue, or q <return> to quit---
359 #39 0x0000000000565659 in command_loop_2 (ignore=12708226) at keyboard.c:1159
360 #40 0x0000000000600992 in internal_catch (tag=12756258, func=
361     0x565633 <command_loop_2>, arg=12708226) at eval.c:1247
362 #41 0x000000000056560c in command_loop () at keyboard.c:1138
363 #42 0x0000000000564da7 in recursive_edit_1 () at keyboard.c:759
364 #43 0x0000000000564f43 in Frecursive_edit () at keyboard.c:823
365 #44 0x0000000000563052 in main (argc=1, argv=0x7fffffffe678) at emacs.c:1711
367 Lisp Backtrace:
368 "recursive-edit" (0xffffca28)
369 "debug" (0xffffcfe8)
370 "image-bol" (0xffffd398)
371 0x68939c0 PVEC_COMPILED
372 "call-interactively" (0xffffdc68)
373 (gdb) 
376 ** DONE new annoying trace
377    CLOSED: [2011-08-13 Sat 16:16]
378 maybe related to scroll inhibiting or cursor inhibiting code.
379 It appears actually to be related to GLYPH_DEBUG=1. this flag is no
380 longer needed.
381 *** the trace
382 Breakpoint 1, abort () at emacs.c:383
383 383       kill (getpid (), SIGABRT);
384 Missing separate debuginfos, use: debuginfo-install hunspell-1.2.15-2.fc15.x86_64 nss-mdns-0.10-9.fc15.x86_64
385 (gdb) 
386 (gdb) 
387 (gdb) bt
388 #0  abort () at emacs.c:383
389 #1  0x0000000000418f01 in matrix_row (matrix=0xac29400, row=-1)
390     at dispnew.c:1477
391 #2  0x000000000046e113 in draw_glyphs (w=0x18235c0, x=198, row=0xa3af100, area=
392     TEXT_AREA, start=17, end=18, hl=DRAW_CURSOR, overlaps=0) at xdisp.c:22550
393 #3  0x000000000047869f in draw_phys_cursor_glyph (w=0x18235c0, row=0xa3af100, 
394     hl=DRAW_CURSOR) at xdisp.c:24882
395 #4  0x00000000005083bb in x_draw_window_cursor (w=0x18235c0, glyph_row=
396     0xa3af100, x=180, y=361, cursor_type=0, cursor_width=1, on_p=1, active_p=1)
397     at xterm.c:7440
398 #5  0x00000000004790cd in display_and_set_cursor (w=0x18235c0, on=1, hpos=17, 
399     vpos=19, x=180, y=361) at xdisp.c:25098
400 #6  0x00000000004fa31f in x_update_window_end (w=0x18235c0, cursor_on_p=1, 
401     mouse_face_overwritten_p=0) at xterm.c:644
402 #7  0x000000000041ccb9 in update_window (w=0x18235c0, force_p=0)
403     at dispnew.c:3694
404 #8  0x000000000041c165 in update_window_tree (w=0x18235c0, force_p=0)
405     at dispnew.c:3331
406 #9  0x000000000041beee in update_frame (f=0x1658460, force_p=0, 
407     inhibit_hairy_id_p=0) at dispnew.c:3258
408 #10 0x0000000000450a2e in redisplay_internal () at xdisp.c:12983
409 #11 0x000000000044e2a6 in redisplay () at xdisp.c:12099
410 #12 0x000000000056a60d in read_char (commandflag=1, nmaps=6, maps=
412 ** DONE allow xwidgets to report their size
413    CLOSED: [2011-07-19 Tue 14:26]
414 now we just hard code sizes. but webkit widgets for instance can
415 report sizes that suit the content. support that.
416 ** DONE BUG xwidget view ghosts
417    CLOSED: [2013-04-05 Fri 23:35]
418 (havent seen this in quite a while)
419 - xwidget-webkit-browse-url somewhere
420 - split window.
421 now theres 2 webkit views
422 - c-x 1
423 now theres 2 views but one is a ghost!
424 one should have been deleted when its window died but that didnt work
425 for some reason here.
427 - m-x xwidget-cleanup
429 the ghost goes away because we killed explicitly but this is just a workaround.
431 xwidget_view_delete_all_in_window(w); in delete-window-internal is not sufficient.
432 delete-other-windows-internal
433 delete_all_subwindows
434 unshow_buffer
436 Added cleanup those window configuration hook which works in practice
437 but feels kludgy.
439 *** code looks like this
441 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
442 (defun xwidget-cleanup ()
443   "Delete zombie xwidgets."
444   ;;its still pretty easy to trigger bugs with xwidgets.
445   ;;this function tries to implement a workaround
446   (interactive)
447   (xwidget-delete-zombies) ;;kill xviews who should have been deleted but stull linger
448   (redraw-display);;redraw display otherwise ghost of zombies  will remain to haunt the screen
449   )
453 ;;this is a workaround because I cant find the right place to put it in C
454 ;;seems to work well in practice though
455 (add-hook 'window-configuration-change-hook 'xwidget-cleanup)
457 *** but it ought rather to work like this
458 xwidget-delete-zombies should be called from C after window
459 configuration has changed but before redisplay. redisplay should not
460 be called.
463 ** DONE BUG annoying backtrace
464    CLOSED: [2011-07-19 Tue 14:28]
465 (this no longer seems to happen even under heavy usage. seems merging
466 from trunk helped. lots were happening in redisplay at this time in trunk.)
468 sadly happens a lot.
469 - happens even with no initialized xwidgets
470 -                    + row->glyphs[area][i].face_id
471 or similar code, so row is invalid for some reason.
472 xwidgets currently disable some redisplay opimizations so it might be
473 an actual emacs bug manifesting without optimizations.
475 *** bt 1
476       /* Compute the width of this line.  */
477       row->pixel_width = row->x;
478       for (i = 0; i < row->used[TEXT_AREA]; ++i)
479         row->pixel_width += row->glyphs[TEXT_AREA][i].pixel_width;
481 (gdb) bt
482 #0  0x000000000045c340 in compute_line_metrics (it=0x7fffffff8a20)
483     at xdisp.c:17549
484 #1  0x00000000004603da in display_line (it=0x7fffffff8a20) at xdisp.c:18792
485 #2  0x0000000000457646 in try_window (window=23403045, pos=..., flags=1)
486     at xdisp.c:15399
487 #3  0x00000000004559c9 in redisplay_window (window=23403045, just_this_one_p=0)
488     at xdisp.c:14944
489 #4  0x0000000000450247 in redisplay_window_0 (window=23403045) at xdisp.c:13152
490 #5  0x00000000005fdcd9 in internal_condition_case_1 (bfun=
491     0x450208 <redisplay_window_0>, arg=23403045, handlers=12691046, hfun=
492     0x4501d9 <redisplay_window_error>) at eval.c:1538
493 #6  0x00000000004501ba in redisplay_windows (window=23403045) at xdisp.c:13132
494 #7  0x000000000044f19c in redisplay_internal () at xdisp.c:12706
495 #8  0x000000000044f9f2 in redisplay_preserve_echo_area (from_where=7)
496     at xdisp.c:12964
497 #9  0x0000000000568525 in swallow_events (do_display=1) at keyboard.c:4197
498 #10 0x0000000000422554 in sit_for (timeout=40, reading=1, do_display=1)
499     at dispnew.c:5963
500 #11 0x000000000056512c in read_char (commandflag=1, nmaps=8, maps=
501     0x7fffffffd3f0, prev_event=12720514, used_mouse_menu=0x7fffffffd604, 
502     end_time=0x0) at keyboard.c:2689
503 #12 0x0000000000572c59 in read_key_sequence (keybuf=0x7fffffffd850, bufsize=
504     30, prompt=12720514, dont_downcase_last=0, can_return_switch_frame=1, 
505 ---Type <return> to continue, or q <return> to quit---
506     fix_current_buffer=1) at keyboard.c:9291
507 #13 0x0000000000562897 in command_loop_1 () at keyboard.c:1446
508 #14 0x00000000005fdb52 in internal_condition_case (bfun=
509     0x5624b4 <command_loop_1>, handlers=12772898, hfun=0x561dab <cmd_error>)
510     at eval.c:1493
511 #15 0x00000000005621ab in command_loop_2 (ignore=12720514) at keyboard.c:1157
512 #16 0x00000000005fd4ce in internal_catch (tag=12768770, func=
513     0x562185 <command_loop_2>, arg=12720514) at eval.c:1247
514 #17 0x000000000056215e in command_loop () at keyboard.c:1136
515 #18 0x00000000005618f9 in recursive_edit_1 () at keyboard.c:757
516 #19 0x0000000000561a95 in Frecursive_edit () at keyboard.c:821
517 #20 0x000000000055fba2 in main (argc=1, argv=0x7fffffffe188) at emacs.c:1704
520 *** bt 2
522 ** DONE Examine using XComposite rather than GTK off-screen
523   rendering. This would make xembed widgets work much better. This
524   would probably be rathter difficult, but could open up other
525   interesting possibilities for Emacs. There is an early attempt in
526   xwidget.c, but the X call to redirect to offscreen rendering fails
527   for unknown reasons.
529   the attempt was further worked on, and the xlib calls replaced with
530   gdk calls, this works better.
532   In the end I abandoned this aproach. Xwidget-osr is the new aproach.
534 ** TODO  make the keyboard event code propagation code work. 
535 There is an attempt to provide an api to send keyboard events to an
536 xwidget, but it doesnt currently work very well.
538 *** TODO try gtk event creation instead 
539 since that works fine in the webkit osr code. 
540 but, oh no, that didn't work for some reason.
541 the widgets seems to receive the event but then the embedded widgets
542 hangs.
544 http://kegel.com/gtk/button.c
546 *** TODO examine some library to synthesize events
547 xdotool
548 xte xautomation
549 crikey
550 libxdo
552 *** TODO webkit raw keyboard event escape
553 c-c tab could send a raw tab to the webkit instance.
554 ** DONE remove the special-case for when the minibuffer is
555   active.  I added some code to reduce the annoying problem display artefacts
556   when making the minibuffer the selected window. This made xwidgets in the
557   buffer go grey or black whenever one did m-x to activate the minibuffer. The
558   coded tried to handle the minibuffer as a special case. That simply wasnt a
559   good idea. Special-casing will never work properly. It is much better to spend
560   time finding solutions that work acceptably in the general case.
562 ** DONE disable emacs cursor drawing on top of an active xwidget. 
563   This ought to be rather simple and should improve the visuals a lot.
565 ** TODO  improve the xwidgets programming interface 
566 so its less of hand-waving affair. This shouldnt be too hard, but I
567   have deliberatley not spent any time on it, since getting the
568   visuals right is much harder. Anyway, I sort of think the interface
569   should be somewhat like it is, except symbols is used instead of
570   integers.
571 *** DONE use symbols for xwidget types rather than ints
572     CLOSED: [2011-06-27 Mon 12:52]
575 *** TODO better lisp based structure for xwidgets
576 the lisp interface woud be like this:
577 - make-xwidget returns an xwidget object, similar to a process
578   object. this object is used when creating the display spec(instead of
579   the user defined id now used)
581 the data structure would be something like this:
582 - a "process" like aproach to create the xwidgets. xwidgets are
583   coupled to buffers, somewhat like processes, except a buffer can
584   hold several xwidgets
585 - an xwidget has a plist to hold the model, like a process
586 - an xwidget has an assoc list of xwidget views
588 there are some things that arent clear:
589 - an xwidget doesnt necessarily need to be coupled to a buffer but it
590   seems to be the clearest model. xwidgets would be buffer local
591 - xwidget-views are by necessity coupled to a emacs window so it might
592   be better to store them window locally rather than in an assoc
593   coupled to the xwidget model
594 - for some gtk widgets that resist an mvc approach, like the webkit
595   widgets, special operations are needed, similar to the old phantom
596   widgets aproach. so we need to differentiate live and phantom
597   instances for these troublesome widgets and let lisp manage all the trickery.
599 stuff that needs to work:
600 - do something for all views of a xwidget(resize, value change)
601 - do something for all xw-views in an emacs window(deletion etc)
602 - lookup xw-view for xwidget in emacs window(during redisplay)
603 (- do something for all siblings of a xw-view. not atm)
605 *** DONE xwidget creation interface
606     CLOSED: [2011-07-18 Mon 01:59]
607 xwidgets are a little bit like emacs processes but also a little bit
608 like emacs images. Therefore its not perfectly obvious how to handle
609 creation. Currently I just use hardcoded identifiers. the real scheme
610 needs to be something else.
612 Heres a tentative approach:
613 - xwidget-create returns a xwidget object, like process creation
614   functions. the xwidget will be largely uninitialized until
615   discovered by redisplay. an xw belongs to a buffer
616 - xwidget-insert inserts the xwidget in a buffer. when discovered by
617   redisplay it will be initialized and a xwidget-view allocated
618 - an event will be emitted when initialization is finished when
619   relevant like for sockets
621 the problem with this aproach is that its not really legal to reuse
622 xwidget objects by writing several display specs who reference the
623 same xwidget. It could presumably be done but it would just become
624 weird for no real benefit. the big preblem is that the display spec
625 decides the on-screen size, and its not sane to have xwidget views
626 with different sizes. therefore such display specs would need to be
627 catched and dissallowed. Except it is hard because AFAIK the specs
628 don't have an identity as such. A flag in the structure could be set
629 by lookup so the first display attempt would win. but then you can't
630 rewrite the spec to change the size. hmmm. A third approach would be
631 to just allow the 1st spec refering an xw during a redisplay to take
632 effect, the rest are signaled as errors. this wouldnt be too bad.
634 the other aproach would be to work more like images:
636 - write the display spec with all information needed to create the
637   xwidget.
638 - retrieve the xwidget objet from the spec with an xwidget-at-point function. It
639   can be uninitalized which client code must handle. Unlike
640   asynchronous process creation we dont get back a handle, because
641   there is none yet.
642 - emitted event on initialization, when needed. Many widgets don't
643   need this. for instance, a button sends an event when pressed. but
644   you can't press it unless its on screen, and then its initialized
645   properly. 
647 This approach seemed good, but how do I know which instance
648 generates an event if I cant set the id beforehand?
650 so, therefore, the first two aproach is used. 
653 *** DONE xwidget creation interface actually
654     CLOSED: [2011-07-18 Mon 01:59]
655 conclusion of above ramblings:
656 - should be similar to make-text-button
657 - don't init from display spec, instead during make-xwidget call
658 *** TODO callbacks would be nice 
659 but they need to be handled initially with events for technical
660 reasons. C code can't call Lisp easily. The event handler can call the
661 callback though.
663 ** TODO  more documentation
664 There should be user docs, and xwidget contributor docs. The current README
665 is all contributor docs there is now, apart from the code.
669 ** CANCELLED look into more ways of displaying xwidgets, like binding them to a
670    CLOSED: [2011-07-05 Tue 11:34]
671 window rather than a point in a buffer. This was suggested by Chidong.
672 This would be a useful addition to Emacs in itself, and would avoid nearly all 
673 display issues. I still think the general case is more interesting, but this
674 special case should also be added. The xwidget would then be bound to
675 replace the view of a particular window, and it would only show in
676 that window.
678 I got the webkit xwidget to work well enough so I dont see the need
679 for this now, except for sockets and I think it can better be dealt
680 with at the lisp level.
682 ** DONE MVC mode for xwidgets
683    CLOSED: [2011-06-27 Mon 12:53]
684 It appears unfruitful to chase using the same display mode for all
685 types of xwidgets. Composition is fun but not robust the way I
686 tried to do it.
688 Instead there should be a set of MVC xwidgets. Each on-screen instance
689 of an MVC widget would be a real GTK widget. The instances would
690 communciate state using signals. 
692 There are drawbacks. There is no inbuilt support for MVC in GTK, so we
693 have to roll our own, which is tedious if not much work for the few
694 cases.
696 MVC for xembedded application will need support from the applications
697 themselves. Inkscape supports multiple views to the same document,
698 other programs don't. In practice it might not be a big drawback.
701 *** DONE figure out what to do with the multiple frames case. 
702     CLOSED: [2011-06-27 Mon 12:52]
703 This should be easier to solve with MVC.
704 Surprisingly, this just worked!
705 *** DONE how to propagate changes in views to other views?
706     CLOSED: [2011-06-27 Mon 12:53]
707 I used gtk signals, the implementation for sliders works well!
709 ** TODO canvas support
710 heres an interesting comparision of gtk canvases
711 http://live.gnome.org/ProjectRidley/CanvasOverview
713 ATM there are small hardcoded demos in the code, these should be
714 removed and replaced with working xwgir counterparts.
715 *** goocanvas
716 goocanvas is a gtk canvas implemented using cairo. investigate.
718 pros:
719 - it has a MVC model aproach out of the box which is nice.
721 http://developer.gnome.org/goocanvas/unstable/goocanvas-model-view-canvas.html
723 export CFLAGS="`pkg-config --cflags goocanvas` -DHAVE_GOOCANVAS"
724 export LDFLAGS=`pkg-config --libs goocanvas`
725 ./configure
726 make
728 I made a hello goo world xwidget so seems doable.
729 I wanted to load a SVG which wasnt immediately straightforward, so I
730 tried clutter. but it turns out the exact same strategy could be used
731 with goocanvas.
733 *** clutter
734 maybe clutter can be used as a canvas? 
735 pros:
736 - seems to have a lot of traction atm. many examples
737 - potentialy fast and cool vector graphics
738 cons:
739 - no out of the box MVC support, but seems doable. no worse than the
740   other home brew mvc support I have in xwidgets
741 (media-explorer in an application that employes the MVC pattern)
743 http://www.openismus.com/documents/clutter_tutorial/0.9/docs/tutorial/html/sec-stage-widget.html
745 there is also cool stuff like this:
746 http://gitorious.org/webkit-clutter/webkit-clutter which is an webkit actor for
747 clutter! hmmmmm.
749 I want to render svg. aparently:
750   librsvg rsvg_handle_render_cairo(h, cr);
751   ClutterCairoTexture
752   Clutter
754 export CFLAGS="`pkg-config --cflags clutter-gtk-1.0` -DHAVE_CLUTTER"
755 export LDFLAGS=`pkg-config --libs clutter-gtk-1.0`
756 ./configure
757 make
759 compiles but I get:
760 Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in
761 the same process is not supported
763 export CFLAGS="`pkg-config --cflags clutter-gtk-0.10` -DHAVE_CLUTTER"
764 export LDFLAGS=`pkg-config --libs clutter-gtk-0.10`
765 ./configure
766 make
769 *** webkit html 5
770 expose the DOM to lisp or something. The webkit xwidget works pretty
771 well now, so this might be the way ahead.
772 ** DONE mvc code crashes after a while
773    CLOSED: [2011-07-12 Tue 18:52]
774 seemingly only when compiling with optimizations.
775 I have no idea why.
777 Doesn't seem to happen after some code cleanups.
778 ** DONE xwidget-resize-at
779    CLOSED: [2011-07-19 Tue 14:28]
780 reimplement so display spec is not involved
781 ** DONE display spec validation
782    CLOSED: [2011-07-19 Tue 14:44]
783 it is an error to reuse xwidgets in several buffers or in the same
784 buffer. how do we catch these errors? 
785 - showing the same xwidget twice in a buffer is no more wrong than
786   showing in several emacs windows, just conceptually wrong, so ignore
787   this case for now
788 - xwidgets now store a reference to the buffer they were created in,
789   so use that to invalidate xwidget references in oher buffers. but
790   thats not really an error either
791 - xwidgets should now be proper lisp objects so you dont delete them
792   you await their garbage collection. so therefore there can never be
793   invalid display specs
795 so turned out this got solved by using proper lisp objects for
796 xwidgets. yay!
798 ** DONE clipping of controllers
799    CLOSED: [2011-07-05 Tue 11:33]
801 Emacs uses a big GTK window and does its own clipping against Emacs
802 windows inside this area. So, in order to layout gtk widgets in emacs
803 windows we must clip thim ourselves. 
805 The following method worked well for a long time:
806 - make a gtk widget, say a button, xw
807 - make a clipping area, of type gtkfixed(many types have been tested)
808 - put the clip area in the main emacs gtk window
809 - figure out clip area changes during emacs redisplay
811 the only weirdness was that one has to tell gtk the clip area has a
812 window in order to get clipping. This is weird because all gtkwidgets
813 are windows in a sense and a window is almost by definition also a
814 clipping area.
816 Anyway, in GTK3 the   gtk_widget_set_has_window(GTK_WIDGET (
817 xv->widgetwindow), TRUE); call is ignored. 
819 The gtkeventbox which is documented to have its own window doesnt work
820 either.
822 http://www.lanedo.com/~carlos/gtk3-doc/chap-drawing-model.html
824 anyway clipping is rather complicated but seems to finally work okay.
826 *** DONE subclass my own clipping widget
827     CLOSED: [2011-07-04 Mon 16:55]
828 http://www.lanedo.com/~carlos/gtk3-doc/GtkWidget.html#gtk-widget-set-has-window
829 mentions that it has_window can only be called inside a widget
830 implementation.
832 this wasnt really the issue. allocation was the problem
833 *** DONE try scrolled window
834     CLOSED: [2011-07-01 Fri 10:56]
835 clipping does in fact work with
836 gtk_scrolled_window_add_with_viewport (xv->widgetwindow, xv->widget);
839 I get unwanted scrollbars in the widget though.
841   gtk_scrolled_window_set_policy      (  xv->widgetwindow,
842   GTK_POLICY_NEVER, GTK_POLICY_NEVER); 
844 stops clipping from working! 
847 *** DONE try viewport
848     CLOSED: [2011-07-01 Fri 10:56]
849 gtkviewport is used in scrolled window so in order to remove
850 scrollbars it should be possible to use viewport directly. however, 
851 viewport ignores size requests. or rather the container does.
854 *** DONE debug allocation
855     CLOSED: [2011-07-04 Mon 16:56]
856 the container determines how much size to allocate to child widgets.
858         GtkAllocation galloc;
859         gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc);
860         printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height);
862 after my clipping attemp shows that my size request is ignored! this
863 might be logical, since the container provided by emacs is a
864 gtkfixed. gtkfixed might choose to heed the widgets size desires and
865 allocate the entire widget size. but we want clipping!
867 since i cant reasonably expect to change the emacs main container, i
868 can maybe overide the setallocation method in gwfixed, and adjust
869 allocation to clipping if its an xwidget asking for allocation.
871 **** DONE subclass gtkfixed
872      CLOSED: [2011-07-04 Mon 16:56]
873 possibly i need to subclass gtkfixed and override
874 #+begin_src C
875   void                gtk_widget_size_allocate            (GtkWidget *widget,
876                                                            GtkAllocation *allocation);
877 #+end_src
878 http://developer.gnome.org/gobject/stable/howto-gobject.html
880 turns out emacs already does this for gtk3 according to jan D:
881 >>For GTK3, Emacs already subclasses GtkFixed, see emacsgtkfixed.[ch].
883 - widgets may not be underallocated, aparently
884 http://mail.gnome.org/archives/commits-list/2011-April/msg10950.html
886 - how to call base class method/chain up
887 http://developer.gnome.org/gobject/stable/howto-gobject-chainup.html
889 - the allocation modification could happen in the container or the
890   child. it feels more apropiate in the container
892 it is however unexpectedy inconvenient to modify allocation because
893 the needed data is private to the base class. to overcome this:
895  - run base class method 1st. 
896  - then, iterate all children, and modify allocation  for xwidget
897    children only. x y will then be set.
899 JanD pointed out the GTK3 port already has its own subclass, so I
900 modified that one.
902 *** DONE clip top
903     CLOSED: [2011-07-05 Tue 11:30]
904 there are four controller edges that potentialy need clipping. I begun
905 with right and bottom edges. clipping them is just a matter of setting
906 the right size of the widgetwindow and also ensure it gets the right
907 allocation from the container.
909 clipping top (and left) is not equally straightforward. I'm using a
910 viewport now and scroll it the amount that needs to be clipped.
911 however, the viewport is sensitive to changes in allocation, which
912 makes it harder to use the allocation workarounds.
914 see:
915 - gtk_widget_set_size_request
916 - gtkscrolledwindow
918 I returned to using a simple gtkfixed for the widgetwindow. with
919 allocation hack and set_has_window it works. Idea prefer not to have
920 the allocatien hack and it wasnt needed it gtk3 only gtk2. needs
921 further investigation.
923 ** various code cleanups
924 There are many cleanups necessary before any hope of inclusion in
925 Emacs trunk. To begin with, the part of the patch that touches other
926 parts of emacs must be very clean. 
927 *** DONE use FRAME_GTK_WIDGET (f)
928     CLOSED: [2011-07-20 Wed 20:02]
929 rather than gwfixed.
931 *** DONE support configure
932     CLOSED: [2011-07-12 Tue 18:48]
933 *** DONE ifdef all xwidget code
934     CLOSED: [2011-08-13 Sat 16:19]
935 so you can reliably disable the code at compiletime
936 ** DONE translate clicks 
937    CLOSED: [2011-07-03 Sun 22:12]
938 on onscreen webkit peer to offscreen
940 maybe
941 http://developer.gnome.org/gdk/stable/gdk-Windows.html#GdkWindow-from-embedder
943 turned out to be not so hard, captured events, copied them and
944 forwarded them offscreen!
946 ** CANCELLED investigate gdk_window_redirect_to_drawable
947    CLOSED: [2013-04-05 Fri 23:37]
948 (cancelled this, the current approach seems okay)
949 http://developer.gnome.org/gdk/stable/gdk-Windows.html#gdk-offscreen-window-set-embedder
950 maybe could be used in place of my own copy hacks? to work it must
951 support a chain of redirects, which seems unlikely. the benefit would
952 be that I dont have to spend time optimizing redrawing.
955 ** DONE remove xwidget_views when emacs window is deleted
956    CLOSED: [2011-07-05 Tue 11:29]
957 removing xwidget views when an Emacs window closes is not reliable.
959 - switching buffers in a window seems to hide the corresponding
960   xwidget-views properly, but they might as well be deleted.
962 -  patching delete-window-internal could be used to delete the xwidget-views
963 this seems to work
966 ** browser xwidget
967 although embedding a browser is not my primary concern many are
968 interested in this. some suitable browser component needs to be found
969 supporting gtk.
971 *** DONE webkit
972     CLOSED: [2011-07-03 Sun 22:13]
973 there is a webkit gtk port. there is no obvious mvc support.
974 http://live.gnome.org/WebKitGtk
975 http://webkitgtk.org/
977 it might be possible to keep a set of webxits in artificial
978 synchronisation by recursive deep copy of the DOM from one webkit to
979 another. This will be error prone at best though. Another way might be
980 to just use bitmap copy of the "live"instance to the "phantom"
981 instances. the problem of transfering the live view remains though.
983 export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT -g"
984 export LDFLAGS=`pkg-config --libs webkit-1.0`
985 ./configure
986 make
988 **** off screen rendering
989 export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT_OSR -g"
990 export LDFLAGS=`pkg-config --libs webkit-1.0`
991 ./configure
992 make
994 works a little bit  but i get errors like:
996 (emacs:8362): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
998 set a breakpoint in g_log, backtrace seems to indicate
999 webkitViewportAttributesRecompute is the offender. 
1001 maybe try gtk3 variants?
1002 #+begin_src sh
1003   export CFLAGS="`pkg-config --cflags webkitgtk-3.0 ` -DHAVE_WEBKIT_OSR "
1004   export LDFLAGS=`pkg-config --libs webkitgtk-3.0 `
1005   ./configure   --with-x-toolkit=gtk3
1006   make
1007 #+end_src
1008 crash in gtk_window_get_size instead. great.
1010 http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscreenwindow_8c-source.html
1012 after many attempts, the basic issue remains. for some reason the
1013 offscreen widget isnt ok when I want to snapshot it, so i simply get
1014 emptiness. the surface is only ok sometimes.
1016 here is a useful debugging snippets:
1017 #+begin_src C
1018   // debugging redraw:
1019   //  - the bg colors always change, so theres no error in signal handling
1020   //  - i get this error now and then:
1021   //(emacs:7109): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
1022   // seems to happen in webkit actually. see README
1023   
1024   if(0){ //redraw debug hack. helped a lot in fact. use the with alpha painter below also
1025     cairo_set_source_rgb(cr, osr_dbg_color, 1.0, 0.2);
1026     cairo_rectangle(cr, 0,0, xw->width, xw->height);
1027     cairo_fill(cr);
1028     osr_dbg_color+=0.1;
1029     if(osr_dbg_color>1.0)
1030       osr_dbg_color=0.0;
1031     
1032   }
1033 #+end_src
1034 you need to terminate drawing like this:
1035 #+begin_src C  
1036   //cairo_set_source_surface (cr, src_pixmap, 0,0); 
1037   //cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1039   //cairo_paint_with_alpha (cr, 1.0);
1040   //cairo_paint(cr);
1041 #+end_src
1043 the snippets change background color on oach redraw. 
1045 **** on-screen rendering to separate window
1046 an alternative might be to open a separate window and snapshot it. the
1047 idea is that whatever oddness webkit does so that offscreen rendering
1048 doesnt work, doesnt happen on-screen. the window could be opened
1049 somewhere not in the way.
1051 *** CANCELLED firefox
1052     CLOSED: [2011-07-03 Sun 22:13]
1053 http://www-archive.mozilla.org/unix/gtk-embedding.html
1054 seems to be severly bitrotted
1056 heres a newer aproach
1057 http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp
1059 while webkit clearly has the best traction as an embedded, the
1060 offscreen rendering issues makes it interesting to see what ff brings
1061 to the table. 
1063 turned out webkit has as good offscreen support as anyone, see I went
1064 with that in the end.
1067 *** DONE text field support
1068     CLOSED: [2011-07-20 Wed 20:05]
1069 Emacs captures all keyboard events so text field support isn't super
1070 straightforward. 
1072 **** propagate keyboard events
1073 I have some old hacks for this and they are not good.
1074 **** use the DOM model
1075 expose document.activeElement to lisp. This is potentially more
1076 interesting than just forwarding keyboard events.
1078 webkit_web_view_get_dom_document ()
1080 this is hard it seems. an idea might be to hack elisp support for swig
1081 to machine generate the bindings. 
1082 **** DONE inject javascript
1083      CLOSED: [2011-07-03 Sun 22:50]
1084 webkit_web_view_execute_script ()
1086 this works now:
1087 (xwidget-webkit-execute-script 5 "document.activeElement.value='test'")
1089 so it should be possible to do some interesting stuff.
1090 execute-script does however not return anything at the interface level
1091 so satisfaction is not total:
1093 http://markmail.org/message/4yowmdgras73z3x5
1095 maybe
1096 https://launchpad.net/gnome-seed
1098 or this funny hack:
1099 <jave> im trying to understand how to interact via javascript to an embedded
1100        webkit gtk instance  [23:38]
1101 <jave> i use webkit_web_view_execute_script() which is nice but doesnt return
1102        a value, by design aparently  [23:39]
1103 <jave> any hints?
1104 <lucian> jave: afaik, webkit still doesn't have full gobject bindings  [23:48]
1105 <lucian> jave: you can hack it up by making the JS modify the title, and read
1106          the title from gtk-side
1107 <jave> lucian: that was a pretty cool idea!
1110 *** webkit_web_view_load_string ()
1111 I would like preview of html in a buffer rather than from uri.
1115 *** DONE simple xwidget-webkit wrapper
1116     CLOSED: [2011-07-22 Fri 11:01]
1117 so that it could be used for actual browsing :)
1118 I dont want to reinvent too many wheels so i'd like to use existing
1119 emacs facilities here possible. use bindings similar to w3m(or info)
1121 - m-x xwidget-webkit starts a session
1122 - 'g' goes to a url
1123 - use bookmark-jump i suppose. I mostly use org for bookmarks myself
1124 - browse-url support so webkit can be the default browser
1125 - some way of getting around the quirky keyboard interaction since
1126   xwidgets dont receive keyboard events because I hawe no idea how to
1127   do that in a sane way
1129 ... and one can of course go on bikeshedding forever. lets keep it
1130 simple and extensible, and compatible with other Emacs packages.
1132 the really cool ideas would need Emacs DOM integration, which is not
1133 easy. 
1135 ** webkit related
1136 *** TODO webkit support webkit signals
1138 **** DONE particularly document-load-finished
1139      CLOSED: [2011-08-01 Mon 22:34]
1140 http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished
1141 because one might need tell set a title and sizes and things when it loads.
1142 **** TODO event bug
1143 Debugger entered--Lisp error: (error "Two bases given in one event")
1145 hapens sometimes with xwidget events. appears to be when the
1146 originating xwidget is offscreen so that the event doesn't get caught
1147 by the correct emacs event map.
1149 maybe I need to set the originating window in the event structure.
1150   event.frame_or_window = Qnil; //frame; //how to get the frame here? //TODO i store it in the xwidget now
1152 since its an offscreen xwidget the buffer local keymap isnt the right
1153 place for the handler. some global map should be used.
1155 onscreen widgets don't have the same issue.
1157 anyway, seems it'll turn out like this:
1158 - xwidget-osr stores a callback and user data
1159 - the event is an implementation detail only and get caught in the
1160   topmost event map
1161 - the event map calls the callback in the xw with the right args.
1163 we need the event handler at some level because we can't call lisp
1164 asynchronously. 
1166 **** TODO navigation signal
1167 **** TODO new window signal
1168 *** TODO console messages
1169 http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-console-message
1170 http://getfirebug.com/wiki/index.php/Console_API#console.count.28.5Btitle.5D.29
1171 because maybe we can make a simple JS REPL that way.
1172   (xwidget-webkit-execute-script ( xwidget-webkit-last-session)
1173   "console.log('hello')")
1174 prints hello to stdout but theres no way to catch stdout from webkit I
1175 think other than receiving the signal.
1177 *** TODO webkit flashkiller by default
1178 while its possible to support plugins in the webkit xwidget, flash has
1179 issues on 64 bit, and slows down emacs to a halt with off screen
1180 rendering, and of course is not free software. its in the way for real
1181 world usage even if its interesting to watch flash animations inside
1182 emacs. which should be achieved with Gnash or other free software
1183 instead.
1185 http://stackoverflow.com/questions/4885513/prevent-flash-in-cocoa-webview
1187 simply use this api:
1188 http://webkitgtk.org/reference/WebKitWebPluginDatabase.html
1190 theres an implementation now but it's not robust enough webkit often
1191 crashes taking emacs with it.
1193 *** TODO webkit downloads
1194 when clicking a download link in Webkit Emacs should take over and handle it
1195 from there. Probably need signals. There are Emacs libraries to
1196 download things, with wget etc. an url.el facility should be made.
1197 "download-requested"
1198 *** TODO webkit alt-text not handled
1199 XKCD use image-title to display a cartoon comment. These mysteriously
1200 don't work ATM. Other mouseovers work though. Maybe webkit tries to
1201 open a new window or something, which wont work.
1203 *** TODO webkit isearch in webkit buffers
1204 have a look at how docview solves it
1205 webkit_web_view_search_text ()
1206 *** TODO webkit relative references doesn't work
1207 because we handle scrolling in a non-standard way. It does
1208 work sort of when theres a html frameset and webkit scrolls by itself.
1210 internal links (page.html#section) do not work
1211 see xwidget-webkit-show-named-element
1213 also did some  webkit signal work for this.
1215 now it actually works! except for I need to know the Y coordinate of
1216 the element to navigate to, and that can either be by "name" or "id"
1217 attribute, currently "id"  works.
1221 *** TODO webkit width adjustment handling issue
1222 since there are so many levels of clipping and whatnot in xwidgets
1223 sizing issues are difficult.
1225 - an xwidget is told how large it can be by emacs. thats the end of
1226   it. if the xwidget thinks otherwise it will be clipped.
1227 - but emacs can ask the xwidget how large it wants to be. it can then
1228   resize the reserved area and inform the xwidget thusly. 
1230 That should have been enough. but webkit never reports less than what
1231 it already has. So currently a webkit view will only growth and not
1232 adjust to smaller sizes. 
1234 This is not a big problem in practice but is still annoying.
1236 to see the problem surface to http://www.slashdot.org
1237 - xwidget-webkit-adjust-size
1238 - xwidget-webkit-adjust-size-to-content
1240 and then compare by resizing in Epiphany, which is also webkit based.
1242 **** TODO try putting webkit osr inside a scrolling window
1243 it seems webkit is supposed to behave differently while embedded in a
1244 scrolling window. This is a bit cumbersome because the container stack
1245 is already deep.
1246 *** TODO xwidget webkit allow loading from string from emacs
1247 *** DONE xwidget-webkit-last-session
1248     CLOSED: [2011-08-01 Mon 22:38]
1249 was rather hurried. end result is that the lisp layer only really
1250 allows for one webkit session.
1251 *** TODO extract DOM to lisp
1252 then the SHR html renderer from Gnus could render the DOM as created
1253 by Webkit. 
1255 made a simple oxperimental DOM tree traverser. It can be expanded to
1256 return a lisp representation, LDOM.
1258 in order to bring lisp and DOM closer together the LDOM can include a
1259 mapping to the originating DOM node. so, find a node in LDOM, and the
1260 cell maps to the original DOM. but since the LDOM is a copy it can get
1261 out of sync. DOM events might help.
1262 *** DONE C-X b in other buffer from webkit
1263     CLOSED: [2011-08-12 Fri 22:20]
1264 bafflingly resets the webkit view to the top. Maybe the window
1265 reconfiguration hook code? further mystification is added because it
1266 only seems to happen with ido mode enabled.
1268 in comparison with image-mode which does the right thing, I discovered
1269 that image-mode has special code to handle scrolling. the browser mode
1270 and image mode has some similarities.
1272 I made some delegation code frrom webkit mode to image mode.
1273 *** TODO url-browse improvement
1274 sindikat: site.com and http://site.com should be equivalent (simple site.com
1275   throws error)
1277 Yes, but its unclear at what level in Emacs to do this
1278 properly. I added a url-tidy function as a start.
1280 this should be further improved:
1281 - change the call to url-tidy so its a hook
1282 - provide a couple of demonstration hooks:
1283   - url-tidy, which just prepends http://
1284   - youtube which appends &html5=1 to urls looking like http://www.youtube.com/watch?v=DZdUgjEx_dQ
1285   - history which logs all visited urls like a traditional browser
1287 *** TODO sindicat notes
1288 Here are some comments from user "sindikat" and my replies
1290 - http://ya.ru renders inadequatly (compare with any other browser) -
1291   the search text-input is way below
1293 The problem is the size communication between Emacs and Webkit. 
1295 - doing PageDown is endless; so if you do 100 PageDowns, you have to
1296   do 100 PageUps to retun to the header of the page
1298 True, I hadn't noticed. Thanks.
1300 - http://linux.org.ru (just an example) renders incorrectly too - it
1301   should stretch horizontally
1303 Size communication.
1305 - obviously, pointing of mouse over some link should change it to
1306   pointing hand cursor
1308 Need to verify with some other webkit browser.
1310 - when you are somewhere on the middle of a long page, than go to some
1311   other page, you are still in the middle, instead of being again on
1312   the top
1314 This is because I inherit from Image view mode. I kind of like it so
1315 we can add an option for it.
1318 - changing dropdown menus cause flickering
1321 - string entering is incorrect - by default it enters the title of the
1322   page, while it should be empty
1324 The cause is the lack of return value in the webkit evaluation
1325 API. Ive made some fixes.
1327 - internal links (page.html#section) do not work
1329  ive added a rudimentary function "xwidget-webkit-show-named-element" for this
1331 - maybe it's a good idea to implement Conkeror or some other
1332   keybindings, where you press 'f' then select the exact <input
1333   type="text"> where you want to enter text, without using mouse,
1334   etc.;
1336 Indeed, this would require better DOM integration.
1338 - pressing 'home' and 'end' puts nonsense into minibuffer
1340 Probably because the Image mode derivative is mostly a hack.
1341 fixed now I think.
1348 - implement search (emacs internal isearch obviously doesn't work)
1350 Either use the webkit search but that doesn't feel right. It would be
1351 better to expose the DOM and search that.
1353 - some sites intercept with keyboard; example -
1354   http://www.artlebedev.ru/kovodstvo/business-lynch/2011/10/03/ uses
1355   Ctrl+left/right/up/down to navigate between pages - this should be
1356   implemented too
1358 Keyboard integration is the unloved step-child of xwidgets, unfortunately.
1362 ** TODO xwidget image display  spec compatibility
1363 some history: the first version of the xwidget display spec was
1364 the same as an image spec. This turned out not to be fantastic because
1365 an xwidget is both like a process and like an image. it has a separate
1366 existence from display. So now the xwidget display spec is just a
1367 pointer to a xwidget. But then some useful functionality in Emacs
1368 can't be reused for xwidget, in particular image-mode.
1370 Maybe a new image type could be added that was a wraper on an
1371 xwidget. Then image mode could be reused for webkit mode. 
1373 I tried some adaptor code in xwidget.el so webkit mode now delegates
1374 to image mode but its a kludge.
1376 ** socket related
1377 *** TODO some flickering during redisplay of sockets
1378 with gtk3 an size allocation workaround is used.
1379 this seems maybe to result in flickering sizewize y-axis with the
1380 xwidget socket type. The webkit xwidget doesn't seem similarily
1381 afflicted.
1383 the size allocation workaround works by 1st running the ordinary
1384 allocation then modifying the results. its done this way to minimize
1385 the copy paste index from the base class. it might be that the
1386 original allocation has a brief time window to show itself.
1388 tried to modify the allocation hack so it doesn't call allocate
1389 twice. this doesn't seem to help flicker at all aparently so the
1390 hypothesis falls. Maybe then a socket simply doesn't like being clipped
1391 by gtkfixed. 
1393 *** TODO xwidget view reaping too agressive
1394 hide an emacs window for a while and return to it. the xwidget might
1395 get reaped and a new socket thus created.
1396 *** DONE try out OSR for sockets
1397     CLOSED: [2011-07-25 Mon 21:30]
1399 didn't work too well in the inkscape case. it might be that some other
1400 bitmap copy method works better though.
1402 basically sockets doesn't like to be offscreen because they want their
1403 own gdk window.
1405 ** DONE synchronise emacs background with xwidget color
1406    CLOSED: [2011-08-11 Thu 11:04]
1407 fine-tuning to reduce flicker.
1409 isn't needed if emacs bg erase disabled
1411 ** DONE xwidgets doesn't work during bootstrap all of a sudden
1412    CLOSED: [2011-08-01 Mon 22:33]
1413 might be some annoying local issues with my install because it is not
1414 reliably reproducible. (went away during merges)
1416 ** CANCELLED low impact xwidget based image viewer
1417    CLOSED: [2013-04-05 Fri 23:38]
1418 (cancelled this because it no longer seems like a good idea)
1419 for instance to render SVG using webkit, or some other canvas.
1420 that way it would be possible to merge to trunk in stages.
1422 so, webkit could be used to display the SVG. the display spec for
1423 images would be used. multiple webkits would be used rather than
1424 offscreen rendering, so it would be GTK2 compatible. 
1425 ** DONE xwidget movement doesn't work all of a sudden
1426    CLOSED: [2011-08-11 Thu 11:03]
1427 this used to work great. now it doesn't.
1429 suspects:
1430 - XCopyArea
1431   - x_shift_glyphs_for_insert
1432   - x_scroll_run. this is run by the try_window* functions, and
1433     inhibiting them doesnt help. but also callid in scrolling_window.
1434   
1436 - try_window_reusing_current_matrix
1437 - I used to enable GLYPH_DEBUG which I currently don't. it disables
1438   many optimisations. this was fixed.
1439 - lookup_xwidget then produce_xwidget_glyph gets called always but not 
1440 x_draw_xwidget_glyph_string probably because of scroll optimization. 
1441 movement detection could possibly be moved to produce_xwidget_glyph(not)
1443 no longer helps:
1444 (setq inhibit-try-window-id t)
1445 (setq inhibit-try-window-reusing t)
1447 workaround:
1448 (run-with-timer 1 1 'redraw-display)
1450 seems to work:
1451 inhibiting scrolling_window(). and this seem to be enough to restore the
1452 old behaviour, GLYPH_DEBUG doesn't seem needed.
1455 ** DONE GLYPH_DEBUG doesn't work
1456    CLOSED: [2011-08-08 Mon 17:30]
1457 was stupid accidental line removal that was hard to spot
1458 ** TODO osc xwidget example  
1459 a couple of xwidget sliders that control a csound/supercollider song with osc.
1460 so, for that to work we need slider callbacks to work. when a slider
1461 changes send an osc message. use ocssend:
1463  oscsend localhost 7777 /sample/address iTfs 1 3.14 hello
1465 or better:
1466 http://delysid.org/emacs/osc.el
1468 sliders could be defined in csound comments or something to illustrate
1469 the point. or if real fanciness is desired parse the csound source
1470 with Semantic and provide a control buffer corresponding to the
1471 defined controls.
1475 Added: [2011-08-11 Thu 10:53]
1478 ** DONE SEB
1479    CLOSED: [2011-10-26 Wed 15:36]
1480 the SEB site does something funny so I can't insert text in
1481 fields. aparently document.activeElement.value doesn't work with framesets.
1483 seems to work using the ugly javascript in 
1484 xwidget-webkit-activeelement-js
1486 ** support downstreams
1487 http://aur.archlinux.org/packages.php?ID=53902
1488 http://gpo.zugaina.org/app-editors/emacs-xwidget/ChangeLog
1489 ** DONE the proof of concept canvas code should be disabled by default.
1490    CLOSED: [2011-10-12 Wed 23:03]
1491 ** TODO advi
1492 active dvi viewer. investigate if it could be xwidgetified.
1493 advi supports embedding inside presentations.
1494 ** cairo configuration support
1495 gtk3 brings in cairo on Fedora, but apparently not on all plattforms.
1496 pkg-config --cflags cairo
1497 ** TODO splint
1498 splint   -Demacs -DHAVE_CONFIG_H  -I. -I/home/joakim/build_myprojs/emacsnew/emacs.bzr/xwidget.mint/src -I../lib -I/home/joakim/build_myprojs/emacsnew/emacs.bzr/xwidget.mint/src/../lib   -DGSEAL_ENABLE  -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -I/usr/include/freetype2    -I/usr/include/alsa    -I/usr/include/librsvg-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/libpng12 -I/usr/include/pixman-1 -I/usr/include/freetype2    -I/usr/include/ImageMagick   -I/usr/include/libxml2   -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include   -DGSEAL_ENABLE  -I/usr/include/webkit-3.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/libsoup-2.4 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libxml2  -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -DORBIT2=1  -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -I/usr/include/freetype2   xwidget.c
1500 ** TODO 32 bit bug
1501 user reports that xwidgets segfaults  on the 32 bit Mint distribution
1502 but not the 64 bit. Mint is an Ubuntu derivative. I got some
1503 VirtualBox images to test with.
1504 ** DONE youtube 
1505    CLOSED: [2011-11-01 Tue 11:19]
1506 http://www.youtube.com/watch?v=DZdUgjEx_dQ&html5=1
1507 html5 makes it work without stupid flash plugins!
1508 ** TODO clicking on an webkit xwidgets
1509 doesn't make the window active. this leads to problems.
1510 ** DONE "g" should default to current url
1511    CLOSED: [2011-11-03 Thu 22:25]
1512 "g" runs xwidget-webkit-browse-url which gets its interactive argument
1513 from browse-url-interactive-arg. this might need a new optional argument.
1515 http://test
1516 ** TODO anything/helm support
1517 hook so anything/helm can filter browser history.
1518 ** TODO new relative url code sometimes fail
1519 http://www.dilbert.com
1520 ** TODO input field enhancements
1521 *** password field. 
1522 was straightforward
1524 *** textarea 
1525 less straightforward. I would like it to work like emacs-w3m, where a
1526 new editing buffer is opened. on c-c, the buffer is closed and the
1527 browser field updated. however, it's not immediately obvious how to
1528 store the reference to the field reliably.
1530 furthermore the current code doesn't seem to propagate linefeed
1531 properly to text areas.
1533 ** DONE bug in current navigation handler
1534    CLOSED: [2011-11-09 Wed 10:04]
1535 on www.dn.se
1536 Debugger entered--Lisp error: (args-out-of-range "http://platform.twitter.com/widgets/hub.html" 54 357)
1537   match-string(1 "http://platform.twitter.com/widgets/hub.html")
1538   xwidget-webkit-callback(48890368 navigation-policy-decision-requested)
1539   xwidget-event-handler()
1540   call-interactively(xwidget-event-handler nil nil)
1541 ** TODO how to set the name of a webkit buffer?
1542 not obvious because, the buffer isn't created immediately and there is
1543 a callback that sets the buffer name automatically
1544 ** TODO how to find next field in tab order?
1545 ** TODO unique buffer names
1546 the webkit xwidgets renames the buffer after load but not uniquely so
1547 it sometimes fails.
1548 ** TODO kill the offscreen webkit xwidgets when last view killed
1549 The offscreen xwidgets is currently kept around even if the xwidgets
1550 views are all gone. this is a general problem and it requires actions
1551 on the behalf of the application to resolve.
1553 In the case of webkit it is currently possible to get errors like these:
1555 Debugger entered--Lisp error: (error "Selecting deleted buffer")
1556   xwidget-webkit-callback(60925380 navigation-policy-decision-requested)
1557   xwidget-event-handler()
1558   call-interactively(xwidget-event-handler nil nil)
1561 because the last view is gone and the offscreen widgets is still
1562 generating events. 
1564 In the case of webkit it is okay to kill the offscreen widgets
1565 completely when the user kills the last view window because it would
1566 be unexpected by the user to see it pop up again. This is not true in
1567 the general case.
1569 ** DONE xwidgets debugging log
1570    CLOSED: [2012-01-23 Mon 14:32]
1571 currently theres a lot of debugging traces using "message" which is
1572 annoying. Instead put them in a separate trace buffer.
1573 (see xwidgetbuffer)
1574 ** TODO make garbage collect work for xwidgets
1575 when an xwidget is removed from xwidget-alist, and there are no other
1576 references(mostly views) the xwidget should be garbage collected.
1578 special finalization would go into gc_sweep()
1579 ** TODO embedding evince
1580 http://developer.gnome.org/libevview/3.2/libevview-ev-view.html
1581 would be useful for reading PDF:s and other document types.
1582 it would work the same way webkit embedding works.
1584 ** TODO support gobject introspection
1585 https://live.gnome.org/GObjectIntrospection/
1586 supporting gobject introspection would mean that more gtk widgets
1587 could be tried out with less effort, and also that the build process
1588 and runtime support would be easier. The drawbacks are small: somewhat
1589 slower execution, and difficulty in providing elisp bindings for
1590 introspection. 
1592 https://live.gnome.org/GObjectIntrospection/HowToWriteALanguageBinding
1594 http://developer.gnome.org/gi/unstable/gi-girepository.html
1595 http://developer.gnome.org/gi/unstable/gi-overview.html
1598 In order for GIR to work, it needs the namespace and class of a
1599   widget. This is used to access the typelib file, which contains the
1600   introspection data. The namespace and class is stored as a property
1601   on the lisp symbol handle used by xwidgets to identify the widget
1602   class.
1604 This snippet sets the needed :xwgir-class property, and calls the
1605 set_zoom_level method:
1607 M-x xwidget-webkit-browse-url RET www.emacswiki.org RET
1609 Then eval the following:
1611 ;;load the webkit typelib
1612 (xwgir-require-namespace "WebKit" "2.0")
1614 ;;provide the metadata needed so xwgir can work with the webkit-osr xwidget
1615 (put 'webkit-osr :xwgir-class '("WebKit" "WebView"))
1616 ;;call the method
1617 (xwgir-call-method (xwidget-at 1) "set_zoom_level" '(3.0))
1619 It's also possible to create widgets dynamically, by using
1620 introspection to call a widget constructor(from xwidget-test.el):
1623 (defun xwgir-test ()
1624   (interactive)
1625   (xwgir-require-namespace "Gtk" "3.0")
1626   (put 'color-selection :xwgir-class '("Gtk" "ColorSelection"))
1627   
1628   (xwgir-demo-a-xwgir-button)
1629   (xwgir-call-method (xwidget-at 1) "set_label" '( "xwgir set label!"))
1630   )
1632 Current limitation:
1633 - Only 0 arg constructors are supported at the moment. Since xwidgets
1634   defer construction, the args needs to be stored with the xwidget.
1636 - xwgir-call-method does indeed lisp to gobject conversion for the
1637   arguments, but only some primitive types are supported atm.
1639 - next to no argument checking. If wrong type args are used with the
1640   xwgir methods, emacs crashes.
1642 *** TODO xwgir create components with more advanced constructor
1643 so this opens up an entire new can of beans.
1645 explain by example:
1646 lets say we want to create agtkhscale on screen. its a slider.
1647 https://developer.gnome.org/gtk3/stable/GtkHScale.html
1648 we can already create buttons, so sliders shouldnt be much more
1649 advanced right? wrong.
1651 the simplest slider constructor looks like:
1652 GtkWidget *         gtk_hscale_new
1653 (GtkAdjustment *adjustment);
1655 so in order to call it, we must be able to forward arguments to the
1656 constructor. this is almost already done, but we lack the ability to
1657 pass object instances, only simple types atm.
1659 we need to be able to create GtkAdjustment 
1660 https://developer.gnome.org/gtk3/stable/GtkAdjustment.html
1662 this we can already almost do, because an xwidget is a gir object
1663 with some decorations. we also store the decorated gir object in an
1664 array, retrievable from lisp.
1666 In order for this to be usable in practice, we need some changes:
1667 - lightweight objects should be stored un-decorated. they have no
1668   need for the entire graphical machinery of xwidgets
1669 - lightweight objects should be garbage collectable, but this is the
1670   same for all the xwidget objects, and isnt really resolved atm.
1673 ** DONE investigate gdk_offscreen_window_set_embedder()
1674    CLOSED: [2013-04-06 Sat 10:45]
1675 https://developer.gnome.org/gdk/unstable/gdk-Windows.html
1677 ,----
1678 | Offscreen windows are more general than composited windows, since they
1679 | allow not only to modify the rendering of the child window onto its
1680 | parent, but also to apply coordinate transformations.
1682 | To integrate an offscreen window into a window hierarchy, one has to
1683 | call gdk_offscreen_window_set_embedder() and handle a number of
1684 | signals. The "pick-embedded-child" signal on the embedder window is
1685 | used to select an offscreen child at given coordinates, and the
1686 | "to-embedder" and "from-embedder" signals on the offscreen window are
1687 | used to translate coordinates between the embedder and the offscreen
1688 | window.
1690 | For rendering an offscreen window onto its embedder, the contents of
1691 | the offscreen window are available as a pixmap, via
1692 | gdk_offscreen_window_get_pixmap().
1693 `----
1695 okay, [2013-04-03 Wed] I finally suceeded in this approach!
1696 it was pretty  hard to make it work and currently works like this:
1697 - the on screen dravwing area is the embedder
1698 - you must implement "pick child"
1699 event forwarding is done automatically! 
1701 BUT its not really super, because it only works well with a single
1702 embedder.
1704 perhaps the strategy could be refined:
1705 - the window frame would be the embedder for all xwidgets. (but what
1706   about several frames then?)
1707 - in the from-embedder signal handler, which maps container coords to
1708   embedded widget coords, find out which xw-view i clicked on, and
1709   compute the coords.
1711 [2013-04-04 Thu] I had a strategy working for a xwgir button but not
1712 a webkit. set_embedded in the motion event handler for the xv. it
1713 even works for 2 frames! but not webkit :(
1715 [2013-04-05 Fri] it works for xwgir osr components, but not for
1716 webkit. Webkit retains the previous event forwarding system.
1718 Now it works like this:
1719 - the offscreen widget is created as before
1720 - the on-screen views also as before, painting and copying as before.
1721 - gdk_offscreen_window_set_embedder() is now used to embedd the
1722   offscreen widget in the onscreen one, upon view creation
1723 - only one widget can embedd one other. This means that the embedding
1724   widget must be switched between the onscreen ones. This is now done
1725   in the mouse motion event handler.
1727 The above approach has been tested for xwgir created buttons and seems
1728 to work. it doesnt work for webkit, so the old scheme is preserved
1729 for webkit.
1730 ** TODO investigate git-remote-bzr