]> code.delx.au - gnu-emacs/blobdiff - src/w32term.c
Separate read and write access to Lisp_Object slots of Lisp_Process.
[gnu-emacs] / src / w32term.c
index 6f0065de9ebc8ca4e2019c4c9d460cfd807c091b..fc4522d56fd18a6ad3d467c231acd661cdad43c1 100644 (file)
@@ -1,4 +1,4 @@
-/* Implementation of GUI terminal on the Microsoft W32 API.
+/* Implementation of GUI terminal on the Microsoft Windows API.
 
 Copyright (C) 1989, 1993-2012 Free Software Foundation, Inc.
 
@@ -155,6 +155,9 @@ int vertical_scroll_bar_bottom_border;
 
 int last_scroll_bar_drag_pos;
 
+/* Keyboard code page - may be changed by language-change events.  */
+int w32_keyboard_codepage;
+
 /* Mouse movement. */
 
 /* Where the mouse was last time we reported a mouse event.  */
@@ -188,9 +191,6 @@ static int volatile input_signal_count;
 static int input_signal_count;
 #endif
 
-/* Keyboard code page - may be changed by language-change events.  */
-static int keyboard_codepage;
-
 static void x_update_window_end (struct window *, int, int);
 static void w32_handle_tool_bar_click (struct frame *,
                                        struct input_event *);
@@ -649,7 +649,7 @@ static void
 x_update_window_end (struct window *w, int cursor_on_p,
                     int mouse_face_overwritten_p)
 {
-  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
+  Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (WGET (w, frame)));
 
   if (!w->pseudo_window_p)
     {
@@ -754,7 +754,7 @@ x_after_update_window_line (struct glyph_row *desired_row)
      overhead is very small.  */
   if (windows_or_buffers_changed
       && desired_row->full_width_p
-      && (f = XFRAME (w->frame),
+      && (f = XFRAME (WGET (w, frame)),
          width = FRAME_INTERNAL_BORDER_WIDTH (f),
          width != 0)
       && (height = desired_row->visible_height,
@@ -2718,7 +2718,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n)
 static void
 x_scroll_run (struct window *w, struct run *run)
 {
-  struct frame *f = XFRAME (w->frame);
+  struct frame *f = XFRAME (WGET (w, frame));
   int x, y, width, height, from_y, to_y, bottom_y;
   HWND hwnd = FRAME_W32_WINDOW (f);
   HRGN expect_dirty;
@@ -2972,7 +2972,7 @@ x_frame_rehighlight (struct w32_display_info *dpyinfo)
           : dpyinfo->w32_focus_frame);
       if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame))
        {
-         FRAME_FOCUS_FRAME (dpyinfo->w32_focus_frame) = Qnil;
+         FSET (dpyinfo->w32_focus_frame, focus_frame, Qnil);
          dpyinfo->x_highlight_frame = dpyinfo->w32_focus_frame;
        }
     }
@@ -3612,6 +3612,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
   SCROLLINFO si;
   struct scroll_bar *bar
     = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
+  Lisp_Object barobj;
 
   BLOCK_INPUT;
 
@@ -3644,7 +3645,8 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
   /* Add bar to its frame's list of scroll bars.  */
   bar->next = FRAME_SCROLL_BARS (f);
   bar->prev = Qnil;
-  XSETVECTOR (FRAME_SCROLL_BARS (f), bar);
+  XSETVECTOR (barobj, bar);
+  FSET (f, scroll_bars, barobj);
   if (! NILP (bar->next))
     XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
 
@@ -3668,7 +3670,7 @@ x_scroll_bar_remove (struct scroll_bar *bar)
   my_destroy_window (f, SCROLL_BAR_W32_WINDOW (bar));
 
   /* Dissociate this scroll bar from its window.  */
-  XWINDOW (bar->window)->vertical_scroll_bar = Qnil;
+  WSET (XWINDOW (bar->window), vertical_scroll_bar, Qnil);
 
   UNBLOCK_INPUT;
 }
