aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-01-22 11:15:05 -0800
committerPaul Eggert2016-01-22 11:15:31 -0800
commit7c3d742c357dd6480e813f067435b324dba2b325 (patch)
tree6b393225ad885e16e829a96d070cd94ab0171ac9 /src
parent7bf54d01159eb09bae3c9cd86f2af0812d9afdf6 (diff)
downloademacs-7c3d742c357dd6480e813f067435b324dba2b325.tar.gz
emacs-7c3d742c357dd6480e813f067435b324dba2b325.zip
xwidgets style cleanup
Adjust the newly-added Xwidgets code so that it uses a more-typical Emacs style. This should not affect behavior, except that in a few places it adds runtime checks that Lisp arguments are of the proper type, and in one place it uses more-precise arithmetic. * src/buffer.c, src/dispnew.c, src/emacs.c, src/emacsgtkfixed.c: * src/emacs.c, src/print.c, src/window.c, src/xdisp.c, src/xterm.c: Include xwidget.h unconditionally. * src/buffer.c (Fkill_buffer): * src/dispnew.c (update_window): * src/emacs.c (main): * src/print.c (print_object): * src/window.c (Fdelete_window_internal): * src/xdisp.c (handle_single_display_spec, push_it, pop_it) (get_next_element, set_iterator_to_next, next_element_from_xwidget) (dump_glyph, calc_pixel_width_or_height, BUILD_GLYPH_STRINGS_XW) (BUILD_GLYPH_STRINGS, x_produce_glyphs, get_window_cursor_type): * src/xterm.c (x_draw_glyph_string, x_draw_bar_cursor): Call xwidget functions and macros without worrying about HAVE_XWIDGETS when the code is a no-op on non-xwidget platforms. * src/dispextern.h (XWIDGET_GLYPH, struct glyph_string.xwidget) (IT_XWIDGET, GET_FROM_XWIDGET, struct it.u.xwidget) (struct it.xwidget): * src/lisp.h (PVEC_XWIDGET, PVEC_XWIDGET_VIEW): Always define. * src/emacsgtkfixed.h: Omit unnecessary comment. * src/keyboard.c: Fix spacing. * src/xdisp.c (BUILD_XWIDGET_GLYPH_STRING, produce_xwidget_glyph): Define to be a no-op if not HAVE_XWIDGETS. * src/xwidget.c: Include xwidget.h first (after config.h) to make sure that it can stand by itself. (Fmake_xwidget, Fxwidget_webkit_execute_script): Fix typo in doc string. (Fmake_xwidget): Check type of args. (Fmake_xwidget, offscreen_damage_event) (webkit_document_load_finished_cb, webkit_download_cb) (webkit_new_window_policy_decision_requested_cb) (webkit_navigation_policy_decision_requested_cb) (xwidget_osr_draw_cb, xwidget_osr_event_forward) (xwidget_osr_event_set_embedder, xwidget_init_view): Omit unnecessary casts. * src/xwidget.c (Fmake_xwidget, xwidget_hidden) (xwidget_show_view, xwidget_hide_view) (x_draw_xwidget_glyph_string, xwidget_start_redisplay, xwidget_touch) (xwidget_touched): * src/xwidget.h (struct xwidget.kill_without_query) (struct xwidget_view.redisplayed, struct xwidget_view.hidden): Use bool for boolean. * src/xwidget.c (store_xwidget_event_string, Fxwidget_size_request): Simplify by using list functions. (WEBKIT_FN_INIT): Omit unnecessary test for nil. (Fxwidget_resize): Check type of integer args before doing any work. Check that they are nonnegative. (Fxwidget_set_adjustment): Check type of integer arg. Avoid redundant call to gtk_scrolled_window_get_vadjustment. Simplify. Use double, not float. (Fxwidget_info, Fxwidget_view_info): Simplify by using CALLN. (valid_xwidget_spec_p): Simplify. (xwidget_spec_value): Omit unused arg FOUND. All callers changed. * src/xwidget.h: Include lisp.h first, so that includers do not need to worry about doing that before including this file. Make this .h file safe to include even on non-HAVE_XWIDGETS configurations, to simplify the includers. (x_draw_xwidget_glyph_string, syms_of_xwidget, valid_xwidget_spec_p) (xwidget_end_redisplay, lookup_xwidget) (xwidget_view_delete_all_in_window, kill_buffer_xwidgets): Now a no-op if !HAVE_XWIDGETS, to simplify callers. (struct glyph_matrix, struct glyph_string, struct xwidget) (struct xwidget_view, struct window): New forward or incomplete decls, so that includers need not assume the corresponding .h files are already included, or that HAVE_XWIDGETS is defined. (struct xwidget_type, xwidget_from_id): Remove; unused.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c8
-rw-r--r--src/dispextern.h28
-rw-r--r--src/dispnew.c7
-rw-r--r--src/emacs.c7
-rw-r--r--src/emacsgtkfixed.c40
-rw-r--r--src/emacsgtkfixed.h2
-rw-r--r--src/keyboard.c4
-rw-r--r--src/lisp.h3
-rw-r--r--src/print.c14
-rw-r--r--src/window.c6
-rw-r--r--src/xdisp.c61
-rw-r--r--src/xterm.c11
-rw-r--r--src/xwidget.c554
-rw-r--r--src/xwidget.h115
14 files changed, 325 insertions, 535 deletions
diff --git a/src/buffer.c b/src/buffer.c
index a2981c90f66..74b6fb6a47f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -42,10 +42,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#include "blockinput.h" 42#include "blockinput.h"
43#include "keymap.h" 43#include "keymap.h"
44#include "frame.h" 44#include "frame.h"
45#include "xwidget.h"
45 46
46#ifdef HAVE_XWIDGETS
47# include "xwidget.h"
48#endif
49#ifdef WINDOWSNT 47#ifdef WINDOWSNT
50#include "w32heap.h" /* for mmap_* */ 48#include "w32heap.h" /* for mmap_* */
51#endif 49#endif
@@ -1749,10 +1747,8 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1749 unlock_buffer (b); 1747 unlock_buffer (b);
1750 1748
1751 kill_buffer_processes (buffer); 1749 kill_buffer_processes (buffer);
1752
1753#ifdef HAVE_XWIDGETS
1754 kill_buffer_xwidgets (buffer); 1750 kill_buffer_xwidgets (buffer);
1755#endif 1751
1756 /* Killing buffer processes may run sentinels which may have killed 1752 /* Killing buffer processes may run sentinels which may have killed
1757 our buffer. */ 1753 our buffer. */
1758 if (!BUFFER_LIVE_P (b)) 1754 if (!BUFFER_LIVE_P (b))
diff --git a/src/dispextern.h b/src/dispextern.h
index fad5bfd6f2f..7d7d7305b43 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -347,11 +347,10 @@ enum glyph_type
347 IMAGE_GLYPH, 347 IMAGE_GLYPH,
348 348
349 /* Glyph is a space of fractional width and/or height. */ 349 /* Glyph is a space of fractional width and/or height. */
350 STRETCH_GLYPH 350 STRETCH_GLYPH,
351#ifdef HAVE_XWIDGETS 351
352 /* Glyph is an external widget drawn by the GUI toolkit. */ 352 /* Glyph is an external widget drawn by the GUI toolkit. */
353 ,XWIDGET_GLYPH 353 XWIDGET_GLYPH
354#endif
355}; 354};
356 355
357 356
@@ -504,8 +503,10 @@ struct glyph
504 int img_id; 503 int img_id;
505 504
506#ifdef HAVE_XWIDGETS 505#ifdef HAVE_XWIDGETS
506 /* Xwidget reference (type == XWIDGET_GLYPH). */
507 struct xwidget *xwidget; 507 struct xwidget *xwidget;
508#endif 508#endif
509
509 /* Sub-structure for type == STRETCH_GLYPH. */ 510 /* Sub-structure for type == STRETCH_GLYPH. */
510 struct 511 struct
511 { 512 {
@@ -1357,9 +1358,9 @@ struct glyph_string
1357 /* Image, if any. */ 1358 /* Image, if any. */
1358 struct image *img; 1359 struct image *img;
1359 1360
1360#ifdef HAVE_XWIDGETS 1361 /* Xwidget. */
1361 struct xwidget *xwidget; 1362 struct xwidget *xwidget;
1362#endif 1363
1363 /* Slice */ 1364 /* Slice */
1364 struct glyph_slice slice; 1365 struct glyph_slice slice;
1365 1366
@@ -2111,11 +2112,10 @@ enum display_element_type
2111 IT_TRUNCATION, 2112 IT_TRUNCATION,
2112 2113
2113 /* Continuation glyphs. See the comment for IT_TRUNCATION. */ 2114 /* Continuation glyphs. See the comment for IT_TRUNCATION. */
2114 IT_CONTINUATION 2115 IT_CONTINUATION,
2115 2116
2116#ifdef HAVE_XWIDGETS 2117 /* Xwidget. */
2117 ,IT_XWIDGET 2118 IT_XWIDGET
2118#endif
2119}; 2119};
2120 2120
2121 2121
@@ -2179,9 +2179,7 @@ enum it_method {
2179 GET_FROM_C_STRING, 2179 GET_FROM_C_STRING,
2180 GET_FROM_IMAGE, 2180 GET_FROM_IMAGE,
2181 GET_FROM_STRETCH, 2181 GET_FROM_STRETCH,
2182#ifdef HAVE_XWIDGETS
2183 GET_FROM_XWIDGET, 2182 GET_FROM_XWIDGET,
2184#endif
2185 NUM_IT_METHODS 2183 NUM_IT_METHODS
2186}; 2184};
2187 2185
@@ -2399,12 +2397,10 @@ struct it
2399 struct { 2397 struct {
2400 Lisp_Object object; 2398 Lisp_Object object;
2401 } stretch; 2399 } stretch;
2402#ifdef HAVE_XWIDGETS
2403 /* method == GET_FROM_XWIDGET */ 2400 /* method == GET_FROM_XWIDGET */
2404 struct { 2401 struct {
2405 Lisp_Object object; 2402 Lisp_Object object;
2406 } xwidget; 2403 } xwidget;
2407#endif
2408 } u; 2404 } u;
2409 2405
2410 /* Current text and display positions. */ 2406 /* Current text and display positions. */
@@ -2529,10 +2525,8 @@ struct it
2529 /* If what == IT_IMAGE, the id of the image to display. */ 2525 /* If what == IT_IMAGE, the id of the image to display. */
2530 ptrdiff_t image_id; 2526 ptrdiff_t image_id;
2531 2527
2532#ifdef HAVE_XWIDGETS
2533 /* If what == IT_XWIDGET. */ 2528 /* If what == IT_XWIDGET. */
2534 struct xwidget *xwidget; 2529 struct xwidget *xwidget;
2535#endif
2536 2530
2537 /* Values from `slice' property. */ 2531 /* Values from `slice' property. */
2538 struct it_slice slice; 2532 struct it_slice slice;
diff --git a/src/dispnew.c b/src/dispnew.c
index 571ed5f851f..433a6e9ed4a 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -39,15 +39,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include "syssignal.h" 39#include "syssignal.h"
40#include "systime.h" 40#include "systime.h"
41#include "tparam.h" 41#include "tparam.h"
42#include "xwidget.h"
42 43
43#ifdef HAVE_WINDOW_SYSTEM 44#ifdef HAVE_WINDOW_SYSTEM
44#include TERM_HEADER 45#include TERM_HEADER
45#endif /* HAVE_WINDOW_SYSTEM */ 46#endif /* HAVE_WINDOW_SYSTEM */
46 47
47#ifdef HAVE_XWIDGETS
48# include "xwidget.h"
49#endif
50
51#include <errno.h> 48#include <errno.h>
52 49
53#include <fpending.h> 50#include <fpending.h>
@@ -3549,9 +3546,7 @@ update_window (struct window *w, bool force_p)
3549 add_window_display_history (w, w->current_matrix->method, paused_p); 3546 add_window_display_history (w, w->current_matrix->method, paused_p);
3550#endif 3547#endif
3551 3548
3552#ifdef HAVE_XWIDGETS
3553 xwidget_end_redisplay (w, w->current_matrix); 3549 xwidget_end_redisplay (w, w->current_matrix);
3554#endif
3555 clear_glyph_matrix (desired_matrix); 3550 clear_glyph_matrix (desired_matrix);
3556 3551
3557 return paused_p; 3552 return paused_p;
diff --git a/src/emacs.c b/src/emacs.c
index ddaa82c1f64..41113f84331 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -65,10 +65,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
65#include "character.h" 65#include "character.h"
66#include "buffer.h" 66#include "buffer.h"
67#include "window.h" 67#include "window.h"
68 68#include "xwidget.h"
69#ifdef HAVE_XWIDGETS
70# include "xwidget.h"
71#endif
72#include "atimer.h" 69#include "atimer.h"
73#include "blockinput.h" 70#include "blockinput.h"
74#include "syssignal.h" 71#include "syssignal.h"
@@ -1492,9 +1489,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1492 syms_of_xfns (); 1489 syms_of_xfns ();
1493 syms_of_xmenu (); 1490 syms_of_xmenu ();
1494 syms_of_fontset (); 1491 syms_of_fontset ();
1495#ifdef HAVE_XWIDGETS
1496 syms_of_xwidget (); 1492 syms_of_xwidget ();
1497#endif
1498 syms_of_xsettings (); 1493 syms_of_xsettings ();
1499#ifdef HAVE_X_SM 1494#ifdef HAVE_X_SM
1500 syms_of_xsmfns (); 1495 syms_of_xsmfns ();
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 08b840389c5..6795155831e 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -23,9 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include "lisp.h" 23#include "lisp.h"
24#include "frame.h" 24#include "frame.h"
25#include "xterm.h" 25#include "xterm.h"
26#ifdef HAVE_XWIDGETS 26#include "xwidget.h"
27# include "xwidget.h"
28#endif
29#include "emacsgtkfixed.h" 27#include "emacsgtkfixed.h"
30 28
31/* Silence a bogus diagnostic; see GNOME bug 683906. */ 29/* Silence a bogus diagnostic; see GNOME bug 683906. */
@@ -50,7 +48,6 @@ static void emacs_fixed_get_preferred_width (GtkWidget *widget,
50static void emacs_fixed_get_preferred_height (GtkWidget *widget, 48static void emacs_fixed_get_preferred_height (GtkWidget *widget,
51 gint *minimum, 49 gint *minimum,
52 gint *natural); 50 gint *natural);
53
54static GType emacs_fixed_get_type (void); 51static GType emacs_fixed_get_type (void);
55G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) 52G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
56 53
@@ -75,28 +72,28 @@ struct GtkFixedPrivateL
75 GList *children; 72 GList *children;
76}; 73};
77 74
78static void emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget, 75static void
79 GtkAllocation *allocation) 76emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget,
77 GtkAllocation *allocation)
80{ 78{
81 // For xwidgets. 79 /* For xwidgets.
82 80
83 // This basically re-implements the base class method and adds an 81 This basically re-implements the base class method and adds an
84 // additional case for an xwidget view. 82 additional case for an xwidget view.
85 83
86 // It would be nicer if the bse class method could be called first, 84 It would be nicer if the bse class method could be called first,
87 // and the the xview modification only would remain here. It wasn't 85 and the the xview modification only would remain here. It wasn't
88 // possible to solve it that way yet. 86 possible to solve it that way yet. */
89 EmacsFixedClass *klass; 87 EmacsFixedClass *klass;
90 GtkWidgetClass *parent_class; 88 GtkWidgetClass *parent_class;
91 struct GtkFixedPrivateL* priv; 89 struct GtkFixedPrivateL *priv;
92 90
93 klass = EMACS_FIXED_GET_CLASS (widget); 91 klass = EMACS_FIXED_GET_CLASS (widget);
94 parent_class = g_type_class_peek_parent (klass); 92 parent_class = g_type_class_peek_parent (klass);
95 parent_class->size_allocate (widget, allocation); 93 parent_class->size_allocate (widget, allocation);
96 94
97 priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, 95 priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, GTK_TYPE_FIXED,
98 GTK_TYPE_FIXED, 96 struct GtkFixedPrivateL);
99 struct GtkFixedPrivateL);
100 97
101 gtk_widget_set_allocation (widget, allocation); 98 gtk_widget_set_allocation (widget, allocation);
102 99
@@ -154,7 +151,6 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
154 151
155 widget_class = (GtkWidgetClass*) klass; 152 widget_class = (GtkWidgetClass*) klass;
156 153
157
158 widget_class->get_preferred_width = emacs_fixed_get_preferred_width; 154 widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
159 widget_class->get_preferred_height = emacs_fixed_get_preferred_height; 155 widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
160#ifdef HAVE_XWIDGETS 156#ifdef HAVE_XWIDGETS
@@ -163,7 +159,6 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
163 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); 159 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
164} 160}
165 161
166
167static void 162static void
168emacs_fixed_init (EmacsFixed *fixed) 163emacs_fixed_init (EmacsFixed *fixed)
169{ 164{
@@ -172,14 +167,7 @@ emacs_fixed_init (EmacsFixed *fixed)
172 fixed->priv->f = 0; 167 fixed->priv->f = 0;
173} 168}
174 169
175/** 170GtkWidget *
176 * emacs_fixed_new:
177 *
178 * Creates a new #EmacsFixed.
179 *
180 * Returns: a new #EmacsFixed.
181 */
182GtkWidget*
183emacs_fixed_new (struct frame *f) 171emacs_fixed_new (struct frame *f)
184{ 172{
185 EmacsFixed *fixed = g_object_new (emacs_fixed_get_type (), NULL); 173 EmacsFixed *fixed = g_object_new (emacs_fixed_get_type (), NULL);
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h
index 378bd2b828c..72652c53104 100644
--- a/src/emacsgtkfixed.h
+++ b/src/emacsgtkfixed.h
@@ -29,7 +29,6 @@ G_BEGIN_DECLS
29 29
30struct frame; 30struct frame;
31 31
32//typedef struct _EmacsFixed EmacsFixed;
33typedef struct _EmacsFixedPrivate EmacsFixedPrivate; 32typedef struct _EmacsFixedPrivate EmacsFixedPrivate;
34typedef struct _EmacsFixedClass EmacsFixedClass; 33typedef struct _EmacsFixedClass EmacsFixedClass;
35 34
@@ -41,7 +40,6 @@ struct _EmacsFixed
41 EmacsFixedPrivate *priv; 40 EmacsFixedPrivate *priv;
42}; 41};
43 42
44
45struct _EmacsFixedClass 43struct _EmacsFixedClass
46{ 44{
47 GtkFixedClass parent_class; 45 GtkFixedClass parent_class;
diff --git a/src/keyboard.c b/src/keyboard.c
index c93876effd9..3cddd4119dd 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5960,7 +5960,7 @@ make_lispy_event (struct input_event *event)
5960#ifdef HAVE_XWIDGETS 5960#ifdef HAVE_XWIDGETS
5961 case XWIDGET_EVENT: 5961 case XWIDGET_EVENT:
5962 { 5962 {
5963 return Fcons (Qxwidget_event,event->arg); 5963 return Fcons (Qxwidget_event, event->arg);
5964 } 5964 }
5965#endif 5965#endif
5966 5966
@@ -10972,7 +10972,7 @@ syms_of_keyboard (void)
10972#endif 10972#endif
10973 10973
10974#ifdef HAVE_XWIDGETS 10974#ifdef HAVE_XWIDGETS
10975 DEFSYM (Qxwidget_event,"xwidget-event"); 10975 DEFSYM (Qxwidget_event, "xwidget-event");
10976#endif 10976#endif
10977 10977
10978#ifdef USE_FILE_NOTIFY 10978#ifdef USE_FILE_NOTIFY
diff --git a/src/lisp.h b/src/lisp.h
index 8aa034e9e57..ee055e90699 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -799,11 +799,8 @@ enum pvec_type
799 PVEC_WINDOW_CONFIGURATION, 799 PVEC_WINDOW_CONFIGURATION,
800 PVEC_SUBR, 800 PVEC_SUBR,
801 PVEC_OTHER, 801 PVEC_OTHER,
802
803#ifdef HAVE_XWIDGETS
804 PVEC_XWIDGET, 802 PVEC_XWIDGET,
805 PVEC_XWIDGET_VIEW, 803 PVEC_XWIDGET_VIEW,
806#endif
807 804
808 /* These should be last, check internal_equal to see why. */ 805 /* These should be last, check internal_equal to see why. */
809 PVEC_COMPILED, 806 PVEC_COMPILED,
diff --git a/src/print.c b/src/print.c
index 4dd4e963093..2ecc0f52b47 100644
--- a/src/print.c
+++ b/src/print.c
@@ -32,10 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include "disptab.h" 32#include "disptab.h"
33#include "intervals.h" 33#include "intervals.h"
34#include "blockinput.h" 34#include "blockinput.h"
35 35#include "xwidget.h"
36#ifdef HAVE_XWIDGETS
37# include "xwidget.h"
38#endif
39 36
40#include <c-ctype.h> 37#include <c-ctype.h>
41#include <float.h> 38#include <float.h>
@@ -1740,18 +1737,11 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1740 print_c_string (XSUBR (obj)->symbol_name, printcharfun); 1737 print_c_string (XSUBR (obj)->symbol_name, printcharfun);
1741 printchar ('>', printcharfun); 1738 printchar ('>', printcharfun);
1742 } 1739 }
1743#ifdef HAVE_XWIDGETS 1740 else if (XWIDGETP (obj) || XWIDGET_VIEW_P (obj))
1744 else if (XWIDGETP (obj))
1745 { 1741 {
1746 print_c_string ("#<xwidget ", printcharfun); 1742 print_c_string ("#<xwidget ", printcharfun);
1747 printchar ('>', printcharfun); 1743 printchar ('>', printcharfun);
1748 } 1744 }
1749 else if (XWIDGET_VIEW_P (obj))
1750 {
1751 print_c_string ("#<xwidget ", printcharfun);
1752 printchar ('>', printcharfun);
1753 }
1754#endif
1755 else if (WINDOWP (obj)) 1745 else if (WINDOWP (obj))
1756 { 1746 {
1757 int len = sprintf (buf, "#<window %"pI"d", 1747 int len = sprintf (buf, "#<window %"pI"d",
diff --git a/src/window.c b/src/window.c
index 880ca4a46bb..9e065ead3ba 100644
--- a/src/window.c
+++ b/src/window.c
@@ -35,15 +35,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35#include "dispextern.h" 35#include "dispextern.h"
36#include "blockinput.h" 36#include "blockinput.h"
37#include "termhooks.h" /* For FRAME_TERMINAL. */ 37#include "termhooks.h" /* For FRAME_TERMINAL. */
38#include "xwidget.h"
38#ifdef HAVE_WINDOW_SYSTEM 39#ifdef HAVE_WINDOW_SYSTEM
39#include TERM_HEADER 40#include TERM_HEADER
40#endif /* HAVE_WINDOW_SYSTEM */ 41#endif /* HAVE_WINDOW_SYSTEM */
41#ifdef MSDOS 42#ifdef MSDOS
42#include "msdos.h" 43#include "msdos.h"
43#endif 44#endif
44#ifdef HAVE_XWIDGETS
45# include "xwidget.h"
46#endif
47 45
48static ptrdiff_t count_windows (struct window *); 46static ptrdiff_t count_windows (struct window *);
49static ptrdiff_t get_leaf_windows (struct window *, struct window **, 47static ptrdiff_t get_leaf_windows (struct window *, struct window **,
@@ -4373,9 +4371,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4373 4371
4374 /* Block input. */ 4372 /* Block input. */
4375 block_input (); 4373 block_input ();
4376#ifdef HAVE_XWIDGETS
4377 xwidget_view_delete_all_in_window (w); 4374 xwidget_view_delete_all_in_window (w);
4378#endif
4379 window_resize_apply (p, horflag); 4375 window_resize_apply (p, horflag);
4380 /* If this window is referred to by the dpyinfo's mouse 4376 /* If this window is referred to by the dpyinfo's mouse
4381 highlight, invalidate that slot to be safe (Bug#9904). */ 4377 highlight, invalidate that slot to be safe (Bug#9904). */
diff --git a/src/xdisp.c b/src/xdisp.c
index 89385c0e172..bba475f8938 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -314,13 +314,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
314#include "font.h" 314#include "font.h"
315#include "fontset.h" 315#include "fontset.h"
316#include "blockinput.h" 316#include "blockinput.h"
317#include "xwidget.h"
317#ifdef HAVE_WINDOW_SYSTEM 318#ifdef HAVE_WINDOW_SYSTEM
318#include TERM_HEADER 319#include TERM_HEADER
319#endif /* HAVE_WINDOW_SYSTEM */ 320#endif /* HAVE_WINDOW_SYSTEM */
320 321
321#ifdef HAVE_XWIDGETS
322# include "xwidget.h"
323#endif
324#ifndef FRAME_X_OUTPUT 322#ifndef FRAME_X_OUTPUT
325#define FRAME_X_OUTPUT(f) ((f)->output_data.x) 323#define FRAME_X_OUTPUT(f) ((f)->output_data.x)
326#endif 324#endif
@@ -857,9 +855,7 @@ static bool next_element_from_buffer (struct it *);
857static bool next_element_from_composition (struct it *); 855static bool next_element_from_composition (struct it *);
858static bool next_element_from_image (struct it *); 856static bool next_element_from_image (struct it *);
859static bool next_element_from_stretch (struct it *); 857static bool next_element_from_stretch (struct it *);
860#ifdef HAVE_XWIDGETS
861static bool next_element_from_xwidget (struct it *); 858static bool next_element_from_xwidget (struct it *);
862#endif
863static void load_overlay_strings (struct it *, ptrdiff_t); 859static void load_overlay_strings (struct it *, ptrdiff_t);
864static bool get_next_display_element (struct it *); 860static bool get_next_display_element (struct it *);
865static enum move_it_result 861static enum move_it_result
@@ -5147,11 +5143,8 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5147 && valid_image_p (value)) 5143 && valid_image_p (value))
5148#endif /* not HAVE_WINDOW_SYSTEM */ 5144#endif /* not HAVE_WINDOW_SYSTEM */
5149 || (CONSP (value) && EQ (XCAR (value), Qspace)) 5145 || (CONSP (value) && EQ (XCAR (value), Qspace))
5150#ifdef HAVE_XWIDGETS
5151 || ((it ? FRAME_WINDOW_P (it->f) : frame_window_p) 5146 || ((it ? FRAME_WINDOW_P (it->f) : frame_window_p)
5152 && valid_xwidget_spec_p (value)) 5147 && valid_xwidget_spec_p (value)));
5153#endif
5154 );
5155 5148
5156 if (valid_p && display_replaced == 0) 5149 if (valid_p && display_replaced == 0)
5157 { 5150 {
@@ -5226,17 +5219,15 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5226 *position = it->position = start_pos; 5219 *position = it->position = start_pos;
5227 retval = 1 + (it->area == TEXT_AREA); 5220 retval = 1 + (it->area == TEXT_AREA);
5228 } 5221 }
5229#ifdef HAVE_XWIDGETS 5222 else if (valid_xwidget_spec_p (value))
5230 else if (valid_xwidget_spec_p(value))
5231 { 5223 {
5232 it->what = IT_XWIDGET; 5224 it->what = IT_XWIDGET;
5233 it->method = GET_FROM_XWIDGET; 5225 it->method = GET_FROM_XWIDGET;
5234 it->position = start_pos; 5226 it->position = start_pos;
5235 it->object = NILP (object) ? it->w->contents : object; 5227 it->object = NILP (object) ? it->w->contents : object;
5236 *position = start_pos; 5228 *position = start_pos;
5237 it->xwidget = lookup_xwidget(value); 5229 it->xwidget = lookup_xwidget (value);
5238 } 5230 }
5239#endif
5240#ifdef HAVE_WINDOW_SYSTEM 5231#ifdef HAVE_WINDOW_SYSTEM
5241 else 5232 else
5242 { 5233 {
@@ -5989,11 +5980,9 @@ push_it (struct it *it, struct text_pos *position)
5989 case GET_FROM_STRETCH: 5980 case GET_FROM_STRETCH:
5990 p->u.stretch.object = it->object; 5981 p->u.stretch.object = it->object;
5991 break; 5982 break;
5992#ifdef HAVE_XWIDGETS
5993 case GET_FROM_XWIDGET: 5983 case GET_FROM_XWIDGET:
5994 p->u.xwidget.object = it->object; 5984 p->u.xwidget.object = it->object;
5995 break; 5985 break;
5996#endif
5997 case GET_FROM_BUFFER: 5986 case GET_FROM_BUFFER:
5998 case GET_FROM_DISPLAY_VECTOR: 5987 case GET_FROM_DISPLAY_VECTOR:
5999 case GET_FROM_STRING: 5988 case GET_FROM_STRING:
@@ -6095,11 +6084,9 @@ pop_it (struct it *it)
6095 it->object = p->u.image.object; 6084 it->object = p->u.image.object;
6096 it->slice = p->u.image.slice; 6085 it->slice = p->u.image.slice;
6097 break; 6086 break;
6098#ifdef HAVE_XWIDGETS
6099 case GET_FROM_XWIDGET: 6087 case GET_FROM_XWIDGET:
6100 it->object = p->u.xwidget.object; 6088 it->object = p->u.xwidget.object;
6101 break; 6089 break;
6102#endif
6103 case GET_FROM_STRETCH: 6090 case GET_FROM_STRETCH:
6104 it->object = p->u.stretch.object; 6091 it->object = p->u.stretch.object;
6105 break; 6092 break;
@@ -6775,9 +6762,7 @@ static next_element_function const get_next_element[NUM_IT_METHODS] =
6775 next_element_from_c_string, 6762 next_element_from_c_string,
6776 next_element_from_image, 6763 next_element_from_image,
6777 next_element_from_stretch, 6764 next_element_from_stretch,
6778#ifdef HAVE_XWIDGETS
6779 next_element_from_xwidget, 6765 next_element_from_xwidget,
6780#endif
6781}; 6766};
6782 6767
6783#define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it) 6768#define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it)
@@ -7638,9 +7623,7 @@ set_iterator_to_next (struct it *it, bool reseat_p)
7638 7623
7639 case GET_FROM_IMAGE: 7624 case GET_FROM_IMAGE:
7640 case GET_FROM_STRETCH: 7625 case GET_FROM_STRETCH:
7641#ifdef HAVE_XWIDGETS
7642 case GET_FROM_XWIDGET: 7626 case GET_FROM_XWIDGET:
7643#endif
7644 7627
7645 /* The position etc with which we have to proceed are on 7628 /* The position etc with which we have to proceed are on
7646 the stack. The position may be at the end of a string, 7629 the stack. The position may be at the end of a string,
@@ -8103,14 +8086,12 @@ next_element_from_image (struct it *it)
8103 return true; 8086 return true;
8104} 8087}
8105 8088
8106#ifdef HAVE_XWIDGETS
8107static bool 8089static bool
8108next_element_from_xwidget (struct it *it) 8090next_element_from_xwidget (struct it *it)
8109{ 8091{
8110 it->what = IT_XWIDGET; 8092 it->what = IT_XWIDGET;
8111 return true; 8093 return true;
8112} 8094}
8113#endif
8114 8095
8115 8096
8116/* Fill iterator IT with next display element from a stretch glyph 8097/* Fill iterator IT with next display element from a stretch glyph
@@ -18844,7 +18825,6 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18844 glyph->left_box_line_p, 18825 glyph->left_box_line_p,
18845 glyph->right_box_line_p); 18826 glyph->right_box_line_p);
18846 } 18827 }
18847#ifdef HAVE_XWIDGETS
18848 else if (glyph->type == XWIDGET_GLYPH) 18828 else if (glyph->type == XWIDGET_GLYPH)
18849 { 18829 {
18850 fprintf (stderr, 18830 fprintf (stderr,
@@ -18865,7 +18845,6 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18865 glyph->right_box_line_p); 18845 glyph->right_box_line_p);
18866 18846
18867 } 18847 }
18868#endif
18869} 18848}
18870 18849
18871 18850
@@ -24364,13 +24343,11 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
24364 24343
24365 return OK_PIXELS (width_p ? img->width : img->height); 24344 return OK_PIXELS (width_p ? img->width : img->height);
24366 } 24345 }
24367# ifdef HAVE_XWIDGETS
24368 if (FRAME_WINDOW_P (it->f) && valid_xwidget_spec_p (prop)) 24346 if (FRAME_WINDOW_P (it->f) && valid_xwidget_spec_p (prop))
24369 { 24347 {
24370 // TODO: Don't return dummy size. 24348 // TODO: Don't return dummy size.
24371 return OK_PIXELS (100); 24349 return OK_PIXELS (100);
24372 } 24350 }
24373# endif
24374#endif 24351#endif
24375 if (EQ (car, Qplus) || EQ (car, Qminus)) 24352 if (EQ (car, Qplus) || EQ (car, Qminus))
24376 { 24353 {
@@ -25273,8 +25250,11 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25273 } \ 25250 } \
25274 while (false) 25251 while (false)
25275 25252
25276#ifdef HAVE_XWIDGETS 25253#ifndef HAVE_XWIDGETS
25277#define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25254# define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
25255 eassume (false)
25256#else
25257# define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
25278 do \ 25258 do \
25279 { \ 25259 { \
25280 s = alloca (sizeof *s); \ 25260 s = alloca (sizeof *s); \
@@ -25287,7 +25267,6 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25287 while (false) 25267 while (false)
25288#endif 25268#endif
25289 25269
25290
25291/* Add a glyph string for a sequence of character glyphs to the list 25270/* Add a glyph string for a sequence of character glyphs to the list
25292 of strings between HEAD and TAIL. START is the index of the first 25271 of strings between HEAD and TAIL. START is the index of the first
25293 glyph in row area AREA of glyph row ROW that is part of the new 25272 glyph in row area AREA of glyph row ROW that is part of the new
@@ -25441,13 +25420,11 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25441 HL, X, LAST_X); \ 25420 HL, X, LAST_X); \
25442 break; 25421 break;
25443 25422
25444#ifdef HAVE_XWIDGETS 25423#define BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
25445# define BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
25446 case XWIDGET_GLYPH: \ 25424 case XWIDGET_GLYPH: \
25447 BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL, \ 25425 BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL, \
25448 HL, X, LAST_X); \ 25426 HL, X, LAST_X); \
25449 break; 25427 break;
25450#endif
25451 25428
25452#define BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25429#define BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X) \
25453 case GLYPHLESS_GLYPH: \ 25430 case GLYPHLESS_GLYPH: \
@@ -25456,7 +25433,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25456 break; \ 25433 break; \
25457 \ 25434 \
25458 default: \ 25435 default: \
25459 emacs_abort (); \ 25436 emacs_abort (); \
25460 } \ 25437 } \
25461 \ 25438 \
25462 if (s) \ 25439 if (s) \
@@ -25468,16 +25445,10 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25468 } while (false) 25445 } while (false)
25469 25446
25470 25447
25471#ifdef HAVE_XWIDGETS 25448#define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X) \
25472# define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X) \
25473 BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25449 BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X) \
25474 BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25450 BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
25475 BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X) 25451 BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
25476#else
25477# define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X) \
25478 BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X) \
25479 BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
25480#endif
25481 25452
25482 25453
25483/* Draw glyphs between START and END in AREA of ROW on window W, 25454/* Draw glyphs between START and END in AREA of ROW on window W,
@@ -26118,10 +26089,10 @@ produce_image_glyph (struct it *it)
26118 } 26089 }
26119} 26090}
26120 26091
26121#ifdef HAVE_XWIDGETS
26122static void 26092static void
26123produce_xwidget_glyph (struct it *it) 26093produce_xwidget_glyph (struct it *it)
26124{ 26094{
26095#ifdef HAVE_XWIDGETS
26125 struct xwidget *xw; 26096 struct xwidget *xw;
26126 int glyph_ascent, crop; 26097 int glyph_ascent, crop;
26127 eassert (it->what == IT_XWIDGET); 26098 eassert (it->what == IT_XWIDGET);
@@ -26219,8 +26190,8 @@ produce_xwidget_glyph (struct it *it)
26219 else 26190 else
26220 IT_EXPAND_MATRIX_WIDTH (it, area); 26191 IT_EXPAND_MATRIX_WIDTH (it, area);
26221 } 26192 }
26222}
26223#endif 26193#endif
26194}
26224 26195
26225/* Append a stretch glyph to IT->glyph_row. OBJECT is the source 26196/* Append a stretch glyph to IT->glyph_row. OBJECT is the source
26226 of the glyph, WIDTH and HEIGHT are the width and height of the 26197 of the glyph, WIDTH and HEIGHT are the width and height of the
@@ -27631,10 +27602,8 @@ x_produce_glyphs (struct it *it)
27631 produce_image_glyph (it); 27602 produce_image_glyph (it);
27632 else if (it->what == IT_STRETCH) 27603 else if (it->what == IT_STRETCH)
27633 produce_stretch_glyph (it); 27604 produce_stretch_glyph (it);
27634#ifdef HAVE_XWIDGETS
27635 else if (it->what == IT_XWIDGET) 27605 else if (it->what == IT_XWIDGET)
27636 produce_xwidget_glyph (it); 27606 produce_xwidget_glyph (it);
27637#endif
27638 27607
27639 done: 27608 done:
27640 /* Accumulate dimensions. Note: can't assume that it->descent > 0 27609 /* Accumulate dimensions. Note: can't assume that it->descent > 0
@@ -28004,10 +27973,8 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
28004 /* Use normal cursor if not blinked off. */ 27973 /* Use normal cursor if not blinked off. */
28005 if (!w->cursor_off_p) 27974 if (!w->cursor_off_p)
28006 { 27975 {
28007#ifdef HAVE_XWIDGETS
28008 if (glyph != NULL && glyph->type == XWIDGET_GLYPH) 27976 if (glyph != NULL && glyph->type == XWIDGET_GLYPH)
28009 return NO_CURSOR; 27977 return NO_CURSOR;
28010#endif
28011 if (glyph != NULL && glyph->type == IMAGE_GLYPH) 27978 if (glyph != NULL && glyph->type == IMAGE_GLYPH)
28012 { 27979 {
28013 if (cursor_type == FILLED_BOX_CURSOR) 27980 if (cursor_type == FILLED_BOX_CURSOR)
diff --git a/src/xterm.c b/src/xterm.c
index 44eed22d2ec..6a38d24c636 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -62,9 +62,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
62#include "composite.h" 62#include "composite.h"
63#include "frame.h" 63#include "frame.h"
64#include "dispextern.h" 64#include "dispextern.h"
65#ifdef HAVE_XWIDGETS 65#include "xwidget.h"
66# include "xwidget.h"
67#endif
68#include "fontset.h" 66#include "fontset.h"
69#include "termhooks.h" 67#include "termhooks.h"
70#include "termopts.h" 68#include "termopts.h"
@@ -3514,11 +3512,9 @@ x_draw_glyph_string (struct glyph_string *s)
3514 x_draw_image_glyph_string (s); 3512 x_draw_image_glyph_string (s);
3515 break; 3513 break;
3516 3514
3517#ifdef HAVE_XWIDGETS
3518 case XWIDGET_GLYPH: 3515 case XWIDGET_GLYPH:
3519 x_draw_xwidget_glyph_string (s); 3516 x_draw_xwidget_glyph_string (s);
3520 break; 3517 break;
3521#endif
3522 3518
3523 case STRETCH_GLYPH: 3519 case STRETCH_GLYPH:
3524 x_draw_stretch_glyph_string (s); 3520 x_draw_stretch_glyph_string (s);
@@ -8929,10 +8925,9 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
8929 if (cursor_glyph == NULL) 8925 if (cursor_glyph == NULL)
8930 return; 8926 return;
8931 8927
8932#ifdef HAVE_XWIDGETS 8928 /* Experimental avoidance of cursor on xwidget. */
8933 if (cursor_glyph->type == XWIDGET_GLYPH) 8929 if (cursor_glyph->type == XWIDGET_GLYPH)
8934 return; // Experimental avoidance of cursor on xwidget. 8930 return;
8935#endif
8936 8931
8937 /* If on an image, draw like a normal cursor. That's usually better 8932 /* If on an image, draw like a normal cursor. That's usually better
8938 visible than drawing a bar, esp. if the image is large so that 8933 visible than drawing a bar, esp. if the image is large so that
diff --git a/src/xwidget.c b/src/xwidget.c
index ea5dea0f9fe..be3e4ca5732 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -19,6 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21 21
22#include "xwidget.h"
22 23
23#include <signal.h> 24#include <signal.h>
24 25
@@ -105,8 +106,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
105#include <webkit/webkitdownload.h> 106#include <webkit/webkitdownload.h>
106#include <webkit/webkitwebpolicydecision.h> 107#include <webkit/webkitwebpolicydecision.h>
107 108
108#include "xwidget.h"
109
110static struct xwidget * 109static struct xwidget *
111allocate_xwidget (void) 110allocate_xwidget (void)
112{ 111{
@@ -120,8 +119,8 @@ allocate_xwidget_view (void)
120 PVEC_XWIDGET_VIEW); 119 PVEC_XWIDGET_VIEW);
121} 120}
122 121
123#define XSETXWIDGET(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET)) 122#define XSETXWIDGET(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET)
124#define XSETXWIDGET_VIEW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW)) 123#define XSETXWIDGET_VIEW(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW)
125 124
126static struct xwidget_view *xwidget_view_lookup (struct xwidget *, 125static struct xwidget_view *xwidget_view_lookup (struct xwidget *,
127 struct window *); 126 struct window *);
@@ -163,67 +162,57 @@ If BUFFER is nil, use the current buffer.
163If BUFFER is a string and no such buffer exists, create it. 162If BUFFER is a string and no such buffer exists, create it.
164TYPE is a symbol which can take one of the following values: 163TYPE is a symbol which can take one of the following values:
165 164
166- webkit_osr 165- webkit-osr
167 166
168Returns the newly constructed xwidget, or nil if construction fails. */) 167Returns the newly constructed xwidget, or nil if construction fails. */)
169 (Lisp_Object beg, Lisp_Object end, 168 (Lisp_Object beg, Lisp_Object end, Lisp_Object type,
170 Lisp_Object type, 169 Lisp_Object title, Lisp_Object width, Lisp_Object height,
171 Lisp_Object title, 170 Lisp_Object arguments, Lisp_Object buffer)
172 Lisp_Object width, Lisp_Object height,
173 Lisp_Object arguments, Lisp_Object buffer)
174{ 171{
175 //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES) 172 CHECK_SYMBOL (type);
176 // arg "type" and fwd should be keyword args eventually 173 CHECK_NATNUM (width);
177 //(make-xwidget 3 3 'button "oei" 31 31 nil) 174 CHECK_NATNUM (height);
178 //(xwidget-info (car xwidget-list)) 175 /* This should work a bit like "make-button"
176 (make-button BEG END &rest PROPERTIES)
177 TYPE etc. should be keyword args eventually.
178 (make-xwidget 3 3 'button "oei" 31 31 nil)
179 (xwidget-info (car xwidget-list)) */
179 struct xwidget *xw = allocate_xwidget (); 180 struct xwidget *xw = allocate_xwidget ();
180 Lisp_Object val; 181 Lisp_Object val;
181 xw->type = type; 182 xw->type = type;
182 xw->title = title; 183 xw->title = title;
183 if (NILP (buffer)) 184 xw->buffer = NILP (buffer) ? Fcurrent_buffer () : Fget_buffer_create (buffer);
184 buffer = Fcurrent_buffer (); // no need to gcpro because
185 // Fcurrent_buffer doesn't
186 // call Feval/eval_sub.
187 else
188 buffer = Fget_buffer_create (buffer);
189 xw->buffer = buffer;
190
191 xw->height = XFASTINT (height); 185 xw->height = XFASTINT (height);
192 xw->width = XFASTINT (width); 186 xw->width = XFASTINT (width);
193 xw->kill_without_query = 0; 187 xw->kill_without_query = false;
194 XSETXWIDGET (val, xw); // set the vectorlike_header of VAL 188 XSETXWIDGET (val, xw);
195 // with the correct value
196 Vxwidget_list = Fcons (val, Vxwidget_list); 189 Vxwidget_list = Fcons (val, Vxwidget_list);
197 xw->widgetwindow_osr = NULL; 190 xw->widgetwindow_osr = NULL;
198 xw->widget_osr = NULL; 191 xw->widget_osr = NULL;
199 xw->plist = Qnil; 192 xw->plist = Qnil;
200 193
201
202 if (EQ (xw->type, Qwebkit_osr)) 194 if (EQ (xw->type, Qwebkit_osr))
203 { 195 {
204 block_input (); 196 block_input ();
205 xw->widgetwindow_osr = gtk_offscreen_window_new (); 197 xw->widgetwindow_osr = gtk_offscreen_window_new ();
206 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width, 198 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width,
207 xw->height); 199 xw->height);
208 xw->widgetscrolledwindow_osr = NULL; //webkit osr is the 200
209 //only scrolled 201 /* WebKit OSR is the only scrolled component at the moment. */
210 //component atm 202 xw->widgetscrolledwindow_osr = NULL;
211 203
212 if (EQ (xw->type, Qwebkit_osr)) 204 if (EQ (xw->type, Qwebkit_osr))
213 { 205 {
214 xw->widgetscrolledwindow_osr = gtk_scrolled_window_new (NULL, NULL); 206 xw->widgetscrolledwindow_osr = gtk_scrolled_window_new (NULL, NULL);
215 gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW 207 gtk_scrolled_window_set_min_content_height
216 (xw-> 208 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
217 widgetscrolledwindow_osr), 209 xw->height);
218 xw->height); 210 gtk_scrolled_window_set_min_content_width
219 gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW 211 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
220 (xw-> 212 xw->width);
221 widgetscrolledwindow_osr), 213 gtk_scrolled_window_set_policy
222 xw->width); 214 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
223 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW 215 GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
224 (xw->widgetscrolledwindow_osr),
225 GTK_POLICY_ALWAYS,
226 GTK_POLICY_ALWAYS);
227 216
228 xw->widget_osr = webkit_web_view_new (); 217 xw->widget_osr = webkit_web_view_new ();
229 gtk_container_add (GTK_CONTAINER (xw->widgetscrolledwindow_osr), 218 gtk_container_add (GTK_CONTAINER (xw->widgetscrolledwindow_osr),
@@ -248,12 +237,10 @@ Returns the newly constructed xwidget, or nil if construction fails. */)
248 gtk_widget_show (xw->widgetwindow_osr); 237 gtk_widget_show (xw->widgetwindow_osr);
249 gtk_widget_show (xw->widgetscrolledwindow_osr); 238 gtk_widget_show (xw->widgetscrolledwindow_osr);
250 239
251 /* store some xwidget data in the gtk widgets for convenient 240 /* Store some xwidget data in the gtk widgets for convenient
252 retrieval in the event handlers. */ 241 retrieval in the event handlers. */
253 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, 242 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, xw);
254 (gpointer) (xw)); 243 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, xw);
255 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET,
256 (gpointer) (xw));
257 244
258 /* signals */ 245 /* signals */
259 if (EQ (xw->type, Qwebkit_osr)) 246 if (EQ (xw->type, Qwebkit_osr))
@@ -286,7 +273,6 @@ Returns the newly constructed xwidget, or nil if construction fails. */)
286 } 273 }
287 274
288 unblock_input (); 275 unblock_input ();
289
290 } 276 }
291 277
292 return val; 278 return val;
@@ -317,18 +303,16 @@ BUFFER may be a buffer or the name of one. */)
317 return xw_list; 303 return xw_list;
318} 304}
319 305
320static int 306static bool
321xwidget_hidden (struct xwidget_view *xv) 307xwidget_hidden (struct xwidget_view *xv)
322{ 308{
323 return xv->hidden; 309 return xv->hidden;
324} 310}
325 311
326
327
328static void 312static void
329xwidget_show_view (struct xwidget_view *xv) 313xwidget_show_view (struct xwidget_view *xv)
330{ 314{
331 xv->hidden = 0; 315 xv->hidden = false;
332 gtk_widget_show (xv->widgetwindow); 316 gtk_widget_show (xv->widgetwindow);
333 gtk_fixed_move (GTK_FIXED (xv->emacswindow), 317 gtk_fixed_move (GTK_FIXED (xv->emacswindow),
334 xv->widgetwindow, 318 xv->widgetwindow,
@@ -336,33 +320,30 @@ xwidget_show_view (struct xwidget_view *xv)
336 xv->y + xv->clip_top); 320 xv->y + xv->clip_top);
337} 321}
338 322
339
340/* Hide an xvidget view. */ 323/* Hide an xvidget view. */
341static void 324static void
342xwidget_hide_view (struct xwidget_view *xv) 325xwidget_hide_view (struct xwidget_view *xv)
343{ 326{
344 xv->hidden = 1; 327 xv->hidden = true;
345 gtk_fixed_move (GTK_FIXED (xv->emacswindow), xv->widgetwindow, 328 gtk_fixed_move (GTK_FIXED (xv->emacswindow), xv->widgetwindow,
346 10000, 10000); 329 10000, 10000);
347} 330}
348 331
349
350
351/* When the off-screen webkit master view changes this signal is called. 332/* When the off-screen webkit master view changes this signal is called.
352 It copies the bitmap from the off-screen instance. */ 333 It copies the bitmap from the off-screen instance. */
353static gboolean 334static gboolean
354offscreen_damage_event (GtkWidget * widget, GdkEvent * event, 335offscreen_damage_event (GtkWidget *widget, GdkEvent *event,
355 gpointer xv_widget) 336 gpointer xv_widget)
356{ 337{
357 // Queue a redraw of onscreen widget. 338 /* Queue a redraw of onscreen widget.
358 // There is a guard against receiving an invalid widget, 339 There is a guard against receiving an invalid widget,
359 // which should only happen if we failed to remove the 340 which should only happen if we failed to remove the
360 // specific signal handler for the damage event. 341 specific signal handler for the damage event. */
361 if (GTK_IS_WIDGET (xv_widget)) 342 if (GTK_IS_WIDGET (xv_widget))
362 gtk_widget_queue_draw (GTK_WIDGET (xv_widget)); 343 gtk_widget_queue_draw (GTK_WIDGET (xv_widget));
363 else 344 else
364 printf ("Warning, offscreen_damage_event received invalid xv pointer:%p\n", 345 printf ("Warning, offscreen_damage_event received invalid xv pointer:%p\n",
365 (void *) xv_widget); 346 xv_widget);
366 347
367 return FALSE; 348 return FALSE;
368} 349}
@@ -377,75 +358,58 @@ store_xwidget_event_string (struct xwidget *xw, const char *eventname,
377 EVENT_INIT (event); 358 EVENT_INIT (event);
378 event.kind = XWIDGET_EVENT; 359 event.kind = XWIDGET_EVENT;
379 event.frame_or_window = Qnil; 360 event.frame_or_window = Qnil;
380 361 event.arg = list3 (intern (eventname), xwl, build_string (eventstr));
381 event.arg = Qnil;
382 event.arg = Fcons (build_string (eventstr), event.arg);
383 event.arg = Fcons (xwl, event.arg);
384 event.arg = Fcons (intern (eventname), event.arg);
385 kbd_buffer_store_event (&event); 362 kbd_buffer_store_event (&event);
386
387} 363}
388 364
389//TODO deprecated, use load-status 365/* TODO deprecated, use load-status. */
390void 366void
391webkit_document_load_finished_cb (WebKitWebView * webkitwebview, 367webkit_document_load_finished_cb (WebKitWebView *webkitwebview,
392 WebKitWebFrame * arg1, 368 WebKitWebFrame *arg1,
393 gpointer data) 369 gpointer data)
394{ 370{
395 struct xwidget *xw = 371 struct xwidget *xw = g_object_get_data (G_OBJECT (webkitwebview),
396 (struct xwidget *) g_object_get_data (G_OBJECT (webkitwebview),
397 XG_XWIDGET); 372 XG_XWIDGET);
398 373
399 store_xwidget_event_string (xw, "document-load-finished", ""); 374 store_xwidget_event_string (xw, "document-load-finished", "");
400} 375}
401 376
402gboolean 377gboolean
403webkit_download_cb (WebKitWebView * webkitwebview, 378webkit_download_cb (WebKitWebView *webkitwebview,
404 WebKitDownload * arg1, 379 WebKitDownload *arg1,
405 gpointer data) 380 gpointer data)
406{ 381{
407 struct xwidget *xw = 382 struct xwidget *xw = g_object_get_data (G_OBJECT (webkitwebview),
408 (struct xwidget *) g_object_get_data (G_OBJECT (webkitwebview),
409 XG_XWIDGET); 383 XG_XWIDGET);
410 store_xwidget_event_string (xw, "download-requested", 384 store_xwidget_event_string (xw, "download-requested",
411 webkit_download_get_uri (arg1)); 385 webkit_download_get_uri (arg1));
412
413 return FALSE; 386 return FALSE;
414} 387}
415 388
416static gboolean 389static gboolean
417webkit_mime_type_policy_typedecision_requested_cb (WebKitWebView *webView, 390webkit_mime_type_policy_typedecision_requested_cb
418 WebKitWebFrame *frame, 391(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
419 WebKitNetworkRequest * request, 392 gchar *mimetype, WebKitWebPolicyDecision *policy_decision, gpointer user_data)
420 gchar * mimetype,
421 WebKitWebPolicyDecision *policy_decision,
422 gpointer user_data)
423{ 393{
424 // This function makes webkit send a download signal for all unknown 394 /* This function makes webkit send a download signal for all unknown
425 // mime types. TODO Defer the decision to lisp, so that its possible 395 mime types. TODO: Defer the decision to Lisp, so that it's
426 // to make Emacs handle teext mime for instance.xs 396 possible to make Emacs handle teext mime for instance.xs. */
427 if (!webkit_web_view_can_show_mime_type (webView, mimetype)) 397 if (!webkit_web_view_can_show_mime_type (webView, mimetype))
428 { 398 {
429 webkit_web_policy_decision_download (policy_decision); 399 webkit_web_policy_decision_download (policy_decision);
430 return TRUE; 400 return TRUE;
431 } 401 }
432 else 402 else
433 { 403 return FALSE;
434 return FALSE;
435 }
436} 404}
437 405
438
439static gboolean 406static gboolean
440webkit_new_window_policy_decision_requested_cb (WebKitWebView *webView, 407webkit_new_window_policy_decision_requested_cb
441 WebKitWebFrame *frame, 408(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
442 WebKitNetworkRequest *request, 409 WebKitWebNavigationAction *navigation_action,
443 WebKitWebNavigationAction *navigation_action, 410 WebKitWebPolicyDecision *policy_decision, gpointer user_data)
444 WebKitWebPolicyDecision *policy_decision,
445 gpointer user_data)
446{ 411{
447 struct xwidget *xw = 412 struct xwidget *xw = g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
448 (struct xwidget *) g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
449 webkit_web_navigation_action_get_original_uri (navigation_action); 413 webkit_web_navigation_action_get_original_uri (navigation_action);
450 414
451 store_xwidget_event_string (xw, "new-window-policy-decision-requested", 415 store_xwidget_event_string (xw, "new-window-policy-decision-requested",
@@ -455,29 +419,24 @@ webkit_new_window_policy_decision_requested_cb (WebKitWebView *webView,
455} 419}
456 420
457static gboolean 421static gboolean
458webkit_navigation_policy_decision_requested_cb (WebKitWebView *webView, 422webkit_navigation_policy_decision_requested_cb
459 WebKitWebFrame *frame, 423(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
460 WebKitNetworkRequest *request, 424 WebKitWebNavigationAction *navigation_action,
461 WebKitWebNavigationAction *navigation_action, 425 WebKitWebPolicyDecision *policy_decision, gpointer user_data)
462 WebKitWebPolicyDecision * policy_decision,
463 gpointer user_data)
464{ 426{
465 struct xwidget *xw = 427 struct xwidget *xw = g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
466 (struct xwidget *) g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
467 store_xwidget_event_string (xw, "navigation-policy-decision-requested", 428 store_xwidget_event_string (xw, "navigation-policy-decision-requested",
468 webkit_web_navigation_action_get_original_uri 429 webkit_web_navigation_action_get_original_uri
469 (navigation_action)); 430 (navigation_action));
470 return FALSE; 431 return FALSE;
471} 432}
472 433
473// For gtk3 offscreen rendered widgets. 434/* For gtk3 offscreen rendered widgets. */
474static gboolean 435static gboolean
475xwidget_osr_draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data) 436xwidget_osr_draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
476{ 437{
477 struct xwidget *xw = 438 struct xwidget *xw = g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
478 (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); 439 struct xwidget_view *xv = g_object_get_data (G_OBJECT (widget),
479 struct xwidget_view *xv =
480 (struct xwidget_view *) g_object_get_data (G_OBJECT (widget),
481 XG_XWIDGET_VIEW); 440 XG_XWIDGET_VIEW);
482 441
483 cairo_rectangle (cr, 0, 0, xv->clip_right, xv->clip_bottom); 442 cairo_rectangle (cr, 0, 0, xv->clip_right, xv->clip_bottom);
@@ -491,31 +450,30 @@ xwidget_osr_draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
491} 450}
492 451
493static gboolean 452static gboolean
494xwidget_osr_event_forward (GtkWidget * widget, 453xwidget_osr_event_forward (GtkWidget *widget, GdkEvent *event,
495 GdkEvent * event, 454 gpointer user_data)
496 gpointer user_data)
497{ 455{
498 /* Copy events that arrive at the outer widget to the offscreen widget. */ 456 /* Copy events that arrive at the outer widget to the offscreen widget. */
499 struct xwidget *xw = 457 struct xwidget *xw = g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
500 (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
501 GdkEvent *eventcopy = gdk_event_copy (event); 458 GdkEvent *eventcopy = gdk_event_copy (event);
502 eventcopy->any.window = gtk_widget_get_window (xw->widget_osr); 459 eventcopy->any.window = gtk_widget_get_window (xw->widget_osr);
503 460
504 //TODO This might leak events. They should be deallocated later, 461 /* TODO: This might leak events. They should be deallocated later,
505 //perhaps in xwgir_event_cb 462 perhaps in xwgir_event_cb. */
506 gtk_main_do_event (eventcopy); 463 gtk_main_do_event (eventcopy);
507 return TRUE; //dont propagate this event furter
508}
509 464
465 /* Don't propagate this event further. */
466 return TRUE;
467}
510 468
511static gboolean 469static gboolean
512xwidget_osr_event_set_embedder (GtkWidget * widget, 470xwidget_osr_event_set_embedder (GtkWidget *widget, GdkEvent *event,
513 GdkEvent * event, gpointer data) 471 gpointer data)
514{ 472{
515 struct xwidget_view *xv = (struct xwidget_view *) data; 473 struct xwidget_view *xv = data;
516 struct xwidget *xww = XXWIDGET (xv->model); 474 struct xwidget *xww = XXWIDGET (xv->model);
517 gdk_offscreen_window_set_embedder (gtk_widget_get_window 475 gdk_offscreen_window_set_embedder (gtk_widget_get_window
518 (xww->widgetwindow_osr), 476 (xww->widgetwindow_osr),
519 gtk_widget_get_window (xv->widget)); 477 gtk_widget_get_window (xv->widget));
520 return FALSE; 478 return FALSE;
521} 479}
@@ -539,11 +497,11 @@ xwidget_init_view (struct xwidget *xww,
539 if (EQ (xww->type, Qwebkit_osr)) 497 if (EQ (xww->type, Qwebkit_osr))
540 { 498 {
541 xv->widget = gtk_drawing_area_new (); 499 xv->widget = gtk_drawing_area_new ();
542 // Expose event handling. 500 /* Expose event handling. */
543 gtk_widget_set_app_paintable (xv->widget, TRUE); 501 gtk_widget_set_app_paintable (xv->widget, TRUE);
544 gtk_widget_add_events (xv->widget, GDK_ALL_EVENTS_MASK); 502 gtk_widget_add_events (xv->widget, GDK_ALL_EVENTS_MASK);
545 503
546 /* Draw the view on damage-event */ 504 /* Draw the view on damage-event. */
547 g_signal_connect (G_OBJECT (xww->widgetwindow_osr), "damage-event", 505 g_signal_connect (G_OBJECT (xww->widgetwindow_osr), "damage-event",
548 G_CALLBACK (offscreen_damage_event), xv->widget); 506 G_CALLBACK (offscreen_damage_event), xv->widget);
549 507
@@ -558,38 +516,33 @@ xwidget_init_view (struct xwidget *xww,
558 } 516 }
559 else 517 else
560 { 518 {
561 // xwgir debug , orthogonal to forwarding 519 /* xwgir debug, orthogonal to forwarding. */
562 g_signal_connect (G_OBJECT (xv->widget), "enter-notify-event", 520 g_signal_connect (G_OBJECT (xv->widget), "enter-notify-event",
563 G_CALLBACK (xwidget_osr_event_set_embedder), xv); 521 G_CALLBACK (xwidget_osr_event_set_embedder), xv);
564 } 522 }
565 g_signal_connect (G_OBJECT (xv->widget), "draw", 523 g_signal_connect (G_OBJECT (xv->widget), "draw",
566 G_CALLBACK (xwidget_osr_draw_cb), NULL); 524 G_CALLBACK (xwidget_osr_draw_cb), NULL);
567 } 525 }
568 // Widget realization.
569 526
570 // Make container widget 1st, and put the actual widget inside the 527 /* Widget realization.
571 // container later. Drawing should crop container window if necessary 528
572 // to handle case where xwidget is partially obscured by other Emacs 529 Make container widget first, and put the actual widget inside the
573 // windows. Other containers than gtk_fixed where explored, but 530 container later. Drawing should crop container window if necessary
574 // gtk_fixed had the most predictable behaviour so far. 531 to handle case where xwidget is partially obscured by other Emacs
532 windows. Other containers than gtk_fixed where explored, but
533 gtk_fixed had the most predictable behaviour so far. */
534
575 xv->emacswindow = FRAME_GTK_WIDGET (s->f); 535 xv->emacswindow = FRAME_GTK_WIDGET (s->f);
576 xv->widgetwindow = gtk_fixed_new (); 536 xv->widgetwindow = gtk_fixed_new ();
577 gtk_widget_set_has_window (xv->widgetwindow, TRUE); 537 gtk_widget_set_has_window (xv->widgetwindow, TRUE);
578 gtk_container_add (GTK_CONTAINER (xv->widgetwindow), xv->widget); 538 gtk_container_add (GTK_CONTAINER (xv->widgetwindow), xv->widget);
579 539
580 // Store some xwidget data in the gtk widgets. 540 /* Store some xwidget data in the gtk widgets. */
581 // The emacs frame. 541 g_object_set_data (G_OBJECT (xv->widget), XG_FRAME_DATA, s->f);
582 g_object_set_data (G_OBJECT (xv->widget), XG_FRAME_DATA, (gpointer) (s->f)); 542 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET, xww);
583 // The xwidget. 543 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET_VIEW, xv);
584 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET, (gpointer) (xww)); 544 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET, xww);
585 // The xwidget. 545 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET_VIEW, xv);
586 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET_VIEW, (gpointer) (xv));
587 // The xwidget window.
588 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET, (gpointer) (xww));
589 // the xwidget view.
590 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET_VIEW,
591 (gpointer) (xv));
592
593 546
594 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width, 547 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width,
595 xww->height); 548 xww->height);
@@ -599,18 +552,15 @@ xwidget_init_view (struct xwidget *xww,
599 xv->y = y; 552 xv->y = y;
600 gtk_widget_show_all (xv->widgetwindow); 553 gtk_widget_show_all (xv->widgetwindow);
601 554
602
603 return xv; 555 return xv;
604} 556}
605 557
606
607void 558void
608x_draw_xwidget_glyph_string (struct glyph_string *s) 559x_draw_xwidget_glyph_string (struct glyph_string *s)
609{ 560{
610 /* This method is called by the redisplay engine and places the 561 /* This method is called by the redisplay engine and places the
611 xwidget on screen. Moving and clipping is done here. Also view 562 xwidget on screen. Moving and clipping is done here. Also view
612 initialization. 563 initialization. */
613 */
614 struct xwidget *xww = s->xwidget; 564 struct xwidget *xww = s->xwidget;
615 struct xwidget_view *xv = xwidget_view_lookup (xww, s->w); 565 struct xwidget_view *xv = xwidget_view_lookup (xww, s->w);
616 int clip_right; 566 int clip_right;
@@ -620,16 +570,14 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
620 570
621 int x = s->x; 571 int x = s->x;
622 int y = s->y + (s->height / 2) - (xww->height / 2); 572 int y = s->y + (s->height / 2) - (xww->height / 2);
623 int moved = 0;
624 573
625 /* We do initialization here in the display loop because there is no 574 /* Do initialization here in the display loop because there is no
626 other time to know things like window placement etc. 575 other time to know things like window placement etc. */
627 */
628 xv = xwidget_init_view (xww, s, x, y); 576 xv = xwidget_init_view (xww, s, x, y);
629 577
630 // Calculate clipping, which is used for all manner of onscreen 578 /* Calculate clipping, which is used for all manner of onscreen
631 // xwidget views. Each widget border can get clipped by other emacs 579 xwidget views. Each widget border can get clipped by other emacs
632 // objects so there are four clipping variables. 580 objects so there are four clipping variables. */
633 clip_right = 581 clip_right =
634 min (xww->width, 582 min (xww->width,
635 WINDOW_RIGHT_EDGE_X (s->w) - x - 583 WINDOW_RIGHT_EDGE_X (s->w) - x -
@@ -646,31 +594,32 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
646 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y); 594 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y);
647 clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y); 595 clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y);
648 596
649 // We are conserned with movement of the onscreen area. The area 597 /* We are conserned with movement of the onscreen area. The area
650 // might sit still when the widget actually moves. This happens 598 might sit still when the widget actually moves. This happens
651 // when an Emacs window border moves across a widget window. So, if 599 when an Emacs window border moves across a widget window. So, if
652 // any corner of the outer widget clipping window moves, that counts 600 any corner of the outer widget clipping window moves, that counts
653 // as movement here, even if it looks like no movement happens 601 as movement here, even if it looks like no movement happens
654 // because the widget sits still inside the clipping area. The 602 because the widget sits still inside the clipping area. The
655 // widget can also move inside the clipping area, which happens 603 widget can also move inside the clipping area, which happens
656 // later 604 later. */
657 moved = (xv->x + xv->clip_left != x + clip_left) 605 bool moved = (xv->x + xv->clip_left != x + clip_left
658 || ((xv->y + xv->clip_top) != (y + clip_top)); 606 || xv->y + xv->clip_top != y + clip_top);
659 xv->x = x; 607 xv->x = x;
660 xv->y = y; 608 xv->y = y;
661 if (moved) // Has it moved? 609
662 { 610 /* Has it moved? */
663 gtk_fixed_move (GTK_FIXED (FRAME_GTK_WIDGET (s->f)), 611 if (moved)
664 xv->widgetwindow, x + clip_left, y + clip_top); 612 gtk_fixed_move (GTK_FIXED (FRAME_GTK_WIDGET (s->f)),
665 } 613 xv->widgetwindow, x + clip_left, y + clip_top);
666 // Clip the widget window if some parts happen to be outside 614
667 // drawable area. An Emacs window is not a gtk window. A gtk window 615 /* Clip the widget window if some parts happen to be outside
668 // covers the entire frame. Clipping might have changed even if we 616 drawable area. An Emacs window is not a gtk window. A gtk window
669 // havent actualy moved, we try figure out when we need to reclip 617 covers the entire frame. Clipping might have changed even if we
670 // for real. 618 havent actualy moved, we try figure out when we need to reclip
671 if ((xv->clip_right != clip_right) 619 for real. */
672 || (xv->clip_bottom != clip_bottom) 620 if (xv->clip_right != clip_right
673 || (xv->clip_top != clip_top) || (xv->clip_left != clip_left)) 621 || xv->clip_bottom != clip_bottom
622 || xv->clip_top != clip_top || xv->clip_left != clip_left)
674 { 623 {
675 gtk_widget_set_size_request (xv->widgetwindow, clip_right + clip_left, 624 gtk_widget_set_size_request (xv->widgetwindow, clip_right + clip_left,
676 clip_bottom + clip_top); 625 clip_bottom + clip_top);
@@ -682,10 +631,11 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
682 xv->clip_top = clip_top; 631 xv->clip_top = clip_top;
683 xv->clip_left = clip_left; 632 xv->clip_left = clip_left;
684 } 633 }
685 // If emacs wants to repaint the area where the widget lives, queue 634
686 // a redraw. It seems its possible to get out of sync with emacs 635 /* If emacs wants to repaint the area where the widget lives, queue
687 // redraws so emacs background sometimes shows up instead of the 636 a redraw. It seems its possible to get out of sync with emacs
688 // xwidgets background. It's just a visual glitch though. 637 redraws so emacs background sometimes shows up instead of the
638 xwidgets background. It's just a visual glitch though. */
689 if (!xwidget_hidden (xv)) 639 if (!xwidget_hidden (xv))
690 { 640 {
691 gtk_widget_queue_draw (xv->widgetwindow); 641 gtk_widget_queue_draw (xv->widgetwindow);
@@ -693,19 +643,15 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
693 } 643 }
694} 644}
695 645
696 646/* Macro that checks WEBKIT_IS_WEB_VIEW (xw->widget_osr) first. */
697// Macro that checks WEBKIT_IS_WEB_VIEW(xw->widget_osr) first 647#define WEBKIT_FN_INIT() \
698#define WEBKIT_FN_INIT() \ 648 CHECK_XWIDGET (xwidget); \
699 struct xwidget* xw; \ 649 struct xwidget *xw = XXWIDGET (xwidget); \
700 CHECK_XWIDGET (xwidget); \ 650 if (!xw->widget_osr || !WEBKIT_IS_WEB_VIEW (xw->widget_osr)) \
701 if (NILP (xwidget)) {printf("ERROR xwidget nil\n"); return Qnil;}; \ 651 { \
702 xw = XXWIDGET (xwidget); \ 652 printf ("ERROR xw->widget_osr does not hold a webkit instance\n"); \
703 if (NULL == xw) printf("ERROR xw is 0\n"); \ 653 return Qnil; \
704 if ((NULL == xw->widget_osr) || !WEBKIT_IS_WEB_VIEW(xw->widget_osr)){ \ 654 }
705 printf ("ERROR xw->widget_osr does not hold a webkit instance\n");\
706 return Qnil;\
707 };
708
709 655
710DEFUN ("xwidget-webkit-goto-uri", 656DEFUN ("xwidget-webkit-goto-uri",
711 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri, 657 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri,
@@ -723,7 +669,7 @@ DEFUN ("xwidget-webkit-goto-uri",
723DEFUN ("xwidget-webkit-execute-script", 669DEFUN ("xwidget-webkit-execute-script",
724 Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script, 670 Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script,
725 2, 2, 0, 671 2, 2, 0,
726 doc: /* Make the Webkit XWIDGET execute javascript SCRIPT. */) 672 doc: /* Make the Webkit XWIDGET execute JavaScript SCRIPT. */)
727 (Lisp_Object xwidget, Lisp_Object script) 673 (Lisp_Object xwidget, Lisp_Object script)
728{ 674{
729 WEBKIT_FN_INIT (); 675 WEBKIT_FN_INIT ();
@@ -741,14 +687,14 @@ This can be used to work around the lack of a return value from the
741exec method. */ ) 687exec method. */ )
742 (Lisp_Object xwidget) 688 (Lisp_Object xwidget)
743{ 689{
744 // TODO support multibyte strings 690 /* TODO support multibyte strings. */
745 WEBKIT_FN_INIT (); 691 WEBKIT_FN_INIT ();
746 const gchar *str = 692 const gchar *str =
747 webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr)); 693 webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr));
748 if (str == 0) 694 if (str == 0)
749 { 695 {
750 // TODO maybe return Qnil instead. I suppose webkit returns 696 /* TODO maybe return Qnil instead. I suppose webkit returns
751 // nullpointer when doc is not properly loaded or something 697 null pointer when doc is not properly loaded or something. */
752 return build_string (""); 698 return build_string ("");
753 } 699 }
754 return build_string (str); 700 return build_string (str);
@@ -759,32 +705,30 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
759 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height) 705 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height)
760{ 706{
761 CHECK_XWIDGET (xwidget); 707 CHECK_XWIDGET (xwidget);
708 CHECK_NATNUM (new_width);
709 CHECK_NATNUM (new_height);
762 struct xwidget *xw = XXWIDGET (xwidget); 710 struct xwidget *xw = XXWIDGET (xwidget);
763 struct xwidget_view *xv; 711 int w = XFASTINT (new_width);
764 int w, h; 712 int h = XFASTINT (new_height);
765
766 CHECK_NUMBER (new_width);
767 CHECK_NUMBER (new_height);
768 w = XFASTINT (new_width);
769 h = XFASTINT (new_height);
770 713
771 xw->width = w; 714 xw->width = w;
772 xw->height = h; 715 xw->height = h;
773 // If there is a offscreen widget resize it 1st. 716
717 /* If there is an offscreen widget resize it first. */
774 if (xw->widget_osr) 718 if (xw->widget_osr)
775 { 719 {
720 /* Use minimum size. */
776 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), 721 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr),
777 xw->width, xw->height); //minimum size 722 xw->width, xw->height);
723
778 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width, 724 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width,
779 xw->height); 725 xw->height);
780 gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW 726 gtk_scrolled_window_set_min_content_height
781 (xw-> 727 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
782 widgetscrolledwindow_osr), 728 xw->height);
783 xw->height); 729 gtk_scrolled_window_set_min_content_width
784 gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW 730 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
785 (xw-> 731 xw->width);
786 widgetscrolledwindow_osr),
787 xw->width);
788 732
789 gtk_container_resize_children (GTK_CONTAINER (xw->widgetwindow_osr)); 733 gtk_container_resize_children (GTK_CONTAINER (xw->widgetwindow_osr));
790 734
@@ -794,7 +738,7 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
794 { 738 {
795 if (XWIDGET_VIEW_P (XCAR (tail))) 739 if (XWIDGET_VIEW_P (XCAR (tail)))
796 { 740 {
797 xv = XXWIDGET_VIEW (XCAR (tail)); 741 struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail));
798 if (XXWIDGET (xv->model) == xw) 742 if (XXWIDGET (xv->model) == xw)
799 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xw->width, 743 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xw->width,
800 xw->height); 744 xw->height);
@@ -816,37 +760,17 @@ VALUE is the amount to scroll, either relatively or absolutely. */)
816 Lisp_Object value) 760 Lisp_Object value)
817{ 761{
818 CHECK_XWIDGET (xwidget); 762 CHECK_XWIDGET (xwidget);
763 CHECK_NATNUM (value);
819 struct xwidget *xw = XXWIDGET (xwidget); 764 struct xwidget *xw = XXWIDGET (xwidget);
820 GtkAdjustment *adjustment; 765 GtkAdjustment *adjustment
821 float final_value = 0.0; 766 = ((EQ (Qhorizontal, axis)
822 767 ? gtk_scrolled_window_get_hadjustment
823 adjustment = 768 : gtk_scrolled_window_get_vadjustment)
824 gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW 769 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr)));
825 (xw->widgetscrolledwindow_osr)); 770 double final_value = XFASTINT (value);
826 if (EQ (Qvertical, axis))
827 {
828 adjustment =
829 gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
830 (xw->widgetscrolledwindow_osr));
831 }
832 if (EQ (Qhorizontal, axis))
833 {
834 adjustment =
835 gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW
836 (xw->widgetscrolledwindow_osr));
837 }
838
839 if (EQ (Qt, relative)) 771 if (EQ (Qt, relative))
840 { 772 final_value += gtk_adjustment_get_value (adjustment);
841 final_value = gtk_adjustment_get_value (adjustment) + XFASTINT (value);
842 }
843 else
844 {
845 final_value = 0.0 + XFASTINT (value);
846 }
847
848 gtk_adjustment_set_value (adjustment, final_value); 773 gtk_adjustment_set_value (adjustment, final_value);
849
850 return Qnil; 774 return Qnil;
851} 775}
852 776
@@ -861,13 +785,9 @@ Emacs allocated area accordingly. */)
861{ 785{
862 CHECK_XWIDGET (xwidget); 786 CHECK_XWIDGET (xwidget);
863 GtkRequisition requisition; 787 GtkRequisition requisition;
864 Lisp_Object rv;
865 gtk_widget_size_request (XXWIDGET (xwidget)->widget_osr, &requisition); 788 gtk_widget_size_request (XXWIDGET (xwidget)->widget_osr, &requisition);
866 rv = Qnil; 789 return list2 (make_number (requisition.width),
867 rv = Fcons (make_number (requisition.height), rv); 790 make_number (requisition.height));
868 rv = Fcons (make_number (requisition.width), rv);
869 return rv;
870
871} 791}
872 792
873DEFUN ("xwidgetp", 793DEFUN ("xwidgetp",
@@ -896,18 +816,9 @@ Currently [TYPE TITLE WIDTH HEIGHT]. */)
896 (Lisp_Object xwidget) 816 (Lisp_Object xwidget)
897{ 817{
898 CHECK_XWIDGET (xwidget); 818 CHECK_XWIDGET (xwidget);
899 Lisp_Object info, n;
900 struct xwidget *xw = XXWIDGET (xwidget); 819 struct xwidget *xw = XXWIDGET (xwidget);
901 820 return CALLN (Fvector, xw->type, xw->title,
902 info = Fmake_vector (make_number (4), Qnil); 821 make_natnum (xw->width), make_natnum (xw->height));
903 ASET (info, 0, xw->type);
904 ASET (info, 1, xw->title);
905 XSETFASTINT (n, xw->width);
906 ASET (info, 2, n);
907 XSETFASTINT (n, xw->height);
908 ASET (info, 3, n);
909
910 return info;
911} 822}
912 823
913DEFUN ("xwidget-view-info", 824DEFUN ("xwidget-view-info",
@@ -919,17 +830,9 @@ Currently [X Y CLIP_RIGHT CLIP_BOTTOM CLIP_TOP CLIP_LEFT]. */)
919{ 830{
920 CHECK_XWIDGET_VIEW (xwidget_view); 831 CHECK_XWIDGET_VIEW (xwidget_view);
921 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view); 832 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view);
922 Lisp_Object info; 833 return CALLN (Fvector, make_number (xv->x), make_number (xv->y),
923 834 make_number (xv->clip_right), make_number (xv->clip_bottom),
924 info = Fmake_vector (make_number (6), Qnil); 835 make_number (xv->clip_top), make_number (xv->clip_left));
925 ASET (info, 0, make_number (xv->x));
926 ASET (info, 1, make_number (xv->y));
927 ASET (info, 2, make_number (xv->clip_right));
928 ASET (info, 3, make_number (xv->clip_bottom));
929 ASET (info, 4, make_number (xv->clip_top));
930 ASET (info, 5, make_number (xv->clip_left));
931
932 return info;
933} 836}
934 837
935DEFUN ("xwidget-view-model", 838DEFUN ("xwidget-view-model",
@@ -963,8 +866,8 @@ DEFUN ("delete-xwidget-view",
963 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view); 866 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view);
964 gtk_widget_destroy (xv->widgetwindow); 867 gtk_widget_destroy (xv->widgetwindow);
965 Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list); 868 Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list);
966 // xv->model still has signals pointing to the view. There can be 869 /* xv->model still has signals pointing to the view. There can be
967 // several views. Find the matching signals and delete them all. 870 several views. Find the matching signals and delete them all. */
968 g_signal_handlers_disconnect_matched (XXWIDGET (xv->model)->widgetwindow_osr, 871 g_signal_handlers_disconnect_matched (XXWIDGET (xv->model)->widgetwindow_osr,
969 G_SIGNAL_MATCH_DATA, 872 G_SIGNAL_MATCH_DATA,
970 0, 0, 0, 0, 873 0, 0, 0, 0,
@@ -1002,7 +905,7 @@ DEFUN ("xwidget-plist",
1002 Fxwidget_plist, Sxwidget_plist, 905 Fxwidget_plist, Sxwidget_plist,
1003 1, 1, 0, 906 1, 1, 0,
1004 doc: /* Return the plist of XWIDGET. */) 907 doc: /* Return the plist of XWIDGET. */)
1005 (register Lisp_Object xwidget) 908 (Lisp_Object xwidget)
1006{ 909{
1007 CHECK_XWIDGET (xwidget); 910 CHECK_XWIDGET (xwidget);
1008 return XXWIDGET (xwidget)->plist; 911 return XXWIDGET (xwidget)->plist;
@@ -1012,7 +915,7 @@ DEFUN ("xwidget-buffer",
1012 Fxwidget_buffer, Sxwidget_buffer, 915 Fxwidget_buffer, Sxwidget_buffer,
1013 1, 1, 0, 916 1, 1, 0,
1014 doc: /* Return the buffer of XWIDGET. */) 917 doc: /* Return the buffer of XWIDGET. */)
1015 (register Lisp_Object xwidget) 918 (Lisp_Object xwidget)
1016{ 919{
1017 CHECK_XWIDGET (xwidget); 920 CHECK_XWIDGET (xwidget);
1018 return XXWIDGET (xwidget)->buffer; 921 return XXWIDGET (xwidget)->buffer;
@@ -1023,7 +926,7 @@ DEFUN ("set-xwidget-plist",
1023 2, 2, 0, 926 2, 2, 0,
1024 doc: /* Replace the plist of XWIDGET with PLIST. 927 doc: /* Replace the plist of XWIDGET with PLIST.
1025Returns PLIST. */) 928Returns PLIST. */)
1026 (register Lisp_Object xwidget, Lisp_Object plist) 929 (Lisp_Object xwidget, Lisp_Object plist)
1027{ 930{
1028 CHECK_XWIDGET (xwidget); 931 CHECK_XWIDGET (xwidget);
1029 CHECK_LIST (plist); 932 CHECK_LIST (plist);
@@ -1059,7 +962,6 @@ DEFUN ("xwidget-query-on-exit-flag",
1059void 962void
1060syms_of_xwidget (void) 963syms_of_xwidget (void)
1061{ 964{
1062
1063 defsubr (&Smake_xwidget); 965 defsubr (&Smake_xwidget);
1064 defsubr (&Sxwidgetp); 966 defsubr (&Sxwidgetp);
1065 DEFSYM (Qxwidgetp, "xwidgetp"); 967 DEFSYM (Qxwidgetp, "xwidgetp");
@@ -1111,7 +1013,6 @@ syms_of_xwidget (void)
1111 Vxwidget_view_list = Qnil; 1013 Vxwidget_view_list = Qnil;
1112 1014
1113 Fprovide (intern ("xwidget-internal"), Qnil); 1015 Fprovide (intern ("xwidget-internal"), Qnil);
1114
1115} 1016}
1116 1017
1117 1018
@@ -1125,19 +1026,13 @@ syms_of_xwidget (void)
1125bool 1026bool
1126valid_xwidget_spec_p (Lisp_Object object) 1027valid_xwidget_spec_p (Lisp_Object object)
1127{ 1028{
1128 int valid_p = false; 1029 return CONSP (object) && EQ (XCAR (object), Qxwidget);
1129
1130 if (CONSP (object) && EQ (XCAR (object), Qxwidget))
1131 valid_p = true;
1132
1133 return valid_p;
1134} 1030}
1135 1031
1136 1032
1137
1138/* Find a value associated with key in spec. */ 1033/* Find a value associated with key in spec. */
1139static Lisp_Object 1034static Lisp_Object
1140xwidget_spec_value (Lisp_Object spec, Lisp_Object key, int *found) 1035xwidget_spec_value (Lisp_Object spec, Lisp_Object key)
1141{ 1036{
1142 Lisp_Object tail; 1037 Lisp_Object tail;
1143 1038
@@ -1147,15 +1042,9 @@ xwidget_spec_value (Lisp_Object spec, Lisp_Object key, int *found)
1147 CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail))) 1042 CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail)))
1148 { 1043 {
1149 if (EQ (XCAR (tail), key)) 1044 if (EQ (XCAR (tail), key))
1150 { 1045 return XCAR (XCDR (tail));
1151 if (found)
1152 *found = 1;
1153 return XCAR (XCDR (tail));
1154 }
1155 } 1046 }
1156 1047
1157 if (found)
1158 *found = 0;
1159 return Qnil; 1048 return Qnil;
1160} 1049}
1161 1050
@@ -1195,19 +1084,17 @@ lookup_xwidget (Lisp_Object spec)
1195{ 1084{
1196 /* When a xwidget lisp spec is found initialize the C struct that is 1085 /* When a xwidget lisp spec is found initialize the C struct that is
1197 used in the C code. This is done by redisplay so values change 1086 used in the C code. This is done by redisplay so values change
1198 if the spec changes. So, take special care of one-shot events. 1087 if the spec changes. So, take special care of one-shot events. */
1199 */
1200 int found = 0;
1201 Lisp_Object value; 1088 Lisp_Object value;
1202 struct xwidget *xw; 1089 struct xwidget *xw;
1203 1090
1204 value = xwidget_spec_value (spec, QCxwidget, &found); 1091 value = xwidget_spec_value (spec, QCxwidget);
1205 xw = XXWIDGET (value); 1092 xw = XXWIDGET (value);
1206 1093
1207 return xw; 1094 return xw;
1208} 1095}
1209 1096
1210/* Set up detection of touched xwidget */ 1097/* Set up detection of touched xwidget. */
1211static void 1098static void
1212xwidget_start_redisplay (void) 1099xwidget_start_redisplay (void)
1213{ 1100{
@@ -1215,7 +1102,7 @@ xwidget_start_redisplay (void)
1215 tail = XCDR (tail)) 1102 tail = XCDR (tail))
1216 { 1103 {
1217 if (XWIDGET_VIEW_P (XCAR (tail))) 1104 if (XWIDGET_VIEW_P (XCAR (tail)))
1218 XXWIDGET_VIEW (XCAR (tail))->redisplayed = 0; 1105 XXWIDGET_VIEW (XCAR (tail))->redisplayed = false;
1219 } 1106 }
1220} 1107}
1221 1108
@@ -1224,57 +1111,48 @@ xwidget_start_redisplay (void)
1224static void 1111static void
1225xwidget_touch (struct xwidget_view *xv) 1112xwidget_touch (struct xwidget_view *xv)
1226{ 1113{
1227 xv->redisplayed = 1; 1114 xv->redisplayed = true;
1228} 1115}
1229 1116
1230static int 1117static bool
1231xwidget_touched (struct xwidget_view *xv) 1118xwidget_touched (struct xwidget_view *xv)
1232{ 1119{
1233 return xv->redisplayed; 1120 return xv->redisplayed;
1234} 1121}
1235 1122
1236/* Redisplay has ended, now we should hide untouched xwidgets 1123/* Redisplay has ended, now we should hide untouched xwidgets. */
1237*/
1238void 1124void
1239xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix) 1125xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
1240{ 1126{
1241
1242 int i; 1127 int i;
1243 int area; 1128 int area;
1244 1129
1245 xwidget_start_redisplay (); 1130 xwidget_start_redisplay ();
1246 // Iterate desired glyph matrix of window here, hide gtk widgets 1131 /* Iterate desired glyph matrix of window here, hide gtk widgets
1247 // not in the desired matrix. 1132 not in the desired matrix.
1248 1133
1249 // This only takes care of xwidgets in active windows. If a window 1134 This only takes care of xwidgets in active windows. If a window
1250 // goes away from screen xwidget views wust be deleted 1135 goes away from screen xwidget views wust be deleted.
1251 1136
1252 // dump_glyph_matrix (matrix, 2); 1137 dump_glyph_matrix (matrix, 2); */
1253 for (i = 0; i < matrix->nrows; ++i) 1138 for (i = 0; i < matrix->nrows; ++i)
1254 { 1139 {
1255 // dump_glyph_row (MATRIX_ROW (matrix, i), i, glyphs); 1140 /* dump_glyph_row (MATRIX_ROW (matrix, i), i, glyphs); */
1256 struct glyph_row *row; 1141 struct glyph_row *row;
1257 row = MATRIX_ROW (matrix, i); 1142 row = MATRIX_ROW (matrix, i);
1258 if (row->enabled_p != 0) 1143 if (row->enabled_p)
1259 { 1144 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
1260 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) 1145 {
1261 { 1146 struct glyph *glyph = row->glyphs[area];
1262 struct glyph *glyph = row->glyphs[area]; 1147 struct glyph *glyph_end = glyph + row->used[area];
1263 struct glyph *glyph_end = glyph + row->used[area]; 1148 for (; glyph < glyph_end; ++glyph)
1264 for (; glyph < glyph_end; ++glyph) 1149 if (glyph->type == XWIDGET_GLYPH)
1265 { 1150 {
1266 if (glyph->type == XWIDGET_GLYPH) 1151 /* The only call to xwidget_end_redisplay is in dispnew.
1267 { 1152 xwidget_end_redisplay (w->current_matrix); */
1268 /* 1153 xwidget_touch (xwidget_view_lookup (glyph->u.xwidget, w));
1269 The only call to xwidget_end_redisplay is in dispnew 1154 }
1270 xwidget_end_redisplay (w->current_matrix); 1155 }
1271 */
1272 xwidget_touch (xwidget_view_lookup (glyph->u.xwidget,
1273 w));
1274 }
1275 }
1276 }
1277 }
1278 } 1156 }
1279 1157
1280 for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail); 1158 for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail);
@@ -1284,8 +1162,8 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
1284 { 1162 {
1285 struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail)); 1163 struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail));
1286 1164
1287 // "touched" is only meaningful for the current window, so 1165 /* "touched" is only meaningful for the current window, so
1288 // disregard other views. 1166 disregard other views. */
1289 if (XWINDOW (xv->w) == w) 1167 if (XWINDOW (xv->w) == w)
1290 { 1168 {
1291 if (xwidget_touched (xv)) 1169 if (xwidget_touched (xv))
@@ -1306,7 +1184,7 @@ kill_buffer_xwidgets (Lisp_Object buffer)
1306 { 1184 {
1307 xwidget = XCAR (tail); 1185 xwidget = XCAR (tail);
1308 Vxwidget_list = Fdelq (xwidget, Vxwidget_list); 1186 Vxwidget_list = Fdelq (xwidget, Vxwidget_list);
1309 /* TODO free the GTK things in xw */ 1187 /* TODO free the GTK things in xw. */
1310 { 1188 {
1311 CHECK_XWIDGET (xwidget); 1189 CHECK_XWIDGET (xwidget);
1312 struct xwidget *xw = XXWIDGET (xwidget); 1190 struct xwidget *xw = XXWIDGET (xwidget);
diff --git a/src/xwidget.h b/src/xwidget.h
index fdcf40d8cbb..1e11f110379 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -20,60 +20,62 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#ifndef XWIDGET_H_INCLUDED 20#ifndef XWIDGET_H_INCLUDED
21#define XWIDGET_H_INCLUDED 21#define XWIDGET_H_INCLUDED
22 22
23void x_draw_xwidget_glyph_string (struct glyph_string *s); 23#include "lisp.h"
24void syms_of_xwidget (void);
25
26//extern Lisp_Object Qxwidget;
27 24
25struct glyph_matrix;
26struct glyph_string;
27struct xwidget;
28struct xwidget_view;
29struct window;
28 30
29bool valid_xwidget_spec_p (Lisp_Object object); 31#ifdef HAVE_XWIDGETS
32# include <gtk/gtk.h>
30 33
31#include <gtk/gtk.h> 34struct xwidget
35{
36 struct vectorlike_header header;
32 37
38 /* Auxiliary data. */
39 Lisp_Object plist;
33 40
34/* 41 /* The widget type. */
35each xwidget instance/model is described by this struct. 42 Lisp_Object type;
36 43
37lisp pseudovector. 44 /* The buffer where the xwidget lives. */
45 Lisp_Object buffer;
38 46
47 /* A title used for button labels, for instance. */
48 Lisp_Object title;
39 49
40 */ 50 /* Here ends the Lisp part. "height" is the marker field. */
41struct xwidget
42{
43 struct vectorlike_header header;
44 Lisp_Object plist; //auxilliary data
45 Lisp_Object type; //the widget type
46 Lisp_Object buffer; //buffer where xwidget lives
47 Lisp_Object title; //a title that is used for button labels for instance
48 51
49 //here ends the lisp part.
50 //"height" is the marker field
51 int height; 52 int height;
52 int width; 53 int width;
53 54
54 //for offscreen widgets, unused if not osr 55 /* For offscreen widgets, unused if not osr. */
55 GtkWidget *widget_osr; 56 GtkWidget *widget_osr;
56 GtkWidget *widgetwindow_osr; 57 GtkWidget *widgetwindow_osr;
57 //this is used if the widget (webkit) is to be wrapped in a scrolled window, 58
59 /* Used if the widget (webkit) is to be wrapped in a scrolled window. */
58 GtkWidget *widgetscrolledwindow_osr; 60 GtkWidget *widgetscrolledwindow_osr;
59 /* Non-nil means kill silently if Emacs is exited. */
60 unsigned int kill_without_query:1;
61 61
62 /* Kill silently if Emacs is exited. */
63 bool_bf kill_without_query : 1;
62}; 64};
63 65
64
65//struct for each xwidget view
66struct xwidget_view 66struct xwidget_view
67{ 67{
68 struct vectorlike_header header; 68 struct vectorlike_header header;
69 Lisp_Object model; 69 Lisp_Object model;
70 Lisp_Object w; 70 Lisp_Object w;
71 71
72 //here ends the lisp part. 72 /* Here ends the lisp part. "redisplayed" is the marker field. */
73 //"redisplayed" is the marker field 73
74 int redisplayed; //if touched by redisplay 74 /* If touched by redisplay. */
75 bool redisplayed;
75 76
76 int hidden; //if the "live" instance isnt drawn 77 /* The "live" instance isn't drawn. */
78 bool hidden;
77 79
78 GtkWidget *widget; 80 GtkWidget *widget;
79 GtkWidget *widgetwindow; 81 GtkWidget *widgetwindow;
@@ -85,48 +87,47 @@ struct xwidget_view
85 int clip_top; 87 int clip_top;
86 int clip_left; 88 int clip_left;
87 89
88
89 long handler_id; 90 long handler_id;
90}; 91};
92#endif
91 93
92/* Test for xwidget pseudovector*/ 94/* Test for xwidget pseudovector. */
93#define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET) 95#define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET)
94#define XXWIDGET(a) (eassert (XWIDGETP(a)), \ 96#define XXWIDGET(a) (eassert (XWIDGETP (a)), \
95 (struct xwidget *) XUNTAG(a, Lisp_Vectorlike)) 97 (struct xwidget *) XUNTAG (a, Lisp_Vectorlike))
96 98
97#define CHECK_XWIDGET(x) \ 99#define CHECK_XWIDGET(x) \
98 CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x) 100 CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x)
99 101
100/* Test for xwidget_view pseudovector */ 102/* Test for xwidget_view pseudovector. */
101#define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW) 103#define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW)
102#define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P(a)), \ 104#define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P (a)), \
103 (struct xwidget_view *) XUNTAG(a, Lisp_Vectorlike)) 105 (struct xwidget_view *) XUNTAG (a, Lisp_Vectorlike))
104 106
105#define CHECK_XWIDGET_VIEW(x) \ 107#define CHECK_XWIDGET_VIEW(x) \
106 CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x) 108 CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x)
107 109
108struct xwidget_type
109{
110 /* A symbol uniquely identifying the xwidget type, */
111 Lisp_Object *type;
112
113 /* Check that SPEC is a valid image specification for the given
114 image type. Value is non-zero if SPEC is valid. */
115 int (*valid_p) (Lisp_Object spec);
116
117 /* Next in list of all supported image types. */
118 struct xwidget_type *next;
119};
120
121
122struct xwidget *xwidget_from_id (int id);
123
124void xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix);
125
126struct xwidget *lookup_xwidget (Lisp_Object spec);
127#define XG_XWIDGET "emacs_xwidget" 110#define XG_XWIDGET "emacs_xwidget"
128#define XG_XWIDGET_VIEW "emacs_xwidget_view" 111#define XG_XWIDGET_VIEW "emacs_xwidget_view"
129void xwidget_view_delete_all_in_window (struct window *w);
130 112
131void kill_buffer_xwidgets (Lisp_Object buffer); 113#ifdef HAVE_XWIDGETS
114void syms_of_xwidget (void);
115bool valid_xwidget_spec_p (Lisp_Object);
116void xwidget_view_delete_all_in_window (struct window *);
117void x_draw_xwidget_glyph_string (struct glyph_string *);
118struct xwidget *lookup_xwidget (Lisp_Object spec);
119void xwidget_end_redisplay (struct window *, struct glyph_matrix *);
120void kill_buffer_xwidgets (Lisp_Object);
121#else
122INLINE_HEADER_BEGIN
123INLINE void syms_of_xwidget (void) {}
124INLINE bool valid_xwidget_spec_p (Lisp_Object obj) { return false; }
125INLINE void xwidget_view_delete_all_in_window (struct window *w) {}
126INLINE void x_draw_xwidget_glyph_string (struct glyph_string *s) { eassume (0); }
127INLINE struct xwidget *lookup_xwidget (Lisp_Object obj) { eassume (0); }
128INLINE void xwidget_end_redisplay (struct window *w, struct glyph_matrix *m) {}
129INLINE void kill_buffer_xwidgets (Lisp_Object buf) {}
130INLINE_HEADER_END
131#endif
132
132#endif /* XWIDGET_H_INCLUDED */ 133#endif /* XWIDGET_H_INCLUDED */