]> code.delx.au - gnu-emacs/commitdiff
Merge branch 'master' into xwidget
authorJoakim Verona <joakim@verona.se>
Sun, 25 Jan 2015 20:19:27 +0000 (21:19 +0100)
committerJoakim Verona <joakim@verona.se>
Sun, 25 Jan 2015 20:19:27 +0000 (21:19 +0100)
1  2 
configure.ac
src/buffer.c
src/emacs.c
src/keyboard.c
src/lisp.h
src/print.c
src/window.c
src/xdisp.c

diff --combined configure.ac
index 0c2555792c96ad13675d379dfaf918db13948e65,cd011b9720b8bb15255419e1f40fc5a248cef429..59b16bdb1ede76c83fb8334c39530ddaa64e5d55
@@@ -374,8 -374,6 +374,8 @@@ otherwise for the first of `gfile' or `
   ],
   [with_file_notification=$with_features])
  
 +OPTION_DEFAULT_OFF([xwidgets],[enable use of some gtk widgets it Emacs buffers])
 +
  ## For the times when you want to build Emacs but don't have
  ## a suitable makeinfo, and can live without the manuals.
  dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
@@@ -416,7 -414,9 +416,9 @@@ esa
  
  AC_ARG_WITH([gnustep-conf],dnl
  [AS_HELP_STRING([--with-gnustep-conf=FILENAME],
-    [name of GNUstep.conf; default $GNUSTEP_CONFIG_FILE, or /etc/GNUstep/GNUstep.conf])])
+    [name of GNUstep configuration file to use on systems where the command
+     'gnustep-config' does not work; default $GNUSTEP_CONFIG_FILE, or
+     /etc/GNUstep/GNUstep.conf])])
  test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
    GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
  test "X$GNUSTEP_CONFIG_FILE" = "X" && \
@@@ -1754,6 -1754,7 +1756,7 @@@ els
  fi
  
  HAVE_NS=no
+ NS_GNUSTEP_CONFIG=no
  NS_IMPL_COCOA=no
  NS_IMPL_GNUSTEP=no
  tmp_CPPFLAGS="$CPPFLAGS"
@@@ -1770,13 -1771,13 +1773,13 @@@ if test "${with_ns}" != no; the
       ns_appresdir=${ns_appdir}/Contents/Resources
       ns_appsrc=Cocoa/Emacs.base
       ns_fontfile=macfont.o
+   elif flags=$( (gnustep-config --objc-flags) 2>/dev/null); then
+      NS_IMPL_GNUSTEP=yes
+      NS_GNUSTEP_CONFIG=yes
+      GNU_OBJC_CFLAGS=$flags
+      LIBS_GNUSTEP=$(gnustep-config --gui-libs) || exit
    elif test -f $GNUSTEP_CONFIG_FILE; then
       NS_IMPL_GNUSTEP=yes
-      ns_appdir=`pwd`/nextstep/Emacs.app
-      ns_appbindir=${ns_appdir}
-      ns_appresdir=${ns_appdir}/Resources
-      ns_appsrc=GNUstep/Emacs.base
-      ns_fontfile=nsfont.o
       dnl FIXME sourcing this several times in subshells seems inefficient.
       GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
       GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
@@@ -1809,8 -1810,16 +1812,16 @@@ fail
         GNU_OBJC_CFLAGS="-fobjc-exceptions"
       fi
    fi
+   if test $NS_IMPL_GNUSTEP = yes; then
+      ns_appdir=`pwd`/nextstep/Emacs.app
+      ns_appbindir=${ns_appdir}
+      ns_appresdir=${ns_appdir}/Resources
+      ns_appsrc=GNUstep/Emacs.base
+      ns_fontfile=nsfont.o
+   fi
  
    dnl This is only used while we test the NS headers, it gets reset below.
+   CPPFLAGS="$CPPFLAGS $GNU_OBJC_CFLAGS"
    CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
  
    AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
@@@ -2515,41 -2524,6 +2526,41 @@@ if test "${HAVE_GTK}" = "yes"; the
   term_header=gtkutil.h
  fi
  
 +
 +HAVE_XWIDGETS=no
 +HAVE_WEBKIT=no
 +HAVE_GIR=no
 +
 +if test "${with_xwidgets}" != "no" && test "${USE_GTK_TOOLKIT}" = "GTK3"  && test "$window_system" != "none" ; then
 +   echo "xwidgets enabled, checking webkit, and others"
 +   HAVE_XWIDGETS=yes
 +   AC_DEFINE(HAVE_XWIDGETS, 1, [Define to 1 if you have xwidgets support.])
 +dnl xwidgets
 +dnl - enable only if GTK3 is enabled, and we have a window system
 +dnl - check for webkit and gobject introspection
 +
 +
 +#webkit version for gtk3.
 +  WEBKIT_REQUIRED=1.4.0
 +  WEBKIT_MODULES="webkitgtk-3.0 >= $WEBKIT_REQUIRED"
 +
 +  if test "${with_gtk3}" = "yes"; then
 +    PKG_CHECK_MODULES(WEBKIT, $WEBKIT_MODULES, HAVE_WEBKIT=yes, HAVE_WEBKIT=no)
 +    if test $HAVE_WEBKIT = yes; then
 +        AC_DEFINE(HAVE_WEBKIT_OSR, 1, [Define to 1 if you have webkit_osr support.])
 +    fi
 +  fi
 +
 +  GIR_REQUIRED=1.32.1
 +  GIR_MODULES="gobject-introspection-1.0 >= $GIR_REQUIRED"
 +  PKG_CHECK_MODULES(GIR, $GIR_MODULES, HAVE_GIR=yes, HAVE_GIR=no)
 +  if test $HAVE_GIR = yes; then
 +     AC_DEFINE(HAVE_GIR, 1, [Define to 1 if you have GIR support.])
 +  fi
 +
 +
 +fi
 +
  CFLAGS=$OLD_CFLAGS
  LIBS=$OLD_LIBS
  
