aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2011-07-03 23:05:58 +0200
committerJoakim Verona2011-07-03 23:05:58 +0200
commitf929f1a90836282bfe85c81fcf8a757bf0b54b50 (patch)
treed47270a8e2be10f467199de148e1bb7801244888
parentd5aa6c9095f22bb9cbac9557b3502e6b90d98d0e (diff)
downloademacs-f929f1a90836282bfe85c81fcf8a757bf0b54b50.tar.gz
emacs-f929f1a90836282bfe85c81fcf8a757bf0b54b50.zip
inject javascript in embeddeb webkit instance
-rw-r--r--README.xwidget41
-rw-r--r--src/xwidget.c34
2 files changed, 63 insertions, 12 deletions
diff --git a/README.xwidget b/README.xwidget
index 59ddf9d2435..bc01ad95d66 100644
--- a/README.xwidget
+++ b/README.xwidget
@@ -317,7 +317,8 @@ although embedding a browser is not my primary concern many are
317interested in this. some suitable browser component needs to be found 317interested in this. some suitable browser component needs to be found
318supporting gtk. 318supporting gtk.
319 319
320*** webkit 320*** DONE webkit
321 CLOSED: [2011-07-03 Sun 22:13]
321there is a webkit gtk port. there is no obvious mvc support. 322there is a webkit gtk port. there is no obvious mvc support.
322http://live.gnome.org/WebKitGtk 323http://live.gnome.org/WebKitGtk
323http://webkitgtk.org/ 324http://webkitgtk.org/
@@ -370,7 +371,8 @@ idea is that whatever oddness webkit does so that offscreen rendering
370doesnt work, doesnt happen on-screen. the window could be opened 371doesnt work, doesnt happen on-screen. the window could be opened
371somewhere not in the way. 372somewhere not in the way.
372 373
373*** firefox 374*** CANCELLED firefox
375 CLOSED: [2011-07-03 Sun 22:13]
374http://www-archive.mozilla.org/unix/gtk-embedding.html 376http://www-archive.mozilla.org/unix/gtk-embedding.html
375seems to be severly bitrotted 377seems to be severly bitrotted
376 378
@@ -379,7 +381,33 @@ http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp
379 381
380while webkit clearly has the best traction as an embeddee, the 382while webkit clearly has the best traction as an embeddee, the
381offscreen rendering issues makes it interesting to see what ff brings 383offscreen rendering issues makes it interesting to see what ff brings
382to the table. 384to the table. turns out webkit has as good offscreen support as anyone.
385
386
387*** TODO text field support
388Emacs captures all keyboard events so text field support isn't super
389straightforward.
390
391**** propagate keyboard events
392I have some old hacks for this and they are not good.
393**** use the DOM model
394expose document.activeElement to lisp. This is potentially more
395interesting than just forwarding keyboard events.
396
397webkit_web_view_get_dom_document ()
398
399**** DONE inject javascript
400 CLOSED: [2011-07-03 Sun 22:50]
401webkit_web_view_execute_script ()
402
403this works now:
404(xwidget-webkit-execute-script 5 "document.activeElement.value='test'")
405
406so it should be possible to do some interesting stuff.
407execute-script does however not return anything at the interface level
408so satisfaction is not total.
409
410http://markmail.org/message/4yowmdgras73z3x5
383 411
384 412
385** TODO clipping of controllers 413** TODO clipping of controllers
@@ -479,13 +507,18 @@ the needed data is private to the base class. to overcome this:
479** TODO use FRAME_GTK_WIDGET (f) 507** TODO use FRAME_GTK_WIDGET (f)
480rather than gwfixed 508rather than gwfixed
481 509
482** TODO translate clicks 510** DONE translate clicks
511 CLOSED: [2011-07-03 Sun 22:12]
483on onscreen webkit peer to offscreen 512on onscreen webkit peer to offscreen
484 513
485maybe 514maybe
486http://developer.gnome.org/gdk/stable/gdk-Windows.html#GdkWindow-from-embedder 515http://developer.gnome.org/gdk/stable/gdk-Windows.html#GdkWindow-from-embedder
487 516
517turned out tell be not so hard, captured events, copied them and
518forwarded them offscreen!
488 519
489** TODO investigate gdk_window_redirect_to_drawable 520** TODO investigate gdk_window_redirect_to_drawable
490http://developer.gnome.org/gdk/stable/gdk-Windows.html#gdk-offscreen-window-set-embedder 521http://developer.gnome.org/gdk/stable/gdk-Windows.html#gdk-offscreen-window-set-embedder
491maybe control be used in place of my own copy hacks? 522maybe control be used in place of my own copy hacks?
523
524
diff --git a/src/xwidget.c b/src/xwidget.c
index a47d6c12dbc..c4e4f2c5ba2 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -540,26 +540,21 @@ xwidget_init_view (
540 } else if (EQ(xww->type, Qwebkit_osr)) { 540 } else if (EQ(xww->type, Qwebkit_osr)) {
541#ifdef HAVE_WEBKIT_OSR 541#ifdef HAVE_WEBKIT_OSR
542 xv->widget = gtk_drawing_area_new(); 542 xv->widget = gtk_drawing_area_new();
543 gtk_widget_set_app_paintable ( xv->widget, TRUE); //because expose event handling 543 gtk_widget_set_app_paintable ( xv->widget, TRUE); //because expose event handling
544#endif 544#endif
545#ifdef HAVE_GTK3 //and webkit_osr 545#ifdef HAVE_GTK3 //and webkit_osr
546 gtk_widget_add_events(xv->widget, 546 gtk_widget_add_events(xv->widget,
547 GDK_BUTTON_PRESS_MASK 547 GDK_BUTTON_PRESS_MASK
548 | GDK_BUTTON_RELEASE_MASK 548 | GDK_BUTTON_RELEASE_MASK
549 | GDK_POINTER_MOTION_MASK 549 | GDK_POINTER_MOTION_MASK);
550 );
551
552 g_signal_connect (G_OBJECT ( xv->widget), "draw", 550 g_signal_connect (G_OBJECT ( xv->widget), "draw",
553 G_CALLBACK (xwidget_osr_draw_callback), NULL); 551 G_CALLBACK (xwidget_osr_draw_callback), NULL);
554
555 g_signal_connect (G_OBJECT ( xv->widget), "button-press-event", 552 g_signal_connect (G_OBJECT ( xv->widget), "button-press-event",
556 G_CALLBACK (xwidget_osr_button_callback), NULL); 553 G_CALLBACK (xwidget_osr_button_callback), NULL);
557 g_signal_connect (G_OBJECT ( xv->widget), "button-release-event", 554 g_signal_connect (G_OBJECT ( xv->widget), "button-release-event",
558 G_CALLBACK (xwidget_osr_button_callback), NULL); 555 G_CALLBACK (xwidget_osr_button_callback), NULL);
559 g_signal_connect (G_OBJECT ( xv->widget), "motion-notify-event", 556 g_signal_connect (G_OBJECT ( xv->widget), "motion-notify-event",
560 G_CALLBACK (xwidget_osr_button_callback), NULL); 557 G_CALLBACK (xwidget_osr_button_callback), NULL);
561
562
563#else 558#else
564 g_signal_connect (G_OBJECT ( xv->widget), "expose_event", 559 g_signal_connect (G_OBJECT ( xv->widget), "expose_event",
565 G_CALLBACK (webkit_osr_expose_event_callback), NULL); 560 G_CALLBACK (webkit_osr_expose_event_callback), NULL);
@@ -774,6 +769,27 @@ DEFUN ("xwidget-webkit-goto-uri", Fxwidget_webkit_goto_uri, Sxwidget_webkit_got
774 769
775 webkit_web_view_load_uri(xw->widget_osr, SDATA(uri)); 770 webkit_web_view_load_uri(xw->widget_osr, SDATA(uri));
776} 771}
772
773DEFUN ("xwidget-webkit-execute-script", Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script, 2, 2, 0,
774 doc: /* webkit exec js.*/
775 )
776 (Lisp_Object xwidget_id, Lisp_Object script)
777{
778
779 //TODO refactor this crap to something sane
780 struct xwidget *xw;
781 int xid;
782
783 CHECK_NUMBER (xwidget_id);
784 xid = XFASTINT (xwidget_id);
785 xw = &xwidgets[xid];
786
787 //TODO check xw actually is of the correct type before trying stuff with it
788
789 webkit_web_view_execute_script(xw->widget_osr, SDATA(script));
790 return Qnil;
791}
792
777#endif 793#endif
778 794
779 795
@@ -868,7 +884,7 @@ DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_key
868 xid = XFASTINT (xwidget_id); 884 xid = XFASTINT (xwidget_id);
869 kbd_flag = XFASTINT (kbd_grab); 885 kbd_flag = XFASTINT (kbd_grab);
870 xw = &xwidgets[xid]; 886 xw = &xwidgets[xid];
871 if(xw->type != 3) return Qnil; //only relevant for xembed //TODO MVC 887
872 888
873 printf ("kbd grab: %d %d\n", xid, kbd_flag); 889 printf ("kbd grab: %d %d\n", xid, kbd_flag);
874 if (kbd_flag) 890 if (kbd_flag)
@@ -991,7 +1007,9 @@ syms_of_xwidget (void)
991 defsubr (&Sxwidget_info); 1007 defsubr (&Sxwidget_info);
992 defsubr (&Sxwidget_resize_internal); 1008 defsubr (&Sxwidget_resize_internal);
993 defsubr (&Sxwidget_embed_steal_window); 1009 defsubr (&Sxwidget_embed_steal_window);
1010
994 defsubr (&Sxwidget_webkit_goto_uri); 1011 defsubr (&Sxwidget_webkit_goto_uri);
1012 defsubr (&Sxwidget_webkit_execute_script);
995 1013
996 DEFSYM (Qxwidget ,"xwidget"); 1014 DEFSYM (Qxwidget ,"xwidget");
997 1015