]> code.delx.au - gnu-emacs/blob - src/w32term.h
Merge from emacs-24; up to 2014-06-26T06:55:15Z!rgm@gnu.org
[gnu-emacs] / src / w32term.h
1 /* Definitions and headers for communication on the Microsoft Windows API.
2 Copyright (C) 1995, 2001-2014 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
19 /* Added by Kevin Gallo */
20
21 #include "w32gui.h"
22 #include "frame.h"
23 #include "atimer.h"
24
25 \f
26 #define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0)
27 #define WHITE_PIX_DEFAULT(f) PALETTERGB(255,255,255)
28
29 #define CP_DEFAULT 1004
30
31 /* Indicates whether we are in the readsocket call and the message we
32 are processing in the current loop */
33
34 extern MSG CurMsg;
35 extern BOOL bUseDflt;
36
37 /* Structure recording bitmaps and reference count.
38 If REFCOUNT is 0 then this record is free to be reused. */
39
40 struct w32_bitmap_record
41 {
42 Pixmap pixmap;
43 char *file;
44 HINSTANCE hinst; /* Used to load the file */
45 int refcount;
46 /* Record some info about this pixmap. */
47 int height, width, depth;
48 };
49
50 struct w32_palette_entry {
51 struct w32_palette_entry * next;
52 PALETTEENTRY entry;
53 #if 0
54 unsigned refcount;
55 #endif
56 };
57
58 extern void w32_regenerate_palette (struct frame *f);
59 extern void w32_fullscreen_rect (HWND hwnd, int fsmode, RECT normal,
60 RECT *rect);
61
62 \f
63 /* For each display (currently only one on w32), we have a structure that
64 records information about it. */
65
66 struct w32_display_info
67 {
68 /* Chain of all w32_display_info structures. */
69 struct w32_display_info *next;
70
71 /* The generic display parameters corresponding to this w32 display. */
72 struct terminal *terminal;
73
74 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */
75 Lisp_Object name_list_element;
76
77 /* Number of frames that are on this display. */
78 int reference_count;
79
80 /* Dots per inch of the screen. */
81 double resx, resy;
82
83 /* Number of planes on this screen. */
84 int n_planes;
85
86 /* Number of bits per pixel on this screen. */
87 int n_cbits;
88
89 /* Mask of things that cause the mouse to be grabbed. */
90 int grabbed;
91
92 /* Emacs bitmap-id of the default icon bitmap for this frame.
93 Or -1 if none has been allocated yet. */
94 ptrdiff_t icon_bitmap_id;
95
96 /* The root window of this screen. */
97 Window root_window;
98
99 /* The cursor to use for vertical scroll bars. */
100 Cursor vertical_scroll_bar_cursor;
101
102 /* The cursor to use for horizontal scroll bars. */
103 Cursor horizontal_scroll_bar_cursor;
104
105 /* Resource data base */
106 XrmDatabase xrdb;
107
108 /* color palette information. */
109 int has_palette;
110 struct w32_palette_entry * color_list;
111 unsigned num_colors;
112 HPALETTE palette;
113
114 /* deferred action flags checked when starting frame update. */
115 int regen_palette;
116
117 /* Keystroke that has been faked by Emacs and will be ignored when
118 received; value is reset after key is received. */
119 int faked_key;
120
121 /* Minimum width over all characters in all fonts in font_table. */
122 int smallest_char_width;
123
124 /* Minimum font height over all fonts in font_table. */
125 int smallest_font_height;
126
127 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
128 XGCValues *scratch_cursor_gc;
129
130 /* Information about the range of text currently shown in
131 mouse-face. */
132 Mouse_HLInfo mouse_highlight;
133
134 char *w32_id_name;
135
136 /* The number of fonts actually stored in w32_font_table.
137 font_table[n] is used and valid if 0 <= n < n_fonts. 0 <=
138 n_fonts <= font_table_size. and font_table[i].name != 0. */
139 int n_fonts;
140
141 /* Pointer to bitmap records. */
142 struct w32_bitmap_record *bitmaps;
143
144 /* Allocated size of bitmaps field. */
145 ptrdiff_t bitmaps_size;
146
147 /* Last used bitmap index. */
148 ptrdiff_t bitmaps_last;
149
150 /* The frame (if any) which has the window that has keyboard focus.
151 Zero if none. This is examined by Ffocus_frame in w32fns.c. Note
152 that a mere EnterNotify event can set this; if you need to know the
153 last frame specified in a FocusIn or FocusOut event, use
154 w32_focus_event_frame. */
155 struct frame *w32_focus_frame;
156
157 /* The last frame mentioned in a FocusIn or FocusOut event. This is
158 separate from w32_focus_frame, because whether or not LeaveNotify
159 events cause us to lose focus depends on whether or not we have
160 received a FocusIn event for it. */
161 struct frame *w32_focus_event_frame;
162
163 /* The frame which currently has the visual highlight, and should get
164 keyboard input (other sorts of input have the frame encoded in the
165 event). It points to the focus frame's selected window's
166 frame. It differs from w32_focus_frame when we're using a global
167 minibuffer. */
168 struct frame *x_highlight_frame;
169
170 /* The frame waiting to be auto-raised in w32_read_socket. */
171 struct frame *w32_pending_autoraise_frame;
172
173 /* The frame where the mouse was last time we reported a mouse event. */
174 struct frame *last_mouse_frame;
175
176 /* The frame where the mouse was last time we reported a mouse motion. */
177 struct frame *last_mouse_motion_frame;
178
179 /* The frame where the mouse was last time we reported a mouse position. */
180 struct frame *last_mouse_glyph_frame;
181
182 /* Position where the mouse was last time we reported a motion.
183 This is a position on last_mouse_motion_frame. */
184 int last_mouse_motion_x;
185 int last_mouse_motion_y;
186
187 /* Where the mouse was last time we reported a mouse position.
188 This is a rectangle on last_mouse_glyph_frame. */
189 RECT last_mouse_glyph;
190
191 /* The scroll bar in which the last motion event occurred. */
192 struct scroll_bar *last_mouse_scroll_bar;
193
194 /* Mouse position on the scroll bar above.
195 FIXME: shouldn't it be a member of struct scroll_bar? */
196 int last_mouse_scroll_bar_pos;
197
198 /* Time of last mouse movement. */
199 Time last_mouse_movement_time;
200
201 /* Value returned by last call of ShowCursor. */
202 int cursor_display_counter;
203 };
204
205 /* This is a chain of structures for all the displays currently in use. */
206 extern struct w32_display_info *x_display_list;
207 extern struct w32_display_info one_w32_display_info;
208
209 /* These 2 are set by w32fns.c and examined in w32term.c. */
210 extern HMENU current_popup_menu;
211 extern int menubar_in_use;
212
213 extern struct frame *x_window_to_frame (struct w32_display_info *, HWND);
214
215 struct w32_display_info *x_display_info_for_name (Lisp_Object);
216
217 Lisp_Object display_x_get_resource (struct w32_display_info *,
218 Lisp_Object, Lisp_Object,
219 Lisp_Object, Lisp_Object);
220
221 /* also defined in xterm.h XXX: factor out to common header */
222
223 extern struct w32_display_info *w32_term_init (Lisp_Object,
224 char *, char *);
225 extern int w32_defined_color (struct frame *f, const char *color,
226 XColor *color_def, int alloc);
227 extern void x_set_window_size (struct frame *f, int change_grav,
228 int width, int height, bool pixelwise);
229 extern int x_display_pixel_height (struct w32_display_info *);
230 extern int x_display_pixel_width (struct w32_display_info *);
231 extern Lisp_Object x_get_focus_frame (struct frame *);
232 extern void x_make_frame_visible (struct frame *f);
233 extern void x_make_frame_invisible (struct frame *f);
234 extern void x_iconify_frame (struct frame *f);
235 extern void x_set_frame_alpha (struct frame *f);
236 extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
237 extern void x_set_tool_bar_lines (struct frame *f,
238 Lisp_Object value,
239 Lisp_Object oldval);
240 extern void x_set_internal_border_width (struct frame *f,
241 Lisp_Object value,
242 Lisp_Object oldval);
243 extern void x_activate_menubar (struct frame *);
244 extern int x_bitmap_icon (struct frame *, Lisp_Object);
245 extern void initialize_frame_menubar (struct frame *);
246 extern void x_free_frame_resources (struct frame *);
247 extern void x_real_positions (struct frame *, int *, int *);
248
249 /* w32inevt.c */
250 extern int w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId);
251 extern int w32_kbd_mods_to_emacs (DWORD mods, WORD key);
252
253
254 extern Lisp_Object x_get_focus_frame (struct frame *);
255
256 /* w32console.c */
257 extern void w32con_hide_cursor (void);
258 extern void w32con_show_cursor (void);
259
260 \f
261 #define PIX_TYPE COLORREF
262
263 /* Each W32 frame object points to its own struct w32_display object
264 in the output_data.w32 field. The w32_display structure contains all
265 the information that is specific to W32 windows. */
266
267 /* Put some things in x_output for compatibility.
268 NTEMACS_TODO: Move all common things here to eliminate unnecessary
269 diffs between X and w32 code. */
270 struct x_output
271 {
272 /* Keep track of focus. May be EXPLICIT if we received a FocusIn for this
273 frame, or IMPLICIT if we received an EnterNotify.
274 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
275 int focus_state;
276 };
277
278 enum
279 {
280 /* Values for focus_state, used as bit mask.
281 EXPLICIT means we received a FocusIn for the frame and know it has
282 the focus. IMPLICIT means we received an EnterNotify and the frame
283 may have the focus if no window manager is running.
284 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
285 FOCUS_NONE = 0,
286 FOCUS_IMPLICIT = 1,
287 FOCUS_EXPLICIT = 2
288 };
289
290 struct w32_output
291 {
292 /* Placeholder for things accessed through output_data.x. */
293 struct x_output x_compatible;
294
295 /* Menubar "widget" handle. */
296 HMENU menubar_widget;
297
298 /* Original palette (used to deselect real palette after drawing) */
299 HPALETTE old_palette;
300
301 /* Here are the Graphics Contexts for the default font. */
302 XGCValues *cursor_gc; /* cursor drawing */
303
304 /* The window used for this frame.
305 May be zero while the frame object is being created
306 and the window has not yet been created. */
307 Window window_desc;
308
309 /* The window that is the parent of this window.
310 Usually this is a window that was made by the window manager,
311 but it can be the root window, and it can be explicitly specified
312 (see the explicit_parent field, below). */
313 Window parent_desc;
314
315 /* Default ASCII font of this frame. */
316 struct font *font;
317
318 /* The baseline offset of the default ASCII font. */
319 int baseline_offset;
320
321 /* If a fontset is specified for this frame instead of font, this
322 value contains an ID of the fontset, else -1. */
323 int fontset;
324
325 /* Pixel values used for various purposes.
326 border_pixel may be -1 meaning use a gray tile. */
327 COLORREF cursor_pixel;
328 COLORREF border_pixel;
329 COLORREF mouse_pixel;
330 COLORREF cursor_foreground_pixel;
331
332 /* Foreground color for scroll bars. A value of -1 means use the
333 default (black for non-toolkit scroll bars). */
334 COLORREF scroll_bar_foreground_pixel;
335
336 /* Background color for scroll bars. A value of -1 means use the
337 default (background color of the frame for non-toolkit scroll
338 bars). */
339 COLORREF scroll_bar_background_pixel;
340
341 /* Descriptor for the cursor in use for this window. */
342 Cursor text_cursor;
343 Cursor nontext_cursor;
344 Cursor modeline_cursor;
345 Cursor hand_cursor;
346 Cursor hourglass_cursor;
347 Cursor horizontal_drag_cursor;
348 Cursor vertical_drag_cursor;
349
350 /* Non-zero means hourglass cursor is currently displayed. */
351 unsigned hourglass_p : 1;
352
353 /* Non-hourglass cursor that is currently active. */
354 Cursor current_cursor;
355
356 DWORD dwStyle;
357
358 /* This is the Emacs structure for the display this frame is on. */
359 /* struct w32_display_info *display_info; */
360
361 /* Nonzero means our parent is another application's window
362 and was explicitly specified. */
363 unsigned explicit_parent : 1;
364
365 /* Nonzero means tried already to make this frame visible. */
366 unsigned asked_for_visible : 1;
367
368 /* Nonzero means menubar is currently active. */
369 unsigned menubar_active : 1;
370
371 /* Relief GCs, colors etc. */
372 struct relief
373 {
374 XGCValues *gc;
375 unsigned long pixel;
376 }
377 black_relief, white_relief;
378
379 /* The background for which the above relief GCs were set up.
380 They are changed only when a different background is involved. */
381 unsigned long relief_background;
382
383 /* Frame geometry and full-screen mode before it was resized by
384 specifying the 'fullscreen' frame parameter. Used to restore the
385 geometry when 'fullscreen' is reset to nil. */
386 WINDOWPLACEMENT normal_placement;
387 int prev_fsmode;
388 };
389
390 extern struct w32_output w32term_display;
391
392 /* Return the X output data for frame F. */
393 #define FRAME_X_OUTPUT(f) ((f)->output_data.w32)
394
395 /* Return the window associated with the frame F. */
396 #define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc)
397 #define FRAME_X_WINDOW(f) FRAME_W32_WINDOW (f)
398
399 #define FRAME_FONT(f) ((f)->output_data.w32->font)
400 #define FRAME_FONTSET(f) ((f)->output_data.w32->fontset)
401 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset)
402
403 /* This gives the w32_display_info structure for the display F is on. */
404 #define FRAME_DISPLAY_INFO(f) (&one_w32_display_info)
405
406 /* This is the `Display *' which frame F is on. */
407 #define FRAME_X_DISPLAY(f) (0)
408
409 #define FRAME_NORMAL_PLACEMENT(F) ((F)->output_data.w32->normal_placement)
410 #define FRAME_PREV_FSMODE(F) ((F)->output_data.w32->prev_fsmode)
411
412 \f
413 /* W32-specific scroll bar stuff. */
414
415 /* We represent scroll bars as lisp vectors. This allows us to place
416 references to them in windows without worrying about whether we'll
417 end up with windows referring to dead scroll bars; the garbage
418 collector will free it when its time comes.
419
420 We use struct scroll_bar as a template for accessing fields of the
421 vector. */
422
423 struct scroll_bar {
424
425 /* This field is shared by all vectors. */
426 struct vectorlike_header header;
427
428 /* The window we're a scroll bar for. */
429 Lisp_Object window;
430
431 /* The next and previous in the chain of scroll bars in this frame. */
432 Lisp_Object next, prev;
433
434 /* The window representing this scroll bar. Since this is a full
435 32-bit quantity, we store it split into two 32-bit values. */
436 Lisp_Object w32_window_low, w32_window_high;
437
438 /* Same as above for the widget. */
439 Lisp_Object w32_widget_low, w32_widget_high;
440
441 /* The position and size of the scroll bar in pixels, relative to the
442 frame. */
443 int top, left, width, height;
444
445 /* The starting and ending positions of the handle, relative to the
446 handle area (i.e. zero is the top position, not
447 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
448 hasn't been drawn yet.
449
450 These are not actually the locations where the beginning and end
451 are drawn; in order to keep handles from becoming invisible when
452 editing large files, we establish a minimum height by always
453 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
454 where they would be normally; the bottom and top are in a
455 different co-ordinate system. */
456 int start, end;
457
458 /* If the scroll bar handle is currently being dragged by the user,
459 this is the number of pixels from the top of the handle to the
460 place where the user grabbed it. If the handle isn't currently
461 being dragged, this is Qnil. */
462 int dragging;
463
464 /* true if the scroll bar is horizontal. */
465 bool horizontal;
466 };
467
468 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
469 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
470
471 #ifdef _WIN64
472 /* Building a 64-bit C integer from two 32-bit lisp integers. */
473 #define SCROLL_BAR_PACK(low, high) (XINT (high) << 32 | XINT (low))
474
475 /* Setting two lisp integers to the low and high words of a 64-bit C int. */
476 #define SCROLL_BAR_UNPACK(low, high, int64) \
477 (XSETINT ((low), ((DWORDLONG)(int64)) & 0xffffffff), \
478 XSETINT ((high), ((DWORDLONG)(int64) >> 32) & 0xffffffff))
479 #else /* not _WIN64 */
480 /* Building a 32-bit C integer from two 16-bit lisp integers. */
481 #define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
482
483 /* Setting two lisp integers to the low and high words of a 32-bit C int. */
484 #define SCROLL_BAR_UNPACK(low, high, int32) \
485 (XSETINT ((low), (int32) & 0xffff), \
486 XSETINT ((high), ((int32) >> 16) & 0xffff))
487 #endif /* not _WIN64 */
488
489 /* Extract the window id of the scroll bar from a struct scroll_bar. */
490 #define SCROLL_BAR_W32_WINDOW(ptr) \
491 ((Window) SCROLL_BAR_PACK ((ptr)->w32_window_low, (ptr)->w32_window_high))
492
493 /* Store a window id in a struct scroll_bar. */
494 #define SET_SCROLL_BAR_W32_WINDOW(ptr, id) \
495 (SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (intptr_t) id))
496
497 /* Return the inside width of a vertical scroll bar, given the outside
498 width. */
499 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f,width) \
500 ((width) \
501 - VERTICAL_SCROLL_BAR_LEFT_BORDER \
502 - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
503
504 /* Return the length of the rectangle within which the top of the
505 handle must stay. This isn't equivalent to the inside height,
506 because the scroll bar handle has a minimum height.
507
508 This is the real range of motion for the scroll bar, so when we're
509 scaling buffer positions to scroll bar positions, we use this, not
510 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
511 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f,height) \
512 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
513
514 /* Return the inside height of vertical scroll bar, given the outside
515 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
516 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f,height) \
517 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
518
519 /* Return the inside height of a horizontal scroll bar, given the
520 outside height. */
521 #define HORIZONTAL_SCROLL_BAR_INSIDE_HEIGHT(f,height) \
522 ((height) \
523 - HORIZONTAL_SCROLL_BAR_TOP_BORDER \
524 - HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER)
525
526 /* Return the length of the rectangle within which the left of the
527 handle must stay. This isn't equivalent to the inside width,
528 because the scroll bar handle has a minimum width.
529
530 This is the real range of motion for the scroll bar, so when we're
531 scaling buffer positions to scroll bar positions, we use this, not
532 HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH. */
533 #define HORIZONTAL_SCROLL_BAR_LEFT_RANGE(f,width) \
534 (HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH (f, width) - HORIZONTAL_SCROLL_BAR_MIN_HANDLE)
535
536 /* Return the inside width of horizontal scroll bar, given the outside
537 width. See HORIZONTAL_SCROLL_BAR_LEFT_RANGE too. */
538 #define HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH(f,width) \
539 ((width) - HORIZONTAL_SCROLL_BAR_LEFT_BORDER - HORIZONTAL_SCROLL_BAR_RIGHT_BORDER)
540
541
542 /* Border widths for scroll bars.
543
544 Scroll bar windows don't have any borders; their border width is
545 set to zero, and we redraw borders ourselves. This makes the code
546 a bit cleaner, since we don't have to convert between outside width
547 (used when relating to the rest of the screen) and inside width
548 (used when sizing and drawing the scroll bar window itself).
549
550 The handle moves up and down/back and forth in a rectangle inset
551 from the edges of the scroll bar. These are widths by which we
552 inset the handle boundaries from the scroll bar edges. */
553 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (0)
554 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (0)
555 #define VERTICAL_SCROLL_BAR_TOP_BORDER (vertical_scroll_bar_top_border)
556 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (vertical_scroll_bar_bottom_border)
557
558 #define HORIZONTAL_SCROLL_BAR_LEFT_BORDER (horizontal_scroll_bar_left_border)
559 #define HORIZONTAL_SCROLL_BAR_RIGHT_BORDER (horizontal_scroll_bar_right_border)
560 #define HORIZONTAL_SCROLL_BAR_TOP_BORDER (0)
561 #define HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER (0)
562
563 /* Minimum lengths for scroll bar handles, in pixels. */
564 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (vertical_scroll_bar_min_handle)
565 #define HORIZONTAL_SCROLL_BAR_MIN_HANDLE (horizontal_scroll_bar_min_handle)
566
567 struct frame; /* from frame.h */
568
569 extern void w32_fill_rect (struct frame *, HDC, COLORREF, RECT *);
570 extern void w32_clear_window (struct frame *);
571
572 #define w32_fill_area(f,hdc,pix,x,y,nx,ny) \
573 do { \
574 RECT rect; \
575 rect.left = x; \
576 rect.top = y; \
577 rect.right = x + nx; \
578 rect.bottom = y + ny; \
579 w32_fill_rect (f,hdc,pix,&rect); \
580 } while (0)
581
582 #define w32_fill_area_abs(f,hdc,pix,x0,y0,x1,y1) \
583 do { \
584 RECT rect; \
585 rect.left = x0; \
586 rect.top = y0; \
587 rect.right = x1; \
588 rect.bottom = y1; \
589 w32_fill_rect (f,hdc,pix,&rect); \
590 } while (0)
591
592 #define w32_clear_rect(f,hdc,lprect) \
593 w32_fill_rect (f, hdc, FRAME_BACKGROUND_PIXEL (f), lprect)
594
595 #define w32_clear_area(f,hdc,px,py,nx,ny) \
596 w32_fill_area (f, hdc, FRAME_BACKGROUND_PIXEL (f), px, py, nx, ny)
597
598 /* Define for earlier versions of Visual C */
599 #ifndef WM_MOUSEWHEEL
600 #define WM_MOUSEWHEEL (WM_MOUSELAST + 1)
601 #endif /* WM_MOUSEWHEEL */
602 #ifndef MSH_MOUSEWHEEL
603 #define MSH_MOUSEWHEEL "MSWHEEL_ROLLMSG"
604 #endif /* MSH_MOUSEWHEEL */
605 #ifndef WM_XBUTTONDOWN
606 #define WM_XBUTTONDOWN (WM_MOUSEWHEEL + 1)
607 #define WM_XBUTTONUP (WM_MOUSEWHEEL + 2)
608 #endif /* WM_XBUTTONDOWN */
609 #ifndef WM_MOUSEHWHEEL
610 #define WM_MOUSEHWHEEL (WM_MOUSEWHEEL + 4)
611 #endif /* WM_MOUSEHWHEEL */
612 #ifndef WM_APPCOMMAND
613 #define WM_APPCOMMAND 0x319
614 #define GET_APPCOMMAND_LPARAM(lParam) (HIWORD(lParam) & 0x7fff)
615 #endif
616 #ifndef WM_UNICHAR
617 #define WM_UNICHAR 0x109
618 #endif
619 #ifndef UNICODE_NOCHAR
620 #define UNICODE_NOCHAR 0xFFFF
621 #endif
622
623 #define WM_EMACS_START (WM_USER + 1)
624 #define WM_EMACS_KILL (WM_EMACS_START + 0)
625 #define WM_EMACS_CREATEWINDOW (WM_EMACS_START + 1)
626 #define WM_EMACS_DONE (WM_EMACS_START + 2)
627 #define WM_EMACS_CREATEVSCROLLBAR (WM_EMACS_START + 3)
628 #define WM_EMACS_CREATEHSCROLLBAR (WM_EMACS_START + 4)
629 #define WM_EMACS_SHOWWINDOW (WM_EMACS_START + 5)
630 #define WM_EMACS_SETWINDOWPOS (WM_EMACS_START + 6)
631 #define WM_EMACS_DESTROYWINDOW (WM_EMACS_START + 7)
632 #define WM_EMACS_TRACKPOPUPMENU (WM_EMACS_START + 8)
633 #define WM_EMACS_SETFOCUS (WM_EMACS_START + 9)
634 #define WM_EMACS_SETFOREGROUND (WM_EMACS_START + 10)
635 #define WM_EMACS_SETLOCALE (WM_EMACS_START + 11)
636 #define WM_EMACS_SETKEYBOARDLAYOUT (WM_EMACS_START + 12)
637 #define WM_EMACS_REGISTER_HOT_KEY (WM_EMACS_START + 13)
638 #define WM_EMACS_UNREGISTER_HOT_KEY (WM_EMACS_START + 14)
639 #define WM_EMACS_TOGGLE_LOCK_KEY (WM_EMACS_START + 15)
640 #define WM_EMACS_TRACK_CARET (WM_EMACS_START + 16)
641 #define WM_EMACS_DESTROY_CARET (WM_EMACS_START + 17)
642 #define WM_EMACS_SHOW_CARET (WM_EMACS_START + 18)
643 #define WM_EMACS_HIDE_CARET (WM_EMACS_START + 19)
644 #define WM_EMACS_SETCURSOR (WM_EMACS_START + 20)
645 #define WM_EMACS_SHOWCURSOR (WM_EMACS_START + 21)
646 #define WM_EMACS_PAINT (WM_EMACS_START + 22)
647 #define WM_EMACS_BRINGTOTOP (WM_EMACS_START + 23)
648 #define WM_EMACS_INPUT_READY (WM_EMACS_START + 24)
649 #define WM_EMACS_FILENOTIFY (WM_EMACS_START + 25)
650 #define WM_EMACS_END (WM_EMACS_START + 26)
651
652 #define WND_FONTWIDTH_INDEX (0)
653 #define WND_LINEHEIGHT_INDEX (4)
654 #define WND_BORDER_INDEX (8)
655 #define WND_VSCROLLBAR_INDEX (12)
656 #define WND_HSCROLLBAR_INDEX (16)
657 #define WND_BACKGROUND_INDEX (20)
658 #define WND_LAST_INDEX (24)
659
660 #define WND_EXTRA_BYTES (WND_LAST_INDEX)
661
662 extern DWORD dwWindowsThreadId;
663 extern HANDLE hWindowsThread;
664 extern DWORD dwMainThreadId;
665 extern HANDLE hMainThread;
666
667 typedef struct W32Msg {
668 MSG msg;
669 DWORD dwModifiers;
670 RECT rect;
671 } W32Msg;
672
673 extern BOOL prepend_msg (W32Msg *lpmsg);
674
675 /* Structure for recording message when input thread must return a
676 result that depends on lisp thread to compute. Lisp thread can
677 complete deferred messages out of order. */
678 typedef struct deferred_msg
679 {
680 struct deferred_msg * next;
681 W32Msg w32msg;
682 LRESULT result;
683 int completed;
684 } deferred_msg;
685
686 extern CRITICAL_SECTION critsect;
687
688 extern void init_crit (void);
689 extern void delete_crit (void);
690
691 extern void signal_quit (void);
692
693 #define enter_crit() EnterCriticalSection (&critsect)
694 #define leave_crit() LeaveCriticalSection (&critsect)
695
696 extern void select_palette (struct frame * f, HDC hdc);
697 extern void deselect_palette (struct frame * f, HDC hdc);
698 extern HDC get_frame_dc (struct frame * f);
699 extern int release_frame_dc (struct frame * f, HDC hDC);
700
701 extern int drain_message_queue (void);
702
703 extern BOOL get_next_msg (W32Msg *, BOOL);
704 extern BOOL post_msg (W32Msg *);
705 extern void complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result);
706
707 extern BOOL parse_button (int, int, int *, int *);
708
709 extern void w32_sys_ring_bell (struct frame *f);
710 extern void x_delete_display (struct w32_display_info *dpyinfo);
711
712 extern volatile int notification_buffer_in_use;
713 extern BYTE file_notifications[16384];
714 extern DWORD notifications_size;
715 extern void *notifications_desc;
716 extern Lisp_Object w32_get_watch_object (void *);
717 extern Lisp_Object lispy_file_action (DWORD);
718 extern int handle_file_notifications (struct input_event *);
719
720 extern void w32_initialize_display_info (Lisp_Object);
721 extern void initialize_w32_display (struct terminal *, int *, int *);
722
723 /* Keypad command key support. W32 doesn't have virtual keys defined
724 for the function keys on the keypad (they are mapped to the standard
725 function keys), so we define our own. */
726 #define VK_NUMPAD_BEGIN 0x92
727 #define VK_NUMPAD_CLEAR (VK_NUMPAD_BEGIN + 0)
728 #define VK_NUMPAD_ENTER (VK_NUMPAD_BEGIN + 1)
729 #define VK_NUMPAD_PRIOR (VK_NUMPAD_BEGIN + 2)
730 #define VK_NUMPAD_NEXT (VK_NUMPAD_BEGIN + 3)
731 #define VK_NUMPAD_END (VK_NUMPAD_BEGIN + 4)
732 #define VK_NUMPAD_HOME (VK_NUMPAD_BEGIN + 5)
733 #define VK_NUMPAD_LEFT (VK_NUMPAD_BEGIN + 6)
734 #define VK_NUMPAD_UP (VK_NUMPAD_BEGIN + 7)
735 #define VK_NUMPAD_RIGHT (VK_NUMPAD_BEGIN + 8)
736 #define VK_NUMPAD_DOWN (VK_NUMPAD_BEGIN + 9)
737 #define VK_NUMPAD_INSERT (VK_NUMPAD_BEGIN + 10)
738 #define VK_NUMPAD_DELETE (VK_NUMPAD_BEGIN + 11)
739
740 #ifndef VK_LWIN
741 /* Older compiler environments don't have these defined. */
742 #define VK_LWIN 0x5B
743 #define VK_RWIN 0x5C
744 #define VK_APPS 0x5D
745 #endif
746
747 /* Support for treating Windows and Apps keys as modifiers. These
748 constants must not overlap with any of the dwControlKeyState flags in
749 KEY_EVENT_RECORD. */
750 #define LEFT_WIN_PRESSED 0x8000
751 #define RIGHT_WIN_PRESSED 0x4000
752 #define APPS_PRESSED 0x2000
753
754 /* The current ANSI input codepage for GUI sessions. */
755 extern int w32_keyboard_codepage;
756
757 /* When compiling on Windows 9x/ME and NT 3.x, the following are not defined
758 (even though they are supported on 98 and ME. */
759 #ifndef WM_MOUSELEAVE
760 #define WM_MOUSELEAVE 0x02A3
761 #define TME_LEAVE 0x00000002;
762
763 typedef struct tagTRACKMOUSEEVENT
764 {
765 DWORD cbSize;
766 DWORD dwFlags;
767 HWND hwndTrack;
768 DWORD dwHoverTime;
769 } TRACKMOUSEEVENT;
770 #endif
771
772 struct image;
773 struct face;
774
775 XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
776
777 typedef DWORD (WINAPI * ClipboardSequence_Proc) (void);
778 typedef BOOL (WINAPI * AppendMenuW_Proc) (
779 IN HMENU,
780 IN UINT,
781 IN UINT_PTR,
782 IN LPCWSTR);
783
784 extern HWND w32_system_caret_hwnd;
785 extern int w32_system_caret_height;
786 extern int w32_system_caret_x;
787 extern int w32_system_caret_y;
788 extern struct window *w32_system_caret_window;
789 extern int w32_system_caret_hdr_height;
790 extern int w32_system_caret_mode_height;
791
792 #ifdef _MSC_VER
793 #ifndef EnumSystemLocales
794 /* MSVC headers define these only for _WIN32_WINNT >= 0x0500. */
795 typedef BOOL (CALLBACK *LOCALE_ENUMPROCA)(LPSTR);
796 typedef BOOL (CALLBACK *LOCALE_ENUMPROCW)(LPWSTR);
797 BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA,DWORD);
798 BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW,DWORD);
799 #ifdef UNICODE
800 #define EnumSystemLocales EnumSystemLocalesW
801 #else
802 #define EnumSystemLocales EnumSystemLocalesA
803 #endif
804 #endif
805 #endif
806
807 #if EMACSDEBUG
808 extern const char*
809 w32_name_of_message (UINT msg);
810 #endif /* EMACSDEBUG */
811
812 #ifdef NTGUI_UNICODE
813 extern Lisp_Object ntgui_encode_system (Lisp_Object str);
814 #define GUISTR(x) (L ## x)
815 #define GUI_ENCODE_FILE GUI_ENCODE_SYSTEM
816 #define GUI_ENCODE_SYSTEM(x) ntgui_encode_system (x)
817 #define GUI_FN(fn) fn ## W
818 typedef wchar_t guichar_t;
819 #else /* !NTGUI_UNICODE */
820 #define GUISTR(x) x
821 #define GUI_ENCODE_FILE ENCODE_FILE
822 #define GUI_ENCODE_SYSTEM ENCODE_SYSTEM
823 #define GUI_FN(fn) fn
824 typedef char guichar_t;
825 #endif /* NTGUI_UNICODE */
826
827 #define GUI_SDATA(x) ((guichar_t*) SDATA (x))
828
829 extern Lisp_Object w32_popup_dialog (struct frame *, Lisp_Object, Lisp_Object);
830 extern void w32_arrow_cursor (void);
831
832 extern void syms_of_w32term (void);
833 extern void syms_of_w32menu (void);
834 extern void syms_of_w32fns (void);
835
836 extern void globals_of_w32menu (void);
837 extern void globals_of_w32fns (void);
838 extern void globals_of_w32notify (void);
839
840 #ifdef CYGWIN
841 extern int w32_message_fd;
842 #endif /* CYGWIN */