@@ -3681,7 +3683,7 @@ static void
 w32_set_vertical_scroll_bar (struct window *w,
                             int portion, int whole, int position)
 {
-  struct frame *f = XFRAME (w->frame);
+  struct frame *f = XFRAME (WGET (w, frame));
   struct scroll_bar *bar;
   int top, height, left, sb_left, width, sb_width;
   int window_y, window_height;
@@ -3721,7 +3723,7 @@ w32_set_vertical_scroll_bar (struct window *w,
                             || WINDOW_RIGHT_MARGIN_COLS (w) == 0));
 
   /* Does the scroll bar exist yet?  */
-  if (NILP (w->vertical_scroll_bar))
+  if (NILP (WGET (w, vertical_scroll_bar)))
     {
       HDC hdc;
       BLOCK_INPUT;
@@ -3743,7 +3745,7 @@ w32_set_vertical_scroll_bar (struct window *w,
       /* It may just need to be moved and resized.  */
       HWND hwnd;
 
-      bar = XSCROLL_BAR (w->vertical_scroll_bar);
+      bar = XSCROLL_BAR (WGET (w, vertical_scroll_bar));
       hwnd = SCROLL_BAR_W32_WINDOW (bar);
 
       /* If already correctly positioned, do nothing.  */
@@ -3805,7 +3807,7 @@ w32_set_vertical_scroll_bar (struct window *w,
 
   w32_set_scroll_bar_thumb (bar, portion, position, whole);
 
-  XSETVECTOR (w->vertical_scroll_bar, bar);
+  XSETVECTOR (WGET (w, vertical_scroll_bar), bar);
 }
 
 
@@ -3829,12 +3831,12 @@ w32_condemn_scroll_bars (FRAME_PTR frame)
     {
       Lisp_Object bar;
       bar = FRAME_SCROLL_BARS (frame);
-      FRAME_SCROLL_BARS (frame) = XSCROLL_BAR (bar)->next;
+      FSET (frame, scroll_bars, XSCROLL_BAR (bar)->next);
       XSCROLL_BAR (bar)->next = FRAME_CONDEMNED_SCROLL_BARS (frame);
       XSCROLL_BAR (bar)->prev = Qnil;
       if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame)))
        XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar;
-      FRAME_CONDEMNED_SCROLL_BARS (frame) = bar;
+      FSET (frame, condemned_scroll_bars, bar);
     }
 }
 
@@ -3846,13 +3848,14 @@ static void
 w32_redeem_scroll_bar (struct window *window)
 {
   struct scroll_bar *bar;
+  Lisp_Object barobj;
   struct frame *f;
 
   /* We can't redeem this window's scroll bar if it doesn't have one.  */
-  if (NILP (window->vertical_scroll_bar))
+  if (NILP (WGET (window, vertical_scroll_bar)))
     abort ();
 
-  bar = XSCROLL_BAR (window->vertical_scroll_bar);
+  bar = XSCROLL_BAR (WGET (window, vertical_scroll_bar));
 
   /* Unlink it from the condemned list.  */
   f = XFRAME (WINDOW_FRAME (window));
@@ -3860,12 +3863,12 @@ w32_redeem_scroll_bar (struct window *window)
     {
       /* If the prev pointer is nil, it must be the first in one of
          the lists.  */
-      if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar))
+      if (EQ (FRAME_SCROLL_BARS (f), WGET (window, vertical_scroll_bar)))
         /* It's not condemned.  Everything's fine.  */
         return;
       else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f),
-                   window->vertical_scroll_bar))
-        FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next;
+                   WGET (window, vertical_scroll_bar)))
+        FSET (f, condemned_scroll_bars, bar->next);
       else
         /* If its prev pointer is nil, it must be at the front of
            one or the other!  */
