aboutsummaryrefslogtreecommitdiffstats
path: root/src/xwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xwidget.c')
-rw-r--r--src/xwidget.c174
1 files changed, 15 insertions, 159 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index 6c712d1d707..ef9de279939 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -89,21 +89,12 @@
89#include <clutter-gtk/clutter-gtk.h> 89#include <clutter-gtk/clutter-gtk.h>
90#endif 90#endif
91 91
92
93#include <wchar.h> 92#include <wchar.h>
94 93
95#ifdef HAVE_WEBKIT
96#include <webkitgtk.h>
97
98#endif
99
100
101#ifdef HAVE_WEBKIT_OSR 94#ifdef HAVE_WEBKIT_OSR
102#include <webkit/webkitwebview.h> 95#include <webkit/webkitwebview.h>
103#endif 96#endif
104 97
105
106
107#include "xwidget.h" 98#include "xwidget.h"
108 99
109//TODO should of course not be a hardcoded array but I can't be bothered atm 100//TODO should of course not be a hardcoded array but I can't be bothered atm
@@ -114,9 +105,6 @@
114struct xwidget xwidgets[MAX_XWIDGETS]; 105struct xwidget xwidgets[MAX_XWIDGETS];
115struct xwidget_view xwidget_views[MAX_XWIDGETS]; 106struct xwidget_view xwidget_views[MAX_XWIDGETS];
116 107
117
118
119
120Lisp_Object Qxwidget; 108Lisp_Object Qxwidget;
121Lisp_Object Qxwidget_id; 109Lisp_Object Qxwidget_id;
122Lisp_Object Qtitle; 110Lisp_Object Qtitle;
@@ -126,7 +114,7 @@ Lisp_Object Qxwidget_info;
126Lisp_Object Qxwidget_resize_internal; 114Lisp_Object Qxwidget_resize_internal;
127Lisp_Object Qxwidget_send_keyboard_event; 115Lisp_Object Qxwidget_send_keyboard_event;
128 116
129Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qcairo, Qwebkit, 117Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qcairo,
130 Qwebkit_osr, QCplist; 118 Qwebkit_osr, QCplist;
131 119
132 120
@@ -274,100 +262,6 @@ void xwidget_slider_changed (GtkRange *range,
274 262
275} 263}
276 264
277double osr_dbg_color=0;
278void webkit_osr_redraw_child ( struct xwidget* xw, GtkWidget *widget)
279{
280
281 //this stuff is different in gtk3
282#ifndef HAVE_GTK3
283 cairo_t *cr;
284
285
286 GdkPixmap *src_pixmap;
287 src_pixmap = gtk_offscreen_window_get_pixmap(xw->widgetwindow_osr);
288
289 //g_object_ref(src_pixmap);//TODO needs to be unrefed eventually, if we are to use his method
290
291
292 printf("webkit_osr_redraw_child xw.id:%d xw.type:%d window:%d\n", xw->id,xw->type, gtk_widget_get_window (widget));
293
294 cr = gdk_cairo_create (gtk_widget_get_window (widget));
295
296 cairo_rectangle(cr, 0,0, xw->width, xw->height);
297 cairo_clip(cr);
298
299 // debugging redraw:
300 // - the bg colors always change, so theres no error in signal handling
301 // - i get this error now and then:
302 //(emacs:7109): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
303 // seems to happen in webkit actually. see README
304
305 if(1){ //redraw debug hack
306 cairo_set_source_rgb(cr, osr_dbg_color, 1.0, 0.2);
307 cairo_rectangle(cr, 0,0, xw->width, xw->height);
308 cairo_fill(cr);
309 osr_dbg_color+=0.1;
310 if(osr_dbg_color>1.0)
311 osr_dbg_color=0.0;
312
313 }
314
315 gdk_cairo_set_source_pixmap (cr, src_pixmap, 0,0); //deprecated. use gdk_cairo_set_source_window
316 //gdk_cairo_set_source_window(cr, src_pixmap, 0,0);
317
318 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
319 cairo_paint_with_alpha (cr, 0.7);
320 //cairo_paint(cr);
321
322
323 cairo_destroy (cr);
324#elseif
325 cairo_t *cr;
326 cairo_surface_t * *src_pixmap;
327 src_pixmap = gtk_offscreen_window_get_surface (xw->widgetwindow_osr);
328
329 printf("webkit_osr_redraw_child gtk3 xw.id:%d xw.type:%d window:%d\n", xw->id,xw->type, gtk_widget_get_window (widget));
330
331 cr = gdk_cairo_create (gtk_widget_get_window (widget));
332
333 cairo_rectangle(cr, 0,0, xw->width, xw->height);
334 cairo_clip(cr);
335
336 // debugging redraw:
337 // - the bg colors always change, so theres no error in signal handling
338 // - i get this error now and then:
339 //(emacs:7109): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
340 // seems to happen in webkit actually. see README
341
342 if(1){ //redraw debug hack
343 cairo_set_source_rgb(cr, osr_dbg_color, 1.0, 0.2);
344 cairo_rectangle(cr, 0,0, xw->width, xw->height);
345 cairo_fill(cr);
346 osr_dbg_color+=0.1;
347 if(osr_dbg_color>1.0)
348 osr_dbg_color=0.0;
349
350 }
351
352 cairo_set_source_surface (cr, src_pixmap, 0,0);
353
354
355 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
356 cairo_paint_with_alpha (cr, 0.7);
357 //cairo_paint(cr);
358 cairo_destroy (cr);
359#endif
360}
361
362/* when the on-screen webkit peer view gets exposed this signal is called.
363 it copies the bitmap from the off-screen webkit instance to the onscreen view*/
364gboolean webkit_osr_expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
365{
366 //TODO optimize by cliping to damage region
367 struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
368 webkit_osr_redraw_child(xw, widget);
369 return FALSE;
370}
371 265
372/* when the off-screen webkit master view changes this signal is called. 266/* when the off-screen webkit master view changes this signal is called.
373 it copies the bitmap from the off-screen webkit instance */ 267 it copies the bitmap from the off-screen webkit instance */
@@ -509,18 +403,10 @@ xwidget_init_view (
509 /* Show the stage: */ 403 /* Show the stage: */
510 clutter_actor_show (stage); 404 clutter_actor_show (stage);
511#endif 405#endif
512
513 } else if (EQ(xww->type, Qwebkit)) {
514#ifdef HAVE_WEBKIT
515 xv->widget = webkit_web_view_new();
516 webkit_web_view_load_uri(xv->widget, "http://www.fsf.org");
517#endif
518 } else if (EQ(xww->type, Qwebkit_osr)) { 406 } else if (EQ(xww->type, Qwebkit_osr)) {
519#ifdef HAVE_WEBKIT_OSR 407#ifdef HAVE_WEBKIT_OSR
520 xv->widget = gtk_drawing_area_new(); 408 xv->widget = gtk_drawing_area_new();
521 gtk_widget_set_app_paintable ( xv->widget, TRUE); //because expose event handling 409 gtk_widget_set_app_paintable ( xv->widget, TRUE); //because expose event handling
522#endif
523#ifdef HAVE_GTK3 //and webkit_osr
524 gtk_widget_add_events(xv->widget, 410 gtk_widget_add_events(xv->widget,
525 GDK_BUTTON_PRESS_MASK 411 GDK_BUTTON_PRESS_MASK
526 | GDK_BUTTON_RELEASE_MASK 412 | GDK_BUTTON_RELEASE_MASK
@@ -533,9 +419,6 @@ xwidget_init_view (
533 G_CALLBACK (xwidget_osr_button_callback), NULL); 419 G_CALLBACK (xwidget_osr_button_callback), NULL);
534 g_signal_connect (G_OBJECT ( xv->widget), "motion-notify-event", 420 g_signal_connect (G_OBJECT ( xv->widget), "motion-notify-event",
535 G_CALLBACK (xwidget_osr_button_callback), NULL); 421 G_CALLBACK (xwidget_osr_button_callback), NULL);
536#else
537 g_signal_connect (G_OBJECT ( xv->widget), "expose_event",
538 G_CALLBACK (webkit_osr_expose_event_callback), NULL);
539#endif 422#endif
540 423
541 424
@@ -973,7 +856,6 @@ syms_of_xwidget (void)
973 DEFSYM (Qslider, "slider"); 856 DEFSYM (Qslider, "slider");
974 DEFSYM (Qsocket, "socket"); 857 DEFSYM (Qsocket, "socket");
975 DEFSYM (Qcairo, "cairo"); 858 DEFSYM (Qcairo, "cairo");
976 DEFSYM (Qwebkit ,"webkit");
977 DEFSYM (Qwebkit_osr ,"webkit-osr"); 859 DEFSYM (Qwebkit_osr ,"webkit-osr");
978 DEFSYM (QCplist, ":plist"); 860 DEFSYM (QCplist, ":plist");
979 861
@@ -1101,10 +983,9 @@ void gtk_window_get_position (GtkWindow *window,
1101int 983int
1102lookup_xwidget (Lisp_Object spec) 984lookup_xwidget (Lisp_Object spec)
1103{ 985{
1104 /*when a xwidget lisp spec is found initialize the C struct that is used in the C code. 986 /* When a xwidget lisp spec is found initialize the C struct that is used in the C code.
1105 this is done by redisplay so values change if the spec changes. 987 This is done by redisplay so values change if the spec changes.
1106 so, take special care of one-shot events 988 So, take special care of one-shot events
1107 xwidget_init
1108 */ 989 */
1109 int found = 0, found1 = 0, found2 = 0; 990 int found = 0, found1 = 0, found2 = 0;
1110 Lisp_Object value; 991 Lisp_Object value;
@@ -1112,56 +993,46 @@ lookup_xwidget (Lisp_Object spec)
1112 struct xwidget *xw; 993 struct xwidget *xw;
1113 994
1114 value = xwidget_spec_value (spec, Qxwidget_id, &found1); 995 value = xwidget_spec_value (spec, Qxwidget_id, &found1);
1115 id = INTEGERP (value) ? XFASTINT (value) : 0; //id 0 by default, but id must be unique so this is dumb 996 id = INTEGERP (value) ? XFASTINT (value) : 0; //TODO id 0 by default, but id must be unique so this is dumb
1116 997
1117 xw = &xwidgets[id]; 998 xw = &xwidgets[id];
1118 xw->id=id; 999 xw->id=id;
1119 value = xwidget_spec_value (spec, QCtype, &found); 1000 value = xwidget_spec_value (spec, QCtype, &found);
1120 xw->type = SYMBOLP (value) ? value : Qbutton; //default to button 1001 xw->type = SYMBOLP (value) ? value : Qbutton; //default to button
1121 value = xwidget_spec_value (spec, Qtitle, &found2); 1002 value = xwidget_spec_value (spec, Qtitle, &found2);
1122 xw->title = STRINGP (value) ? (char *) SDATA (value) : "?"; //funky cast FIXME 1003 xw->title = STRINGP (value) ? (char *) SDATA (value) : "?"; //funky cast FIXME TODO
1123 1004
1124 value = xwidget_spec_value (spec, QCheight, NULL); 1005 value = xwidget_spec_value (spec, QCheight, NULL);
1125 xw->height = INTEGERP (value) ? XFASTINT (value) : 50; //ok 1006 xw->height = INTEGERP (value) ? XFASTINT (value) : 50;
1126 value = xwidget_spec_value (spec, QCwidth, NULL); 1007 value = xwidget_spec_value (spec, QCwidth, NULL);
1127 xw->width = INTEGERP (value) ? XFASTINT (value) : 50; //ok 1008 xw->width = INTEGERP (value) ? XFASTINT (value) : 50;
1128 1009
1129 value = xwidget_spec_value (spec, QCplist, NULL); 1010 value = xwidget_spec_value (spec, QCplist, NULL);
1130 xw->plist = value; 1011 xw->plist = value;
1131 printf ("xwidget_id:%d type:%d found:%d %d %d title:%s (%d,%d)\n", id, 1012 printf ("xwidget_id:%d type:%d found:%d %d %d title:%s (%d,%d)\n", id,
1132 xw->type, found, found1, found2, xw->title, xw->height, xw->width); 1013 xw->type, found, found1, found2, xw->title, xw->height, xw->width);
1133 1014
1134
1135 assert_valid_xwidget_id (id, "lookup_xwidget"); 1015 assert_valid_xwidget_id (id, "lookup_xwidget");
1136 1016
1137#ifdef HAVE_WEBKIT_OSR 1017#ifdef HAVE_WEBKIT_OSR
1138 //diy mvc. widget is rendered offscreen(or in an onscreen separate toplevel for testing), later blitted to the views 1018 /* DIY mvc. widget is rendered offscreen,
1019 later bitmap copied to the views.
1020 */
1139 if (EQ(xw->type, Qwebkit_osr) && !xw->widgetwindow_osr){ 1021 if (EQ(xw->type, Qwebkit_osr) && !xw->widgetwindow_osr){
1140 BLOCK_INPUT; 1022 BLOCK_INPUT;
1141 //xw->widgetwindow_osr = GTK_CONTAINER (gtk_window_new ( GTK_WINDOW_TOPLEVEL));
1142 //xw->widgetwindow_osr = GTK_CONTAINER (gtk_dialog_new ());
1143 xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ()); 1023 xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ());
1144 gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); 1024 gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height);
1145 //xw->widgetwindow_osr = SELECTED_FRAME()->gwfixed;
1146 xw->widget_osr = webkit_web_view_new(); 1025 xw->widget_osr = webkit_web_view_new();
1147 //xw->widget_osr = gtk_button_new();
1148
1149 //random debug hack
1150 //gtk_widget_set_double_buffered (xw->widget_osr,FALSE);
1151 //gtk_widget_set_double_buffered (xw->widgetwindow_osr,FALSE);
1152 1026
1153 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); 1027 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height);
1154 gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); 1028 gtk_container_add (xw->widgetwindow_osr, xw->widget_osr);
1155 //gtk_fixed_put(GTK_FIXED(xw->widgetwindow_osr), xw->widget_osr, 0, 200);
1156 1029
1157 gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); 1030 gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr));
1158 1031
1159 //store some xwidget data in the gtk widgets 1032 /* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. */
1160 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); //the xwidget 1033 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw));
1161 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); //the xwidget 1034 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw));
1162
1163 g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (webkit_osr_damage_event_callback), NULL); 1035 g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (webkit_osr_damage_event_callback), NULL);
1164 //g_signal_connect (G_OBJECT ( xw->widget_osr), "draw", G_CALLBACK (webkit_osr_damage_event_callback), NULL);
1165 1036
1166 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org"); 1037 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org");
1167 UNBLOCK_INPUT; 1038 UNBLOCK_INPUT;
@@ -1171,13 +1042,6 @@ lookup_xwidget (Lisp_Object spec)
1171 return id; 1042 return id;
1172} 1043}
1173 1044
1174
1175
1176
1177
1178//////////////////////////////////
1179int region_modified = 0;
1180
1181/*set up detection of touched xwidget*/ 1045/*set up detection of touched xwidget*/
1182void 1046void
1183xwidget_start_redisplay (void) 1047xwidget_start_redisplay (void)
@@ -1192,7 +1056,6 @@ xwidget_start_redisplay (void)
1192void 1056void
1193xwidget_touch (struct xwidget_view *xw) 1057xwidget_touch (struct xwidget_view *xw)
1194{ 1058{
1195 //printf("touch xwidget %d\n", xw->id);
1196 xw->redisplayed = 1; 1059 xw->redisplayed = 1;
1197} 1060}
1198 1061
@@ -1203,7 +1066,6 @@ xwidget_touched (struct xwidget_view *xw)
1203} 1066}
1204 1067
1205/* redisplay has ended, now we should hide untouched xwidgets 1068/* redisplay has ended, now we should hide untouched xwidgets
1206
1207*/ 1069*/
1208void 1070void
1209xwidget_end_redisplay (struct glyph_matrix *matrix) 1071xwidget_end_redisplay (struct glyph_matrix *matrix)
@@ -1213,7 +1075,7 @@ xwidget_end_redisplay (struct glyph_matrix *matrix)
1213 struct xwidget *xw; 1075 struct xwidget *xw;
1214 int area; 1076 int area;
1215 1077
1216 region_modified = 0; 1078
1217 xwidget_start_redisplay (); 1079 xwidget_start_redisplay ();
1218 //iterate desired glyph matrix of "live" window here, hide gtk widgets 1080 //iterate desired glyph matrix of "live" window here, hide gtk widgets
1219 //not in the desired matrix. 1081 //not in the desired matrix.
@@ -1279,10 +1141,4 @@ xwidget_end_redisplay (struct glyph_matrix *matrix)
1279 } 1141 }
1280} 1142}
1281 1143
1282/* some type of modification was made to the buffers(unused)*/
1283void
1284xwidget_modify_region (void)
1285{
1286 region_modified = 1;
1287}
1288 1144