Commit | Line | Data |
---|---|---|
de31b97a | 1 | /* Definitions and headers for communication on the Microsoft W32 API. |
0b5538bd | 2 | Copyright (C) 1995, 2001, 2002, 2003, 2004, |
114f9c96 | 3 | 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
c3b8ccce GV |
4 | |
5 | This file is part of GNU Emacs. | |
6 | ||
b9b1cc14 | 7 | GNU Emacs is free software: you can redistribute it and/or modify |
c3b8ccce | 8 | it under the terms of the GNU General Public License as published by |
b9b1cc14 GM |
9 | the Free Software Foundation, either version 3 of the License, or |
10 | (at your option) any later version. | |
c3b8ccce GV |
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 | |
b9b1cc14 | 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
c3b8ccce GV |
19 | |
20 | /* Added by Kevin Gallo */ | |
21 | ||
51dcffad | 22 | #include "w32gui.h" |
c3b8ccce | 23 | |
c3b8ccce | 24 | \f |
3fed86ff GV |
25 | #define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0) |
26 | #define WHITE_PIX_DEFAULT(f) PALETTERGB(255,255,255) | |
c3b8ccce | 27 | |
3af8ab1d KH |
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) | |
c3b8ccce | 32 | |
ad23de76 JR |
33 | #define CP_DEFAULT 1004 |
34 | ||
fbd6baed | 35 | #define CHECK_W32_FRAME(f, frame) \ |
c3b8ccce | 36 | if (NILP (frame)) \ |
51dcffad | 37 | f = SELECTED_FRAME (); \ |
c3b8ccce GV |
38 | else \ |
39 | { \ | |
40 | CHECK_LIVE_FRAME (frame, 0); \ | |
41 | f = XFRAME (frame); \ | |
42 | } \ | |
fbd6baed | 43 | if (! FRAME_W32_P (f)) |
c3b8ccce GV |
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 | ||
c3b8ccce GV |
51 | /* Structure recording bitmaps and reference count. |
52 | If REFCOUNT is 0 then this record is free to be reused. */ | |
53 | ||
177c0ea7 | 54 | struct w32_bitmap_record |
c3b8ccce GV |
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 | }; | |
aba66c88 GV |
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 | ||
fbd6baed | 68 | extern Lisp_Object Vw32_enable_palette; |
aba66c88 | 69 | |
fbd6baed GV |
70 | struct w32_palette_entry { |
71 | struct w32_palette_entry * next; | |
aba66c88 GV |
72 | PALETTEENTRY entry; |
73 | #if 0 | |
74 | unsigned refcount; | |
75 | #endif | |
76 | }; | |
77 | ||
fbd6baed | 78 | extern void w32_regenerate_palette(struct frame *f); |
aba66c88 | 79 | |
c3b8ccce | 80 | \f |
fbd6baed | 81 | /* For each display (currently only one on w32), we have a structure that |
c3b8ccce GV |
82 | records information about it. */ |
83 | ||
fbd6baed | 84 | struct w32_display_info |
c3b8ccce | 85 | { |
fbd6baed GV |
86 | /* Chain of all w32_display_info structures. */ |
87 | struct w32_display_info *next; | |
51dcffad | 88 | |
a032a9a8 JR |
89 | /* The generic display parameters corresponding to this w32 display. */ |
90 | struct terminal *terminal; | |
91 | ||
c3b8ccce GV |
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; | |
51dcffad | 95 | |
c3b8ccce GV |
96 | /* Number of frames that are on this display. */ |
97 | int reference_count; | |
51dcffad JR |
98 | |
99 | /* Dots per inch of the screen. */ | |
100 | double resx, resy; | |
101 | ||
c3b8ccce GV |
102 | /* Number of planes on this screen. */ |
103 | int n_planes; | |
51dcffad | 104 | |
c3b8ccce GV |
105 | /* Number of bits per pixel on this screen. */ |
106 | int n_cbits; | |
51dcffad | 107 | |
c3b8ccce GV |
108 | /* Mask of things that cause the mouse to be grabbed. */ |
109 | int grabbed; | |
51dcffad JR |
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 | ||
c3b8ccce GV |
115 | /* The root window of this screen. */ |
116 | Window root_window; | |
51dcffad | 117 | |
c3b8ccce GV |
118 | /* The cursor to use for vertical scroll bars. */ |
119 | Cursor vertical_scroll_bar_cursor; | |
120 | ||
71147653 | 121 | /* Resource data base */ |
abdb2fa0 | 122 | XrmDatabase xrdb; |
71147653 | 123 | |
bb355434 | 124 | /* color palette information. */ |
aba66c88 | 125 | int has_palette; |
fbd6baed | 126 | struct w32_palette_entry * color_list; |
aba66c88 GV |
127 | unsigned num_colors; |
128 | HPALETTE palette; | |
129 | ||
bb355434 | 130 | /* deferred action flags checked when starting frame update. */ |
aba66c88 GV |
131 | int regen_palette; |
132 | ||
bb355434 GV |
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 | ||
51dcffad JR |
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. */ | |
c3b8ccce | 151 | int mouse_face_beg_row, mouse_face_beg_col; |
51dcffad | 152 | int mouse_face_beg_x, mouse_face_beg_y; |
c3b8ccce | 153 | int mouse_face_end_row, mouse_face_end_col; |
51dcffad | 154 | int mouse_face_end_x, mouse_face_end_y; |
c3b8ccce GV |
155 | int mouse_face_past_end; |
156 | Lisp_Object mouse_face_window; | |
157 | int mouse_face_face_id; | |
42bde733 | 158 | Lisp_Object mouse_face_overlay; |
c3b8ccce GV |
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 | ||
f16c05f2 KS |
172 | /* Nonzero means that the mouse highlight should not be shown. */ |
173 | int mouse_face_hidden; | |
174 | ||
51dcffad JR |
175 | int mouse_face_image_state; |
176 | ||
fbd6baed | 177 | char *w32_id_name; |
c3b8ccce | 178 | |
fbd6baed | 179 | /* The number of fonts actually stored in w32_font_table. |
e0f24100 | 180 | font_table[n] is used and valid if 0 <= n < n_fonts. 0 <= |
51dcffad | 181 | n_fonts <= font_table_size. and font_table[i].name != 0. */ |
c3b8ccce GV |
182 | int n_fonts; |
183 | ||
184 | /* Pointer to bitmap records. */ | |
fbd6baed | 185 | struct w32_bitmap_record *bitmaps; |
c3b8ccce GV |
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 | |
fbd6baed GV |
197 | w32_focus_event_frame. */ |
198 | struct frame *w32_focus_frame; | |
c3b8ccce GV |
199 | |
200 | /* The last frame mentioned in a FocusIn or FocusOut event. This is | |
fbd6baed | 201 | separate from w32_focus_frame, because whether or not LeaveNotify |
c3b8ccce GV |
202 | events cause us to lose focus depends on whether or not we have |
203 | received a FocusIn event for it. */ | |
fbd6baed | 204 | struct frame *w32_focus_event_frame; |
c3b8ccce GV |
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 | |
fbd6baed | 209 | frame. It differs from w32_focus_frame when we're using a global |
c3b8ccce | 210 | minibuffer. */ |
6b3acc48 | 211 | struct frame *x_highlight_frame; |
c3b8ccce GV |
212 | }; |
213 | ||
214 | /* This is a chain of structures for all the displays currently in use. */ | |
8911aff3 | 215 | extern struct w32_display_info *x_display_list; |
fbd6baed | 216 | extern struct w32_display_info one_w32_display_info; |
c3b8ccce GV |
217 | |
218 | /* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE), | |
fbd6baed | 219 | one for each element of w32_display_list and in the same order. |
c3b8ccce GV |
220 | NAME is the name of the frame. |
221 | FONT-LIST-CACHE records previous values returned by x-list-fonts. */ | |
fbd6baed | 222 | extern Lisp_Object w32_display_name_list; |
c3b8ccce | 223 | |
d82f9149 GV |
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 | ||
361358ea JB |
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); | |
c3b8ccce | 230 | |
383e0970 J |
231 | Lisp_Object display_x_get_resource (struct w32_display_info *, |
232 | Lisp_Object, Lisp_Object, | |
233 | Lisp_Object, Lisp_Object); | |
f3c4ec74 | 234 | |
361358ea JB |
235 | extern struct w32_display_info *w32_term_init (Lisp_Object, |
236 | char *, char *); | |
a53400f3 | 237 | |
383e0970 J |
238 | extern int x_display_pixel_height (struct w32_display_info *); |
239 | extern int x_display_pixel_width (struct w32_display_info *); | |
a53400f3 | 240 | |
c3b8ccce | 241 | \f |
51dcffad JR |
242 | #define PIX_TYPE COLORREF |
243 | ||
fbd6baed GV |
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. */ | |
c3b8ccce | 247 | |
51dcffad JR |
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 | { | |
9e75e167 | 253 | #if 0 /* These are also defined in struct frame. Use that instead. */ |
51dcffad JR |
254 | PIX_TYPE background_pixel; |
255 | PIX_TYPE foreground_pixel; | |
9e75e167 | 256 | #endif |
bc2223e6 JR |
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 | ||
51dcffad JR |
263 | }; |
264 | ||
bc2223e6 JR |
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 | }; | |
51dcffad | 276 | |
fbd6baed | 277 | struct w32_output |
c3b8ccce | 278 | { |
51dcffad | 279 | /* Placeholder for things accessed through output_data.x. */ |
42bde733 | 280 | struct x_output x_compatible; |
51dcffad | 281 | |
8694f11b GV |
282 | /* Menubar "widget" handle. */ |
283 | HMENU menubar_widget; | |
284 | ||
aba66c88 GV |
285 | /* Original palette (used to deselect real palette after drawing) */ |
286 | HPALETTE old_palette; | |
287 | ||
51dcffad JR |
288 | /* Here are the Graphics Contexts for the default font. */ |
289 | XGCValues *cursor_gc; /* cursor drawing */ | |
290 | ||
c3b8ccce GV |
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 | ||
d82f9149 | 302 | /* Default ASCII font of this frame. */ |
3af8ab1d | 303 | struct font *font; |
47e420b5 | 304 | |
51dcffad JR |
305 | /* The baseline offset of the default ASCII font. */ |
306 | int baseline_offset; | |
d82f9149 GV |
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 | ||
c3b8ccce GV |
312 | /* Pixel values used for various purposes. |
313 | border_pixel may be -1 meaning use a gray tile. */ | |
51dcffad JR |
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; | |
177c0ea7 | 322 | |
51dcffad JR |
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; | |
c3b8ccce GV |
327 | |
328 | /* Descriptor for the cursor in use for this window. */ | |
329 | Cursor text_cursor; | |
330 | Cursor nontext_cursor; | |
331 | Cursor modeline_cursor; | |
b8a93676 | 332 | Cursor hand_cursor; |
5fa36066 | 333 | Cursor hourglass_cursor; |
f03fad22 | 334 | Cursor horizontal_drag_cursor; |
51dcffad | 335 | |
5fa36066 GM |
336 | /* Non-zero means hourglass cursor is currently displayed. */ |
337 | unsigned hourglass_p : 1; | |
c3b8ccce | 338 | |
d148e14d JR |
339 | /* Non-hourglass cursor that is currently active. */ |
340 | Cursor current_cursor; | |
341 | ||
c3b8ccce GV |
342 | /* Flag to set when the window needs to be completely repainted. */ |
343 | int needs_exposure; | |
344 | ||
c3b8ccce GV |
345 | DWORD dwStyle; |
346 | ||
c3b8ccce | 347 | /* This is the Emacs structure for the display this frame is on. */ |
fbd6baed | 348 | /* struct w32_display_info *display_info; */ |
c3b8ccce GV |
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; | |
8694f11b GV |
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; | |
51dcffad JR |
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; | |
c3b8ccce GV |
376 | }; |
377 | ||
2d764c78 EZ |
378 | extern struct w32_output w32term_display; |
379 | ||
8e025dd5 KS |
380 | /* Return the X output data for frame F. */ |
381 | #define FRAME_X_OUTPUT(f) ((f)->output_data.w32) | |
382 | ||
c3b8ccce | 383 | /* Return the window associated with the frame F. */ |
fbd6baed | 384 | #define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc) |
8e025dd5 | 385 | #define FRAME_X_WINDOW(f) ((f)->output_data.w32->window_desc) |
c3b8ccce | 386 | |
fbd6baed | 387 | #define FRAME_FONT(f) ((f)->output_data.w32->font) |
d82f9149 | 388 | #define FRAME_FONTSET(f) ((f)->output_data.w32->fontset) |
51dcffad | 389 | #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset) |
c3b8ccce | 390 | |
fbd6baed GV |
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) | |
51dcffad | 393 | #define FRAME_X_DISPLAY_INFO(f) (&one_w32_display_info) |
c3b8ccce | 394 | |
8e025dd5 KS |
395 | /* This is the `Display *' which frame F is on. */ |
396 | #define FRAME_X_DISPLAY(f) (0) | |
397 | ||
51dcffad JR |
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 | |
51dcffad | 407 | \f |
fbd6baed | 408 | /* W32-specific scroll bar stuff. */ |
c3b8ccce GV |
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. */ | |
fbd6baed | 432 | Lisp_Object w32_window_low, w32_window_high; |
c3b8ccce | 433 | |
51dcffad JR |
434 | /* Same as above for the widget. */ |
435 | Lisp_Object w32_widget_low, w32_widget_high; | |
436 | ||
c3b8ccce GV |
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; | |
680e49c3 YM |
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; | |
c3b8ccce GV |
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. */ | |
fbd6baed GV |
485 | #define SCROLL_BAR_W32_WINDOW(ptr) \ |
486 | ((Window) SCROLL_BAR_PACK ((ptr)->w32_window_low, (ptr)->w32_window_high)) | |
c3b8ccce GV |
487 | |
488 | /* Store a window id in a struct scroll_bar. */ | |
fbd6baed GV |
489 | #define SET_SCROLL_BAR_W32_WINDOW(ptr, id) \ |
490 | (SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (int) id)) | |
c3b8ccce | 491 | |
51dcffad JR |
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)) | |
c3b8ccce | 495 | |
51dcffad JR |
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)) | |
c3b8ccce GV |
499 | |
500 | /* Return the inside width of a vertical scroll bar, given the outside | |
501 | width. */ | |
51dcffad JR |
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) | |
c3b8ccce GV |
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, | |
177c0ea7 | 510 | because the scroll bar handle has a minimum height. |
c3b8ccce GV |
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. */ | |
51dcffad JR |
515 | #define VERTICAL_SCROLL_BAR_TOP_RANGE(f,height) \ |
516 | (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE) | |
c3b8ccce GV |
517 | |
518 | /* Return the inside height of vertical scroll bar, given the outside | |
519 | height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */ | |
51dcffad | 520 | #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f,height) \ |
c3b8ccce GV |
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) | |
8694f11b GV |
537 | #define VERTICAL_SCROLL_BAR_TOP_BORDER (vertical_scroll_bar_top_border) |
538 | #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (vertical_scroll_bar_bottom_border) | |
c3b8ccce GV |
539 | |
540 | /* Minimum lengths for scroll bar handles, in pixels. */ | |
8694f11b GV |
541 | #define VERTICAL_SCROLL_BAR_MIN_HANDLE (vertical_scroll_bar_min_handle) |
542 | ||
51dcffad JR |
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) | |
c3b8ccce GV |
546 | |
547 | \f | |
361358ea JB |
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 *); | |
c3b8ccce | 552 | |
fbd6baed | 553 | #define w32_fill_area(f,hdc,pix,x,y,nx,ny) \ |
680e49c3 | 554 | do { \ |
c3b8ccce GV |
555 | RECT rect; \ |
556 | rect.left = x; \ | |
557 | rect.top = y; \ | |
558 | rect.right = x + nx; \ | |
559 | rect.bottom = y + ny; \ | |
fbd6baed | 560 | w32_fill_rect (f,hdc,pix,&rect); \ |
680e49c3 | 561 | } while (0) |
c3b8ccce | 562 | |
fbd6baed | 563 | #define w32_clear_rect(f,hdc,lprect) \ |
9e75e167 | 564 | w32_fill_rect (f, hdc, FRAME_BACKGROUND_PIXEL (f), lprect) |
c3b8ccce | 565 | |
51dcffad | 566 | #define w32_clear_area(f,hdc,px,py,nx,ny) \ |
9e75e167 | 567 | w32_fill_area (f, hdc, FRAME_BACKGROUND_PIXEL (f), px, py, nx, ny) |
c3b8ccce | 568 | |
8694f11b GV |
569 | /* Define for earlier versions of Visual C */ |
570 | #ifndef WM_MOUSEWHEEL | |
f11f6cce | 571 | #define WM_MOUSEWHEEL (WM_MOUSELAST + 1) |
8694f11b | 572 | #endif /* WM_MOUSEWHEEL */ |
f11f6cce GV |
573 | #ifndef MSH_MOUSEWHEEL |
574 | #define MSH_MOUSEWHEEL "MSWHEEL_ROLLMSG" | |
575 | #endif /* MSH_MOUSEWHEEL */ | |
76e4fd8c JR |
576 | #ifndef WM_XBUTTONDOWN |
577 | #define WM_XBUTTONDOWN (WM_MOUSEWHEEL + 1) | |
578 | #define WM_XBUTTONUP (WM_MOUSEWHEEL + 2) | |
579 | #endif /* WM_XBUTTONDOWN */ | |
c3659876 JR |
580 | #ifndef WM_MOUSEHWHEEL |
581 | #define WM_MOUSEHWHEEL (WM_MOUSEWHEEL + 4) | |
582 | #endif /* WM_MOUSEHWHEEL */ | |
0fe216b2 JR |
583 | #ifndef WM_APPCOMMAND |
584 | #define WM_APPCOMMAND 0x319 | |
585 | #define GET_APPCOMMAND_LPARAM(lParam) (HIWORD(lParam) & 0x7fff) | |
586 | #endif | |
499180d5 JR |
587 | #ifndef WM_UNICHAR |
588 | #define WM_UNICHAR 0x109 | |
589 | #endif | |
590 | #ifndef UNICODE_NOCHAR | |
591 | #define UNICODE_NOCHAR 0xFFFF | |
592 | #endif | |
8694f11b | 593 | |
c3b8ccce | 594 | #define WM_EMACS_START (WM_USER + 1) |
bb355434 GV |
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) | |
93066bc2 | 609 | #define WM_EMACS_TOGGLE_LOCK_KEY (WM_EMACS_START + 14) |
64ade657 JR |
610 | #define WM_EMACS_TRACK_CARET (WM_EMACS_START + 15) |
611 | #define WM_EMACS_DESTROY_CARET (WM_EMACS_START + 16) | |
ab8b2d20 JR |
612 | #define WM_EMACS_SHOW_CARET (WM_EMACS_START + 17) |
613 | #define WM_EMACS_HIDE_CARET (WM_EMACS_START + 18) | |
f3358105 | 614 | #define WM_EMACS_SETCURSOR (WM_EMACS_START + 19) |
f7b146dc JR |
615 | #define WM_EMACS_PAINT (WM_EMACS_START + 20) |
616 | #define WM_EMACS_END (WM_EMACS_START + 21) | |
c3b8ccce | 617 | |
177c0ea7 JB |
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) | |
8694f11b | 623 | #define WND_LAST_INDEX (20) |
c3b8ccce | 624 | |
c3b8ccce GV |
625 | #define WND_EXTRA_BYTES (WND_LAST_INDEX) |
626 | ||
de31b97a GV |
627 | extern DWORD dwWindowsThreadId; |
628 | extern HANDLE hWindowsThread; | |
c3b8ccce GV |
629 | extern DWORD dwMainThreadId; |
630 | extern HANDLE hMainThread; | |
631 | ||
fbd6baed | 632 | typedef struct W32Msg { |
c3b8ccce GV |
633 | MSG msg; |
634 | DWORD dwModifiers; | |
635 | RECT rect; | |
fbd6baed | 636 | } W32Msg; |
c3b8ccce | 637 | |
8694f11b GV |
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 | ||
aba66c88 GV |
649 | extern CRITICAL_SECTION critsect; |
650 | ||
361358ea JB |
651 | extern void init_crit (void); |
652 | extern void delete_crit (void); | |
c3b8ccce | 653 | |
361358ea | 654 | extern void signal_quit (void); |
b44c3d59 | 655 | |
aba66c88 GV |
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 | ||
361358ea | 664 | extern void drain_message_queue (void); |
b37ac782 | 665 | |
361358ea JB |
666 | extern BOOL get_next_msg (W32Msg *, BOOL); |
667 | extern BOOL post_msg (W32Msg *); | |
8694f11b | 668 | extern void complete_deferred_msg (HWND hwnd, UINT msg, LRESULT result); |
c3b8ccce | 669 | |
361358ea | 670 | extern BOOL parse_button (int, int, int *, int *); |
c684f475 | 671 | |
a032a9a8 JR |
672 | extern void w32_sys_ring_bell (struct frame *f); |
673 | extern void x_delete_display (struct w32_display_info *dpyinfo); | |
674 | ||
fbd6baed | 675 | /* Keypad command key support. W32 doesn't have virtual keys defined |
c684f475 GV |
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 | |
bb355434 GV |
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 | |
51dcffad | 705 | |
a81bf19b JR |
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 | ||
177c0ea7 | 712 | typedef struct tagTRACKMOUSEEVENT |
a81bf19b JR |
713 | { |
714 | DWORD cbSize; | |
715 | DWORD dwFlags; | |
716 | HWND hwndTrack; | |
717 | DWORD dwHoverTime; | |
718 | } TRACKMOUSEEVENT; | |
719 | #endif | |
720 | ||
9f21c5a2 EZ |
721 | struct image; |
722 | struct face; | |
723 | ||
51dcffad JR |
724 | XGCValues *XCreateGC (void *, Window, unsigned long, XGCValues *); |
725 | struct frame * check_x_frame (Lisp_Object); | |
f3c4ec74 | 726 | |
ad23de76 JR |
727 | EXFUN (Fx_display_color_p, 1); |
728 | EXFUN (Fx_display_grayscale_p, 1); | |
8e025dd5 | 729 | |
361358ea | 730 | typedef DWORD (WINAPI * ClipboardSequence_Proc) (void); |
ee8062ff JR |
731 | typedef BOOL (WINAPI * AppendMenuW_Proc) ( |
732 | IN HMENU, | |
733 | IN UINT, | |
734 | IN UINT_PTR, | |
735 | IN LPCWSTR); | |
6b61353c KH |
736 | |
737 | /* arch-tag: f201d05a-1240-4fc5-8ea4-ca24d4ee5671 | |
738 | (do not change this comment) */ |