Fix crashes in a text-mode session on Windows.
[bpt/emacs.git] / src / w32console.c
index 5a44d37..ee92a59 100644 (file)
@@ -1,5 +1,5 @@
 /* Terminal hooks for GNU Emacs on the Microsoft Windows API.
-   Copyright (C) 1992, 1999, 2001-201 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1999, 2001-2013 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -37,7 +37,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "termchar.h"
 #include "dispextern.h"
 #include "w32term.h"
-#include "w32heap.h"   /* for os_subtype */
+#include "w32common.h" /* for os_subtype */
 #include "w32inevt.h"
 
 /* from window.c */
@@ -601,7 +601,7 @@ w32_face_attributes (struct frame *f, int face_id)
 }
 
 void
-initialize_w32_display (struct terminal *term)
+initialize_w32_display (struct terminal *term, int *width, int *height)
 {
   CONSOLE_SCREEN_BUFFER_INFO   info;
   Mouse_HLInfo *hlinfo;
@@ -722,23 +722,21 @@ initialize_w32_display (struct terminal *term)
              || info.srWindow.Right - info.srWindow.Left < 40
              || info.srWindow.Right - info.srWindow.Left > 100)))
     {
-      FRAME_LINES (SELECTED_FRAME ()) = 25;
-      SET_FRAME_COLS (SELECTED_FRAME (), 80);
+      *height = 25;
+      *width = 80;
     }
 
   else if (w32_use_full_screen_buffer)
     {
-      FRAME_LINES (SELECTED_FRAME ()) = info.dwSize.Y; /* lines per page */
-      SET_FRAME_COLS (SELECTED_FRAME (), info.dwSize.X);  /* characters per line */
+      *height = info.dwSize.Y; /* lines per page */
+      *width = info.dwSize.X;  /* characters per line */
     }
   else
     {
       /* Lines per page.  Use buffer coords instead of buffer size.  */
-      FRAME_LINES (SELECTED_FRAME ()) = 1 + info.srWindow.Bottom -
-       info.srWindow.Top;
+      *height = 1 + info.srWindow.Bottom - info.srWindow.Top;
       /* Characters per line.  Use buffer coords instead of buffer size.  */
-      SET_FRAME_COLS (SELECTED_FRAME (), 1 + info.srWindow.Right -
-                      info.srWindow.Left);
+      *width = 1 + info.srWindow.Right - info.srWindow.Left;
     }
 
   if (os_subtype == OS_NT)
@@ -746,6 +744,9 @@ initialize_w32_display (struct terminal *term)
   else
     w32_console_unicode_input = 0;
 
+  /* This is needed by w32notify.c:send_notifications.  */
+  dwMainThreadId = GetCurrentThreadId ();
+
   /* Setup w32_display_info structure for this frame. */
 
   w32_initialize_display_info (build_string ("Console"));