]> code.delx.au - gnu-emacs/commitdiff
Merge branch 'master' into xwidget
authorJoakim Verona <joakim@verona.se>
Sat, 31 Jan 2015 23:37:46 +0000 (00:37 +0100)
committerJoakim Verona <joakim@verona.se>
Sat, 31 Jan 2015 23:37:46 +0000 (00:37 +0100)
1  2 
configure.ac
src/Makefile.in
src/dispextern.h
src/emacs.c
src/keyboard.c
src/xdisp.c

diff --combined configure.ac
index 59b16bdb1ede76c83fb8334c39530ddaa64e5d55,5776e4ef8ed9d5352bfc4b90d000e584941116bf..f4fcf529498c896c9d8ebebc7a371cf5f692aaf0
@@@ -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
@@@ -1940,6 -1938,9 +1940,9 @@@ CM_OBJ="cm.o
  XARGS_LIMIT=
  if test "${HAVE_W32}" = "yes"; then
    AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
+   if test "$with_toolkit_scroll_bars" = "no"; then
+     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for w32 build.])
+   fi
    AC_CHECK_TOOL(WINDRES, [windres],
                  [AC_MSG_ERROR([No resource compiler found.])])
    W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
@@@ -2526,41 -2527,6 +2529,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
  
@@@ -4840,7 -4806,7 +4843,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)
  
@@@ -5161,10 -5127,6 +5164,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/Makefile.in
index 079e0e41c9f1b7c8672b1f6656044bf64abe02fb,32615c848a73ecc01157ac87aef489ad5ee9c317..81977dbfec2a5764f70f22c96b39c35015e432e2
@@@ -218,12 -218,6 +218,12 @@@ CFLAGS_SOUND= @CFLAGS_SOUND
  RSVG_LIBS= @RSVG_LIBS@
  RSVG_CFLAGS= @RSVG_CFLAGS@
  
 +WEBKIT_LIBS= @WEBKIT_LIBS@
 +WEBKIT_CFLAGS= @WEBKIT_CFLAGS@
 +
 +GIR_LIBS= @GIR_LIBS@
 +GIR_CFLAGS= @GIR_CFLAGS@
 +
  IMAGEMAGICK_LIBS= @IMAGEMAGICK_LIBS@
  IMAGEMAGICK_CFLAGS= @IMAGEMAGICK_CFLAGS@
  
@@@ -349,7 -343,6 +349,7 @@@ ALL_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I
    $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \
    $(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \
    $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) $(XFIXES_CFLAGS) \
 +  $(WEBKIT_CFLAGS) $(GIR_CFLAGS) \
    $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
    $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \
    $(LIBGNUTLS_CFLAGS) $(GFILENOTIFY_CFLAGS) \
@@@ -379,13 -372,11 +379,13 @@@ base_obj = dispnew.o frame.o scroll.o x
        process.o gnutls.o callproc.o \
        region-cache.o sound.o atimer.o \
        doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \
 +      xwidget.o \
        profiler.o decompress.o \
        $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
        $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ)
  obj = $(base_obj) $(NS_OBJC_OBJ)
  
 +xwidget.o: xwidget.c xwidget.h
  ## Object files used on some machine or other.
  ## These go in the DOC file on all machines in case they are needed.
  ## Some of them have no DOC entries, but it does no harm to have them
@@@ -430,7 -421,6 +430,7 @@@ ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OB
  LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
     $(LIBX_OTHER) $(LIBSOUND) \
     $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \
 +   $(WEBKIT_LIBS) $(GIR_LIBS) \
     $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
     $(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \
     $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
@@@ -504,11 -494,17 +504,17 @@@ buildobj.h: Makefil
  
  GLOBAL_SOURCES = $(base_obj:.o=.c) $(NS_OBJC_OBJ:.o=.m)
  
+ AM_V_GLOBALS = $(am__v_GLOBALS_@AM_V@)
+ am__v_GLOBALS_ = $(am__v_GLOBALS_@AM_DEFAULT_V@)
+ am__v_GLOBALS_0 = @echo "  GEN     " globals.h;
+ am__v_GLOBALS_1 =
  gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
-       $(AM_V_GEN)$(libsrc)/make-docfile -d $(srcdir) -g $(obj) >$@
+       $(AM_V_GLOBALS)$(libsrc)/make-docfile -d $(srcdir) -g $(obj) > globals.tmp
+       $(AM_V_at)$(top_srcdir)/build-aux/move-if-change globals.tmp globals.h
+       $(AM_V_at)echo timestamp > $@
  
- globals.h: gl-stamp
-       $(AM_V_GEN)cmp $< $@ >/dev/null || cp $< $@
+ globals.h: gl-stamp; @true
  
  $(ALLOBJS): globals.h
  
diff --combined src/dispextern.h
index 9ea64fb9f638f3eac4629a7c639d334cc95a0bd8,413947991ec689eb42c66024cea965d3bcc844bb..fbf0c74454d9e2264f360fa9a6608992f631bbba
@@@ -348,10 -348,6 +348,10 @@@ enum glyph_typ
  
    /* Glyph is a space of fractional width and/or height.  */
    STRETCH_GLYPH
 +#ifdef HAVE_XWIDGETS
 +  /* Glyph is an external widget drawn by the GUI toolkit.   */
 +  ,XWIDGET_GLYPH
 +#endif
  };
  
  
