emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xterm.c [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/xterm.c [lexbind]
Date: Tue, 14 Oct 2003 19:23:35 -0400

Index: emacs/src/xterm.c
diff -c emacs/src/xterm.c:1.735.2.1 emacs/src/xterm.c:1.735.2.2
*** emacs/src/xterm.c:1.735.2.1 Fri Apr  4 01:21:09 2003
--- emacs/src/xterm.c   Tue Oct 14 19:22:52 2003
***************
*** 1,5 ****
  /* X Communication module for terminals which understand the X protocol.
!    Copyright (C) 1989, 93, 94, 95, 96, 1997, 1998, 1999, 2000, 2001, 2002
     Free Software Foundation, Inc.
  
  This file is part of GNU Emacs.
--- 1,5 ----
  /* X Communication module for terminals which understand the X protocol.
!    Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999, 2000, 01, 02, 2003
     Free Software Foundation, Inc.
  
  This file is part of GNU Emacs.
***************
*** 158,163 ****
--- 158,170 ----
  
  #define abs(x)        ((x) < 0 ? -(x) : (x))
  
+ /* Default to using XIM if available.  */
+ #ifdef USE_XIM
+ int use_xim = 1;
+ #else
+ int use_xim = 0;  /* configure --without-xim */
+ #endif
+ 
  
  
  /* Non-nil means Emacs uses toolkit scroll bars.  */
***************
*** 294,303 ****
  static Lisp_Object Qalt, Qhyper, Qmeta, Qsuper, Qmodifier_value;
  
  static Lisp_Object Qvendor_specific_keysyms;
! static Lisp_Object Qlatin_1, Qutf_8;
  
  extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
! 
  
  static int x_alloc_nearest_color_1 P_ ((Display *, Colormap, XColor *));
  static void x_set_window_size_1 P_ ((struct frame *, int, int, int));
--- 301,310 ----
  static Lisp_Object Qalt, Qhyper, Qmeta, Qsuper, Qmodifier_value;
  
  static Lisp_Object Qvendor_specific_keysyms;
! static Lisp_Object Qlatin_1;
  
  extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
! extern int x_bitmap_mask P_ ((FRAME_PTR, int));
  
  static int x_alloc_nearest_color_1 P_ ((Display *, Colormap, XColor *));
  static void x_set_window_size_1 P_ ((struct frame *, int, int, int));
***************
*** 344,351 ****
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
  
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
!                              GC, int));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
--- 351,357 ----
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
  
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
***************
*** 356,362 ****
                                            Lisp_Object *, Lisp_Object *,
                                            unsigned long *));
  static void x_check_fullscreen P_ ((struct frame *));
! static void x_check_fullscreen_move P_ ((struct frame *));
  static int handle_one_xevent P_ ((struct x_display_info *,
                                    XEvent *,
                                    struct input_event **,
--- 362,368 ----
                                            Lisp_Object *, Lisp_Object *,
                                            unsigned long *));
  static void x_check_fullscreen P_ ((struct frame *));
! static void x_check_expected_move P_ ((struct frame *));
  static int handle_one_xevent P_ ((struct x_display_info *,
                                    XEvent *,
                                    struct input_event **,
***************
*** 528,534 ****
       int x, y0, y1;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
!   
    XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
             f->output_data.x->normal_gc, x, y0, x, y1);
  }
--- 534,540 ----
       int x, y0, y1;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
! 
    XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
             f->output_data.x->normal_gc, x, y0, x, y1);
  }
***************
*** 673,679 ****
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    0, y, width, height, False);
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                   f->output_data.x->pixel_width - width,
                    y, width, height, False);
        UNBLOCK_INPUT;
      }
--- 679,685 ----
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    0, y, width, height, False);
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
!                   FRAME_PIXEL_WIDTH (f) - width,
                    y, width, height, False);
        UNBLOCK_INPUT;
      }
***************
*** 692,698 ****
    struct face *face = p->face;
  
    /* Must clip because of partially visible lines.  */
!   x_clip_to_row (w, row, gc, 1);
  
    if (p->bx >= 0)
      {
--- 698,704 ----
    struct face *face = p->face;
  
    /* Must clip because of partially visible lines.  */
!   x_clip_to_row (w, row, gc);
  
    if (p->bx >= 0)
      {
***************
*** 2076,2084 ****
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += FRAME_X_RIGHT_FRINGE_WIDTH (s->f);
!       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
!       last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
      }
  
    /* The glyph that may have a right box line.  */
--- 2082,2091 ----
    if (s->row->full_width_p
        && !s->w->pseudo_window_p)
      {
!       last_x += WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (s->w);
!       if (s->area != RIGHT_MARGIN_AREA
!         || WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (s->w))
!       last_x += WINDOW_RIGHT_FRINGE_WIDTH (s->w);
      }
  
    /* The glyph that may have a right box line.  */
***************
*** 2466,2472 ****
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (CANON_X_UNIT (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
--- 2473,2479 ----
      {
        /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
         as wide as the stretch glyph.  */
!       int width = min (FRAME_COLUMN_WIDTH (s->f), s->background_width);
  
        /* Draw cursor.  */
        x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height);
***************
*** 2819,2830 ****
  
      {
        /* Get the height not including a menu bar widget.  */
!       int height = CHAR_TO_PIXEL_HEIGHT (f, FRAME_HEIGHT (f));
        /* Height of each line to flash.  */
        int flash_height = FRAME_LINE_HEIGHT (f);
        /* These will be the left and right margins of the rectangles.  */
        int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int flash_right = PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f);
  
        int width;
  
--- 2826,2837 ----
  
      {
        /* Get the height not including a menu bar widget.  */
!       int height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f));
        /* Height of each line to flash.  */
        int flash_height = FRAME_LINE_HEIGHT (f);
        /* These will be the left and right margins of the rectangles.  */
        int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
!       int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH 
(f);
  
        int width;
  
***************
*** 2852,2858 ****
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * CANON_Y_UNIT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
--- 2859,2865 ----
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
***************
*** 2906,2912 ****
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * CANON_Y_UNIT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
--- 2913,2919 ----
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
                          (FRAME_INTERNAL_BORDER_WIDTH (f)
!                          + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
                          width, flash_height);
          XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                          flash_left,
***************
*** 2998,3005 ****
       without mode lines.  Include in this box the left and right
       fringe of W.  */
    window_box (w, -1, &x, &y, &width, &height);
-   width += FRAME_X_FRINGE_WIDTH (f);
-   x -= FRAME_X_LEFT_FRINGE_WIDTH (f);
  
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->current_y);
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->desired_y);
--- 3005,3010 ----
***************
*** 3103,3109 ****
        selected_frame = frame;
        XSETFRAME (XWINDOW (selected_frame->selected_window)->frame,
                 selected_frame);
!       Fselect_window (selected_frame->selected_window);
        choose_minibuf_frame ();
  #endif /* ! 0 */
  
--- 3108,3114 ----
        selected_frame = frame;
        XSETFRAME (XWINDOW (selected_frame->selected_window)->frame,
                 selected_frame);
!       Fselect_window (selected_frame->selected_window, Qnil);
        choose_minibuf_frame ();
  #endif /* ! 0 */
  
***************
*** 3574,3588 ****
    Lisp_Object window;
    int found = 0;
  