@@@ -3412,11 -3386,13 +3423,13 @@@ if test "${HAVE_NS}" = "yes"; the
    fi
    if test "${NS_IMPL_GNUSTEP}" = "yes"; then
      AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
-     # See also .m.o rule in Makefile.in */
-     # FIXME: are all these flags really needed?  Document here why.  */
-     GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
-     ## Extra CFLAGS applied to src/*.m files.
-     GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE"
+     if test $NS_GNUSTEP_CONFIG != yes; then
+       # See also .m.o rule in src/Makefile.in.  */
+       # FIXME: are all these flags really needed?  Document here why.  */
+       GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
+       ## Extra CFLAGS applied to src/*.m files.
+       GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE"
+     fi
    fi
    OTHER_FILES=ns-app
  fi
@@@ -4827,7 -4803,7 +4840,7 @@@ TOOLKIT_LIBW
  case "$USE_X_TOOLKIT" in
    MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
    LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
 -  none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
 +  none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS -lXcomposite" ;;
  esac
  AC_SUBST(TOOLKIT_LIBW)
  
@@@ -5148,10 -5124,6 +5161,10 @@@ echo "  Does Emacs use -lxft
  echo "  Does Emacs directly use zlib?                           ${HAVE_ZLIB}"
  
  echo "  Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}"
 +
 +echo "  Does Emacs support Xwidgets?                            ${HAVE_XWIDGETS}"
 +echo "       Does xwidgets support webkit(requires gtk3)?       ${HAVE_WEBKIT}"
 +echo "       Does xwidgets support gobject introspection?       ${HAVE_GIR}"
  echo
  
  if test -n "${EMACSDATA}"; then
diff --combined src/buffer.c
index 6bff57fe12e1283b5649db21e4390af60936c6e8,67eda3ee89ee1bd4bf7ad52d0bf6b616010e55e3..223683db6f32c60f6d3bacf7b29562696dffec96
@@@ -42,9 -42,6 +42,9 @@@ along with GNU Emacs.  If not, see <htt
  #include "keymap.h"
  #include "frame.h"
  
 +#ifdef HAVE_XWIDGETS
 +#include "xwidget.h"
 +#endif  /* HAVE_XWIDGETS */
  #ifdef WINDOWSNT
  #include "w32heap.h"          /* for mmap_* */
  #endif
@@@ -390,7 -387,6 +390,6 @@@ followed by the rest of the buffers.  *
    if (FRAMEP (frame))
      {
        Lisp_Object framelist, prevlist, tail;
-       Lisp_Object args[3];
  
        framelist = Fcopy_sequence (XFRAME (frame)->buffer_list);
        prevlist = Fnreverse (Fcopy_sequence
          tail = XCDR (tail);
        }
  
-       args[0] = framelist;
-       args[1] = general;
-       args[2] = prevlist;
-       return Fnconc (3, args);
+       return CALLN (Fnconc, framelist, general, prevlist);
      }
    else
      return general;