@@@ -503,9 -499,6 +503,9 @@@ struct glyp
      /* Image ID for image glyphs (type == IMAGE_GLYPH).  */
      int img_id;
  
 +#ifdef HAVE_XWIDGETS
 +    struct xwidget* xwidget;
 +#endif
      /* Sub-structure for type == STRETCH_GLYPH.  */
      struct
      {
@@@ -1360,9 -1353,6 +1360,9 @@@ struct glyph_strin
    /* Image, if any.  */
    struct image *img;
  
 +#ifdef HAVE_XWIDGETS
 +  struct xwidget* xwidget;
 +#endif
    /* Slice */
    struct glyph_slice slice;
  
@@@ -1860,10 -1850,10 +1860,10 @@@ GLYPH_CODE_P (Lisp_Object gc
               : TYPE_MAXIMUM (EMACS_INT)))));
  }
  
- /* Non-zero means face attributes have been changed since the last
+ /* True means face attributes have been changed since the last
     redisplay.  Used in redisplay_internal.  */
  
- extern int face_change_count;
+ extern bool face_change;
  
  /* For reordering of bidirectional text.  */
  
@@@ -2107,10 -2097,6 +2107,10 @@@ enum display_element_typ
  
    /* Continuation glyphs.  See the comment for IT_TRUNCATION.  */
    IT_CONTINUATION
 +
 +#ifdef HAVE_XWIDGETS
 +  ,IT_XWIDGET
 +#endif
  };
  
  
@@@ -2174,9 -2160,6 +2174,9 @@@ enum it_method 
    GET_FROM_C_STRING,
    GET_FROM_IMAGE,
    GET_FROM_STRETCH,
 +#ifdef HAVE_XWIDGETS
 +  GET_FROM_XWIDGET,
 +#endif
    NUM_IT_METHODS
  };
  
@@@ -2398,12 -2381,6 +2398,12 @@@ struct i
        struct {
        Lisp_Object object;
        } stretch;
 +#ifdef HAVE_XWIDGETS
 +      /* method == GET_FROM_XWIDGET */
 +      struct {
 +      Lisp_Object object;
 +      } xwidget;
 +#endif
      } u;
  
      /* Current text and display positions.  */
    /* If what == IT_IMAGE, the id of the image to display.  */
    ptrdiff_t image_id;
  
 +#ifdef HAVE_XWIDGETS
 +  /* If what == IT_XWIDGET*/
 +  struct xwidget* xwidget;
 +#endif
    /* Values from `slice' property.  */
    struct it_slice slice;
  
diff --combined src/emacs.c
index 03dea46fe2dacb70d61af99f902abaaae438f075,fdd17d1e062c511bf97862954cb2f70babee6a08..87b1f11d59b059079b4becf01b890fa749acf45d
@@@ -65,9 -65,6 +65,9 @@@ along with GNU Emacs.  If not, see <htt
  #include "buffer.h"
  #include "window.h"
  
 +#ifdef HAVE_XWIDGETS
 +#include "xwidget.h"
 +#endif
  #include "systty.h"
  #include "atimer.h"
  #include "blockinput.h"