@@ -3879,7 +3882,8 @@ w32_redeem_scroll_bar (struct window *window)
 
   bar->next = FRAME_SCROLL_BARS (f);
   bar->prev = Qnil;
-  XSETVECTOR (FRAME_SCROLL_BARS (f), bar);
+  XSETVECTOR (barobj, bar);
+  FSET (f, scroll_bars, barobj);
   if (! NILP (bar->next))
     XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
 }
@@ -3896,7 +3900,7 @@ w32_judge_scroll_bars (FRAME_PTR f)
 
   /* Clear out the condemned list now so we won't try to process any
      more events on the hapless scroll bars.  */
-  FRAME_CONDEMNED_SCROLL_BARS (f) = Qnil;
+  FSET (f, condemned_scroll_bars, Qnil);
 
   for (; ! NILP (bar); bar = next)
     {
@@ -4189,7 +4193,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                  /* We may get paint messages even though the client
                     area is clipped - these are not expose events. */
                  DebPrint (("clipped frame %p (%s) got WM_PAINT - ignored\n", f,
-                            SDATA (f->name)));
+                            SDATA (FGET (f, name))));
                }
              else if (f->async_visible != 1)
                {
@@ -4198,7 +4202,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                  f->async_iconified = 0;
                  SET_FRAME_GARBAGED (f);
                  DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f,
-                            SDATA (f->name)));
+                            SDATA (FGET (f, name))));
 
                  /* WM_PAINT serves as MapNotify as well, so report
                     visibility changes properly.  */
@@ -4235,14 +4239,14 @@ w32_read_socket (struct terminal *terminal, int expected,
 
          /* lParam contains the input language ID in its low 16 bits.
             Use it to update our record of the keyboard codepage.  */
-         keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam
-                                                         & 0xffff));
+         w32_keyboard_codepage = codepage_for_locale ((LCID)(msg.msg.lParam
+                                                             & 0xffff));
 
          if (f)
            {
              inev.kind = LANGUAGE_CHANGE_EVENT;
              XSETFRAME (inev.frame_or_window, f);
-             inev.code = keyboard_codepage;
+             inev.code = w32_keyboard_codepage;
              inev.modifiers = msg.msg.lParam & 0xffff;
            }
          break;
