Fix crashes with lots of overlays.
[bpt/emacs.git] / src / w32term.c
index d7c5d07..16c7bd4 100644 (file)
@@ -1,6 +1,6 @@
 /* Implementation of GUI terminal on the Microsoft Windows API.
 
-Copyright (C) 1989, 1993-2012 Free Software Foundation, Inc.
+Copyright (C) 1989, 1993-2013 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -358,7 +358,7 @@ w32_restore_glyph_string_clip (struct glyph_string *s)
 void
 w32_draw_underwave (struct glyph_string *s, COLORREF color)
 {
-  int wave_height = 2, wave_length = 3;
+  int wave_height = 3, wave_length = 2;
   int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
   XRectangle wave_clip, string_clip, final_clip;
   RECT w32_final_clip, w32_string_clip;
@@ -367,7 +367,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
   dx = wave_length;
   dy = wave_height - 1;
   x0 = s->x;
-  y0 = s->ybase + 1;
+  y0 = s->ybase - wave_height + 3;
   width = s->width;
   xmax = x0 + width;
 
@@ -2456,7 +2456,8 @@ x_draw_glyph_string (struct glyph_string *s)
               unsigned long thickness, position;
               int y;
 
-              if (s->prev && s->prev->face->underline_p)
+              if (s->prev && s->prev->face->underline_p
+                 && s->prev->face->underline_type == FACE_UNDER_LINE)
                 {
                   /* We use the same underline style as the previous one.  */
                   thickness = s->prev->underline_thickness;
@@ -3244,6 +3245,7 @@ lispy_file_action (DWORD action)
   return retval;
 }
 
+#ifdef WINDOWSNT
 /* Put file notifications into the Emacs input event queue.  This
    function runs when the WM_EMACS_FILENOTIFY message arrives from a
    watcher thread.  */
@@ -3320,6 +3322,7 @@ queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f,
   /* We've stuffed all the events ourselves, so w32_read_socket shouldn't.  */
   event->kind = NO_EVENT;
 }
+#endif
 
 \f
 /* Function to report a mouse movement to the mainstream Emacs code.
@@ -4954,11 +4957,13 @@ w32_read_socket (struct terminal *terminal,
          check_visibility = 1;
          break;
 
+#ifdef WINDOWSNT
        case WM_EMACS_FILENOTIFY:
          f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
          if (f)
            queue_notifications (&inev, &msg, f, &count);
          break;
+#endif
 
        default:
          /* Check for messages registered at runtime.  */
@@ -5644,6 +5649,77 @@ x_check_fullscreen (struct frame *f)
     }
 }
 
+static void
+w32fullscreen_hook (FRAME_PTR f)
+{
+  static int normal_width, normal_height;
+
+  if (f->async_visible)
+    {
+      int width, height, top_pos, left_pos, pixel_height, pixel_width;
+      int cur_w = FRAME_COLS (f), cur_h = FRAME_LINES (f);
+      RECT workarea_rect;
+
+      block_input ();
+      if (normal_height <= 0)
+       normal_height = cur_h;
+      if (normal_width <= 0)
+       normal_width = cur_w;
+      x_real_positions (f, &f->left_pos, &f->top_pos);
+      x_fullscreen_adjust (f, &width, &height, &top_pos, &left_pos);
+
+      SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0);
+      pixel_height = workarea_rect.bottom - workarea_rect.top;
+      pixel_width  = workarea_rect.right  - workarea_rect.left;
+
+      switch (f->want_fullscreen)
+       {
+         /* No difference between these two when there is no WM */
+       case FULLSCREEN_MAXIMIZED:
+         PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, 0xf030, 0);
+         break;
+       case FULLSCREEN_BOTH:
+         height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) - 2;
+         width  = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width);
+         left_pos = workarea_rect.left;
+         top_pos = workarea_rect.top;
+         break;
+       case FULLSCREEN_WIDTH:
+         width  = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width);
+         if (normal_height > 0)
+           height = normal_height;
+         left_pos = workarea_rect.left;
+         break;
+       case FULLSCREEN_HEIGHT:
+         height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) - 2;
+         if (normal_width > 0)
+           width = normal_width;
+         top_pos = workarea_rect.top;
+         break;
+       case FULLSCREEN_NONE:
+         if (normal_height > 0)
+           height = normal_height;
+         else
+           normal_height = height;
+         if (normal_width > 0)
+           width = normal_width;
+         else
+           normal_width = width;
+         /* FIXME: Should restore the original position of the frame.  */
+         top_pos = left_pos = 0;
+         break;
+       }
+
+      if (cur_w != width || cur_h != height)
+       {
+         x_set_offset (f, left_pos, top_pos, 1);
+         x_set_window_size (f, 1, width, height);
+         do_pending_window_change (0);
+       }
+      unblock_input ();
+    }
+}
+
 /* Call this to change the size of frame F's x-window.
    If CHANGE_GRAVITY is 1, we change to top-left-corner window gravity
    for this size change and subsequent size changes.
@@ -6334,7 +6410,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
   terminal->mouse_position_hook = w32_mouse_position;
   terminal->frame_rehighlight_hook = w32_frame_rehighlight;
   terminal->frame_raise_lower_hook = w32_frame_raise_lower;
-  /* terminal->fullscreen_hook = XTfullscreen_hook; */
+  terminal->fullscreen_hook = w32fullscreen_hook;
   terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar;
   terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars;
   terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;