aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xwidget.c98
1 files changed, 45 insertions, 53 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index 1ed7eaae2a7..88cdb941c4c 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -160,18 +160,13 @@ DEFUN ("make-xwidget",
160 Fmake_xwidget, Smake_xwidget, 160 Fmake_xwidget, Smake_xwidget,
161 7, 8, 0, 161 7, 8, 0,
162 doc: /* Make an xwidget from BEG to END of TYPE. 162 doc: /* Make an xwidget from BEG to END of TYPE.
163 163If BUFFER is nil, use the current buffer.
164If BUFFER is nil it uses the current 164If BUFFER is a string and no such buffer exists, create it.
165buffer. If BUFFER is a string and no such 165TYPE is a symbol which can take one of the following values:
166buffer exists, it is created.
167
168TYPE is a symbol which can take one of the
169following values:
170 166
171- webkit_osr 167- webkit_osr
172 168
173Returns the newly constructed xwidget, or nil if construction 169Returns the newly constructed xwidget, or nil if construction fails. */)
174fails. */)
175 (Lisp_Object beg, Lisp_Object end, 170 (Lisp_Object beg, Lisp_Object end,
176 Lisp_Object type, 171 Lisp_Object type,
177 Lisp_Object title, 172 Lisp_Object title,
@@ -255,7 +250,7 @@ fails. */)
255 gtk_widget_show (xw->widgetscrolledwindow_osr); 250 gtk_widget_show (xw->widgetscrolledwindow_osr);
256 251
257 /* store some xwidget data in the gtk widgets for convenient 252 /* store some xwidget data in the gtk widgets for convenient
258 retrieval in the event handlers. */ 253 retrieval in the event handlers. */
259 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, 254 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET,
260 (gpointer) (xw)); 255 (gpointer) (xw));
261 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, 256 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET,
@@ -302,7 +297,7 @@ fails. */)
302DEFUN ("get-buffer-xwidgets", Fget_buffer_xwidgets, Sget_buffer_xwidgets, 297DEFUN ("get-buffer-xwidgets", Fget_buffer_xwidgets, Sget_buffer_xwidgets,
303 1, 1, 0, 298 1, 1, 0,
304 doc: /* Return a list of xwidgets associated with BUFFER. 299 doc: /* Return a list of xwidgets associated with BUFFER.
305BUFFER may be a buffer or the name of one. */) 300BUFFER may be a buffer or the name of one. */)
306 (Lisp_Object buffer) 301 (Lisp_Object buffer)
307{ 302{
308 Lisp_Object xw, tail, xw_list; 303 Lisp_Object xw, tail, xw_list;
@@ -429,7 +424,7 @@ webkit_mime_type_policy_typedecision_requested_cb (WebKitWebView *webView,
429 gpointer user_data) 424 gpointer user_data)
430{ 425{
431 // This function makes webkit send a download signal for all unknown 426 // This function makes webkit send a download signal for all unknown
432 // mime types. TODO Defer the decision to lisp, so that its possible 427 // mime types. TODO Defer the decision to lisp, so that its possible
433 // to make Emacs handle teext mime for instance.xs 428 // to make Emacs handle teext mime for instance.xs
434 if (!webkit_web_view_can_show_mime_type (webView, mimetype)) 429 if (!webkit_web_view_can_show_mime_type (webView, mimetype))
435 { 430 {
@@ -502,13 +497,13 @@ xwidget_osr_event_forward (GtkWidget * widget,
502 GdkEvent * event, 497 GdkEvent * event,
503 gpointer user_data) 498 gpointer user_data)
504{ 499{
505 /* Copy events that arrive at the outer widget to the offscreen widget. */ 500 /* Copy events that arrive at the outer widget to the offscreen widget. */
506 struct xwidget *xw = 501 struct xwidget *xw =
507 (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); 502 (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
508 GdkEvent *eventcopy = gdk_event_copy (event); 503 GdkEvent *eventcopy = gdk_event_copy (event);
509 eventcopy->any.window = gtk_widget_get_window (xw->widget_osr); 504 eventcopy->any.window = gtk_widget_get_window (xw->widget_osr);
510 505
511 //TODO This might leak events. They should be deallocated later, 506 //TODO This might leak events. They should be deallocated later,
512 //perhaps in xwgir_event_cb 507 //perhaps in xwgir_event_cb
513 gtk_main_do_event (eventcopy); 508 gtk_main_do_event (eventcopy);
514 return TRUE; //dont propagate this event furter 509 return TRUE; //dont propagate this event furter
@@ -528,7 +523,7 @@ xwidget_osr_event_set_embedder (GtkWidget * widget,
528} 523}
529 524
530 525
531/* Initializes and does initial placement of an xwidget view on screen. */ 526/* Initializes and does initial placement of an xwidget view on screen. */
532static struct xwidget_view * 527static struct xwidget_view *
533xwidget_init_view (struct xwidget *xww, 528xwidget_init_view (struct xwidget *xww,
534 struct glyph_string *s, 529 struct glyph_string *s,
@@ -653,9 +648,9 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
653 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y); 648 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y);
654 clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y); 649 clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y);
655 650
656 // We are conserned with movement of the onscreen area. The area 651 // We are conserned with movement of the onscreen area. The area
657 // might sit still when the widget actually moves. This happens 652 // might sit still when the widget actually moves. This happens
658 // when an Emacs window border moves across a widget window. So, if 653 // when an Emacs window border moves across a widget window. So, if
659 // any corner of the outer widget clipping window moves, that counts 654 // any corner of the outer widget clipping window moves, that counts
660 // as movement here, even if it looks like no movement happens 655 // as movement here, even if it looks like no movement happens
661 // because the widget sits still inside the clipping area. The 656 // because the widget sits still inside the clipping area. The
@@ -671,8 +666,8 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
671 xv->widgetwindow, x + clip_left, y + clip_top); 666 xv->widgetwindow, x + clip_left, y + clip_top);
672 } 667 }
673 // Clip the widget window if some parts happen to be outside 668 // Clip the widget window if some parts happen to be outside
674 // drawable area. An Emacs window is not a gtk window. A gtk window 669 // drawable area. An Emacs window is not a gtk window. A gtk window
675 // covers the entire frame. Clipping might have changed even if we 670 // covers the entire frame. Clipping might have changed even if we
676 // havent actualy moved, we try figure out when we need to reclip 671 // havent actualy moved, we try figure out when we need to reclip
677 // for real. 672 // for real.
678 if ((xv->clip_right != clip_right) 673 if ((xv->clip_right != clip_right)
@@ -690,9 +685,9 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
690 xv->clip_left = clip_left; 685 xv->clip_left = clip_left;
691 } 686 }
692 // If emacs wants to repaint the area where the widget lives, queue 687 // If emacs wants to repaint the area where the widget lives, queue
693 // a redraw. It seems its possible to get out of sync with emacs 688 // a redraw. It seems its possible to get out of sync with emacs
694 // redraws so emacs background sometimes shows up instead of the 689 // redraws so emacs background sometimes shows up instead of the
695 // xwidgets background. It's just a visual glitch though. 690 // xwidgets background. It's just a visual glitch though.
696 if (!xwidget_hidden (xv)) 691 if (!xwidget_hidden (xv))
697 { 692 {
698 gtk_widget_queue_draw (xv->widgetwindow); 693 gtk_widget_queue_draw (xv->widgetwindow);
@@ -717,8 +712,7 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
717DEFUN ("xwidget-webkit-goto-uri", 712DEFUN ("xwidget-webkit-goto-uri",
718 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri, 713 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri,
719 2, 2, 0, 714 2, 2, 0,
720 doc: /* Make the xwidget webkit instance referenced by XWIDGET 715 doc: /* Make the xwidget webkit instance referenced by XWIDGET browse URI. */)
721browse URI. */)
722 (Lisp_Object xwidget, Lisp_Object uri) 716 (Lisp_Object xwidget, Lisp_Object uri)
723{ 717{
724 WEBKIT_FN_INIT (); 718 WEBKIT_FN_INIT ();
@@ -744,7 +738,7 @@ DEFUN ("xwidget-webkit-execute-script",
744DEFUN ("xwidget-webkit-get-title", 738DEFUN ("xwidget-webkit-get-title",
745 Fxwidget_webkit_get_title, Sxwidget_webkit_get_title, 739 Fxwidget_webkit_get_title, Sxwidget_webkit_get_title,
746 1, 1, 0, 740 1, 1, 0,
747 doc: /* Returns the title from the Webkit instance in XWIDGET. 741 doc: /* Return the title from the Webkit instance in XWIDGET.
748This can be used to work around the lack of a return value from the 742This can be used to work around the lack of a return value from the
749exec method. */ ) 743exec method. */ )
750 (Lisp_Object xwidget) 744 (Lisp_Object xwidget)
@@ -755,7 +749,7 @@ exec method. */ )
755 webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr)); 749 webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr));
756 if (str == 0) 750 if (str == 0)
757 { 751 {
758 // TODO maybe return Qnil instead. I suppose webkit returns 752 // TODO maybe return Qnil instead. I suppose webkit returns
759 // nullpointer when doc is not properly loaded or something 753 // nullpointer when doc is not properly loaded or something
760 return build_string (""); 754 return build_string ("");
761 } 755 }
@@ -763,8 +757,7 @@ exec method. */ )
763} 757}
764 758
765DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0, 759DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
766 doc: /* Resize XWIDGET. NEW_WIDTH NEW_HEIGHT defines the new 760 doc: /* Resize XWIDGET. NEW_WIDTH, NEW_HEIGHT define the new size. */ )
767size. */ )
768 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height) 761 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height)
769{ 762{
770 CHECK_XWIDGET (xwidget); 763 CHECK_XWIDGET (xwidget);
@@ -817,8 +810,9 @@ size. */ )
817 810
818DEFUN ("xwidget-set-adjustment", 811DEFUN ("xwidget-set-adjustment",
819 Fxwidget_set_adjustment, Sxwidget_set_adjustment, 4, 4, 0, 812 Fxwidget_set_adjustment, Sxwidget_set_adjustment, 4, 4, 0,
820 doc: /* Set native scrolling for XWIDGET. AXIS can be 'vertical or 813 doc: /* Set native scrolling for XWIDGET.
821'horizontal. If RELATIVE is t, scroll relative, otherwise absolutely. 814AXIS can be 'vertical or 'horizontal.
815If RELATIVE is t, scroll relative, otherwise absolutely.
822VALUE is the amount to scroll, either relatively or absolutely. */) 816VALUE is the amount to scroll, either relatively or absolutely. */)
823 (Lisp_Object xwidget, Lisp_Object axis, Lisp_Object relative, 817 (Lisp_Object xwidget, Lisp_Object axis, Lisp_Object relative,
824 Lisp_Object value) 818 Lisp_Object value)
@@ -863,7 +857,6 @@ DEFUN ("xwidget-size-request",
863 Fxwidget_size_request, Sxwidget_size_request, 857 Fxwidget_size_request, Sxwidget_size_request,
864 1, 1, 0, 858 1, 1, 0,
865 doc: /* Return the desired size of the XWIDGET. 859 doc: /* Return the desired size of the XWIDGET.
866
867This can be used to read the xwidget desired size, and resizes the 860This can be used to read the xwidget desired size, and resizes the
868Emacs allocated area accordingly. */) 861Emacs allocated area accordingly. */)
869 (Lisp_Object xwidget) 862 (Lisp_Object xwidget)
@@ -882,7 +875,7 @@ Emacs allocated area accordingly. */)
882DEFUN ("xwidgetp", 875DEFUN ("xwidgetp",
883 Fxwidgetp, Sxwidgetp, 876 Fxwidgetp, Sxwidgetp,
884 1, 1, 0, 877 1, 1, 0,
885 doc: /* Return t if OBJECT is a xwidget. */) 878 doc: /* Return t if OBJECT is an xwidget. */)
886 (Lisp_Object object) 879 (Lisp_Object object)
887{ 880{
888 return XWIDGETP (object) ? Qt : Qnil; 881 return XWIDGETP (object) ? Qt : Qnil;
@@ -891,7 +884,7 @@ DEFUN ("xwidgetp",
891DEFUN ("xwidget-view-p", 884DEFUN ("xwidget-view-p",
892 Fxwidget_view_p, Sxwidget_view_p, 885 Fxwidget_view_p, Sxwidget_view_p,
893 1, 1, 0, 886 1, 1, 0,
894 doc: /* Return t if OBJECT is a xwidget-view. */) 887 doc: /* Return t if OBJECT is an xwidget-view. */)
895 (Lisp_Object object) 888 (Lisp_Object object)
896{ 889{
897 return XWIDGET_VIEW_P (object) ? Qt : Qnil; 890 return XWIDGET_VIEW_P (object) ? Qt : Qnil;
@@ -900,8 +893,8 @@ DEFUN ("xwidget-view-p",
900DEFUN ("xwidget-info", 893DEFUN ("xwidget-info",
901 Fxwidget_info, Sxwidget_info, 894 Fxwidget_info, Sxwidget_info,
902 1, 1, 0, 895 1, 1, 0,
903 doc: /* Return XWIDGET properties in a vector. Currently [TYPE 896 doc: /* Return XWIDGET properties in a vector.
904TITLE WIDTH HEIGHT]. */) 897Currently [TYPE TITLE WIDTH HEIGHT]. */)
905 (Lisp_Object xwidget) 898 (Lisp_Object xwidget)
906{ 899{
907 CHECK_XWIDGET (xwidget); 900 CHECK_XWIDGET (xwidget);
@@ -923,7 +916,7 @@ DEFUN ("xwidget-view-info",
923 Fxwidget_view_info, Sxwidget_view_info, 916 Fxwidget_view_info, Sxwidget_view_info,
924 1, 1, 0, 917 1, 1, 0,
925 doc: /* Return properties of XWIDGET-VIEW in a vector. 918 doc: /* Return properties of XWIDGET-VIEW in a vector.
926Currently [X Y CLIP_RIGHT CLIP_BOTTOM CLIP_TOP CLIP_LEFT] */) 919Currently [X Y CLIP_RIGHT CLIP_BOTTOM CLIP_TOP CLIP_LEFT]. */)
927 (Lisp_Object xwidget_view) 920 (Lisp_Object xwidget_view)
928{ 921{
929 CHECK_XWIDGET_VIEW (xwidget_view); 922 CHECK_XWIDGET_VIEW (xwidget_view);
@@ -944,7 +937,7 @@ Currently [X Y CLIP_RIGHT CLIP_BOTTOM CLIP_TOP CLIP_LEFT] */)
944DEFUN ("xwidget-view-model", 937DEFUN ("xwidget-view-model",
945 Fxwidget_view_model, Sxwidget_view_model, 938 Fxwidget_view_model, Sxwidget_view_model,
946 1, 1, 0, 939 1, 1, 0,
947 doc: /* Return the model associated with XWIDGET-VIEW. */) 940 doc: /* Return the model associated with XWIDGET-VIEW. */)
948 (Lisp_Object xwidget_view) 941 (Lisp_Object xwidget_view)
949{ 942{
950 CHECK_XWIDGET_VIEW (xwidget_view); 943 CHECK_XWIDGET_VIEW (xwidget_view);
@@ -954,7 +947,7 @@ DEFUN ("xwidget-view-model",
954DEFUN ("xwidget-view-window", 947DEFUN ("xwidget-view-window",
955 Fxwidget_view_window, Sxwidget_view_window, 948 Fxwidget_view_window, Sxwidget_view_window,
956 1, 1, 0, 949 1, 1, 0,
957 doc: /* Return the window of XWIDGET-VIEW. */) 950 doc: /* Return the window of XWIDGET-VIEW. */)
958 (Lisp_Object xwidget_view) 951 (Lisp_Object xwidget_view)
959{ 952{
960 CHECK_XWIDGET_VIEW (xwidget_view); 953 CHECK_XWIDGET_VIEW (xwidget_view);
@@ -965,15 +958,15 @@ DEFUN ("xwidget-view-window",
965DEFUN ("delete-xwidget-view", 958DEFUN ("delete-xwidget-view",
966 Fdelete_xwidget_view, Sdelete_xwidget_view, 959 Fdelete_xwidget_view, Sdelete_xwidget_view,
967 1, 1, 0, 960 1, 1, 0,
968 doc: /* Delete the XWIDGET-VIEW. */) 961 doc: /* Delete the XWIDGET-VIEW. */)
969 (Lisp_Object xwidget_view) 962 (Lisp_Object xwidget_view)
970{ 963{
971 CHECK_XWIDGET_VIEW (xwidget_view); 964 CHECK_XWIDGET_VIEW (xwidget_view);
972 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view); 965 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view);
973 gtk_widget_destroy (xv->widgetwindow); 966 gtk_widget_destroy (xv->widgetwindow);
974 Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list); 967 Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list);
975 // xv->model still has signals pointing to the view. There can be 968 // xv->model still has signals pointing to the view. There can be
976 // several views. Find the matching signals and delete them all. 969 // several views. Find the matching signals and delete them all.
977 g_signal_handlers_disconnect_matched (XXWIDGET (xv->model)->widgetwindow_osr, 970 g_signal_handlers_disconnect_matched (XXWIDGET (xv->model)->widgetwindow_osr,
978 G_SIGNAL_MATCH_DATA, 971 G_SIGNAL_MATCH_DATA,
979 0, 0, 0, 0, 972 0, 0, 0, 0,
@@ -984,9 +977,9 @@ DEFUN ("delete-xwidget-view",
984DEFUN ("xwidget-view-lookup", 977DEFUN ("xwidget-view-lookup",
985 Fxwidget_view_lookup, Sxwidget_view_lookup, 978 Fxwidget_view_lookup, Sxwidget_view_lookup,
986 1, 2, 0, 979 1, 2, 0,
987 doc: /* Return the xwidget-view associated with XWIDGET in 980 doc: /* Return the xwidget-view associated with XWIDGET in WINDOW.
988WINDOW if specified, otherwise it uses the selected window. Return nil 981If WINDOW is unspecified or nil, use the selected window.
989if no association is found. */) 982Return nil if no association is found. */)
990 (Lisp_Object xwidget, Lisp_Object window) 983 (Lisp_Object xwidget, Lisp_Object window)
991{ 984{
992 CHECK_XWIDGET (xwidget); 985 CHECK_XWIDGET (xwidget);
@@ -1044,10 +1037,10 @@ Returns PLIST. */)
1044DEFUN ("set-xwidget-query-on-exit-flag", 1037DEFUN ("set-xwidget-query-on-exit-flag",
1045 Fset_xwidget_query_on_exit_flag, Sset_xwidget_query_on_exit_flag, 1038 Fset_xwidget_query_on_exit_flag, Sset_xwidget_query_on_exit_flag,
1046 2, 2, 0, 1039 2, 2, 0,
1047 doc: /* Specify if query is needed for XWIDGET when 1040 doc: /* Specify if query is needed for XWIDGET when Emacs is exited.
1048Emacs is exited. If the second argument FLAG is non-nil, Emacs will 1041If the second argument FLAG is non-nil, Emacs will query the user before
1049queries the user before exiting or killing a buffer if XWIDGET is 1042exiting or killing a buffer if XWIDGET is running.
1050running. This function returns FLAG. */) 1043This function returns FLAG. */)
1051 (Lisp_Object xwidget, Lisp_Object flag) 1044 (Lisp_Object xwidget, Lisp_Object flag)
1052{ 1045{
1053 CHECK_XWIDGET (xwidget); 1046 CHECK_XWIDGET (xwidget);
@@ -1058,8 +1051,7 @@ running. This function returns FLAG. */)
1058DEFUN ("xwidget-query-on-exit-flag", 1051DEFUN ("xwidget-query-on-exit-flag",
1059 Fxwidget_query_on_exit_flag, Sxwidget_query_on_exit_flag, 1052 Fxwidget_query_on_exit_flag, Sxwidget_query_on_exit_flag,
1060 1, 1, 0, 1053 1, 1, 0,
1061 doc: /* Return the current value of query-on-exit 1054 doc: /* Return the current value of the query-on-exit flag for XWIDGET. */)
1062flag for XWIDGET. */)
1063 (Lisp_Object xwidget) 1055 (Lisp_Object xwidget)
1064{ 1056{
1065 CHECK_XWIDGET (xwidget); 1057 CHECK_XWIDGET (xwidget);
@@ -1107,7 +1099,7 @@ syms_of_xwidget (void)
1107 DEFSYM (QCtitle, ":title"); 1099 DEFSYM (QCtitle, ":title");
1108 1100
1109 /* Do not forget to update the docstring of make-xwidget if you add 1101 /* Do not forget to update the docstring of make-xwidget if you add
1110 new types. */ 1102 new types. */
1111 1103
1112 DEFSYM (Qvertical, "vertical"); 1104 DEFSYM (Qvertical, "vertical");
1113 DEFSYM (Qhorizontal, "horizontal"); 1105 DEFSYM (Qhorizontal, "horizontal");
@@ -1219,7 +1211,7 @@ lookup_xwidget (Lisp_Object spec)
1219 return xw; 1211 return xw;
1220} 1212}
1221 1213
1222/* Set up detection of touched xwidget*/ 1214/* Set up detection of touched xwidget */
1223void 1215void
1224xwidget_start_redisplay (void) 1216xwidget_start_redisplay (void)
1225{ 1217{
@@ -1258,7 +1250,7 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
1258 // Iterate desired glyph matrix of window here, hide gtk widgets 1250 // Iterate desired glyph matrix of window here, hide gtk widgets
1259 // not in the desired matrix. 1251 // not in the desired matrix.
1260 1252
1261 // This only takes care of xwidgets in active windows. if a window 1253 // This only takes care of xwidgets in active windows. If a window
1262 // goes away from screen xwidget views wust be deleted 1254 // goes away from screen xwidget views wust be deleted
1263 1255
1264 // dump_glyph_matrix (matrix, 2); 1256 // dump_glyph_matrix (matrix, 2);
@@ -1309,7 +1301,7 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
1309 } 1301 }
1310} 1302}
1311 1303
1312/* Kill all xwidget in BUFFER. */ 1304/* Kill all xwidget in BUFFER. */
1313void 1305void
1314kill_buffer_xwidgets (Lisp_Object buffer) 1306kill_buffer_xwidgets (Lisp_Object buffer)
1315{ 1307{