!   window = window_from_coordinates (f, x, y, 0, 0);
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
-       frame_to_window_pixel_xy (w, &x, &y);
- 
        for (; !found && r < end && r->enabled_p; ++r)
        if (r->y >= y)
          {
--- 3579,3591 ----
    Lisp_Object window;
    int found = 0;
  
!   window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
    if (!NILP (window))
      {
        struct window *w = XWINDOW (window);
        struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
        for (; !found && r < end && r->enabled_p; ++r)
        if (r->y >= y)
          {
***************
*** 3802,3808 ****
                gx = win_x;
                gy = win_y;
  
!               /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
                   round down even for negative values.  */
                if (gx < 0)
                  gx -= width - 1;
--- 3805,3811 ----
                gx = win_x;
                gy = win_y;
  
!               /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
                   round down even for negative values.  */
                if (gx < 0)
                  gx -= width - 1;
***************
*** 3985,3991 ****
        x_send_scroll_bar_event (window_being_scrolled,
                               scroll_bar_end_scroll, 0, 0);
        w = XWINDOW (window_being_scrolled);
!       
        if (!NILP (XSCROLL_BAR (w->vertical_scroll_bar)->dragging))
        {
          XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil;
--- 3988,3994 ----
        x_send_scroll_bar_event (window_being_scrolled,
                               scroll_bar_end_scroll, 0, 0);
        w = XWINDOW (window_being_scrolled);
! 
        if (!NILP (XSCROLL_BAR (w->vertical_scroll_bar)->dragging))
        {
          XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil;
***************
*** 4190,4200 ****
  #else /* !USE_MOTIF, i.e. Xaw or GTK */
  #ifdef USE_GTK
  /* Scroll bar callback for GTK scroll bars.  WIDGET is the scroll
!    bar adjustment widget.  DATA is a pointer to the scroll_bar structure. */
  
  static void
  xg_scroll_callback (widget, data)
!      GtkWidget *widget;
       gpointer data;
  {
    struct scroll_bar *bar = (struct scroll_bar *) data;
--- 4193,4203 ----
  #else /* !USE_MOTIF, i.e. Xaw or GTK */
  #ifdef USE_GTK
  /* Scroll bar callback for GTK scroll bars.  WIDGET is the scroll
!    bar widget.  DATA is a pointer to the scroll_bar structure. */
  
  static void
  xg_scroll_callback (widget, data)
!      GtkRange *widget;
       gpointer data;
  {
    struct scroll_bar *bar = (struct scroll_bar *) data;
***************
*** 4204,4210 ****
    int diff;
  
    int part = -1, whole = 0, portion = 0;
!   GtkAdjustment *adj = GTK_ADJUSTMENT (widget);
  
    if (xg_ignore_gtk_scrollbar) return;
  
--- 4207,4213 ----
    int diff;
  
    int part = -1, whole = 0, portion = 0;
!   GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (widget));
  
    if (xg_ignore_gtk_scrollbar) return;
  
***************
*** 4588,4594 ****
       its size, the update will often happen too late.
       If you don't believe it, check out revision 1.650 of xterm.c to see
       what hoops we were going through and the still poor behavior we got.  */
!   portion = XFASTINT (XWINDOW (bar->window)->height) * 30;
    /* When the thumb is at the bottom, position == whole.
       So we need to increase `whole' to make space for the thumb.  */
    whole += portion;
--- 4591,4597 ----
       its size, the update will often happen too late.
       If you don't believe it, check out revision 1.650 of xterm.c to see
       what hoops we were going through and the still poor behavior we got.  */
!   portion = WINDOW_TOTAL_LINES (XWINDOW (bar->window)) * 30;
    /* When the thumb is at the bottom, position == whole.
       So we need to increase `whole' to make space for the thumb.  */
    whole += portion;
***************
*** 4956,4992 ****
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
!   int window_x, window_y, window_width, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
    top = window_y;
!   width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     left = XINT (w->left) + XINT (w->width) - FRAME_SCROLL_BAR_COLS (f);
!   else
!     left = XFASTINT (w->left);
!   left *= CANON_X_UNIT (f);
!   left += FRAME_INTERNAL_BORDER_WIDTH (f);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0)
!     sb_width = FRAME_SCROLL_BAR_PIXEL_WIDTH (f);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
  #else
!   if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
      sb_left = left + width - sb_width;
    else
      sb_left = left;
--- 4959,4990 ----
    struct frame *f = XFRAME (w->frame);
    struct scroll_bar *bar;
    int top, height, left, sb_left, width, sb_width;
!   int window_y, window_height;
  
    /* Get window dimensions.  */
!   window_box (w, -1, 0, &window_y, 0, &window_height);
    top = window_y;
!   width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f);
    height = window_height;
  
    /* Compute the left edge of the scroll bar area.  */
!   left = WINDOW_SCROLL_BAR_AREA_X (w);
  
    /* Compute the width of the scroll bar which might be less than
       the width of the area reserved for the scroll bar.  */
!   if (WINDOW_CONFIG_SCROLL_BAR_WIDTH (w) > 0)
!     sb_width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
    else
      sb_width = width;
  
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
  #else
!   if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w))
      sb_left = left + width - sb_width;
    else
      sb_left = left;
***************
*** 5071,5081 ****
         previous mode line display is cleared after C-x 2 C-x 1, for
         example.  */
        {
!       int area_width = FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
        int rest = area_width - sb_width;
        if (rest > 0 && height > 0)
          {
!           if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
              x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                            left + area_width -  rest, top,
                            rest, height, False);
--- 5069,5079 ----
         previous mode line display is cleared after C-x 2 C-x 1, for
         example.  */
        {
!       int area_width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH 
(f);
        int rest = area_width - sb_width;
        if (rest > 0 && height > 0)
          {
!           if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
              x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                            left + area_width -  rest, top,
                            rest, height, False);
***************
*** 5862,5869 ****
  
              if (f)
                {
!                 f->output_data.x->left_pos = new_x;
!                 f->output_data.x->top_pos = new_y;
                }
            }
  #ifdef HACK_EDITRES
--- 5860,5867 ----
  
              if (f)
                {
!                 f->left_pos = new_x;
!                 f->top_pos = new_y;
                }
            }
  #ifdef HACK_EDITRES
***************
*** 5990,5997 ****
            int x, y;
            f->output_data.x->parent_desc = event.xreparent.parent;
            x_real_positions (f, &x, &y);
!           f->output_data.x->left_pos = x;
!           f->output_data.x->top_pos = y;
          }
        goto OTHER;
        break;
--- 5988,5998 ----
            int x, y;
            f->output_data.x->parent_desc = event.xreparent.parent;
            x_real_positions (f, &x, &y);
!           f->left_pos = x;
!           f->top_pos = y;
! 
!           /* Perhaps reparented due to a WM restart.  Reset this.  */
!           FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN;
          }
        goto OTHER;
        break;
***************
*** 6010,6018 ****
                SET_FRAME_GARBAGED (f);
              }
            else
!             expose_frame (x_window_to_frame (dpyinfo,
!                                              event.xexpose.window),
!                           event.xexpose.x, event.xexpose.y,
                            event.xexpose.width, event.xexpose.height);
          }
        else
--- 6011,6018 ----
                SET_FRAME_GARBAGED (f);
              }
            else
!             expose_frame (f,
!                         event.xexpose.x, event.xexpose.y,
                            event.xexpose.width, event.xexpose.height);
          }
        else
***************
*** 6461,6467 ****
                      require = decoding_buffer_size (&coding, nbytes);
                      p = (unsigned char *) alloca (require);
                      coding.mode |= CODING_MODE_LAST_BLOCK;
!                     /* We explicitely disable composition
                         handling because key data should
                         not contain any composition
                         sequence.  */
--- 6461,6467 ----
                      require = decoding_buffer_size (&coding, nbytes);
                      p = (unsigned char *) alloca (require);
                      coding.mode |= CODING_MODE_LAST_BLOCK;
!                     /* We explicitly disable composition
                         handling because key data should
                         not contain any composition
                         sequence.  */
***************
*** 6657,6663 ****
  
                  window = window_from_coordinates (f,
                                                    event.xmotion.x, 
event.xmotion.y,
!                                                   0, 0);
  
                  /* Window will be selected only when it is not selected now 
and
                     last mouse movement event was not in it.  Minibuffer window
--- 6657,6663 ----
  
                  window = window_from_coordinates (f,
                                                    event.xmotion.x, 
event.xmotion.y,
!                                                   0, 0, 0, 0);
  
                  /* Window will be selected only when it is not selected now 
and
                     last mouse movement event was not in it.  Minibuffer window
***************
*** 6728,6738 ****
               do this one, the right one will come later.
               The toolkit version doesn't seem to need this, but we
               need to reset it below.  */
