]> code.delx.au - gnu-emacs/blobdiff - src/xterm.c
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
[gnu-emacs] / src / xterm.c
index 62ea22abeee20869d196fae346e5ef2afe0fc1f9..06a40fcdf7e65e9da3b509547c5340bc3c28f088 100644 (file)
@@ -1,5 +1,5 @@
 /* X Communication module for terminals which understand the X protocol.
-   Copyright (C) 1989, 93, 94, 95, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1989, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1013,17 +1013,32 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
                    if (relative_compose)
                      {
                        pcm = PER_CHAR_METRIC (font, x_2byte_buffer + i);
-                       if (- pcm->descent >= relative_compose)
+                       if (NILP (Vignore_relative_composition)
+                           || NILP (Faref (Vignore_relative_composition,
+                                           make_number (cmpcharp->glyph[gidx]))))
                          {
-                           /* Draw above the current glyphs.  */
-                           y_offset = highest + pcm->descent;
-                           highest += pcm->ascent + pcm->descent;
+                           if (- pcm->descent >= relative_compose)
+                             {
+                               /* Draw above the current glyphs.  */
+                               y_offset = highest + pcm->descent;
+                               highest += pcm->ascent + pcm->descent;
+                             }
+                           else if (pcm->ascent <= 0)
+                             {
+                               /* Draw beneath the current glyphs.  */
+                               y_offset = lowest - pcm->ascent;
+                               lowest -= pcm->ascent + pcm->descent;
+                             }
                          }
-                       else if (pcm->ascent <= 0)
+                       else
                          {
-                           /* Draw beneath the current glyphs.  */
-                           y_offset = lowest - pcm->ascent;
-                           lowest -= pcm->ascent + pcm->descent;
+                           /* Draw the glyph at normal position.  If
+                               it sticks out of HIGHEST or LOWEST,
+                               update them appropriately.  */
+                           if (pcm->ascent > highest)
+                             highest = pcm->ascent;
+                           else if (- pcm->descent < lowest)
+                             lowest = - pcm->descent;
                          }
                      }
                    else if (cmpcharp->cmp_rule)
@@ -2728,7 +2743,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
 
   BLOCK_INPUT;
 
-  if (! NILP (last_mouse_scroll_bar))
+  if (! NILP (last_mouse_scroll_bar) && insist == 0)
     x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
   else
     {
@@ -2857,7 +2872,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
              }
          }
 
-       if (f1 == 0 && insist)
+       if (f1 == 0 && insist > 0)
          f1 = selected_frame;
 
        if (f1)
@@ -4464,6 +4479,16 @@ XTread_socket (sd, bufp, numchars, expected)
                      f->output_data.x->win_gravity = NorthWestGravity;
                      x_wm_set_size_hint (f, (long) 0, 0);
                    }
+#ifdef USE_MOTIF
+                 /* Some window managers pass (0,0) as the location of
+                    the window, and the Motif event handler stores it
+                    in the emacs widget, which messes up Motif menus.  */
+                 if (event.xconfigure.x == 0 && event.xconfigure.y == 0)
+                   {
+                     event.xconfigure.x = f->output_data.x->widget->core.x;
+                     event.xconfigure.y = f->output_data.x->widget->core.y;
+                   }
+#endif
                }
              goto OTHER;
 
