diff options
| author | Joakim Verona | 2011-06-30 01:17:01 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-06-30 01:17:01 +0200 |
| commit | 9333b6a4d92243ebeee9c5fc3ae3f1ec1a47abc3 (patch) | |
| tree | 671159954531f8a5ed0c4aaef64333f7a150e9ed /src/xwidget.c | |
| parent | b380a76ffbf54594dfd6fc3d932983ac0439d07f (diff) | |
| download | emacs-9333b6a4d92243ebeee9c5fc3ae3f1ec1a47abc3.tar.gz emacs-9333b6a4d92243ebeee9c5fc3ae3f1ec1a47abc3.zip | |
added an offscreen rendered webkit variant. the on-screen view shows up sometimes so the principle is validated
Diffstat (limited to 'src/xwidget.c')
| -rw-r--r-- | src/xwidget.c | 71 |
1 files changed, 68 insertions, 3 deletions
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; | |||
| 105 | Lisp_Object Qxwidget_resize_internal; | 105 | Lisp_Object Qxwidget_resize_internal; |
| 106 | Lisp_Object Qxwidget_send_keyboard_event; | 106 | Lisp_Object Qxwidget_send_keyboard_event; |
| 107 | 107 | ||
| 108 | Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qcairo, Qwebkit, QCplist; | 108 | Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qcairo, Qwebkit, |
| 109 | Qwebkit_osr, QCplist; | ||
| 109 | 110 | ||
| 110 | 111 | ||
| 111 | extern Lisp_Object QCtype; | 112 | extern 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 */ | ||
| 257 | webkit_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 | |||
| 254 | int xwidget_view_index=0; | 287 | int 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 | ||
| 547 | DEFUN ("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 | |||
| 836 | lookup_xwidget (Lisp_Object spec) | 890 | lookup_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 | ||