!           int dont_resize =
!             ((f->output_data.x->want_fullscreen & FULLSCREEN_WAIT)
!              && FRAME_NEW_WIDTH (f) != 0);
!           int rows = PIXEL_TO_CHAR_HEIGHT (f, event.xconfigure.height);
!           int columns = PIXEL_TO_CHAR_WIDTH (f, event.xconfigure.width);
            if (dont_resize)
              goto OTHER;
  
--- 6728,6739 ----
               do this one, the right one will come later.
               The toolkit version doesn't seem to need this, but we
               need to reset it below.  */
!           int dont_resize
!           = ((f->want_fullscreen & FULLSCREEN_WAIT)
!              && f->new_text_cols != 0);
!           int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, 
event.xconfigure.height);
!           int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, 
event.xconfigure.width);
! 
            if (dont_resize)
              goto OTHER;
  
***************
*** 6743,6752 ****
            /* Even if the number of character rows and columns has
               not changed, the font size may have changed, so we need
               to check the pixel dimensions as well.  */
!           if (columns != f->width
!               || rows != f->height
!               || event.xconfigure.width != f->output_data.x->pixel_width
!               || event.xconfigure.height != f->output_data.x->pixel_height)
              {
                change_frame_size (f, rows, columns, 0, 1, 0);
                SET_FRAME_GARBAGED (f);
--- 6744,6753 ----
            /* Even if the number of character rows and columns has
               not changed, the font size may have changed, so we need
               to check the pixel dimensions as well.  */
!           if (columns != FRAME_COLS (f)
!               || rows != FRAME_LINES (f)
!               || event.xconfigure.width != FRAME_PIXEL_WIDTH (f)
!               || event.xconfigure.height != FRAME_PIXEL_HEIGHT (f))
              {
                change_frame_size (f, rows, columns, 0, 1, 0);
                SET_FRAME_GARBAGED (f);
***************
*** 6755,6782 ****
  #endif /* not USE_GTK */
  #endif
  
!           f->output_data.x->pixel_width = event.xconfigure.width;
!           f->output_data.x->pixel_height = event.xconfigure.height;
  
  #ifdef USE_GTK
            /* GTK creates windows but doesn't map them.
               Only get real positions and check fullscreen when mapped. */
            if (FRAME_GTK_OUTER_WIDGET (f)
                && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f)))
-             {
  #endif
!           /* What we have now is the position of Emacs's own window.
!              Convert that to the position of the window manager window.  */
!           x_real_positions (f, &f->output_data.x->left_pos,
!                             &f->output_data.x->top_pos);
! 
!           x_check_fullscreen_move (f);
!           if (f->output_data.x->want_fullscreen & FULLSCREEN_WAIT)
!             f->output_data.x->want_fullscreen &=
!               ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
! #ifdef USE_GTK
              }
! #endif
  #ifdef HAVE_X_I18N
            if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea))
              xic_set_statusarea (f);
--- 6756,6780 ----
  #endif /* not USE_GTK */
  #endif
  
!           FRAME_PIXEL_WIDTH (f) = event.xconfigure.width;
!           FRAME_PIXEL_HEIGHT (f) = event.xconfigure.height;
  
  #ifdef USE_GTK
            /* GTK creates windows but doesn't map them.
               Only get real positions and check fullscreen when mapped. */
            if (FRAME_GTK_OUTER_WIDGET (f)
                && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f)))
  #endif
!             {
!             /* What we have now is the position of Emacs's own window.
!                Convert that to the position of the window manager window.  */
!             x_real_positions (f, &f->left_pos, &f->top_pos);
! 
!             x_check_expected_move (f);
!             if (f->want_fullscreen & FULLSCREEN_WAIT)
!               f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
              }
! 
  #ifdef HAVE_X_I18N
            if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea))
              xic_set_statusarea (f);
***************
*** 6786,6792 ****
              {
                /* Since the WM decorations come below top_pos now,
                   we must put them below top_pos in the future.  */
!               f->output_data.x->win_gravity = NorthWestGravity;
                x_wm_set_size_hint (f, (long) 0, 0);
              }
          }
--- 6784,6790 ----
              {
                /* Since the WM decorations come below top_pos now,
                   we must put them below top_pos in the future.  */
!               f->win_gravity = NorthWestGravity;
                x_wm_set_size_hint (f, (long) 0, 0);
              }
          }
