aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.xwidget16
-rw-r--r--lisp/xwidget-test.el4
-rw-r--r--src/xwidget.c71
-rw-r--r--src/xwidget.h6
4 files changed, 94 insertions, 3 deletions
diff --git a/README.xwidget b/README.xwidget
index 6a6633b4b20..4477f53051c 100644
--- a/README.xwidget
+++ b/README.xwidget
@@ -187,6 +187,10 @@ there are some things that arent clear:
187- xwidget-views are by necessity coupled to a emacs window so it might 187- xwidget-views are by necessity coupled to a emacs window so it might
188 be better to store them window locally rather than in an assoc 188 be better to store them window locally rather than in an assoc
189 coupled to the xwidget model 189 coupled to the xwidget model
190- for some gtk widgets that resist an mvc approach, like the webkit
191 widgets, special operations are needed, similar to the old phantom
192 widgets aproach. so we need to differentiate live and phantom
193 instances for these troublesome widgets and let lisp manage all the trickery.
190 194
191stuff that needs to work: 195stuff that needs to work:
192- do something for all views of a xwidget(resize, value change) 196- do something for all views of a xwidget(resize, value change)
@@ -318,12 +322,24 @@ there is a webkit gtk port. there is no obvious mvc support.
318http://live.gnome.org/WebKitGtk 322http://live.gnome.org/WebKitGtk
319http://webkitgtk.org/ 323http://webkitgtk.org/
320 324
325it might be possible to keep a set of webxits in artificial
326synchronisation by recursive deep copy of the DOM from one webkit to
327another. This will be error prone at best though. Another way might be
328to just use bitmap copy of the "live"instance to the "phantom"
329instances. the problem of transfering the live view remains though.
321 330
322export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT -g" 331export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT -g"
323export LDFLAGS=`pkg-config --libs webkit-1.0` 332export LDFLAGS=`pkg-config --libs webkit-1.0`
324./configure 333./configure
325make 334make
326 335
336export CFLAGS="`pkg-config --cflags webkit-1.0` -DHAVE_WEBKIT_OSR -g"
337export LDFLAGS=`pkg-config --libs webkit-1.0`
338./configure
339make
340
341
342
327*** firefox 343*** firefox
328http://www-archive.mozilla.org/unix/gtk-embedding.html 344http://www-archive.mozilla.org/unix/gtk-embedding.html
329seems to be severly bitrotted 345seems to be severly bitrotted
diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el
index 2e1cb033d8d..46caf749fa1 100644
--- a/lisp/xwidget-test.el
+++ b/lisp/xwidget-test.el
@@ -60,6 +60,10 @@
60 (xwidget-insert (point-min) 'webkit "webkit" 1000 1000 5) 60 (xwidget-insert (point-min) 'webkit "webkit" 1000 1000 5)
61 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) 61 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
62 62
63(xwidget-demo "a-webkit-osr"
64 (xwidget-insert (point-min) 'webkit-osr "webkit-osr" 1000 1000 5)
65 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
66
63 67
64 68
65(xwidget-demo "basic" 69(xwidget-demo "basic"
diff --git a/src/xwidget.c b/src/xwidget.c
index 14110af7fce..627bd70e150 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -105,7 +105,8 @@ Lisp_Object Qxwidget_info;
105Lisp_Object Qxwidget_resize_internal; 105Lisp_Object Qxwidget_resize_internal;
106Lisp_Object Qxwidget_send_keyboard_event; 106Lisp_Object Qxwidget_send_keyboard_event;
107 107
108Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qcairo, Qwebkit, QCplist; 108Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qcairo, Qwebkit,
109 Qwebkit_osr, QCplist;
109 110
110 111
111extern Lisp_Object QCtype; 112extern Lisp_Object QCtype;
@@ -251,6 +252,38 @@ void xwidget_slider_changed (GtkRange *range,
251 252
252} 253}
253 254
255/* when the on-screen webkit peer view gets exposed this signal is called.
256 it copies the bitmap from the off-screen webkit instance */
257webkit_osr_expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
258 {
259 struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
260 cairo_t *cr;
261 GdkPixmap *src_pixmap;
262 src_pixmap = xw->widget_osr->window;
263 printf("xwidget_composite_draw_widgetwindow xw.id:%d xw.type:%d window:%d\n", xw->id,xw->type, gtk_widget_get_window (widget));
264
265 cr = gdk_cairo_create (gtk_widget_get_window (widget));
266
267 cairo_rectangle(cr, 0,0, xw->width, xw->height);
268 cairo_clip(cr);
269
270 /*
271 cairo_set_source_rgb(cr, 0.1, 1.0, 0.2);
272 cairo_rectangle(cr, 0,0, xw->width, xw->height);
273 cairo_fill(cr);
274 */
275
276 gdk_cairo_set_source_pixmap (cr, src_pixmap,
277 0,0);
278
279 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
280 //cairo_paint_with_alpha (cr, 0.9);
281 cairo_paint(cr);
282 cairo_destroy (cr);
283
284 return FALSE;
285 }
286
254int xwidget_view_index=0; 287int xwidget_view_index=0;
255 288
256/* initializes and does initial placement of an xwidget view on screen */ 289/* initializes and does initial placement of an xwidget view on screen */
@@ -344,6 +377,13 @@ xwidget_init_view (
344 xv->widget = webkit_web_view_new(); 377 xv->widget = webkit_web_view_new();
345 webkit_web_view_load_uri(xv->widget, "http://www.fsf.org"); 378 webkit_web_view_load_uri(xv->widget, "http://www.fsf.org");
346#endif 379#endif
380 } else if (EQ(xww->type, Qwebkit_osr)) {
381#ifdef HAVE_WEBKIT_OSR
382 xv->widget = gtk_drawing_area_new();
383 g_signal_connect (G_OBJECT ( xv->widget), "expose_event",
384 G_CALLBACK (webkit_osr_expose_event_callback), NULL);
385
386#endif
347 387
348 388
349 } else return NULL; 389 } else return NULL;
@@ -503,6 +543,19 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
503 } 543 }
504} 544}
505 545
546#ifdef HAVE_WEBKIT
547DEFUN ("xwidget-webkit-goto-uri", Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri, 2, 2, 0,
548 doc: /* webkit goto uri.*/
549 )
550 (Lisp_Object xwidget_id, Lisp_Object uri)
551{
552/* now we have the same issue as always except worse. webkit resists an MVC approach!
553 for now, the 1st webkit view will be manipulated only
554 */
555
556//webkit_web_view_load_uri(xv->widget, "http://www.fsf.org");
557}
558#endif
506 559
507 560
508 561
@@ -721,6 +774,7 @@ syms_of_xwidget (void)
721 defsubr (&Sxwidget_embed_steal_window); 774 defsubr (&Sxwidget_embed_steal_window);
722 775
723 DEFSYM (Qxwidget ,"xwidget"); 776 DEFSYM (Qxwidget ,"xwidget");
777
724 DEFSYM (Qxwidget_id ,":xwidget-id"); 778 DEFSYM (Qxwidget_id ,":xwidget-id");
725 DEFSYM (Qtitle ,":title"); 779 DEFSYM (Qtitle ,":title");
726 780
@@ -730,7 +784,7 @@ syms_of_xwidget (void)
730 DEFSYM (Qsocket, "socket"); 784 DEFSYM (Qsocket, "socket");
731 DEFSYM (Qcairo, "cairo"); 785 DEFSYM (Qcairo, "cairo");
732 DEFSYM (Qwebkit ,"webkit"); 786 DEFSYM (Qwebkit ,"webkit");
733 787 DEFSYM (Qwebkit_osr ,"webkit-osr");
734 DEFSYM (QCplist, ":plist"); 788 DEFSYM (QCplist, ":plist");
735 789
736 Fprovide (intern ("xwidget-internal"), Qnil); 790 Fprovide (intern ("xwidget-internal"), Qnil);
@@ -836,7 +890,7 @@ int
836lookup_xwidget (Lisp_Object spec) 890lookup_xwidget (Lisp_Object spec)
837{ 891{
838 /*when a xwidget lisp spec is found initialize the C struct that is used in the C code. 892 /*when a xwidget lisp spec is found initialize the C struct that is used in the C code.
839 893 xwidget_init
840 */ 894 */
841 int found = 0, found1 = 0, found2 = 0; 895 int found = 0, found1 = 0, found2 = 0;
842 Lisp_Object value; 896 Lisp_Object value;
@@ -866,6 +920,17 @@ lookup_xwidget (Lisp_Object spec)
866 920
867 assert_valid_xwidget_id (id, "lookup_xwidget"); 921 assert_valid_xwidget_id (id, "lookup_xwidget");
868 922
923#ifdef HAVE_WEBKIT_OSR
924 //diy mvc. widget is rendered offscreen, later blitted onscreen
925 if (EQ(xw->type, Qwebkit_osr)){
926 xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ());
927 xw->widget_osr = webkit_web_view_new();
928 gtk_container_add (xw->widgetwindow_osr, xw->widget_osr);
929 gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr));
930 webkit_web_view_load_uri(xw->widget_osr, "http://www.fsf.org");
931
932 }
933#endif
869 return id; 934 return id;
870} 935}
871 936
diff --git a/src/xwidget.h b/src/xwidget.h
index 3a7d92f70a7..d54d4e649d8 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -24,6 +24,12 @@ struct xwidget{
24 int height; 24 int height;
25 int width; 25 int width;
26 int initialized; 26 int initialized;
27
28
29 //for offscreen widgets, unused if not osr
30 GtkWidget* widget_osr;
31 GtkContainer* widgetwindow_osr;
32
27}; 33};
28 34
29 35