aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-04-09 00:22:55 +0200
committerJoakim Verona2013-04-09 00:22:55 +0200
commit7744b1dba9cb0a83cea2abbc64932a93f28a82e0 (patch)
tree4d28dc9f1eb77ff5fd244f382e7b48ee845be162
parente25d341cec1ebaee2b96d627d99d4d7b92dee6b0 (diff)
parenta1c060aa21c3d17e5cca7f730d8fead6746bd29c (diff)
downloademacs-7744b1dba9cb0a83cea2abbc64932a93f28a82e0.tar.gz
emacs-7744b1dba9cb0a83cea2abbc64932a93f28a82e0.zip
funny diverged branches
-rw-r--r--README.xwidget102
-rw-r--r--lisp/xwidget-test.el9
-rw-r--r--src/xwidget.c103
3 files changed, 146 insertions, 68 deletions
diff --git a/README.xwidget b/README.xwidget
index 6ca6f1a62ca..1abc8f843e2 100644
--- a/README.xwidget
+++ b/README.xwidget
@@ -404,7 +404,9 @@ Missing separate debuginfos, use: debuginfo-install hunspell-1.2.15-2.fc15.x86_6
404 CLOSED: [2011-07-19 Tue 14:26] 404 CLOSED: [2011-07-19 Tue 14:26]
405now we just hard code sizes. but webkit widgets for instance can 405now we just hard code sizes. but webkit widgets for instance can
406report sizes that suit the content. support that. 406report sizes that suit the content. support that.
407** TODO BUG xwidget view ghosts 407** DONE BUG xwidget view ghosts
408 CLOSED: [2013-04-05 Fri 23:35]
409(havent seen this in quite a while)
408- xwidget-webkit-browse-url somewhere 410- xwidget-webkit-browse-url somewhere
409- split window. 411- split window.
410now theres 2 webkit views 412now theres 2 webkit views
@@ -929,7 +931,9 @@ http://developer.gnome.org/gdk/stable/gdk-Windows.html#GdkWindow-from-embedder
929turned out to be not so hard, captured events, copied them and 931turned out to be not so hard, captured events, copied them and
930forwarded them offscreen! 932forwarded them offscreen!
931 933
932** TODO investigate gdk_window_redirect_to_drawable 934** CANCELLED investigate gdk_window_redirect_to_drawable
935 CLOSED: [2013-04-05 Fri 23:37]
936(cancelled this, the current approach seems okay)
933http://developer.gnome.org/gdk/stable/gdk-Windows.html#gdk-offscreen-window-set-embedder 937http://developer.gnome.org/gdk/stable/gdk-Windows.html#gdk-offscreen-window-set-embedder
934maybe could be used in place of my own copy hacks? to work it must 938maybe could be used in place of my own copy hacks? to work it must
935support a chain of redirects, which seems unlikely. the benefit would 939support a chain of redirects, which seems unlikely. the benefit would
@@ -1397,7 +1401,9 @@ isn't needed if emacs bg erase disabled
1397might be some annoying local issues with my install because it is not 1401might be some annoying local issues with my install because it is not
1398reliably reproducible. (went away during merges) 1402reliably reproducible. (went away during merges)
1399 1403
1400** TODO low impact xwidget based image viewer 1404** CANCELLED low impact xwidget based image viewer
1405 CLOSED: [2013-04-05 Fri 23:38]
1406(cancelled this because it no longer seems like a good idea)
1401for instance to render SVG using webkit, or some other canvas. 1407for instance to render SVG using webkit, or some other canvas.
1402that way it would be possible to merge to trunk in stages. 1408that way it would be possible to merge to trunk in stages.
1403 1409
@@ -1558,7 +1564,6 @@ when an xwidget is removed from xwidget-alist, and there are no other
1558references(mostly views) the xwidget should be garbage collected. 1564references(mostly views) the xwidget should be garbage collected.
1559 1565
1560special finalization would go into gc_sweep() 1566special finalization would go into gc_sweep()
1561<<<<<<< TREE
1562** TODO embedding evince 1567** TODO embedding evince
1563http://developer.gnome.org/libevview/3.2/libevview-ev-view.html 1568http://developer.gnome.org/libevview/3.2/libevview-ev-view.html
1564would be useful for reading PDF:s and other document types. 1569would be useful for reading PDF:s and other document types.
@@ -1622,4 +1627,91 @@ Current limitation:
1622- next to no argument checking. If wrong type args are used with the 1627- next to no argument checking. If wrong type args are used with the
1623 xwgir methods, emacs crashes. 1628 xwgir methods, emacs crashes.
1624 1629
1625 1630*** TODO xwgir create components with more advanced constructor
1631so this opens up an entire new can of beans.
1632
1633explain by example:
1634lets say we want to create agtkhscale on screen. its a slider.
1635https://developer.gnome.org/gtk3/stable/GtkHScale.html
1636we can already create buttons, so sliders shouldnt be much more
1637advanced right? wrong.
1638
1639the simplest slider constructor looks like:
1640GtkWidget * gtk_hscale_new
1641(GtkAdjustment *adjustment);
1642
1643so in order to call it, we must be able to forward arguments to the
1644constructor. this is almost already done, but we lack the ability to
1645pass object instances, only simple types atm.
1646
1647we need to be able to create GtkAdjustment
1648https://developer.gnome.org/gtk3/stable/GtkAdjustment.html
1649
1650this we can already almost do, because an xwidget is a gir object
1651with some decorations. we also store the decorated gir object in an
1652array, retrievable from lisp.
1653
1654In order for this to be usable in practice, we need some changes:
1655- lightweight objects should be stored un-decorated. they have no
1656 need for the entire graphical machinery of xwidgets
1657- lightweight objects should be garbage collectable, but this is the
1658 same for all the xwidget objects, and isnt really resolved atm.
1659
1660
1661** DONE investigate gdk_offscreen_window_set_embedder()
1662 CLOSED: [2013-04-06 Sat 10:45]
1663https://developer.gnome.org/gdk/unstable/gdk-Windows.html
1664
1665,----
1666| Offscreen windows are more general than composited windows, since they
1667| allow not only to modify the rendering of the child window onto its
1668| parent, but also to apply coordinate transformations.
1669|
1670| To integrate an offscreen window into a window hierarchy, one has to
1671| call gdk_offscreen_window_set_embedder() and handle a number of
1672| signals. The "pick-embedded-child" signal on the embedder window is
1673| used to select an offscreen child at given coordinates, and the
1674| "to-embedder" and "from-embedder" signals on the offscreen window are
1675| used to translate coordinates between the embedder and the offscreen
1676| window.
1677|
1678| For rendering an offscreen window onto its embedder, the contents of
1679| the offscreen window are available as a pixmap, via
1680| gdk_offscreen_window_get_pixmap().
1681`----
1682
1683okay, [2013-04-03 Wed] I finally suceeded in this approach!
1684it was pretty hard to make it work and currently works like this:
1685- the on screen dravwing area is the embedder
1686- you must implement "pick child"
1687event forwarding is done automatically!
1688
1689BUT its not really super, because it only works well with a single
1690embedder.
1691
1692perhaps the strategy could be refined:
1693- the window frame would be the embedder for all xwidgets. (but what
1694 about several frames then?)
1695- in the from-embedder signal handler, which maps container coords to
1696 embedded widget coords, find out which xw-view i clicked on, and
1697 compute the coords.
1698
1699[2013-04-04 Thu] I had a strategy working for a xwgir button but not
1700a webkit. set_embedded in the motion event handler for the xv. it
1701even works for 2 frames! but not webkit :(
1702
1703[2013-04-05 Fri] it works for xwgir osr components, but not for
1704webkit. Webkit retains the previous event forwarding system.
1705
1706Now it works like this:
1707- the offscreen widget is created as before
1708- the on-screen views also as before, painting and copying as before.
1709- gdk_offscreen_window_set_embedder() is now used to embedd the
1710 offscreen widget in the onscreen one, upon view creation
1711- only one widget can embedd one other. This means that the embedding
1712 widget must be switched between the onscreen ones. This is now done
1713 in the mouse motion event handler.
1714
1715The above approach has been tested for xwgir created buttons and seems
1716to work. it doesnt work for webkit, so the old scheme is preserved
1717for webkit.
diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el
index ba434f3d79a..07b841bdc94 100644
--- a/lisp/xwidget-test.el
+++ b/lisp/xwidget-test.el
@@ -88,7 +88,7 @@
88 (put 'xwgirButton :xwgir-class '("Gtk" "Button")) 88 (put 'xwgirButton :xwgir-class '("Gtk" "Button"))
89 89
90 (xwidget-insert (point-min) 'xwgirButton "xwgir label didnt work..." 700 700) 90 (xwidget-insert (point-min) 'xwgirButton "xwgir label didnt work..." 700 700)
91 (xwgir-call-method (xwidget-at 1) "set_label" '( "xwgir label worked!")) 91 (xwgir-xwidget-call-method (xwidget-at 1) "set_label" '( "xwgir label worked!"))
92 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) 92 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
93 93
94(xwidget-demo "a-xwgir-check-button" 94(xwidget-demo "a-xwgir-check-button"
@@ -98,6 +98,13 @@
98 (xwidget-insert (point-min) 'xwgirCheckButton "xwgir label didnt work..." 700 700) 98 (xwidget-insert (point-min) 'xwgirCheckButton "xwgir label didnt work..." 700 700)
99 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) 99 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
100 100
101(xwidget-demo "a-xwgir-hscale"
102 (xwgir-require-namespace "Gtk" "3.0")
103 (put 'xwgirHScale :xwgir-class '("Gtk" "HScale"))
104
105 (xwidget-insert (point-min) 'xwgirHScale "xwgir label didnt work..." 700 700)
106 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
107
101(xwidget-demo "a-xwgir-webkit" 108(xwidget-demo "a-xwgir-webkit"
102 (xwgir-require-namespace "WebKit" "3.0") 109 (xwgir-require-namespace "WebKit" "3.0")
103 (put 'xwgirWebkit :xwgir-class '("WebKit" "WebView")) 110 (put 'xwgirWebkit :xwgir-class '("WebKit" "WebView"))
diff --git a/src/xwidget.c b/src/xwidget.c
index c6714ad40a5..d169069c99d 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -238,11 +238,6 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0,
238 xw->widget_osr = xwgir_create( SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))), 238 xw->widget_osr = xwgir_create( SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))),
239 SDATA(Fcar(Fget(xw->type, Qcxwgir_class)))); 239 SDATA(Fcar(Fget(xw->type, Qcxwgir_class))));
240 240
241 ///debug xwgir
242 /* gdk_offscreen_window_set_embedder ( gtk_widget_get_window (xw->widget_osr), */
243 /* gtk_widget_get_window (GTK_WIDGET (xw->widgetwindow_osr)) */
244 /* ); */
245 ///
246 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); 241 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height);
247 gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); 242 gtk_container_add (xw->widgetwindow_osr, xw->widget_osr);
248 243
@@ -254,9 +249,6 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0,
254 /* signals */ 249 /* signals */
255 g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); 250 g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL);
256 251
257 //TODO these were just a test hack
258 /* g_signal_connect (G_OBJECT ( xw->widget_osr), "key-press-event", G_CALLBACK (webkit_osr_key_event_callback), NULL); */
259 /* g_signal_connect (G_OBJECT ( xw->widget_osr), "key-release-event", G_CALLBACK (webkit_osr_key_event_callback), NULL); */
260 252
261 if (EQ(xw->type, Qwebkit_osr)){ 253 if (EQ(xw->type, Qwebkit_osr)){
262 g_signal_connect (G_OBJECT ( xw->widget_osr), 254 g_signal_connect (G_OBJECT ( xw->widget_osr),
@@ -303,56 +295,6 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0,
303 } 295 }
304#endif 296#endif
305 297
306 /* if (EQ(xw->type, Qsocket_osr)){ */
307 /* printf("init socket osr\n"); */
308 /* block_input(); */
309 /* xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ()); */
310 /* gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); */
311
312 /* //////////////////// */
313 /* //xw->widget_osr = webkit_web_view_new(); */
314 /* xw->widget_osr = gtk_socket_new(); */
315 /* //g_signal_connect_after(xv->widget, "plug-added", G_CALLBACK(xwidget_plug_added), "plug added"); */
316 /* //g_signal_connect_after(xv->widget, "plug-removed", G_CALLBACK(xwidget_plug_removed), "plug removed"); */
317 /* /////////////////// */
318
319 /* gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); */
320 /* gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); */
321
322 /* gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); */
323
324 /* /\* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. *\/ */
325 /* g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); */
326 /* g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); */
327 /* g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); */
328
329 /* //webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org"); */
330 /* unblock_input(); */
331
332 /* } */
333
334
335 /* ////////////////////////////// */
336 /* gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); */
337 /* gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); */
338
339 /* gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); */
340
341 /* /\* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. *\/ */
342 /* g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); */
343 /* g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); */
344 /* /\* signals *\/ */
345 /* g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); */
346 /* g_signal_connect (G_OBJECT ( xw->widget_osr), "button-press-event", G_CALLBACK (xwgir_event_callback), xw); */
347
348
349 /* unblock_input(); */
350 /* } */
351
352 ////////////////////////////////////////////////////////
353
354
355
356 UNGCPRO; 298 UNGCPRO;
357 return val; 299 return val;
358} 300}
@@ -522,7 +464,7 @@ webkit_osr_key_event_callback (GtkWidget *widget, GdkEventKey *event, gpointer d
522 464
523 465
524void 466void
525store_xwidget_event_string(struct xwidget* xw, char* eventname,char* eventstr) 467store_xwidget_event_string(struct xwidget* xw, char* eventname, const char* eventstr)
526{ 468{
527 //refactor attempt 469 //refactor attempt
528 struct input_event event; 470 struct input_event event;
@@ -816,7 +758,43 @@ xwgir_convert_lisp_to_gir_arg(GIArgument* giarg,
816 return 0; 758 return 0;
817} 759}
818 760
819DEFUN ("xwgir-call-method", Fxwgir_call_method, Sxwgir_call_method, 3, 3, 0, 761#if 0
762void
763refactor_attempt(){
764 //this methhod should be called from xwgir-xwidget-call-method and from xwgir xwidget construction
765 char* class = SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class))));
766
767 GIObjectInfo* obj_info = g_irepository_find_by_name(girepository, namespace, class);
768 GIFunctionInfo* f_info = g_object_info_find_method (obj_info, SDATA(method));
769
770 //loop over args, convert from lisp to primitive type, given arg introspection data
771 //TODO g_callable_info_get_n_args(f_info) should match
772 int argscount = XFASTINT(Flength(arguments));
773 if(argscount != g_callable_info_get_n_args(f_info)){
774 printf("xwgir call method arg count doesn match! \n");
775 return Qnil;
776 }
777 int i;
778 for (i = 1; i < argscount + 1; ++i)
779 {
780 xwgir_convert_lisp_to_gir_arg(&in_args[i], g_callable_info_get_arg(f_info, i - 1), Fnth(i - 1, arguments));
781 }
782
783 in_args[0].v_pointer = widget;
784 if(g_function_info_invoke(f_info,
785 in_args, argscount + 1,
786 NULL, 0,
787 &return_value,
788 &error)) {
789 //g_error("ERROR: %s\n", error->message);
790 printf("invokation error\n");
791 return Qnil;
792 }
793 return Qt;
794}
795#endif
796
797DEFUN ("xwgir-xwidget-call-method", Fxwgir_xwidget_call_method, Sxwgir_xwidget_call_method, 3, 3, 0,
820 doc: /* call xwidget object method.*/) 798 doc: /* call xwidget object method.*/)
821 (Lisp_Object xwidget, Lisp_Object method, Lisp_Object arguments) 799 (Lisp_Object xwidget, Lisp_Object method, Lisp_Object arguments)
822{ 800{
@@ -1406,7 +1384,8 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0, doc:
1406 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); //minimum size 1384 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); //minimum size
1407 //gtk_window_resize( GTK_WINDOW(xw->widget_osr), xw->width, xw->height); 1385 //gtk_window_resize( GTK_WINDOW(xw->widget_osr), xw->width, xw->height);
1408 gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); 1386 gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height);
1409 gtk_container_resize_children ( GTK_WINDOW(xw->widgetwindow_osr)); 1387 //gtk_container_resize_children ( GTK_WINDOW(xw->widgetwindow_osr));
1388 gtk_container_resize_children ( GTK_CONTAINER(xw->widgetwindow_osr));
1410 1389
1411 } 1390 }
1412 1391
@@ -1620,7 +1599,7 @@ syms_of_xwidget (void)
1620 DEFSYM (Qwebkit_osr ,"webkit-osr"); 1599 DEFSYM (Qwebkit_osr ,"webkit-osr");
1621#endif 1600#endif
1622 1601
1623 defsubr (&Sxwgir_call_method ); 1602 defsubr (&Sxwgir_xwidget_call_method );
1624 defsubr (&Sxwgir_require_namespace); 1603 defsubr (&Sxwgir_require_namespace);
1625 defsubr (&Sxwidget_size_request ); 1604 defsubr (&Sxwidget_size_request );
1626 defsubr (&Sxwidget_delete_zombies); 1605 defsubr (&Sxwidget_delete_zombies);