***************
*** 6814,6826 ****
            {
              /* Is this in the tool-bar?  */
              if (WINDOWP (f->tool_bar_window)
!                 && XFASTINT (XWINDOW (f->tool_bar_window)->height))
                {
                  Lisp_Object window;
                  int x = event.xbutton.x;
                  int y = event.xbutton.y;
  
!                 window = window_from_coordinates (f, x, y, 0, 1);
                  if (EQ (window, f->tool_bar_window))
                    {
                    if (event.xbutton.type == ButtonPress)
--- 6812,6824 ----
            {
              /* Is this in the tool-bar?  */
              if (WINDOWP (f->tool_bar_window)
!                 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
                {
                  Lisp_Object window;
                  int x = event.xbutton.x;
                  int y = event.xbutton.y;
  
!                 window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
                  if (EQ (window, f->tool_bar_window))
                    {
                    if (event.xbutton.type == ButtonPress)
***************
*** 6903,6909 ****
              /* Verify the event is really within the menu bar
                 and not just sent to it due to grabbing.  */
              && event.xbutton.x >= 0
!             && event.xbutton.x < f->output_data.x->pixel_width
              && event.xbutton.y >= 0
              && event.xbutton.y < f->output_data.x->menubar_height
              && event.xbutton.same_screen)
--- 6901,6907 ----
              /* Verify the event is really within the menu bar
                 and not just sent to it due to grabbing.  */
              && event.xbutton.x >= 0
!             && event.xbutton.x < FRAME_PIXEL_WIDTH (f)
              && event.xbutton.y >= 0
              && event.xbutton.y < f->output_data.x->menubar_height
              && event.xbutton.same_screen)
***************
*** 6999,7008 ****
  {
    struct x_display_info *dpyinfo;
    struct input_event bufp[10];
!   struct input_event *bufpp = bufp;
    int numchars = 10;
    int finish = X_EVENT_NORMAL;
  
    for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
      if (dpyinfo->display == display)
        break;
--- 6997,7010 ----
  {
    struct x_display_info *dpyinfo;
    struct input_event bufp[10];
!   struct input_event *bufpp;
    int numchars = 10;
    int finish = X_EVENT_NORMAL;
  
+   for (bufpp = bufp; bufpp != bufp + 10; bufpp++)
+     EVENT_INIT (*bufpp);
+   bufpp = bufp;
+ 
    for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
      if (dpyinfo->display == display)
        break;
***************
*** 7116,7122 ****
  
        while (gtk_events_pending ())
          {
-           static int nr = 0;
            current_count = count;
            current_numcharsp = &numchars;
            current_bufp = &bufp;
--- 7118,7123 ----
***************
*** 7204,7228 ****
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
-    WHOLE_LINE_P non-zero means include the areas used for truncation
-    mark display and alike in the clipping rectangle.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, gc, whole_line_p)
       struct window *w;
       struct glyph_row *row;
       GC gc;
-      int whole_line_p;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    XRectangle clip_rect;
!   int window_x, window_y, window_width, window_height;
  
!   window_box (w, -1, &window_x, &window_y, &window_width, &window_height);
  
    clip_rect.x = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
--- 7205,7226 ----
  
  /* Set clipping for output in glyph row ROW.  W is the window in which
     we operate.  GC is the graphics context to set clipping in.
  
     ROW may be a text row or, e.g., a mode line.  Text rows must be
     clipped to the interior of the window dedicated to text display,
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, gc)
       struct window *w;
       struct glyph_row *row;
       GC gc;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    XRectangle clip_rect;
!   int window_y, window_width;
  
!   window_box (w, -1, 0, &window_y, &window_width, 0);
  
    clip_rect.x = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
***************
*** 7230,7243 ****
    clip_rect.width = window_width;
    clip_rect.height = row->visible_height;
  
-   /* If clipping to the whole line, including trunc marks, extend
-      the rectangle to the left and increase its width.  */
-   if (whole_line_p)
-     {
-       clip_rect.x -= FRAME_X_LEFT_FRINGE_WIDTH (f);
-       clip_rect.width += FRAME_X_FRINGE_WIDTH (f);
-     }
- 
    XSetClipRectangles (FRAME_X_DISPLAY (f), gc, 0, 0, &clip_rect, 1, Unsorted);
  }
  
--- 7228,7233 ----
***************
*** 7277,7283 ****
    wd = cursor_glyph->pixel_width - 1;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (CANON_X_UNIT (f), wd);
    w->phys_cursor_width = wd;
  
    /* The foreground of cursor_gc is typically the same as the normal
--- 7267,7273 ----
    wd = cursor_glyph->pixel_width - 1;
    if (cursor_glyph->type == STRETCH_GLYPH
        && !x_stretch_cursor_p)
!     wd = min (FRAME_COLUMN_WIDTH (f), wd);
    w->phys_cursor_width = wd;
  
    /* The foreground of cursor_gc is typically the same as the normal
***************
*** 7291,7297 ****
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, gc, 0);
    XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h);
    XSetClipMask (dpy, gc, None);
  }
--- 7281,7287 ----
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, gc);
    XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h);
    XSetClipMask (dpy, gc, None);
  }
***************
*** 7363,7369 ****
        width = min (cursor_glyph->pixel_width, width);
  
        w->phys_cursor_width = width;
!       x_clip_to_row (w, row, gc, 0);
  
        if (kind == BAR_CURSOR)
          XFillRectangle (dpy, window, gc,
--- 7353,7359 ----
        width = min (cursor_glyph->pixel_width, width);
  
        w->phys_cursor_width = width;
!       x_clip_to_row (w, row, gc);
  
        if (kind == BAR_CURSOR)
          XFillRectangle (dpy, window, gc,
***************
*** 7477,7500 ****
    if (FRAME_X_WINDOW (f) == 0)
      return 1;
  
!   /* Free up our existing icon bitmap if any.  */
    if (f->output_data.x->icon_bitmap > 0)
      x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
    f->output_data.x->icon_bitmap = 0;
  
    if (STRINGP (file))
!     bitmap_id = x_create_bitmap_from_file (f, file);
    else
      {
!       /* Create the GNU bitmap if necessary.  */
        if (FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0)
!       FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id
!         = x_create_bitmap_from_data (f, gnu_bits,
!                                      gnu_width, gnu_height);
  
!       /* The first time we create the GNU bitmap,
         this increments the ref-count one extra time.
!        As a result, the GNU bitmap is never freed.
         That way, we don't have to worry about allocating it again.  */
        x_reference_bitmap (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
  
--- 7467,7502 ----
    if (FRAME_X_WINDOW (f) == 0)
      return 1;
  
!   /* Free up our existing icon bitmap and mask if any.  */
    if (f->output_data.x->icon_bitmap > 0)
      x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
    f->output_data.x->icon_bitmap = 0;
  
    if (STRINGP (file))
!     {
! #ifdef USE_GTK
!       /* Use gtk_window_set_icon_from_file() if available,
!        It's not restricted to bitmaps */
!       if (xg_set_icon(f, file))
!       return 0;
! #endif /* USE_GTK */
!       bitmap_id = x_create_bitmap_from_file (f, file);
!       x_create_bitmap_mask(f, bitmap_id);
!     }
    else
      {
!       /* Create the GNU bitmap and mask if necessary.  */
        if (FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0)
!       {
!         FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id
!           = x_create_bitmap_from_data (f, gnu_bits,
!                                        gnu_width, gnu_height);
!         x_create_bitmap_mask(f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
!       }
  
!       /* The first time we create the GNU bitmap and mask,
         this increments the ref-count one extra time.
!        As a result, the GNU bitmap and mask are never freed.
         That way, we don't have to worry about allocating it again.  */
        x_reference_bitmap (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
  
***************
*** 7882,7927 ****
    if (!fontp)
      return Qnil;
  
!   f->output_data.x->font = (XFontStruct *) (fontp->font);
!   f->output_data.x->baseline_offset = fontp->baseline_offset;
!   f->output_data.x->fontset = -1;
  
    compute_fringe_widths (f, 1);
  
    /* Compute the scroll bar width in character columns.  */
!   if (f->scroll_bar_pixel_width > 0)
      {
!       int wid = FONT_WIDTH (f->output_data.x->font);
!       f->scroll_bar_cols = (f->scroll_bar_pixel_width + wid-1) / wid;
      }
    else
      {
!       int wid = FONT_WIDTH (f->output_data.x->font);
!       f->scroll_bar_cols = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_X_WINDOW (f) != 0)
      {
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
!               f->output_data.x->font->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
!               f->output_data.x->font->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
!               f->output_data.x->font->fid);
! 
!       frame_update_line_height (f);
  
        /* Don't change the size of a tip frame; there's no point in
         doing it because it's done in Fx_show_tip, and it leads to
         problems because the tip frame has no widget.  */
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!       x_set_window_size (f, 0, f->width, f->height);
      }
-   else
-     /* If we are setting a new frame's font for the first time,
-        there are no faces yet, so this font's height is the line height.  */
-     f->output_data.x->line_height = FONT_HEIGHT (f->output_data.x->font);
  
    return build_string (fontp->full_name);
  }
--- 7884,7927 ----
    if (!fontp)
      return Qnil;
  
!   FRAME_FONT (f) = (XFontStruct *) (fontp->font);
!   FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
!   FRAME_FONTSET (f) = -1;
! 
!   FRAME_COLUMN_WIDTH (f) = FONT_WIDTH (FRAME_FONT (f));
!   FRAME_LINE_HEIGHT (f) = FONT_HEIGHT (FRAME_FONT (f));
  
    compute_fringe_widths (f, 1);
  
    /* Compute the scroll bar width in character columns.  */
!   if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f)
!       = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid;
      }
    else
      {
!       int wid = FRAME_COLUMN_WIDTH (f);
!       FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
      }
  
    /* Now make the frame display the given font.  */
    if (FRAME_X_WINDOW (f) != 0)
      {
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
!               FRAME_FONT (f)->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
!               FRAME_FONT (f)->fid);
        XSetFont (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
!               FRAME_FONT (f)->fid);
  
        /* Don't change the size of a tip frame; there's no point in
         doing it because it's done in Fx_show_tip, and it leads to
         problems because the tip frame has no widget.  */
        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
!       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
      }
  
    return build_string (fontp->full_name);
  }
***************
*** 7942,7948 ****
    if (fontset < 0)
      return Qnil;
  
!   if (f->output_data.x->fontset == fontset)
      /* This fontset is already set in frame F.  There's nothing more
         to do.  */
      return fontset_name (fontset);
--- 7942,7948 ----
    if (fontset < 0)
      return Qnil;
  
!   if (FRAME_FONTSET (f) == fontset)
      /* This fontset is already set in frame F.  There's nothing more
         to do.  */
      return fontset_name (fontset);
***************
*** 7954,7960 ****
      return Qnil;
  
    /* Since x_new_font doesn't update any fontset information, do it now.  */
!   f->output_data.x->fontset = fontset;
  
  #ifdef HAVE_X_I18N
    if (FRAME_XIC (f)
--- 7954,7960 ----
      return Qnil;
  
    /* Since x_new_font doesn't update any fontset information, do it now.  */
!   FRAME_FONTSET (f) = fontset;
  
  #ifdef HAVE_X_I18N
    if (FRAME_XIC (f)
***************
*** 8025,8055 ****
       struct x_display_info *dpyinfo;
       char *resource_name;
  {
- #ifdef USE_XIM
    XIM xim;
  
!   xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, EMACS_CLASS);
!   dpyinfo->xim = xim;
! 
!   if (xim)
      {
  #ifdef HAVE_X11R6
!       XIMCallback destroy;
  #endif
  
!       /* Get supported styles and XIM values.  */
!       XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL);
  
  #ifdef HAVE_X11R6
!       destroy.callback = xim_destroy_callback;
!       destroy.client_data = (XPointer)dpyinfo;
!       XSetIMValues (xim, XNDestroyCallback, &destroy, NULL);
  #endif
      }
  
! #else /* not USE_XIM */
!   dpyinfo->xim = NULL;
! #endif /* not USE_XIM */
  }
  
  
--- 8025,8059 ----
       struct x_display_info *dpyinfo;
       char *resource_name;
  {
    XIM xim;
  
! #ifdef HAVE_XIM
!   if (use_xim)
      {
+       xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name,
+                    EMACS_CLASS);
+       dpyinfo->xim = xim;
+ 
+       if (xim)
+       {
  #ifdef HAVE_X11R6
!         XIMCallback destroy;
  #endif
  
!         /* Get supported styles and XIM values.  */
!         XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL);
  
  #ifdef HAVE_X11R6
!         destroy.callback = xim_destroy_callback;
!         destroy.client_data = (XPointer)dpyinfo;
!         XSetIMValues (xim, XNDestroyCallback, &destroy, NULL);
  #endif
+       }
      }
  
!   else
! #endif /* HAVE_XIM */
!     dpyinfo->xim = NULL;
  }
  
  
***************
*** 8123,8154 ****
       struct x_display_info *dpyinfo;
       char *resource_name;
  {
! #ifdef USE_XIM
  #ifdef HAVE_X11R6_XIM
!   struct xim_inst_t *xim_inst;
!   int len;
  
!   dpyinfo->xim = NULL;
!   xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
!   xim_inst->dpyinfo = dpyinfo;
!   len = strlen (resource_name);
!   xim_inst->resource_name = (char *) xmalloc (len + 1);
!   bcopy (resource_name, xim_inst->resource_name, len + 1);
!   XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
!                                 resource_name, EMACS_CLASS,
!                                 xim_instantiate_callback,
!                                 /* Fixme: This is XPointer in
!                                    XFree86 but (XPointer *) on
!                                    Tru64, at least.  */
!                                 (XPointer) xim_inst);
  #else /* not HAVE_X11R6_XIM */
!   dpyinfo->xim = NULL;
!   xim_open_dpy (dpyinfo, resource_name);
  #endif /* not HAVE_X11R6_XIM */
  
! #else /* not USE_XIM */
!   dpyinfo->xim = NULL;
! #endif /* not USE_XIM */
  }
  
  
--- 8127,8161 ----
       struct x_display_info *dpyinfo;
       char *resource_name;
  {
! #ifdef HAVE_XIM
!   if (use_xim)
!     {
  #ifdef HAVE_X11R6_XIM
!       struct xim_inst_t *xim_inst;
!       int len;
  
!       dpyinfo->xim = NULL;
!       xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
!       xim_inst->dpyinfo = dpyinfo;
!       len = strlen (resource_name);
!       xim_inst->resource_name = (char *) xmalloc (len + 1);
!       bcopy (resource_name, xim_inst->resource_name, len + 1);
!       XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
!                                     resource_name, EMACS_CLASS,
!                                     xim_instantiate_callback,
!                                     /* This is XPointer in XFree86
!                                        but (XPointer *) on Tru64, at
!                                        least, hence the configure test.  */
!                                     (XRegisterIMInstantiateCallback_arg6) 
xim_inst);
  #else /* not HAVE_X11R6_XIM */
!       dpyinfo->xim = NULL;
!       xim_open_dpy (dpyinfo, resource_name);
  #endif /* not HAVE_X11R6_XIM */
  
!     }
!   else
! #endif /* HAVE_XIM */
!     dpyinfo->xim = NULL;
  }
  
  
***************
*** 8158,8175 ****
  xim_close_dpy (dpyinfo)
       struct x_display_info *dpyinfo;
  {
! #ifdef USE_XIM
  #ifdef HAVE_X11R6_XIM
!   if (dpyinfo->display)
!     XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
!                                     NULL, EMACS_CLASS,
!                                     xim_instantiate_callback, NULL);
  #endif /* not HAVE_X11R6_XIM */
!   if (dpyinfo->display)
!     XCloseIM (dpyinfo->xim);
!   dpyinfo->xim = NULL;
!   XFree (dpyinfo->xim_styles);
! #endif /* USE_XIM */
  }
  
  #endif /* not HAVE_X11R6_XIM */
