]> code.delx.au - gnu-emacs/blobdiff - src/xterm.c
Add fullscreen_hook.
[gnu-emacs] / src / xterm.c
index 5e4eeb3bb641bcc00fe5356f6a11f7a16534dc71..564da0d876c4079da31b235289bf2003acf5ee78 100644 (file)
@@ -182,6 +182,10 @@ static Lisp_Object last_window;
 
 int x_use_underline_position_properties;
 
+/* Non-zero means to draw the underline at the same place as the descent line.  */
+
+int x_underline_at_descent_line;
+
 /* This is a chain of structures for all the X displays currently in
    use.  */
 
@@ -2589,7 +2593,9 @@ x_draw_stretch_glyph_string (s)
       int background_width = s->background_width;
       int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
 
-      if (x < left_x)
+      /* Don't draw into left margin, fringe or scrollbar area
+         except for header line and mode line.  */
+      if (x < left_x && !s->row->mode_line_p)
        {
          background_width -= left_x - x;
          x = left_x;
@@ -2683,32 +2689,34 @@ x_draw_glyph_string (s)
          if (!XGetFontProperty (s->font, XA_UNDERLINE_THICKNESS, &h))
            h = 1;
 
-         /* Get the underline position.  This is the recommended
-            vertical offset in pixels from the baseline to the top of
-            the underline.  This is a signed value according to the
-            specs, and its default is
-
-            ROUND ((maximum descent) / 2), with
-            ROUND(x) = floor (x + 0.5)  */
-
-         if (x_use_underline_position_properties
-             && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
-           y = s->ybase + (long) tem;
-         else if (s->face->font)
-           y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
-         else
-           y = s->y + s->height - h;
+         y = s->y + s->height - h;
+         if (!x_underline_at_descent_line)
+            {
+             /* Get the underline position.  This is the recommended
+                 vertical offset in pixels from the baseline to the top of
+                 the underline.  This is a signed value according to the
+                 specs, and its default is
+
+                ROUND ((maximum descent) / 2), with
+                ROUND(x) = floor (x + 0.5)  */
+
+              if (x_use_underline_position_properties
+                  && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
+                y = s->ybase + (long) tem;
+              else if (s->face->font)
+                y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
+            }
 
          if (s->face->underline_defaulted_p)
            XFillRectangle (s->display, s->window, s->gc,
-                           s->x, y, s->width, h);
+                           s->x, y, s->background_width, h);
          else
            {
              XGCValues xgcv;
              XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
              XSetForeground (s->display, s->gc, s->face->underline_color);
              XFillRectangle (s->display, s->window, s->gc,
-                             s->x, y, s->width, h);
+                             s->x, y, s->background_width, h);
              XSetForeground (s->display, s->gc, xgcv.foreground);
            }
        }
@@ -2720,14 +2728,14 @@ x_draw_glyph_string (s)
 
          if (s->face->overline_color_defaulted_p)
            XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
-                           s->width, h);
+                           s->background_width, h);
          else
            {
              XGCValues xgcv;
              XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
              XSetForeground (s->display, s->gc, s->face->overline_color);
              XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
-                             s->width, h);
+                             s->background_width, h);
              XSetForeground (s->display, s->gc, xgcv.foreground);
            }
        }
@@ -4083,6 +4091,9 @@ x_send_scroll_bar_event (window, part, portion, whole)
 
   /* Make Xt timeouts work while the scroll bar is active.  */
   toolkit_scroll_bar_interaction = 1;
+#ifdef USE_X_TOOLKIT
+  x_activate_timeout_atimer ();
+#endif
 
   /* Setting the event mask to zero means that the message will
      be sent to the client that created the window, and if that
@@ -6575,7 +6586,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
           {
 
             /* Generate SELECT_WINDOW_EVENTs when needed.  */
