diff options
| author | Joakim Verona | 2013-06-12 23:37:36 +0200 |
|---|---|---|
| committer | Joakim Verona | 2013-06-12 23:37:36 +0200 |
| commit | bfa52886b98804a3e1440a03c4c07490568e6407 (patch) | |
| tree | 0d26aa6a7a78a38173f06d48200d9e62d986d468 | |
| parent | dd7febaa6c58b6c0163ab0f7344ea70b51614460 (diff) | |
| parent | 32a590b04a10f6bbe92bc1519b9e5ba2d32cfabc (diff) | |
| download | emacs-bfa52886b98804a3e1440a03c4c07490568e6407.tar.gz emacs-bfa52886b98804a3e1440a03c4c07490568e6407.zip | |
Merge branch 'xwidget' of https://github.com/daimrod/xwidget-emacs into xwidget
| -rw-r--r-- | README.xwidget | 44 | ||||
| -rw-r--r-- | configure.ac | 26 | ||||
| -rw-r--r-- | lisp/xwidget-test.el | 2 | ||||
| -rw-r--r-- | lisp/xwidget.el | 240 | ||||
| -rw-r--r-- | src/Makefile.in | 3 | ||||
| -rw-r--r-- | src/emacsgtkfixed.c | 2 | ||||
| -rw-r--r-- | src/xwidget.c | 272 | ||||
| -rw-r--r-- | src/xwidget.h | 2 |
8 files changed, 265 insertions, 326 deletions
diff --git a/README.xwidget b/README.xwidget index f631ea04ad8..a4c49b10250 100644 --- a/README.xwidget +++ b/README.xwidget | |||
| @@ -123,7 +123,7 @@ we provide proper sizes and so on back to the redisplay engine. | |||
| 123 | The problem is that Emacs cant actually draw the widgets, as it can with | 123 | The problem is that Emacs cant actually draw the widgets, as it can with |
| 124 | images. Emacs must notify GTK about where the widgets should be, and how they | 124 | images. Emacs must notify GTK about where the widgets should be, and how they |
| 125 | should be clipped and so on, and this information must be given to GTK | 125 | should be clipped and so on, and this information must be given to GTK |
| 126 | synchonous with Emacs display changes. Ok, so why is that difficult then? | 126 | synchronous with Emacs display changes. Ok, so why is that difficult then? |
| 127 | 127 | ||
| 128 | - How do we know when a widget is NOT to be drawn? The only way I found so far | 128 | - How do we know when a widget is NOT to be drawn? The only way I found so far |
| 129 | is having a flag for each xwdiget, that is reset before a redisplay. When an | 129 | is having a flag for each xwdiget, that is reset before a redisplay. When an |
| @@ -200,9 +200,9 @@ xembed host widget that allows for embedding other applications inside | |||
| 200 | an Emacs window, the story gets more complex. | 200 | an Emacs window, the story gets more complex. |
| 201 | 201 | ||
| 202 | The problem is that xembed is designed to plug an application window | 202 | The problem is that xembed is designed to plug an application window |
| 203 | inside a a secket and thats it. You can't move a plug between | 203 | inside a socket and thats it. You can't move a plug between |
| 204 | sockets. I tried numerous hacks to get around this but there is | 204 | sockets. I tried numerous hacks to get around this but there is |
| 205 | nothing that works realy well. | 205 | nothing that works really well. |
| 206 | 206 | ||
| 207 | Therefore the Emacs part of the code will only expose well-defined | 207 | Therefore the Emacs part of the code will only expose well-defined |
| 208 | interfaces. cooperating applications will be able to use the interface | 208 | interfaces. cooperating applications will be able to use the interface |
| @@ -217,14 +217,14 @@ multi view xembed function. That way Emacs is sane and the insanity | |||
| 217 | contained. | 217 | contained. |
| 218 | 218 | ||
| 219 | This app will work by providing a socket that an app plugs into. The | 219 | This app will work by providing a socket that an app plugs into. The |
| 220 | socket window is copied efficientlp by means of composition to a | 220 | socket window is copied efficiently by means of composition to a |
| 221 | number of other windows, that then are plugged into the different | 221 | number of other windows, that are then plugged into the different |
| 222 | Emacs sockets. | 222 | Emacs sockets. |
| 223 | ** old notes from x_draw_xwidget_glyph_string | 223 | ** old notes from x_draw_xwidget_glyph_string |
| 224 | 224 | ||
| 225 | BUG it seems this method for some reason is called with bad s->x and s->y sometimes. | 225 | BUG it seems this method for some reason is called with bad s->x and s->y sometimes. |
| 226 | When this happens the xwidget doesnt move on screen as it should. | 226 | When this happens the xwidget doesnt move on screen as it should. |
| 227 | This mightbe because of x_scroll_run. Emacs decides to scroll the screen by blitting sometimes. | 227 | This might be because of x_scroll_run. Emacs decides to scroll the screen by blitting sometimes. |
| 228 | then emacs doesnt try to actualy call the paint routines, which means this here code will never | 228 | then emacs doesnt try to actualy call the paint routines, which means this here code will never |
| 229 | run so the xwidget wont know it has been moved. | 229 | run so the xwidget wont know it has been moved. |
| 230 | 230 | ||
| @@ -235,7 +235,7 @@ Emacs sockets. | |||
| 235 | always available in an off-screen buffer. My current attempt at composition doesnt work properly however. | 235 | always available in an off-screen buffer. My current attempt at composition doesnt work properly however. |
| 236 | 236 | ||
| 237 | //allocation debugging. the correct values cant be expected to show upp immediately, but eventually they should get to be ok | 237 | //allocation debugging. the correct values cant be expected to show upp immediately, but eventually they should get to be ok |
| 238 | // this is because we dont know when the container gets around to doing layout | 238 | // this is because we dont know when the container gets around to do layout |
| 239 | //GtkAllocation galloc; | 239 | //GtkAllocation galloc; |
| 240 | //gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc); | 240 | //gtk_widget_get_allocation(GTK_WIDGET (xv->widgetwindow), &galloc); |
| 241 | //printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height); | 241 | //printf("allocation %d %d , %d %d\n", galloc.x,galloc.y,galloc.width,galloc.height); |
| @@ -244,7 +244,7 @@ Emacs sockets. | |||
| 244 | *** old notes about the old live/phantom scheme | 244 | *** old notes about the old live/phantom scheme |
| 245 | 245 | ||
| 246 | //TODO: | 246 | //TODO: |
| 247 | // 1) always draw live xwidget in slected window | 247 | // 1) always draw live xwidget in selected window |
| 248 | // (2) if there were no live instances of the xwidget in selected window, also draw it live) | 248 | // (2) if there were no live instances of the xwidget in selected window, also draw it live) |
| 249 | // 3) if there was a live xwidget previously, now phantom it. | 249 | // 3) if there was a live xwidget previously, now phantom it. |
| 250 | 250 | ||
| @@ -549,7 +549,7 @@ hangs. | |||
| 549 | 549 | ||
| 550 | http://kegel.com/gtk/button.c | 550 | http://kegel.com/gtk/button.c |
| 551 | 551 | ||
| 552 | *** TODO examine some library to synthesise events | 552 | *** TODO examine some library to synthesize events |
| 553 | xdotool | 553 | xdotool |
| 554 | xte xautomation | 554 | xte xautomation |
| 555 | crikey | 555 | crikey |
| @@ -643,7 +643,7 @@ the other aproach would be to work more like images: | |||
| 643 | xwidget. | 643 | xwidget. |
| 644 | - retrieve the xwidget objet from the spec with an xwidget-at-point function. It | 644 | - retrieve the xwidget objet from the spec with an xwidget-at-point function. It |
| 645 | can be uninitalized which client code must handle. Unlike | 645 | can be uninitalized which client code must handle. Unlike |
| 646 | assynchronous process creation we dont get back a handle, because | 646 | asynchronous process creation we dont get back a handle, because |
| 647 | there is none yet. | 647 | there is none yet. |
| 648 | - emitted event on initialization, when needed. Many widgets don't | 648 | - emitted event on initialization, when needed. Many widgets don't |
| 649 | need this. for instance, a button sends an event when pressed. but | 649 | need this. for instance, a button sends an event when pressed. but |
| @@ -833,7 +833,7 @@ anyway clipping is rather complicated but seems to finally work okay. | |||
| 833 | CLOSED: [2011-07-04 Mon 16:55] | 833 | CLOSED: [2011-07-04 Mon 16:55] |
| 834 | http://www.lanedo.com/~carlos/gtk3-doc/GtkWidget.html#gtk-widget-set-has-window | 834 | http://www.lanedo.com/~carlos/gtk3-doc/GtkWidget.html#gtk-widget-set-has-window |
| 835 | mentions that it has_window can only be called inside a widget | 835 | mentions that it has_window can only be called inside a widget |
| 836 | impementation. | 836 | implementation. |
| 837 | 837 | ||
| 838 | this wasnt really the issue. allocation was the problem | 838 | this wasnt really the issue. allocation was the problem |
| 839 | *** DONE try scrolled window | 839 | *** DONE try scrolled window |
| @@ -924,7 +924,7 @@ see: | |||
| 924 | I returned to using a simple gtkfixed for the widgetwindow. with | 924 | I returned to using a simple gtkfixed for the widgetwindow. with |
| 925 | allocation hack and set_has_window it works. Idea prefer not to have | 925 | allocation hack and set_has_window it works. Idea prefer not to have |
| 926 | the allocatien hack and it wasnt needed it gtk3 only gtk2. needs | 926 | the allocatien hack and it wasnt needed it gtk3 only gtk2. needs |
| 927 | furthi investigation, | 927 | further investigation. |
| 928 | 928 | ||
| 929 | ** various code cleanups | 929 | ** various code cleanups |
| 930 | There are many cleanups necessary before any hope of inclusion in | 930 | There are many cleanups necessary before any hope of inclusion in |
| @@ -1015,9 +1015,9 @@ crash in gtk_window_get_size instead. great. | |||
| 1015 | 1015 | ||
| 1016 | http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscreenwindow_8c-source.html | 1016 | http://gtkplus-p3.0.sourcearchive.com/documentation/2.91.5-0ubuntu1/testoffscreenwindow_8c-source.html |
| 1017 | 1017 | ||
| 1018 | after many atempts, the basic issue remains. for some reason the | 1018 | after many attempts, the basic issue remains. for some reason the |
| 1019 | offscreen widget isnt ok when I want to snapshot it, so i simply get | 1019 | offscreen widget isnt ok when I want to snapshot it, so i simply get |
| 1020 | emptiness. the surface is only ok someimes. | 1020 | emptiness. the surface is only ok sometimes. |
| 1021 | 1021 | ||
| 1022 | here is a useful debugging snippets: | 1022 | here is a useful debugging snippets: |
| 1023 | #+begin_src C | 1023 | #+begin_src C |
| @@ -1062,7 +1062,7 @@ seems to be severly bitrotted | |||
| 1062 | heres a newer aproach | 1062 | heres a newer aproach |
| 1063 | http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp | 1063 | http://hg.mozilla.org/incubator/embedding/file/29ac0fe51754/gtk/tests/test.cpp |
| 1064 | 1064 | ||
| 1065 | while webkit clearly has the best traction as an embeddee, the | 1065 | while webkit clearly has the best traction as an embedded, the |
| 1066 | offscreen rendering issues makes it interesting to see what ff brings | 1066 | offscreen rendering issues makes it interesting to see what ff brings |
| 1067 | to the table. | 1067 | to the table. |
| 1068 | 1068 | ||
| @@ -1102,7 +1102,7 @@ maybe | |||
| 1102 | https://launchpad.net/gnome-seed | 1102 | https://launchpad.net/gnome-seed |
| 1103 | 1103 | ||
| 1104 | or this funny hack: | 1104 | or this funny hack: |
| 1105 | <jave> im trying to understanh how to interact via javascript to an embedded | 1105 | <jave> im trying to understand how to interact via javascript to an embedded |
| 1106 | webkit gtk instance [23:38] | 1106 | webkit gtk instance [23:38] |
| 1107 | <jave> i use webkit_web_view_execute_script() which is nice but doesnt return | 1107 | <jave> i use webkit_web_view_execute_script() which is nice but doesnt return |
| 1108 | a value, by design aparently [23:39] | 1108 | a value, by design aparently [23:39] |
| @@ -1141,7 +1141,7 @@ easy. | |||
| 1141 | ** webkit related | 1141 | ** webkit related |
| 1142 | *** TODO webkit support webkit signals | 1142 | *** TODO webkit support webkit signals |
| 1143 | 1143 | ||
| 1144 | **** DONE particularily document-load-finished | 1144 | **** DONE particularly document-load-finished |
| 1145 | CLOSED: [2011-08-01 Mon 22:34] | 1145 | CLOSED: [2011-08-01 Mon 22:34] |
| 1146 | http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished | 1146 | http://webkitgtk.org/reference/webkitgtk-webkitwebview.html#WebKitWebView-document-load-finished |
| 1147 | because one might need tell set a title and sizes and things when it loads. | 1147 | because one might need tell set a title and sizes and things when it loads. |
| @@ -1377,7 +1377,7 @@ Maybe a new image type could be added that was a wraper on an | |||
| 1377 | xwidget. Then image mode could be reused for webkit mode. | 1377 | xwidget. Then image mode could be reused for webkit mode. |
| 1378 | 1378 | ||
| 1379 | I tried some adaptor code in xwidget.el so webkit mode now delegates | 1379 | I tried some adaptor code in xwidget.el so webkit mode now delegates |
| 1380 | to image mode buh its a kludge. | 1380 | to image mode but its a kludge. |
| 1381 | 1381 | ||
| 1382 | ** socket related | 1382 | ** socket related |
| 1383 | *** TODO some flickering during redisplay of sockets | 1383 | *** TODO some flickering during redisplay of sockets |
| @@ -1387,13 +1387,13 @@ xwidget socket type. The webkit xwidget doesn't seem similarily | |||
| 1387 | afflicted. | 1387 | afflicted. |
| 1388 | 1388 | ||
| 1389 | the size allocation workaround works by 1st running the ordinary | 1389 | the size allocation workaround works by 1st running the ordinary |
| 1390 | allocation then modifying the results. its done this way to minimise | 1390 | allocation then modifying the results. its done this way to minimize |
| 1391 | the copy paste index from the base class. it might be that the | 1391 | the copy paste index from the base class. it might be that the |
| 1392 | original allocation has a brief time window to show itself. | 1392 | original allocation has a brief time window to show itself. |
| 1393 | 1393 | ||
| 1394 | tried to modify the allocation hack so it doesn't call allocate | 1394 | tried to modify the allocation hack so it doesn't call allocate |
| 1395 | twice. this doesn't seem to help flicker at all aparently so the | 1395 | twice. this doesn't seem to help flicker at all aparently so the |
| 1396 | hypothesis falls. Maybe then a socket simply doesn't lke being clipped | 1396 | hypothesis falls. Maybe then a socket simply doesn't like being clipped |
| 1397 | by gtkfixed. | 1397 | by gtkfixed. |
| 1398 | 1398 | ||
| 1399 | *** TODO xwidget view reaping too agressive | 1399 | *** TODO xwidget view reaping too agressive |
| @@ -1436,7 +1436,7 @@ suspects: | |||
| 1436 | - XCopyArea | 1436 | - XCopyArea |
| 1437 | - x_shift_glyphs_for_insert | 1437 | - x_shift_glyphs_for_insert |
| 1438 | - x_scroll_run. this is run by the try_window* functions, and | 1438 | - x_scroll_run. this is run by the try_window* functions, and |
| 1439 | inhibiting them dösnt help. but also callid in scrolling_window. | 1439 | inhibiting them doesnt help. but also callid in scrolling_window. |
| 1440 | 1440 | ||
| 1441 | 1441 | ||
| 1442 | - try_window_reusing_current_matrix | 1442 | - try_window_reusing_current_matrix |
| @@ -1454,7 +1454,7 @@ workaround: | |||
| 1454 | (run-with-timer 1 1 'redraw-display) | 1454 | (run-with-timer 1 1 'redraw-display) |
| 1455 | 1455 | ||
| 1456 | seems to work: | 1456 | seems to work: |
| 1457 | inhibiting scrolling_window(). and this seem to be enaugh to restore | 1457 | inhibiting scrolling_window(). and this seem to be enough to restore the |
| 1458 | old behaviour, GLYPH_DEBUG doesn't seem needed. | 1458 | old behaviour, GLYPH_DEBUG doesn't seem needed. |
| 1459 | 1459 | ||
| 1460 | 1460 | ||
diff --git a/configure.ac b/configure.ac index 67015b19e36..4a676ba6b6f 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -2208,8 +2208,6 @@ fi | |||
| 2208 | 2208 | ||
| 2209 | HAVE_XWIDGETS=no | 2209 | HAVE_XWIDGETS=no |
| 2210 | HAVE_WEBKIT=no | 2210 | HAVE_WEBKIT=no |
| 2211 | HAVE_GOOCANVAS=no | ||
| 2212 | HAVE_CLUTTER=no | ||
| 2213 | HAVE_GIR=no | 2211 | HAVE_GIR=no |
| 2214 | 2212 | ||
| 2215 | if test "${with_xwidgets}" != "no"; then | 2213 | if test "${with_xwidgets}" != "no"; then |
| @@ -2219,7 +2217,7 @@ if test "${with_xwidgets}" != "no"; then | |||
| 2219 | #xwidgets | 2217 | #xwidgets |
| 2220 | #TODO | 2218 | #TODO |
| 2221 | # - enable only if gtk/gtk3 enabled | 2219 | # - enable only if gtk/gtk3 enabled |
| 2222 | # - webkit, goocanvas, clutter | 2220 | # - webkit |
| 2223 | # - only webkit_osr is good so remove plain webkit laterish | 2221 | # - only webkit_osr is good so remove plain webkit laterish |
| 2224 | 2222 | ||
| 2225 | #webkit version for gtk3. | 2223 | #webkit version for gtk3. |
| @@ -2233,26 +2231,6 @@ if test "${with_xwidgets}" != "no"; then | |||
| 2233 | fi | 2231 | fi |
| 2234 | fi | 2232 | fi |
| 2235 | 2233 | ||
| 2236 | if test "${with_xwdemo}" = "yes"; then | ||
| 2237 | #clutter and goocanvas are just proof of concept so disable for now | ||
| 2238 | CLUTTER_REQUIRED=1.0.0 | ||
| 2239 | CLUTTER_MODULES="clutter-gtk-1.0 >= $CLUTTER_REQUIRED" | ||
| 2240 | |||
| 2241 | PKG_CHECK_MODULES(CLUTTER, $CLUTTER_MODULES, HAVE_CLUTTER=yes, HAVE_CLUTTER=no) | ||
| 2242 | if test $HAVE_CLUTTER = yes; then | ||
| 2243 | AC_DEFINE(HAVE_CLUTTER, 1, [Define to 1 if you have clutter support.]) | ||
| 2244 | fi | ||
| 2245 | |||
| 2246 | |||
| 2247 | GOOCANVAS_REQUIRED=1.4.0 | ||
| 2248 | GOOCANVAS_MODULES="goocanvasgtk-3.0 >= $GOOCANVAS_REQUIRED" | ||
| 2249 | |||
| 2250 | PKG_CHECK_MODULES(GOOCANVAS, $GOOCANVAS_MODULES, HAVE_GOOCANVAS=yes, HAVE_GOOCANVAS=no) | ||
| 2251 | if test $HAVE_GOOCANVAS = yes; then | ||
| 2252 | AC_DEFINE(HAVE_GOOCANVAS, 1, [Define to 1 if you have goocanvas support.]) | ||
| 2253 | fi | ||
| 2254 | fi | ||
| 2255 | |||
| 2256 | GIR_REQUIRED=1.32.1 | 2234 | GIR_REQUIRED=1.32.1 |
| 2257 | GIR_MODULES="gobject-introspection-1.0 >= $GIR_REQUIRED" | 2235 | GIR_MODULES="gobject-introspection-1.0 >= $GIR_REQUIRED" |
| 2258 | PKG_CHECK_MODULES(GIR, $GIR_MODULES, HAVE_GIR=yes, HAVE_GIR=no) | 2236 | PKG_CHECK_MODULES(GIR, $GIR_MODULES, HAVE_GIR=yes, HAVE_GIR=no) |
| @@ -4836,8 +4814,6 @@ echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SC | |||
| 4836 | echo " Does Emacs support Xwidgets? ${HAVE_XWIDGETS}" | 4814 | echo " Does Emacs support Xwidgets? ${HAVE_XWIDGETS}" |
| 4837 | echo " Does xwidgets support webkit(requires gtk3)? ${HAVE_WEBKIT}" | 4815 | echo " Does xwidgets support webkit(requires gtk3)? ${HAVE_WEBKIT}" |
| 4838 | echo " Does xwidgets support gobject introspection? ${HAVE_GIR}" | 4816 | echo " Does xwidgets support gobject introspection? ${HAVE_GIR}" |
| 4839 | echo " Does xwidgets support clutter(demo code)? ${HAVE_CLUTTER}" | ||
| 4840 | echo " Does xwidgets support goocanvas(demo code)? ${HAVE_GOOCANVAS}" | ||
| 4841 | echo | 4817 | echo |
| 4842 | 4818 | ||
| 4843 | if test -n "${EMACSDATA}"; then | 4819 | if test -n "${EMACSDATA}"; then |
diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el index 07b841bdc94..88d2739a209 100644 --- a/lisp/xwidget-test.el +++ b/lisp/xwidget-test.el | |||
| @@ -194,3 +194,5 @@ | |||
| 194 | ; (xwidget-resize-hack 1 200 200) | 194 | ; (xwidget-resize-hack 1 200 200) |
| 195 | 195 | ||
| 196 | ;(xwidget-demo-basic) | 196 | ;(xwidget-demo-basic) |
| 197 | |||
| 198 | (provide 'xwidget-test) | ||
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 8af8d47c00d..7e556dfa6ba 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | ;;; Commentary: | 5 | ;;; Commentary: |
| 6 | ;; | 6 | ;; |
| 7 | 7 | ||
| 8 | ;;TODO this breaks compilation when we dont have xwidgets | 8 | ;;TODO this breaks compilation when we dont have xwidgets |
| 9 | ;;(require 'xwidget-internal) | 9 | ;;(require 'xwidget-internal) |
| @@ -11,19 +11,22 @@ | |||
| 11 | ;;TODO model after make-text-button instead! | 11 | ;;TODO model after make-text-button instead! |
| 12 | ;;; Code: | 12 | ;;; Code: |
| 13 | 13 | ||
| 14 | (eval-when-compile (require 'cl)) | ||
| 15 | |||
| 14 | (defun xwidget-insert (pos type title width height) | 16 | (defun xwidget-insert (pos type title width height) |
| 15 | "Insert an xwidget at POS, given ID, TYPE, TITLE WIDTH and HEIGHT. | 17 | "Insert an xwidget at POS, given ID, TYPE, TITLE WIDTH and |
| 18 | HEIGHT in the current buffer. | ||
| 19 | |||
| 16 | Return ID | 20 | Return ID |
| 17 | 21 | ||
| 18 | see xwidget.c for types suitable for TYPE." | 22 | see `make-xwidget' for types suitable for TYPE." |
| 19 | (goto-char pos) | 23 | (goto-char pos) |
| 20 | (let ((id (make-xwidget (point) (point) type title width height nil))) | 24 | (let ((id (make-xwidget (point) (point) |
| 21 | (put-text-property (point) | 25 | type title width height nil))) |
| 22 | (+ 1 (point)) 'display (list 'xwidget ':xwidget id)) | 26 | (put-text-property (point) (+ 1 (point)) |
| 23 | 27 | 'display (list 'xwidget ':xwidget id)) | |
| 24 | id)) | 28 | id)) |
| 25 | 29 | ||
| 26 | |||
| 27 | (defun xwidget-at (pos) | 30 | (defun xwidget-at (pos) |
| 28 | "Return xwidget at POS." | 31 | "Return xwidget at POS." |
| 29 | ;;TODO this function is a bit tedious because the C layer isnt well protected yet and | 32 | ;;TODO this function is a bit tedious because the C layer isnt well protected yet and |
| @@ -31,10 +34,7 @@ see xwidget.c for types suitable for TYPE." | |||
| 31 | (let* ((disp (get-text-property pos 'display)) | 34 | (let* ((disp (get-text-property pos 'display)) |
| 32 | (xw (car (cdr (cdr disp))))) | 35 | (xw (car (cdr (cdr disp))))) |
| 33 | ;;(if ( xwidgetp xw) xw nil) | 36 | ;;(if ( xwidgetp xw) xw nil) |
| 34 | (if (equal 'xwidget (car disp)) xw) | 37 | (if (equal 'xwidget (car disp)) xw))) |
| 35 | )) | ||
| 36 | |||
| 37 | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | ;; (defun xwidget-socket-handler () | 40 | ;; (defun xwidget-socket-handler () |
| @@ -63,7 +63,7 @@ see xwidget.c for types suitable for TYPE." | |||
| 63 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 63 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 64 | ;;; webkit support | 64 | ;;; webkit support |
| 65 | (require 'browse-url) | 65 | (require 'browse-url) |
| 66 | (require 'image-mode);;for some image-mode alike functinoality | 66 | (require 'image-mode);;for some image-mode alike functionality |
| 67 | (require 'cl-macs);;for flet | 67 | (require 'cl-macs);;for flet |
| 68 | 68 | ||
| 69 | ;;;###autoload | 69 | ;;;###autoload |
| @@ -72,14 +72,14 @@ see xwidget.c for types suitable for TYPE." | |||
| 72 | NEW-SESSION specifies whether to create a new xwidget-webkit session. URL | 72 | NEW-SESSION specifies whether to create a new xwidget-webkit session. URL |
| 73 | defaults to the string looking like a url around the cursor position." | 73 | defaults to the string looking like a url around the cursor position." |
| 74 | (interactive (progn | 74 | (interactive (progn |
| 75 | (require 'browse-url) | 75 | (require 'browse-url) |
| 76 | (browse-url-interactive-arg "xwidget-webkit URL: " | 76 | (browse-url-interactive-arg "xwidget-webkit URL: " |
| 77 | ;;( xwidget-webkit-current-url) | 77 | ;;( xwidget-webkit-current-url) |
| 78 | ))) | 78 | ))) |
| 79 | (when (stringp url) | 79 | (when (stringp url) |
| 80 | (setq url (url-tidy url)) | 80 | (setq url (url-tidy url)) |
| 81 | (if new-session | 81 | (if new-session |
| 82 | (xwidget-webkit-new-session url) | 82 | (xwidget-webkit-new-session url) |
| 83 | (xwidget-webkit-goto-url url)))) | 83 | (xwidget-webkit-goto-url url)))) |
| 84 | 84 | ||
| 85 | 85 | ||
| @@ -97,7 +97,7 @@ defaults to the string looking like a url around the cursor position." | |||
| 97 | (funcall ,fn )))) | 97 | (funcall ,fn )))) |
| 98 | 98 | ||
| 99 | (defmacro xwidget-image-mode-navigation-adaptor-p (fn) | 99 | (defmacro xwidget-image-mode-navigation-adaptor-p (fn) |
| 100 | "Image code adaptor. `image-mode' FN is called with interactive arg." | 100 | "Image code adaptor. `image-mode' FN is called with interactive arg." |
| 101 | `(lambda (n) (interactive "p") | 101 | `(lambda (n) (interactive "p") |
| 102 | (cl-flet ((image-display-size (spec) (xwidget-image-display-size spec))) | 102 | (cl-flet ((image-display-size (spec) (xwidget-image-display-size spec))) |
| 103 | (funcall ,fn n)))) | 103 | (funcall ,fn n)))) |
| @@ -116,26 +116,26 @@ defaults to the string looking like a url around the cursor position." | |||
| 116 | (define-key map "w" 'xwidget-webkit-current-url) | 116 | (define-key map "w" 'xwidget-webkit-current-url) |
| 117 | 117 | ||
| 118 | ;;similar to image mode bindings | 118 | ;;similar to image mode bindings |
| 119 | (define-key map (kbd "SPC") (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) | 119 | (define-key map (kbd "SPC") (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) |
| 120 | (define-key map (kbd "DEL") (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) | 120 | (define-key map (kbd "DEL") (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) |
| 121 | 121 | ||
| 122 | (define-key map [remap scroll-up] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) | 122 | (define-key map [remap scroll-up] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) |
| 123 | (define-key map [remap scroll-up-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) | 123 | (define-key map [remap scroll-up-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) |
| 124 | 124 | ||
| 125 | (define-key map [remap scroll-down] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) | 125 | (define-key map [remap scroll-down] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) |
| 126 | (define-key map [remap scroll-down-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) | 126 | (define-key map [remap scroll-down-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) |
| 127 | 127 | ||
| 128 | (define-key map [remap forward-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) | 128 | (define-key map [remap forward-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) |
| 129 | (define-key map [remap backward-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) | 129 | (define-key map [remap backward-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) |
| 130 | (define-key map [remap right-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) | 130 | (define-key map [remap right-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) |
| 131 | (define-key map [remap left-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) | 131 | (define-key map [remap left-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) |
| 132 | (define-key map [remap previous-line] (xwidget-image-mode-navigation-adaptor-p 'image-previous-line)) | 132 | (define-key map [remap previous-line] (xwidget-image-mode-navigation-adaptor-p 'image-previous-line)) |
| 133 | (define-key map [remap next-line] (xwidget-image-mode-navigation-adaptor-p 'image-next-line)) | 133 | (define-key map [remap next-line] (xwidget-image-mode-navigation-adaptor-p 'image-next-line)) |
| 134 | 134 | ||
| 135 | (define-key map [remap move-beginning-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-bol)) | 135 | (define-key map [remap move-beginning-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-bol)) |
| 136 | (define-key map [remap move-end-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-eol)) | 136 | (define-key map [remap move-end-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-eol)) |
| 137 | (define-key map [remap beginning-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-bob)) | 137 | (define-key map [remap beginning-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-bob)) |
| 138 | (define-key map [remap end-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-eob)) | 138 | (define-key map [remap end-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-eob)) |
| 139 | map) | 139 | map) |
| 140 | "Keymap for `xwidget-webkit-mode'.") | 140 | "Keymap for `xwidget-webkit-mode'.") |
| 141 | 141 | ||
| @@ -162,42 +162,36 @@ defaults to the string looking like a url around the cursor position." | |||
| 162 | ) | 162 | ) |
| 163 | ;(funcall xwidget-callback xwidget xwidget-event-type) | 163 | ;(funcall xwidget-callback xwidget xwidget-event-type) |
| 164 | (message "xw callback %s" xwidget) | 164 | (message "xw callback %s" xwidget) |
| 165 | (funcall 'xwidget-webkit-callback xwidget xwidget-event-type) | 165 | (funcall 'xwidget-webkit-callback xwidget xwidget-event-type))) |
| 166 | )) | ||
| 167 | 166 | ||
| 168 | (defun xwidget-webkit-callback (xwidget xwidget-event-type) | 167 | (defun xwidget-webkit-callback (xwidget xwidget-event-type) |
| 169 | (save-excursion | 168 | (save-excursion |
| 170 | (cond ( (buffer-live-p (xwidget-buffer xwidget)) | 169 | (cond ((buffer-live-p (xwidget-buffer xwidget)) |
| 171 | (set-buffer (xwidget-buffer xwidget)) | 170 | (set-buffer (xwidget-buffer xwidget)) |
| 172 | (let* ( (strarg (nth 3 last-input-event))) | 171 | (let* ((strarg (nth 3 last-input-event))) |
| 173 | (cond ((eq xwidget-event-type 'document-load-finished) | 172 | (cond ((eq xwidget-event-type 'document-load-finished) |
| 174 | (xwidget-log "webkit finished loading: '%s'" (xwidget-webkit-get-title xwidget)) | 173 | (xwidget-log "webkit finished loading: '%s'" (xwidget-webkit-get-title xwidget)) |
| 175 | (xwidget-adjust-size-to-content xwidget) | 174 | (xwidget-adjust-size-to-content xwidget) |
| 176 | (rename-buffer (format "*xwidget webkit: %s *" (xwidget-webkit-get-title xwidget))) | 175 | (rename-buffer (format "*xwidget webkit: %s *" (xwidget-webkit-get-title xwidget))) |
| 177 | (pop-to-buffer (current-buffer)) | 176 | (pop-to-buffer (current-buffer))) |
| 178 | ) | 177 | ((eq xwidget-event-type 'navigation-policy-decision-requested) |
| 179 | 178 | (if (string-match ".*#\\(.*\\)" strarg) | |
| 180 | ((eq xwidget-event-type 'navigation-policy-decision-requested) | 179 | (xwidget-webkit-show-id-or-named-element xwidget (match-string 1 strarg)))) |
| 181 | (if (string-match ".*#\\(.*\\)" strarg) | 180 | (t (xwidget-log "unhandled event:%s" xwidget-event-type))))) |
| 182 | (xwidget-webkit-show-id-or-named-element xwidget (match-string 1 strarg)))) | ||
| 183 | (t (xwidget-log "unhandled event:%s" xwidget-event-type))))) | ||
| 184 | (t (xwidget-log "error: callback called for xwidget with dead buffer"))))) | 181 | (t (xwidget-log "error: callback called for xwidget with dead buffer"))))) |
| 185 | 182 | ||
| 186 | (define-derived-mode xwidget-webkit-mode | 183 | (define-derived-mode xwidget-webkit-mode |
| 187 | special-mode "xwidget-webkit" "xwidget webkit view mode" | 184 | special-mode "xwidget-webkit" "xwidget webkit view mode" |
| 188 | (setq buffer-read-only t) | 185 | (setq buffer-read-only t) |
| 189 | ;; Keep track of [vh]scroll when switching buffers | 186 | ;; Keep track of [vh]scroll when switching buffers |
| 190 | (image-mode-setup-winprops) | 187 | (image-mode-setup-winprops)) |
| 191 | |||
| 192 | ) | ||
| 193 | 188 | ||
| 194 | (defvar xwidget-webkit-last-session-buffer nil) | 189 | (defvar xwidget-webkit-last-session-buffer nil) |
| 195 | 190 | ||
| 196 | (defun xwidget-webkit-last-session () | 191 | (defun xwidget-webkit-last-session () |
| 197 | "Last active webkit, or nil." | 192 | "Last active webkit, or nil." |
| 198 | (if (buffer-live-p xwidget-webkit-last-session-buffer) | 193 | (if (buffer-live-p xwidget-webkit-last-session-buffer) |
| 199 | (save-excursion | 194 | (with-current-buffer xwidget-webkit-last-session-buffer |
| 200 | (set-buffer xwidget-webkit-last-session-buffer) | ||
| 201 | (xwidget-at 1)) | 195 | (xwidget-at 1)) |
| 202 | nil)) | 196 | nil)) |
| 203 | 197 | ||
| @@ -238,13 +232,13 @@ function findactiveelement(doc){ | |||
| 238 | 232 | ||
| 239 | " | 233 | " |
| 240 | 234 | ||
| 241 | "javascript that finds the active element." | 235 | "javascript that finds the active element." |
| 242 | ;;yes its ugly. because: | 236 | ;;yes its ugly. because: |
| 243 | ;; - there is aparently no way to find the active frame other than recursion | 237 | ;; - there is aparently no way to find the active frame other than recursion |
| 244 | ;; - the js "for each" construct missbehaved on the "frames" collection | 238 | ;; - the js "for each" construct missbehaved on the "frames" collection |
| 245 | ;; - a window with no frameset still has frames.length == 1, but frames[0].document.activeElement != document.activeElement | 239 | ;; - a window with no frameset still has frames.length == 1, but frames[0].document.activeElement != document.activeElement |
| 246 | ;;TODO the activeelement type needs to be examined, for iframe, etc. sucks. | 240 | ;;TODO the activeelement type needs to be examined, for iframe, etc. sucks. |
| 247 | ) | 241 | ) |
| 248 | 242 | ||
| 249 | (defun xwidget-webkit-insert-string (xw str) | 243 | (defun xwidget-webkit-insert-string (xw str) |
| 250 | "Insert string in the active field in the webkit. | 244 | "Insert string in the active field in the webkit. |
| @@ -258,27 +252,29 @@ Argument STR string." | |||
| 258 | (progn | 252 | (progn |
| 259 | (xwidget-webkit-execute-script xww xwidget-webkit-activeelement-js) | 253 | (xwidget-webkit-execute-script xww xwidget-webkit-activeelement-js) |
| 260 | (xwidget-webkit-execute-script-rv xww "findactiveelement(document).value;" ))) | 254 | (xwidget-webkit-execute-script-rv xww "findactiveelement(document).value;" ))) |
| 261 | (field-type (xwidget-webkit-execute-script-rv xww "findactiveelement(document).type;" ))) | 255 | (field-type (xwidget-webkit-execute-script-rv xww "findactiveelement(document).type;" ))) |
| 262 | (list xww | 256 | (list xww |
| 263 | (cond ( (equal "text" field-type) (read-string "text:" field-value)) | 257 | (cond ((equal "text" field-type) |
| 264 | ( (equal "password" field-type) (read-passwd "password:" nil field-value)) | 258 | (read-string "text:" field-value)) |
| 265 | ( (equal "textarea" field-type) (xwidget-webkit-begin-edit-textarea xww field-value)) | 259 | ((equal "password" field-type) |
| 266 | )))) | 260 | (read-passwd "password:" nil field-value)) |
| 261 | ((equal "textarea" field-type) | ||
| 262 | (xwidget-webkit-begin-edit-textarea xww field-value)))))) | ||
| 267 | (xwidget-webkit-execute-script xw (format "findactiveelement(document).value='%s'" str))) | 263 | (xwidget-webkit-execute-script xw (format "findactiveelement(document).value='%s'" str))) |
| 268 | 264 | ||
| 269 | 265 | ||
| 270 | (defun xwidget-webkit-begin-edit-textarea (xw text) | 266 | (defun xwidget-webkit-begin-edit-textarea (xw text) |
| 271 | (switch-to-buffer | 267 | (switch-to-buffer |
| 272 | (generate-new-buffer "textarea")) | 268 | (generate-new-buffer "textarea")) |
| 273 | 269 | ||
| 274 | (set (make-local-variable 'xwbl) xw) | 270 | (set (make-local-variable 'xwbl) xw) |
| 275 | (insert text) | 271 | (insert text)) |
| 276 | ) | ||
| 277 | 272 | ||
| 278 | (defun xwidget-webkit-end-edit-textarea () | 273 | (defun xwidget-webkit-end-edit-textarea () |
| 279 | (interactive) | 274 | (interactive) |
| 280 | (goto-char (point-min)) | 275 | (goto-char (point-min)) |
| 281 | (replace-string "\n" "\\n") | 276 | (while (search-forward "\n" nil t) |
| 277 | (replace-match "\\n" nil t)) | ||
| 282 | (xwidget-webkit-execute-script xwbl (format "findactiveelement(document).value='%s'" | 278 | (xwidget-webkit-execute-script xwbl (format "findactiveelement(document).value='%s'" |
| 283 | (buffer-substring (point-min) (point-max)))) | 279 | (buffer-substring (point-min) (point-max)))) |
| 284 | ;;TODO convert linefeed to \n | 280 | ;;TODO convert linefeed to \n |
| @@ -295,42 +291,49 @@ Argument STR string." | |||
| 295 | ;; - the selected window is scrolled but this is not always correct | 291 | ;; - the selected window is scrolled but this is not always correct |
| 296 | ;; - this needs to be interfaced into browse-url somehow. the tricky part is that we need to do this in two steps: | 292 | ;; - this needs to be interfaced into browse-url somehow. the tricky part is that we need to do this in two steps: |
| 297 | ;; A: load the base url, wait for load signal to arrive B: navigate to the anchor when the base url is finished rendering | 293 | ;; A: load the base url, wait for load signal to arrive B: navigate to the anchor when the base url is finished rendering |
| 298 | 294 | ||
| 299 | ;;this part figures out the Y coordinate of the element | 295 | ;;this part figures out the Y coordinate of the element |
| 300 | (let ((y | 296 | (let ((y (string-to-number |
| 301 | (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-name) 0)))) | 297 | (xwidget-webkit-execute-script-rv xw |
| 302 | ;;now we need to tell emacs to scroll the element into view. | 298 | (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-name) |
| 299 | 0)))) | ||
| 300 | ;;now we need to tell emacs to scroll the element into view. | ||
| 303 | (xwidget-log "scroll: %d" y) | 301 | (xwidget-log "scroll: %d" y) |
| 304 | (set-window-vscroll (selected-window) y t)) | 302 | (set-window-vscroll (selected-window) y t))) |
| 305 | ) | ||
| 306 | 303 | ||
| 307 | (defun xwidget-webkit-show-id-element (xw element-id) | 304 | (defun xwidget-webkit-show-id-element (xw element-id) |
| 308 | "make id-element show. for instance an anchor." | 305 | "make id-element show. for instance an anchor." |
| 309 | (interactive (list (xwidget-webkit-current-session) (read-string "element id:"))) | 306 | (interactive (list (xwidget-webkit-current-session) |
| 310 | (let ((y | 307 | (read-string "element id:"))) |
| 311 | (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementById('%s').getBoundingClientRect().top" element-id) 0)))) | 308 | (let ((y (string-to-number |
| 312 | ;;now we need to tell emacs to scroll the element into view. | 309 | (xwidget-webkit-execute-script-rv xw |
| 310 | (format "document.getElementById('%s').getBoundingClientRect().top" element-id) | ||
| 311 | 0)))) | ||
| 312 | ;;now we need to tell emacs to scroll the element into view. | ||
| 313 | (xwidget-log "scroll: %d" y) | 313 | (xwidget-log "scroll: %d" y) |
| 314 | (set-window-vscroll (selected-window) y t)) | 314 | (set-window-vscroll (selected-window) y t))) |
| 315 | ) | ||
| 316 | 315 | ||
| 317 | (defun xwidget-webkit-show-id-or-named-element (xw element-id) | 316 | (defun xwidget-webkit-show-id-or-named-element (xw element-id) |
| 318 | "make id-element show. for instance an anchor." | 317 | "make id-element show. for instance an anchor." |
| 319 | (interactive (list (xwidget-webkit-current-session) (read-string "element id:"))) | 318 | (interactive (list (xwidget-webkit-current-session) |
| 320 | (let* ((y1 | 319 | (read-string "element id:"))) |
| 321 | (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-id) "0"))) | 320 | (let* ((y1 (string-to-number |
| 322 | (y2 | 321 | (xwidget-webkit-execute-script-rv xw |
| 323 | (string-to-number (xwidget-webkit-execute-script-rv xw (format "document.getElementById('%s').getBoundingClientRect().top" element-id) "0"))) | 322 | (format "document.getElementsByName('%s')[0].getBoundingClientRect().top" element-id) |
| 324 | (y3 (max y1 y2))) | 323 | "0"))) |
| 325 | ;;now we need to tell emacs to scroll the element into view. | 324 | (y2 (string-to-number |
| 325 | (xwidget-webkit-execute-script-rv xw | ||
| 326 | (format "document.getElementById('%s').getBoundingClientRect().top" element-id) | ||
| 327 | "0"))) | ||
| 328 | (y3 (max y1 y2))) | ||
| 329 | ;;now we need to tell emacs to scroll the element into view. | ||
| 326 | (xwidget-log "scroll: %d" y3) | 330 | (xwidget-log "scroll: %d" y3) |
| 327 | (set-window-vscroll (selected-window) y3 t)) | 331 | (set-window-vscroll (selected-window) y3 t))) |
| 328 | ) | ||
| 329 | 332 | ||
| 330 | (defun xwidget-webkit-adjust-size-to-content () | 333 | (defun xwidget-webkit-adjust-size-to-content () |
| 331 | "Adjust webkit to content size." | 334 | "Adjust webkit to content size." |
| 332 | (interactive) | 335 | (interactive) |
| 333 | ( xwidget-adjust-size-to-content ( xwidget-webkit-current-session))) | 336 | (xwidget-adjust-size-to-content (xwidget-webkit-current-session))) |
| 334 | 337 | ||
| 335 | (defun xwidget-webkit-adjust-size (w h) | 338 | (defun xwidget-webkit-adjust-size (w h) |
| 336 | "Manualy set webkit size. | 339 | "Manualy set webkit size. |
| @@ -338,16 +341,16 @@ Argument W width. | |||
| 338 | Argument H height." | 341 | Argument H height." |
| 339 | ;;TODO shouldnt be tied to the webkit xwidget | 342 | ;;TODO shouldnt be tied to the webkit xwidget |
| 340 | (interactive "nWidth:\nnHeight:\n") | 343 | (interactive "nWidth:\nnHeight:\n") |
| 341 | ( xwidget-resize ( xwidget-webkit-current-session) w h)) | 344 | (xwidget-resize ( xwidget-webkit-current-session) w h)) |
| 342 | 345 | ||
| 343 | (defun xwidget-webkit-fit-width () | 346 | (defun xwidget-webkit-fit-width () |
| 344 | (interactive) | 347 | (interactive) |
| 345 | (xwidget-webkit-adjust-size | 348 | (xwidget-webkit-adjust-size (- (caddr (window-inside-pixel-edges)) |
| 346 | (- (caddr (window-inside-pixel-edges)) (car (window-inside-pixel-edges))) | 349 | (car (window-inside-pixel-edges))) |
| 347 | 1000)) | 350 | 1000)) |
| 348 | 351 | ||
| 349 | (defun xwidget-webkit-new-session (url) | 352 | (defun xwidget-webkit-new-session (url) |
| 350 | "Create a new webkit session buffer with URL." | 353 | "Create a new webkit session buffer with URL." |
| 351 | (let* | 354 | (let* |
| 352 | ((bufname (generate-new-buffer-name "*xwidget-webkit*")) | 355 | ((bufname (generate-new-buffer-name "*xwidget-webkit*")) |
| 353 | xw) | 356 | xw) |
| @@ -356,31 +359,32 @@ Argument H height." | |||
| 356 | (setq xw (xwidget-insert 1 'webkit-osr bufname 1000 1000)) | 359 | (setq xw (xwidget-insert 1 'webkit-osr bufname 1000 1000)) |
| 357 | (xwidget-put xw 'callback 'xwidget-webkit-callback) | 360 | (xwidget-put xw 'callback 'xwidget-webkit-callback) |
| 358 | (xwidget-webkit-mode) | 361 | (xwidget-webkit-mode) |
| 359 | (xwidget-webkit-goto-uri ( xwidget-webkit-last-session) url ))) | 362 | (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url ))) |
| 360 | 363 | ||
| 361 | 364 | ||
| 362 | (defun xwidget-webkit-goto-url (url) | 365 | (defun xwidget-webkit-goto-url (url) |
| 363 | "Goto URL." | 366 | "Goto URL." |
| 364 | (if ( xwidget-webkit-current-session) | 367 | (if (xwidget-webkit-current-session) |
| 365 | (progn | 368 | (progn |
| 366 | (xwidget-webkit-goto-uri ( xwidget-webkit-current-session) url)) | 369 | (xwidget-webkit-goto-uri (xwidget-webkit-current-session) url)) |
| 367 | ( xwidget-webkit-new-session url))) | 370 | (xwidget-webkit-new-session url))) |
| 368 | 371 | ||
| 369 | (defun xwidget-webkit-back () | 372 | (defun xwidget-webkit-back () |
| 370 | "Back in history." | 373 | "Back in history." |
| 371 | (interactive) | 374 | (interactive) |
| 372 | (xwidget-webkit-execute-script ( xwidget-webkit-current-session) "history.go(-1);")) | 375 | (xwidget-webkit-execute-script (xwidget-webkit-current-session) "history.go(-1);")) |
| 373 | 376 | ||
| 374 | (defun xwidget-webkit-reload () | 377 | (defun xwidget-webkit-reload () |
| 375 | "Reload current url." | 378 | "Reload current url." |
| 376 | (interactive) | 379 | (interactive) |
| 377 | (xwidget-webkit-execute-script ( xwidget-webkit-current-session) "history.go(0);")) | 380 | (xwidget-webkit-execute-script (xwidget-webkit-current-session) "history.go(0);")) |
| 378 | 381 | ||
| 379 | (defun xwidget-webkit-current-url () | 382 | (defun xwidget-webkit-current-url () |
| 380 | "Get the webkit url. place it on kill ring." | 383 | "Get the webkit url. place it on kill ring." |
| 381 | (interactive) | 384 | (interactive) |
| 382 | (let* ((rv (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session) "document.URL")) | 385 | (let* ((rv (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session) |
| 383 | (url (kill-new (if rv rv "")))) | 386 | "document.URL")) |
| 387 | (url (kill-new (or rv "")))) | ||
| 384 | (message "url: %s" url ) | 388 | (message "url: %s" url ) |
| 385 | url)) | 389 | url)) |
| 386 | 390 | ||
| @@ -391,13 +395,15 @@ Argument H height." | |||
| 391 | ;;or we find some other way to access the DOM | 395 | ;;or we find some other way to access the DOM |
| 392 | 396 | ||
| 393 | ;;reset webkit title. fugly. | 397 | ;;reset webkit title. fugly. |
| 394 | (let* ( (emptytag "titlecantbewhitespaceohthehorror") | 398 | (let* ((emptytag "titlecantbewhitespaceohthehorror") |
| 395 | title) | 399 | title) |
| 396 | (xwidget-webkit-execute-script xw (format "document.title=\"%s\";" (if default default emptytag))) | 400 | (xwidget-webkit-execute-script xw (format "document.title=\"%s\";" (or default emptytag))) |
| 397 | (xwidget-webkit-execute-script xw (format "document.title=%s;" script)) | 401 | (xwidget-webkit-execute-script xw (format "document.title=%s;" script)) |
| 398 | (setq title (xwidget-webkit-get-title xw)) | 402 | (setq title (xwidget-webkit-get-title xw)) |
| 399 | (if (equal emptytag title) (setq title "")) | 403 | (if (equal emptytag title) |
| 400 | (unless title (setq title default)) | 404 | (setq title "")) |
| 405 | (unless title | ||
| 406 | (setq title default)) | ||
| 401 | title)) | 407 | title)) |
| 402 | 408 | ||
| 403 | 409 | ||
| @@ -427,7 +433,7 @@ This is the last value stored with `(xwidget-put XWIDGET PROPNAME VALUE)'." | |||
| 427 | "Change XWIDGET' PROPNAME property to VALUE. | 433 | "Change XWIDGET' PROPNAME property to VALUE. |
| 428 | It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'." | 434 | It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'." |
| 429 | (set-xwidget-plist xwidget | 435 | (set-xwidget-plist xwidget |
| 430 | (plist-put (xwidget-plist xwidget) propname value))) | 436 | (plist-put (xwidget-plist xwidget) propname value))) |
| 431 | 437 | ||
| 432 | 438 | ||
| 433 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 439 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -463,6 +469,4 @@ yet, so deinstall Flash instead for now." | |||
| 463 | 469 | ||
| 464 | (provide 'xwidget) | 470 | (provide 'xwidget) |
| 465 | 471 | ||
| 466 | (provide 'xwidget) | ||
| 467 | |||
| 468 | ;;; xwidget.el ends here | 472 | ;;; xwidget.el ends here |
diff --git a/src/Makefile.in b/src/Makefile.in index 8d8133c9e6c..3b5c736517f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -237,9 +237,6 @@ CFLAGS_SOUND= @CFLAGS_SOUND@ | |||
| 237 | RSVG_LIBS= @RSVG_LIBS@ | 237 | RSVG_LIBS= @RSVG_LIBS@ |
| 238 | RSVG_CFLAGS= @RSVG_CFLAGS@ | 238 | RSVG_CFLAGS= @RSVG_CFLAGS@ |
| 239 | 239 | ||
| 240 | CLUTTER_LIBS= @CLUTTER_LIBS@ | ||
| 241 | CLUTTER_CFLAGS= @CLUTTER_CFLAGS@ | ||
| 242 | |||
| 243 | WEBKIT_LIBS= @WEBKIT_LIBS@ | 240 | WEBKIT_LIBS= @WEBKIT_LIBS@ |
| 244 | WEBKIT_CFLAGS= @WEBKIT_CFLAGS@ | 241 | WEBKIT_CFLAGS= @WEBKIT_CFLAGS@ |
| 245 | 242 | ||
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c index 6df0b2422b1..f675bd76d97 100644 --- a/src/emacsgtkfixed.c +++ b/src/emacsgtkfixed.c | |||
| @@ -184,7 +184,7 @@ static void emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget, | |||
| 184 | 184 | ||
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | #endif | 187 | #endif /* HAVE_XWIDGETS */ |
| 188 | 188 | ||
| 189 | static void | 189 | static void |
| 190 | emacs_fixed_class_init (EmacsFixedClass *klass) | 190 | emacs_fixed_class_init (EmacsFixedClass *klass) |
diff --git a/src/xwidget.c b/src/xwidget.c index d169069c99d..eada274949c 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -68,7 +68,7 @@ | |||
| 68 | 68 | ||
| 69 | #include "gtkutil.h" | 69 | #include "gtkutil.h" |
| 70 | #include "font.h" | 70 | #include "font.h" |
| 71 | #endif | 71 | #endif /* HAVE_X_WINDOWS */ |
| 72 | 72 | ||
| 73 | #include <gtk/gtk.h> | 73 | #include <gtk/gtk.h> |
| 74 | #include <gdk/gdk.h> | 74 | #include <gdk/gdk.h> |
| @@ -79,18 +79,6 @@ | |||
| 79 | #include "emacsgtkfixed.h" | 79 | #include "emacsgtkfixed.h" |
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | |||
| 83 | |||
| 84 | #ifdef HAVE_GOOCANVAS | ||
| 85 | #include <goocanvas.h> | ||
| 86 | #endif | ||
| 87 | |||
| 88 | #ifdef HAVE_CLUTTER | ||
| 89 | #include <librsvg/rsvg.h> | ||
| 90 | #include <clutter/clutter.h> | ||
| 91 | #include <clutter-gtk/clutter-gtk.h> | ||
| 92 | #endif | ||
| 93 | |||
| 94 | #include <wchar.h> | 82 | #include <wchar.h> |
| 95 | 83 | ||
| 96 | #ifdef HAVE_WEBKIT_OSR | 84 | #ifdef HAVE_WEBKIT_OSR |
| @@ -132,14 +120,14 @@ allocate_xwidget_view (void) | |||
| 132 | #define XSETXWIDGET_VIEW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW)) | 120 | #define XSETXWIDGET_VIEW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW)) |
| 133 | 121 | ||
| 134 | Lisp_Object Qxwidget; | 122 | Lisp_Object Qxwidget; |
| 135 | Lisp_Object Qcxwidget; | 123 | Lisp_Object QCxwidget; |
| 136 | Lisp_Object Qtitle; | 124 | Lisp_Object QCtitle; |
| 137 | Lisp_Object Qxwidget_set_keyboard_grab; | 125 | Lisp_Object Qxwidget_set_keyboard_grab; |
| 138 | Lisp_Object Qxwidget_embed_steal_window; | 126 | Lisp_Object Qxwidget_embed_steal_window; |
| 139 | Lisp_Object Qxwidget_info; | 127 | Lisp_Object Qxwidget_info; |
| 140 | Lisp_Object Qxwidget_resize; | 128 | Lisp_Object Qxwidget_resize; |
| 141 | Lisp_Object Qxwidget_send_keyboard_event; | 129 | Lisp_Object Qxwidget_send_keyboard_event; |
| 142 | Lisp_Object Qcxwgir_class; | 130 | Lisp_Object QCxwgir_class; |
| 143 | Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qsocket_osr, Qcairo, Qxwgir, | 131 | Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qsocket_osr, Qcairo, Qxwgir, |
| 144 | Qwebkit_osr, QCplist; | 132 | Qwebkit_osr, QCplist; |
| 145 | 133 | ||
| @@ -188,14 +176,27 @@ xwgir_event_callback (GtkWidget *widget, | |||
| 188 | GtkWidget* xwgir_create(char* class, char* namespace); | 176 | GtkWidget* xwgir_create(char* class, char* namespace); |
| 189 | static void | 177 | static void |
| 190 | send_xembed_ready_event (struct xwidget* xw, int xembedid); | 178 | send_xembed_ready_event (struct xwidget* xw, int xembedid); |
| 191 | DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, | 179 | DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 8, 0, |
| 192 | doc: /* xw */ | 180 | doc: /* Make an xwidget from BEG to END of TYPE. |
| 181 | |||
| 182 | If BUFFER is nil it uses the current buffer. If BUFFER is a string and | ||
| 183 | no such buffer exists, it is created. | ||
| 184 | |||
| 185 | TYPE is a symbol which can take one of the following values: | ||
| 186 | - Button | ||
| 187 | - ToggleButton | ||
| 188 | - slider | ||
| 189 | - socket | ||
| 190 | - socket-osr | ||
| 191 | - cairo | ||
| 192 | */ | ||
| 193 | ) | 193 | ) |
| 194 | (Lisp_Object beg, Lisp_Object end, | 194 | (Lisp_Object beg, Lisp_Object end, |
| 195 | Lisp_Object type, | 195 | Lisp_Object type, |
| 196 | Lisp_Object title, | 196 | Lisp_Object title, |
| 197 | Lisp_Object width, Lisp_Object height, | 197 | Lisp_Object width, Lisp_Object height, |
| 198 | Lisp_Object data) | 198 | Lisp_Object data, |
| 199 | Lisp_Object buffer) | ||
| 199 | { | 200 | { |
| 200 | //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES) | 201 | //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES) |
| 201 | // arg "type" and fwd should be keyword args eventually | 202 | // arg "type" and fwd should be keyword args eventually |
| @@ -203,16 +204,18 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, | |||
| 203 | //(xwidget-info (car xwidget-alist)) | 204 | //(xwidget-info (car xwidget-alist)) |
| 204 | struct xwidget* xw = allocate_xwidget(); | 205 | struct xwidget* xw = allocate_xwidget(); |
| 205 | Lisp_Object val; | 206 | Lisp_Object val; |
| 206 | struct gcpro gcpro1; | ||
| 207 | GCPRO1(xw); | ||
| 208 | XSETSYMBOL(xw->type, type); | 207 | XSETSYMBOL(xw->type, type); |
| 209 | XSETSTRING(xw->title, title); | 208 | XSETSTRING(xw->title, title); |
| 210 | //TODO buffer should be an optional argument not just assumed to be the current buffer | 209 | if (NILP (buffer)) |
| 211 | XSETBUFFER(xw->buffer, Fcurrent_buffer()); // conservatively gcpro xw since we call lisp | 210 | buffer = Fcurrent_buffer(); // no need to gcpro because Fcurrent_buffer doesn't call Feval/eval_sub. |
| 211 | else | ||
| 212 | buffer = Fget_buffer_create (buffer); | ||
| 213 | XSETBUFFER(xw->buffer, buffer); | ||
| 214 | |||
| 212 | xw->height = XFASTINT(height); | 215 | xw->height = XFASTINT(height); |
| 213 | xw->width = XFASTINT(width); | 216 | xw->width = XFASTINT(width); |
| 214 | XSETPSEUDOVECTOR (val, xw, PVEC_XWIDGET); //?? dunno why i need this | 217 | XSETPSEUDOVECTOR (val, xw, PVEC_XWIDGET); // set the vectorlike_header of VAL with the correct value |
| 215 | Vxwidget_alist = Fcons ( val, Vxwidget_alist); | 218 | Vxwidget_alist = Fcons (val, Vxwidget_alist); |
| 216 | xw->widgetwindow_osr = NULL; | 219 | xw->widgetwindow_osr = NULL; |
| 217 | xw->widget_osr = NULL; | 220 | xw->widget_osr = NULL; |
| 218 | xw->plist = Qnil; | 221 | xw->plist = Qnil; |
| @@ -224,78 +227,77 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, | |||
| 224 | */ | 227 | */ |
| 225 | if (EQ(xw->type, Qwebkit_osr)|| | 228 | if (EQ(xw->type, Qwebkit_osr)|| |
| 226 | EQ(xw->type, Qsocket_osr)|| | 229 | EQ(xw->type, Qsocket_osr)|| |
| 227 | (Fget(xw->type, Qcxwgir_class) != Qnil)){ | 230 | (Fget(xw->type, QCxwgir_class) != Qnil)) { |
| 228 | printf("init osr widget\n"); | 231 | printf("init osr widget\n"); |
| 229 | block_input(); | 232 | block_input(); |
| 230 | xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ()); | 233 | xw->widgetwindow_osr = GTK_CONTAINER (gtk_offscreen_window_new ()); |
| 231 | gtk_window_resize( GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); | 234 | gtk_window_resize(GTK_WINDOW(xw->widgetwindow_osr), xw->width, xw->height); |
| 232 | 235 | ||
| 233 | if (EQ(xw->type, Qwebkit_osr)) | 236 | if (EQ(xw->type, Qwebkit_osr)) |
| 234 | xw->widget_osr = webkit_web_view_new(); | 237 | xw->widget_osr = webkit_web_view_new(); |
| 235 | if(EQ(xw->type, Qsocket_osr)) | 238 | if(EQ(xw->type, Qsocket_osr)) |
| 236 | xw->widget_osr = gtk_socket_new(); | 239 | xw->widget_osr = gtk_socket_new(); |
| 237 | if(Fget(xw->type, Qcxwgir_class) != Qnil) | 240 | if(Fget(xw->type, QCxwgir_class) != Qnil) |
| 238 | xw->widget_osr = xwgir_create( SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))), | 241 | xw->widget_osr = xwgir_create(SDATA(Fcar(Fcdr(Fget(xw->type, QCxwgir_class)))), |
| 239 | SDATA(Fcar(Fget(xw->type, Qcxwgir_class)))); | 242 | SDATA(Fcar(Fget(xw->type, QCxwgir_class)))); |
| 240 | 243 | ||
| 241 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); | 244 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, xw->height); |
| 242 | gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); | 245 | gtk_container_add (xw->widgetwindow_osr, xw->widget_osr); |
| 243 | 246 | ||
| 244 | gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); | 247 | gtk_widget_show_all (GTK_WIDGET (xw->widgetwindow_osr)); |
| 245 | 248 | ||
| 246 | /* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. */ | 249 | /* store some xwidget data in the gtk widgets for convenient retrieval in the event handlers. */ |
| 247 | g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); | 250 | g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, (gpointer) (xw)); |
| 248 | g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); | 251 | g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, (gpointer) (xw)); |
| 249 | /* signals */ | 252 | |
| 250 | g_signal_connect (G_OBJECT ( xw->widgetwindow_osr), "damage-event", G_CALLBACK (xwidget_osr_damage_event_callback), NULL); | 253 | /* signals */ |
| 251 | 254 | g_signal_connect (G_OBJECT (xw->widgetwindow_osr), "damage-event", | |
| 252 | 255 | G_CALLBACK (xwidget_osr_damage_event_callback), NULL); | |
| 253 | if (EQ(xw->type, Qwebkit_osr)){ | 256 | |
| 254 | g_signal_connect (G_OBJECT ( xw->widget_osr), | 257 | if (EQ(xw->type, Qwebkit_osr)) { |
| 255 | "document-load-finished", | 258 | g_signal_connect (G_OBJECT (xw->widget_osr), |
| 256 | G_CALLBACK (webkit_osr_document_load_finished_callback), | 259 | "document-load-finished", |
| 257 | xw); | 260 | G_CALLBACK (webkit_osr_document_load_finished_callback), |
| 261 | xw); | ||
| 258 | 262 | ||
| 259 | g_signal_connect (G_OBJECT ( xw->widget_osr), | 263 | g_signal_connect (G_OBJECT (xw->widget_osr), |
| 260 | "download-requested", | 264 | "download-requested", |
| 261 | G_CALLBACK (webkit_osr_download_callback), | 265 | G_CALLBACK (webkit_osr_download_callback), |
| 262 | xw); | 266 | xw); |
| 263 | 267 | ||
| 264 | g_signal_connect (G_OBJECT ( xw->widget_osr), | 268 | g_signal_connect (G_OBJECT (xw->widget_osr), |
| 265 | "mime-type-policy-decision-requested", | 269 | "mime-type-policy-decision-requested", |
| 266 | G_CALLBACK (webkit_osr_mime_type_policy_typedecision_requested_callback), | 270 | G_CALLBACK (webkit_osr_mime_type_policy_typedecision_requested_callback), |
| 267 | xw); | 271 | xw); |
| 268 | 272 | ||
| 269 | g_signal_connect (G_OBJECT ( xw->widget_osr), | 273 | g_signal_connect (G_OBJECT (xw->widget_osr), |
| 270 | "new-window-policy-decision-requested", | 274 | "new-window-policy-decision-requested", |
| 271 | G_CALLBACK (webkit_osr_new_window_policy_decision_requested_callback), | 275 | G_CALLBACK (webkit_osr_new_window_policy_decision_requested_callback), |
| 272 | xw); | 276 | xw); |
| 273 | 277 | ||
| 274 | g_signal_connect (G_OBJECT ( xw->widget_osr), | 278 | g_signal_connect (G_OBJECT (xw->widget_osr), |
| 275 | "navigation-policy-decision-requested", | 279 | "navigation-policy-decision-requested", |
| 276 | G_CALLBACK (webkit_osr_navigation_policy_decision_requested_callback), | 280 | G_CALLBACK (webkit_osr_navigation_policy_decision_requested_callback), |
| 277 | xw); | 281 | xw); |
| 278 | //webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org"); | 282 | //webkit_web_view_load_uri(WEBKIT_WEB_VIEW(xw->widget_osr), "http://www.fsf.org"); |
| 279 | 283 | ||
| 280 | } | 284 | } |
| 281 | 285 | ||
| 282 | if (EQ(xw->type, Qsocket_osr)) { | 286 | if (EQ(xw->type, Qsocket_osr)) { |
| 283 | printf ("xwid:%d socket id:%x %d\n", | 287 | printf ("xwid:%d socket id:%x %d\n", |
| 284 | xw, | 288 | xw, |
| 285 | gtk_socket_get_id (GTK_SOCKET (xw->widget_osr)), | 289 | gtk_socket_get_id (GTK_SOCKET (xw->widget_osr)), |
| 286 | gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); | 290 | gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); |
| 287 | send_xembed_ready_event (xw, | 291 | send_xembed_ready_event (xw, gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); |
| 288 | gtk_socket_get_id (GTK_SOCKET (xw->widget_osr))); | 292 | //gtk_widget_realize(xw->widget); |
| 289 | //gtk_widget_realize(xw->widget); | 293 | } |
| 290 | } | ||
| 291 | 294 | ||
| 292 | 295 | ||
| 293 | unblock_input(); | 296 | unblock_input(); |
| 294 | 297 | ||
| 295 | } | 298 | } |
| 296 | #endif | 299 | #endif /* HAVE_WEBKIT_OSR */ |
| 297 | 300 | ||
| 298 | UNGCPRO; | ||
| 299 | return val; | 301 | return val; |
| 300 | } | 302 | } |
| 301 | 303 | ||
| @@ -762,7 +764,7 @@ xwgir_convert_lisp_to_gir_arg(GIArgument* giarg, | |||
| 762 | void | 764 | void |
| 763 | refactor_attempt(){ | 765 | refactor_attempt(){ |
| 764 | //this methhod should be called from xwgir-xwidget-call-method and from xwgir xwidget construction | 766 | //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)))); | 767 | char* class = SDATA(Fcar(Fcdr(Fget(xw->type, QCxwgir_class)))); |
| 766 | 768 | ||
| 767 | GIObjectInfo* obj_info = g_irepository_find_by_name(girepository, namespace, class); | 769 | GIObjectInfo* obj_info = g_irepository_find_by_name(girepository, namespace, class); |
| 768 | GIFunctionInfo* f_info = g_object_info_find_method (obj_info, SDATA(method)); | 770 | GIFunctionInfo* f_info = g_object_info_find_method (obj_info, SDATA(method)); |
| @@ -792,7 +794,7 @@ refactor_attempt(){ | |||
| 792 | } | 794 | } |
| 793 | return Qt; | 795 | return Qt; |
| 794 | } | 796 | } |
| 795 | #endif | 797 | #endif /* 0 */ |
| 796 | 798 | ||
| 797 | DEFUN ("xwgir-xwidget-call-method", Fxwgir_xwidget_call_method, Sxwgir_xwidget_call_method, 3, 3, 0, | 799 | DEFUN ("xwgir-xwidget-call-method", Fxwgir_xwidget_call_method, Sxwgir_xwidget_call_method, 3, 3, 0, |
| 798 | doc: /* call xwidget object method.*/) | 800 | doc: /* call xwidget object method.*/) |
| @@ -808,7 +810,7 @@ DEFUN ("xwgir-xwidget-call-method", Fxwgir_xwidget_call_method, Sxwgir_xwidget_ | |||
| 808 | if(Qnil == xwidget) {printf("ERROR xwidget nil\n"); return Qnil;}; | 810 | if(Qnil == xwidget) {printf("ERROR xwidget nil\n"); return Qnil;}; |
| 809 | xw = XXWIDGET(xwidget); | 811 | xw = XXWIDGET(xwidget); |
| 810 | if(NULL == xw) printf("ERROR xw is 0\n"); | 812 | if(NULL == xw) printf("ERROR xw is 0\n"); |
| 811 | char* namespace = SDATA(Fcar(Fget(xw->type, Qcxwgir_class))); | 813 | char* namespace = SDATA(Fcar(Fget(xw->type, QCxwgir_class))); |
| 812 | //we need the concrete widget, which happens in 2 ways depending on OSR or not TODO | 814 | //we need the concrete widget, which happens in 2 ways depending on OSR or not TODO |
| 813 | GtkWidget* widget = NULL; | 815 | GtkWidget* widget = NULL; |
| 814 | if(NULL == xw->widget_osr) { | 816 | if(NULL == xw->widget_osr) { |
| @@ -823,7 +825,7 @@ DEFUN ("xwgir-xwidget-call-method", Fxwgir_xwidget_call_method, Sxwgir_xwidget_ | |||
| 823 | /* char* class = G_OBJECT_TYPE_NAME(widget); //gives "GtkButton"(I want "Button") */ | 825 | /* char* class = G_OBJECT_TYPE_NAME(widget); //gives "GtkButton"(I want "Button") */ |
| 824 | /* class += strlen(namespace); //TODO check for corresponding api method. but this seems to work. */ | 826 | /* class += strlen(namespace); //TODO check for corresponding api method. but this seems to work. */ |
| 825 | 827 | ||
| 826 | char* class = SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))); | 828 | char* class = SDATA(Fcar(Fcdr(Fget(xw->type, QCxwgir_class)))); |
| 827 | 829 | ||
| 828 | GIObjectInfo* obj_info = g_irepository_find_by_name(girepository, namespace, class); | 830 | GIObjectInfo* obj_info = g_irepository_find_by_name(girepository, namespace, class); |
| 829 | GIFunctionInfo* f_info = g_object_info_find_method (obj_info, SDATA(method)); | 831 | GIFunctionInfo* f_info = g_object_info_find_method (obj_info, SDATA(method)); |
| @@ -981,54 +983,9 @@ xwidget_init_view (struct xwidget *xww, | |||
| 981 | //Cairo view | 983 | //Cairo view |
| 982 | //uhm cairo is differentish in gtk 3. | 984 | //uhm cairo is differentish in gtk 3. |
| 983 | //gdk_cairo_create (gtk_widget_get_window (FRAME_GTK_WIDGET (s->f))); | 985 | //gdk_cairo_create (gtk_widget_get_window (FRAME_GTK_WIDGET (s->f))); |
| 984 | #ifdef HAVE_GOOCANVAS | ||
| 985 | xv->widget = goo_canvas_new(); | ||
| 986 | GooCanvasItem *root, *rect_item, *text_item; | ||
| 987 | goo_canvas_set_bounds (GOO_CANVAS (xv->widget), 0, 0, 1000, 1000); | ||
| 988 | root = goo_canvas_get_root_item (GOO_CANVAS (xv->widget)); | ||
| 989 | rect_item = goo_canvas_rect_new (root, 100, 100, 400, 400, | ||
| 990 | "line-width", 10.0, | ||
| 991 | "radius-x", 20.0, | ||
| 992 | "radius-y", 10.0, | ||
| 993 | "stroke-color", "yellow", | ||
| 994 | "fill-color", "red", | ||
| 995 | NULL); | ||
| 996 | |||
| 997 | text_item = goo_canvas_text_new (root, "Hello World", 300, 300, -1, | ||
| 998 | GTK_ANCHOR_CENTER, | ||
| 999 | "font", "Sans 24", | ||
| 1000 | NULL); | ||
| 1001 | goo_canvas_item_rotate (text_item, 45, 300, 300); | ||
| 1002 | |||
| 1003 | #endif | ||
| 1004 | #ifdef HAVE_CLUTTER | ||
| 1005 | xv->widget = gtk_clutter_embed_new ();; | ||
| 1006 | ClutterActor *stage = NULL; | ||
| 1007 | stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED ( xv->widget)); | ||
| 1008 | ClutterColor stage_color = { 0xaa, 0xaa, 0xaa, 0xff }; /* Black */ | ||
| 1009 | clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); | ||
| 1010 | |||
| 1011 | ClutterActor * texture = clutter_cairo_texture_new (1000, 1000); | ||
| 1012 | clutter_container_add_actor(stage, texture); | ||
| 1013 | clutter_actor_set_position(texture, 0,0); | ||
| 1014 | clutter_actor_show(texture); | ||
| 1015 | |||
| 1016 | cairo_t *cr; | ||
| 1017 | cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (texture)); | ||
| 1018 | |||
| 1019 | /* draw on the context */ | ||
| 1020 | RsvgHandle *h = rsvg_handle_new_from_file ("/tmp/tst.svg", | ||
| 1021 | NULL); | ||
| 1022 | |||
| 1023 | rsvg_handle_render_cairo(h, cr); | ||
| 1024 | cairo_destroy (cr); | ||
| 1025 | |||
| 1026 | /* Show the stage: */ | ||
| 1027 | clutter_actor_show (stage); | ||
| 1028 | #endif | ||
| 1029 | } else if (EQ(xww->type, Qwebkit_osr)|| | 986 | } else if (EQ(xww->type, Qwebkit_osr)|| |
| 1030 | EQ(xww->type, Qsocket_osr)|| | 987 | EQ(xww->type, Qsocket_osr)|| |
| 1031 | (Fget(xww->type, Qcxwgir_class) != Qnil))//xwgir widgets are OSR | 988 | (Fget(xww->type, QCxwgir_class) != Qnil))//xwgir widgets are OSR |
| 1032 | { | 989 | { |
| 1033 | #ifdef HAVE_WEBKIT_OSR //TODO the ifdef isnt really relevant anymore, we always have osr | 990 | #ifdef HAVE_WEBKIT_OSR //TODO the ifdef isnt really relevant anymore, we always have osr |
| 1034 | printf("osr init:%s\n",SDATA(SYMBOL_NAME(xww->type))); | 991 | printf("osr init:%s\n",SDATA(SYMBOL_NAME(xww->type))); |
| @@ -1067,7 +1024,7 @@ xwidget_init_view (struct xwidget *xww, | |||
| 1067 | /* g_signal_connect (G_OBJECT ( xv->widget), "key-release-event", */ | 1024 | /* g_signal_connect (G_OBJECT ( xv->widget), "key-release-event", */ |
| 1068 | /* G_CALLBACK (xwidget_osr_event_forward), NULL); */ | 1025 | /* G_CALLBACK (xwidget_osr_event_forward), NULL); */ |
| 1069 | 1026 | ||
| 1070 | #endif | 1027 | #endif /* HAVE_WEBKIT_OSR */ |
| 1071 | 1028 | ||
| 1072 | 1029 | ||
| 1073 | } | 1030 | } |
| @@ -1114,7 +1071,7 @@ xwidget_init_view (struct xwidget *xww, | |||
| 1114 | //xwgir debug | 1071 | //xwgir debug |
| 1115 | if (//EQ(xww->type, Qwebkit_osr)|| //TODO should be able to choose compile time which method to use with webkit | 1072 | if (//EQ(xww->type, Qwebkit_osr)|| //TODO should be able to choose compile time which method to use with webkit |
| 1116 | EQ(xww->type, Qsocket_osr)|| | 1073 | EQ(xww->type, Qsocket_osr)|| |
| 1117 | (Fget(xww->type, Qcxwgir_class) != Qnil))//xwgir widgets are OSR | 1074 | (Fget(xww->type, QCxwgir_class) != Qnil))//xwgir widgets are OSR |
| 1118 | { | 1075 | { |
| 1119 | //xwidget_set_embedder_view(xww,xv); | 1076 | //xwidget_set_embedder_view(xww,xv); |
| 1120 | printf("gdk_offscreen_window_set_embedder %d %d\n", | 1077 | printf("gdk_offscreen_window_set_embedder %d %d\n", |
| @@ -1350,7 +1307,7 @@ DEFUN ("xwidget-webkit-dom-dump", Fxwidget_webkit_dom_dump, Sxwidget_webkit_dom | |||
| 1350 | 1307 | ||
| 1351 | 1308 | ||
| 1352 | 1309 | ||
| 1353 | #endif | 1310 | #endif /* HAVE_WEBKIT_OSR */ |
| 1354 | 1311 | ||
| 1355 | 1312 | ||
| 1356 | 1313 | ||
| @@ -1611,12 +1568,14 @@ syms_of_xwidget (void) | |||
| 1611 | defsubr (&Sxwidget_buffer); | 1568 | defsubr (&Sxwidget_buffer); |
| 1612 | defsubr (&Sset_xwidget_plist); | 1569 | defsubr (&Sset_xwidget_plist); |
| 1613 | 1570 | ||
| 1614 | DEFSYM (Qxwidget ,"xwidget"); | 1571 | DEFSYM (Qxwidget, "xwidget"); |
| 1615 | 1572 | ||
| 1616 | DEFSYM (Qcxwidget ,":xwidget"); | 1573 | DEFSYM (QCxwidget, ":xwidget"); |
| 1617 | DEFSYM (Qcxwgir_class ,":xwgir-class"); | 1574 | DEFSYM (QCxwgir_class, ":xwgir-class"); |
| 1618 | DEFSYM (Qtitle ,":title"); | 1575 | DEFSYM (QCtitle, ":title"); |
| 1619 | 1576 | ||
| 1577 | /* Do not forget to update the docstring of make-xwidget if you add | ||
| 1578 | new types. */ | ||
| 1620 | DEFSYM (Qbutton, "Button"); //changed to match the gtk class because xwgir(experimental and not really needed) | 1579 | DEFSYM (Qbutton, "Button"); //changed to match the gtk class because xwgir(experimental and not really needed) |
| 1621 | DEFSYM (Qtoggle, "ToggleButton"); | 1580 | DEFSYM (Qtoggle, "ToggleButton"); |
| 1622 | DEFSYM (Qslider, "slider"); | 1581 | DEFSYM (Qslider, "slider"); |
| @@ -1626,10 +1585,11 @@ syms_of_xwidget (void) | |||
| 1626 | 1585 | ||
| 1627 | DEFSYM (QCplist, ":plist"); | 1586 | DEFSYM (QCplist, ":plist"); |
| 1628 | 1587 | ||
| 1629 | DEFVAR_LISP ("xwidget-alist", Vxwidget_alist, doc: /*xwidgets list*/); | 1588 | DEFVAR_LISP ("xwidget-alist", Vxwidget_alist, doc: /*xwidgets list*/); |
| 1630 | Vxwidget_alist = Qnil; | 1589 | Vxwidget_alist = Qnil; |
| 1631 | DEFVAR_LISP ("xwidget-view-alist", Vxwidget_view_alist, doc: /*xwidget views list*/); | 1590 | |
| 1632 | Vxwidget_alist = Qnil; | 1591 | DEFVAR_LISP ("xwidget-view-alist", Vxwidget_view_alist, doc: /*xwidget views list*/); |
| 1592 | Vxwidget_view_alist = Qnil; | ||
| 1633 | 1593 | ||
| 1634 | Fprovide (intern ("xwidget-internal"), Qnil); | 1594 | Fprovide (intern ("xwidget-internal"), Qnil); |
| 1635 | 1595 | ||
| @@ -1744,12 +1704,12 @@ lookup_xwidget (Lisp_Object spec) | |||
| 1744 | Lisp_Object value; | 1704 | Lisp_Object value; |
| 1745 | struct xwidget *xw; | 1705 | struct xwidget *xw; |
| 1746 | 1706 | ||
| 1747 | value = xwidget_spec_value (spec, Qcxwidget, &found1); | 1707 | value = xwidget_spec_value (spec, QCxwidget, &found1); |
| 1748 | xw = XXWIDGET(value); | 1708 | xw = XXWIDGET(value); |
| 1749 | 1709 | ||
| 1750 | /* value = xwidget_spec_value (spec, QCtype, &found); */ | 1710 | /* value = xwidget_spec_value (spec, QCtype, &found); */ |
| 1751 | /* xw->type = SYMBOLP (value) ? value : Qbutton; //default to button */ | 1711 | /* xw->type = SYMBOLP (value) ? value : Qbutton; //default to button */ |
| 1752 | /* value = xwidget_spec_value (spec, Qtitle, &found2); */ | 1712 | /* value = xwidget_spec_value (spec, QCtitle, &found2); */ |
| 1753 | /* xw->title = STRINGP (value) ? (char *) SDATA (value) : "?"; //funky cast FIXME TODO */ | 1713 | /* xw->title = STRINGP (value) ? (char *) SDATA (value) : "?"; //funky cast FIXME TODO */ |
| 1754 | 1714 | ||
| 1755 | /* value = xwidget_spec_value (spec, QCheight, NULL); */ | 1715 | /* value = xwidget_spec_value (spec, QCheight, NULL); */ |
| @@ -1852,4 +1812,4 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix) | |||
| 1852 | } | 1812 | } |
| 1853 | 1813 | ||
| 1854 | 1814 | ||
| 1855 | #endif | 1815 | #endif /* HAVE_XWIDGETS */ |
diff --git a/src/xwidget.h b/src/xwidget.h index e5cfe6de902..92c6e6e3513 100644 --- a/src/xwidget.h +++ b/src/xwidget.h | |||
| @@ -107,4 +107,4 @@ struct xwidget* lookup_xwidget (Lisp_Object spec); | |||
| 107 | #define XG_XWIDGET "emacs_xwidget" | 107 | #define XG_XWIDGET "emacs_xwidget" |
| 108 | #define XG_XWIDGET_VIEW "emacs_xwidget_view" | 108 | #define XG_XWIDGET_VIEW "emacs_xwidget_view" |
| 109 | void xwidget_view_delete_all_in_window( struct window *w ); | 109 | void xwidget_view_delete_all_in_window( struct window *w ); |
| 110 | #endif | 110 | #endif /* XWIDGET_H_INCLUDED */ |