--- 8165,8185 ----
  xim_close_dpy (dpyinfo)
       struct x_display_info *dpyinfo;
  {
! #ifdef HAVE_XIM
!   if (use_xim)
!     {
  #ifdef HAVE_X11R6_XIM
!       if (dpyinfo->display)
!       XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
!                                         NULL, EMACS_CLASS,
!                                         xim_instantiate_callback, NULL);
  #endif /* not HAVE_X11R6_XIM */
!       if (dpyinfo->display)
!       XCloseIM (dpyinfo->xim);
!       dpyinfo->xim = NULL;
!       XFree (dpyinfo->xim_styles);
!     }
! #endif /* HAVE_XIM */
  }
  
  #endif /* not HAVE_X11R6_XIM */
***************
*** 8185,8191 ****
  {
    Window child;
    int win_x = 0, win_y = 0;
!   int flags = f->output_data.x->size_hint_flags;
    int this_window;
  
    /* We have nothing to do if the current position
--- 8195,8201 ----
  {
    Window child;
    int win_x = 0, win_y = 0;
!   int flags = f->size_hint_flags;
    int this_window;
  
    /* We have nothing to do if the current position
***************
*** 8243,8255 ****
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->output_data.x->left_pos = (FRAME_X_DISPLAY_INFO (f)->width
!                                 - 2 * f->output_data.x->border_width - win_x
!                                 - PIXEL_WIDTH (f)
!                                 + f->output_data.x->left_pos);
  
    {
!     int height = PIXEL_HEIGHT (f);
  
  #if defined USE_X_TOOLKIT && defined USE_MOTIF
      /* Something is fishy here.  When using Motif, starting Emacs with
--- 8253,8265 ----
    /* Treat negative positions as relative to the leftmost bottommost
       position that fits on the screen.  */
    if (flags & XNegative)
!     f->left_pos = (FRAME_X_DISPLAY_INFO (f)->width
!                  - 2 * f->border_width - win_x
!                  - FRAME_PIXEL_WIDTH (f)
!                  + f->left_pos);
  
    {
!     int height = FRAME_PIXEL_HEIGHT (f);
  
  #if defined USE_X_TOOLKIT && defined USE_MOTIF
      /* Something is fishy here.  When using Motif, starting Emacs with
***************
*** 8268,8284 ****
  #endif
  
    if (flags & YNegative)
!     f->output_data.x->top_pos = (FRAME_X_DISPLAY_INFO (f)->height
!                                - 2 * f->output_data.x->border_width
!                                - win_y
!                                - height
!                                + f->output_data.x->top_pos);
    }
  
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->output_data.x->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
--- 8278,8294 ----
  #endif
  
    if (flags & YNegative)
!     f->top_pos = (FRAME_X_DISPLAY_INFO (f)->height
!                 - 2 * f->border_width
!                 - win_y
!                 - height
!                 + f->top_pos);
    }
  
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
!   f->size_hint_flags &= ~ (XNegative | YNegative);
  }
  
  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
***************
*** 8297,8331 ****
  
    if (change_gravity > 0)
      {
!       f->output_data.x->top_pos = yoff;
!       f->output_data.x->left_pos = xoff;
!       f->output_data.x->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->output_data.x->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->output_data.x->size_hint_flags |= YNegative;
!       f->output_data.x->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
! 
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->output_data.x->left_pos;
!   modified_top = f->output_data.x->top_pos;
  #if 0 /* Running on psilocin (Debian), and displaying on the NCD X-terminal,
         this seems to be unnecessary and incorrect.  rms, 4/17/97.  */
    /* It is a mystery why we need to add the border_width here
       when the frame is already visible, but experiment says we do.  */
    if (change_gravity != 0)
      {
!       modified_left += f->output_data.x->border_width;
!       modified_top += f->output_data.x->border_width;
      }
  #endif
  
    XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
                 modified_left, modified_top);
    UNBLOCK_INPUT;
  }
  