-            if (mouse_autoselect_window)
+            if (!NILP (Vmouse_autoselect_window))
               {
                 Lisp_Object window;
 
@@ -7492,7 +7503,7 @@ struct x_error_message_stack {
 static struct x_error_message_stack *x_error_message;
 
 /* An X error handler which stores the error message in
-   x_error_message_string.  This is called from x_error_handler if
+   *x_error_message.  This is called from x_error_handler if
    x_catch_errors is in effect.  */
 
 static void
@@ -7511,7 +7522,7 @@ x_error_catcher (display, error)
 
    After calling this function, X protocol errors no longer cause
    Emacs to exit; instead, they are recorded in the string
-   stored in x_error_message_string.
+   stored in *x_error_message.
 
    Calling x_check_errors signals an Emacs error if an X error has
    occurred since the last call to x_catch_errors or x_check_errors.
@@ -7771,7 +7782,7 @@ x_connection_closed (dpy, error_message)
 
 /* We specifically use it before defining it, so that gcc doesn't inline it,
    otherwise gdb doesn't know how to properly put a breakpoint on it.  */
-static void x_error_quitter P_ ((Display *, XErrorEvent *)) NO_RETURN;
+static void x_error_quitter P_ ((Display *, XErrorEvent *));
 
 /* This is the first-level handler for X protocol errors.
    It calls x_error_quitter or x_error_catcher.  */
@@ -7816,6 +7827,12 @@ x_error_quitter (display, error)
 {
   char buf[256], buf1[356];
 
+  /* Ignore BadName errors.  They can happen because of fonts
+     or colors that are not defined.  */
+
+  if (error->error_code == BadName)
+    return;
+
   /* Note that there is no real way portable across R3/R4 to get the
      original error handler.  */
 
@@ -8323,7 +8340,7 @@ x_check_expected_move (f, expected_left, expected_top)
      int expected_left;
      int expected_top;
 {
-  int count = 0, current_left = 0, current_top = 0;
+  int current_left = 0, current_top = 0;
 
   /* x_real_positions returns the left and top offsets of the outermost
      window manager window around the frame.  */
@@ -8590,13 +8607,25 @@ void
 x_raise_frame (f)
      struct frame *f;
 {
+  Lisp_Object frame;
+  const char *atom = "_NET_ACTIVE_WINDOW";
+
+  BLOCK_INPUT;
   if (f->async_visible)
-    {
-      BLOCK_INPUT;
-      XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
-      XFlush (FRAME_X_DISPLAY (f));
-      UNBLOCK_INPUT;
-    }
+    XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
+
+  XSETFRAME (frame, f);
+  /* See Window Manager Specification/Extended Window Manager Hints at
+     http://freedesktop.org/wiki/Standards_2fwm_2dspec */
+
+  Fx_send_client_event (frame, make_number (0), frame,
+                        make_unibyte_string (atom, strlen (atom)),
+                        make_number (32),
+                        Fcons (make_number (1),
+                               Fcons (make_number (time (NULL) * 1000),
+                                      Qnil)));
+  XFlush (FRAME_X_DISPLAY (f));
+  UNBLOCK_INPUT;
 }
 
 /* Lower frame F.  */
@@ -10056,8 +10085,8 @@ x_query_font (f, fontname)
 
   for (i = 0; i < dpyinfo->n_fonts; i++)
     if (dpyinfo->font_table[i].name
-       && (!strcmp (dpyinfo->font_table[i].name, fontname)
-           || !strcmp (dpyinfo->font_table[i].full_name, fontname)))
+       && (!strcasecmp (dpyinfo->font_table[i].name, fontname)
+           || !strcasecmp (dpyinfo->font_table[i].full_name, fontname)))
       return (dpyinfo->font_table + i);
   return NULL;
 }
@@ -10120,6 +10149,11 @@ static XrmOptionDescRec emacs_options[] = {
   {"-mc",      "*pointerColor", XrmoptionSepArg, (XtPointer) NULL},
   {"-cr",      "*cursorColor", XrmoptionSepArg, (XtPointer) NULL}
 };
+
+/* Whether atimer for Xt timeouts is activated or not.  */
+
+static int x_timeout_atimer_activated_flag;
+
 #endif /* USE_X_TOOLKIT */
 
 static int x_initialized;
@@ -10584,6 +10618,11 @@ x_term_init (display_name, xrm_option, resource_name)
 
   dpyinfo->cut_buffers_initialized = 0;
 
+  dpyinfo->x_dnd_atoms_size = 8;
+  dpyinfo->x_dnd_atoms_length = 0;
+  dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms)
+                                  * dpyinfo->x_dnd_atoms_size);
+
   connection = ConnectionNumber (dpyinfo->display);
   dpyinfo->connection = connection;
 
