aboutsummaryrefslogtreecommitdiffstats
path: root/README.xwidget
diff options
context:
space:
mode:
authorJoakim Verona2011-07-23 09:34:37 +0200
committerJoakim Verona2011-07-23 09:34:37 +0200
commit37d53e76fafe8ba6732cbeb1c481a23ea5ade726 (patch)
treea604697b2525954e1a712784cf1e936a9664c1de /README.xwidget
parentde37acc4249c95bd02295f7c3a8c080297335a1d (diff)
parent043604ee51e5b5e0d0f645b999a35a1609a16b24 (diff)
downloademacs-37d53e76fafe8ba6732cbeb1c481a23ea5ade726.tar.gz
emacs-37d53e76fafe8ba6732cbeb1c481a23ea5ade726.zip
experiment send key event to xwidget. this version had som bad merges from trunk so it seems unstble
Diffstat (limited to 'README.xwidget')
-rw-r--r--README.xwidget426
1 files changed, 243 insertions, 183 deletions
diff --git a/README.xwidget b/README.xwidget
index 296be30bb6d..cee891931d2 100644
--- a/README.xwidget
+++ b/README.xwidget
@@ -41,7 +41,36 @@ If that didnt work out try the minimal demonstration instead:
41(load-library "xwidget-test") 41(load-library "xwidget-test")
42(xwidget-demo-a-button) 42(xwidget-demo-a-button)
43 43
44It looks unimpressive, but it's a gtk button inside an Emars buffer! 44It looks unimpressive, but it's a gtk button inside an Emacs buffer!
45*** webkit hints
46If you got webkit working, great! Please note, though, that the
47current support is far from a full fledged browser. My focus is on
48delivering a component that can be used to build a full emacs based
49browser on. Since I implement a browse-url function you can get quite
50far just by:
51
52(setq browse-url-browser-function 'xwidget-webkit-browse-url)
53
54then all Emacs browser interface systems work to a degree.
55heres stuff I use currenly
56
57- m-x anything-surfraw interfaces to search engines
58- C-o in org mode opens links inside org
59- m-x ffap opens links anywhere in a buffer
60- m-x gtk-lookup-symbol searches gtk docs
61- m-x bookmark-jump
62etc..
63
64I'll add more examples as I go along.
65
66However theres lots of support missing, see TODO list for
67information. Briefly:
68- download handling
69- keyboard field navigation
70- isearch
71- history
72- sites that use flash. I dont really care about this issue so its
73unlikely to be fixed. Just a heads up.
45 74
46** Stability 75** Stability
47Beginning with Summer 2011 I am now able to use Xwidget Emacs as my 76Beginning with Summer 2011 I am now able to use Xwidget Emacs as my
@@ -173,20 +202,6 @@ socket window is copied efficientlp by means of composition to a
173number of other windows, that then are plugged into the different 202number of other windows, that then are plugged into the different
174Emacs sockets. 203Emacs sockets.
175* ToDo:s 204* ToDo:s
176** DONE webkit flashkiller by default
177 CLOSED: [2011-07-19 Tue 14:27]
178while its possible to support plugins in the webkit xwidget, flash has
179issues on 64 bit, and slows down emacs to a halt with off screen
180rendering, and of course is not free software. its in the way for real
181world usage even if its interesting to watch flash animations inside
182emacs. which should be achieved with Gnash or other free software
183instead.
184
185http://stackoverflow.com/questions/4885513/prevent-flash-in-cocoa-webview
186
187simply use this api:
188http://webkitgtk.org/reference/WebKitWebPluginDatabase.html
189
190** DONE allow xwidgets to report thoir size 205** DONE allow xwidgets to report thoir size
191 CLOSED: [2011-07-19 Tue 14:26] 206 CLOSED: [2011-07-19 Tue 14:26]
192now we just hard code sizes. but webkit widgets for instance can 207now we just hard code sizes. but webkit widgets for instance can
@@ -522,171 +537,6 @@ buffer. how do we catch these errors?
522so turned out this got solved by using proper lisp objects for 537so turned out this got solved by using proper lisp objects for
523xwidgets. yay! 538xwidgets. yay!
524 539
525
526** DONE browser xwidget
527 CLOSED: [2011-07-20 Wed 20:05]
528although embedding a browser is not my primary concern many are
529interested in this. some suitable browser component needs to be found
530supporting gtk.
531
532*** DONE webkit
533 CLOSED: [2011-07-03 Sun 22:13]
534there is a webkit gtk port. there is no obvious mvc support.
535http://live.gnome.org/WebKitGtk
536http://webkitgtk.org/
537
538it might be possible to keep a set of webxits in artificial
539synchronisation by recursive deep copy of the DOM from one webkit to
540another. This will be error prone at best though. Another way might be
541to just use bitmap copy of the "live"instance to the "phantom"
542instances. the problem of transfering the live view remains though.
543
544export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT -g"
545export LDFLAGS=`pkg-config --libs webkit-1.0`
546./configure
547make
548
549**** off screen rendering
550export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT_OSR -g"
551export LDFLAGS=`pkg-config --libs webkit-1.0`
552./configure
553make
554
555works a little bit but i get errors like:
556
557(emacs:8362): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
558
559set a breakpoint in g_log, backtrace seems to indicate
560webkitViewportAttributesRecompute is the offender.
561
562maybe try gtk3 variants?
563
564export CFLAGS="`pkg-config --cflags webkitgtk-3.0 ` -DHAVE_WEBKIT_OSR "
565export LDFLAGS=`pkg-config --libs webkitgtk-3.0 `
566./configure --with-x-toolkit=gtk3
567make
568
569crash in gtk_window_get_size instead. great.
570
571http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscreenwindow_8c-source.html
572
573after many atempts, the basic issue remains. for some reason the
574offscreen widget isnt ok when I want to snapshot it, so i simply get
575emptiness. the surface is only ok someimes.
576
577here is a useful debugging snippets:
578 // debugging redraw:
579 // - the bg colors always change, so theres no error in signal handling
580 // - i get this error now and then:
581 //(emacs:7109): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
582 // seems to happen in webkit actually. see README
583
584 if(0){ //redraw debug hack. helped a lot in fact. use the with alpha painter below also
585 cairo_set_source_rgb(cr, osr_dbg_color, 1.0, 0.2);
586 cairo_rectangle(cr, 0,0, xw->width, xw->height);
587 cairo_fill(cr);
588 osr_dbg_color+=0.1;
589 if(osr_dbg_color>1.0)
590 osr_dbg_color=0.0;
591
592 }
593
594you need to terminate drawing like this:
595
596 //cairo_set_source_surface (cr, src_pixmap, 0,0);
597 //cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
598
599 //cairo_paint_with_alpha (cr, 1.0);
600 //cairo_paint(cr);
601
602the snippets change background color on oach redraw.
603
604**** on-screen rendering to separate window
605an alternative might be to open a separate window and snapshot it. the
606idea is that whatever oddness webkit does so that offscreen rendering
607doesnt work, doesnt happen on-screen. the window could be opened
608somewhere not in the way.
609
610*** CANCELLED firefox
611 CLOSED: [2011-07-03 Sun 22:13]
612http://www-archive.mozilla.org/unix/gtk-embedding.html
613seems to be severly bitrotted
614
615heres a newer aproach
616http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp
617
618while webkit clearly has the best traction as an embeddee, the
619offscreen rendering issues makes it interesting to see what ff brings
620to the table. turns out webkit has as good offscreen support as anyone.
621
622
623*** DONE text field support
624 CLOSED: [2011-07-20 Wed 20:05]
625Emacs captures all keyboard events so text field support isn't super
626straightforward.
627
628**** propagate keyboard events
629I have some old hacks for this and they are not good.
630**** use the DOM model
631expose document.activeElement to lisp. This is potentially more
632interesting than just forwarding keyboard events.
633
634webkit_web_view_get_dom_document ()
635
636this is hard it seems. an idea might be to hack elisp support for swig
637to machine generate the bindings.
638**** DONE inject javascript
639 CLOSED: [2011-07-03 Sun 22:50]
640webkit_web_view_execute_script ()
641
642this works now:
643(xwidget-webkit-execute-script 5 "document.activeElement.value='test'")
644
645so it should be possible to do some interesting stuff.
646execute-script does however not return anything at the interface level
647so satisfaction is not total:
648
649http://markmail.org/message/4yowmdgras73z3x5
650
651maybe
652https://launchpad.net/gnome-seed
653
654or this funny hack:
655<jave> im trying to understanh how to interact via javascript to an embedded
656 webkit gtk instance [23:38]
657<jave> i use webkit_web_view_execute_script() which is nice but doesnt return
658 a value, by design aparently [23:39]
659<jave> any hints?
660<lucian> jave: afaik, webkit still doesn't have full gobject bindings [23:48]
661<lucian> jave: you can hack it up by making the JS modify the title, and read
662 the title from gtk-side
663<jave> lucian: that was a pretty cool idea!
664
665
666*** webkit_web_view_load_string ()
667I would like preview of html in a buffer rather than from uri.
668
669
670
671*** TODO simple xwidget-webkit wrapper
672so that it could be used for actual browsing :)
673I dont want to reinvent too many wheels so i'd like to use existing
674emacs facilities here possible. use bindings similar to w3m(or info)
675
676- m-x xwidget-webkit starts a session
677- 'g' goes to a url
678- use bookmark-jump i suppose. I mostly use org for bookmarks myself
679- browse-url support so webkit can be the default browser
680- some way of getting around the quirky keyboard interaction since
681 xwidgets dont receive keyboard events because I hawe no idea how to
682 do that in a sane way
683
684... and one can of course go on bikeshedding forever. lets keep it
685simple and extensible, and compatible with other Emacs packages.
686
687the really cool ideas would need Emacs DOM integration, which is not
688easy.
689
690** DONE clipping of controllers 540** DONE clipping of controllers
691 CLOSED: [2011-07-05 Tue 11:33] 541 CLOSED: [2011-07-05 Tue 11:33]
692 542
@@ -840,7 +690,6 @@ support a chain of redirects, which seems unlikely. the benefit would
840be that I dont have to spend time optimizing redrawing. 690be that I dont have to spend time optimizing redrawing.
841 691
842 692
843
844** DONE remove xwidget_views when emacs window is deleted 693** DONE remove xwidget_views when emacs window is deleted
845 CLOSED: [2011-07-05 Tue 11:29] 694 CLOSED: [2011-07-05 Tue 11:29]
846removing xwidget views when an Emacs window closes is not reliable. 695removing xwidget views when an Emacs window closes is not reliable.
@@ -852,6 +701,171 @@ removing xwidget views when an Emacs window closes is not reliable.
852this seems to work 701this seems to work
853 702
854 703
704** browser xwidget
705although embedding a browser is not my primary concern many are
706interested in this. some suitable browser component needs to be found
707supporting gtk.
708
709*** DONE webkit
710 CLOSED: [2011-07-03 Sun 22:13]
711there is a webkit gtk port. there is no obvious mvc support.
712http://live.gnome.org/WebKitGtk
713http://webkitgtk.org/
714
715it might be possible to keep a set of webxits in artificial
716synchronisation by recursive deep copy of the DOM from one webkit to
717another. This will be error prone at best though. Another way might be
718to just use bitmap copy of the "live"instance to the "phantom"
719instances. the problem of transfering the live view remains though.
720
721export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT -g"
722export LDFLAGS=`pkg-config --libs webkit-1.0`
723./configure
724make
725
726**** off screen rendering
727export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT_OSR -g"
728export LDFLAGS=`pkg-config --libs webkit-1.0`
729./configure
730make
731
732works a little bit but i get errors like:
733
734(emacs:8362): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
735
736set a breakpoint in g_log, backtrace seems to indicate
737webkitViewportAttributesRecompute is the offender.
738
739maybe try gtk3 variants?
740
741export CFLAGS="`pkg-config --cflags webkitgtk-3.0 ` -DHAVE_WEBKIT_OSR "
742export LDFLAGS=`pkg-config --libs webkitgtk-3.0 `
743./configure --with-x-toolkit=gtk3
744make
745
746crash in gtk_window_get_size instead. great.
747
748http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscreenwindow_8c-source.html
749
750after many atempts, the basic issue remains. for some reason the
751offscreen widget isnt ok when I want to snapshot it, so i simply get
752emptiness. the surface is only ok someimes.
753
754here is a useful debugging snippets:
755 // debugging redraw:
756 // - the bg colors always change, so theres no error in signal handling
757 // - i get this error now and then:
758 //(emacs:7109): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
759 // seems to happen in webkit actually. see README
760
761 if(0){ //redraw debug hack. helped a lot in fact. use the with alpha painter below also
762 cairo_set_source_rgb(cr, osr_dbg_color, 1.0, 0.2);
763 cairo_rectangle(cr, 0,0, xw->width, xw->height);
764 cairo_fill(cr);
765 osr_dbg_color+=0.1;
766 if(osr_dbg_color>1.0)
767 osr_dbg_color=0.0;
768
769 }
770
771you need to terminate drawing like this:
772
773 //cairo_set_source_surface (cr, src_pixmap, 0,0);
774 //cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
775
776 //cairo_paint_with_alpha (cr, 1.0);
777 //cairo_paint(cr);
778
779the snippets change background color on oach redraw.
780
781**** on-screen rendering to separate window
782an alternative might be to open a separate window and snapshot it. the
783idea is that whatever oddness webkit does so that offscreen rendering
784doesnt work, doesnt happen on-screen. the window could be opened
785somewhere not in the way.
786
787*** CANCELLED firefox
788 CLOSED: [2011-07-03 Sun 22:13]
789http://www-archive.mozilla.org/unix/gtk-embedding.html
790seems to be severly bitrotted
791
792heres a newer aproach
793http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp
794
795while webkit clearly has the best traction as an embeddee, the
796offscreen rendering issues makes it interesting to see what ff brings
797to the table. turns out webkit has as good offscreen support as anyone.
798
799
800*** DONE text field support
801 CLOSED: [2011-07-20 Wed 20:05]
802Emacs captures all keyboard events so text field support isn't super
803straightforward.
804
805**** propagate keyboard events
806I have some old hacks for this and they are not good.
807**** use the DOM model
808expose document.activeElement to lisp. This is potentially more
809interesting than just forwarding keyboard events.
810
811webkit_web_view_get_dom_document ()
812
813this is hard it seems. an idea might be to hack elisp support for swig
814to machine generate the bindings.
815**** DONE inject javascript
816 CLOSED: [2011-07-03 Sun 22:50]
817webkit_web_view_execute_script ()
818
819this works now:
820(xwidget-webkit-execute-script 5 "document.activeElement.value='test'")
821
822so it should be possible to do some interesting stuff.
823execute-script does however not return anything at the interface level
824so satisfaction is not total:
825
826http://markmail.org/message/4yowmdgras73z3x5
827
828maybe
829https://launchpad.net/gnome-seed
830
831or this funny hack:
832<jave> im trying to understanh how to interact via javascript to an embedded
833 webkit gtk instance [23:38]
834<jave> i use webkit_web_view_execute_script() which is nice but doesnt return
835 a value, by design aparently [23:39]
836<jave> any hints?
837<lucian> jave: afaik, webkit still doesn't have full gobject bindings [23:48]
838<lucian> jave: you can hack it up by making the JS modify the title, and read
839 the title from gtk-side
840<jave> lucian: that was a pretty cool idea!
841
842
843*** webkit_web_view_load_string ()
844I would like preview of html in a buffer rather than from uri.
845
846
847
848*** DONE simple xwidget-webkit wrapper
849 CLOSED: [2011-07-22 Fri 11:01]
850so that it could be used for actual browsing :)
851I dont want to reinvent too many wheels so i'd like to use existing
852emacs facilities here possible. use bindings similar to w3m(or info)
853
854- m-x xwidget-webkit starts a session
855- 'g' goes to a url
856- use bookmark-jump i suppose. I mostly use org for bookmarks myself
857- browse-url support so webkit can be the default browser
858- some way of getting around the quirky keyboard interaction since
859 xwidgets dont receive keyboard events because I hawe no idea how to
860 do that in a sane way
861
862... and one can of course go on bikeshedding forever. lets keep it
863simple and extensible, and compatible with other Emacs packages.
864
865the really cool ideas would need Emacs DOM integration, which is not
866easy.
867
868
855** TODO support webkit signals 869** TODO support webkit signals
856*** TODO particularily document-load-finished 870*** TODO particularily document-load-finished
857http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished 871http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished
@@ -865,11 +879,26 @@ prints hello to stdout but theres no way to catch stdout from webkit I
865think other than receiving the signal. 879think other than receiving the signal.
866 880
867 881
882** DONE webkit flashkiller by default
883 CLOSED: [2011-07-19 Tue 14:27]
884while its possible to support plugins in the webkit xwidget, flash has
885issues on 64 bit, and slows down emacs to a halt with off screen
886rendering, and of course is not free software. its in the way for real
887world usage even if its interesting to watch flash animations inside
888emacs. which should be achieved with Gnash or other free software
889instead.
890
891http://stackoverflow.com/questions/4885513/prevent-flash-in-cocoa-webview
892
893simply use this api:
894http://webkitgtk.org/reference/WebKitWebPluginDatabase.html
895
868 896
869** TODO webkit downloads 897** TODO webkit downloads
870when clicking a download link in Webkit Emacs should take over and handle it 898when clicking a download link in Webkit Emacs should take over and handle it
871from there. Probably need signals. 899from there. Probably need signals. There are Emacs libraries to
872 900download things, with wget etc.
901"download-requested"
873** TODO webkit alt-text not handled 902** TODO webkit alt-text not handled
874XKCD use image-title to display a cartoon comment. These mysteriously 903XKCD use image-title to display a cartoon comment. These mysteriously
875don't work ATM. Other mouseovers work though. Maybe webkit tries to 904don't work ATM. Other mouseovers work though. Maybe webkit tries to
@@ -880,6 +909,36 @@ have a look at how docview solves it
880webkit_web_view_search_text () 909webkit_web_view_search_text ()
881** TODO webkit relative references doesn't work 910** TODO webkit relative references doesn't work
882probably because we handle scrolling in a non-standard way 911probably because we handle scrolling in a non-standard way
912** TODO webkit width adjustment handling issue
913since there are so many levels of clipping and whatnot in xwidgets
914sizing issues are difficult.
915
916- an xwidget is told how large it can be by emacs. thats the end of
917 it. if the xwidget thinks otherwise it will be clipped.
918- but emacs can ask the xwudget how large it wants to be. it can then
919 resize the reserved area and inform the xwidget thusly.
920
921That should have been enough. but webkit never reports less than what
922it already has. So currently a webkit view will only growth and not
923adjust to smaller sizes.
924
925This is not a big problem in practice but is still annoying.
926
927to see the problem surface to http://www.slashdot.org
928- xwidget-webkit-adjust-size
929- xwidget-webkit-adjust-size-to-content
930
931and then try resizing Epiphany.
932
933
934** TODO synchronise emacs background with xwidget color
935fine-tuning to reduce flicker.
936
937** TODO xwidget allow loading from string from emacs
938
939
940** TODO xwidgets doesn't work during bootstrap all of a sudden
941
883* old notes from x_draw_xwidget_glyph_string 942* old notes from x_draw_xwidget_glyph_string
884 943
885 BUG it seems this method for some reason is called with bad s->x and s->y sometimes. 944 BUG it seems this method for some reason is called with bad s->x and s->y sometimes.
@@ -922,3 +981,4 @@ probably because we handle scrolling in a non-standard way
922 this means valid cases like xwidgets being displayed only once in 981 this means valid cases like xwidgets being displayed only once in
923 non-selected windows, does not work well. they should also be visible 982 non-selected windows, does not work well. they should also be visible
924 in that case not phantomed. 983 in that case not phantomed.
984