--- 8307,8360 ----
  
    if (change_gravity > 0)
      {
!       f->top_pos = yoff;
!       f->left_pos = xoff;
!       f->size_hint_flags &= ~ (XNegative | YNegative);
        if (xoff < 0)
!       f->size_hint_flags |= XNegative;
        if (yoff < 0)
!       f->size_hint_flags |= YNegative;
!       f->win_gravity = NorthWestGravity;
      }
    x_calc_absolute_position (f);
!  
    BLOCK_INPUT;
    x_wm_set_size_hint (f, (long) 0, 0);
  
!   modified_left = f->left_pos;
!   modified_top = f->top_pos;
! 
  #if 0 /* Running on psilocin (Debian), and displaying on the NCD X-terminal,
         this seems to be unnecessary and incorrect.  rms, 4/17/97.  */
    /* It is a mystery why we need to add the border_width here
       when the frame is already visible, but experiment says we do.  */
    if (change_gravity != 0)
      {
!       modified_left += f->border_width;
!       modified_top += f->border_width;
      }
  #endif
  
+   if (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_A)
+     {
+       /* Some WMs (twm, wmaker at least) has an offset that is smaller
+          than the WM decorations.  So we use the calculated offset instead
+          of the WM decoration sizes here (x/y_pixels_outer_diff).  */
+       modified_left += FRAME_X_OUTPUT (f)->move_offset_left;
+       modified_top += FRAME_X_OUTPUT (f)->move_offset_top;
+     }
+ 
    XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
                 modified_left, modified_top);
+ 
+   if (FRAME_VISIBLE_P (f)
+       && FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN)
+     {
+       FRAME_X_OUTPUT (f)->check_expected_move = 1;
+       FRAME_X_OUTPUT (f)->expected_top = f->top_pos;
+       FRAME_X_OUTPUT (f)->expected_left = f->left_pos;
+     }
+ 
    UNBLOCK_INPUT;
  }
  
***************
*** 8335,8391 ****
  x_check_fullscreen (f)
       struct frame *f;
  {
!   if (f->output_data.x->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
  
!       x_real_positions (f, &f->output_data.x->left_pos,
!                         &f->output_data.x->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
  
        /* We do not need to move the window, it shall be taken care of
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
!          x_check_fullscreen_move. */
!       if (f->width != width || f->height != height)
          {
            change_frame_size (f, height, width, 0, 1, 0);
            SET_FRAME_GARBAGED (f);
            cancel_mouse_face (f);
  
            /* Wait for the change of frame size to occur */
!           f->output_data.x->want_fullscreen |= FULLSCREEN_WAIT;
          }
      }
  }
  
  /* If frame parameters are set after the frame is mapped, we need to move
!    the window.  This is done in xfns.c.
     Some window managers moves the window to the right position, some
     moves the outer window manager window to the specified position.
     Here we check that we are in the right spot.  If not, make a second
     move, assuming we are dealing with the second kind of window manager. */
  static void
! x_check_fullscreen_move (f)
       struct frame *f;
  {
!   if (f->output_data.x->want_fullscreen & FULLSCREEN_MOVE_WAIT)
    {
!     int expect_top = f->output_data.x->top_pos;
!     int expect_left = f->output_data.x->left_pos;
  
!     if (f->output_data.x->want_fullscreen & FULLSCREEN_HEIGHT)
!       expect_top = 0;
!     if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
!       expect_left = 0;
! 
!     if (expect_top != f->output_data.x->top_pos
!         || expect_left != f->output_data.x->left_pos)
!       x_set_offset (f, expect_left, expect_top, 1);
  
      /* Just do this once */
!     f->output_data.x->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
    }
  }
  
--- 8364,8421 ----
  x_check_fullscreen (f)
       struct frame *f;
  {
!   if (f->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
  
!       x_real_positions (f, &f->left_pos, &f->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
  
        /* We do not need to move the window, it shall be taken care of
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
!          x_check_expected_move. */
!       if (FRAME_COLS (f) != width || FRAME_LINES (f) != height)
          {
            change_frame_size (f, height, width, 0, 1, 0);
            SET_FRAME_GARBAGED (f);
            cancel_mouse_face (f);
  
            /* Wait for the change of frame size to occur */
!           f->want_fullscreen |= FULLSCREEN_WAIT;
          }
      }
  }
  
  /* If frame parameters are set after the frame is mapped, we need to move
!    the window.
     Some window managers moves the window to the right position, some
     moves the outer window manager window to the specified position.
     Here we check that we are in the right spot.  If not, make a second
     move, assuming we are dealing with the second kind of window manager. */
  static void
! x_check_expected_move (f)
       struct frame *f;
  {
!   if (FRAME_X_OUTPUT (f)->check_expected_move)
    {
!     int expect_top = FRAME_X_OUTPUT (f)->expected_top;
!     int expect_left = FRAME_X_OUTPUT (f)->expected_left;
! 
!     if (expect_top != f->top_pos || expect_left != f->left_pos)
!       {
!         FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_A;
!         FRAME_X_OUTPUT (f)->move_offset_left = expect_left - f->left_pos;
!         FRAME_X_OUTPUT (f)->move_offset_top = expect_top - f->top_pos;
  
!         x_set_offset (f, expect_left, expect_top, 1);
!       }
!     else if (FRAME_X_DISPLAY_INFO (f)->wm_type == X_WMTYPE_UNKNOWN)
!       FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_B;
  
      /* Just do this once */
!     FRAME_X_OUTPUT (f)->check_expected_move = 0;
    }
  }
  
***************
*** 8404,8422 ****
    int pixelwidth, pixelheight;
  
    check_frame_size (f, &rows, &cols);
!   f->output_data.x->vertical_scroll_bar_extra
      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
         ? 0
!        : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
!        ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
!        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
  
!   f->output_data.x->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    XSync (FRAME_X_DISPLAY (f), False);
--- 8434,8452 ----
    int pixelwidth, pixelheight;
  
    check_frame_size (f, &rows, &cols);
!   f->scroll_bar_actual_width
      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
         ? 0
!        : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
!        ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)
!        : (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)));
  
    compute_fringe_widths (f, 0);
  
!   pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols);
!   pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
  
!   f->win_gravity = NorthWestGravity;
    x_wm_set_size_hint (f, (long) 0, 0);
  
    XSync (FRAME_X_DISPLAY (f), False);
***************
*** 8437,8444 ****
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   PIXEL_WIDTH (f) = pixelwidth;
!   PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
--- 8467,8474 ----
       We pass 1 for DELAY since we can't run Lisp code inside of
       a BLOCK_INPUT.  */
    change_frame_size (f, rows, cols, 0, 1, 0);
!   FRAME_PIXEL_WIDTH (f) = pixelwidth;
!   FRAME_PIXEL_HEIGHT (f) = pixelheight;
  
    /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
       receive in the ConfigureNotify event; if we get what we asked
***************
*** 8512,8525 ****
  {
    int pix_x, pix_y;
  
!   pix_x = CHAR_TO_PIXEL_COL (f, x) + FONT_WIDTH  (f->output_data.x->font) / 2;
!   pix_y = CHAR_TO_PIXEL_ROW (f, y) + f->output_data.x->line_height / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > PIXEL_WIDTH (f)) pix_x = PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > PIXEL_HEIGHT (f)) pix_y = PIXEL_HEIGHT (f);
  
    BLOCK_INPUT;
  
