aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2011-07-30 22:36:30 +0200
committerJoakim Verona2011-07-30 22:36:30 +0200
commitc8937ab98654b9161bd7d79ff98a76bd0d3a984d (patch)
tree6dbc240277a8ac10ef84a6a7fa1019a6adc38ee7 /src
parente9a96749ccad781690820381679b5091f2b1d6f4 (diff)
downloademacs-c8937ab98654b9161bd7d79ff98a76bd0d3a984d.tar.gz
emacs-c8937ab98654b9161bd7d79ff98a76bd0d3a984d.zip
ifdef guarding of xwidget code. not complete
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h18
-rw-r--r--src/dispnew.c4
-rw-r--r--src/emacs.c4
-rw-r--r--src/emacsgtkfixed.c7
-rw-r--r--src/insdel.c1
-rw-r--r--src/keyboard.c18
-rw-r--r--src/lisp.h2
-rw-r--r--src/print.c5
-rw-r--r--src/termhooks.h5
-rw-r--r--src/window.c5
-rw-r--r--src/xdisp.c57
-rw-r--r--src/xterm.c8
-rw-r--r--src/xwidget-attic.c499
13 files changed, 100 insertions, 533 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index 442839c3cf9..94c72e5ce3c 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -291,9 +291,10 @@ enum glyph_type
291 291
292 /* Glyph is a space of fractional width and/or height. */ 292 /* Glyph is a space of fractional width and/or height. */
293 STRETCH_GLYPH, 293 STRETCH_GLYPH,
294 294#ifdef HAVE_XWIDGETS
295 /* Glyph is an external widget drawn by the GUI toolkit. */ 295 /* Glyph is an external widget drawn by the GUI toolkit. */
296 XWIDGET_GLYPH 296 XWIDGET_GLYPH
297#endif
297}; 298};
298 299
299 300
@@ -436,7 +437,9 @@ struct glyph
436 /* Image ID for image glyphs (type == IMAGE_GLYPH). */ 437 /* Image ID for image glyphs (type == IMAGE_GLYPH). */
437 int img_id; 438 int img_id;
438 439
440#ifdef HAVE_XWIDGETS
439 struct xwidget* xwidget; 441 struct xwidget* xwidget;
442#endif
440 /* Sub-structure for type == STRETCH_GLYPH. */ 443 /* Sub-structure for type == STRETCH_GLYPH. */
441 struct 444 struct
442 { 445 {
@@ -1303,8 +1306,9 @@ struct glyph_string
1303 /* Image, if any. */ 1306 /* Image, if any. */
1304 struct image *img; 1307 struct image *img;
1305 1308
1309#ifdef HAVE_XWIDGETS
1306 struct xwidget* xwidget; 1310 struct xwidget* xwidget;
1307 1311#endif
1308 /* Slice */ 1312 /* Slice */
1309 struct glyph_slice slice; 1313 struct glyph_slice slice;
1310 1314
@@ -1987,7 +1991,9 @@ enum display_element_type
1987 /* Continuation glyphs. See the comment for IT_TRUNCATION. */ 1991 /* Continuation glyphs. See the comment for IT_TRUNCATION. */
1988 IT_CONTINUATION, 1992 IT_CONTINUATION,
1989 1993
1994#ifdef HAVE_XWIDGETS
1990 IT_XWIDGET 1995 IT_XWIDGET
1996#endif
1991}; 1997};
1992 1998
1993 1999
@@ -2051,7 +2057,9 @@ enum it_method {
2051 GET_FROM_C_STRING, 2057 GET_FROM_C_STRING,
2052 GET_FROM_IMAGE, 2058 GET_FROM_IMAGE,
2053 GET_FROM_STRETCH, 2059 GET_FROM_STRETCH,
2060#ifdef HAVE_XWIDGETS
2054 GET_FROM_XWIDGET, 2061 GET_FROM_XWIDGET,
2062#endif
2055 NUM_IT_METHODS 2063 NUM_IT_METHODS
2056}; 2064};
2057 2065
@@ -2265,12 +2273,13 @@ struct it
2265 struct { 2273 struct {
2266 Lisp_Object object; 2274 Lisp_Object object;
2267 } stretch; 2275 } stretch;
2276#ifdef HAVE_XWIDGETS
2268 /* method == GET_FROM_XWIDGET */ 2277 /* method == GET_FROM_XWIDGET */
2269 struct { 2278 struct {
2270 Lisp_Object object; 2279 Lisp_Object object;
2271 struct xwidget* xwidget; 2280 struct xwidget* xwidget;
2272 } xwidget; 2281 } xwidget;
2273 2282#endif
2274 } u; 2283 } u;
2275 2284
2276 /* current text and display positions. */ 2285 /* current text and display positions. */
@@ -2393,9 +2402,10 @@ struct it
2393 /* If what == IT_IMAGE, the id of the image to display. */ 2402 /* If what == IT_IMAGE, the id of the image to display. */
2394 int image_id; 2403 int image_id;
2395 2404
2405#ifdef HAVE_XWIDGETS
2396 /* If what == IT_XWIDGET*/ 2406 /* If what == IT_XWIDGET*/
2397 struct xwidget* xwidget; 2407 struct xwidget* xwidget;
2398 2408#endif
2399 /* Values from `slice' property. */ 2409 /* Values from `slice' property. */
2400 struct it_slice slice; 2410 struct it_slice slice;
2401 2411
diff --git a/src/dispnew.c b/src/dispnew.c
index 57beb1ae30e..1d9f849c43e 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3702,9 +3702,9 @@ update_window (struct window *w, int force_p)
3702 add_window_display_history (w, w->current_matrix->method, paused_p); 3702 add_window_display_history (w, w->current_matrix->method, paused_p);
3703#endif 3703#endif
3704 3704
3705 // if ((XWINDOW(FRAME_SELECTED_WINDOW (SELECTED_FRAME()))) == (w)) 3705#ifdef HAVE_XWIDGETS
3706 xwidget_end_redisplay(w, w->current_matrix); 3706 xwidget_end_redisplay(w, w->current_matrix);
3707 3707#endif
3708 clear_glyph_matrix (desired_matrix); 3708 clear_glyph_matrix (desired_matrix);
3709 3709
3710 return paused_p; 3710 return paused_p;
diff --git a/src/emacs.c b/src/emacs.c
index 4c818ff048f..bda56740e83 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -48,7 +48,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
48#include "buffer.h" 48#include "buffer.h"
49#include "window.h" 49#include "window.h"
50 50
51#ifdef HAVE_XWIDGETS
51#include "xwidget.h" 52#include "xwidget.h"
53#endif
52#include "systty.h" 54#include "systty.h"
53#include "blockinput.h" 55#include "blockinput.h"
54#include "syssignal.h" 56#include "syssignal.h"
@@ -1529,7 +1531,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1529 syms_of_xfns (); 1531 syms_of_xfns ();
1530 syms_of_xmenu (); 1532 syms_of_xmenu ();
1531 syms_of_fontset (); 1533 syms_of_fontset ();
1534#ifdef HAVE_XWIDGETS
1532 syms_of_xwidget(); 1535 syms_of_xwidget();
1536#endif
1533 syms_of_xsettings (); 1537 syms_of_xsettings ();
1534#ifdef HAVE_X_SM 1538#ifdef HAVE_X_SM
1535 syms_of_xsmfns (); 1539 syms_of_xsmfns ();
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 9b10957f583..34daab7285f 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -27,7 +27,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27#include "lisp.h" 27#include "lisp.h"
28#include "frame.h" 28#include "frame.h"
29#include "xterm.h" 29#include "xterm.h"
30#ifdef HAVE_XWIDGETS
30#include "xwidget.h" 31#include "xwidget.h"
32#endif
31struct _EmacsFixedPrivate 33struct _EmacsFixedPrivate
32{ 34{
33 struct frame *f; 35 struct frame *f;
@@ -42,6 +44,7 @@ static void emacs_fixed_get_preferred_height (GtkWidget *widget,
42 gint *natural); 44 gint *natural);
43G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) 45G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
44 46
47#ifdef HAVE_XWIDGETS
45/* void aloc_callback(GtkWidget* child, GtkWidget* fixed){ */ 48/* void aloc_callback(GtkWidget* child, GtkWidget* fixed){ */
46/* GtkAllocation child_allocation; */ 49/* GtkAllocation child_allocation; */
47/* GtkRequisition child_requisition; */ 50/* GtkRequisition child_requisition; */
@@ -154,7 +157,7 @@ static void emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget,
154 157
155} 158}
156 159
157 160#endif
158 161
159static void 162static void
160emacs_fixed_class_init (EmacsFixedClass *klass) 163emacs_fixed_class_init (EmacsFixedClass *klass)
@@ -167,7 +170,9 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
167 170
168 widget_class->get_preferred_width = emacs_fixed_get_preferred_width; 171 widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
169 widget_class->get_preferred_height = emacs_fixed_get_preferred_height; 172 widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
173#ifdef HAVE_XWIDGETS
170 widget_class->size_allocate = emacs_fixed_gtk_widget_size_allocate; 174 widget_class->size_allocate = emacs_fixed_gtk_widget_size_allocate;
175#endif
171 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); 176 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
172} 177}
173 178
diff --git a/src/insdel.c b/src/insdel.c
index dad9378c86e..0cae578925d 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -30,7 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include "window.h" 30#include "window.h"
31#include "blockinput.h" 31#include "blockinput.h"
32#include "region-cache.h" 32#include "region-cache.h"
33#include "xwidget.h"
34 33
35#ifndef NULL 34#ifndef NULL
36#define NULL 0 35#define NULL 0
diff --git a/src/keyboard.c b/src/keyboard.c
index 1c5cfcde951..b1d95a69124 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -329,7 +329,9 @@ static Lisp_Object Qsave_session;
329#ifdef HAVE_DBUS 329#ifdef HAVE_DBUS
330static Lisp_Object Qdbus_event; 330static Lisp_Object Qdbus_event;
331#endif 331#endif
332#ifdef HAVE_XWIDGETS
332Lisp_Object Qxwidget_event; 333Lisp_Object Qxwidget_event;
334#endif
333static Lisp_Object Qconfig_changed_event; 335static Lisp_Object Qconfig_changed_event;
334 336
335/* Lisp_Object Qmouse_movement; - also an event header */ 337/* Lisp_Object Qmouse_movement; - also an event header */
@@ -4029,7 +4031,14 @@ kbd_buffer_get_event (KBOARD **kbp,
4029 kbd_fetch_ptr = event + 1; 4031 kbd_fetch_ptr = event + 1;
4030 } 4032 }
4031#endif 4033#endif
4032 else if (event->kind == CONFIG_CHANGED_EVENT || event->kind == XWIDGET_EVENT) 4034#ifdef HAVE_XWIDGETS
4035 else if (event->kind == XWIDGET_EVENT)
4036 {
4037 obj = make_lispy_event (event);
4038 kbd_fetch_ptr = event + 1;
4039 }
4040#endif
4041 else if (event->kind == CONFIG_CHANGED_EVENT)
4033 { 4042 {
4034 obj = make_lispy_event (event); 4043 obj = make_lispy_event (event);
4035 kbd_fetch_ptr = event + 1; 4044 kbd_fetch_ptr = event + 1;
@@ -5924,12 +5933,13 @@ make_lispy_event (struct input_event *event)
5924 return Fcons (Qdbus_event, event->arg); 5933 return Fcons (Qdbus_event, event->arg);
5925 } 5934 }
5926#endif /* HAVE_DBUS */ 5935#endif /* HAVE_DBUS */
5936#ifdef HAVE_XWIDGETS
5927 case XWIDGET_EVENT: 5937 case XWIDGET_EVENT:
5928 { 5938 {
5929 printf("cool, an xwidget event arrived in make_lispy_event!\n"); 5939 printf("cool, an xwidget event arrived in make_lispy_event!\n");
5930 return Fcons (Qxwidget_event,event->arg); 5940 return Fcons (Qxwidget_event,event->arg);
5931 } 5941 }
5932 5942#endif
5933 case CONFIG_CHANGED_EVENT: 5943 case CONFIG_CHANGED_EVENT:
5934 return Fcons (Qconfig_changed_event, 5944 return Fcons (Qconfig_changed_event,
5935 Fcons (event->arg, 5945 Fcons (event->arg,
@@ -11542,10 +11552,10 @@ syms_of_keyboard (void)
11542 DEFSYM (Qdbus_event, "dbus-event"); 11552 DEFSYM (Qdbus_event, "dbus-event");
11543#endif 11553#endif
11544 11554
11545 11555#ifdef HAVE_XWIDGETS
11546 Qxwidget_event = intern ("xwidget-event"); 11556 Qxwidget_event = intern ("xwidget-event");
11547 staticpro (&Qxwidget_event); 11557 staticpro (&Qxwidget_event);
11548 11558#endif
11549 DEFSYM (QCenable, ":enable"); 11559 DEFSYM (QCenable, ":enable");
11550 DEFSYM (QCvisible, ":visible"); 11560 DEFSYM (QCvisible, ":visible");
11551 DEFSYM (QChelp, ":help"); 11561 DEFSYM (QChelp, ":help");
diff --git a/src/lisp.h b/src/lisp.h
index f404f8c368d..2359ff177dd 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -405,8 +405,10 @@ enum pvec_type
405 PVEC_SUB_CHAR_TABLE = 0x100000, 405 PVEC_SUB_CHAR_TABLE = 0x100000,
406 PVEC_FONT = 0x200000, 406 PVEC_FONT = 0x200000,
407 PVEC_OTHER = 0x400000, 407 PVEC_OTHER = 0x400000,
408#ifdef HAVE_XWIDGETS
408 PVEC_XWIDGET = 0x800000, 409 PVEC_XWIDGET = 0x800000,
409 PVEC_XWIDGET_VIEW = 0x1000000, 410 PVEC_XWIDGET_VIEW = 0x1000000,
411#endif
410 PVEC_TYPE_MASK = 0x3fffe00 412 PVEC_TYPE_MASK = 0x3fffe00
411 413
412#if 0 /* This is used to make the value of PSEUDOVECTOR_FLAG available to 414#if 0 /* This is used to make the value of PSEUDOVECTOR_FLAG available to
diff --git a/src/print.c b/src/print.c
index 9e30bc82258..15650d1bb6e 100644
--- a/src/print.c
+++ b/src/print.c
@@ -36,8 +36,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
36#include "blockinput.h" 36#include "blockinput.h"
37#include "termhooks.h" /* For struct terminal. */ 37#include "termhooks.h" /* For struct terminal. */
38#include "font.h" 38#include "font.h"
39#ifdef HAVE_XWIDGETS
39#include "xwidget.h" 40#include "xwidget.h"
40 41#endif
41Lisp_Object Qstandard_output; 42Lisp_Object Qstandard_output;
42 43
43static Lisp_Object Qtemp_buffer_setup_hook; 44static Lisp_Object Qtemp_buffer_setup_hook;
@@ -1759,11 +1760,13 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1759 strout (XSUBR (obj)->symbol_name, -1, -1, printcharfun); 1760 strout (XSUBR (obj)->symbol_name, -1, -1, printcharfun);
1760 PRINTCHAR ('>'); 1761 PRINTCHAR ('>');
1761 } 1762 }
1763#ifdef HAVE_XWIDGETS
1762 else if (XXWIDGETP (obj)) 1764 else if (XXWIDGETP (obj))
1763 { 1765 {
1764 strout ("#<xwidget ", -1, -1, printcharfun); 1766 strout ("#<xwidget ", -1, -1, printcharfun);
1765 PRINTCHAR ('>'); 1767 PRINTCHAR ('>');
1766 } 1768 }
1769#endif
1767 else if (WINDOWP (obj)) 1770 else if (WINDOWP (obj))
1768 { 1771 {
1769 strout ("#<window ", -1, -1, printcharfun); 1772 strout ("#<window ", -1, -1, printcharfun);
diff --git a/src/termhooks.h b/src/termhooks.h
index 8143948fb03..1310fba2f0a 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -205,9 +205,10 @@ enum event_kind
205 /* Non-key system events (e.g. application menu events) */ 205 /* Non-key system events (e.g. application menu events) */
206 , NS_NONKEY_EVENT 206 , NS_NONKEY_EVENT
207#endif 207#endif
208 /* events generated by xwidgets*/ 208#ifdef HAVE_XWIDGETS
209 /* events generated by xwidgets*/
209 , XWIDGET_EVENT 210 , XWIDGET_EVENT
210 211#endif
211}; 212};
212 213
213/* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT 214/* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
diff --git a/src/window.c b/src/window.c
index 14ebc89e04e..c945e0695f2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -49,8 +49,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
49#ifdef HAVE_NS 49#ifdef HAVE_NS
50#include "nsterm.h" 50#include "nsterm.h"
51#endif 51#endif
52 52#ifdef HAVE_XWIDGETS
53#include "xwidget.h" 53#include "xwidget.h"
54#endif
54Lisp_Object Qwindowp, Qwindow_live_p; 55Lisp_Object Qwindowp, Qwindow_live_p;
55static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; 56static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer;
56static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; 57static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
@@ -3934,7 +3935,9 @@ when WINDOW is the only window on its frame. */)
3934 { 3935 {
3935 /* Block input. */ 3936 /* Block input. */
3936 BLOCK_INPUT; 3937 BLOCK_INPUT;
3938#ifdef HAVE_XWIDGETS
3937 xwidget_view_delete_all_in_window(w); 3939 xwidget_view_delete_all_in_window(w);
3940#endif
3938 window_resize_apply (p, horflag); 3941 window_resize_apply (p, horflag);
3939 3942
3940 windows_or_buffers_changed++; 3943 windows_or_buffers_changed++;
diff --git a/src/xdisp.c b/src/xdisp.c
index 597793c70b5..14541eb9df0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -313,8 +313,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
313#endif 313#endif
314 314
315#include "font.h" 315#include "font.h"
316 316#ifdef HAVE_XWIDGETS
317#include "xwidget.h" 317#include "xwidget.h"
318#endif
318#ifndef FRAME_X_OUTPUT 319#ifndef FRAME_X_OUTPUT
319#define FRAME_X_OUTPUT(f) ((f)->output_data.x) 320#define FRAME_X_OUTPUT(f) ((f)->output_data.x)
320#endif 321#endif
@@ -884,7 +885,9 @@ static int next_element_from_c_string (struct it *);
884static int next_element_from_buffer (struct it *); 885static int next_element_from_buffer (struct it *);
885static int next_element_from_composition (struct it *); 886static int next_element_from_composition (struct it *);
886static int next_element_from_image (struct it *); 887static int next_element_from_image (struct it *);
888#ifdef HAVE_XWIDGETS
887static int next_element_from_xwidget(struct it *); 889static int next_element_from_xwidget(struct it *);
890#endif
888static int next_element_from_stretch (struct it *); 891static int next_element_from_stretch (struct it *);
889static void load_overlay_strings (struct it *, EMACS_INT); 892static void load_overlay_strings (struct it *, EMACS_INT);
890static int init_from_display_pos (struct it *, struct window *, 893static int init_from_display_pos (struct it *, struct window *,
@@ -4129,7 +4132,9 @@ handle_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4129 if (CONSP (spec) 4132 if (CONSP (spec)
4130 /* Simple specerties. */ 4133 /* Simple specerties. */
4131 && !EQ (XCAR (spec), Qimage) 4134 && !EQ (XCAR (spec), Qimage)
4135#ifdef HAVE_XWIDGETS
4132 && !EQ (XCAR (spec), Qxwidget) 4136 && !EQ (XCAR (spec), Qxwidget)
4137#endif
4133 && !EQ (XCAR (spec), Qspace) 4138 && !EQ (XCAR (spec), Qspace)
4134 && !EQ (XCAR (spec), Qwhen) 4139 && !EQ (XCAR (spec), Qwhen)
4135 && !EQ (XCAR (spec), Qslice) 4140 && !EQ (XCAR (spec), Qslice)
@@ -4548,7 +4553,10 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4548 && valid_image_p (value)) 4553 && valid_image_p (value))
4549#endif /* not HAVE_WINDOW_SYSTEM */ 4554#endif /* not HAVE_WINDOW_SYSTEM */
4550 || (CONSP (value) && EQ (XCAR (value), Qspace)) 4555 || (CONSP (value) && EQ (XCAR (value), Qspace))
4551 || XWIDGETP(value)); 4556#ifdef HAVE_XWIDGETS
4557 || XWIDGETP(value)
4558#endif
4559 );
4552 4560
4553 if (valid_p && !display_replaced_p) 4561 if (valid_p && !display_replaced_p)
4554 { 4562 {
@@ -4612,6 +4620,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4612 it->object = value; 4620 it->object = value;
4613 *position = it->position = start_pos; 4621 *position = it->position = start_pos;
4614 } 4622 }
4623#ifdef HAVE_XWIDGETS
4615 else if (XWIDGETP(value)) 4624 else if (XWIDGETP(value))
4616 { 4625 {
4617 //printf("handle_single_display_spec: im an xwidget!!\n"); 4626 //printf("handle_single_display_spec: im an xwidget!!\n");
@@ -4623,8 +4632,9 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4623 4632
4624 it->xwidget = lookup_xwidget(value); 4633 it->xwidget = lookup_xwidget(value);
4625 } 4634 }
4635#endif
4626#ifdef HAVE_WINDOW_SYSTEM 4636#ifdef HAVE_WINDOW_SYSTEM
4627 else //if nothing else, its an image 4637 else
4628 { 4638 {
4629 it->what = IT_IMAGE; 4639 it->what = IT_IMAGE;
4630 it->image_id = lookup_image (it->f, value); 4640 it->image_id = lookup_image (it->f, value);
@@ -5338,9 +5348,11 @@ push_it (struct it *it, struct text_pos *position)
5338 case GET_FROM_STRETCH: 5348 case GET_FROM_STRETCH:
5339 p->u.stretch.object = it->object; 5349 p->u.stretch.object = it->object;
5340 break; 5350 break;
5351#ifdef HAVE_XWIDGETS
5341 case GET_FROM_XWIDGET: 5352 case GET_FROM_XWIDGET:
5342 p->u.xwidget.object = it->object; 5353 p->u.xwidget.object = it->object;
5343 break; 5354 break;
5355#endif
5344 } 5356 }
5345 p->position = position ? *position : it->position; 5357 p->position = position ? *position : it->position;
5346 p->current = it->current; 5358 p->current = it->current;
@@ -5433,9 +5445,11 @@ pop_it (struct it *it)
5433 it->object = p->u.image.object; 5445 it->object = p->u.image.object;
5434 it->slice = p->u.image.slice; 5446 it->slice = p->u.image.slice;
5435 break; 5447 break;
5448#ifdef HAVE_XWIDGETS
5436 case GET_FROM_XWIDGET: 5449 case GET_FROM_XWIDGET:
5437 it->object = p->u.xwidget.object; 5450 it->object = p->u.xwidget.object;
5438 break; 5451 break;
5452#endif
5439 case GET_FROM_STRETCH: 5453 case GET_FROM_STRETCH:
5440 it->object = p->u.stretch.object; 5454 it->object = p->u.stretch.object;
5441 break; 5455 break;
@@ -6031,8 +6045,10 @@ static int (* get_next_element[NUM_IT_METHODS]) (struct it *it) =
6031 next_element_from_string, 6045 next_element_from_string,
6032 next_element_from_c_string, 6046 next_element_from_c_string,
6033 next_element_from_image, 6047 next_element_from_image,
6034 next_element_from_stretch, 6048 next_element_from_stretch
6035 next_element_from_xwidget 6049#ifdef HAVE_XWIDGETS
6050 ,next_element_from_xwidget
6051#endif
6036}; 6052};
6037 6053
6038#define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it) 6054#define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it)
@@ -6832,7 +6848,9 @@ set_iterator_to_next (struct it *it, int reseat_p)
6832 6848
6833 case GET_FROM_IMAGE: 6849 case GET_FROM_IMAGE:
6834 case GET_FROM_STRETCH: 6850 case GET_FROM_STRETCH:
6851#ifdef HAVE_XWIDGETS
6835 case GET_FROM_XWIDGET: 6852 case GET_FROM_XWIDGET:
6853#endif
6836 /* The position etc with which we have to proceed are on 6854 /* The position etc with which we have to proceed are on
6837 the stack. The position may be at the end of a string, 6855 the stack. The position may be at the end of a string,
6838 if the `display' property takes up the whole string. */ 6856 if the `display' property takes up the whole string. */
@@ -7259,6 +7277,7 @@ next_element_from_image (struct it *it)
7259 return 1; 7277 return 1;
7260} 7278}
7261 7279
7280#ifdef HAVE_XWIDGETS
7262/* im not sure about this FIXME JAVE*/ 7281/* im not sure about this FIXME JAVE*/
7263static int 7282static int
7264next_element_from_xwidget (struct it *it) 7283next_element_from_xwidget (struct it *it)
@@ -7269,7 +7288,7 @@ next_element_from_xwidget (struct it *it)
7269 //printf("xwidget_id %d: in next_element_from_xwidget: FIXME \n", it->xwidget_id); 7288 //printf("xwidget_id %d: in next_element_from_xwidget: FIXME \n", it->xwidget_id);
7270 return 1; 7289 return 1;
7271} 7290}
7272 7291#endif
7273 7292
7274 7293
7275/* Fill iterator IT with next display element from a stretch glyph 7294/* Fill iterator IT with next display element from a stretch glyph
@@ -17206,6 +17225,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
17206 glyph->left_box_line_p, 17225 glyph->left_box_line_p,
17207 glyph->right_box_line_p); 17226 glyph->right_box_line_p);
17208 } 17227 }
17228#ifdef HAVE_XWIDGETS
17209 else if (glyph->type == XWIDGET_GLYPH) 17229 else if (glyph->type == XWIDGET_GLYPH)
17210 { 17230 {
17211 fprintf (stderr, 17231 fprintf (stderr,
@@ -17227,6 +17247,7 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
17227 17247
17228 // printf("dump xwidget glyph\n"); 17248 // printf("dump xwidget glyph\n");
17229 } 17249 }
17250#endif
17230} 17251}
17231 17252
17232 17253
@@ -17600,10 +17621,7 @@ static void
17600compute_line_metrics (struct it *it) 17621compute_line_metrics (struct it *it)
17601{ 17622{
17602 struct glyph_row *row = it->glyph_row; 17623 struct glyph_row *row = it->glyph_row;
17603 if(row->used[TEXT_AREA] > 1000){ 17624
17604 printf("compute_line_metrics %d %d %d\n", row->used[TEXT_AREA], it->f->text_cols, row->end.pos.charpos);
17605 printf("row->used[TEXT_AREA] seems weirdly big! emacs will crash soon\n");
17606 }
17607 if (FRAME_WINDOW_P (it->f)) 17625 if (FRAME_WINDOW_P (it->f))
17608 { 17626 {
17609 int i, min_y, max_y; 17627 int i, min_y, max_y;
@@ -21332,12 +21350,13 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
21332 21350
21333 return OK_PIXELS (width_p ? img->width : img->height); 21351 return OK_PIXELS (width_p ? img->width : img->height);
21334 } 21352 }
21335 21353#ifdef HAVE_XWIDGETS
21336 if (FRAME_WINDOW_P (it->f) && valid_xwidget_p (prop)) 21354 if (FRAME_WINDOW_P (it->f) && valid_xwidget_p (prop))
21337 { 21355 {
21338 printf("calc_pixel_width_or_height: return dummy size FIXME\n"); 21356 printf("calc_pixel_width_or_height: return dummy size FIXME\n");
21339 return OK_PIXELS (width_p ? 100 : 100); 21357 return OK_PIXELS (width_p ? 100 : 100);
21340 } 21358 }
21359#endif
21341#endif 21360#endif
21342 if (EQ (car, Qplus) || EQ (car, Qminus)) 21361 if (EQ (car, Qplus) || EQ (car, Qminus))
21343 { 21362 {
@@ -21832,6 +21851,7 @@ fill_image_glyph_string (struct glyph_string *s)
21832 s->ybase += s->first_glyph->voffset; 21851 s->ybase += s->first_glyph->voffset;
21833} 21852}
21834 21853
21854#ifdef HAVE_XWIDGETS
21835static void 21855static void
21836fill_xwidget_glyph_string (struct glyph_string *s) 21856fill_xwidget_glyph_string (struct glyph_string *s)
21837{ 21857{
@@ -21844,7 +21864,7 @@ fill_xwidget_glyph_string (struct glyph_string *s)
21844 s->xwidget = s->first_glyph->u.xwidget; 21864 s->xwidget = s->first_glyph->u.xwidget;
21845 //assert_valid_xwidget_id ( s->xwidget, "fill_xwidget_glyph_string"); 21865 //assert_valid_xwidget_id ( s->xwidget, "fill_xwidget_glyph_string");
21846} 21866}
21847 21867#endif
21848/* Fill glyph string S from a sequence of stretch glyphs. 21868/* Fill glyph string S from a sequence of stretch glyphs.
21849 21869
21850 START is the index of the first glyph to consider, 21870 START is the index of the first glyph to consider,
@@ -22176,6 +22196,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p)
22176 } \ 22196 } \
22177 while (0) 22197 while (0)
22178 22198
22199#ifdef HAVE_XWIDGETS
22179#define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ 22200#define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
22180 do \ 22201 do \
22181 { \ 22202 { \
@@ -22188,7 +22209,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p)
22188 s->x = (X); \ 22209 s->x = (X); \
22189 } \ 22210 } \
22190 while (0) 22211 while (0)
22191 22212#endif
22192 22213
22193 22214
22194/* Add a glyph string for a sequence of character glyphs to the list 22215/* Add a glyph string for a sequence of character glyphs to the list
@@ -22348,7 +22369,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, int backward_p)
22348 BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL, \ 22369 BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL, \
22349 HL, X, LAST_X); \ 22370 HL, X, LAST_X); \
22350 break; \ 22371 break; \
22351 \ 22372 \
22352 \ 22373 \
22353 case GLYPHLESS_GLYPH: \ 22374 case GLYPHLESS_GLYPH: \
22354 BUILD_GLYPHLESS_GLYPH_STRING (START, END, HEAD, TAIL, \ 22375 BUILD_GLYPHLESS_GLYPH_STRING (START, END, HEAD, TAIL, \
@@ -22960,6 +22981,7 @@ produce_image_glyph (struct it *it)
22960 } 22981 }
22961} 22982}
22962 22983
22984#ifdef HAVE_XWIDGETS
22963static void 22985static void
22964produce_xwidget_glyph (struct it *it) 22986produce_xwidget_glyph (struct it *it)
22965{ 22987{
@@ -23041,7 +23063,7 @@ produce_xwidget_glyph (struct it *it)
23041 IT_EXPAND_MATRIX_WIDTH (it, area); 23063 IT_EXPAND_MATRIX_WIDTH (it, area);
23042 } 23064 }
23043} 23065}
23044 23066#endif
23045 23067
23046/* Append a stretch glyph to IT->glyph_row. OBJECT is the source 23068/* Append a stretch glyph to IT->glyph_row. OBJECT is the source
23047 of the glyph, WIDTH and HEIGHT are the width and height of the 23069 of the glyph, WIDTH and HEIGHT are the width and height of the
@@ -24215,9 +24237,10 @@ x_produce_glyphs (struct it *it)
24215 produce_image_glyph (it); 24237 produce_image_glyph (it);
24216 else if (it->what == IT_STRETCH) 24238 else if (it->what == IT_STRETCH)
24217 produce_stretch_glyph (it); 24239 produce_stretch_glyph (it);
24240#ifdef HAVE_XWIDGETS
24218 else if (it->what == IT_XWIDGET) 24241 else if (it->what == IT_XWIDGET)
24219 produce_xwidget_glyph (it); 24242 produce_xwidget_glyph (it);
24220 24243#endif
24221 done: 24244 done:
24222 /* Accumulate dimensions. Note: can't assume that it->descent > 0 24245 /* Accumulate dimensions. Note: can't assume that it->descent > 0
24223 because this isn't true for images with `:ascent 100'. */ 24246 because this isn't true for images with `:ascent 100'. */
@@ -24579,10 +24602,12 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
24579 if (!w->cursor_off_p) 24602 if (!w->cursor_off_p)
24580 { 24603 {
24581 24604
24605#ifdef HAVE_XWIDGETS
24582 if (glyph != NULL && glyph->type == XWIDGET_GLYPH){ 24606 if (glyph != NULL && glyph->type == XWIDGET_GLYPH){
24583 printf("attempt xwidget cursor avoidance in get_window_cursor_type\n"); 24607 printf("attempt xwidget cursor avoidance in get_window_cursor_type\n");
24584 return NO_CURSOR; 24608 return NO_CURSOR;
24585 } 24609 }
24610#endif
24586 if (glyph != NULL && glyph->type == IMAGE_GLYPH) 24611 if (glyph != NULL && glyph->type == IMAGE_GLYPH)
24587 { 24612 {
24588 if (cursor_type == FILLED_BOX_CURSOR) 24613 if (cursor_type == FILLED_BOX_CURSOR)
diff --git a/src/xterm.c b/src/xterm.c
index a7bdffa8bf3..510016e3d45 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -62,7 +62,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
62#include "coding.h" 62#include "coding.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
66#include "fontset.h" 68#include "fontset.h"
67#include "termhooks.h" 69#include "termhooks.h"
68#include "termopts.h" 70#include "termopts.h"
@@ -2680,13 +2682,13 @@ x_draw_glyph_string (struct glyph_string *s)
2680 case IMAGE_GLYPH: 2682 case IMAGE_GLYPH:
2681 x_draw_image_glyph_string (s); 2683 x_draw_image_glyph_string (s);
2682 break; 2684 break;
2683 2685#ifdef HAVE_XWIDGETS
2684 case XWIDGET_GLYPH: 2686 case XWIDGET_GLYPH:
2685 //erase xwidget background 2687 //erase xwidget background
2686 x_draw_glyph_string_background (s, 0); 2688 x_draw_glyph_string_background (s, 0);
2687 x_draw_xwidget_glyph_string (s); 2689 x_draw_xwidget_glyph_string (s);
2688 break; 2690 break;
2689 2691#endif
2690 case STRETCH_GLYPH: 2692 case STRETCH_GLYPH:
2691 x_draw_stretch_glyph_string (s); 2693 x_draw_stretch_glyph_string (s);
2692 break; 2694 break;
@@ -7255,10 +7257,12 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
7255 cursor_glyph = get_phys_cursor_glyph (w); 7257 cursor_glyph = get_phys_cursor_glyph (w);
7256 if (cursor_glyph == NULL) 7258 if (cursor_glyph == NULL)
7257 return; 7259 return;
7260#ifdef HAVE_XWIDGETS
7258 if (cursor_glyph->type == XWIDGET_GLYPH){ 7261 if (cursor_glyph->type == XWIDGET_GLYPH){
7259 printf("tried avoiding xwidget cursor\n"); 7262 printf("tried avoiding xwidget cursor\n");
7260 return; //experimental avoidance of cursor on xwidget 7263 return; //experimental avoidance of cursor on xwidget
7261 } 7264 }
7265#endif
7262 /* If on an image, draw like a normal cursor. That's usually better 7266 /* If on an image, draw like a normal cursor. That's usually better
7263 visible than drawing a bar, esp. if the image is large so that 7267 visible than drawing a bar, esp. if the image is large so that
7264 the bar might not be in the window. */ 7268 the bar might not be in the window. */
diff --git a/src/xwidget-attic.c b/src/xwidget-attic.c
deleted file mode 100644
index 5bbbddc2d57..00000000000
--- a/src/xwidget-attic.c
+++ /dev/null
@@ -1,499 +0,0 @@
1static int once = 0;
2
3int
4xwidget_has_composition(void){ //unused
5int event_base, error_base;
6Display* dpy = GDK_DISPLAY ();
7int i;
8 if(xwidget_query_composition_called)
9 return hasNamePixmap;
10 xwidget_query_composition_called = 1;
11
12 //do this once in an emacs session
13
14 if(gdk_display_supports_composite(gdk_display_get_default ())){
15 hasNamePixmap = 1;
16 }else{
17 return 0;
18 }
19 return 1;
20}
21
22
23
24
25
26void
27xwidget_end_composition(struct xwidget* w){ //unused
28 //XCompositeUnredirectWindow(); stop redirecting, should be called when the socket is destroyed
29}
30
31
32static gboolean
33xwidget_composite_draw_phantom(struct xwidget* xw,
34 int x, int y,
35 int clipx, int clipy)
36{
37 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA);
38 ////////////////////////////////////////////////////////////////
39 //Example 7. Composited windows
40 GdkRegion *region;
41 GtkWidget *child;
42 cairo_t *cr;
43 printf("xwidget_composite_draw_2 at:%d %d\n", x,y);
44 /* get our child (in this case, the event box) */
45 child = xw->widget; //gtk_bin_get_child (GTK_BIN (widget));
46 /* create a cairo context to draw to the emacs window */
47 cr = gdk_cairo_create (gtk_widget_get_window (FRAME_GTK_WIDGET (s->f)));//GTK_WIDGET(xw->emacswindow));//));//widget->window);
48 /* the source data is the (composited) xwidget */
49 //cairo_move_to(cr, xw->x, xw->y);
50
51 cairo_rectangle(cr, x,y, clipx, clipy);
52 cairo_clip(cr);
53
54 cairo_set_source_rgb(cr,1.0,0,0);
55 cairo_rectangle(cr,x,y,xw->width,xw->height);
56 cairo_fill(cr);
57
58 gdk_cairo_set_source_pixmap (cr, child->window,
59 x,//child->allocation.x,
60 y//child->allocation.y
61 );
62 /* draw no more than our expose event intersects our child */
63 /* region = gdk_region_rectangle (&child->allocation);
64 gdk_region_intersect (region, event->region);
65 gdk_cairo_region (cr, region);
66 cairo_clip (cr); */
67 /* composite, with a 50% opacity */
68 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
69 //cairo_paint_with_alpha (cr, phantom ? 0.5 : 0);
70 cairo_paint_with_alpha (cr, 0.9);
71 //cairo_paint(cr);//transparency);
72 /* we're done */
73 cairo_destroy (cr);
74 return FALSE;
75}
76
77
78
79/*
80static gboolean
81xwidget_composite_draw(GtkWidget *widget,
82 GdkEventExpose *event,
83 gpointer data)
84{
85 struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
86 printf("xwidget_composite_draw %s\n", data);
87 xwidget_composite_draw_2(widget,
88 event,
89 data,
90 xw->x, xw->y, 0);
91 return FALSE;
92}
93*/
94
95
96static gboolean
97xwidget_composite_draw_widgetwindow(GtkWidget *widget,
98 GdkEventExpose *event,
99 gpointer data)
100{
101 struct xwidget* xw = (struct xwidget*) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
102 cairo_t *cr;
103 GdkPixmap *pixmap;
104 pixmap=xw->widget->window;
105 printf("xwidget_composite_draw_widgetwindow xw.id:%d xw.type:%d window:%d\n", xw->id,xw->type, gtk_widget_get_window (widget));
106 //if(xw->type!=3)//TODO this is just trial and terror to see if i can draw the live socket anywhere at all
107 cr = gdk_cairo_create (gtk_widget_get_window (widget));//GTK_LAYOUT (xw->widgetwindow)->bin_window);//
108 //else cr = gdk_cairo_create (gtk_widget_get_window (xw->emacswindow));
109 cairo_rectangle(cr, 0,0, xw->width, xw->height);
110 cairo_clip(cr);
111
112 cairo_set_source_rgb(cr,0,1.0,0);
113 cairo_rectangle(cr, 0,0, xw->width, xw->height);
114 cairo_fill(cr);
115 gdk_cairo_set_source_pixmap (cr, pixmap,
116 0,0);
117
118 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
119 cairo_paint_with_alpha (cr, 0.9);
120 //cairo_paint(cr);
121 cairo_destroy (cr);
122
123 return FALSE;
124}
125
126
127//type support nevermind for now
128
129/* /\* List of supported image types. Use define_image_type to add new */
130/* types. Use lookup_image_type to find a type for a given symbol. *\/ */
131
132/* static struct wxidget_type *wxidget_types; */
133
134/* /\* Look up xwidget type SYMBOL, and return a pointer to its xwidget_type */
135/* structure. Value is null if SYMBOL is not a known image type. *\/ */
136
137/* static INLINE struct xwidget_type *lookup_xwidget_type (Lisp_Object symbol) */
138/* { */
139/* struct xwidget_type *type; */
140
141/* for (type = xwidget_types; type; type = type->next) */
142/* if (EQ (symbol, *type->type)) */
143/* break; */
144
145/* return type; */
146/* } */
147
148
149////////////////////////////////////////////////////////////////
150
151/* delete the xwidget and its native widget peer(unused) */
152void xwidget_delete(struct xwidget* xw);
153
154
155void
156xwidget_delete (struct xwidget *xw)
157{
158 printf ("xwidget %d deleted\n", xw->id);
159 xw->initialized = 0;
160 gtk_widget_destroy (xw->widget);
161
162}
163
164
165/* redraw all xwidgets(unused) */
166void
167xwidget_invalidate (void)
168{
169 int i;
170 struct xwidget *xw;
171 printf ("invalidate ");
172 for (i = 0; i < MAX_XWIDGETS; i++)
173 {
174 xw = &xwidgets[i];
175 if (xw->initialized)
176 {
177 printf ("%d,", i);
178 gtk_widget_queue_draw_area (xw->widget, 0, 0, xw->width,
179 xw->height);
180 }
181 }
182 printf ("\n");
183}
184
185
186/* initializes the xwidget model */
187void
188xwidget_init_model (struct xwidget *xw,
189 struct glyph_string *s,
190 int x, int y)
191{
192 xw->id = s->xwidget_id;
193 xw->initialized = 1;
194}
195
196
197
198DEFUN ("xwidget-replug", Fxwidget_replug, Sxwidget_replug, 2, 2, 0,
199 doc: /* unplug from socket1 plug into socket2.*/
200 )
201 (Lisp_Object old_parent, Lisp_Object new_parent)
202{
203
204 struct xwidget *xw1;
205 struct xwidget *xw2;
206
207
208 GtkWidget* widget;
209 CHECK_NUMBER (old_parent);
210 CHECK_NUMBER (new_parent);
211
212 xw1 = &xwidgets[XFASTINT (old_parent)];
213 xw2 = &xwidgets[XFASTINT (new_parent)];
214
215
216 ///this wasnt thought through. we need the views rather than the model.
217 //so we need to map xw+w to xv
218
219 widget = xw1->widget->gtk_socket_get_plug_window ();
220
221 //the plug...
222 gtk_widget_ref(widget);//...gets an xtra ref to prevent garb, then it ...
223 gtk_container_remove(GTK_CONTAINER(xw1->widget), widget);//...is uplugged from old socket and...
224 gtk_container_add(GTK_CONTAINER(xw2->widget), widget);//...replugged in new socket...
225 gtk_widget_unref(widget);//...and lastly remove the ref
226
227 return Qnil;
228}
229
230
231
232double osr_dbg_color=0;
233void webkit_osr_redraw_child ( struct xwidget* xw, GtkWidget *widget)
234{
235
236 //this stuff is different in gtk3
237#ifndef HAVE_GTK3
238 cairo_t *cr;
239
240
241 GdkPixmap *src_pixmap;
242 src_pixmap = gtk_offscreen_window_get_pixmap(xw->widgetwindow_osr);
243
244 //g_object_ref(src_pixmap);//TODO needs to be unrefed eventually, if we are to use his method
245
246
247 printf("webkit_osr_redraw_child xw.id:%d xw.type:%d window:%d\n", xw->id,xw->type, gtk_widget_get_window (widget));
248
249 cr = gdk_cairo_create (gtk_widget_get_window (widget));
250
251 cairo_rectangle(cr, 0,0, xw->width, xw->height);
252 cairo_clip(cr);
253
254 // debugging redraw:
255 // - the bg colors always change, so theres no error in signal handling
256 // - i get this error now and then:
257 //(emacs:7109): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
258 // seems to happen in webkit actually. see README
259
260 if(1){ //redraw debug hack
261 cairo_set_source_rgb(cr, osr_dbg_color, 1.0, 0.2);
262 cairo_rectangle(cr, 0,0, xw->width, xw->height);
263 cairo_fill(cr);
264 osr_dbg_color+=0.1;
265 if(osr_dbg_color>1.0)
266 osr_dbg_color=0.0;
267
268 }
269
270 gdk_cairo_set_source_pixmap (cr, src_pixmap, 0,0); //deprecated. use gdk_cairo_set_source_window
271 //gdk_cairo_set_source_window(cr, src_pixmap, 0,0);
272
273 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
274 cairo_paint_with_alpha (cr, 0.7);
275 //cairo_paint(cr);
276
277
278 cairo_destroy (cr);
279#else
280 cairo_t *cr;
281 cairo_surface_t * *src_pixmap;
282 src_pixmap = gtk_offscreen_window_get_surface (xw->widgetwindow_osr);
283
284 printf("webkit_osr_redraw_child gtk3 xw.id:%d xw.type:%d window:%d\n", xw->id,xw->type, gtk_widget_get_window (widget));
285
286 cr = gdk_cairo_create (gtk_widget_get_window (widget));
287
288 cairo_rectangle(cr, 0,0, xw->width, xw->height);
289 cairo_clip(cr);
290
291 // debugging redraw:
292 // - the bg colors always change, so theres no error in signal handling
293 // - i get this error now and then:
294 //(emacs:7109): GLib-GObject-WARNING **: invalid cast from `GdkOffscreenWindow' to `GdkDrawableImplX11'
295 // seems to happen in webkit actually. see README
296
297 if(1){ //redraw debug hack
298 cairo_set_source_rgb(cr, osr_dbg_color, 1.0, 0.2);
299 cairo_rectangle(cr, 0,0, xw->width, xw->height);
300 cairo_fill(cr);
301 osr_dbg_color+=0.1;
302 if(osr_dbg_color>1.0)
303 osr_dbg_color=0.0;
304
305 }
306
307 cairo_set_source_surface (cr, src_pixmap, 0,0);
308
309
310 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
311 cairo_paint_with_alpha (cr, 0.7);
312 //cairo_paint(cr);
313 cairo_destroy (cr);
314#endif
315}
316
317
318
319DEFUN ("xwidget-embed-steal-window", Fxwidget_embed_steal_window, Sxwidget_embed_steal_window, 2, 2, 0,
320 doc: /* Tell existing embed xwidget to steal other window id. This is based on a deprecated method in GTK and doesnt work too well.*/
321 )
322 (Lisp_Object xwidget_id, Lisp_Object window_id)
323{
324 int iwindow_id;
325 struct xwidget* xw = xid2xw(xwidget_id);
326
327 CHECK_NUMBER (window_id);
328 iwindow_id = XFASTINT (window_id);
329
330 // gtk_socket_steal(GTK_SOCKET(xw->widget),iwindow_id);
331 //try adding proper gtk plugs instead, i never once had "steal" work
332 ///////// gtk_socket_add_id (GTK_SOCKET (xw->widget), iwindow_id); /////TODO MVC
333 //add_id annoyingly odesnt work either. the only working option
334 //seems to be clients that plug into the sockets, and so far only emacs and mplayer
335 //oenvrml
336 return Qnil;
337}
338
339
340
341DEFUN("xwidget-info", Fxwidget_info , Sxwidget_info, 1,1,0, doc: /* get xwidget props */)
342 (Lisp_Object xwidget_id)
343{
344 struct xwidget *xw = xid2xw(xwidget_id);
345 Lisp_Object info;
346
347 info = Fmake_vector (make_number (4), Qnil);
348 XVECTOR (info)->contents[0] = make_number(xw->id);
349 XVECTOR (info)->contents[1] = xw->type;
350 XVECTOR (info)->contents[2] = make_number(xw->width);
351 XVECTOR (info)->contents[3] = make_number(xw->height);
352
353
354 return info;
355}
356
357
358
359//xterm.c listens to xwidget_owns_kbd and tries to not eat events when its set
360int xwidget_owns_kbd = 0;
361DEFUN ("xwidget-set-keyboard-grab", Fxwidget_set_keyboard_grab, Sxwidget_set_keyboard_grab, 2, 2, 0, doc: /* set unset kbd grab for xwidget. */
362 )
363 (Lisp_Object xwidget_id, Lisp_Object kbd_grab)
364{
365 struct xwidget *xw = xid2xw(xwidget_id);
366 int xid, kbd_flag;
367
368 CHECK_NUMBER (kbd_grab);
369 kbd_flag = XFASTINT (kbd_grab);
370
371
372
373 printf ("kbd grab: %d %d\n", xid, kbd_flag);
374 if (kbd_flag)
375 {
376 //int rv=gtk_widget_activate(xw->widget); //ok, but how deactivate?
377 //printf("activation:%d\n",rv);
378 // gtk_window_present(GTK_WINDOW(xw->widget));
379 //gtk_widget_grab_focus(xw->widget);
380 // gtk_socket_windowing_update_active (xw->widget,1);
381 // GDK_WINDOW_XWINDOW (GTK_WIDGET (socket)->window)
382 //FRAME_X_OUTPUT (f)->widget
383 // gdk_keyboard_grab(xw->widget,TRUE,GDK_CURRENT_TIME);
384
385 /* GtkWidget *parent = gtk_widget_get_parent (xw->widget); */
386 /* GtkWidget *lastparent; */
387 /* for (lastparent = parent; parent = gtk_widget_get_parent (parent); */
388 /* parent == NULL); */
389
390 /* gtk_container_set_focus_child (GTK_CONTAINER (lastparent), xw->widget); */
391
392 ////gtk_container_set_focus_child (GTK_CONTAINER (xw->widgetwindow), xw->widget); //TODO MVC
393
394 xwidget_owns_kbd = TRUE;
395 }
396 else
397 {
398 xwidget_owns_kbd = FALSE;
399 }
400 /*
401 gdk_keyboard_grab(xw->widget,TRUE,GDK_CURRENT_TIME);
402 else
403 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
404 */
405 return Qnil;
406}
407
408
409
410
411
412
413//lowlevel fn mostly cloned from xembed_send_message()
414void
415xwidget_key_send_message (struct frame *f,
416 Window destination_window,
417 int keycode, int keypress, int modifiers)
418{
419
420 XKeyEvent event;
421 //segfaults:
422 /* xwidget_key_send_message (f=0x0, destination_window=0, keycode=65, keypress=1, */
423 /* modifiers=0) at xwidget.c:332 */
424 /* 332 event.display = FRAME_X_DISPLAY (f); */
425
426 event.display = FRAME_X_DISPLAY (f);
427 event.window = destination_window;
428 event.root = FRAME_X_WINDOW (f);
429 event.subwindow = None;
430 event.time = CurrentTime;
431 event.x = 1;
432 event.y = 1;
433 event.x_root = 1;
434 event.y_root = 1;
435 event.same_screen = TRUE;
436
437 event.type = keypress ? KeyPress : KeyRelease;
438 event.keycode = keycode;
439 event.state = modifiers;
440
441 XSendEvent (event.display, event.window, TRUE, KeyPressMask,
442 (XEvent *) & event);
443}
444
445//using "accessible" interfaces seems expensive
446//pkg-config --cflags cspi-1.0
447//#include <at-spi-1.0/cspi/spi.h>
448
449DEFUN ("xwidget-send-keyboard-event", Fxwidget_send_keyboard_event, Sxwidget_send_keyboard_event, 2, 2, 0, doc:/* synthesize a kbd event for a xwidget. */
450 )
451 (Lisp_Object xwidget_id, Lisp_Object keydescriptor)
452{
453 int keyval;
454 char *keystring = "";
455 FRAME_PTR f;
456 struct xwidget *xw = xid2xw(xwidget_id);
457 GdkWindow *window;
458 XID xid;
459
460 /* TODO MVC
461 f = (FRAME_PTR) g_object_get_data (G_OBJECT (xw->widget), XG_FRAME_DATA);
462
463 //GdkWindow* window=gtk_widget_get_window(xw->widget); //event winds up in emacs
464
465 //TODO assert xw is a gtk_socket or THIS WILL FAIL GLORIOUSLY
466 window = gtk_socket_get_plug_window (GTK_SOCKET (xw->widget));
467 //the event gets eaten somewhere.
468 //i suspect you just cant send an event to a child window and not have emacs eat it.
469 //but if this were true the event should pop to emacs right?
470
471
472 xid = gdk_x11_drawable_get_xid (window);
473
474 printf ("xwidget-send-keyboard-event %d %d\n", window, xid);
475
476 xwidget_key_send_message (f, xid, 38, 1, 0); //38 is 'a' HACK for now
477 xwidget_key_send_message (f, xid, 38, 0, 0);
478 */
479 return Qnil;
480}
481
482
483void
484assert_valid_xwidget_id (int id, char *str)
485{
486 if (id < 0 || id > MAX_XWIDGETS)
487 {
488 printf ("broken xwidgetid:%d %s\n", id, str);
489 abort ();
490 }
491}
492
493
494struct xwidget *
495xwidget_from_id (int id)
496{
497 assert_valid_xwidget_id (id, "xwidget_from_id");
498 return &xwidgets[id];
499}