@@ -4254,7 +4258,7 @@ w32_read_socket (struct terminal *terminal, int expected,
          if (f && !f->iconified)
            {
              if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
-                 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
+                 && !EQ (FGET (f, tool_bar_window), hlinfo->mouse_face_window))
                {
                  clear_mouse_face (hlinfo);
                  hlinfo->mouse_face_hidden = 1;
@@ -4279,7 +4283,7 @@ w32_read_socket (struct terminal *terminal, int expected,
          if (f && !f->iconified)
            {
              if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
-                 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
+                 && !EQ (FGET (f, tool_bar_window), hlinfo->mouse_face_window))
                {
                  clear_mouse_face (hlinfo);
                  hlinfo->mouse_face_hidden = 1;
@@ -4308,7 +4312,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                     {
                       dbcs[0] = dbcs_lead;
                       dbcs_lead = 0;
-                      if (!MultiByteToWideChar (keyboard_codepage, 0,
+                      if (!MultiByteToWideChar (w32_keyboard_codepage, 0,
                                                dbcs, 2, &code, 1))
                         {
                           /* Garbage */
@@ -4318,7 +4322,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                           break;
                         }
                     }
-                  else if (IsDBCSLeadByteEx (keyboard_codepage,
+                  else if (IsDBCSLeadByteEx (w32_keyboard_codepage,
                                             (BYTE) msg.msg.wParam))
                     {
                       dbcs_lead = (char) msg.msg.wParam;
@@ -4327,7 +4331,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                     }
                   else
                     {
-                      if (!MultiByteToWideChar (keyboard_codepage, 0,
+                      if (!MultiByteToWideChar (w32_keyboard_codepage, 0,
                                                &dbcs[1], 1, &code, 1))
                         {
                           /* What to do with garbage? */
@@ -4357,7 +4361,7 @@ w32_read_socket (struct terminal *terminal, int expected,
          if (f && !f->iconified)
            {
              if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
-                 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
+                 && !EQ (FGET (f, tool_bar_window), hlinfo->mouse_face_window))
                {
                  clear_mouse_face (hlinfo);
                  hlinfo->mouse_face_hidden = 1;
@@ -4422,8 +4426,8 @@ w32_read_socket (struct terminal *terminal, int expected,
                         create event iff we don't leave the
                         selected frame.  */
                      && (focus_follows_mouse
-                         || (EQ (XWINDOW (window)->frame,
-                                 XWINDOW (selected_window)->frame))))
+                         || (EQ (WGET (XWINDOW (window), frame),
+                                 WGET (XWINDOW (selected_window), frame)))))
                    {
                      inev.kind = SELECT_WINDOW_EVENT;
                      inev.frame_or_window = window;
@@ -4481,8 +4485,8 @@ w32_read_socket (struct terminal *terminal, int expected,
                 construct_mouse_click (&inev, &msg, f);
 
                 /* Is this in the tool-bar?  */
-                if (WINDOWP (f->tool_bar_window)
-                    && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
+                if (WINDOWP (FGET (f, tool_bar_window))
+                    && WINDOW_TOTAL_LINES (XWINDOW (FGET (f, tool_bar_window))))
                   {
                     Lisp_Object window;
                    int x = XFASTINT (inev.x);
@@ -4490,7 +4494,7 @@ w32_read_socket (struct terminal *terminal, int expected,
 
                     window = window_from_coordinates (f, x, y, 0, 1);
 
-                    if (EQ (window, f->tool_bar_window))
+                    if (EQ (window, FGET (f, tool_bar_window)))
                       {
                         w32_handle_tool_bar_click (f, &inev);
                         tool_bar_p = 1;
@@ -4935,7 +4939,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                if (!FRAME_OBSCURED_P (f))
                  {
                    DebPrint (("frame %p (%s) obscured\n", f,
-                              SDATA (f->name)));
+                              SDATA (FGET (f, name))));
                  }
              }
            else
@@ -4947,7 +4951,7 @@ w32_read_socket (struct terminal *terminal, int expected,
                  {
                    SET_FRAME_GARBAGED (f);
                    DebPrint (("obscured frame %p (%s) found to be visible\n", f,
-                              SDATA (f->name)));
+                              SDATA (FGET (f, name))));
 
                    /* Force a redisplay sooner or later.  */
                    record_asynch_buffer_change ();
@@ -5038,7 +5042,7 @@ static void
 x_draw_bar_cursor (struct window *w, struct glyph_row *row,
                   int width, enum text_cursor_kinds kind)
 {
-  struct frame *f = XFRAME (w->frame);
+  struct frame *f = XFRAME (WGET (w, frame));
   struct glyph *cursor_glyph;
 
   /* If cursor is out of bounds, don't draw garbage.  This can happen
@@ -5595,7 +5599,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
   SET_FRAME_GARBAGED (f);
 
   /* If cursor was outside the new size, mark it as off.  */
-  mark_window_cursors_off (XWINDOW (f->root_window));
+  mark_window_cursors_off (XWINDOW (FGET (f, root_window)));
 
   /* Clear out any recollection of where the mouse highlighting was,
      since it might be in a place that's outside the new frame size.
@@ -6426,7 +6430,8 @@ w32_initialize (void)
 
   {
     DWORD input_locale_id = (DWORD) GetKeyboardLayout (0);
-    keyboard_codepage = codepage_for_locale ((LCID) (input_locale_id & 0xffff));
+    w32_keyboard_codepage =
+      codepage_for_locale ((LCID) (input_locale_id & 0xffff));
   }
 
   /* Create the window thread - it will terminate itself when the app