@@ -10796,13 +10835,39 @@ static void
 x_process_timeouts (timer)
      struct atimer *timer;
 {
+  BLOCK_INPUT;
+  x_timeout_atimer_activated_flag = 0;
   if (toolkit_scroll_bar_interaction || popup_activated ())
     {
-      BLOCK_INPUT;
       while (XtAppPending (Xt_app_con) & XtIMTimer)
        XtAppProcessEvent (Xt_app_con, XtIMTimer);
-      UNBLOCK_INPUT;
+      /* Reactivate the atimer for next time.  */
+      x_activate_timeout_atimer ();
     }
+  UNBLOCK_INPUT;
+}
+
+/* Install an asynchronous timer that processes Xt timeout events
+   every 0.1s as long as either `toolkit_scroll_bar_interaction' or
+   `popup_activated_flag' (in xmenu.c) is set.  Make sure to call this
+   function whenever these variables are set.  This is necessary
+   because some widget sets use timeouts internally, for example the
+   LessTif menu bar, or the Xaw3d scroll bar.  When Xt timeouts aren't
+   processed, these widgets don't behave normally.  */
+
+void
+x_activate_timeout_atimer ()
+{
+  BLOCK_INPUT;
+  if (!x_timeout_atimer_activated_flag)
+    {
+      EMACS_TIME interval;
+
+      EMACS_SET_SECS_USECS (interval, 0, 100000);
+      start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0);
+      x_timeout_atimer_activated_flag = 1;
+    }
+  UNBLOCK_INPUT;
 }
 
 #endif /* USE_X_TOOLKIT */
@@ -10908,17 +10973,6 @@ x_initialize ()
                         XtCacheByDisplay, cvt_pixel_dtor);
 
   XtAppSetFallbackResources (Xt_app_con, Xt_default_resources);
-
-  /* Install an asynchronous timer that processes Xt timeout events
-     every 0.1s.  This is necessary because some widget sets use
-     timeouts internally, for example the LessTif menu bar, or the
-     Xaw3d scroll bar.  When Xt timouts aren't processed, these
-     widgets don't behave normally.  */
-  {
-    EMACS_TIME interval;
-    EMACS_SET_SECS_USECS (interval, 0, 100000);
-    start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0);
-  }
 #endif
 
 #ifdef USE_TOOLKIT_SCROLL_BARS
@@ -10972,6 +11026,14 @@ UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
 to 4.1, set this to nil.  */);
   x_use_underline_position_properties = 1;
 
+  DEFVAR_BOOL ("x-underline-at-descent-line",
+              &x_underline_at_descent_line,
+     doc: /* *Non-nil means to draw the underline at the same place as the descent line.
+nil means to draw the underline according to the value of the variable
+`x-use-underline-position-properties', which is usually at the baseline
+level.  The default value is nil.  */);
+  x_underline_at_descent_line = 0;
+
   DEFVAR_BOOL ("x-mouse-click-focus-ignore-position",
               &x_mouse_click_focus_ignore_position,
     doc: /* Non-nil means that a mouse click to focus a frame does not move point.