@@@ -1657,15 -1650,14 +1653,14 @@@ cleaning up all windows currently displ
    /* Run hooks with the buffer to be killed the current buffer.  */
    {
      ptrdiff_t count = SPECPDL_INDEX ();
-     Lisp_Object arglist[1];
  
      record_unwind_protect (save_excursion_restore, save_excursion_save ());
      set_buffer_internal (b);
  
      /* First run the query functions; if any query is answered no,
         don't kill the buffer.  */
-     arglist[0] = Qkill_buffer_query_functions;
-     tem = Frun_hook_with_args_until_failure (1, arglist);
+     tem = CALLN (Frun_hook_with_args_until_failure,
+                Qkill_buffer_query_functions);
      if (NILP (tem))
        return unbind_to (count, Qnil);
  
    kill_buffer_processes (buffer);
    UNGCPRO;
  
 +#ifdef HAVE_XWIDGETS
 +  GCPRO1 (buffer);
 +  kill_buffer_xwidgets (buffer);
 +  UNGCPRO;
 +#endif  /* HAVE_XWIDGETS */
    /* Killing buffer processes may run sentinels which may have killed
       our buffer.  */
    if (!BUFFER_LIVE_P (b))
diff --combined src/emacs.c
index d83311ac5b6b32849065973b34862819a5565c34,345fe3e75b82a40f59f8f966f1e9e32b40a66cee..03dea46fe2dacb70d61af99f902abaaae438f075
@@@ -59,20 -59,12 +59,15 @@@ along with GNU Emacs.  If not, see <htt
  #include TERM_HEADER
  #endif /* HAVE_WINDOW_SYSTEM */
  
- #ifdef NS_IMPL_GNUSTEP
- /* At least under Debian, GSConfig is in a subdirectory.  --Stef  */
- #include <GNUstepBase/GSConfig.h>
- #endif
  #include "commands.h"
  #include "intervals.h"
  #include "character.h"
  #include "buffer.h"
  #include "window.h"
  
 +#ifdef HAVE_XWIDGETS
 +#include "xwidget.h"
 +#endif
  #include "systty.h"
  #include "atimer.h"
  #include "blockinput.h"
@@@ -1442,9 -1434,6 +1437,9 @@@ Using an Emacs configured with --with-x
        syms_of_xfns ();
        syms_of_xmenu ();
        syms_of_fontset ();
 +#ifdef HAVE_XWIDGETS
 +      syms_of_xwidget();
 +#endif
        syms_of_xsettings ();
  #ifdef HAVE_X_SM
        syms_of_xsmfns ();
diff --combined src/keyboard.c
index e9ecd8cbd3df9d7cf5ebb86d59d93f1b92043769,383c109c4466abda02a8277b459e2973d0f554ee..a5e1363326cd30e128f0b57105a79b97816cdef8
@@@ -1844,7 -1844,7 +1844,7 @@@ safe_run_hooks_error (Lisp_Object error
    AUTO_STRING (format, "Error in %s (%S): %S");
    Lisp_Object hook = args[0];
    Lisp_Object fun = args[1];
-   Fmessage (4, (Lisp_Object []) {format, hook, fun, error});
+   CALLN (Fmessage, format, hook, fun, error);
  
    if (SYMBOLP (hook))
      {
  static Lisp_Object
  safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args)
  {
-   Lisp_Object iargs[2];
    eassert (nargs == 2);
-   /* Yes, run_hook_with_args works this way.  */
-   iargs[0] = args[1];
-   iargs[1] = args[0];
-   internal_condition_case_n (safe_run_hooks_1, 2, iargs,
+   /* Yes, run_hook_with_args works with args in the other order.  */
+   internal_condition_case_n (safe_run_hooks_1,
+                            2, ((Lisp_Object []) {args[1], args[0]}),
                             Qt, safe_run_hooks_error);
    return Qnil;
  }
  void
  safe_run_hooks (Lisp_Object hook)
  {
-   Lisp_Object args[2];
    struct gcpro gcpro1;
    ptrdiff_t count = SPECPDL_INDEX ();
  
-   args[0] = hook;
-   args[1] = hook;
    GCPRO1 (hook);
    specbind (Qinhibit_quit, Qt);
-   run_hook_with_args (2, args, safe_run_hook_funcall);
+   run_hook_with_args (2, ((Lisp_Object []) {hook, hook}), safe_run_hook_funcall);
    unbind_to (count, Qnil);
    UNGCPRO;
  }
@@@ -4117,20 -4110,6 +4110,20 @@@ kbd_buffer_get_event (KBOARD **kbp
          obj = make_lispy_event (event);
          kbd_fetch_ptr = event + 1;
        }
 +#endif
 +#ifdef HAVE_XWIDGETS
 +      else if (event->kind == XWIDGET_EVENT)
 +      {
 +        obj = make_lispy_event (event);
 +        kbd_fetch_ptr = event + 1;
 +      }
 +#endif
 +#ifdef HAVE_INOTIFY
 +      else if (event->kind == FILE_NOTIFY_EVENT)
 +        {
 +          obj = make_lispy_event (event);
 +          kbd_fetch_ptr = event + 1;
 +        }
  #endif
        else if (event->kind == CONFIG_CHANGED_EVENT)
        {
@@@ -6078,14 -6057,6 +6071,14 @@@ make_lispy_event (struct input_event *e
        }
  #endif /* HAVE_DBUS */
  
 +#ifdef HAVE_XWIDGETS
 +    case XWIDGET_EVENT:
 +      {
 +        return  Fcons (Qxwidget_event,event->arg);
 +      }
 +#endif /* HAVE_XWIDGETS */
 +
 +
  #if defined HAVE_GFILENOTIFY || defined HAVE_INOTIFY
      case FILE_NOTIFY_EVENT:
        {
@@@ -10756,25 -10727,25 +10749,25 @@@ The elements of this list correspond t
  `set-input-mode'.  */)
    (void)
  {
-   Lisp_Object val[4];
    struct frame *sf = XFRAME (selected_frame);
  
-   val[0] = interrupt_input ? Qt : Qnil;
+   Lisp_Object interrupt = interrupt_input ? Qt : Qnil;
+   Lisp_Object flow, meta;
    if (FRAME_TERMCAP_P (sf) || FRAME_MSDOS_P (sf))
      {
-       val[1] = FRAME_TTY (sf)->flow_control ? Qt : Qnil;
-       val[2] = (FRAME_TTY (sf)->meta_key == 2
-                 ? make_number (0)
-                 : (CURTTY ()->meta_key == 1 ? Qt : Qnil));
+       flow = FRAME_TTY (sf)->flow_control ? Qt : Qnil;
+       meta = (FRAME_TTY (sf)->meta_key == 2
+             ? make_number (0)
+             : (CURTTY ()->meta_key == 1 ? Qt : Qnil));
      }
    else
      {
-       val[1] = Qnil;
-       val[2] = Qt;
+       flow = Qnil;
+       meta = Qt;
      }
-   XSETFASTINT (val[3], quit_char);
+   Lisp_Object quit = make_number (quit_char);
  
-   return Flist (ARRAYELTS (val), val);
+   return list4 (interrupt, flow, meta, quit);
  }
  
  DEFUN ("posn-at-x-y", Fposn_at_x_y, Sposn_at_x_y, 2, 4, 0,
@@@ -11103,9 -11074,6 +11096,9 @@@ syms_of_keyboard (void
    DEFSYM (Qdbus_event, "dbus-event");
  #endif
  
 +#ifdef HAVE_XWIDGETS
 +  DEFSYM (Qxwidget_event,"xwidget-event");
 +#endif /* HAVE_XWIDGETS */
  #ifdef USE_FILE_NOTIFY
    DEFSYM (Qfile_notify, "file-notify");
  #endif /* USE_FILE_NOTIFY */
diff --combined src/lisp.h
index 76a9ed8f1593fe20f72191c6e7bf3503acb41320,f5242ab84a1bcbf03204137897e958b0a0707e70..87bc3efd1980130b560ed65f26bb7f3e83ef050e
@@@ -781,11 -781,6 +781,11 @@@ enum pvec_typ
    PVEC_WINDOW_CONFIGURATION,
    PVEC_SUBR,
    PVEC_OTHER,
 +#ifdef HAVE_XWIDGETS
 +  PVEC_XWIDGET,
 +  PVEC_XWIDGET_VIEW,
 +#endif
 +
    /* These should be last, check internal_equal to see why.  */
    PVEC_COMPILED,
    PVEC_CHAR_TABLE,
@@@ -2803,6 -2798,15 +2803,15 @@@ enum maxarg
      UNEVALLED = -1
    };
  
+ /* Call a function F that accepts many args, passing it ARRAY's elements.  */
+ #define CALLMANY(f, array) (f) (ARRAYELTS (array), array)
+ /* Call a function F that accepts many args, passing it the remaining args,
+    E.g., 'return CALLN (Fformat, fmt, text);' is less error-prone than
+    '{ Lisp_Object a[2]; a[0] = fmt; a[1] = text; return Fformat (2, a); }'.
+    CALLN is overkill for simple usages like 'Finsert (1, &text);'.  */
+ #define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
  extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *);
  extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *);
  extern void defvar_bool (struct Lisp_Boolfwd *, const char *, bool *);
diff --combined src/print.c
index 688327dfe1c501715d3e548ce6fca2e7b89a7e0d,1a0aebbeba7f05a74656cdbfd6829245acf50e74..75288bc6a3a3aa28437d002d4f1be1d514491d50
@@@ -37,10 -37,6 +37,10 @@@ along with GNU Emacs.  If not, see <htt
  #include "termhooks.h"                /* For struct terminal.  */
  #include "font.h"
  
 +#ifdef HAVE_XWIDGETS
 +#include "xwidget.h"
 +#endif
 +
  #include <float.h>
  #include <ftoastr.h>
  
@@@ -1175,12 -1171,7 +1175,7 @@@ print_preprocess (Lisp_Object obj
    if (PRINT_CIRCLE_CANDIDATE_P (obj))
      {
        if (!HASH_TABLE_P (Vprint_number_table))
-       {
-         Lisp_Object args[2];
-         args[0] = QCtest;
-         args[1] = Qeq;
-         Vprint_number_table = Fmake_hash_table (2, args);
-       }
+       Vprint_number_table = CALLN (Fmake_hash_table, QCtest, Qeq);
  
        /* In case print-circle is nil and print-gensym is t,
         add OBJ to Vprint_number_table only when OBJ is a symbol.  */
@@@ -1781,18 -1772,6 +1776,18 @@@ print_object (Lisp_Object obj, Lisp_Obj
          strout (XSUBR (obj)->symbol_name, -1, -1, printcharfun);
          PRINTCHAR ('>');
        }
 +#ifdef HAVE_XWIDGETS
 +      else if (XWIDGETP (obj))
 +      {
 +        strout ("#<xwidget ", -1, -1, printcharfun);
 +        PRINTCHAR ('>');
 +      }
 +      else if (XWIDGET_VIEW_P (obj))
 +      {
 +        strout ("#<xwidget-view ", -1, -1, printcharfun);
 +        PRINTCHAR ('>');
 +      }
 +#endif
        else if (WINDOWP (obj))
        {
          int len;
diff --combined src/window.c
index d14a0f74fa01d24f973599851c6a24853af60974,2f44bf78304b5da98cf7f0dad1bf2021ea425ce9..b4230100150af067984f30f1ffcfdd7c467742b7
@@@ -44,9 -44,6 +44,9 @@@ along with GNU Emacs.  If not, see <htt
  #ifdef MSDOS
  #include "msdos.h"
  #endif
 +#ifdef HAVE_XWIDGETS
 +#include "xwidget.h"
 +#endif
  
  static int displayed_window_lines (struct window *);
  static int count_windows (struct window *);
@@@ -2429,16 -2426,14 +2429,14 @@@ window_list (void
        Vwindow_list = Qnil;
        FOR_EACH_FRAME (tail, frame)
        {
-         Lisp_Object args[2];
+         Lisp_Object arglist = Qnil;
  
          /* We are visiting windows in canonical order, and add
             new windows at the front of args[1], which means we
             have to reverse this list at the end.  */
-         args[1] = Qnil;
-         foreach_window (XFRAME (frame), add_window_to_list, &args[1]);
-         args[0] = Vwindow_list;
-         args[1] = Fnreverse (args[1]);
-         Vwindow_list = Fnconc (2, args);
+         foreach_window (XFRAME (frame), add_window_to_list, &arglist);
+         arglist = Fnreverse (arglist);
+         Vwindow_list = CALLN (Fnconc, Vwindow_list, arglist);
        }
      }
  
@@@ -4564,9 -4559,6 +4562,9 @@@ Signal an error when WINDOW is the onl
  
        /* Block input.  */
        block_input ();
 +#ifdef HAVE_XWIDGETS
 +      xwidget_view_delete_all_in_window(w);
 +#endif
        window_resize_apply (p, horflag);
        /* If this window is referred to by the dpyinfo's mouse
         highlight, invalidate that slot to be safe (Bug#9904).  */
diff --combined src/xdisp.c
index aec6741dbfcb89fa43ea48cdfeb783fe09688386,d974687a431b63cff368ea0d8f9eb1b8310dde8e..0ced00f9525977d92b1f994e07146688c0de02b4
@@@ -318,9 -318,6 +318,9 @@@ along with GNU Emacs.  If not, see <htt
  #include TERM_HEADER
  #endif /* HAVE_WINDOW_SYSTEM */
  
 +#ifdef HAVE_XWIDGETS
 +#include "xwidget.h"
 +#endif
  #ifndef FRAME_X_OUTPUT
  #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
  #endif
@@@ -845,9 -842,6 +845,9 @@@ static int next_element_from_c_string (
  static int next_element_from_buffer (struct it *);
  static int next_element_from_composition (struct it *);
  static int next_element_from_image (struct it *);
 +#ifdef HAVE_XWIDGETS
 +static int next_element_from_xwidget(struct it *);
 +#endif
  static int next_element_from_stretch (struct it *);
  static void load_overlay_strings (struct it *, ptrdiff_t);
  static int init_from_display_pos (struct it *, struct window *,
@@@ -4684,9 -4678,6 +4684,9 @@@ handle_display_spec (struct it *it, Lis
    if (CONSP (spec)
        /* Simple specifications.  */
        && !EQ (XCAR (spec), Qimage)
 +#ifdef HAVE_XWIDGETS
 +      && !EQ (XCAR (spec), Qxwidget)
 +#endif
        && !EQ (XCAR (spec), Qspace)
        && !EQ (XCAR (spec), Qwhen)
        && !EQ (XCAR (spec), Qslice)
@@@ -5133,11 -5124,7 +5133,11 @@@ handle_single_display_spec (struct it *
               || ((it ? FRAME_WINDOW_P (it->f) : frame_window_p)
                 && valid_image_p (value))
  #endif /* not HAVE_WINDOW_SYSTEM */
 -             || (CONSP (value) && EQ (XCAR (value), Qspace)));
 +             || (CONSP (value) && EQ (XCAR (value), Qspace))
 +#ifdef HAVE_XWIDGETS
 +             || valid_xwidget_spec_p(value)
 +#endif
 +             );
  
    if (valid_p && !display_replaced_p)
      {
          *position = it->position = start_pos;
          retval = 1 + (it->area == TEXT_AREA);
        }
 +#ifdef HAVE_XWIDGETS
 +      else if (valid_xwidget_spec_p(value))
 +      {
 +          it->what = IT_XWIDGET;
 +          it->method = GET_FROM_XWIDGET;
 +          it->position = start_pos;
 +        it->object = NILP (object) ? it->w->contents : object;
 +        *position = start_pos;
 +
 +          it->xwidget = lookup_xwidget(value);
 +      }
 +#endif
  #ifdef HAVE_WINDOW_SYSTEM
        else
        {
@@@ -5960,11 -5935,6 +5960,11 @@@ push_it (struct it *it, struct text_po
      case GET_FROM_STRETCH:
        p->u.stretch.object = it->object;
        break;
 +#ifdef HAVE_XWIDGETS
 +    case GET_FROM_XWIDGET:
 +      p->u.xwidget.object = it->object;
 +      break;
 +#endif
      }
    p->position = position ? *position : it->position;
    p->current = it->current;
@@@ -6058,11 -6028,6 +6058,11 @@@ pop_it (struct it *it
        it->object = p->u.image.object;
        it->slice = p->u.image.slice;
        break;
 +#ifdef HAVE_XWIDGETS
 +    case GET_FROM_XWIDGET:
 +      it->object = p->u.xwidget.object;
 +      break;
 +#endif
      case GET_FROM_STRETCH:
        it->object = p->u.stretch.object;
        break;
@@@ -6725,9 -6690,6 +6725,9 @@@ static int (* get_next_element[NUM_IT_M
    next_element_from_c_string,
    next_element_from_image,
    next_element_from_stretch
 +#ifdef HAVE_XWIDGETS
 +  ,next_element_from_xwidget
 +#endif
  };
  
  #define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it)
@@@ -7573,10 -7535,6 +7573,10 @@@ set_iterator_to_next (struct it *it, in
  
      case GET_FROM_IMAGE:
      case GET_FROM_STRETCH:
 +#ifdef HAVE_XWIDGETS
 +    case GET_FROM_XWIDGET:
 +#endif
 +
        /* The position etc with which we have to proceed are on
         the stack.  The position may be at the end of a string,
           if the `display' property takes up the whole string.  */
@@@ -8039,16 -7997,6 +8039,16 @@@ next_element_from_image (struct it *it
    return 1;
  }
  
 +#ifdef HAVE_XWIDGETS
 +/* im not sure about this FIXME JAVE*/
 +static int
 +next_element_from_xwidget (struct it *it)
 +{
 +  it->what = IT_XWIDGET;
 +  return 1;
 +}
 +#endif
 +
  
  /* Fill iterator IT with next display element from a stretch glyph
     property.  IT->object is the value of the text property.  Value is
@@@ -8338,22 -8286,18 +8338,18 @@@ next_element_from_buffer (struct it *it
  static void
  run_redisplay_end_trigger_hook (struct it *it)
  {
-   Lisp_Object args[3];
    /* IT->glyph_row should be non-null, i.e. we should be actually
       displaying something, or otherwise we should not run the hook.  */
    eassert (it->glyph_row);
  
-   /* Set up hook arguments.  */
-   args[0] = Qredisplay_end_trigger_functions;
-   args[1] = it->window;
-   XSETINT (args[2], it->redisplay_end_trigger_charpos);
+   ptrdiff_t charpos = it->redisplay_end_trigger_charpos;
    it->redisplay_end_trigger_charpos = 0;
  
    /* Since we are *trying* to run these functions, don't try to run
       them again, even if they get an error.  */
    wset_redisplay_end_trigger (it->w, Qnil);
-   Frun_hook_with_args (3, args);
+   CALLN (Frun_hook_with_args, Qredisplay_end_trigger_functions, it->window,
+        make_number (charpos));
  
    /* Notice if it changed the face of the character we are on.  */
    handle_face_prop (it);
@@@ -9852,7 -9796,6 +9848,6 @@@ include the height of both, if present
  void
  add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2)
  {
-   Lisp_Object args[3];
    Lisp_Object msg, fmt;
    char *buffer;
    ptrdiff_t len;
    fmt = msg = Qnil;
    GCPRO4 (fmt, msg, arg1, arg2);
  
-   args[0] = fmt = build_string (format);
-   args[1] = arg1;
-   args[2] = arg2;
-   msg = Fformat (3, args);
+   fmt = build_string (format);
+   msg = CALLN (Fformat, fmt, arg1, arg2);
  
    len = SBYTES (msg) + 1;
    buffer = SAFE_ALLOCA (len);
@@@ -10280,15 -10221,13 +10273,13 @@@ message_with_string (const char *m, Lis
         initialized yet, just toss it.  */
        if (f->glyphs_initialized_p)
        {
-         Lisp_Object args[2], msg;
          struct gcpro gcpro1, gcpro2;
  
-         args[0] = build_string (m);
-         args[1] = msg = string;
-         GCPRO2 (args[0], msg);
-         gcpro1.nvars = 2;
+         Lisp_Object fmt = build_string (m);
+         Lisp_Object msg = string;
+         GCPRO2 (fmt, msg);
  
-         msg = Fformat (2, args);
+         msg = CALLN (Fformat, fmt, msg);
  
          if (log)
            message3 (msg);
@@@ -17062,13 -17001,6 +17053,13 @@@ try_window_reusing_current_matrix (stru
      return 0;
  #endif
  
 +#ifdef HAVE_XWIDGETS_xxx
 + //currently this is needed to detect xwidget movement reliably. or probably not.
 +  printf("try_window_reusing_current_matrix\n");
 +    return 0;
 +#endif
 +
 +
    if (/* This function doesn't handle terminal frames.  */
        !FRAME_WINDOW_P (f)
        /* Don't try to reuse the display if windows have been split
@@@ -18648,28 -18580,6 +18639,28 @@@ dump_glyph (struct glyph_row *row, stru
               glyph->left_box_line_p,
               glyph->right_box_line_p);
      }
 +#ifdef HAVE_XWIDGETS
 +  else if (glyph->type == XWIDGET_GLYPH)
 +    {
 +      fprintf (stderr,
 +             "  %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
 +             glyph - row->glyphs[TEXT_AREA],
 +             'X',
 +             glyph->charpos,
 +             (BUFFERP (glyph->object)
 +              ? 'B'
 +              : (STRINGP (glyph->object)
 +                 ? 'S'
 +                 : '-')),
 +             glyph->pixel_width,
 +             glyph->u.xwidget,
 +             '.',
 +             glyph->face_id,
 +             glyph->left_box_line_p,
 +             glyph->right_box_line_p);
 +
 +    }
 +#endif
  }
  
  
@@@ -24087,13 -23997,6 +24078,13 @@@ calc_pixel_width_or_height (double *res
  
              return OK_PIXELS (width_p ? img->width : img->height);
            }
 +#ifdef HAVE_XWIDGETS
 +        if (FRAME_WINDOW_P (it->f) && valid_xwidget_spec_p (prop))
 +          {
 +              //TODO dont return dummy size
 +              return OK_PIXELS (width_p ? 100 : 100);
 +            }
 +#endif
  #endif
          if (EQ (car, Qplus) || EQ (car, Qminus))
            {
@@@ -24598,18 -24501,6 +24589,18 @@@ fill_image_glyph_string (struct glyph_s
  }
  
  
 +#ifdef HAVE_XWIDGETS
 +static void
 +fill_xwidget_glyph_string (struct glyph_string *s)
 +{
 +  eassert (s->first_glyph->type == XWIDGET_GLYPH);
 +  s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
 +  s->font = s->face->font;
 +  s->width = s->first_glyph->pixel_width;
 +  s->ybase += s->first_glyph->voffset;
 +  s->xwidget = s->first_glyph->u.xwidget;
 +}
 +#endif
  /* Fill glyph string S from a sequence of stretch glyphs.
  
     START is the index of the first glyph to consider,
@@@ -24945,20 -24836,6 +24936,20 @@@ compute_overhangs_and_x (struct glyph_s
         }                                                              \
       while (0)
  
 +#ifdef HAVE_XWIDGETS
 +#define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
 +     do                                                                       \
 +       { \
 +       s = (struct glyph_string *) alloca (sizeof *s);                \
 +       INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL);          \
 +       fill_xwidget_glyph_string (s);                                 \
 +       append_glyph_string (&HEAD, &TAIL, s);                         \
 +       ++START;                                                       \
 +         s->x = (X);                                                  \
 +       }                                                              \
 +     while (0)
 +#endif
 +
  
  /* Add a glyph string for a sequence of character glyphs to the list
     of strings between HEAD and TAIL.  START is the index of the first
     to allocate glyph strings (because draw_glyphs can be called
     asynchronously).  */
  
 -#define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X)    \
 +#define BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X)  \
    do                                                                  \
      {                                                                 \
        HEAD = TAIL = NULL;                                             \
            case IMAGE_GLYPH:                                           \
              BUILD_IMAGE_GLYPH_STRING (START, END, HEAD, TAIL,         \
                                        HL, X, LAST_X);                 \
 -            break;                                                    \
 -                                                                      \
 +            break;
 +
 +#define BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
 +            case XWIDGET_GLYPH:                                         \
 +              BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL,       \
 +                                          HL, X, LAST_X);               \
 +              break;
 +
 +#define BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)  \
            case GLYPHLESS_GLYPH:                                       \
              BUILD_GLYPHLESS_GLYPH_STRING (START, END, HEAD, TAIL,     \
                                            HL, X, LAST_X);             \
      } while (0)
  
  
 +#ifdef HAVE_XWIDGETS
 +#define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X)    \
 +BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X)  \
 +BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
 +BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
 +#else
 +#define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X)    \
 +BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X)  \
 +BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
 +#endif
 +
 +
  /* Draw glyphs between START and END in AREA of ROW on window W,
     starting at x-position X.  X is relative to AREA in W.  HL is a
     face-override with the following meaning:
@@@ -25779,113 -25637,6 +25770,113 @@@ produce_image_glyph (struct it *it
      }
  }
  
 +#ifdef HAVE_XWIDGETS
 +static void
 +produce_xwidget_glyph (struct it *it)
 +{
 +  struct xwidget* xw;
 +  struct face *face;
 +  int glyph_ascent, crop;
 +  eassert (it->what == IT_XWIDGET);
 +
 +  face = FACE_FROM_ID (it->f, it->face_id);
 +  eassert (face);
 +  /* Make sure X resources of the face is loaded.  */
 +  prepare_face_for_display (it->f, face);
 +
 +  xw = it->xwidget;
 +  it->ascent = it->phys_ascent = glyph_ascent = xw->height/2;
 +  it->descent = xw->height/2;
 +  it->phys_descent = it->descent;
 +  it->pixel_width = xw->width;
 +  /* It's quite possible for images to have an ascent greater than
 +     their height, so don't get confused in that case.  */
 +  if (it->descent < 0)
 +    it->descent = 0;
 +
 +  it->nglyphs = 1;
 +
 +  if (face->box != FACE_NO_BOX)
 +    {
 +      if (face->box_line_width > 0)
 +      {
 +          it->ascent += face->box_line_width;
 +          it->descent += face->box_line_width;
 +      }
 +
 +      if (it->start_of_box_run_p)
 +      it->pixel_width += eabs (face->box_line_width);
 +      it->pixel_width += eabs (face->box_line_width);
 +    }
 +
 +  take_vertical_position_into_account (it);
 +
 +  /* Automatically crop wide image glyphs at right edge so we can
 +     draw the cursor on same display row.  */
 +  if ((crop = it->pixel_width - (it->last_visible_x - it->current_x), crop > 0)
 +      && (it->hpos == 0 || it->pixel_width > it->last_visible_x / 4))
 +    {
 +      it->pixel_width -= crop;
 +    }
 +
 +  if (it->glyph_row)
 +    {
 +      struct glyph *glyph;
 +      enum glyph_row_area area = it->area;
 +
 +      glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
 +      if (it->glyph_row->reversed_p)
 +      {
 +        struct glyph *g;
 +
 +        /* Make room for the new glyph.  */
 +        for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--)
 +          g[1] = *g;
 +        glyph = it->glyph_row->glyphs[it->area];
 +      }
 +      if (glyph < it->glyph_row->glyphs[area + 1])
 +      {
 +        glyph->charpos = CHARPOS (it->position);
 +        glyph->object = it->object;
 +        glyph->pixel_width = it->pixel_width;
 +        glyph->ascent = glyph_ascent;
 +        glyph->descent = it->descent;
 +        glyph->voffset = it->voffset;
 +        glyph->type = XWIDGET_GLYPH;
 +        glyph->avoid_cursor_p = it->avoid_cursor_p;
 +        glyph->multibyte_p = it->multibyte_p;
 +        if (it->glyph_row->reversed_p && area == TEXT_AREA)
 +          {
 +            /* In R2L rows, the left and the right box edges need to be
 +               drawn in reverse direction.  */
 +            glyph->right_box_line_p = it->start_of_box_run_p;
 +            glyph->left_box_line_p = it->end_of_box_run_p;
 +          }
 +        else
 +          {
 +            glyph->left_box_line_p = it->start_of_box_run_p;
 +            glyph->right_box_line_p = it->end_of_box_run_p;
 +          }
 +          glyph->overlaps_vertically_p = 0;
 +          glyph->padding_p = 0;
 +        glyph->glyph_not_available_p = 0;
 +        glyph->face_id = it->face_id;
 +          glyph->u.xwidget = it->xwidget;
 +          //assert_valid_xwidget_id(glyph->u.xwidget_id,"produce_xwidget_glyph");
 +        glyph->font_type = FONT_TYPE_UNKNOWN;
 +        if (it->bidi_p)
 +          {
 +            glyph->resolved_level = it->bidi_it.resolved_level;
 +            eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
 +            glyph->bidi_type = it->bidi_it.type;
 +          }
 +        ++it->glyph_row->used[area];
 +      }
 +      else
 +      IT_EXPAND_MATRIX_WIDTH (it, area);
 +    }
 +}
 +#endif
  
  /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source
     of the glyph, WIDTH and HEIGHT are the width and height of the
@@@ -27226,10 -26977,6 +27217,10 @@@ x_produce_glyphs (struct it *it
      produce_image_glyph (it);
    else if (it->what == IT_STRETCH)
      produce_stretch_glyph (it);
 +#ifdef HAVE_XWIDGETS
 +  else if (it->what == IT_XWIDGET)
 +    produce_xwidget_glyph (it);
 +#endif
  
   done:
    /* Accumulate dimensions.  Note: can't assume that it->descent > 0
@@@ -27599,12 -27346,6 +27590,12 @@@ get_window_cursor_type (struct window *
    /* Use normal cursor if not blinked off.  */
    if (!w->cursor_off_p)
      {
 +
 +#ifdef HAVE_XWIDGETS
 +      if (glyph != NULL && glyph->type == XWIDGET_GLYPH){
 +        return NO_CURSOR;
 +      }
 +#endif
        if (glyph != NULL && glyph->type == IMAGE_GLYPH)
        {
          if (cursor_type == FILLED_BOX_CURSOR)