@@@ -234,7 -231,7 +234,7 @@@ Initialization options:\n
      "\
  --no-desktop                do not load a saved desktop\n\
  --no-init-file, -q          load neither ~/.emacs nor default.el\n\
- --no-shared-memory, -nl     do not use shared memory\n\
+ --no-loadup, -nl            do not load loadup.el into bare Emacs\n\
  --no-site-file              do not load site-start.el\n\
  --no-site-lisp, -nsl        do not add site-lisp directories to load-path\n\
  --no-splash                 do not display a splash screen on startup\n\
@@@ -1437,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 ();
@@@ -2398,9 -2392,7 +2398,7 @@@ hpux, irix, usg-unix-v) indicates some 
    /* See configure.ac (and config.nt) for the possible SYSTEM_TYPEs.  */
  
    DEFVAR_LISP ("system-configuration", Vsystem_configuration,
-              doc: /* Value is string indicating configuration Emacs was built for.
- On MS-Windows, the value reflects the OS flavor and version on which
- Emacs is running.  */);
+              doc: /* Value is string indicating configuration Emacs was built for.  */);
    Vsystem_configuration = build_string (EMACS_CONFIGURATION);
  
    DEFVAR_LISP ("system-configuration-options", Vsystem_configuration_options,
diff --combined src/keyboard.c
index a5e1363326cd30e128f0b57105a79b97816cdef8,1176d701f2a16032481d20b0a1c50d6de37c3cd0..a9ff77d047346145dd0fb671c80c6dde8eb34db1
@@@ -2288,30 -2288,41 +2288,41 @@@ read_decoded_event_from_main_queue (str
            { /* An encoded byte sequence, let's try to decode it.  */
              struct coding_system *coding
                = TERMINAL_KEYBOARD_CODING (terminal);
-             unsigned char src[MAX_ENCODED_BYTES];
-             unsigned char dest[MAX_ENCODED_BYTES * MAX_MULTIBYTE_LENGTH];
-             int i;
-             for (i = 0; i < n; i++)
-               src[i] = XINT (events[i]);
-             if (meta_key != 2)
-               for (i = 0; i < n; i++)
-                 src[i] &= ~0x80;
-             coding->destination = dest;
-             coding->dst_bytes = sizeof dest;
-             decode_coding_c_string (coding, src, n, Qnil);
-             eassert (coding->produced_char <= n);
-             if (coding->produced_char == 0)
-               { /* The encoded sequence is incomplete.  */
-                 if (n < MAX_ENCODED_BYTES) /* Avoid buffer overflow.  */
-                   continue;                /* Read on!  */
+             if (raw_text_coding_system_p (coding))
+               {
+                 int i;
+                 if (meta_key != 2)
+                   for (i = 0; i < n; i++)
+                     events[i] = make_number (XINT (events[i]) & ~0x80);
                }
              else
                {
-                 const unsigned char *p = coding->destination;
-                 eassert (coding->carryover_bytes == 0);
-                 n = 0;
-                 while (n < coding->produced_char)
-                   events[n++] = make_number (STRING_CHAR_ADVANCE (p));
+                 unsigned char src[MAX_ENCODED_BYTES];
+                 unsigned char dest[MAX_ENCODED_BYTES * MAX_MULTIBYTE_LENGTH];
+                 int i;
+                 for (i = 0; i < n; i++)
+                   src[i] = XINT (events[i]);
+                 if (meta_key != 2)
+                   for (i = 0; i < n; i++)
+                     src[i] &= ~0x80;
+                 coding->destination = dest;
+                 coding->dst_bytes = sizeof dest;
+                 decode_coding_c_string (coding, src, n, Qnil);
+                 eassert (coding->produced_char <= n);
+                 if (coding->produced_char == 0)
+                   { /* The encoded sequence is incomplete.  */
+                     if (n < MAX_ENCODED_BYTES) /* Avoid buffer overflow.  */
+                       continue;                    /* Read on!  */
+                   }
+                 else
+                   {
+                     const unsigned char *p = coding->destination;
+                     eassert (coding->carryover_bytes == 0);
+                     n = 0;
+                     while (n < coding->produced_char)
+                       events[n++] = make_number (STRING_CHAR_ADVANCE (p));
+                   }
                }
            }
          /* Now `events' should hold decoded events.
@@@ -3639,7 -3650,9 +3650,9 @@@ kbd_buffer_store_event_hold (register s
       as input, set quit-flag to cause an interrupt.  */
    if (!NILP (Vthrow_on_input)
        && event->kind != FOCUS_IN_EVENT
+       && event->kind != FOCUS_OUT_EVENT
        && event->kind != HELP_EVENT
+       && event->kind != ICONIFY_EVENT
        && event->kind != DEICONIFY_EVENT)
      {
        Vquit_flag = Vthrow_on_input;
@@@ -4110,20 -4123,6 +4123,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)
        {
@@@ -6071,14 -6070,6 +6084,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:
        {
@@@ -11096,9 -11087,6 +11109,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/xdisp.c
index d868633e25cf1fd22610ab2392efc5a8608c9c06,68c0fa545724974aa22dafd535317d3f6cdd17e9..01d598fe2c2d2f5281b192cd8d652bacedf93cfb
@@@ -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 *,
@@@ -2730,9 -2724,9 +2730,9 @@@ init_iterator (struct it *it, struct wi
       free realized faces now because they depend on face definitions
       that might have changed.  Don't free faces while there might be
       desired matrices pending which reference these faces.  */
-   if (face_change_count && !inhibit_free_realized_faces)
+   if (face_change && !inhibit_free_realized_faces)
      {
-       face_change_count = 0;
+       face_change = false;
        free_all_realized_faces (Qnil);
      }
  
@@@ -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,12 -5124,7 +5133,12 @@@ 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
 +             || ((it ? FRAME_WINDOW_P (it->f) : frame_window_p)
 +               && 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
        {
@@@ -5961,11 -5935,6 +5961,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;
@@@ -6059,11 -6028,6 +6059,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;
@@@ -6726,9 -6690,6 +6726,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)
@@@ -7574,10 -7535,6 +7574,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.  */
@@@ -8040,16 -7997,6 +8040,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
@@@ -9316,6 -9263,7 +9316,7 @@@ move_it_to (struct it *it, ptrdiff_t to
        && it->current_x == it->last_visible_x - 1
        && it->c != '\n'
        && it->c != '\t'
+       && it->w->window_end_valid
        && it->vpos < it->w->window_end_vpos)
      {
        it->continuation_lines_width += it->current_x;
@@@ -13425,10 -13373,10 +13426,10 @@@ redisplay_internal (void
    last_glyphless_glyph_frame = NULL;
    last_glyphless_glyph_face_id = (1 << FACE_ID_BITS);
  
-   /* If face_change_count is non-zero, init_iterator will free all
-      realized faces, which includes the faces referenced from current
-      matrices.  So, we can't reuse current matrices in this case.  */
-   if (face_change_count)
+   /* If face_change, init_iterator will free all realized faces, which
+      includes the faces referenced from current matrices.  So, we
+      can't reuse current matrices in this case.  */
+   if (face_change)
      windows_or_buffers_changed = 47;
  
    if ((FRAME_TERMCAP_P (sf) || FRAME_MSDOS_P (sf))
@@@ -15436,7 -15384,8 +15437,8 @@@ try_cursor_movement (Lisp_Object window
    /* Likewise there was a check whether window_end_vpos is nil or larger
       than the window.  Now window_end_vpos is int and so never nil, but
       let's leave eassert to check whether it fits in the window.  */
-   eassert (w->window_end_vpos < w->current_matrix->nrows);
+   eassert (!w->window_end_valid
+          || w->window_end_vpos < w->current_matrix->nrows);
  
    /* Handle case where text has not changed, only point, and it has
       not moved off the frame.  */
@@@ -17054,13 -17003,6 +17056,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
@@@ -18183,6 -18125,21 +18185,21 @@@ try_window_id (struct window *w
    if (f->fonts_changed)
      return -1;
  
+   /* The redisplay iterations in display_line above could have
+      triggered font-lock, which could have done something that
+      invalidates IT->w window's end-point information, on which we
+      rely below.  E.g., one package, which will remain unnamed, used
+      to install a font-lock-fontify-region-function that called
+      bury-buffer, whose side effect is to switch the buffer displayed
+      by IT->w, and that predictably resets IT->w's window_end_valid
+      flag, which we already tested at the entry to this function.
+      Amply punish such packages/modes by giving up on this
+      optimization in those cases.  */
+   if (!w->window_end_valid)
+     {
+       clear_glyph_matrix (w->desired_matrix);
+       return -1;
+     }
  
    /* Compute differences in buffer positions, y-positions etc.  for
       lines reused at the bottom of the window.  Compute what we can
@@@ -18640,28 -18597,6 +18657,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
  }
  
  
@@@ -24079,13 -24014,6 +24096,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))
            {
@@@ -24590,18 -24518,6 +24607,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,
@@@ -24937,20 -24853,6 +24954,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:
@@@ -25728,6 -25611,15 +25745,15 @@@ produce_image_glyph (struct it *it
        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);
      }
  }
  
 +#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
@@@ -27218,10 -27003,6 +27244,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
@@@ -27591,12 -27372,6 +27617,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)