--- 8542,8555 ----
  {
    int pix_x, pix_y;
  
!   pix_x = FRAME_COL_TO_PIXEL_X (f, x) + FRAME_COLUMN_WIDTH (f) / 2;
!   pix_y = FRAME_LINE_TO_PIXEL_Y (f, y) + FRAME_LINE_HEIGHT (f) / 2;
  
    if (pix_x < 0) pix_x = 0;
!   if (pix_x > FRAME_PIXEL_WIDTH (f)) pix_x = FRAME_PIXEL_WIDTH (f);
  
    if (pix_y < 0) pix_y = 0;
!   if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
  
    BLOCK_INPUT;
  
***************
*** 8646,8652 ****
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.x->asked_for_visible)
!       x_set_offset (f, f->output_data.x->left_pos, f->output_data.x->top_pos, 
0);
  
        f->output_data.x->asked_for_visible = 1;
  
--- 8676,8682 ----
         before the window gets really visible.  */
        if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.x->asked_for_visible)
!       x_set_offset (f, f->left_pos, f->top_pos, 0);
  
        f->output_data.x->asked_for_visible = 1;
  
***************
*** 8684,8691 ****
         will set it when they are handled.  */
      int previously_visible = f->output_data.x->has_been_visible;
  
!     original_left = f->output_data.x->left_pos;
!     original_top = f->output_data.x->top_pos;
  
      /* This must come after we set COUNT.  */
      UNBLOCK_INPUT;
--- 8714,8721 ----
         will set it when they are handled.  */
      int previously_visible = f->output_data.x->has_been_visible;
  
!     original_left = f->left_pos;
!     original_top = f->top_pos;
  
      /* This must come after we set COUNT.  */
      UNBLOCK_INPUT;
***************
*** 8702,8708 ****
         and we don't want to override it.  */
  
      if (! FRAME_VISIBLE_P (f) && ! FRAME_ICONIFIED_P (f)
!       && f->output_data.x->win_gravity == NorthWestGravity
        && previously_visible)
        {
        Drawable rootw;
--- 8732,8738 ----
         and we don't want to override it.  */
  
      if (! FRAME_VISIBLE_P (f) && ! FRAME_ICONIFIED_P (f)
!       && f->win_gravity == NorthWestGravity
        && previously_visible)
        {
        Drawable rootw;
***************
*** 8768,8774 ****
          (raise-frame f))
  
         the frame is not raised with various window managers on
!        FreeBSD, Linux and Solaris.  It turns out that, for some
         unknown reason, the call to XtMapWidget is completely ignored.
         Mapping the widget a second time works.  */
  
--- 8798,8804 ----
          (raise-frame f))
  
         the frame is not raised with various window managers on
!        FreeBSD, GNU/Linux and Solaris.  It turns out that, for some
         unknown reason, the call to XtMapWidget is completely ignored.
         Mapping the widget a second time works.  */
  
***************
*** 8943,8949 ****
    /* Make sure the X server knows where the window should be positioned,
       in case the user deiconifies with the window manager.  */
    if (! FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f))
!     x_set_offset (f, f->output_data.x->left_pos, f->output_data.x->top_pos, 
0);
  
    /* Since we don't know which revision of X we're running, we'll use both
       the X11R3 and X11R4 techniques.  I don't know if this is a good idea.  */
--- 8973,8979 ----
    /* Make sure the X server knows where the window should be positioned,
       in case the user deiconifies with the window manager.  */
    if (! FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f))
!     x_set_offset (f, f->left_pos, f->top_pos, 0);
  
    /* Since we don't know which revision of X we're running, we'll use both
       the X11R3 and X11R4 techniques.  I don't know if this is a good idea.  */
***************
*** 9158,9165 ****
    /* Setting PMaxSize caused various problems.  */
    size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
  
!   size_hints.x = f->output_data.x->left_pos;
!   size_hints.y = f->output_data.x->top_pos;
  
  #ifdef USE_X_TOOLKIT
    XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
--- 9188,9195 ----
    /* Setting PMaxSize caused various problems.  */
    size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;
  
!   size_hints.x = f->left_pos;
!   size_hints.y = f->top_pos;
  
  #ifdef USE_X_TOOLKIT
    XtSetArg (al[ac], XtNwidth, &widget_width); ac++;
***************
*** 9168,9183 ****
    size_hints.height = widget_height;
    size_hints.width = widget_width;
  #else /* not USE_X_TOOLKIT */
!   size_hints.height = PIXEL_HEIGHT (f);
!   size_hints.width = PIXEL_WIDTH (f);
  #endif /* not USE_X_TOOLKIT */
  
!   size_hints.width_inc = FONT_WIDTH (f->output_data.x->font);
!   size_hints.height_inc = f->output_data.x->line_height;
    size_hints.max_width
!     = FRAME_X_DISPLAY_INFO (f)->width - CHAR_TO_PIXEL_WIDTH (f, 0);
    size_hints.max_height
!     = FRAME_X_DISPLAY_INFO (f)->height - CHAR_TO_PIXEL_HEIGHT (f, 0);
  
    /* Calculate the base and minimum sizes.
  
--- 9198,9213 ----
    size_hints.height = widget_height;
    size_hints.width = widget_width;
  #else /* not USE_X_TOOLKIT */
!   size_hints.height = FRAME_PIXEL_HEIGHT (f);
!   size_hints.width = FRAME_PIXEL_WIDTH (f);
  #endif /* not USE_X_TOOLKIT */
  
!   size_hints.width_inc = FRAME_COLUMN_WIDTH (f);
!   size_hints.height_inc = FRAME_LINE_HEIGHT (f);
    size_hints.max_width
!     = FRAME_X_DISPLAY_INFO (f)->width - FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
    size_hints.max_height
!     = FRAME_X_DISPLAY_INFO (f)->height - FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 
0);
  
    /* Calculate the base and minimum sizes.
  
***************
*** 9188,9195 ****
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
  
!     base_width = CHAR_TO_PIXEL_WIDTH (f, 0);
!     base_height = CHAR_TO_PIXEL_HEIGHT (f, 0);
  
      check_frame_size (f, &min_rows, &min_cols);
  
--- 9218,9225 ----
      int base_width, base_height;
      int min_rows = 0, min_cols = 0;
  
!     base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
!     base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
  
      check_frame_size (f, &min_rows, &min_cols);
  
***************
*** 9264,9270 ****
  #endif
  
  #ifdef PWinGravity
!   size_hints.win_gravity = f->output_data.x->win_gravity;
    size_hints.flags |= PWinGravity;
  
    if (user_position)
--- 9294,9300 ----
  #endif
  
  #ifdef PWinGravity
!   size_hints.win_gravity = f->win_gravity;
    size_hints.flags |= PWinGravity;
  
    if (user_position)
***************
*** 9309,9315 ****
       struct frame *f;
       int pixmap_id;
  {
!   Pixmap icon_pixmap;
  
  #ifndef USE_X_TOOLKIT
    Window window = FRAME_OUTER_WINDOW (f);
--- 9339,9345 ----
       struct frame *f;
       int pixmap_id;
  {
!   Pixmap icon_pixmap, icon_mask;
  
  #ifndef USE_X_TOOLKIT
    Window window = FRAME_OUTER_WINDOW (f);
***************
*** 9319,9324 ****
--- 9349,9356 ----
      {
        icon_pixmap = x_bitmap_pixmap (f, pixmap_id);
        f->output_data.x->wm_hints.icon_pixmap = icon_pixmap;
+       icon_mask = x_bitmap_mask (f, pixmap_id);
+       f->output_data.x->wm_hints.icon_mask = icon_mask;
      }
    else
      {
***************
*** 9331,9336 ****
--- 9363,9369 ----
         best to explicitly give up.  */
  #if 0
        f->output_data.x->wm_hints.icon_pixmap = None;
+       f->output_data.x->wm_hints.icon_mask = None;
  #else
        return;
  #endif
***************
*** 9342,9352 ****
      Arg al[1];
      XtSetArg (al[0], XtNiconPixmap, icon_pixmap);
      XtSetValues (f->output_data.x->widget, al, 1);
    }
  
  #else /* not USE_X_TOOLKIT */
  