@@ -4877,6 +4902,10 @@ x_display_cursor (f, on, x, y)
 {
   BLOCK_INPUT;
 
+ if ((unsigned) x >= FRAME_WIDTH (f) + FRAME_LEFT_SCROLL_BAR_WIDTH (f)
+      || (unsigned) y >= FRAME_HEIGHT (f))
+    abort ();
+
   if (FRAME_DESIRED_CURSOR (f) == filled_box_cursor)
     x_display_box_cursor (f, on, x, y);
   else if (FRAME_DESIRED_CURSOR (f) == bar_cursor)
@@ -5821,7 +5850,7 @@ x_make_frame_visible (f)
            /* It could be confusing if a real alarm arrives while processing
               the fake one.  Turn it off and let the handler reset it.  */
            alarm (0);
-           input_poll_signal ();
+           input_poll_signal (0);
          }
        /* Once we have handled input events,
           we should have received the MapNotify if one is coming.
@@ -6355,17 +6384,24 @@ x_list_fonts (f, pattern, size, maxnames)
   Lisp_Object list = Qnil, patterns, newlist = Qnil, key, tem, second_best;
   Display *dpy = f != NULL ? FRAME_X_DISPLAY (f) : x_display_list->display;
 
-  patterns = Fassoc (pattern, Valternative_fontname_alist);
+  patterns = Fassoc (pattern, Valternate_fontname_alist);
   if (NILP (patterns))
     patterns = Fcons (pattern, Qnil);
 
+  /* We try at least 10 fonts because X server will return auto-scaled
+     fonts at the head.  */
+  if (maxnames < 10) maxnames = 10;
+
   for (; CONSP (patterns); patterns = XCONS (patterns)->cdr)
     {
       int num_fonts;
       char **names;
 
       pattern = XCONS (patterns)->car;
-      /* See if we cached the result for this particular query.  */
+      /* See if we cached the result for this particular query.
+         The cache is an alist of the form:
+          (((PATTERN . MAXNAMES) (FONTNAME . WIDTH) ...) ...)
+      */
       if (f && (tem = XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->cdr,
                key = Fcons (pattern, make_number (maxnames)),
                !NILP (list = Fassoc (key, tem))))
@@ -6439,6 +6475,8 @@ x_list_fonts (f, pattern, size, maxnames)
       /* Make a list of the fonts that have the right width.  */
       for (; CONSP (list); list = XCONS (list)->cdr)
        {
+         int found_size;
+
          tem = XCONS (list)->car;
 
          if (!CONSP (tem) || NILP (XCONS (tem)->car))
@@ -6462,7 +6500,10 @@ x_list_fonts (f, pattern, size, maxnames)
 
              if (thisinfo)
                {
-                 XCONS (tem)->cdr =  make_number (thisinfo->max_bounds.width);
+                 XCONS (tem)->cdr
+                   = (thisinfo->min_bounds.width == 0
+                      ? make_number (0)
+                      : make_number (thisinfo->max_bounds.width));
                  XFreeFont (dpy, thisinfo);
                }
              else
@@ -6471,21 +6512,26 @@ x_list_fonts (f, pattern, size, maxnames)
                  as 0 not to try to open it again.  */
                XCONS (tem)->cdr = make_number (0);
            }
-         if (XINT (XCONS (tem)->cdr) == size)
+
+         found_size = XINT (XCONS (tem)->cdr);
+         if (found_size == size)
            newlist = Fcons (XCONS (tem)->car, newlist);
-         else if (NILP (second_best))
-           second_best = tem;
-         else if (XINT (XCONS (tem)->cdr) < size)
+         else if (found_size > 0)
            {
-             if (XINT (XCONS (second_best)->cdr) > size
-                 || XINT (XCONS (second_best)->cdr) < XINT (XCONS (tem)->cdr))
-               second_best = tem;
-           }
-         else
-           {
-             if (XINT (XCONS (second_best)->cdr) > size
-                 && XINT (XCONS (second_best)->cdr) > XINT (XCONS (tem)->cdr))
+             if (NILP (second_best))
                second_best = tem;
+             else if (found_size < size)
+               {
+                 if (XINT (XCONS (second_best)->cdr) > size
+                     || XINT (XCONS (second_best)->cdr) < found_size)
+                   second_best = tem;
+               }
+             else
+               {
+                 if (XINT (XCONS (second_best)->cdr) > size
+                     && XINT (XCONS (second_best)->cdr) > found_size)
+                   second_best = tem;
+               }
            }
        }
       if (!NILP (newlist))