Merge changes made in Gnus trunk.
[bpt/emacs.git] / src / w32term.h
1 /* Definitions and headers for communication on the Microsoft W32 API.
2 Copyright (C) 1995, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* Added by Kevin Gallo */
21
22 #include "w32gui.h"
23
24 \f
25 #define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0)
26 #define WHITE_PIX_DEFAULT(f) PALETTERGB(255,255,255)
27
28 #define FONT_WIDTH(f) ((f)->max_width)
29 #define FONT_HEIGHT(f) ((f)->height)
30 #define FONT_BASE(f) ((f)->ascent)
31 #define FONT_DESCENT(f) ((f)->descent)
32
33 #define CP_DEFAULT 1004
34
35 #define CHECK_W32_FRAME(f, frame) \
36 if (NILP (frame)) \
37 f = SELECTED_FRAME (); \
38 else \
39 { \
40 CHECK_LIVE_FRAME (frame, 0); \
41 f = XFRAME (frame); \
42 } \
43 if (! FRAME_W32_P (f))
44
45 /* Indicates whether we are in the readsocket call and the message we
46 are processing in the current loop */
47
48 extern MSG CurMsg;
49 extern BOOL bUseDflt;
50
51 /* Structure recording bitmaps and reference count.
52 If REFCOUNT is 0 then this record is free to be reused. */
53
54 struct w32_bitmap_record
55 {
56 Pixmap pixmap;
57 char *file;
58 HINSTANCE hinst; /* Used to load the file */
59 int refcount;
60 /* Record some info about this pixmap. */
61 int height, width, depth;
62 };
63
64 /* Palette book-keeping stuff for mapping requested colors into the
65 system palette. Keep a ref-counted list of requested colors and
66 regenerate the app palette whenever the requested list changes. */
67
68 extern Lisp_Object Vw32_enable_palette;
69
70 struct w32_palette_entry {
71 struct w32_palette_entry * next;
72 PALETTEENTRY entry;
73 #if 0
74 unsigned refcount;
75 #endif
76 };
77
78 extern void w32_regenerate_palette(struct frame *f);
79
80 \f
81 /* For each display (currently only one on w32), we have a structure that
82 records information about it. */
83
84 struct w32_display_info
85 {
86 /* Chain of all w32_display_info structures. */
87 struct w32_display_info *next;
88
89 /* The generic display parameters corresponding to this w32 display. */
90 struct terminal *terminal;
91
92 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
93 The same cons cell also appears in x_display_name_list. */
94 Lisp_Object name_list_element;
95
96 /* Number of frames that are on this display. */
97 int reference_count;
98
99 /* Dots per inch of the screen. */
100 double resx, resy;
101
102 /* Number of planes on this screen. */
103 int n_planes;
104
105 /* Number of bits per pixel on this screen. */
106 int n_cbits;
107
108 /* Mask of things that cause the mouse to be grabbed. */
109 int grabbed;
110
111 /* Emacs bitmap-id of the default icon bitmap for this frame.
112 Or -1 if none has been allocated yet. */
113 int icon_bitmap_id;
114
115 /* The root window of this screen. */
116 Window root_window;
117
118 /* The cursor to use for vertical scroll bars. */
119 Cursor vertical_scroll_bar_cursor;
120
121 /* Resource data base */
122 XrmDatabase xrdb;
123
124 /* color palette information. */
125 int has_palette;
126 struct w32_palette_entry * color_list;
127 unsigned num_colors;
128 HPALETTE palette;
129
130 /* deferred action flags checked when starting frame update. */
131 int regen_palette;
132
133 /* Keystroke that has been faked by Emacs and will be ignored when
134 received; value is reset after key is received. */
135 int faked_key;
136
137 /* Minimum width over all characters in all fonts in font_table. */
138 int smallest_char_width;
139
140 /* Minimum font height over all fonts in font_table. */
141 int smallest_font_height;
142
143 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
144 XGCValues *scratch_cursor_gc;
145
146 /* These variables describe the range of text currently shown in its
147 mouse-face, together with the window they apply to. As long as
148 the mouse stays within this range, we need not redraw anything on
149 its account. Rows and columns are glyph matrix positions in
150 MOUSE_FACE_WINDOW. */
151 int mouse_face_beg_row, mouse_face_beg_col;
152 int mouse_face_beg_x, mouse_face_beg_y;
153 int mouse_face_end_row, mouse_face_end_col;
154 int mouse_face_end_x, mouse_face_end_y;
155 int mouse_face_past_end;
156 Lisp_Object mouse_face_window;
157 int mouse_face_face_id;
158 Lisp_Object mouse_face_overlay;
159
160 /* 1 if a mouse motion event came and we didn't handle it right away because
161 gc was in progress. */
162 int mouse_face_deferred_gc;
163
164 /* FRAME and X, Y position of mouse when last checked for
165 highlighting. X and Y can be negative or out of range for the frame. */
166 struct frame *mouse_face_mouse_frame;
167 int mouse_face_mouse_x, mouse_face_mouse_y;
168
169 /* Nonzero means defer mouse-motion highlighting. */
170 int mouse_face_defer;
171
172 /* Nonzero means that the mouse highlight should not be shown. */
173 int mouse_face_hidden;
174
175 int mouse_face_image_state;
176
177 char *w32_id_name;
178
179 /* The number of fonts actually stored in w32_font_table.
180 font_table[n] is used and valid if 0 <= n < n_fonts. 0 <=
181 n_fonts <= font_table_size. and font_table[i].name != 0. */
182 int n_fonts;
183
184 /* Pointer to bitmap records. */
185 struct w32_bitmap_record *bitmaps;
186
187 /* Allocated size of bitmaps field. */
188 int bitmaps_size;
189
190 /* Last used bitmap index. */
191 int bitmaps_last;
192
193 /* The frame (if any) which has the window that has keyboard focus.
194 Zero if none. This is examined by Ffocus_frame in w32fns.c. Note
195 that a mere EnterNotify event can set this; if you need to know the
196 last frame specified in a FocusIn or FocusOut event, use
197 w32_focus_event_frame. */
198 struct frame *w32_focus_frame;
199
200 /* The last frame mentioned in a FocusIn or FocusOut event. This is
201 separate from w32_focus_frame, because whether or not LeaveNotify
202 events cause us to lose focus depends on whether or not we have
203 received a FocusIn event for it. */
204 struct frame *w32_focus_event_frame;
205
206 /* The frame which currently has the visual highlight, and should get
207 keyboard input (other sorts of input have the frame encoded in the
208 event). It points to the focus frame's selected window's
209 frame. It differs from w32_focus_frame when we're using a global
210 minibuffer. */
211 struct frame *x_highlight_frame;
212 };
213
214 /* This is a chain of structures for all the displays currently in use. */
215 extern struct w32_display_info *x_display_list;
216 extern struct w32_display_info one_w32_display_info;
217
218 /* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE),
219 one for each element of w32_display_list and in the same order.
220 NAME is the name of the frame.
221 FONT-LIST-CACHE records previous values returned by x-list-fonts. */
222 extern Lisp_Object w32_display_name_list;
223
224 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
225 extern Lisp_Object Vx_pixel_size_width_font_regexp;
226
227 extern struct frame *x_window_to_frame (struct w32_display_info *, HWND);
228
229 struct w32_display_info *x_display_info_for_name (Lisp_Object);
230
231 Lisp_Object display_x_get_resource (struct w32_display_info *,
232 Lisp_Object, Lisp_Object,
233 Lisp_Object, Lisp_Object);
234
235 extern struct w32_display_info *w32_term_init (Lisp_Object,
236 char *, char *);
237
238 extern int x_display_pixel_height (struct w32_display_info *);
239 extern int x_display_pixel_width (struct w32_display_info *);
240
241 \f
242 #define PIX_TYPE COLORREF
243
244 /* Each W32 frame object points to its own struct w32_display object
245 in the output_data.w32 field. The w32_display structure contains all
246 the information that is specific to W32 windows. */
247
248 /* Put some things in x_output for compatibility.
249 NTEMACS_TODO: Move all common things here to eliminate unneccesary
250 diffs between X and w32 code. */
251 struct x_output
252 {
253 #if 0 /* These are also defined in struct frame. Use that instead. */
254 PIX_TYPE background_pixel;
255 PIX_TYPE foreground_pixel;
256 #endif
257
258 /* Keep track of focus. May be EXPLICIT if we received a FocusIn for this
259 frame, or IMPLICIT if we received an EnterNotify.
260 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
261 int focus_state;
262
263 };
264
265 enum
266 {
267 /* Values for focus_state, used as bit mask.
268 EXPLICIT means we received a FocusIn for the frame and know it has
269 the focus. IMPLICIT means we recevied an EnterNotify and the frame
270 may have the focus if no window manager is running.
271 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
272 FOCUS_NONE = 0,
273 FOCUS_IMPLICIT = 1,
274 FOCUS_EXPLICIT = 2
275 };
276
277 struct w32_output
278 {
279 /* Placeholder for things accessed through output_data.x. */
280 struct x_output x_compatible;
281
282 /* Menubar "widget" handle. */
283 HMENU menubar_widget;
284
285 /* Original palette (used to deselect real palette after drawing) */
286 HPALETTE old_palette;
287
288 /* Here are the Graphics Contexts for the default font. */
289 XGCValues *cursor_gc; /* cursor drawing */
290
291 /* The window used for this frame.
292 May be zero while the frame object is being created
293 and the window has not yet been created. */
294 Window window_desc;
295
296 /* The window that is the parent of this window.
297 Usually this is a window that was made by the window manager,
298 but it can be the root window, and it can be explicitly specified
299 (see the explicit_parent field, below). */
300 Window parent_desc;
301
302 /* Default ASCII font of this frame. */
303 struct font *font;
304
305 /* The baseline offset of the default ASCII font. */
306 int baseline_offset;
307
308 /* If a fontset is specified for this frame instead of font, this
309 value contains an ID of the fontset, else -1. */
310 int fontset;
311
312 /* Pixel values used for various purposes.
313 border_pixel may be -1 meaning use a gray tile. */
314 COLORREF cursor_pixel;
315 COLORREF border_pixel;
316 COLORREF mouse_pixel;
317 COLORREF cursor_foreground_pixel;
318
319 /* Foreground color for scroll bars. A value of -1 means use the
320 default (black for non-toolkit scroll bars). */
321 COLORREF scroll_bar_foreground_pixel;
322
323 /* Background color for scroll bars. A value of -1 means use the
324 default (background color of the frame for non-toolkit scroll
325 bars). */
326 COLORREF scroll_bar_background_pixel;
327
328 /* Descriptor for the cursor in use for this window. */
329 Cursor text_cursor;
330 Cursor nontext_cursor;
331 Cursor modeline_cursor;
332 Cursor hand_cursor;
333 Cursor hourglass_cursor;
334 Cursor horizontal_drag_cursor;
335
336 /* Non-zero means hourglass cursor is currently displayed. */
337 unsigned hourglass_p : 1;
338
339 /* Non-hourglass cursor that is currently active. */
340 Cursor current_cursor;
341
342 /* Flag to set when the window needs to be completely repainted. */
343 int needs_exposure;
344
345 DWORD dwStyle;
346
347 /* This is the Emacs structure for the display this frame is on. */
348 /* struct w32_display_info *display_info; */
349
350 /* Nonzero means our parent is another application's window
351 and was explicitly specified. */
352 char explicit_parent;
353
354 /* Nonzero means tried already to make this frame visible. */
355 char asked_for_visible;
356
357 /* Nonzero means menubar is currently active. */
358 char menubar_active;
359
360 /* Nonzero means menubar is about to become active, but should be
361 brought up to date first. */
362 volatile char pending_menu_activation;
363
364 /* Relief GCs, colors etc. */
365 struct relief
366 {
367 XGCValues *gc;
368 unsigned long pixel;
369 int allocated_p;
370 }
371 black_relief, white_relief;
372
373 /* The background for which the above relief GCs were set up.
374 They are changed only when a different background is involved. */
375 unsigned long relief_background;
376 };
377
378 extern struct w32_output w32term_display;
379
380 /* Return the X output data for frame F. */
381 #define FRAME_X_OUTPUT(f) ((f)->output_data.w32)
382
383 /* Return the window associated with the frame F. */
384 #define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc)
385 #define FRAME_X_WINDOW(f) ((f)->output_data.w32->window_desc)
386
387 #define FRAME_FONT(f) ((f)->output_data.w32->font)
388 #define FRAME_FONTSET(f) ((f)->output_data.w32->fontset)
389 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset)
390
391 /* This gives the w32_display_info structure for the display F is on. */
392 #define FRAME_W32_DISPLAY_INFO(f) (&one_w32_display_info)
393 #define FRAME_X_DISPLAY_INFO(f) (&one_w32_display_info)
394
395 /* This is the `Display *' which frame F is on. */
396 #define FRAME_X_DISPLAY(f) (0)
397
398 /* Value is the smallest width of any character in any font on frame F. */
399
400 #define FRAME_SMALLEST_CHAR_WIDTH(F) \
401 FRAME_W32_DISPLAY_INFO(F)->smallest_char_width
402
403 /* Value is the smallest height of any font on frame F. */
404
405 #define FRAME_SMALLEST_FONT_HEIGHT(F) \
406 FRAME_W32_DISPLAY_INFO(F)->smallest_font_height
407 \f
408 /* W32-specific scroll bar stuff. */
409
410 /* We represent scroll bars as lisp vectors. This allows us to place
411 references to them in windows without worrying about whether we'll
412 end up with windows referring to dead scroll bars; the garbage
413 collector will free it when its time comes.
414
415 We use struct scroll_bar as a template for accessing fields of the
416 vector. */
417
418 struct scroll_bar {
419
420 /* These fields are shared by all vectors. */
421 EMACS_INT size_from_Lisp_Vector_struct;
422 struct Lisp_Vector *next_from_Lisp_Vector_struct;
423
424 /* The window we're a scroll bar for. */
425 Lisp_Object window;
426
427 /* The next and previous in the chain of scroll bars in this frame. */
428 Lisp_Object next, prev;
429
430 /* The window representing this scroll bar. Since this is a full
431 32-bit quantity, we store it split into two 32-bit values. */
432 Lisp_Object w32_window_low, w32_window_high;
433
434 /* Same as above for the widget. */
435 Lisp_Object w32_widget_low, w32_widget_high;
436
437 /* The position and size of the scroll bar in pixels, relative to the
438 frame. */
439 Lisp_Object top, left, width, height;
440
441 /* The starting and ending positions of the handle, relative to the
442 handle area (i.e. zero is the top position, not
443 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
444 hasn't been drawn yet.
445
446 These are not actually the locations where the beginning and end
447 are drawn; in order to keep handles from becoming invisible when
448 editing large files, we establish a minimum height by always
449 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
450 where they would be normally; the bottom and top are in a
451 different co-ordinate system. */
452 Lisp_Object start, end;
453
454 /* If the scroll bar handle is currently being dragged by the user,
455 this is the number of pixels from the top of the handle to the
456 place where the user grabbed it. If the handle isn't currently
457 being dragged, this is Qnil. */
458 Lisp_Object dragging;
459
460 /* t if the background of the fringe that is adjacent to a scroll
461 bar is extended to the gap between the fringe and the bar. */
462 Lisp_Object fringe_extended_p;
463 };
464
465 /* The number of elements a vector holding a struct scroll_bar needs. */
466 #define SCROLL_BAR_VEC_SIZE \
467 ((sizeof (struct scroll_bar) \
468 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \
469 / sizeof (Lisp_Object))
470
471 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
472 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
473
474
475 /* Building a 32-bit C integer from two 16-bit lisp integers. */
476 #define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
477
478 /* Setting two lisp integers to the low and high words of a 32-bit C int. */
479 #define SCROLL_BAR_UNPACK(low, high, int32) \
480 (XSETINT ((low), (int32) & 0xffff), \
481 XSETINT ((high), ((int32) >> 16) & 0xffff))
482
483
484 /* Extract the window id of the scroll bar from a struct scroll_bar. */
485 #define SCROLL_BAR_W32_WINDOW(ptr) \
486 ((Window) SCROLL_BAR_PACK ((ptr)->w32_window_low, (ptr)->w32_window_high))
487
488 /* Store a window id in a struct scroll_bar. */
489 #define SET_SCROLL_BAR_W32_WINDOW(ptr, id) \
490 (SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (int) id))
491
492 /* Extract the X widget of the scroll bar from a struct scroll_bar. */
493 #define SCROLL_BAR_X_WIDGET(ptr) \
494 ((Widget) SCROLL_BAR_PACK ((ptr)->x_widget_low, (ptr)->x_widget_high))
495
496 /* Store a widget id in a struct scroll_bar. */
497 #define SET_SCROLL_BAR_X_WIDGET(ptr, w) \
498 (SCROLL_BAR_UNPACK ((ptr)->x_widget_low, (ptr)->x_widget_high, (int) w))
499
500 /* Return the inside width of a vertical scroll bar, given the outside
501 width. */
502 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f,width) \
503 ((width) \
504 - VERTICAL_SCROLL_BAR_LEFT_BORDER \
505 - VERTICAL_SCROLL_BAR_RIGHT_BORDER \
506 - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2)
507
508 /* Return the length of the rectangle within which the top of the
509 handle must stay. This isn't equivalent to the inside height,
510 because the scroll bar handle has a minimum height.
511
512 This is the real range of motion for the scroll bar, so when we're
513 scaling buffer positions to scroll bar positions, we use this, not
514 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
515 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f,height) \
516 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
517
518 /* Return the inside height of vertical scroll bar, given the outside
519 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
520 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f,height) \
521 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
522
523
524 /* Border widths for scroll bars.
525
526 Scroll bar windows don't have any borders; their border width is
527 set to zero, and we redraw borders ourselves. This makes the code
528 a bit cleaner, since we don't have to convert between outside width
529 (used when relating to the rest of the screen) and inside width
530 (used when sizing and drawing the scroll bar window itself).
531
532 The handle moves up and down/back and forth in a rectangle inset
533 from the edges of the scroll bar. These are widths by which we
534 inset the handle boundaries from the scroll bar edges. */
535 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (0)
536 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (0)
537 #define VERTICAL_SCROLL_BAR_TOP_BORDER (vertical_scroll_bar_top_border)
538 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (vertical_scroll_bar_bottom_border)
539
540 /* Minimum lengths for scroll bar handles, in pixels. */
541 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (vertical_scroll_bar_min_handle)
542
543 /* Trimming off a few pixels from each side prevents
544 text from glomming up against the scroll bar */
545 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
546
547 \f
548 struct frame; /* from frame.h */
549
550 extern void w32_fill_rect (struct frame *, HDC, COLORREF, RECT *);
551 extern void w32_clear_window (struct frame *);
552
553 #define w32_fill_area(f,hdc,pix,x,y,nx,ny) \
554 do { \
555 RECT rect; \
556 rect.left = x; \
557 rect.top = y; \
558 rect.right = x + nx; \
559 rect.bottom = y + ny; \
560 w32_fill_rect (f,hdc,pix,&rect); \
561 } while (0)
562
563 #define w32_clear_rect(f,hdc,lprect) \
564 w32_fill_rect (f, hdc, FRAME_BACKGROUND_PIXEL (f), lprect)
565
566 #define w32_clear_area(f,hdc,px,py,nx,ny) \
567 w32_fill_area (f, hdc, FRAME_BACKGROUND_PIXEL (f), px, py, nx, ny)
568
569 /* Define for earlier versions of Visual C */
570 #ifndef WM_MOUSEWHEEL
571 #define WM_MOUSEWHEEL (WM_MOUSELAST + 1)
572 #endif /* WM_MOUSEWHEEL */
573 #ifndef MSH_MOUSEWHEEL
574 #define MSH_MOUSEWHEEL "MSWHEEL_ROLLMSG"
575 #endif /* MSH_MOUSEWHEEL */
576 #ifndef WM_XBUTTONDOWN
577 #define WM_XBUTTONDOWN (WM_MOUSEWHEEL + 1)
578 #define WM_XBUTTONUP (WM_MOUSEWHEEL + 2)
579 #endif /* WM_XBUTTONDOWN */
580 #ifndef WM_MOUSEHWHEEL
581 #define WM_MOUSEHWHEEL (WM_MOUSEWHEEL + 4)
582 #endif /* WM_MOUSEHWHEEL */
583 #ifndef WM_APPCOMMAND
584 #define WM_APPCOMMAND 0x319
585 #define GET_APPCOMMAND_LPARAM(lParam) (HIWORD(lParam) & 0x7fff)
586 #endif
587 #ifndef WM_UNICHAR
588 #define WM_UNICHAR 0x109
589 #endif
590 #ifndef UNICODE_NOCHAR
591 #define UNICODE_NOCHAR 0xFFFF
592 #endif
593
594 #define WM_EMACS_START (WM_USER + 1)
595 #define WM_EMACS_KILL (WM_EMACS_START + 0)
596 #define WM_EMACS_CREATEWINDOW (WM_EMACS_START + 1)
597 #define WM_EMACS_DONE (WM_EMACS_START + 2)
598 #define WM_EMACS_CREATESCROLLBAR (WM_EMACS_START + 3)
599 #define WM_EMACS_SHOWWINDOW (WM_EMACS_START + 4)
600 #define WM_EMACS_SETWINDOWPOS (WM_EMACS_START + 5)
601 #define WM_EMACS_DESTROYWINDOW (WM_EMACS_START + 6)
602 #define WM_EMACS_TRACKPOPUPMENU (WM_EMACS_START + 7)
603 #define WM_EMACS_SETFOCUS (WM_EMACS_START + 8)
604 #define WM_EMACS_SETFOREGROUND (WM_EMACS_START + 9)
605 #define WM_EMACS_SETLOCALE (WM_EMACS_START + 10)
606 #define WM_EMACS_SETKEYBOARDLAYOUT (WM_EMACS_START + 11)
607 #define WM_EMACS_REGISTER_HOT_KEY (WM_EMACS_START + 12)
608 #define WM_EMACS_UNREGISTER_HOT_KEY (WM_EMACS_START + 13)
609 #define WM_EMACS_TOGGLE_LOCK_KEY (WM_EMACS_START + 14)
610 #define WM_EMACS_TRACK_CARET (WM_EMACS_START + 15)
611 #define WM_EMACS_DESTROY_CARET (WM_EMACS_START + 16)
612 #define WM_EMACS_SHOW_CARET (WM_EMACS_START + 17)
613 #define WM_EMACS_HIDE_CARET (WM_EMACS_START + 18)
614 #define WM_EMACS_SETCURSOR (WM_EMACS_START + 19)
615 #define WM_EMACS_PAINT (WM_EMACS_START + 20)
616 #define WM_EMACS_END (WM_EMACS_START + 21)
617
618 #define WND_FONTWIDTH_INDEX (0)
619 #define WND_LINEHEIGHT_INDEX (4)
620 #define WND_BORDER_INDEX (8)
621 #define WND_SCROLLBAR_INDEX (12)
622 #define WND_BACKGROUND_INDEX (16)
623 #define WND_LAST_INDEX (20)
624
625 #define WND_EXTRA_BYTES (WND_LAST_INDEX)
626
627 extern DWORD dwWindowsThreadId;
628 extern HANDLE hWindowsThread;
629 extern DWORD dwMainThreadId;
630 extern HANDLE hMainThread;
631
632 typedef struct W32Msg {
633 MSG msg;
634 DWORD dwModifiers;
635 RECT rect;
636 } W32Msg;
637
638 /* Structure for recording message when input thread must return a
639 result that depends on lisp thread to compute. Lisp thread can
640 complete deferred messages out of order. */
641 typedef struct deferred_msg
642 {
643 struct deferred_msg * next;
644 W32Msg w32msg;
645 LRESULT result;
646 int completed;
647 } deferred_msg;
648
649 extern CRITICAL_SECTION critsect;
650
651 extern void init_crit (void);
652 extern void delete_crit (void);
653
654 extern void signal_quit (void);
655
656 #define enter_crit() EnterCriticalSection (&critsect)
657 #define leave_crit() LeaveCriticalSection (&critsect)
658
659 extern void select_palette (struct frame * f, HDC hdc);
660 extern void deselect_palette (struct frame * f, HDC hdc);
661 extern HDC get_frame_dc (struct frame * f);
662 extern int release_frame_dc (struct frame * f, HDC hDC);
663
664 extern void drain_message_queue (void);
665
666 extern BOOL get_next_msg (W32Msg *, BOOL);
667 extern BOOL post_msg (W32Msg *);
668 extern void complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result);
669
670 extern BOOL parse_button (int, int, int *, int *);
671
672 extern void w32_sys_ring_bell (struct frame *f);
673 extern void x_delete_display (struct w32_display_info *dpyinfo);
674
675 /* Keypad command key support. W32 doesn't have virtual keys defined
676 for the function keys on the keypad (they are mapped to the standard
677 fuction keys), so we define our own. */
678 #define VK_NUMPAD_BEGIN 0x92
679 #define VK_NUMPAD_CLEAR (VK_NUMPAD_BEGIN + 0)
680 #define VK_NUMPAD_ENTER (VK_NUMPAD_BEGIN + 1)
681 #define VK_NUMPAD_PRIOR (VK_NUMPAD_BEGIN + 2)
682 #define VK_NUMPAD_NEXT (VK_NUMPAD_BEGIN + 3)
683 #define VK_NUMPAD_END (VK_NUMPAD_BEGIN + 4)
684 #define VK_NUMPAD_HOME (VK_NUMPAD_BEGIN + 5)
685 #define VK_NUMPAD_LEFT (VK_NUMPAD_BEGIN + 6)
686 #define VK_NUMPAD_UP (VK_NUMPAD_BEGIN + 7)
687 #define VK_NUMPAD_RIGHT (VK_NUMPAD_BEGIN + 8)
688 #define VK_NUMPAD_DOWN (VK_NUMPAD_BEGIN + 9)
689 #define VK_NUMPAD_INSERT (VK_NUMPAD_BEGIN + 10)
690 #define VK_NUMPAD_DELETE (VK_NUMPAD_BEGIN + 11)
691
692 #ifndef VK_LWIN
693 /* Older compiler environments don't have these defined. */
694 #define VK_LWIN 0x5B
695 #define VK_RWIN 0x5C
696 #define VK_APPS 0x5D
697 #endif
698
699 /* Support for treating Windows and Apps keys as modifiers. These
700 constants must not overlap with any of the dwControlKeyState flags in
701 KEY_EVENT_RECORD. */
702 #define LEFT_WIN_PRESSED 0x8000
703 #define RIGHT_WIN_PRESSED 0x4000
704 #define APPS_PRESSED 0x2000
705
706 /* When compiling on Windows 9x/ME and NT 3.x, the following are not defined
707 (even though they are supported on 98 and ME. */
708 #ifndef WM_MOUSELEAVE
709 #define WM_MOUSELEAVE 0x02A3
710 #define TME_LEAVE 0x00000002;
711
712 typedef struct tagTRACKMOUSEEVENT
713 {
714 DWORD cbSize;
715 DWORD dwFlags;
716 HWND hwndTrack;
717 DWORD dwHoverTime;
718 } TRACKMOUSEEVENT;
719 #endif
720
721 struct image;
722 struct face;
723
724 XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *);
725 struct frame * check_x_frame (Lisp_Object);
726
727 EXFUN (Fx_display_color_p, 1);
728 EXFUN (Fx_display_grayscale_p, 1);
729
730 typedef DWORD (WINAPI * ClipboardSequence_Proc) (void);
731 typedef BOOL (WINAPI * AppendMenuW_Proc) (
732 IN HMENU,
733 IN UINT,
734 IN UINT_PTR,
735 IN LPCWSTR);
736
737 /* arch-tag: f201d05a-1240-4fc5-8ea4-ca24d4ee5671
738 (do not change this comment) */