!   f->output_data.x->wm_hints.flags |= IconPixmapHint;
    XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);
  
  #endif /* not USE_X_TOOLKIT */
--- 9375,9387 ----
      Arg al[1];
      XtSetArg (al[0], XtNiconPixmap, icon_pixmap);
      XtSetValues (f->output_data.x->widget, al, 1);
+     XtSetArg (al[0], XtNiconMask, icon_mask);
+     XtSetValues (f->output_data.x->widget, al, 1);
    }
  
  #else /* not USE_X_TOOLKIT */
  
!   f->output_data.x->wm_hints.flags |= (IconPixmapHint | IconMaskHint);
    XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);
  
  #endif /* not USE_X_TOOLKIT */
***************
*** 9856,9861 ****
--- 9891,9897 ----
  
      /* Now fill in the slots of *FONTP.  */
      BLOCK_INPUT;
+     bzero (fontp, sizeof (*fontp));
      fontp->font = font;
      fontp->font_idx = i;
      fontp->name = (char *) xmalloc (strlen (fontname) + 1);
***************
*** 10110,10115 ****
--- 10146,10179 ----
  }
  #endif
  
+ /* Count number of set bits in mask and number of bits to shift to
+    get to the first bit.  With MASK 0x7e0, *BITS is set to 6, and *OFFSET
+    to 5.  */
+ static void
+ get_bits_and_offset (mask, bits, offset)
+      unsigned long mask;
+      int *bits;
+      int *offset;
+ {
+   int nr = 0;
+   int off = 0;
+ 
+   while (!(mask & 1))
+     {
+       off++;
+       mask >>= 1;
+     }
+ 
+   while (mask & 1)
+     {
+       nr++;
+       mask >>= 1;
+     }
+ 
+   *offset = off;
+   *bits = nr;
+ }
+ 
  struct x_display_info *
  x_term_init (display_name, xrm_option, resource_name)
       Lisp_Object display_name;
***************
*** 10126,10132 ****
    if (!x_initialized)
      {
        x_initialize ();
!       x_initialized = 1;
      }
  
  #ifdef USE_GTK
--- 10190,10196 ----
    if (!x_initialized)
      {
        x_initialize ();
!       ++x_initialized;
      }
  
  #ifdef USE_GTK
***************
*** 10142,10149 ****
      if (x_initialized > 1)
        return 0;
  
-     x_initialized++;
- 
      for (argc = 0; argc < NUM_ARGV; ++argc)
        argv[argc] = 0;
  
--- 10206,10211 ----
***************
*** 10184,10190 ****
        s = make_string (file, strlen (file));
        abs_file = Fexpand_file_name(s, Qnil);
  
!       if (! NILP (abs_file) && Ffile_readable_p (abs_file))
          gtk_rc_parse (SDATA (abs_file));
  
        UNGCPRO;
--- 10246,10252 ----
        s = make_string (file, strlen (file));
        abs_file = Fexpand_file_name(s, Qnil);
  
!       if (! NILP (abs_file) && !NILP (Ffile_readable_p (abs_file)))
          gtk_rc_parse (SDATA (abs_file));
  
        UNGCPRO;
***************
*** 10333,10338 ****
--- 10395,10401 ----
    dpyinfo->height = HeightOfScreen (dpyinfo->screen);
    dpyinfo->width = WidthOfScreen (dpyinfo->screen);
    dpyinfo->root_window = RootWindowOfScreen (dpyinfo->screen);
+   dpyinfo->client_leader_window = 0;
    dpyinfo->grabbed = 0;
    dpyinfo->reference_count = 0;
    dpyinfo->icon_bitmap_id = -1;
***************
*** 10357,10363 ****
--- 10420,10441 ----
    dpyinfo->x_focus_event_frame = 0;
    dpyinfo->x_highlight_frame = 0;
    dpyinfo->image_cache = make_image_cache ();
+   dpyinfo->wm_type = X_WMTYPE_UNKNOWN;
  
+   /* See if we can construct pixel values from RGB values.  */
+   dpyinfo->red_bits = dpyinfo->blue_bits = dpyinfo->green_bits = 0;
+   dpyinfo->red_offset = dpyinfo->blue_offset = dpyinfo->green_offset = 0;
+ 
+   if (dpyinfo->visual->class == TrueColor)
+     {
+       get_bits_and_offset (dpyinfo->visual->red_mask,
+                            &dpyinfo->red_bits, &dpyinfo->red_offset);
+       get_bits_and_offset (dpyinfo->visual->blue_mask,
+                            &dpyinfo->blue_bits, &dpyinfo->blue_offset);
+       get_bits_and_offset (dpyinfo->visual->green_mask,
+                            &dpyinfo->green_bits, &dpyinfo->green_offset);
+     }
+       
    /* See if a private colormap is requested.  */
    if (dpyinfo->visual == DefaultVisualOfScreen (dpyinfo->screen))
      {
***************
*** 10402,10407 ****
--- 10480,10487 ----
      = XInternAtom (dpyinfo->display, "WM_CONFIGURE_DENIED", False);
    dpyinfo->Xatom_wm_window_moved
      = XInternAtom (dpyinfo->display, "WM_MOVED", False);
+   dpyinfo->Xatom_wm_client_leader
+     = XInternAtom (dpyinfo->display, "WM_CLIENT_LEADER", False);
    dpyinfo->Xatom_editres
      = XInternAtom (dpyinfo->display, "Editres", False);
    dpyinfo->Xatom_CLIPBOARD
***************
*** 10537,10542 ****
--- 10617,10647 ----
        XSynchronize (dpyinfo->display, True);
    }
  
+   {
+     Lisp_Object value;
+     value = display_x_get_resource (dpyinfo,
+                                   build_string ("useXIM"),
+                                   build_string ("UseXIM"),
+                                   Qnil, Qnil);
+ #ifdef USE_XIM
+     if (STRINGP (value)
+       && (!strcmp (XSTRING (value)->data, "false")
+           || !strcmp (XSTRING (value)->data, "off")))
+       use_xim = 0;
+ #else
+     if (STRINGP (value)
+       && (!strcmp (XSTRING (value)->data, "true")
+           || !strcmp (XSTRING (value)->data, "on")))
+       use_xim = 1;
+ #endif
+   }
+ 
+ #ifdef HAVE_X_SM
+   /* Only do this for the first display.  */
+   if (x_initialized == 1)
+     x_session_initialize (dpyinfo);
+ #endif
+ 
    UNBLOCK_INPUT;
  
    return dpyinfo;
***************
*** 10549,10554 ****
--- 10654,10661 ----
  x_delete_display (dpyinfo)
       struct x_display_info *dpyinfo;
  {
+   int i;
+ 
    delete_keyboard_wait_descriptor (dpyinfo->connection);
  
    /* Discard this display from x_display_name_list and x_display_list.
***************
*** 10600,10605 ****
--- 10707,10724 ----
      xim_close_dpy (dpyinfo);
  #endif
  
+   /* Free the font names in the font table.  */
+   for (i = 0; i < dpyinfo->n_fonts; i++)
+     if (dpyinfo->font_table[i].name)
+       {
+       if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)
+         xfree (dpyinfo->font_table[i].full_name);
+       xfree (dpyinfo->font_table[i].name);
+       }
+ 
+   if (dpyinfo->font_table->font_encoder)
+     xfree (dpyinfo->font_table->font_encoder);
+ 
    xfree (dpyinfo->font_table);
    xfree (dpyinfo->x_id_name);
    xfree (dpyinfo->color_cells);
***************
*** 10750,10759 ****
  #endif /* SIGWINCH */
  
    signal (SIGPIPE, x_connection_signal);
- 
- #ifdef HAVE_X_SM
-   x_session_initialize ();
- #endif
  }
  
  
--- 10869,10874 ----
***************
*** 10856,10858 ****
--- 10971,10976 ----
  }
  
  #endif /* HAVE_X_WINDOWS */
+ 
+ /* arch-tag: 6d4e4cb7-abc1-4302-9585-d84dcfb09d0f
+    (do not change this comment) */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]