comparison src/w32term.c @ 91041:bdb3fe0ba9fa

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 866-879) - Merge multi-tty branch - Update from CVS - Merge from emacs--rel--22 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author Miles Bader <miles@gnu.org>
date Thu, 11 Oct 2007 16:22:07 +0000
parents d41ffb650865 5039706521c9
children a0e466c4d599
comparison
equal deleted inserted replaced
91040:14c4a6aac623 91041:bdb3fe0ba9fa
62 62
63 #ifdef USE_FONT_BACKEND 63 #ifdef USE_FONT_BACKEND
64 #include "font.h" 64 #include "font.h"
65 #endif /* USE_FONT_BACKEND */ 65 #endif /* USE_FONT_BACKEND */
66 66
67 #define abs(x) ((x) < 0 ? -(x) : (x))
68
69 67
70 /* Fringe bitmaps. */ 68 /* Fringe bitmaps. */
71 69
72 static int max_fringe_bmp = 0; 70 static int max_fringe_bmp = 0;
73 static HBITMAP *fringe_bmp = 0; 71 static HBITMAP *fringe_bmp = 0;
263 static void w32_initialize P_ ((void)); 261 static void w32_initialize P_ ((void));
264 static void x_font_min_bounds P_ ((XFontStruct *, int *, int *)); 262 static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
265 int x_compute_min_glyph_bounds P_ ((struct frame *)); 263 int x_compute_min_glyph_bounds P_ ((struct frame *));
266 static void x_update_end P_ ((struct frame *)); 264 static void x_update_end P_ ((struct frame *));
267 static void w32_frame_up_to_date P_ ((struct frame *)); 265 static void w32_frame_up_to_date P_ ((struct frame *));
268 static void w32_set_terminal_modes P_ ((void)); 266 static void w32_set_terminal_modes P_ ((struct terminal *));
269 static void w32_reset_terminal_modes P_ ((void)); 267 static void w32_reset_terminal_modes P_ ((struct terminal *));
270 static void x_clear_frame P_ ((void)); 268 static void x_clear_frame P_ ((struct frame *));
271 static void frame_highlight P_ ((struct frame *)); 269 static void frame_highlight P_ ((struct frame *));
272 static void frame_unhighlight P_ ((struct frame *)); 270 static void frame_unhighlight P_ ((struct frame *));
273 static void x_new_focus_frame P_ ((struct w32_display_info *, 271 static void x_new_focus_frame P_ ((struct w32_display_info *,
274 struct frame *)); 272 struct frame *));
275 static void x_focus_changed P_ ((int, int, struct w32_display_info *, 273 static void x_focus_changed P_ ((int, int, struct w32_display_info *,
877 suspend. When starting Emacs, no window is mapped. And nothing 875 suspend. When starting Emacs, no window is mapped. And nothing
878 must be done to Emacs's own window if it is suspended (though that 876 must be done to Emacs's own window if it is suspended (though that
879 rarely happens). */ 877 rarely happens). */
880 878
881 static void 879 static void
882 w32_set_terminal_modes (void) 880 w32_set_terminal_modes (struct terminal *term)
883 { 881 {
884 } 882 }
885 883
886 /* This is called when exiting or suspending Emacs. Exiting will make 884 /* This is called when exiting or suspending Emacs. Exiting will make
887 the W32 windows go away, and suspending requires no action. */ 885 the W32 windows go away, and suspending requires no action. */
888 886
889 static void 887 static void
890 w32_reset_terminal_modes (void) 888 w32_reset_terminal_modes (struct terminal *term)
891 { 889 {
892 } 890 }
893 891
894 892
895 893
3014 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, s->y + dy, 3012 w32_fill_area (s->f, s->hdc, s->gc->foreground, s->x, s->y + dy,
3015 s->width, h); 3013 s->width, h);
3016 } 3014 }
3017 else 3015 else
3018 { 3016 {
3019 w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, 3017 w32_fill_area (s->f, s->hdc, s->face->strike_through_color, s->x,
3020 s->y + dy, s->width, h); 3018 s->y + dy, s->width, h);
3021 } 3019 }
3022 } 3020 }
3023 3021
3024 /* Draw relief if not yet drawn. */ 3022 /* Draw relief if not yet drawn. */
3107 3105
3108 /* Delete N glyphs at the nominal cursor position. Not implemented 3106 /* Delete N glyphs at the nominal cursor position. Not implemented
3109 for X frames. */ 3107 for X frames. */
3110 3108
3111 static void 3109 static void
3112 x_delete_glyphs (n) 3110 x_delete_glyphs (f, n)
3111 struct frame *f;
3113 register int n; 3112 register int n;
3114 { 3113 {
3115 struct frame *f;
3116
3117 if (updating_frame)
3118 f = updating_frame;
3119 else
3120 f = SELECTED_FRAME ();
3121
3122 if (! FRAME_W32_P (f)) 3114 if (! FRAME_W32_P (f))
3123 return; 3115 return;
3124 3116
3125 abort (); 3117 abort ();
3126 } 3118 }
3128 3120
3129 /* Clear entire frame. If updating_frame is non-null, clear that 3121 /* Clear entire frame. If updating_frame is non-null, clear that
3130 frame. Otherwise clear the selected frame. */ 3122 frame. Otherwise clear the selected frame. */
3131 3123
3132 static void 3124 static void
3133 x_clear_frame () 3125 x_clear_frame (struct frame *f)
3134 { 3126 {
3135 struct frame *f;
3136
3137 if (updating_frame)
3138 f = updating_frame;
3139 else
3140 f = SELECTED_FRAME ();
3141
3142 if (! FRAME_W32_P (f)) 3127 if (! FRAME_W32_P (f))
3143 return; 3128 return;
3144 3129
3145 /* Clearing the frame will erase any cursor, so mark them all as no 3130 /* Clearing the frame will erase any cursor, so mark them all as no
3146 longer visible. */ 3131 longer visible. */
3163 3148
3164 3149
3165 /* Make audible bell. */ 3150 /* Make audible bell. */
3166 3151
3167 static void 3152 static void
3168 w32_ring_bell (void) 3153 w32_ring_bell (struct frame *f)
3169 { 3154 {
3170 struct frame *f;
3171
3172 f = SELECTED_FRAME ();
3173
3174 BLOCK_INPUT; 3155 BLOCK_INPUT;
3175 3156
3176 if (FRAME_W32_P (f) && visible_bell) 3157 if (FRAME_W32_P (f) && visible_bell)
3177 { 3158 {
3178 int i; 3159 int i;
3179 HWND hwnd = FRAME_W32_WINDOW (SELECTED_FRAME ()); 3160 HWND hwnd = FRAME_W32_WINDOW (f);
3180 3161
3181 for (i = 0; i < 5; i++) 3162 for (i = 0; i < 5; i++)
3182 { 3163 {
3183 FlashWindow (hwnd, TRUE); 3164 FlashWindow (hwnd, TRUE);
3184 Sleep (10); 3165 Sleep (10);
3185 } 3166 }
3186 FlashWindow (hwnd, FALSE); 3167 FlashWindow (hwnd, FALSE);
3187 } 3168 }
3188 else 3169 else
3189 w32_sys_ring_bell (); 3170 w32_sys_ring_bell (f);
3190 3171
3191 UNBLOCK_INPUT; 3172 UNBLOCK_INPUT;
3192 } 3173 }
3193 3174
3194 3175
3211 3192
3212 /* Perform an insert-lines or delete-lines operation, inserting N 3193 /* Perform an insert-lines or delete-lines operation, inserting N
3213 lines or deleting -N lines at vertical position VPOS. */ 3194 lines or deleting -N lines at vertical position VPOS. */
3214 3195
3215 static void 3196 static void
3216 x_ins_del_lines (vpos, n) 3197 x_ins_del_lines (f, vpos, n)
3198 struct frame *f;
3217 int vpos, n; 3199 int vpos, n;
3218 { 3200 {
3219 struct frame *f;
3220
3221 if (updating_frame)
3222 f = updating_frame;
3223 else
3224 f = SELECTED_FRAME ();
3225
3226 if (! FRAME_W32_P (f)) 3201 if (! FRAME_W32_P (f))
3227 return; 3202 return;
3228 3203
3229 abort (); 3204 abort ();
3230 } 3205 }
3625 struct frame *f; 3600 struct frame *f;
3626 { 3601 {
3627 POINT p; 3602 POINT p;
3628 int delta; 3603 int delta;
3629 3604
3630 result->kind = WHEEL_EVENT; 3605 result->kind = msg->msg.message == WM_MOUSEHWHEEL ? HORIZ_WHEEL_EVENT
3606 : WHEEL_EVENT;
3631 result->code = 0; 3607 result->code = 0;
3632 result->timestamp = msg->msg.time; 3608 result->timestamp = msg->msg.time;
3633 3609
3634 /* A WHEEL_DELTA positive value indicates that the wheel was rotated 3610 /* A WHEEL_DELTA positive value indicates that the wheel was rotated
3635 forward, away from the user (up); a negative value indicates that 3611 forward, away from the user (up); a negative value indicates that
4857 selected now and last mouse movement event was 4833 selected now and last mouse movement event was
4858 not in it. Minibuffer window will be selected 4834 not in it. Minibuffer window will be selected
4859 only when it is active. */ 4835 only when it is active. */
4860 if (WINDOWP(window) 4836 if (WINDOWP(window)
4861 && !EQ (window, last_window) 4837 && !EQ (window, last_window)
4862 && !EQ (window, selected_window)) 4838 && !EQ (window, selected_window)
4839 /* For click-to-focus window managers
4840 create event iff we don't leave the
4841 selected frame. */
4842 && (focus_follows_mouse
4843 || (EQ (XWINDOW (window)->frame,
4844 XWINDOW (selected_window)->frame))))
4863 { 4845 {
4864 inev.kind = SELECT_WINDOW_EVENT; 4846 inev.kind = SELECT_WINDOW_EVENT;
4865 inev.frame_or_window = window; 4847 inev.frame_or_window = window;
4866 } 4848 }
4867 4849
4962 } 4944 }
4963 break; 4945 break;
4964 } 4946 }
4965 4947
4966 case WM_MOUSEWHEEL: 4948 case WM_MOUSEWHEEL:
4949 case WM_MOUSEHWHEEL:
4967 { 4950 {
4968 if (dpyinfo->grabbed && last_mouse_frame 4951 if (dpyinfo->grabbed && last_mouse_frame
4969 && FRAME_LIVE_P (last_mouse_frame)) 4952 && FRAME_LIVE_P (last_mouse_frame))
4970 f = last_mouse_frame; 4953 f = last_mouse_frame;
4971 else 4954 else
6476 if (FRAME_W32_WINDOW (f)) 6459 if (FRAME_W32_WINDOW (f))
6477 my_destroy_window (f, FRAME_W32_WINDOW (f)); 6460 my_destroy_window (f, FRAME_W32_WINDOW (f));
6478 6461
6479 free_frame_menubar (f); 6462 free_frame_menubar (f);
6480 6463
6481 unload_color (f, f->output_data.x->foreground_pixel); 6464 unload_color (f, FRAME_FOREGROUND_PIXEL (f));
6482 unload_color (f, f->output_data.x->background_pixel); 6465 unload_color (f, FRAME_BACKGROUND_PIXEL (f));
6483 unload_color (f, f->output_data.w32->cursor_pixel); 6466 unload_color (f, f->output_data.w32->cursor_pixel);
6484 unload_color (f, f->output_data.w32->cursor_foreground_pixel); 6467 unload_color (f, f->output_data.w32->cursor_foreground_pixel);
6485 unload_color (f, f->output_data.w32->border_pixel); 6468 unload_color (f, f->output_data.w32->border_pixel);
6486 unload_color (f, f->output_data.w32->mouse_pixel); 6469 unload_color (f, f->output_data.w32->mouse_pixel);
6487 if (f->output_data.w32->white_relief.allocated_p) 6470 if (f->output_data.w32->white_relief.allocated_p)
6516 UNBLOCK_INPUT; 6499 UNBLOCK_INPUT;
6517 } 6500 }
6518 6501
6519 6502
6520 /* Destroy the window of frame F. */ 6503 /* Destroy the window of frame F. */
6521 6504 void
6522 x_destroy_window (f) 6505 x_destroy_window (f)
6523 struct frame *f; 6506 struct frame *f;
6524 { 6507 {
6525 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 6508 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
6526 6509
6527 x_free_frame_resources (f); 6510 x_free_frame_resources (f);
6528
6529 dpyinfo->reference_count--; 6511 dpyinfo->reference_count--;
6530 } 6512 }
6531 6513
6532 6514
6533 /* Setting window manager hints. */ 6515 /* Setting window manager hints. */
6783 *current = '\0'; 6765 *current = '\0';
6784 6766
6785 return buffer; 6767 return buffer;
6786 } 6768 }
6787 6769
6788 struct w32_display_info *
6789 w32_term_init (display_name, xrm_option, resource_name)
6790 Lisp_Object display_name;
6791 char *xrm_option;
6792 char *resource_name;
6793 {
6794 struct w32_display_info *dpyinfo;
6795 HDC hdc;
6796
6797 BLOCK_INPUT;
6798
6799 if (!w32_initialized)
6800 {
6801 w32_initialize ();
6802 w32_initialized = 1;
6803 }
6804
6805 w32_initialize_display_info (display_name);
6806
6807 dpyinfo = &one_w32_display_info;
6808
6809 dpyinfo->xrdb = xrm_option ? w32_make_rdb (xrm_option) : NULL;
6810
6811 /* Put this display on the chain. */
6812 dpyinfo->next = x_display_list;
6813 x_display_list = dpyinfo;
6814
6815 hdc = GetDC (GetDesktopWindow ());
6816
6817 dpyinfo->height = GetDeviceCaps (hdc, VERTRES);
6818 dpyinfo->width = GetDeviceCaps (hdc, HORZRES);
6819 dpyinfo->root_window = GetDesktopWindow ();
6820 dpyinfo->n_planes = GetDeviceCaps (hdc, PLANES);
6821 dpyinfo->n_cbits = GetDeviceCaps (hdc, BITSPIXEL);
6822 dpyinfo->resx = GetDeviceCaps (hdc, LOGPIXELSX);
6823 dpyinfo->resy = GetDeviceCaps (hdc, LOGPIXELSY);
6824 dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE;
6825 dpyinfo->image_cache = make_image_cache ();
6826 dpyinfo->height_in = dpyinfo->height / dpyinfo->resx;
6827 dpyinfo->width_in = dpyinfo->width / dpyinfo->resy;
6828 ReleaseDC (GetDesktopWindow (), hdc);
6829
6830 /* initialise palette with white and black */
6831 {
6832 XColor color;
6833 w32_defined_color (0, "white", &color, 1);
6834 w32_defined_color (0, "black", &color, 1);
6835 }
6836
6837 /* Create Fringe Bitmaps and store them for later use.
6838
6839 On W32, bitmaps are all unsigned short, as Windows requires
6840 bitmap data to be Word aligned. For some reason they are
6841 horizontally reflected compared to how they appear on X, so we
6842 need to bitswap and convert to unsigned shorts before creating
6843 the bitmaps. */
6844 w32_init_fringe ();
6845
6846 #ifndef F_SETOWN_BUG
6847 #ifdef F_SETOWN
6848 #ifdef F_SETOWN_SOCK_NEG
6849 /* stdin is a socket here */
6850 fcntl (connection, F_SETOWN, -getpid ());
6851 #else /* ! defined (F_SETOWN_SOCK_NEG) */
6852 fcntl (connection, F_SETOWN, getpid ());
6853 #endif /* ! defined (F_SETOWN_SOCK_NEG) */
6854 #endif /* ! defined (F_SETOWN) */
6855 #endif /* F_SETOWN_BUG */
6856
6857 #ifdef SIGIO
6858 if (interrupt_input)
6859 init_sigio (connection);
6860 #endif /* ! defined (SIGIO) */
6861
6862 UNBLOCK_INPUT;
6863
6864 return dpyinfo;
6865 }
6866
6867 /* Get rid of display DPYINFO, assuming all frames are already gone. */
6868
6869 void
6870 x_delete_display (dpyinfo)
6871 struct w32_display_info *dpyinfo;
6872 {
6873 /* Discard this display from w32_display_name_list and w32_display_list.
6874 We can't use Fdelq because that can quit. */
6875 if (! NILP (w32_display_name_list)
6876 && EQ (XCAR (w32_display_name_list), dpyinfo->name_list_element))
6877 w32_display_name_list = XCDR (w32_display_name_list);
6878 else
6879 {
6880 Lisp_Object tail;
6881
6882 tail = w32_display_name_list;
6883 while (CONSP (tail) && CONSP (XCDR (tail)))
6884 {
6885 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
6886 {
6887 XSETCDR (tail, XCDR (XCDR (tail)));
6888 break;
6889 }
6890 tail = XCDR (tail);
6891 }
6892 }
6893
6894 /* free palette table */
6895 {
6896 struct w32_palette_entry * plist;
6897
6898 plist = dpyinfo->color_list;
6899 while (plist)
6900 {
6901 struct w32_palette_entry * pentry = plist;
6902 plist = plist->next;
6903 xfree (pentry);
6904 }
6905 dpyinfo->color_list = NULL;
6906 if (dpyinfo->palette)
6907 DeleteObject(dpyinfo->palette);
6908 }
6909 xfree (dpyinfo->font_table);
6910 xfree (dpyinfo->w32_id_name);
6911
6912 w32_reset_fringes ();
6913 }
6914
6915 /* Set up use of W32. */
6916
6917 DWORD WINAPI w32_msg_worker (void * arg);
6918
6919 void 6770 void
6920 x_flush (struct frame * f) 6771 x_flush (struct frame * f)
6921 { /* Nothing to do */ } 6772 { /* Nothing to do */ }
6773
6922 6774
6923 extern frame_parm_handler w32_frame_parm_handlers[]; 6775 extern frame_parm_handler w32_frame_parm_handlers[];
6924 6776
6925 static struct redisplay_interface w32_redisplay_interface = 6777 static struct redisplay_interface w32_redisplay_interface =
6926 { 6778 {
6951 w32_draw_window_cursor, 6803 w32_draw_window_cursor,
6952 w32_draw_vertical_window_border, 6804 w32_draw_vertical_window_border,
6953 w32_shift_glyphs_for_insert 6805 w32_shift_glyphs_for_insert
6954 }; 6806 };
6955 6807
6808 static void x_delete_terminal (struct terminal *term);
6809
6810 static struct terminal *
6811 w32_create_terminal (struct w32_display_info *dpyinfo)
6812 {
6813 struct terminal *terminal;
6814
6815 terminal = create_terminal ();
6816
6817 terminal->type = output_w32;
6818 terminal->display_info.w32 = dpyinfo;
6819 dpyinfo->terminal = terminal;
6820
6821 /* MSVC does not type K&R functions with no arguments correctly, and
6822 so we must explicitly cast them. */
6823 terminal->clear_frame_hook = x_clear_frame;
6824 terminal->ins_del_lines_hook = x_ins_del_lines;
6825 terminal->delete_glyphs_hook = x_delete_glyphs;
6826 terminal->ring_bell_hook = w32_ring_bell;
6827 terminal->reset_terminal_modes_hook = w32_reset_terminal_modes;
6828 terminal->set_terminal_modes_hook = w32_set_terminal_modes;
6829 terminal->update_begin_hook = x_update_begin;
6830 terminal->update_end_hook = x_update_end;
6831 terminal->set_terminal_window_hook = w32_set_terminal_window;
6832 terminal->read_socket_hook = w32_read_socket;
6833 terminal->frame_up_to_date_hook = w32_frame_up_to_date;
6834 terminal->mouse_position_hook = w32_mouse_position;
6835 terminal->frame_rehighlight_hook = w32_frame_rehighlight;
6836 terminal->frame_raise_lower_hook = w32_frame_raise_lower;
6837 // terminal->fullscreen_hook = XTfullscreen_hook;
6838 terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar;
6839 terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars;
6840 terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;
6841 terminal->judge_scroll_bars_hook = w32_judge_scroll_bars;
6842
6843 terminal->delete_frame_hook = x_destroy_window;
6844 terminal->delete_terminal_hook = x_delete_terminal;
6845
6846 terminal->rif = &w32_redisplay_interface;
6847 terminal->scroll_region_ok = 1; /* We'll scroll partial frames. */
6848 terminal->char_ins_del_ok = 1;
6849 terminal->line_ins_del_ok = 1; /* We'll just blt 'em. */
6850 terminal->fast_clear_end_of_line = 1; /* X does this well. */
6851 terminal->memory_below_frame = 0; /* We don't remember what scrolls
6852 off the bottom. */
6853
6854 #ifdef MULTI_KBOARD
6855 /* We don't yet support separate terminals on W32, so don't try to share
6856 keyboards between virtual terminals that are on the same physical
6857 terminal like X does. */
6858 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
6859 init_kboard (terminal->kboard);
6860 terminal->kboard->next_kboard = all_kboards;
6861 all_kboards = terminal->kboard;
6862 /* Don't let the initial kboard remain current longer than necessary.
6863 That would cause problems if a file loaded on startup tries to
6864 prompt in the mini-buffer. */
6865 if (current_kboard == initial_kboard)
6866 current_kboard = terminal->kboard;
6867 terminal->kboard->reference_count++;
6868 #endif
6869
6870 return terminal;
6871 }
6872
6873 static void
6874 x_delete_terminal (struct terminal *terminal)
6875 {
6876 struct w32_display_info *dpyinfo = terminal->display_info.w32;
6877 int i;
6878
6879 /* Protect against recursive calls. Fdelete_frame in
6880 delete_terminal calls us back when it deletes our last frame. */
6881 if (!terminal->name)
6882 return;
6883
6884 BLOCK_INPUT;
6885 /* Free the fonts in the font table. */
6886 for (i = 0; i < dpyinfo->n_fonts; i++)
6887 if (dpyinfo->font_table[i].name)
6888 {
6889 DeleteObject (((XFontStruct*)(dpyinfo->font_table[i].font))->hfont);
6890 }
6891
6892 x_delete_display (dpyinfo);
6893 UNBLOCK_INPUT;
6894 }
6895
6896 struct w32_display_info *
6897 w32_term_init (display_name, xrm_option, resource_name)
6898 Lisp_Object display_name;
6899 char *xrm_option;
6900 char *resource_name;
6901 {
6902 struct w32_display_info *dpyinfo;
6903 struct terminal *terminal;
6904 HDC hdc;
6905
6906 BLOCK_INPUT;
6907
6908 if (!w32_initialized)
6909 {
6910 w32_initialize ();
6911 w32_initialized = 1;
6912 }
6913
6914 w32_initialize_display_info (display_name);
6915
6916 dpyinfo = &one_w32_display_info;
6917 terminal = w32_create_terminal (dpyinfo);
6918
6919 /* Set the name of the terminal. */
6920 terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
6921 strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
6922 terminal->name[SBYTES (display_name)] = 0;
6923
6924 dpyinfo->xrdb = xrm_option ? w32_make_rdb (xrm_option) : NULL;
6925
6926 /* Put this display on the chain. */
6927 dpyinfo->next = x_display_list;
6928 x_display_list = dpyinfo;
6929
6930 hdc = GetDC (GetDesktopWindow ());
6931
6932 dpyinfo->height = GetDeviceCaps (hdc, VERTRES);
6933 dpyinfo->width = GetDeviceCaps (hdc, HORZRES);
6934 dpyinfo->root_window = GetDesktopWindow ();
6935 dpyinfo->n_planes = GetDeviceCaps (hdc, PLANES);
6936 dpyinfo->n_cbits = GetDeviceCaps (hdc, BITSPIXEL);
6937 dpyinfo->resx = GetDeviceCaps (hdc, LOGPIXELSX);
6938 dpyinfo->resy = GetDeviceCaps (hdc, LOGPIXELSY);
6939 dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE;
6940 dpyinfo->image_cache = make_image_cache ();
6941 dpyinfo->height_in = dpyinfo->height / dpyinfo->resx;
6942 dpyinfo->width_in = dpyinfo->width / dpyinfo->resy;
6943 ReleaseDC (GetDesktopWindow (), hdc);
6944
6945 /* initialise palette with white and black */
6946 {
6947 XColor color;
6948 w32_defined_color (0, "white", &color, 1);
6949 w32_defined_color (0, "black", &color, 1);
6950 }
6951
6952 /* Add the default keyboard. */
6953 add_keyboard_wait_descriptor (0);
6954
6955 /* Create Fringe Bitmaps and store them for later use.
6956
6957 On W32, bitmaps are all unsigned short, as Windows requires
6958 bitmap data to be Word aligned. For some reason they are
6959 horizontally reflected compared to how they appear on X, so we
6960 need to bitswap and convert to unsigned shorts before creating
6961 the bitmaps. */
6962 w32_init_fringe (terminal->rif);
6963
6964 #ifndef F_SETOWN_BUG
6965 #ifdef F_SETOWN
6966 #ifdef F_SETOWN_SOCK_NEG
6967 /* stdin is a socket here */
6968 fcntl (connection, F_SETOWN, -getpid ());
6969 #else /* ! defined (F_SETOWN_SOCK_NEG) */
6970 fcntl (connection, F_SETOWN, getpid ());
6971 #endif /* ! defined (F_SETOWN_SOCK_NEG) */
6972 #endif /* ! defined (F_SETOWN) */
6973 #endif /* F_SETOWN_BUG */
6974
6975 #ifdef SIGIO
6976 if (interrupt_input)
6977 init_sigio (connection);
6978 #endif /* ! defined (SIGIO) */
6979
6980 UNBLOCK_INPUT;
6981
6982 return dpyinfo;
6983 }
6984
6985 /* Get rid of display DPYINFO, assuming all frames are already gone. */
6986 void
6987 x_delete_display (dpyinfo)
6988 struct w32_display_info *dpyinfo;
6989 {
6990 /* Discard this display from w32_display_name_list and w32_display_list.
6991 We can't use Fdelq because that can quit. */
6992 if (! NILP (w32_display_name_list)
6993 && EQ (XCAR (w32_display_name_list), dpyinfo->name_list_element))
6994 w32_display_name_list = XCDR (w32_display_name_list);
6995 else
6996 {
6997 Lisp_Object tail;
6998
6999 tail = w32_display_name_list;
7000 while (CONSP (tail) && CONSP (XCDR (tail)))
7001 {
7002 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
7003 {
7004 XSETCDR (tail, XCDR (XCDR (tail)));
7005 break;
7006 }
7007 tail = XCDR (tail);
7008 }
7009 }
7010
7011 /* free palette table */
7012 {
7013 struct w32_palette_entry * plist;
7014
7015 plist = dpyinfo->color_list;
7016 while (plist)
7017 {
7018 struct w32_palette_entry * pentry = plist;
7019 plist = plist->next;
7020 xfree (pentry);
7021 }
7022 dpyinfo->color_list = NULL;
7023 if (dpyinfo->palette)
7024 DeleteObject(dpyinfo->palette);
7025 }
7026 xfree (dpyinfo->font_table);
7027 xfree (dpyinfo->w32_id_name);
7028
7029 w32_reset_fringes ();
7030 }
7031
7032 /* Set up use of W32. */
7033
7034 DWORD WINAPI w32_msg_worker (void * arg);
7035
6956 static void 7036 static void
6957 w32_initialize () 7037 w32_initialize ()
6958 { 7038 {
6959 rif = &w32_redisplay_interface;
6960
6961 /* MSVC does not type K&R functions with no arguments correctly, and
6962 so we must explicitly cast them. */
6963 clear_frame_hook = (void (*)(void)) x_clear_frame;
6964 ring_bell_hook = (void (*)(void)) w32_ring_bell;
6965 update_begin_hook = x_update_begin;
6966 update_end_hook = x_update_end;
6967
6968 read_socket_hook = w32_read_socket;
6969
6970 frame_up_to_date_hook = w32_frame_up_to_date;
6971
6972 mouse_position_hook = w32_mouse_position;
6973 frame_rehighlight_hook = w32_frame_rehighlight;
6974 frame_raise_lower_hook = w32_frame_raise_lower;
6975 set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar;
6976 condemn_scroll_bars_hook = w32_condemn_scroll_bars;
6977 redeem_scroll_bar_hook = w32_redeem_scroll_bar;
6978 judge_scroll_bars_hook = w32_judge_scroll_bars;
6979
6980 scroll_region_ok = 1; /* we'll scroll partial frames */
6981 char_ins_del_ok = 1;
6982 line_ins_del_ok = 1; /* we'll just blt 'em */
6983 fast_clear_end_of_line = 1; /* X does this well */
6984 memory_below_frame = 0; /* we don't remember what scrolls
6985 off the bottom */
6986 baud_rate = 19200; 7039 baud_rate = 19200;
6987 7040
6988 w32_system_caret_hwnd = NULL; 7041 w32_system_caret_hwnd = NULL;
6989 w32_system_caret_height = 0; 7042 w32_system_caret_height = 0;
6990 w32_system_caret_x = 0; 7043 w32_system_caret_x = 0;