1 /* Implementation of GUI terminal on the Microsoft W32 API.
2 Copyright (C) 1989, 93, 94, 95, 96, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
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 2, or (at your option)
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.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
28 #include "blockinput.h"
47 #include "dispextern.h"
49 #include "termhooks.h"
56 #include "intervals.h"
57 #include "composite.h"
60 #define abs(x) ((x) < 0 ? -(x) : (x))
62 #define BETWEEN(X, LOWER, UPPER) ((X) >= (LOWER) && (X) < (UPPER))
67 enum fringe_bitmap_type
70 LEFT_TRUNCATION_BITMAP
,
71 RIGHT_TRUNCATION_BITMAP
,
73 CONTINUED_LINE_BITMAP
,
74 CONTINUATION_LINE_BITMAP
,
78 /* Bitmaps are all unsigned short, as Windows requires bitmap data to
79 be Word aligned. For some reason they are horizontally reflected
80 compared to how they appear on X, so changes in xterm.c should be
83 /* Bitmap drawn to indicate lines not displaying text if
84 `indicate-empty-lines' is non-nil. */
89 static unsigned short zv_bits
[] = {
90 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
91 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
92 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
93 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
94 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
95 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
96 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
97 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
98 static HBITMAP zv_bmp
;
100 /* An arrow like this: `<-'. */
103 #define left_height 8
104 static unsigned short left_bits
[] = {
105 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
106 static HBITMAP left_bmp
;
108 /* Right truncation arrow bitmap `->'. */
110 #define right_width 8
111 #define right_height 8
112 static unsigned short right_bits
[] = {
113 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
114 static HBITMAP right_bmp
;
116 /* Marker for continued lines. */
118 #define continued_width 8
119 #define continued_height 8
120 static unsigned short continued_bits
[] = {
121 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
122 static HBITMAP continued_bmp
;
124 /* Marker for continuation lines. */
126 #define continuation_width 8
127 #define continuation_height 8
128 static unsigned short continuation_bits
[] = {
129 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
130 static HBITMAP continuation_bmp
;
132 /* Overlay arrow bitmap. */
138 static unsigned short ov_bits
[] = {
139 0x0c, 0x10, 0x3c, 0x7e, 0x5e, 0x5e, 0x46, 0x3c};
141 /* A triangular arrow. */
144 static unsigned short ov_bits
[] = {
145 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
147 static HBITMAP ov_bmp
;
149 extern Lisp_Object Qhelp_echo
;
152 /* Non-nil means Emacs uses toolkit scroll bars. */
154 Lisp_Object Vx_toolkit_scroll_bars
;
156 /* If a string, w32_read_socket generates an event to display that string.
157 (The display is done in read_char.) */
159 static Lisp_Object help_echo
;
160 static Lisp_Object help_echo_window
;
161 static Lisp_Object help_echo_object
;
162 static int help_echo_pos
;
164 /* Temporary variable for w32_read_socket. */
166 static Lisp_Object previous_help_echo
;
168 /* Non-zero means that a HELP_EVENT has been generated since Emacs
171 static int any_help_event_p
;
173 /* Non-zero means autoselect window with the mouse cursor. */
175 int mouse_autoselect_window
;
177 /* Non-zero means draw block and hollow cursor as wide as the glyph
178 under it. For example, if a block cursor is over a tab, it will be
179 drawn as wide as that tab on the display. */
181 int x_stretch_cursor_p
;
183 /* Non-zero means make use of UNDERLINE_POSITION font properties. */
185 int x_use_underline_position_properties
;
187 extern unsigned int msh_mousewheel
;
189 extern void free_frame_menubar ();
191 extern int w32_codepage_for_font (char *fontname
);
193 extern glyph_metric
*w32_BDF_TextMetric(bdffont
*fontp
,
194 unsigned char *text
, int dim
);
195 extern Lisp_Object Vwindow_system
;
197 #define x_any_window_to_frame x_window_to_frame
198 #define x_top_window_to_frame x_window_to_frame
201 /* This is display since w32 does not support multiple ones. */
202 struct w32_display_info one_w32_display_info
;
203 struct w32_display_info
*x_display_list
;
205 /* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE),
206 one for each element of w32_display_list and in the same order.
207 NAME is the name of the frame.
208 FONT-LIST-CACHE records previous values returned by x-list-fonts. */
209 Lisp_Object w32_display_name_list
;
211 /* Frame being updated by update_frame. This is declared in term.c.
212 This is set by update_begin and looked at by all the
213 w32 functions. It is zero while not inside an update.
214 In that case, the w32 functions assume that `SELECTED_FRAME ()'
215 is the frame to apply to. */
216 extern struct frame
*updating_frame
;
218 /* This is a frame waiting to be autoraised, within w32_read_socket. */
219 struct frame
*pending_autoraise_frame
;
221 /* Nominal cursor position -- where to draw output.
222 HPOS and VPOS are window relative glyph matrix coordinates.
223 X and Y are window relative pixel coordinates. */
225 struct cursor_pos output_cursor
;
227 /* The handle of the frame that currently owns the system caret. */
228 HWND w32_system_caret_hwnd
;
229 int w32_system_caret_height
;
230 int w32_system_caret_x
;
231 int w32_system_caret_y
;
232 int w32_use_visible_system_caret
;
234 /* Flag to enable Unicode output in case users wish to use programs
235 like Twinbridge on '95 rather than installed system level support
236 for Far East languages. */
237 int w32_enable_unicode_output
;
239 DWORD dwWindowsThreadId
= 0;
240 HANDLE hWindowsThread
= NULL
;
241 DWORD dwMainThreadId
= 0;
242 HANDLE hMainThread
= NULL
;
245 /* These definitions are new with Windows 95. */
246 #define SIF_RANGE 0x0001
247 #define SIF_PAGE 0x0002
248 #define SIF_POS 0x0004
249 #define SIF_DISABLENOSCROLL 0x0008
250 #define SIF_TRACKPOS 0x0010
251 #define SIF_ALL (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS)
253 typedef struct tagSCROLLINFO
262 } SCROLLINFO
, FAR
*LPSCROLLINFO
;
263 typedef SCROLLINFO CONST FAR
*LPCSCROLLINFO
;
266 /* Dynamic linking to new proportional scroll bar functions. */
267 int (PASCAL
*pfnSetScrollInfo
) (HWND hwnd
, int fnBar
, LPSCROLLINFO lpsi
, BOOL fRedraw
);
268 BOOL (PASCAL
*pfnGetScrollInfo
) (HWND hwnd
, int fnBar
, LPSCROLLINFO lpsi
);
270 int vertical_scroll_bar_min_handle
;
271 int vertical_scroll_bar_top_border
;
272 int vertical_scroll_bar_bottom_border
;
274 int last_scroll_bar_drag_pos
;
276 /* Mouse movement. */
278 /* Where the mouse was last time we reported a mouse event. */
280 FRAME_PTR last_mouse_frame
;
281 static RECT last_mouse_glyph
;
282 static Lisp_Object last_mouse_press_frame
;
284 Lisp_Object Vw32_num_mouse_buttons
;
286 Lisp_Object Vw32_swap_mouse_buttons
;
288 /* Control whether x_raise_frame also sets input focus. */
289 Lisp_Object Vw32_grab_focus_on_raise
;
291 /* Control whether Caps Lock affects non-ascii characters. */
292 Lisp_Object Vw32_capslock_is_shiftlock
;
294 /* Control whether right-alt and left-ctrl should be recognized as AltGr. */
295 Lisp_Object Vw32_recognize_altgr
;
297 /* The scroll bar in which the last motion event occurred.
299 If the last motion event occurred in a scroll bar, we set this
300 so w32_mouse_position can know whether to report a scroll bar motion or
303 If the last motion event didn't occur in a scroll bar, we set this
304 to Qnil, to tell w32_mouse_position to return an ordinary motion event. */
305 static Lisp_Object last_mouse_scroll_bar
;
306 static int last_mouse_scroll_bar_pos
;
308 /* This is a hack. We would really prefer that w32_mouse_position would
309 return the time associated with the position it returns, but there
310 doesn't seem to be any way to wrest the time-stamp from the server
311 along with the position query. So, we just keep track of the time
312 of the last movement we received, and return that in hopes that
313 it's somewhat accurate. */
315 static Time last_mouse_movement_time
;
317 /* Incremented by w32_read_socket whenever it really tries to read
321 static int volatile input_signal_count
;
323 static int input_signal_count
;
326 extern Lisp_Object Vcommand_line_args
, Vsystem_name
;
328 extern Lisp_Object Qface
, Qmouse_face
;
334 /* A mask of extra modifier bits to put into every keyboard char. */
336 extern EMACS_INT extra_keyboard_modifiers
;
338 /* Enumeration for overriding/changing the face to use for drawing
339 glyphs in x_draw_glyphs. */
341 enum draw_glyphs_face
351 static void x_update_window_end
P_ ((struct window
*, int, int));
352 static void frame_to_window_pixel_xy
P_ ((struct window
*, int *, int *));
353 void w32_delete_display
P_ ((struct w32_display_info
*));
354 static int fast_find_position
P_ ((struct window
*, int, int *, int *,
355 int *, int *, Lisp_Object
));
356 static int fast_find_string_pos
P_ ((struct window
*, int, Lisp_Object
,
357 int *, int *, int *, int *, int));
358 static void set_output_cursor
P_ ((struct cursor_pos
*));
359 static struct glyph
*x_y_to_hpos_vpos
P_ ((struct window
*, int, int,
360 int *, int *, int *, int));
361 static void note_mode_line_highlight
P_ ((struct window
*, int, int));
362 static void note_mouse_highlight
P_ ((struct frame
*, int, int));
363 static void note_tool_bar_highlight
P_ ((struct frame
*f
, int, int));
364 static void w32_handle_tool_bar_click
P_ ((struct frame
*,
365 struct input_event
*));
366 static void show_mouse_face
P_ ((struct w32_display_info
*,
367 enum draw_glyphs_face
));
368 static int cursor_in_mouse_face_p
P_ ((struct window
*));
369 static int clear_mouse_face
P_ ((struct w32_display_info
*));
371 void x_lower_frame
P_ ((struct frame
*));
372 void x_scroll_bar_clear
P_ ((struct frame
*));
373 void x_wm_set_size_hint
P_ ((struct frame
*, long, int));
374 void x_raise_frame
P_ ((struct frame
*));
375 void x_set_window_size
P_ ((struct frame
*, int, int, int));
376 void x_wm_set_window_state
P_ ((struct frame
*, int));
377 void x_wm_set_icon_pixmap
P_ ((struct frame
*, int));
378 void w32_initialize
P_ ((void));
379 static void x_font_min_bounds
P_ ((XFontStruct
*, int *, int *));
380 int x_compute_min_glyph_bounds
P_ ((struct frame
*));
381 static void x_draw_phys_cursor_glyph
P_ ((struct window
*,
383 enum draw_glyphs_face
));
384 static void x_update_end
P_ ((struct frame
*));
385 static void w32_frame_up_to_date
P_ ((struct frame
*));
386 static void w32_set_terminal_modes
P_ ((void));
387 static void w32_reset_terminal_modes
P_ ((void));
388 static void w32_cursor_to
P_ ((int, int, int, int));
389 static void x_write_glyphs
P_ ((struct glyph
*, int));
390 static void x_clear_end_of_line
P_ ((int));
391 static void x_clear_frame
P_ ((void));
392 static void x_clear_cursor
P_ ((struct window
*));
393 static void frame_highlight
P_ ((struct frame
*));
394 static void frame_unhighlight
P_ ((struct frame
*));
395 static void x_new_focus_frame
P_ ((struct w32_display_info
*,
397 static void w32_frame_rehighlight
P_ ((struct frame
*));
398 static void x_frame_rehighlight
P_ ((struct w32_display_info
*));
399 static void x_draw_hollow_cursor
P_ ((struct window
*, struct glyph_row
*));
400 static void x_draw_bar_cursor
P_ ((struct window
*, struct glyph_row
*, int,
401 enum text_cursor_kinds
));
402 static void expose_frame
P_ ((struct frame
*, int, int, int, int));
403 static int expose_window_tree
P_ ((struct window
*, RECT
*));
404 static int expose_window
P_ ((struct window
*, RECT
*));
405 static void expose_area
P_ ((struct window
*, struct glyph_row
*,
406 RECT
*, enum glyph_row_area
));
407 static int expose_line
P_ ((struct window
*, struct glyph_row
*,
409 void x_update_cursor
P_ ((struct frame
*, int));
410 static void x_update_cursor_in_window_tree
P_ ((struct window
*, int));
411 static void x_update_window_cursor
P_ ((struct window
*, int));
412 static void x_erase_phys_cursor
P_ ((struct window
*));
413 void x_display_cursor
P_ ((struct window
*w
, int, int, int, int, int));
414 void x_display_and_set_cursor
P_ ((struct window
*, int, int, int, int, int));
415 static void w32_draw_fringe_bitmap
P_ ((struct window
*, HDC hdc
,
417 enum fringe_bitmap_type
, int left_p
));
418 static void w32_clip_to_row
P_ ((struct window
*, struct glyph_row
*,
420 static int x_phys_cursor_in_rect_p
P_ ((struct window
*, RECT
*));
421 static void x_draw_row_fringe_bitmaps
P_ ((struct window
*,
422 struct glyph_row
*));
423 static void notice_overwritten_cursor
P_ ((struct window
*,
425 int, int, int, int));
427 static Lisp_Object Qvendor_specific_keysyms
;
430 /***********************************************************************
432 ***********************************************************************/
436 /* This is a function useful for recording debugging information about
437 the sequence of occurrences in this file. */
445 struct record event_record
[100];
447 int event_record_index
;
449 record_event (locus
, type
)
453 if (event_record_index
== sizeof (event_record
) / sizeof (struct record
))
454 event_record_index
= 0;
456 event_record
[event_record_index
].locus
= locus
;
457 event_record
[event_record_index
].type
= type
;
458 event_record_index
++;
464 void XChangeGC (void * ignore
, XGCValues
* gc
, unsigned long mask
,
467 if (mask
& GCForeground
)
468 gc
->foreground
= xgcv
->foreground
;
469 if (mask
& GCBackground
)
470 gc
->background
= xgcv
->background
;
472 gc
->font
= xgcv
->font
;
475 XGCValues
*XCreateGC (void * ignore
, Window window
, unsigned long mask
,
478 XGCValues
*gc
= (XGCValues
*) xmalloc (sizeof (XGCValues
));
479 bzero (gc
, sizeof (XGCValues
));
481 XChangeGC (ignore
, gc
, mask
, xgcv
);
486 void XGetGCValues (void* ignore
, XGCValues
*gc
,
487 unsigned long mask
, XGCValues
*xgcv
)
489 XChangeGC (ignore
, xgcv
, mask
, gc
);
493 w32_set_clip_rectangle (HDC hdc
, RECT
*rect
)
497 HRGN clip_region
= CreateRectRgnIndirect (rect
);
498 SelectClipRgn (hdc
, clip_region
);
499 DeleteObject (clip_region
);
502 SelectClipRgn (hdc
, NULL
);
506 /* Draw a hollow rectangle at the specified position. */
508 w32_draw_rectangle (HDC hdc
, XGCValues
*gc
, int x
, int y
,
509 int width
, int height
)
514 hb
= CreateSolidBrush (gc
->background
);
515 hp
= CreatePen (PS_SOLID
, 0, gc
->foreground
);
516 oldhb
= SelectObject (hdc
, hb
);
517 oldhp
= SelectObject (hdc
, hp
);
519 Rectangle (hdc
, x
, y
, x
+ width
, y
+ height
);
521 SelectObject (hdc
, oldhb
);
522 SelectObject (hdc
, oldhp
);
527 /* Draw a filled rectangle at the specified position. */
529 w32_fill_rect (f
, hdc
, pix
, lprect
)
537 hb
= CreateSolidBrush (pix
);
538 FillRect (hdc
, lprect
, hb
);
547 HDC hdc
= get_frame_dc (f
);
549 /* Under certain conditions, this can be called at startup with
550 a console frame pointer before the GUI frame is created. An HDC
551 of 0 indicates this. */
554 GetClientRect (FRAME_W32_WINDOW (f
), &rect
);
555 w32_clear_rect (f
, hdc
, &rect
);
558 release_frame_dc (f
, hdc
);
562 /***********************************************************************
563 Starting and ending an update
564 ***********************************************************************/
566 /* Start an update of frame F. This function is installed as a hook
567 for update_begin, i.e. it is called when update_begin is called.
568 This function is called prior to calls to x_update_window_begin for
569 each window being updated. */
575 struct w32_display_info
*display_info
= FRAME_W32_DISPLAY_INFO (f
);
577 if (! FRAME_W32_P (f
))
580 /* Regenerate display palette before drawing if list of requested
581 colors has changed. */
582 if (display_info
->regen_palette
)
584 w32_regenerate_palette (f
);
585 display_info
->regen_palette
= FALSE
;
590 /* Start update of window W. Set the global variable updated_window
591 to the window being updated and set output_cursor to the cursor
595 x_update_window_begin (w
)
598 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
599 struct w32_display_info
*display_info
= FRAME_W32_DISPLAY_INFO (f
);
601 /* Hide the system caret during an update. */
602 if (w32_use_visible_system_caret
)
603 SendMessage (w32_system_caret_hwnd
, WM_EMACS_HIDE_CARET
, 0, 0);
606 set_output_cursor (&w
->cursor
);
610 if (f
== display_info
->mouse_face_mouse_frame
)
612 /* Don't do highlighting for mouse motion during the update. */
613 display_info
->mouse_face_defer
= 1;
615 /* If F needs to be redrawn, simply forget about any prior mouse
617 if (FRAME_GARBAGED_P (f
))
618 display_info
->mouse_face_window
= Qnil
;
620 #if 0 /* Rows in a current matrix containing glyphs in mouse-face have
621 their mouse_face_p flag set, which means that they are always
622 unequal to rows in a desired matrix which never have that
623 flag set. So, rows containing mouse-face glyphs are never
624 scrolled, and we don't have to switch the mouse highlight off
625 here to prevent it from being scrolled. */
627 /* Can we tell that this update does not affect the window
628 where the mouse highlight is? If so, no need to turn off.
629 Likewise, don't do anything if the frame is garbaged;
630 in that case, the frame's current matrix that we would use
631 is all wrong, and we will redisplay that line anyway. */
632 if (!NILP (display_info
->mouse_face_window
)
633 && w
== XWINDOW (display_info
->mouse_face_window
))
637 for (i
= 0; i
< w
->desired_matrix
->nrows
; ++i
)
638 if (MATRIX_ROW_ENABLED_P (w
->desired_matrix
, i
))
641 if (i
< w
->desired_matrix
->nrows
)
642 clear_mouse_face (display_info
);
651 /* Draw a vertical window border to the right of window W if W doesn't
652 have vertical scroll bars. */
655 x_draw_vertical_border (w
)
658 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
660 /* Redraw borders between horizontally adjacent windows. Don't
661 do it for frames with vertical scroll bars because either the
662 right scroll bar of a window, or the left scroll bar of its
663 neighbor will suffice as a border. */
664 if (!WINDOW_RIGHTMOST_P (w
)
665 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
670 window_box_edges (w
, -1, (int *) &r
.left
, (int *) &r
.top
,
671 (int *) &r
.right
, (int *) &r
.bottom
);
672 r
.left
= r
.right
+ FRAME_X_RIGHT_FRINGE_WIDTH (f
);
673 r
.right
= r
.left
+ 1;
676 hdc
= get_frame_dc (f
);
677 w32_fill_rect (f
, hdc
, FRAME_FOREGROUND_PIXEL (f
), &r
);
678 release_frame_dc (f
, hdc
);
683 /* End update of window W (which is equal to updated_window).
685 Draw vertical borders between horizontally adjacent windows, and
686 display W's cursor if CURSOR_ON_P is non-zero.
688 MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing
689 glyphs in mouse-face were overwritten. In that case we have to
690 make sure that the mouse-highlight is properly redrawn.
692 W may be a menu bar pseudo-window in case we don't have X toolkit
693 support. Such windows don't have a cursor, so don't display it
697 x_update_window_end (w
, cursor_on_p
, mouse_face_overwritten_p
)
699 int cursor_on_p
, mouse_face_overwritten_p
;
701 struct w32_display_info
*dpyinfo
702 = FRAME_W32_DISPLAY_INFO (XFRAME (w
->frame
));
704 if (!w
->pseudo_window_p
)
709 x_display_and_set_cursor (w
, 1, output_cursor
.hpos
,
711 output_cursor
.x
, output_cursor
.y
);
713 x_draw_vertical_border (w
);
717 /* If a row with mouse-face was overwritten, arrange for
718 XTframe_up_to_date to redisplay the mouse highlight. */
719 if (mouse_face_overwritten_p
)
721 dpyinfo
->mouse_face_beg_row
= dpyinfo
->mouse_face_beg_col
= -1;
722 dpyinfo
->mouse_face_end_row
= dpyinfo
->mouse_face_end_col
= -1;
723 dpyinfo
->mouse_face_window
= Qnil
;
726 /* Unhide the caret. This won't actually show the cursor, unless it
727 was visible before the corresponding call to HideCaret in
728 x_update_window_begin. */
729 if (w32_use_visible_system_caret
)
730 SendMessage (w32_system_caret_hwnd
, WM_EMACS_SHOW_CARET
, 0, 0);
732 updated_window
= NULL
;
736 /* End update of frame F. This function is installed as a hook in
743 if (! FRAME_W32_P (f
))
746 /* Mouse highlight may be displayed again. */
747 FRAME_W32_DISPLAY_INFO (f
)->mouse_face_defer
= 0;
751 /* This function is called from various places in xdisp.c whenever a
752 complete update has been performed. The global variable
753 updated_window is not available here. */
756 w32_frame_up_to_date (f
)
761 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
762 if (dpyinfo
->mouse_face_deferred_gc
763 || f
== dpyinfo
->mouse_face_mouse_frame
)
766 if (dpyinfo
->mouse_face_mouse_frame
)
767 note_mouse_highlight (dpyinfo
->mouse_face_mouse_frame
,
768 dpyinfo
->mouse_face_mouse_x
,
769 dpyinfo
->mouse_face_mouse_y
);
770 dpyinfo
->mouse_face_deferred_gc
= 0;
777 /* Draw truncation mark bitmaps, continuation mark bitmaps, overlay
778 arrow bitmaps, or clear the fringes if no bitmaps are required
779 before DESIRED_ROW is made current. The window being updated is
780 found in updated_window. This function is called from
781 update_window_line only if it is known that there are differences
782 between bitmaps to be drawn between current row and DESIRED_ROW. */
785 x_after_update_window_line (desired_row
)
786 struct glyph_row
*desired_row
;
788 struct window
*w
= updated_window
;
794 if (!desired_row
->mode_line_p
&& !w
->pseudo_window_p
)
797 x_draw_row_fringe_bitmaps (w
, desired_row
);
801 /* When a window has disappeared, make sure that no rest of
802 full-width rows stays visible in the internal border. Could
803 check here if updated_window is the leftmost/rightmost window,
804 but I guess it's not worth doing since vertically split windows
805 are almost never used, internal border is rarely set, and the
806 overhead is very small. */
807 if (windows_or_buffers_changed
808 && desired_row
->full_width_p
809 && (f
= XFRAME (w
->frame
),
810 width
= FRAME_INTERNAL_BORDER_WIDTH (f
),
812 && (height
= desired_row
->visible_height
,
815 int y
= WINDOW_TO_FRAME_PIXEL_Y (w
, max (0, desired_row
->y
));
816 /* Internal border is drawn below the tool bar. */
817 if (WINDOWP (f
->tool_bar_window
)
818 && w
== XWINDOW (f
->tool_bar_window
))
823 HDC hdc
= get_frame_dc (f
);
824 w32_clear_area (f
, hdc
, 0, y
, width
, height
);
825 w32_clear_area (f
, hdc
, f
->output_data
.w32
->pixel_width
- width
,
827 release_frame_dc (f
, hdc
);
834 /* Draw the bitmap WHICH in one of the left or right fringes of
835 window W. ROW is the glyph row for which to display the bitmap; it
836 determines the vertical position at which the bitmap has to be
840 w32_draw_fringe_bitmap (w
, hdc
, row
, which
, left_p
)
843 struct glyph_row
*row
;
844 enum fringe_bitmap_type which
;
847 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
848 Window window
= FRAME_W32_WINDOW (f
);
856 /* Must clip because of partially visible lines. */
857 w32_clip_to_row (w
, row
, hdc
, 1);
859 /* Convert row to frame coordinates. */
860 y
= WINDOW_TO_FRAME_PIXEL_Y (w
, row
->y
);
864 case NO_FRINGE_BITMAP
:
869 case LEFT_TRUNCATION_BITMAP
:
875 case OVERLAY_ARROW_BITMAP
:
881 case RIGHT_TRUNCATION_BITMAP
:
887 case CONTINUED_LINE_BITMAP
:
888 wd
= continued_width
;
889 h
= continued_height
;
890 pixmap
= continued_bmp
;
893 case CONTINUATION_LINE_BITMAP
:
894 wd
= continuation_width
;
895 h
= continuation_height
;
896 pixmap
= continuation_bmp
;
901 h
= zv_height
- (y
% zv_period
);
909 /* Clip bitmap if too high. */
913 /* Set dy to the offset in the row to start drawing the bitmap. */
914 dy
= (row
->height
- h
) / 2;
916 /* Draw the bitmap. */
917 face
= FACE_FROM_ID (f
, FRINGE_FACE_ID
);
918 PREPARE_FACE_FOR_DISPLAY (f
, face
);
920 /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
925 if (wd
> FRAME_X_LEFT_FRINGE_WIDTH (f
))
926 wd
= FRAME_X_LEFT_FRINGE_WIDTH (f
);
927 x
= (WINDOW_TO_FRAME_PIXEL_X (w
, 0)
929 - (FRAME_X_LEFT_FRINGE_WIDTH (f
) - wd
) / 2);
930 if (wd
< FRAME_X_LEFT_FRINGE_WIDTH (f
) || row
->height
> h
)
932 /* If W has a vertical border to its left, don't draw over it. */
933 int border
= ((XFASTINT (w
->left
) > 0
934 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
936 b1
= (window_box_left (w
, -1)
937 - FRAME_X_LEFT_FRINGE_WIDTH (f
)
939 b2
= (FRAME_X_LEFT_FRINGE_WIDTH (f
) - border
);
944 if (wd
> FRAME_X_RIGHT_FRINGE_WIDTH (f
))
945 wd
= FRAME_X_RIGHT_FRINGE_WIDTH (f
);
946 x
= (window_box_right (w
, -1)
947 + (FRAME_X_RIGHT_FRINGE_WIDTH (f
) - wd
) / 2);
948 /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
950 if (wd
< FRAME_X_RIGHT_FRINGE_WIDTH (f
) || row
->height
> h
)
952 b1
= window_box_right (w
, -1);
953 b2
= FRAME_X_RIGHT_FRINGE_WIDTH (f
);
959 int header_line_height
= WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w
);
961 w32_fill_area (f
, hdc
, face
->background
,
963 WINDOW_TO_FRAME_PIXEL_Y (w
, max (header_line_height
,
966 row
->visible_height
);
969 if (which
== NO_FRINGE_BITMAP
)
972 compat_hdc
= CreateCompatibleDC (hdc
);
975 horig_obj
= SelectObject (compat_hdc
, pixmap
);
976 SetTextColor (hdc
, face
->background
);
977 SetBkColor (hdc
, face
->foreground
);
979 BitBlt (hdc
, x
, y
+ dy
, wd
, h
, compat_hdc
, 0,
980 (which
== ZV_LINE_BITMAP
? (row
->y
% zv_period
) : 0),
983 SelectObject (compat_hdc
, horig_obj
);
984 DeleteDC (compat_hdc
);
989 /* Draw fringe bitmaps for glyph row ROW on window W. Call this
990 function with input blocked. */
993 x_draw_row_fringe_bitmaps (w
, row
)
995 struct glyph_row
*row
;
997 struct frame
*f
= XFRAME (w
->frame
);
998 enum fringe_bitmap_type bitmap
;
1001 xassert (interrupt_input_blocked
);
1003 /* If row is completely invisible, because of vscrolling, we
1004 don't have to draw anything. */
1005 if (row
->visible_height
<= 0)
1008 hdc
= get_frame_dc (f
);
1010 if (FRAME_X_LEFT_FRINGE_WIDTH (f
) != 0)
1012 /* Decide which bitmap to draw in the left fringe. */
1013 if (row
->overlay_arrow_p
)
1014 bitmap
= OVERLAY_ARROW_BITMAP
;
1015 else if (row
->truncated_on_left_p
)
1016 bitmap
= LEFT_TRUNCATION_BITMAP
;
1017 else if (MATRIX_ROW_CONTINUATION_LINE_P (row
))
1018 bitmap
= CONTINUATION_LINE_BITMAP
;
1019 else if (row
->indicate_empty_line_p
)
1020 bitmap
= ZV_LINE_BITMAP
;
1022 bitmap
= NO_FRINGE_BITMAP
;
1024 w32_draw_fringe_bitmap (w
, hdc
, row
, bitmap
, 1);
1027 if (FRAME_X_RIGHT_FRINGE_WIDTH (f
) != 0)
1029 /* Decide which bitmap to draw in the right fringe. */
1030 if (row
->truncated_on_right_p
)
1031 bitmap
= RIGHT_TRUNCATION_BITMAP
;
1032 else if (row
->continued_p
)
1033 bitmap
= CONTINUED_LINE_BITMAP
;
1034 else if (row
->indicate_empty_line_p
&& FRAME_X_LEFT_FRINGE_WIDTH (f
) == 0)
1035 bitmap
= ZV_LINE_BITMAP
;
1037 bitmap
= NO_FRINGE_BITMAP
;
1039 w32_draw_fringe_bitmap (w
, hdc
, row
, bitmap
, 0);
1042 release_frame_dc (f
, hdc
);
1046 /* This is called when starting Emacs and when restarting after
1047 suspend. When starting Emacs, no window is mapped. And nothing
1048 must be done to Emacs's own window if it is suspended (though that
1052 w32_set_terminal_modes (void)
1056 /* This is called when exiting or suspending Emacs. Exiting will make
1057 the W32 windows go away, and suspending requires no action. */
1060 w32_reset_terminal_modes (void)
1066 /***********************************************************************
1068 ***********************************************************************/
1070 /* Set the global variable output_cursor to CURSOR. All cursor
1071 positions are relative to updated_window. */
1074 set_output_cursor (cursor
)
1075 struct cursor_pos
*cursor
;
1077 output_cursor
.hpos
= cursor
->hpos
;
1078 output_cursor
.vpos
= cursor
->vpos
;
1079 output_cursor
.x
= cursor
->x
;
1080 output_cursor
.y
= cursor
->y
;
1084 /* Set a nominal cursor position.
1086 HPOS and VPOS are column/row positions in a window glyph matrix. X
1087 and Y are window text area relative pixel positions.
1089 If this is done during an update, updated_window will contain the
1090 window that is being updated and the position is the future output
1091 cursor position for that window. If updated_window is null, use
1092 selected_window and display the cursor at the given position. */
1095 w32_cursor_to (vpos
, hpos
, y
, x
)
1096 int vpos
, hpos
, y
, x
;
1100 /* If updated_window is not set, work on selected_window. */
1104 w
= XWINDOW (selected_window
);
1106 /* Set the output cursor. */
1107 output_cursor
.hpos
= hpos
;
1108 output_cursor
.vpos
= vpos
;
1109 output_cursor
.x
= x
;
1110 output_cursor
.y
= y
;
1112 /* If not called as part of an update, really display the cursor.
1113 This will also set the cursor position of W. */
1114 if (updated_window
== NULL
)
1117 x_display_cursor (w
, 1, hpos
, vpos
, x
, y
);
1124 /***********************************************************************
1126 ***********************************************************************/
1128 /* Function prototypes of this page. */
1130 static struct face
*x_get_glyph_face_and_encoding
P_ ((struct frame
*,
1134 static struct face
*x_get_char_face_and_encoding
P_ ((struct frame
*, int,
1135 int, wchar_t *, int));
1136 static XCharStruct
*w32_per_char_metric
P_ ((XFontStruct
*,
1138 enum w32_char_font_type
));
1139 static enum w32_char_font_type
1140 w32_encode_char
P_ ((int, wchar_t *, struct font_info
*, int *));
1141 static void x_append_glyph
P_ ((struct it
*));
1142 static void x_append_composite_glyph
P_ ((struct it
*));
1143 static void x_append_stretch_glyph
P_ ((struct it
*it
, Lisp_Object
,
1145 static void x_produce_glyphs
P_ ((struct it
*));
1146 static void x_produce_image_glyph
P_ ((struct it
*it
));
1149 /* Dealing with bits of wchar_t as if they were an XChar2B. */
1150 #define BUILD_WCHAR_T(byte1, byte2) \
1151 ((wchar_t)((((byte1) & 0x00ff) << 8) | ((byte2) & 0x00ff)))
1155 (((ch) & 0xff00) >> 8)
1161 /* Get metrics of character CHAR2B in FONT. Value is always non-null.
1162 If CHAR2B is not contained in FONT, the font's default character
1163 metric is returned. */
1166 w32_bdf_per_char_metric (font
, char2b
, dim
, pcm
)
1172 glyph_metric
* bdf_metric
;
1176 buf
[0] = (char)(*char2b
);
1179 buf
[0] = BYTE1 (*char2b
);
1180 buf
[1] = BYTE2 (*char2b
);
1183 bdf_metric
= w32_BDF_TextMetric (font
->bdf
, buf
, dim
);
1187 pcm
->width
= bdf_metric
->dwidth
;
1188 pcm
->lbearing
= bdf_metric
->bbox
;
1189 pcm
->rbearing
= bdf_metric
->dwidth
1190 - (bdf_metric
->bbox
+ bdf_metric
->bbw
);
1191 pcm
->ascent
= bdf_metric
->bboy
+ bdf_metric
->bbh
;
1192 pcm
->descent
= -bdf_metric
->bboy
;
1201 w32_native_per_char_metric (font
, char2b
, font_type
, pcm
)
1204 enum w32_char_font_type font_type
;
1207 HDC hdc
= GetDC (NULL
);
1209 BOOL retval
= FALSE
;
1211 xassert (font
&& char2b
);
1212 xassert (font
->hfont
);
1213 xassert (font_type
== UNICODE_FONT
|| font_type
== ANSI_FONT
);
1215 old_font
= SelectObject (hdc
, font
->hfont
);
1217 if ((font
->tm
.tmPitchAndFamily
& TMPF_TRUETYPE
) != 0)
1221 if (font_type
== UNICODE_FONT
)
1222 retval
= GetCharABCWidthsW (hdc
, *char2b
, *char2b
, &char_widths
);
1224 retval
= GetCharABCWidthsA (hdc
, *char2b
, *char2b
, &char_widths
);
1229 /* Disabled until we can find a way to get the right results
1230 on all versions of Windows. */
1232 /* Don't trust the ABC widths. For synthesized fonts they are
1233 wrong, and so is the result of GetCharWidth()! */
1235 GetCharWidth (hdc
, *char2b
, *char2b
, &real_width
);
1237 pcm
->width
= char_widths
.abcA
+ char_widths
.abcB
+ char_widths
.abcC
;
1239 /* As far as I can tell, this is the best way to determine what
1240 ExtTextOut will do with the broken font. */
1241 if (pcm
->width
!= real_width
)
1242 pcm
->width
= (pcm
->width
+ real_width
) / 2;
1244 pcm
->lbearing
= char_widths
.abcA
;
1245 pcm
->rbearing
= char_widths
.abcA
+ char_widths
.abcB
;
1246 pcm
->ascent
= FONT_BASE (font
);
1247 pcm
->descent
= FONT_DESCENT (font
);
1253 /* Either font is not a True-type font, or GetCharABCWidthsW
1254 failed (it is not supported on Windows 9x for instance), so we
1255 can't determine the full info we would like. All is not lost
1256 though - we can call GetTextExtentPoint32 to get rbearing and
1257 deduce width based on the font's per-string overhang. lbearing
1258 is assumed to be zero. */
1260 /* TODO: Some Thai characters (and other composites if Windows
1261 supports them) do have lbearing, and report their total width
1262 as zero. Need some way of handling them when
1263 GetCharABCWidthsW fails. */
1266 if (font_type
== UNICODE_FONT
)
1267 retval
= GetTextExtentPoint32W (hdc
, char2b
, 1, &sz
);
1269 retval
= GetTextExtentPoint32A (hdc
, (char*)char2b
, 1, &sz
);
1273 pcm
->width
= sz
.cx
- font
->tm
.tmOverhang
;
1274 pcm
->rbearing
= sz
.cx
;
1276 pcm
->ascent
= FONT_BASE (font
);
1277 pcm
->descent
= FONT_DESCENT (font
);
1282 if (pcm
->width
== 0 && (pcm
->rbearing
- pcm
->lbearing
) == 0)
1287 SelectObject (hdc
, old_font
);
1288 ReleaseDC (NULL
, hdc
);
1294 static XCharStruct
*
1295 w32_per_char_metric (font
, char2b
, font_type
)
1298 enum w32_char_font_type font_type
;
1300 /* The result metric information. */
1304 xassert (font
&& char2b
);
1305 xassert (font_type
!= UNKNOWN_FONT
);
1307 /* Handle the common cases quickly. */
1308 if (!font
->bdf
&& font
->per_char
== NULL
)
1309 /* TODO: determine whether char2b exists in font? */
1310 return &font
->max_bounds
;
1311 else if (!font
->bdf
&& *char2b
< 128)
1312 return &font
->per_char
[*char2b
];
1314 pcm
= &font
->scratch
;
1316 if (font_type
== BDF_1D_FONT
)
1317 retval
= w32_bdf_per_char_metric (font
, char2b
, 1, pcm
);
1318 else if (font_type
== BDF_2D_FONT
)
1319 retval
= w32_bdf_per_char_metric (font
, char2b
, 2, pcm
);
1321 retval
= w32_native_per_char_metric (font
, char2b
, font_type
, pcm
);
1330 w32_cache_char_metrics (font
)
1333 wchar_t char2b
= L
'x';
1335 /* Cache char metrics for the common cases. */
1338 /* TODO: determine whether font is fixed-pitch. */
1339 if (!w32_bdf_per_char_metric (font
, &char2b
, 1, &font
->max_bounds
))
1341 /* Use the font width and height as max bounds, as not all BDF
1342 fonts contain the letter 'x'. */
1343 font
->max_bounds
.width
= FONT_MAX_WIDTH (font
);
1344 font
->max_bounds
.lbearing
= -font
->bdf
->llx
;
1345 font
->max_bounds
.rbearing
= FONT_MAX_WIDTH (font
) - font
->bdf
->urx
;
1346 font
->max_bounds
.ascent
= FONT_BASE (font
);
1347 font
->max_bounds
.descent
= FONT_DESCENT (font
);
1352 if (((font
->tm
.tmPitchAndFamily
& TMPF_FIXED_PITCH
) != 0)
1353 /* Some fonts (eg DBCS fonts) are marked as fixed width even
1354 though they contain characters of different widths. */
1355 || (font
->tm
.tmMaxCharWidth
!= font
->tm
.tmAveCharWidth
))
1357 /* Font is not fixed pitch, so cache per_char info for the
1358 ASCII characters. It would be much more work, and probably
1359 not worth it, to cache other chars, since we may change
1360 between using Unicode and ANSI text drawing functions at
1364 font
->per_char
= xmalloc (128 * sizeof(XCharStruct
));
1365 for (i
= 0; i
< 128; i
++)
1368 w32_native_per_char_metric (font
, &char2b
, ANSI_FONT
,
1369 &font
->per_char
[i
]);
1373 w32_native_per_char_metric (font
, &char2b
, ANSI_FONT
,
1379 /* Determine if a font is double byte. */
1380 int w32_font_is_double_byte (XFontStruct
*font
)
1382 return font
->double_byte_p
;
1387 w32_use_unicode_for_codepage (codepage
)
1390 /* If the current codepage is supported, use Unicode for output. */
1391 return (w32_enable_unicode_output
1392 && codepage
!= CP_8BIT
1393 && (codepage
== CP_UNICODE
|| IsValidCodePage (codepage
)));
1396 /* Encode CHAR2B using encoding information from FONT_INFO. CHAR2B is
1397 the two-byte form of C. Encoding is returned in *CHAR2B. */
1399 static INLINE
enum w32_char_font_type
1400 w32_encode_char (c
, char2b
, font_info
, two_byte_p
)
1403 struct font_info
*font_info
;
1406 int charset
= CHAR_CHARSET (c
);
1410 XFontStruct
*font
= font_info
->font
;
1412 xassert (two_byte_p
);
1414 *two_byte_p
= w32_font_is_double_byte (font
);
1416 /* FONT_INFO may define a scheme by which to encode byte1 and byte2.
1417 This may be either a program in a special encoder language or a
1419 if (font_info
->font_encoder
)
1421 /* It's a program. */
1422 struct ccl_program
*ccl
= font_info
->font_encoder
;
1424 if (CHARSET_DIMENSION (charset
) == 1)
1426 ccl
->reg
[0] = charset
;
1427 ccl
->reg
[1] = BYTE2 (*char2b
);
1431 ccl
->reg
[0] = charset
;
1432 ccl
->reg
[1] = BYTE1 (*char2b
);
1433 ccl
->reg
[2] = BYTE2 (*char2b
);
1436 ccl_driver (ccl
, NULL
, NULL
, 0, 0, NULL
);
1438 /* We assume that MSBs are appropriately set/reset by CCL
1440 if (!*two_byte_p
) /* 1-byte font */
1441 *char2b
= BUILD_WCHAR_T (0, ccl
->reg
[1]);
1443 *char2b
= BUILD_WCHAR_T (ccl
->reg
[1], ccl
->reg
[2]);
1445 else if (font_info
->encoding
[charset
])
1447 /* Fixed encoding scheme. See fontset.h for the meaning of the
1448 encoding numbers. */
1449 int enc
= font_info
->encoding
[charset
];
1451 if ((enc
== 1 || enc
== 2)
1452 && CHARSET_DIMENSION (charset
) == 2)
1453 *char2b
= BUILD_WCHAR_T (BYTE1 (*char2b
) | 0x80, BYTE2 (*char2b
));
1455 if (enc
== 1 || enc
== 3
1456 || (enc
== 4 && CHARSET_DIMENSION (charset
) == 1))
1457 *char2b
= BUILD_WCHAR_T (BYTE1 (*char2b
), BYTE2 (*char2b
) | 0x80);
1462 ENCODE_SJIS (BYTE1 (*char2b
), BYTE2 (*char2b
),
1464 *char2b
= BUILD_WCHAR_T (sjis1
, sjis2
);
1467 codepage
= font_info
->codepage
;
1469 /* If charset is not ASCII or Latin-1, may need to move it into
1471 if ( font
&& !font
->bdf
&& w32_use_unicode_for_codepage (codepage
)
1472 && charset
!= CHARSET_ASCII
&& charset
!= charset_latin_iso8859_1
1473 && charset
!= CHARSET_8_BIT_CONTROL
&& charset
!= CHARSET_8_BIT_GRAPHIC
)
1476 temp
[0] = BYTE1 (*char2b
);
1477 temp
[1] = BYTE2 (*char2b
);
1479 if (codepage
!= CP_UNICODE
)
1482 MultiByteToWideChar (codepage
, 0, temp
, 2, char2b
, 1);
1484 MultiByteToWideChar (codepage
, 0, temp
+1, 1, char2b
, 1);
1490 return UNKNOWN_FONT
;
1491 else if (font
->bdf
&& CHARSET_DIMENSION (charset
) == 1)
1496 return UNICODE_FONT
;
1502 /* Get face and two-byte form of character C in face FACE_ID on frame
1503 F. The encoding of C is returned in *CHAR2B. MULTIBYTE_P non-zero
1504 means we want to display multibyte text. Value is a pointer to a
1505 realized face that is ready for display. */
1507 static INLINE
struct face
*
1508 x_get_char_face_and_encoding (f
, c
, face_id
, char2b
, multibyte_p
)
1514 struct face
*face
= FACE_FROM_ID (f
, face_id
);
1518 /* Unibyte case. We don't have to encode, but we have to make
1519 sure to use a face suitable for unibyte. */
1520 *char2b
= BUILD_WCHAR_T (0, c
);
1521 face_id
= FACE_FOR_CHAR (f
, face
, c
);
1522 face
= FACE_FROM_ID (f
, face_id
);
1524 else if (c
< 128 && face_id
< BASIC_FACE_ID_SENTINEL
)
1526 /* Case of ASCII in a face known to fit ASCII. */
1527 *char2b
= BUILD_WCHAR_T (0, c
);
1531 int c1
, c2
, charset
;
1533 /* Split characters into bytes. If c2 is -1 afterwards, C is
1534 really a one-byte character so that byte1 is zero. */
1535 SPLIT_CHAR (c
, charset
, c1
, c2
);
1537 *char2b
= BUILD_WCHAR_T (c1
, c2
);
1539 *char2b
= BUILD_WCHAR_T (0, c1
);
1541 /* Maybe encode the character in *CHAR2B. */
1542 if (face
->font
!= NULL
)
1544 struct font_info
*font_info
1545 = FONT_INFO_FROM_ID (f
, face
->font_info_id
);
1547 w32_encode_char (c
, char2b
, font_info
, &multibyte_p
);
1551 /* Make sure X resources of the face are allocated. */
1552 xassert (face
!= NULL
);
1553 PREPARE_FACE_FOR_DISPLAY (f
, face
);
1559 /* Get face and two-byte form of character glyph GLYPH on frame F.
1560 The encoding of GLYPH->u.ch is returned in *CHAR2B. Value is
1561 a pointer to a realized face that is ready for display. */
1563 static INLINE
struct face
*
1564 x_get_glyph_face_and_encoding (f
, glyph
, char2b
, two_byte_p
)
1566 struct glyph
*glyph
;
1573 xassert (glyph
->type
== CHAR_GLYPH
);
1574 face
= FACE_FROM_ID (f
, glyph
->face_id
);
1579 two_byte_p
= &dummy
;
1581 if (!glyph
->multibyte_p
)
1583 /* Unibyte case. We don't have to encode, but we have to make
1584 sure to use a face suitable for unibyte. */
1585 *char2b
= BUILD_WCHAR_T (0, glyph
->u
.ch
);
1587 else if (glyph
->u
.ch
< 128
1588 && glyph
->face_id
< BASIC_FACE_ID_SENTINEL
)
1590 /* Case of ASCII in a face known to fit ASCII. */
1591 *char2b
= BUILD_WCHAR_T (0, glyph
->u
.ch
);
1595 int c1
, c2
, charset
;
1597 /* Split characters into bytes. If c2 is -1 afterwards, C is
1598 really a one-byte character so that byte1 is zero. */
1599 SPLIT_CHAR (glyph
->u
.ch
, charset
, c1
, c2
);
1601 *char2b
= BUILD_WCHAR_T (c1
, c2
);
1603 *char2b
= BUILD_WCHAR_T (0, c1
);
1605 /* Maybe encode the character in *CHAR2B. */
1606 if (charset
!= CHARSET_ASCII
)
1608 struct font_info
*font_info
1609 = FONT_INFO_FROM_ID (f
, face
->font_info_id
);
1612 glyph
->w32_font_type
1613 = w32_encode_char (glyph
->u
.ch
, char2b
, font_info
, two_byte_p
);
1618 /* Make sure X resources of the face are allocated. */
1619 xassert (face
!= NULL
);
1620 PREPARE_FACE_FOR_DISPLAY (f
, face
);
1625 /* Store one glyph for IT->char_to_display in IT->glyph_row.
1626 Called from x_produce_glyphs when IT->glyph_row is non-null. */
1632 struct glyph
*glyph
;
1633 enum glyph_row_area area
= it
->area
;
1635 xassert (it
->glyph_row
);
1636 xassert (it
->char_to_display
!= '\n' && it
->char_to_display
!= '\t');
1638 glyph
= it
->glyph_row
->glyphs
[area
] + it
->glyph_row
->used
[area
];
1639 if (glyph
< it
->glyph_row
->glyphs
[area
+ 1])
1641 glyph
->charpos
= CHARPOS (it
->position
);
1642 glyph
->object
= it
->object
;
1643 glyph
->pixel_width
= it
->pixel_width
;
1644 glyph
->voffset
= it
->voffset
;
1645 glyph
->type
= CHAR_GLYPH
;
1646 glyph
->multibyte_p
= it
->multibyte_p
;
1647 glyph
->left_box_line_p
= it
->start_of_box_run_p
;
1648 glyph
->right_box_line_p
= it
->end_of_box_run_p
;
1649 glyph
->overlaps_vertically_p
= (it
->phys_ascent
> it
->ascent
1650 || it
->phys_descent
> it
->descent
);
1651 glyph
->padding_p
= 0;
1652 glyph
->glyph_not_available_p
= it
->glyph_not_available_p
;
1653 glyph
->face_id
= it
->face_id
;
1654 glyph
->u
.ch
= it
->char_to_display
;
1655 glyph
->w32_font_type
= UNKNOWN_FONT
;
1656 ++it
->glyph_row
->used
[area
];
1660 /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
1661 Called from x_produce_glyphs when IT->glyph_row is non-null. */
1664 x_append_composite_glyph (it
)
1667 struct glyph
*glyph
;
1668 enum glyph_row_area area
= it
->area
;
1670 xassert (it
->glyph_row
);
1672 glyph
= it
->glyph_row
->glyphs
[area
] + it
->glyph_row
->used
[area
];
1673 if (glyph
< it
->glyph_row
->glyphs
[area
+ 1])
1675 glyph
->charpos
= CHARPOS (it
->position
);
1676 glyph
->object
= it
->object
;
1677 glyph
->pixel_width
= it
->pixel_width
;
1678 glyph
->voffset
= it
->voffset
;
1679 glyph
->type
= COMPOSITE_GLYPH
;
1680 glyph
->multibyte_p
= it
->multibyte_p
;
1681 glyph
->left_box_line_p
= it
->start_of_box_run_p
;
1682 glyph
->right_box_line_p
= it
->end_of_box_run_p
;
1683 glyph
->overlaps_vertically_p
= (it
->phys_ascent
> it
->ascent
1684 || it
->phys_descent
> it
->descent
);
1685 glyph
->padding_p
= 0;
1686 glyph
->glyph_not_available_p
= 0;
1687 glyph
->face_id
= it
->face_id
;
1688 glyph
->u
.cmp_id
= it
->cmp_id
;
1689 glyph
->w32_font_type
= UNKNOWN_FONT
;
1690 ++it
->glyph_row
->used
[area
];
1695 /* Change IT->ascent and IT->height according to the setting of
1699 take_vertical_position_into_account (it
)
1704 if (it
->voffset
< 0)
1705 /* Increase the ascent so that we can display the text higher
1707 it
->ascent
+= abs (it
->voffset
);
1709 /* Increase the descent so that we can display the text lower
1711 it
->descent
+= it
->voffset
;
1716 /* Produce glyphs/get display metrics for the image IT is loaded with.
1717 See the description of struct display_iterator in dispextern.h for
1718 an overview of struct display_iterator. */
1721 x_produce_image_glyph (it
)
1727 xassert (it
->what
== IT_IMAGE
);
1729 face
= FACE_FROM_ID (it
->f
, it
->face_id
);
1730 img
= IMAGE_FROM_ID (it
->f
, it
->image_id
);
1733 /* Make sure X resources of the face and image are loaded. */
1734 PREPARE_FACE_FOR_DISPLAY (it
->f
, face
);
1735 prepare_image_for_display (it
->f
, img
);
1737 it
->ascent
= it
->phys_ascent
= image_ascent (img
, face
);
1738 it
->descent
= it
->phys_descent
= img
->height
+ 2 * img
->vmargin
- it
->ascent
;
1739 it
->pixel_width
= img
->width
+ 2 * img
->hmargin
;
1743 if (face
->box
!= FACE_NO_BOX
)
1745 if (face
->box_line_width
> 0)
1747 it
->ascent
+= face
->box_line_width
;
1748 it
->descent
+= face
->box_line_width
;
1751 if (it
->start_of_box_run_p
)
1752 it
->pixel_width
+= abs (face
->box_line_width
);
1753 if (it
->end_of_box_run_p
)
1754 it
->pixel_width
+= abs (face
->box_line_width
);
1757 take_vertical_position_into_account (it
);
1761 struct glyph
*glyph
;
1762 enum glyph_row_area area
= it
->area
;
1764 glyph
= it
->glyph_row
->glyphs
[area
] + it
->glyph_row
->used
[area
];
1765 if (glyph
< it
->glyph_row
->glyphs
[area
+ 1])
1767 glyph
->charpos
= CHARPOS (it
->position
);
1768 glyph
->object
= it
->object
;
1769 glyph
->pixel_width
= it
->pixel_width
;
1770 glyph
->voffset
= it
->voffset
;
1771 glyph
->type
= IMAGE_GLYPH
;
1772 glyph
->multibyte_p
= it
->multibyte_p
;
1773 glyph
->left_box_line_p
= it
->start_of_box_run_p
;
1774 glyph
->right_box_line_p
= it
->end_of_box_run_p
;
1775 glyph
->overlaps_vertically_p
= 0;
1776 glyph
->padding_p
= 0;
1777 glyph
->glyph_not_available_p
= 0;
1778 glyph
->face_id
= it
->face_id
;
1779 glyph
->u
.img_id
= img
->id
;
1780 glyph
->w32_font_type
= UNKNOWN_FONT
;
1781 ++it
->glyph_row
->used
[area
];
1787 /* Append a stretch glyph to IT->glyph_row. OBJECT is the source
1788 of the glyph, WIDTH and HEIGHT are the width and height of the
1789 stretch. ASCENT is the percentage/100 of HEIGHT to use for the
1790 ascent of the glyph (0 <= ASCENT <= 1). */
1793 x_append_stretch_glyph (it
, object
, width
, height
, ascent
)
1799 struct glyph
*glyph
;
1800 enum glyph_row_area area
= it
->area
;
1802 xassert (ascent
>= 0 && ascent
<= 1);
1804 glyph
= it
->glyph_row
->glyphs
[area
] + it
->glyph_row
->used
[area
];
1805 if (glyph
< it
->glyph_row
->glyphs
[area
+ 1])
1807 glyph
->charpos
= CHARPOS (it
->position
);
1808 glyph
->object
= object
;
1809 glyph
->pixel_width
= width
;
1810 glyph
->voffset
= it
->voffset
;
1811 glyph
->type
= STRETCH_GLYPH
;
1812 glyph
->multibyte_p
= it
->multibyte_p
;
1813 glyph
->left_box_line_p
= it
->start_of_box_run_p
;
1814 glyph
->right_box_line_p
= it
->end_of_box_run_p
;
1815 glyph
->overlaps_vertically_p
= 0;
1816 glyph
->padding_p
= 0;
1817 glyph
->glyph_not_available_p
= 0;
1818 glyph
->face_id
= it
->face_id
;
1819 glyph
->u
.stretch
.ascent
= height
* ascent
;
1820 glyph
->u
.stretch
.height
= height
;
1821 glyph
->w32_font_type
= UNKNOWN_FONT
;
1822 ++it
->glyph_row
->used
[area
];
1827 /* Produce a stretch glyph for iterator IT. IT->object is the value
1828 of the glyph property displayed. The value must be a list
1829 `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs
1832 1. `:width WIDTH' specifies that the space should be WIDTH *
1833 canonical char width wide. WIDTH may be an integer or floating
1836 2. `:relative-width FACTOR' specifies that the width of the stretch
1837 should be computed from the width of the first character having the
1838 `glyph' property, and should be FACTOR times that width.
1840 3. `:align-to HPOS' specifies that the space should be wide enough
1841 to reach HPOS, a value in canonical character units.
1843 Exactly one of the above pairs must be present.
1845 4. `:height HEIGHT' specifies that the height of the stretch produced
1846 should be HEIGHT, measured in canonical character units.
1848 5. `:relative-height FACTOR' specifies that the height of the
1849 stretch should be FACTOR times the height of the characters having
1852 Either none or exactly one of 4 or 5 must be present.
1854 6. `:ascent ASCENT' specifies that ASCENT percent of the height
1855 of the stretch should be used for the ascent of the stretch.
1856 ASCENT must be in the range 0 <= ASCENT <= 100. */
1859 ((INTEGERP (X) || FLOATP (X)) \
1865 x_produce_stretch_glyph (it
)
1868 /* (space :width WIDTH :height HEIGHT. */
1870 extern Lisp_Object Qspace
;
1872 extern Lisp_Object QCwidth
, QCheight
, QCascent
;
1873 extern Lisp_Object QCrelative_width
, QCrelative_height
;
1874 extern Lisp_Object QCalign_to
;
1875 Lisp_Object prop
, plist
;
1876 double width
= 0, height
= 0, ascent
= 0;
1877 struct face
*face
= FACE_FROM_ID (it
->f
, it
->face_id
);
1878 XFontStruct
*font
= face
->font
? face
->font
: FRAME_FONT (it
->f
);
1880 PREPARE_FACE_FOR_DISPLAY (it
->f
, face
);
1882 /* List should start with `space'. */
1883 xassert (CONSP (it
->object
) && EQ (XCAR (it
->object
), Qspace
));
1884 plist
= XCDR (it
->object
);
1886 /* Compute the width of the stretch. */
1887 if (prop
= Fplist_get (plist
, QCwidth
),
1889 /* Absolute width `:width WIDTH' specified and valid. */
1890 width
= NUMVAL (prop
) * CANON_X_UNIT (it
->f
);
1891 else if (prop
= Fplist_get (plist
, QCrelative_width
),
1894 /* Relative width `:relative-width FACTOR' specified and valid.
1895 Compute the width of the characters having the `glyph'
1898 unsigned char *p
= BYTE_POS_ADDR (IT_BYTEPOS (*it
));
1901 if (it
->multibyte_p
)
1903 int maxlen
= ((IT_BYTEPOS (*it
) >= GPT
? ZV
: GPT
)
1904 - IT_BYTEPOS (*it
));
1905 it2
.c
= STRING_CHAR_AND_LENGTH (p
, maxlen
, it2
.len
);
1908 it2
.c
= *p
, it2
.len
= 1;
1910 it2
.glyph_row
= NULL
;
1911 it2
.what
= IT_CHARACTER
;
1912 x_produce_glyphs (&it2
);
1913 width
= NUMVAL (prop
) * it2
.pixel_width
;
1915 else if (prop
= Fplist_get (plist
, QCalign_to
),
1917 width
= NUMVAL (prop
) * CANON_X_UNIT (it
->f
) - it
->current_x
;
1919 /* Nothing specified -> width defaults to canonical char width. */
1920 width
= CANON_X_UNIT (it
->f
);
1922 /* Compute height. */
1923 if (prop
= Fplist_get (plist
, QCheight
),
1925 height
= NUMVAL (prop
) * CANON_Y_UNIT (it
->f
);
1926 else if (prop
= Fplist_get (plist
, QCrelative_height
),
1928 height
= FONT_HEIGHT (font
) * NUMVAL (prop
);
1930 height
= FONT_HEIGHT (font
);
1932 /* Compute percentage of height used for ascent. If
1933 `:ascent ASCENT' is present and valid, use that. Otherwise,
1934 derive the ascent from the font in use. */
1935 if (prop
= Fplist_get (plist
, QCascent
),
1936 NUMVAL (prop
) > 0 && NUMVAL (prop
) <= 100)
1937 ascent
= NUMVAL (prop
) / 100.0;
1939 ascent
= (double) FONT_BASE (font
) / FONT_HEIGHT (font
);
1948 Lisp_Object object
= it
->stack
[it
->sp
- 1].string
;
1949 if (!STRINGP (object
))
1950 object
= it
->w
->buffer
;
1951 x_append_stretch_glyph (it
, object
, width
, height
, ascent
);
1954 it
->pixel_width
= width
;
1955 it
->ascent
= it
->phys_ascent
= height
* ascent
;
1956 it
->descent
= it
->phys_descent
= height
- it
->ascent
;
1959 if (face
->box
!= FACE_NO_BOX
)
1961 if (face
->box_line_width
> 0)
1963 it
->ascent
+= face
->box_line_width
;
1964 it
->descent
+= face
->box_line_width
;
1967 if (it
->start_of_box_run_p
)
1968 it
->pixel_width
+= abs (face
->box_line_width
);
1969 if (it
->end_of_box_run_p
)
1970 it
->pixel_width
+= abs (face
->box_line_width
);
1973 take_vertical_position_into_account (it
);
1976 /* Return proper value to be used as baseline offset of font that has
1977 ASCENT and DESCENT to draw characters by the font at the vertical
1978 center of the line of frame F.
1980 Here, out task is to find the value of BOFF in the following figure;
1982 -------------------------+-----------+-
1983 -+-+---------+-+ | |
1985 | | | | F_ASCENT F_HEIGHT
1988 | | |-|-+------+-----------|------- baseline
1990 | |---------|-+-+ | |
1992 -+-+---------+-+ F_DESCENT |
1993 -------------------------+-----------+-
1995 -BOFF + DESCENT + (F_HEIGHT - HEIGHT) / 2 = F_DESCENT
1996 BOFF = DESCENT + (F_HEIGHT - HEIGHT) / 2 - F_DESCENT
1997 DESCENT = FONT->descent
1998 HEIGHT = FONT_HEIGHT (FONT)
1999 F_DESCENT = (F->output_data.x->font->descent
2000 - F->output_data.x->baseline_offset)
2001 F_HEIGHT = FRAME_LINE_HEIGHT (F)
2004 #define VCENTER_BASELINE_OFFSET(FONT, F) \
2005 (FONT_DESCENT (FONT) \
2006 + (FRAME_LINE_HEIGHT ((F)) - FONT_HEIGHT ((FONT)) \
2007 + (FRAME_LINE_HEIGHT ((F)) > FONT_HEIGHT ((FONT)))) / 2 \
2008 - (FONT_DESCENT (FRAME_FONT (F)) - FRAME_BASELINE_OFFSET (F)))
2010 /* Produce glyphs/get display metrics for the display element IT is
2011 loaded with. See the description of struct display_iterator in
2012 dispextern.h for an overview of struct display_iterator. */
2015 x_produce_glyphs (it
)
2018 it
->glyph_not_available_p
= 0;
2020 if (it
->what
== IT_CHARACTER
)
2024 struct face
*face
= FACE_FROM_ID (it
->f
, it
->face_id
);
2026 int font_not_found_p
;
2027 struct font_info
*font_info
;
2028 int boff
; /* baseline offset */
2029 /* We may change it->multibyte_p upon unibyte<->multibyte
2030 conversion. So, save the current value now and restore it
2033 Note: It seems that we don't have to record multibyte_p in
2034 struct glyph because the character code itself tells if or
2035 not the character is multibyte. Thus, in the future, we must
2036 consider eliminating the field `multibyte_p' in the struct
2039 int saved_multibyte_p
= it
->multibyte_p
;
2041 /* Maybe translate single-byte characters to multibyte, or the
2043 it
->char_to_display
= it
->c
;
2044 if (!ASCII_BYTE_P (it
->c
))
2046 if (unibyte_display_via_language_environment
2047 && SINGLE_BYTE_CHAR_P (it
->c
)
2049 || !NILP (Vnonascii_translation_table
)))
2051 it
->char_to_display
= unibyte_char_to_multibyte (it
->c
);
2052 it
->multibyte_p
= 1;
2053 it
->face_id
= FACE_FOR_CHAR (it
->f
, face
, it
->char_to_display
);
2054 face
= FACE_FROM_ID (it
->f
, it
->face_id
);
2056 else if (!SINGLE_BYTE_CHAR_P (it
->c
)
2057 && !it
->multibyte_p
)
2059 it
->multibyte_p
= 1;
2060 it
->face_id
= FACE_FOR_CHAR (it
->f
, face
, it
->char_to_display
);
2061 face
= FACE_FROM_ID (it
->f
, it
->face_id
);
2065 /* Get font to use. Encode IT->char_to_display. */
2066 x_get_char_face_and_encoding (it
->f
, it
->char_to_display
,
2067 it
->face_id
, &char2b
,
2071 /* When no suitable font found, use the default font. */
2072 font_not_found_p
= font
== NULL
;
2073 if (font_not_found_p
)
2075 font
= FRAME_FONT (it
->f
);
2076 boff
= it
->f
->output_data
.w32
->baseline_offset
;
2081 font_info
= FONT_INFO_FROM_ID (it
->f
, face
->font_info_id
);
2082 boff
= font_info
->baseline_offset
;
2083 if (font_info
->vertical_centering
)
2084 boff
= VCENTER_BASELINE_OFFSET (font
, it
->f
) - boff
;
2087 if (it
->char_to_display
>= ' '
2088 && (!it
->multibyte_p
|| it
->char_to_display
< 128))
2090 /* Either unibyte or ASCII. */
2095 pcm
= w32_per_char_metric (font
, &char2b
,
2096 font
->bdf
? BDF_1D_FONT
: ANSI_FONT
);
2097 it
->ascent
= FONT_BASE (font
) + boff
;
2098 it
->descent
= FONT_DESCENT (font
) - boff
;
2102 it
->phys_ascent
= pcm
->ascent
+ boff
;
2103 it
->phys_descent
= pcm
->descent
- boff
;
2104 it
->pixel_width
= pcm
->width
;
2108 it
->glyph_not_available_p
= 1;
2109 it
->phys_ascent
= FONT_BASE (font
) + boff
;
2110 it
->phys_descent
= FONT_DESCENT (font
) - boff
;
2111 it
->pixel_width
= FONT_WIDTH (font
);
2114 /* If this is a space inside a region of text with
2115 `space-width' property, change its width. */
2116 stretched_p
= it
->char_to_display
== ' ' && !NILP (it
->space_width
);
2118 it
->pixel_width
*= XFLOATINT (it
->space_width
);
2120 /* If face has a box, add the box thickness to the character
2121 height. If character has a box line to the left and/or
2122 right, add the box line width to the character's width. */
2123 if (face
->box
!= FACE_NO_BOX
)
2125 int thick
= face
->box_line_width
;
2129 it
->ascent
+= thick
;
2130 it
->descent
+= thick
;
2135 if (it
->start_of_box_run_p
)
2136 it
->pixel_width
+= thick
;
2137 if (it
->end_of_box_run_p
)
2138 it
->pixel_width
+= thick
;
2141 /* If face has an overline, add the height of the overline
2142 (1 pixel) and a 1 pixel margin to the character height. */
2143 if (face
->overline_p
)
2146 take_vertical_position_into_account (it
);
2148 /* If we have to actually produce glyphs, do it. */
2153 /* Translate a space with a `space-width' property
2154 into a stretch glyph. */
2155 double ascent
= (double) FONT_BASE (font
)
2156 / FONT_HEIGHT (font
);
2157 x_append_stretch_glyph (it
, it
->object
, it
->pixel_width
,
2158 it
->ascent
+ it
->descent
, ascent
);
2161 x_append_glyph (it
);
2163 /* If characters with lbearing or rbearing are displayed
2164 in this line, record that fact in a flag of the
2165 glyph row. This is used to optimize X output code. */
2166 if (pcm
&& (pcm
->lbearing
< 0 || pcm
->rbearing
> pcm
->width
))
2167 it
->glyph_row
->contains_overlapping_glyphs_p
= 1;
2170 else if (it
->char_to_display
== '\n')
2172 /* A newline has no width but we need the height of the line. */
2173 it
->pixel_width
= 0;
2175 it
->ascent
= it
->phys_ascent
= FONT_BASE (font
) + boff
;
2176 it
->descent
= it
->phys_descent
= FONT_DESCENT (font
) - boff
;
2178 if (face
->box
!= FACE_NO_BOX
2179 && face
->box_line_width
> 0)
2181 it
->ascent
+= face
->box_line_width
;
2182 it
->descent
+= face
->box_line_width
;
2185 else if (it
->char_to_display
== '\t')
2187 int tab_width
= it
->tab_width
* CANON_X_UNIT (it
->f
);
2188 int x
= it
->current_x
+ it
->continuation_lines_width
;
2189 int next_tab_x
= ((1 + x
+ tab_width
- 1) / tab_width
) * tab_width
;
2191 /* If the distance from the current position to the next tab
2192 stop is less than a canonical character width, use the
2193 tab stop after that. */
2194 if (next_tab_x
- x
< CANON_X_UNIT (it
->f
))
2195 next_tab_x
+= tab_width
;
2197 it
->pixel_width
= next_tab_x
- x
;
2199 it
->ascent
= it
->phys_ascent
= FONT_BASE (font
) + boff
;
2200 it
->descent
= it
->phys_descent
= FONT_DESCENT (font
) - boff
;
2204 double ascent
= (double) it
->ascent
/ (it
->ascent
+ it
->descent
);
2205 x_append_stretch_glyph (it
, it
->object
, it
->pixel_width
,
2206 it
->ascent
+ it
->descent
, ascent
);
2211 /* A multi-byte character.
2212 If we found a font, this font should give us the right
2213 metrics. If we didn't find a font, use the frame's
2214 default font and calculate the width of the character
2215 from the charset width; this is what old redisplay code
2217 enum w32_char_font_type type
;
2219 if (font
->bdf
&& CHARSET_DIMENSION (CHAR_CHARSET (it
->c
)) == 1)
2224 type
= UNICODE_FONT
;
2226 pcm
= w32_per_char_metric (font
, &char2b
, type
);
2228 if (font_not_found_p
|| !pcm
)
2230 int charset
= CHAR_CHARSET (it
->char_to_display
);
2232 it
->glyph_not_available_p
= 1;
2233 it
->pixel_width
= (FONT_WIDTH (FRAME_FONT (it
->f
))
2234 * CHARSET_WIDTH (charset
));
2235 it
->phys_ascent
= FONT_BASE (font
) + boff
;
2236 it
->phys_descent
= FONT_DESCENT (font
) - boff
;
2240 it
->pixel_width
= pcm
->width
;
2241 it
->phys_ascent
= pcm
->ascent
+ boff
;
2242 it
->phys_descent
= pcm
->descent
- boff
;
2244 && (pcm
->lbearing
< 0
2245 || pcm
->rbearing
> pcm
->width
))
2246 it
->glyph_row
->contains_overlapping_glyphs_p
= 1;
2249 it
->ascent
= FONT_BASE (font
) + boff
;
2250 it
->descent
= FONT_DESCENT (font
) - boff
;
2251 if (face
->box
!= FACE_NO_BOX
)
2253 int thick
= face
->box_line_width
;
2257 it
->ascent
+= thick
;
2258 it
->descent
+= thick
;
2263 if (it
->start_of_box_run_p
)
2264 it
->pixel_width
+= thick
;
2265 if (it
->end_of_box_run_p
)
2266 it
->pixel_width
+= thick
;
2269 /* If face has an overline, add the height of the overline
2270 (1 pixel) and a 1 pixel margin to the character height. */
2271 if (face
->overline_p
)
2274 take_vertical_position_into_account (it
);
2277 x_append_glyph (it
);
2279 it
->multibyte_p
= saved_multibyte_p
;
2281 else if (it
->what
== IT_COMPOSITION
)
2283 /* Note: A composition is represented as one glyph in the
2284 glyph matrix. There are no padding glyphs. */
2287 struct face
*face
= FACE_FROM_ID (it
->f
, it
->face_id
);
2289 int font_not_found_p
;
2290 struct font_info
*font_info
;
2291 int boff
; /* baseline offset */
2292 struct composition
*cmp
= composition_table
[it
->cmp_id
];
2294 /* Maybe translate single-byte characters to multibyte. */
2295 it
->char_to_display
= it
->c
;
2296 if (unibyte_display_via_language_environment
2297 && SINGLE_BYTE_CHAR_P (it
->c
)
2300 && !NILP (Vnonascii_translation_table
))))
2302 it
->char_to_display
= unibyte_char_to_multibyte (it
->c
);
2305 /* Get face and font to use. Encode IT->char_to_display. */
2306 it
->face_id
= FACE_FOR_CHAR (it
->f
, face
, it
->char_to_display
);
2307 face
= FACE_FROM_ID (it
->f
, it
->face_id
);
2308 x_get_char_face_and_encoding (it
->f
, it
->char_to_display
,
2309 it
->face_id
, &char2b
, it
->multibyte_p
);
2312 /* When no suitable font found, use the default font. */
2313 font_not_found_p
= font
== NULL
;
2314 if (font_not_found_p
)
2316 font
= FRAME_FONT (it
->f
);
2317 boff
= it
->f
->output_data
.w32
->baseline_offset
;
2322 font_info
= FONT_INFO_FROM_ID (it
->f
, face
->font_info_id
);
2323 boff
= font_info
->baseline_offset
;
2324 if (font_info
->vertical_centering
)
2325 boff
= VCENTER_BASELINE_OFFSET (font
, it
->f
) - boff
;
2328 /* There are no padding glyphs, so there is only one glyph to
2329 produce for the composition. Important is that pixel_width,
2330 ascent and descent are the values of what is drawn by
2331 draw_glyphs (i.e. the values of the overall glyphs composed). */
2334 /* If we have not yet calculated pixel size data of glyphs of
2335 the composition for the current face font, calculate them
2336 now. Theoretically, we have to check all fonts for the
2337 glyphs, but that requires much time and memory space. So,
2338 here we check only the font of the first glyph. This leads
2339 to incorrect display very rarely, and C-l (recenter) can
2340 correct the display anyway. */
2341 if (cmp
->font
!= (void *) font
)
2343 /* Ascent and descent of the font of the first character of
2344 this composition (adjusted by baseline offset). Ascent
2345 and descent of overall glyphs should not be less than
2346 them respectively. */
2347 int font_ascent
= FONT_BASE (font
) + boff
;
2348 int font_descent
= FONT_DESCENT (font
) - boff
;
2349 /* Bounding box of the overall glyphs. */
2350 int leftmost
, rightmost
, lowest
, highest
;
2351 int i
, width
, ascent
, descent
;
2352 enum w32_char_font_type font_type
;
2354 cmp
->font
= (void *) font
;
2356 if (font
->bdf
&& CHARSET_DIMENSION (CHAR_CHARSET (it
->c
)) == 1)
2357 font_type
= BDF_1D_FONT
;
2359 font_type
= BDF_2D_FONT
;
2361 font_type
= UNICODE_FONT
;
2363 /* Initialize the bounding box. */
2365 && (pcm
= w32_per_char_metric (font
, &char2b
, font_type
)))
2368 ascent
= pcm
->ascent
;
2369 descent
= pcm
->descent
;
2373 width
= FONT_WIDTH (font
);
2374 ascent
= FONT_BASE (font
);
2375 descent
= FONT_DESCENT (font
);
2379 lowest
= - descent
+ boff
;
2380 highest
= ascent
+ boff
;
2384 && font_info
->default_ascent
2385 && CHAR_TABLE_P (Vuse_default_ascent
)
2386 && !NILP (Faref (Vuse_default_ascent
,
2387 make_number (it
->char_to_display
))))
2388 highest
= font_info
->default_ascent
+ boff
;
2390 /* Draw the first glyph at the normal position. It may be
2391 shifted to right later if some other glyphs are drawn at
2393 cmp
->offsets
[0] = 0;
2394 cmp
->offsets
[1] = boff
;
2396 /* Set cmp->offsets for the remaining glyphs. */
2397 for (i
= 1; i
< cmp
->glyph_len
; i
++)
2399 int left
, right
, btm
, top
;
2400 int ch
= COMPOSITION_GLYPH (cmp
, i
);
2401 int face_id
= FACE_FOR_CHAR (it
->f
, face
, ch
);
2403 face
= FACE_FROM_ID (it
->f
, face_id
);
2404 x_get_char_face_and_encoding (it
->f
, ch
, face
->id
, &char2b
,
2409 font
= FRAME_FONT (it
->f
);
2410 boff
= it
->f
->output_data
.w32
->baseline_offset
;
2416 = FONT_INFO_FROM_ID (it
->f
, face
->font_info_id
);
2417 boff
= font_info
->baseline_offset
;
2418 if (font_info
->vertical_centering
)
2419 boff
= VCENTER_BASELINE_OFFSET (font
, it
->f
) - boff
;
2422 if (font
->bdf
&& CHARSET_DIMENSION (CHAR_CHARSET (ch
)) == 1)
2423 font_type
= BDF_1D_FONT
;
2425 font_type
= BDF_2D_FONT
;
2427 font_type
= UNICODE_FONT
;
2430 && (pcm
= w32_per_char_metric (font
, &char2b
, font_type
)))
2433 ascent
= pcm
->ascent
;
2434 descent
= pcm
->descent
;
2438 width
= FONT_WIDTH (font
);
2443 if (cmp
->method
!= COMPOSITION_WITH_RULE_ALTCHARS
)
2445 /* Relative composition with or without
2447 left
= (leftmost
+ rightmost
- width
) / 2;
2448 btm
= - descent
+ boff
;
2449 if (font_info
&& font_info
->relative_compose
2450 && (! CHAR_TABLE_P (Vignore_relative_composition
)
2451 || NILP (Faref (Vignore_relative_composition
,
2452 make_number (ch
)))))
2455 if (- descent
>= font_info
->relative_compose
)
2456 /* One extra pixel between two glyphs. */
2458 else if (ascent
<= 0)
2459 /* One extra pixel between two glyphs. */
2460 btm
= lowest
- 1 - ascent
- descent
;
2465 /* A composition rule is specified by an integer
2466 value that encodes global and new reference
2467 points (GREF and NREF). GREF and NREF are
2468 specified by numbers as below:
2476 ---3---4---5--- baseline
2478 6---7---8 -- descent
2480 int rule
= COMPOSITION_RULE (cmp
, i
);
2481 int gref
, nref
, grefx
, grefy
, nrefx
, nrefy
;
2483 COMPOSITION_DECODE_RULE (rule
, gref
, nref
);
2484 grefx
= gref
% 3, nrefx
= nref
% 3;
2485 grefy
= gref
/ 3, nrefy
= nref
/ 3;
2488 + grefx
* (rightmost
- leftmost
) / 2
2489 - nrefx
* width
/ 2);
2490 btm
= ((grefy
== 0 ? highest
2492 : grefy
== 2 ? lowest
2493 : (highest
+ lowest
) / 2)
2494 - (nrefy
== 0 ? ascent
+ descent
2495 : nrefy
== 1 ? descent
- boff
2497 : (ascent
+ descent
) / 2));
2500 cmp
->offsets
[i
* 2] = left
;
2501 cmp
->offsets
[i
* 2 + 1] = btm
+ descent
;
2503 /* Update the bounding box of the overall glyphs. */
2504 right
= left
+ width
;
2505 top
= btm
+ descent
+ ascent
;
2506 if (left
< leftmost
)
2508 if (right
> rightmost
)
2516 /* If there are glyphs whose x-offsets are negative,
2517 shift all glyphs to the right and make all x-offsets
2521 for (i
= 0; i
< cmp
->glyph_len
; i
++)
2522 cmp
->offsets
[i
* 2] -= leftmost
;
2523 rightmost
-= leftmost
;
2526 cmp
->pixel_width
= rightmost
;
2527 cmp
->ascent
= highest
;
2528 cmp
->descent
= - lowest
;
2529 if (cmp
->ascent
< font_ascent
)
2530 cmp
->ascent
= font_ascent
;
2531 if (cmp
->descent
< font_descent
)
2532 cmp
->descent
= font_descent
;
2535 it
->pixel_width
= cmp
->pixel_width
;
2536 it
->ascent
= it
->phys_ascent
= cmp
->ascent
;
2537 it
->descent
= it
->phys_descent
= cmp
->descent
;
2539 if (face
->box
!= FACE_NO_BOX
)
2541 int thick
= face
->box_line_width
;
2545 it
->ascent
+= thick
;
2546 it
->descent
+= thick
;
2551 if (it
->start_of_box_run_p
)
2552 it
->pixel_width
+= thick
;
2553 if (it
->end_of_box_run_p
)
2554 it
->pixel_width
+= thick
;
2557 /* If face has an overline, add the height of the overline
2558 (1 pixel) and a 1 pixel margin to the character height. */
2559 if (face
->overline_p
)
2562 take_vertical_position_into_account (it
);
2565 x_append_composite_glyph (it
);
2567 else if (it
->what
== IT_IMAGE
)
2568 x_produce_image_glyph (it
);
2569 else if (it
->what
== IT_STRETCH
)
2570 x_produce_stretch_glyph (it
);
2572 /* Accumulate dimensions. Note: can't assume that it->descent > 0
2573 because this isn't true for images with `:ascent 100'. */
2574 xassert (it
->ascent
>= 0 && it
->descent
>= 0);
2575 if (it
->area
== TEXT_AREA
)
2576 it
->current_x
+= it
->pixel_width
;
2578 it
->descent
+= it
->extra_line_spacing
;
2580 it
->max_ascent
= max (it
->max_ascent
, it
->ascent
);
2581 it
->max_descent
= max (it
->max_descent
, it
->descent
);
2582 it
->max_phys_ascent
= max (it
->max_phys_ascent
, it
->phys_ascent
);
2583 it
->max_phys_descent
= max (it
->max_phys_descent
, it
->phys_descent
);
2587 /* Estimate the pixel height of the mode or top line on frame F.
2588 FACE_ID specifies what line's height to estimate. */
2591 x_estimate_mode_line_height (f
, face_id
)
2593 enum face_id face_id
;
2595 int height
= FONT_HEIGHT (FRAME_FONT (f
));
2597 /* This function is called so early when Emacs starts that the face
2598 cache and mode line face are not yet initialized. */
2599 if (FRAME_FACE_CACHE (f
))
2601 struct face
*face
= FACE_FROM_ID (f
, face_id
);
2605 height
= FONT_HEIGHT (face
->font
);
2606 if (face
->box_line_width
> 0)
2607 height
+= 2 * face
->box_line_width
;
2615 /***********************************************************************
2617 ***********************************************************************/
2619 /* A sequence of glyphs to be drawn in the same face.
2621 This data structure is not really completely X specific, so it
2622 could possibly, at least partially, be useful for other systems. It
2623 is currently not part of the external redisplay interface because
2624 it's not clear what other systems will need. */
2628 /* X-origin of the string. */
2631 /* Y-origin and y-position of the base line of this string. */
2634 /* The width of the string, not including a face extension. */
2637 /* The width of the string, including a face extension. */
2638 int background_width
;
2640 /* The height of this string. This is the height of the line this
2641 string is drawn in, and can be different from the height of the
2642 font the string is drawn in. */
2645 /* Number of pixels this string overwrites in front of its x-origin.
2646 This number is zero if the string has an lbearing >= 0; it is
2647 -lbearing, if the string has an lbearing < 0. */
2650 /* Number of pixels this string overwrites past its right-most
2651 nominal x-position, i.e. x + width. Zero if the string's
2652 rbearing is <= its nominal width, rbearing - width otherwise. */
2655 /* The frame on which the glyph string is drawn. */
2658 /* The window on which the glyph string is drawn. */
2661 /* X display and window for convenience. */
2664 /* The glyph row for which this string was built. It determines the
2665 y-origin and height of the string. */
2666 struct glyph_row
*row
;
2668 /* The area within row. */
2669 enum glyph_row_area area
;
2671 /* Characters to be drawn, and number of characters. */
2675 /* A face-override for drawing cursors, mouse face and similar. */
2676 enum draw_glyphs_face hl
;
2678 /* Face in which this string is to be drawn. */
2681 /* Font in which this string is to be drawn. */
2684 /* Font info for this string. */
2685 struct font_info
*font_info
;
2687 /* Non-null means this string describes (part of) a composition.
2688 All characters from char2b are drawn composed. */
2689 struct composition
*cmp
;
2691 /* Index of this glyph string's first character in the glyph
2692 definition of CMP. If this is zero, this glyph string describes
2693 the first character of a composition. */
2696 /* 1 means this glyph strings face has to be drawn to the right end
2697 of the window's drawing area. */
2698 unsigned extends_to_end_of_line_p
: 1;
2700 /* 1 means the background of this string has been drawn. */
2701 unsigned background_filled_p
: 1;
2703 /* 1 means glyph string must be drawn with 16-bit functions. */
2704 unsigned two_byte_p
: 1;
2706 /* 1 means that the original font determined for drawing this glyph
2707 string could not be loaded. The member `font' has been set to
2708 the frame's default font in this case. */
2709 unsigned font_not_found_p
: 1;
2711 /* 1 means that the face in which this glyph string is drawn has a
2713 unsigned stippled_p
: 1;
2715 /* 1 means only the foreground of this glyph string must be drawn,
2716 and we should use the physical height of the line this glyph
2717 string appears in as clip rect. */
2718 unsigned for_overlaps_p
: 1;
2720 /* The GC to use for drawing this glyph string. */
2725 /* A pointer to the first glyph in the string. This glyph
2726 corresponds to char2b[0]. Needed to draw rectangles if
2727 font_not_found_p is 1. */
2728 struct glyph
*first_glyph
;
2730 /* Image, if any. */
2733 struct glyph_string
*next
, *prev
;
2737 /* Encapsulate the different ways of displaying text under W32. */
2740 w32_text_out (s
, x
, y
,chars
,nchars
)
2741 struct glyph_string
* s
;
2746 int charset_dim
= w32_font_is_double_byte (s
->gc
->font
) ? 2 : 1;
2747 if (s
->gc
->font
->bdf
)
2748 w32_BDF_TextOut (s
->gc
->font
->bdf
, s
->hdc
,
2749 x
, y
, (char *) chars
, charset_dim
,
2750 nchars
* charset_dim
, 0);
2751 else if (s
->first_glyph
->w32_font_type
== UNICODE_FONT
)
2752 ExtTextOutW (s
->hdc
, x
, y
, 0, NULL
, chars
, nchars
, NULL
);
2754 ExtTextOutA (s
->hdc
, x
, y
, 0, NULL
, (char *) chars
,
2755 nchars
* charset_dim
, NULL
);
2761 x_dump_glyph_string (s
)
2762 struct glyph_string
*s
;
2764 fprintf (stderr
, "glyph string\n");
2765 fprintf (stderr
, " x, y, w, h = %d, %d, %d, %d\n",
2766 s
->x
, s
->y
, s
->width
, s
->height
);
2767 fprintf (stderr
, " ybase = %d\n", s
->ybase
);
2768 fprintf (stderr
, " hl = %d\n", s
->hl
);
2769 fprintf (stderr
, " left overhang = %d, right = %d\n",
2770 s
->left_overhang
, s
->right_overhang
);
2771 fprintf (stderr
, " nchars = %d\n", s
->nchars
);
2772 fprintf (stderr
, " extends to end of line = %d\n",
2773 s
->extends_to_end_of_line_p
);
2774 fprintf (stderr
, " font height = %d\n", FONT_HEIGHT (s
->font
));
2775 fprintf (stderr
, " bg width = %d\n", s
->background_width
);
2778 #endif /* GLYPH_DEBUG */
2782 static void x_append_glyph_string_lists
P_ ((struct glyph_string
**,
2783 struct glyph_string
**,
2784 struct glyph_string
*,
2785 struct glyph_string
*));
2786 static void x_prepend_glyph_string_lists
P_ ((struct glyph_string
**,
2787 struct glyph_string
**,
2788 struct glyph_string
*,
2789 struct glyph_string
*));
2790 static void x_append_glyph_string
P_ ((struct glyph_string
**,
2791 struct glyph_string
**,
2792 struct glyph_string
*));
2793 static int x_left_overwritten
P_ ((struct glyph_string
*));
2794 static int x_left_overwriting
P_ ((struct glyph_string
*));
2795 static int x_right_overwritten
P_ ((struct glyph_string
*));
2796 static int x_right_overwriting
P_ ((struct glyph_string
*));
2797 static int x_fill_glyph_string
P_ ((struct glyph_string
*, int, int, int,
2799 static void w32_init_glyph_string
P_ ((struct glyph_string
*, HDC hdc
,
2800 wchar_t *, struct window
*,
2802 enum glyph_row_area
, int,
2803 enum draw_glyphs_face
));
2804 static int x_draw_glyphs
P_ ((struct window
*, int , struct glyph_row
*,
2805 enum glyph_row_area
, int, int,
2806 enum draw_glyphs_face
, int));
2807 static void x_set_glyph_string_clipping
P_ ((struct glyph_string
*));
2808 static void x_set_glyph_string_gc
P_ ((struct glyph_string
*));
2809 static void x_draw_glyph_string_background
P_ ((struct glyph_string
*,
2811 static void x_draw_glyph_string_foreground
P_ ((struct glyph_string
*));
2812 static void x_draw_composite_glyph_string_foreground
P_ ((struct glyph_string
*));
2813 static void x_draw_glyph_string_box
P_ ((struct glyph_string
*));
2814 static void x_draw_glyph_string
P_ ((struct glyph_string
*));
2815 static void x_compute_glyph_string_overhangs
P_ ((struct glyph_string
*));
2816 static void x_set_cursor_gc
P_ ((struct glyph_string
*));
2817 static void x_set_mode_line_face_gc
P_ ((struct glyph_string
*));
2818 static void x_set_mouse_face_gc
P_ ((struct glyph_string
*));
2819 static void w32_get_glyph_overhangs
P_ ((HDC hdc
, struct glyph
*,
2822 static void x_compute_overhangs_and_x
P_ ((struct glyph_string
*, int, int));
2823 static int w32_alloc_lighter_color (struct frame
*, COLORREF
*, double, int);
2824 static void w32_setup_relief_color
P_ ((struct frame
*, struct relief
*,
2825 double, int, COLORREF
));
2826 static void x_setup_relief_colors
P_ ((struct glyph_string
*));
2827 static void x_draw_image_glyph_string
P_ ((struct glyph_string
*));
2828 static void x_draw_image_relief
P_ ((struct glyph_string
*));
2829 static void x_draw_image_foreground
P_ ((struct glyph_string
*));
2830 static void w32_draw_image_foreground_1
P_ ((struct glyph_string
*, HBITMAP
));
2831 static void x_fill_image_glyph_string
P_ ((struct glyph_string
*));
2832 static void x_clear_glyph_string_rect
P_ ((struct glyph_string
*, int,
2834 static void w32_draw_relief_rect
P_ ((struct frame
*, int, int, int, int,
2835 int, int, int, int, RECT
*));
2836 static void w32_draw_box_rect
P_ ((struct glyph_string
*, int, int, int, int,
2837 int, int, int, RECT
*));
2838 static void x_fix_overlapping_area
P_ ((struct window
*, struct glyph_row
*,
2839 enum glyph_row_area
));
2840 static int x_fill_stretch_glyph_string
P_ ((struct glyph_string
*,
2842 enum glyph_row_area
, int, int));
2845 static void x_check_font
P_ ((struct frame
*, XFontStruct
*));
2849 /* Append the list of glyph strings with head H and tail T to the list
2850 with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the result. */
2853 x_append_glyph_string_lists (head
, tail
, h
, t
)
2854 struct glyph_string
**head
, **tail
;
2855 struct glyph_string
*h
, *t
;
2869 /* Prepend the list of glyph strings with head H and tail T to the
2870 list with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the
2874 x_prepend_glyph_string_lists (head
, tail
, h
, t
)
2875 struct glyph_string
**head
, **tail
;
2876 struct glyph_string
*h
, *t
;
2890 /* Append glyph string S to the list with head *HEAD and tail *TAIL.
2891 Set *HEAD and *TAIL to the resulting list. */
2894 x_append_glyph_string (head
, tail
, s
)
2895 struct glyph_string
**head
, **tail
;
2896 struct glyph_string
*s
;
2898 s
->next
= s
->prev
= NULL
;
2899 x_append_glyph_string_lists (head
, tail
, s
, s
);
2903 /* Set S->gc to a suitable GC for drawing glyph string S in cursor
2908 struct glyph_string
*s
;
2910 if (s
->font
== FRAME_FONT (s
->f
)
2911 && s
->face
->background
== FRAME_BACKGROUND_PIXEL (s
->f
)
2912 && s
->face
->foreground
== FRAME_FOREGROUND_PIXEL (s
->f
)
2914 s
->gc
= s
->f
->output_data
.w32
->cursor_gc
;
2917 /* Cursor on non-default face: must merge. */
2921 xgcv
.background
= s
->f
->output_data
.w32
->cursor_pixel
;
2922 xgcv
.foreground
= s
->face
->background
;
2924 /* If the glyph would be invisible, try a different foreground. */
2925 if (xgcv
.foreground
== xgcv
.background
)
2926 xgcv
.foreground
= s
->face
->foreground
;
2927 if (xgcv
.foreground
== xgcv
.background
)
2928 xgcv
.foreground
= s
->f
->output_data
.w32
->cursor_foreground_pixel
;
2929 if (xgcv
.foreground
== xgcv
.background
)
2930 xgcv
.foreground
= s
->face
->foreground
;
2932 /* Make sure the cursor is distinct from text in this face. */
2933 if (xgcv
.background
== s
->face
->background
2934 && xgcv
.foreground
== s
->face
->foreground
)
2936 xgcv
.background
= s
->face
->foreground
;
2937 xgcv
.foreground
= s
->face
->background
;
2940 IF_DEBUG (x_check_font (s
->f
, s
->font
));
2941 xgcv
.font
= s
->font
;
2942 mask
= GCForeground
| GCBackground
| GCFont
;
2944 if (FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
)
2945 XChangeGC (NULL
, FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
,
2948 FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
2949 = XCreateGC (NULL
, s
->window
, mask
, &xgcv
);
2951 s
->gc
= FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
;
2956 /* Set up S->gc of glyph string S for drawing text in mouse face. */
2959 x_set_mouse_face_gc (s
)
2960 struct glyph_string
*s
;
2965 /* What face has to be used last for the mouse face? */
2966 face_id
= FRAME_W32_DISPLAY_INFO (s
->f
)->mouse_face_face_id
;
2967 face
= FACE_FROM_ID (s
->f
, face_id
);
2969 face
= FACE_FROM_ID (s
->f
, MOUSE_FACE_ID
);
2971 if (s
->first_glyph
->type
== CHAR_GLYPH
)
2972 face_id
= FACE_FOR_CHAR (s
->f
, face
, s
->first_glyph
->u
.ch
);
2974 face_id
= FACE_FOR_CHAR (s
->f
, face
, 0);
2975 s
->face
= FACE_FROM_ID (s
->f
, face_id
);
2976 PREPARE_FACE_FOR_DISPLAY (s
->f
, s
->face
);
2978 /* If font in this face is same as S->font, use it. */
2979 if (s
->font
== s
->face
->font
)
2980 s
->gc
= s
->face
->gc
;
2983 /* Otherwise construct scratch_cursor_gc with values from FACE
2988 xgcv
.background
= s
->face
->background
;
2989 xgcv
.foreground
= s
->face
->foreground
;
2990 IF_DEBUG (x_check_font (s
->f
, s
->font
));
2991 xgcv
.font
= s
->font
;
2992 mask
= GCForeground
| GCBackground
| GCFont
;
2994 if (FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
)
2995 XChangeGC (NULL
, FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
,
2998 FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
2999 = XCreateGC (NULL
, s
->window
, mask
, &xgcv
);
3001 s
->gc
= FRAME_W32_DISPLAY_INFO (s
->f
)->scratch_cursor_gc
;
3004 xassert (s
->gc
!= 0);
3008 /* Set S->gc of glyph string S to a GC suitable for drawing a mode line.
3009 Faces to use in the mode line have already been computed when the
3010 matrix was built, so there isn't much to do, here. */
3013 x_set_mode_line_face_gc (s
)
3014 struct glyph_string
*s
;
3016 s
->gc
= s
->face
->gc
;
3020 /* Set S->gc of glyph string S for drawing that glyph string. Set
3021 S->stippled_p to a non-zero value if the face of S has a stipple
3025 x_set_glyph_string_gc (s
)
3026 struct glyph_string
*s
;
3028 PREPARE_FACE_FOR_DISPLAY (s
->f
, s
->face
);
3030 if (s
->hl
== DRAW_NORMAL_TEXT
)
3032 s
->gc
= s
->face
->gc
;
3033 s
->stippled_p
= s
->face
->stipple
!= 0;
3035 else if (s
->hl
== DRAW_INVERSE_VIDEO
)
3037 x_set_mode_line_face_gc (s
);
3038 s
->stippled_p
= s
->face
->stipple
!= 0;
3040 else if (s
->hl
== DRAW_CURSOR
)
3042 x_set_cursor_gc (s
);
3045 else if (s
->hl
== DRAW_MOUSE_FACE
)
3047 x_set_mouse_face_gc (s
);
3048 s
->stippled_p
= s
->face
->stipple
!= 0;
3050 else if (s
->hl
== DRAW_IMAGE_RAISED
3051 || s
->hl
== DRAW_IMAGE_SUNKEN
)
3053 s
->gc
= s
->face
->gc
;
3054 s
->stippled_p
= s
->face
->stipple
!= 0;
3058 s
->gc
= s
->face
->gc
;
3059 s
->stippled_p
= s
->face
->stipple
!= 0;
3062 /* GC must have been set. */
3063 xassert (s
->gc
!= 0);
3067 /* Return in *R the clipping rectangle for glyph string S. */
3070 w32_get_glyph_string_clip_rect (s
, r
)
3071 struct glyph_string
*s
;
3074 int r_height
, r_width
;
3076 if (s
->row
->full_width_p
)
3078 /* Draw full-width. X coordinates are relative to S->w->left. */
3079 int canon_x
= CANON_X_UNIT (s
->f
);
3081 r
->left
= WINDOW_LEFT_MARGIN (s
->w
) * canon_x
;
3082 r_width
= XFASTINT (s
->w
->width
) * canon_x
;
3084 if (FRAME_HAS_VERTICAL_SCROLL_BARS (s
->f
))
3086 int width
= FRAME_SCROLL_BAR_WIDTH (s
->f
) * canon_x
;
3087 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s
->f
))
3091 r
->left
+= FRAME_INTERNAL_BORDER_WIDTH (s
->f
);
3093 /* Unless displaying a mode or menu bar line, which are always
3094 fully visible, clip to the visible part of the row. */
3095 if (s
->w
->pseudo_window_p
)
3096 r_height
= s
->row
->visible_height
;
3098 r_height
= s
->height
;
3102 /* This is a text line that may be partially visible. */
3103 r
->left
= WINDOW_AREA_TO_FRAME_PIXEL_X (s
->w
, s
->area
, 0);
3104 r_width
= window_box_width (s
->w
, s
->area
);
3105 r_height
= s
->row
->visible_height
;
3108 /* If S draws overlapping rows, it's sufficient to use the top and
3109 bottom of the window for clipping because this glyph string
3110 intentionally draws over other lines. */
3111 if (s
->for_overlaps_p
)
3113 r
->top
= WINDOW_DISPLAY_HEADER_LINE_HEIGHT (s
->w
);
3114 r_height
= window_text_bottom_y (s
->w
) - r
->top
;
3118 /* Don't use S->y for clipping because it doesn't take partially
3119 visible lines into account. For example, it can be negative for
3120 partially visible lines at the top of a window. */
3121 if (!s
->row
->full_width_p
3122 && MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (s
->w
, s
->row
))
3123 r
->top
= WINDOW_DISPLAY_HEADER_LINE_HEIGHT (s
->w
);
3125 r
->top
= max (0, s
->row
->y
);
3127 /* If drawing a tool-bar window, draw it over the internal border
3128 at the top of the window. */
3129 if (s
->w
== XWINDOW (s
->f
->tool_bar_window
))
3130 r
->top
-= s
->f
->output_data
.w32
->internal_border_width
;
3133 r
->top
= WINDOW_TO_FRAME_PIXEL_Y (s
->w
, r
->top
);
3135 r
->bottom
= r
->top
+ r_height
;
3136 r
->right
= r
->left
+ r_width
;
3140 /* Set clipping for output of glyph string S. S may be part of a mode
3141 line or menu if we don't have X toolkit support. */
3144 x_set_glyph_string_clipping (s
)
3145 struct glyph_string
*s
;
3148 w32_get_glyph_string_clip_rect (s
, &r
);
3149 w32_set_clip_rectangle (s
->hdc
, &r
);
3153 /* Compute left and right overhang of glyph string S. If S is a glyph
3154 string for a composition, assume overhangs don't exist. */
3157 x_compute_glyph_string_overhangs (s
)
3158 struct glyph_string
*s
;
3160 /* TODO: Windows does not appear to have a method for
3161 getting this info without getting the ABC widths for each
3162 individual character and working it out manually. */
3166 /* Compute overhangs and x-positions for glyph string S and its
3167 predecessors, or successors. X is the starting x-position for S.
3168 BACKWARD_P non-zero means process predecessors. */
3171 x_compute_overhangs_and_x (s
, x
, backward_p
)
3172 struct glyph_string
*s
;
3180 x_compute_glyph_string_overhangs (s
);
3190 x_compute_glyph_string_overhangs (s
);
3199 /* Set *LEFT and *RIGHT to the left and right overhang of GLYPH on
3200 frame F. Overhangs of glyphs other than type CHAR_GLYPH are
3201 assumed to be zero. */
3204 w32_get_glyph_overhangs (hdc
, glyph
, f
, left
, right
)
3206 struct glyph
*glyph
;
3212 if (glyph
->type
== CHAR_GLYPH
)
3219 face
= x_get_glyph_face_and_encoding (f
, glyph
, &char2b
, NULL
);
3223 && (pcm
= w32_per_char_metric (font
, &char2b
,
3224 glyph
->w32_font_type
)))
3226 if (pcm
->rbearing
> pcm
->width
)
3227 *right
= pcm
->rbearing
- pcm
->width
;
3228 if (pcm
->lbearing
< 0)
3229 *left
= -pcm
->lbearing
;
3236 x_get_glyph_overhangs (glyph
, f
, left
, right
)
3237 struct glyph
*glyph
;
3241 HDC hdc
= get_frame_dc (f
);
3242 /* Convert to unicode! */
3243 w32_get_glyph_overhangs (hdc
, glyph
, f
, left
, right
);
3244 release_frame_dc (f
, hdc
);
3248 /* Return the index of the first glyph preceding glyph string S that
3249 is overwritten by S because of S's left overhang. Value is -1
3250 if no glyphs are overwritten. */
3253 x_left_overwritten (s
)
3254 struct glyph_string
*s
;
3258 if (s
->left_overhang
)
3261 struct glyph
*glyphs
= s
->row
->glyphs
[s
->area
];
3262 int first
= s
->first_glyph
- glyphs
;
3264 for (i
= first
- 1; i
>= 0 && x
> -s
->left_overhang
; --i
)
3265 x
-= glyphs
[i
].pixel_width
;
3276 /* Return the index of the first glyph preceding glyph string S that
3277 is overwriting S because of its right overhang. Value is -1 if no
3278 glyph in front of S overwrites S. */
3281 x_left_overwriting (s
)
3282 struct glyph_string
*s
;
3285 struct glyph
*glyphs
= s
->row
->glyphs
[s
->area
];
3286 int first
= s
->first_glyph
- glyphs
;
3290 for (i
= first
- 1; i
>= 0; --i
)
3293 w32_get_glyph_overhangs (s
->hdc
, glyphs
+ i
, s
->f
, &left
, &right
);
3296 x
-= glyphs
[i
].pixel_width
;
3303 /* Return the index of the last glyph following glyph string S that is
3304 not overwritten by S because of S's right overhang. Value is -1 if
3305 no such glyph is found. */
3308 x_right_overwritten (s
)
3309 struct glyph_string
*s
;
3313 if (s
->right_overhang
)
3316 struct glyph
*glyphs
= s
->row
->glyphs
[s
->area
];
3317 int first
= (s
->first_glyph
- glyphs
) + (s
->cmp
? 1 : s
->nchars
);
3318 int end
= s
->row
->used
[s
->area
];
3320 for (i
= first
; i
< end
&& s
->right_overhang
> x
; ++i
)
3321 x
+= glyphs
[i
].pixel_width
;
3330 /* Return the index of the last glyph following glyph string S that
3331 overwrites S because of its left overhang. Value is negative
3332 if no such glyph is found. */
3335 x_right_overwriting (s
)
3336 struct glyph_string
*s
;
3339 int end
= s
->row
->used
[s
->area
];
3340 struct glyph
*glyphs
= s
->row
->glyphs
[s
->area
];
3341 int first
= (s
->first_glyph
- glyphs
) + (s
->cmp
? 1 : s
->nchars
);
3345 for (i
= first
; i
< end
; ++i
)
3348 w32_get_glyph_overhangs (s
->hdc
, glyphs
+ i
, s
->f
, &left
, &right
);
3351 x
+= glyphs
[i
].pixel_width
;
3358 /* Fill rectangle X, Y, W, H with background color of glyph string S. */
3361 x_clear_glyph_string_rect (s
, x
, y
, w
, h
)
3362 struct glyph_string
*s
;
3370 /* Take clipping into account. */
3371 if (s
->gc
->clip_mask
== Rect
)
3373 real_x
= max (real_x
, s
->gc
->clip_rectangle
.left
);
3374 real_y
= max (real_y
, s
->gc
->clip_rectangle
.top
);
3375 real_w
= min (real_w
, s
->gc
->clip_rectangle
.right
3376 - s
->gc
->clip_rectangle
.left
);
3377 real_h
= min (real_h
, s
->gc
->clip_rectangle
.bottom
3378 - s
->gc
->clip_rectangle
.top
);
3381 w32_fill_area (s
->f
, s
->hdc
, s
->gc
->background
, real_x
, real_y
,
3386 /* Draw the background of glyph_string S. If S->background_filled_p
3387 is non-zero don't draw it. FORCE_P non-zero means draw the
3388 background even if it wouldn't be drawn normally. This is used
3389 when a string preceding S draws into the background of S, or S
3390 contains the first component of a composition. */
3393 x_draw_glyph_string_background (s
, force_p
)
3394 struct glyph_string
*s
;
3397 /* Nothing to do if background has already been drawn or if it
3398 shouldn't be drawn in the first place. */
3399 if (!s
->background_filled_p
)
3401 int box_line_width
= max (s
->face
->box_line_width
, 0);
3403 #if 0 /* TODO: stipple */
3406 /* Fill background with a stipple pattern. */
3407 XSetFillStyle (s
->display
, s
->gc
, FillOpaqueStippled
);
3408 XFillRectangle (s
->display
, s
->window
, s
->gc
, s
->x
,
3409 s
->y
+ box_line_width
,
3410 s
->background_width
,
3411 s
->height
- 2 * box_line_width
);
3412 XSetFillStyle (s
->display
, s
->gc
, FillSolid
);
3413 s
->background_filled_p
= 1;
3417 if (FONT_HEIGHT (s
->font
) < s
->height
- 2 * box_line_width
3418 || s
->font_not_found_p
3419 || s
->extends_to_end_of_line_p
3423 x_clear_glyph_string_rect (s
, s
->x
, s
->y
+ box_line_width
,
3424 s
->background_width
,
3425 s
->height
- 2 * box_line_width
);
3426 s
->background_filled_p
= 1;
3432 /* Draw the foreground of glyph string S. */
3435 x_draw_glyph_string_foreground (s
)
3436 struct glyph_string
*s
;
3441 /* If first glyph of S has a left box line, start drawing the text
3442 of S to the right of that box line. */
3443 if (s
->face
->box
!= FACE_NO_BOX
3444 && s
->first_glyph
->left_box_line_p
)
3445 x
= s
->x
+ abs (s
->face
->box_line_width
);
3449 if (s
->for_overlaps_p
|| (s
->background_filled_p
&& s
->hl
!= DRAW_CURSOR
))
3450 SetBkMode (s
->hdc
, TRANSPARENT
);
3452 SetBkMode (s
->hdc
, OPAQUE
);
3454 SetTextColor (s
->hdc
, s
->gc
->foreground
);
3455 SetBkColor (s
->hdc
, s
->gc
->background
);
3456 SetTextAlign (s
->hdc
, TA_BASELINE
| TA_LEFT
);
3458 if (s
->font
&& s
->font
->hfont
)
3459 old_font
= SelectObject (s
->hdc
, s
->font
->hfont
);
3461 /* Draw characters of S as rectangles if S's font could not be
3463 if (s
->font_not_found_p
)
3465 for (i
= 0; i
< s
->nchars
; ++i
)
3467 struct glyph
*g
= s
->first_glyph
+ i
;
3469 w32_draw_rectangle (s
->hdc
, s
->gc
, x
, s
->y
, g
->pixel_width
- 1,
3471 x
+= g
->pixel_width
;
3476 char *char1b
= (char *) s
->char2b
;
3477 int boff
= s
->font_info
->baseline_offset
;
3479 if (s
->font_info
->vertical_centering
)
3480 boff
= VCENTER_BASELINE_OFFSET (s
->font
, s
->f
) - boff
;
3482 /* If we can use 8-bit functions, condense S->char2b. */
3484 for (i
= 0; i
< s
->nchars
; ++i
)
3485 char1b
[i
] = BYTE2 (s
->char2b
[i
]);
3487 /* Draw text with TextOut and friends. */
3488 w32_text_out (s
, x
, s
->ybase
- boff
, s
->char2b
, s
->nchars
);
3490 if (s
->font
&& s
->font
->hfont
)
3491 SelectObject (s
->hdc
, old_font
);
3494 /* Draw the foreground of composite glyph string S. */
3497 x_draw_composite_glyph_string_foreground (s
)
3498 struct glyph_string
*s
;
3503 /* If first glyph of S has a left box line, start drawing the text
3504 of S to the right of that box line. */
3505 if (s
->face
->box
!= FACE_NO_BOX
3506 && s
->first_glyph
->left_box_line_p
)
3507 x
= s
->x
+ abs (s
->face
->box_line_width
);
3511 /* S is a glyph string for a composition. S->gidx is the index of
3512 the first character drawn for glyphs of this composition.
3513 S->gidx == 0 means we are drawing the very first character of
3514 this composition. */
3516 SetTextColor (s
->hdc
, s
->gc
->foreground
);
3517 SetBkColor (s
->hdc
, s
->gc
->background
);
3518 SetBkMode (s
->hdc
, TRANSPARENT
);
3519 SetTextAlign (s
->hdc
, TA_BASELINE
| TA_LEFT
);
3521 if (s
->font
&& s
->font
->hfont
)
3522 old_font
= SelectObject (s
->hdc
, s
->font
->hfont
);
3524 /* Draw a rectangle for the composition if the font for the very
3525 first character of the composition could not be loaded. */
3526 if (s
->font_not_found_p
)
3529 w32_draw_rectangle (s
->hdc
, s
->gc
, x
, s
->y
, s
->width
- 1,
3534 for (i
= 0; i
< s
->nchars
; i
++, ++s
->gidx
)
3535 w32_text_out (s
, x
+ s
->cmp
->offsets
[s
->gidx
* 2],
3536 s
->ybase
- s
->cmp
->offsets
[s
->gidx
* 2 + 1],
3539 if (s
->font
&& s
->font
->hfont
)
3540 SelectObject (s
->hdc
, old_font
);
3544 /* Brightness beyond which a color won't have its highlight brightness
3547 Nominally, highlight colors for `3d' faces are calculated by
3548 brightening an object's color by a constant scale factor, but this
3549 doesn't yield good results for dark colors, so for colors who's
3550 brightness is less than this value (on a scale of 0-255) have to
3551 use an additional additive factor.
3553 The value here is set so that the default menu-bar/mode-line color
3554 (grey75) will not have its highlights changed at all. */
3555 #define HIGHLIGHT_COLOR_DARK_BOOST_LIMIT 187
3558 /* Allocate a color which is lighter or darker than *COLOR by FACTOR
3559 or DELTA. Try a color with RGB values multiplied by FACTOR first.
3560 If this produces the same color as COLOR, try a color where all RGB
3561 values have DELTA added. Return the allocated color in *COLOR.
3562 DISPLAY is the X display, CMAP is the colormap to operate on.
3563 Value is non-zero if successful. */
3566 w32_alloc_lighter_color (f
, color
, factor
, delta
)
3575 /* On Windows, RGB values are 0-255, not 0-65535, so scale delta. */
3578 /* Change RGB values by specified FACTOR. Avoid overflow! */
3579 xassert (factor
>= 0);
3580 new = PALETTERGB (min (0xff, factor
* GetRValue (*color
)),
3581 min (0xff, factor
* GetGValue (*color
)),
3582 min (0xff, factor
* GetBValue (*color
)));
3584 /* Calculate brightness of COLOR. */
3585 bright
= (2 * GetRValue (*color
) + 3 * GetGValue (*color
)
3586 + GetBValue (*color
)) / 6;
3588 /* We only boost colors that are darker than
3589 HIGHLIGHT_COLOR_DARK_BOOST_LIMIT. */
3590 if (bright
< HIGHLIGHT_COLOR_DARK_BOOST_LIMIT
)
3591 /* Make an additive adjustment to NEW, because it's dark enough so
3592 that scaling by FACTOR alone isn't enough. */
3594 /* How far below the limit this color is (0 - 1, 1 being darker). */
3595 double dimness
= 1 - (double)bright
/ HIGHLIGHT_COLOR_DARK_BOOST_LIMIT
;
3596 /* The additive adjustment. */
3597 int min_delta
= delta
* dimness
* factor
/ 2;
3600 new = PALETTERGB (max (0, min (0xff, min_delta
- GetRValue (*color
))),
3601 max (0, min (0xff, min_delta
- GetGValue (*color
))),
3602 max (0, min (0xff, min_delta
- GetBValue (*color
))));
3604 new = PALETTERGB (max (0, min (0xff, min_delta
+ GetRValue (*color
))),
3605 max (0, min (0xff, min_delta
+ GetGValue (*color
))),
3606 max (0, min (0xff, min_delta
+ GetBValue (*color
))));
3610 new = PALETTERGB (max (0, min (0xff, delta
+ GetRValue (*color
))),
3611 max (0, min (0xff, delta
+ GetGValue (*color
))),
3612 max (0, min (0xff, delta
+ GetBValue (*color
))));
3614 /* TODO: Map to palette and retry with delta if same? */
3615 /* TODO: Free colors (if using palette)? */
3626 /* Set up the foreground color for drawing relief lines of glyph
3627 string S. RELIEF is a pointer to a struct relief containing the GC
3628 with which lines will be drawn. Use a color that is FACTOR or
3629 DELTA lighter or darker than the relief's background which is found
3630 in S->f->output_data.x->relief_background. If such a color cannot
3631 be allocated, use DEFAULT_PIXEL, instead. */
3634 w32_setup_relief_color (f
, relief
, factor
, delta
, default_pixel
)
3636 struct relief
*relief
;
3639 COLORREF default_pixel
;
3642 struct w32_output
*di
= f
->output_data
.w32
;
3643 unsigned long mask
= GCForeground
;
3645 COLORREF background
= di
->relief_background
;
3646 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
3648 /* TODO: Free colors (if using palette)? */
3650 /* Allocate new color. */
3651 xgcv
.foreground
= default_pixel
;
3653 if (w32_alloc_lighter_color (f
, &pixel
, factor
, delta
))
3655 relief
->allocated_p
= 1;
3656 xgcv
.foreground
= relief
->pixel
= pixel
;
3659 if (relief
->gc
== 0)
3661 #if 0 /* TODO: stipple */
3662 xgcv
.stipple
= dpyinfo
->gray
;
3665 relief
->gc
= XCreateGC (NULL
, FRAME_W32_WINDOW (f
), mask
, &xgcv
);
3668 XChangeGC (NULL
, relief
->gc
, mask
, &xgcv
);
3672 /* Set up colors for the relief lines around glyph string S. */
3675 x_setup_relief_colors (s
)
3676 struct glyph_string
*s
;
3678 struct w32_output
*di
= s
->f
->output_data
.w32
;
3681 if (s
->face
->use_box_color_for_shadows_p
)
3682 color
= s
->face
->box_color
;
3683 else if (s
->first_glyph
->type
== IMAGE_GLYPH
3685 && !IMAGE_BACKGROUND_TRANSPARENT (s
->img
, s
->f
, 0))
3686 color
= IMAGE_BACKGROUND (s
->img
, s
->f
, 0);
3688 color
= s
->gc
->background
;
3690 if (di
->white_relief
.gc
== 0
3691 || color
!= di
->relief_background
)
3693 di
->relief_background
= color
;
3694 w32_setup_relief_color (s
->f
, &di
->white_relief
, 1.2, 0x8000,
3695 WHITE_PIX_DEFAULT (s
->f
));
3696 w32_setup_relief_color (s
->f
, &di
->black_relief
, 0.6, 0x4000,
3697 BLACK_PIX_DEFAULT (s
->f
));
3702 /* Draw a relief on frame F inside the rectangle given by LEFT_X,
3703 TOP_Y, RIGHT_X, and BOTTOM_Y. WIDTH is the thickness of the relief
3704 to draw, it must be >= 0. RAISED_P non-zero means draw a raised
3705 relief. LEFT_P non-zero means draw a relief on the left side of
3706 the rectangle. RIGHT_P non-zero means draw a relief on the right
3707 side of the rectangle. CLIP_RECT is the clipping rectangle to use
3711 w32_draw_relief_rect (f
, left_x
, top_y
, right_x
, bottom_y
, width
,
3712 raised_p
, left_p
, right_p
, clip_rect
)
3714 int left_x
, top_y
, right_x
, bottom_y
, left_p
, right_p
, raised_p
;
3719 HDC hdc
= get_frame_dc (f
);
3722 gc
.foreground
= f
->output_data
.w32
->white_relief
.gc
->foreground
;
3724 gc
.foreground
= f
->output_data
.w32
->black_relief
.gc
->foreground
;
3726 w32_set_clip_rectangle (hdc
, clip_rect
);
3729 for (i
= 0; i
< width
; ++i
)
3730 w32_fill_area (f
, hdc
, gc
.foreground
,
3731 left_x
+ i
* left_p
, top_y
+ i
,
3732 right_x
- left_x
- i
* (left_p
+ right_p
) + 1, 1);
3736 for (i
= 0; i
< width
; ++i
)
3737 w32_fill_area (f
, hdc
, gc
.foreground
,
3738 left_x
+ i
, top_y
+ i
, 1,
3739 bottom_y
- top_y
- 2 * i
+ 1);
3742 gc
.foreground
= f
->output_data
.w32
->black_relief
.gc
->foreground
;
3744 gc
.foreground
= f
->output_data
.w32
->white_relief
.gc
->foreground
;
3747 for (i
= 0; i
< width
; ++i
)
3748 w32_fill_area (f
, hdc
, gc
.foreground
,
3749 left_x
+ i
* left_p
, bottom_y
- i
,
3750 right_x
- left_x
- i
* (left_p
+ right_p
) + 1, 1);
3754 for (i
= 0; i
< width
; ++i
)
3755 w32_fill_area (f
, hdc
, gc
.foreground
,
3756 right_x
- i
, top_y
+ i
+ 1, 1,
3757 bottom_y
- top_y
- 2 * i
- 1);
3759 w32_set_clip_rectangle (hdc
, NULL
);
3761 release_frame_dc (f
, hdc
);
3765 /* Draw a box on frame F inside the rectangle given by LEFT_X, TOP_Y,
3766 RIGHT_X, and BOTTOM_Y. WIDTH is the thickness of the lines to
3767 draw, it must be >= 0. LEFT_P non-zero means draw a line on the
3768 left side of the rectangle. RIGHT_P non-zero means draw a line
3769 on the right side of the rectangle. CLIP_RECT is the clipping
3770 rectangle to use when drawing. */
3773 w32_draw_box_rect (s
, left_x
, top_y
, right_x
, bottom_y
, width
,
3774 left_p
, right_p
, clip_rect
)
3775 struct glyph_string
*s
;
3776 int left_x
, top_y
, right_x
, bottom_y
, width
, left_p
, right_p
;
3779 w32_set_clip_rectangle (s
->hdc
, clip_rect
);
3782 w32_fill_area (s
->f
, s
->hdc
, s
->face
->box_color
,
3783 left_x
, top_y
, right_x
- left_x
+ 1, width
);
3788 w32_fill_area (s
->f
, s
->hdc
, s
->face
->box_color
,
3789 left_x
, top_y
, width
, bottom_y
- top_y
+ 1);
3793 w32_fill_area (s
->f
, s
->hdc
, s
->face
->box_color
,
3794 left_x
, bottom_y
- width
+ 1, right_x
- left_x
+ 1, width
);
3799 w32_fill_area (s
->f
, s
->hdc
, s
->face
->box_color
,
3800 right_x
- width
+ 1, top_y
, width
, bottom_y
- top_y
+ 1);
3803 w32_set_clip_rectangle (s
->hdc
, NULL
);
3807 /* Draw a box around glyph string S. */
3810 x_draw_glyph_string_box (s
)
3811 struct glyph_string
*s
;
3813 int width
, left_x
, right_x
, top_y
, bottom_y
, last_x
, raised_p
;
3814 int left_p
, right_p
;
3815 struct glyph
*last_glyph
;
3818 last_x
= window_box_right (s
->w
, s
->area
);
3819 if (s
->row
->full_width_p
3820 && !s
->w
->pseudo_window_p
)
3822 last_x
+= FRAME_X_RIGHT_FRINGE_WIDTH (s
->f
);
3823 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s
->f
))
3824 last_x
+= FRAME_SCROLL_BAR_WIDTH (s
->f
) * CANON_X_UNIT (s
->f
);
3827 /* The glyph that may have a right box line. */
3828 last_glyph
= (s
->cmp
|| s
->img
3830 : s
->first_glyph
+ s
->nchars
- 1);
3832 width
= abs (s
->face
->box_line_width
);
3833 raised_p
= s
->face
->box
== FACE_RAISED_BOX
;
3835 right_x
= ((s
->row
->full_width_p
&& s
->extends_to_end_of_line_p
3837 : min (last_x
, s
->x
+ s
->background_width
) - 1));
3839 bottom_y
= top_y
+ s
->height
- 1;
3841 left_p
= (s
->first_glyph
->left_box_line_p
3842 || (s
->hl
== DRAW_MOUSE_FACE
3844 || s
->prev
->hl
!= s
->hl
)));
3845 right_p
= (last_glyph
->right_box_line_p
3846 || (s
->hl
== DRAW_MOUSE_FACE
3848 || s
->next
->hl
!= s
->hl
)));
3850 w32_get_glyph_string_clip_rect (s
, &clip_rect
);
3852 if (s
->face
->box
== FACE_SIMPLE_BOX
)
3853 w32_draw_box_rect (s
, left_x
, top_y
, right_x
, bottom_y
, width
,
3854 left_p
, right_p
, &clip_rect
);
3857 x_setup_relief_colors (s
);
3858 w32_draw_relief_rect (s
->f
, left_x
, top_y
, right_x
, bottom_y
,
3859 width
, raised_p
, left_p
, right_p
, &clip_rect
);
3864 /* Draw foreground of image glyph string S. */
3867 x_draw_image_foreground (s
)
3868 struct glyph_string
*s
;
3871 int y
= s
->ybase
- image_ascent (s
->img
, s
->face
);
3873 /* If first glyph of S has a left box line, start drawing it to the
3874 right of that line. */
3875 if (s
->face
->box
!= FACE_NO_BOX
3876 && s
->first_glyph
->left_box_line_p
)
3877 x
= s
->x
+ abs (s
->face
->box_line_width
);
3881 /* If there is a margin around the image, adjust x- and y-position
3883 x
+= s
->img
->hmargin
;
3884 y
+= s
->img
->vmargin
;
3890 #if 0 /* TODO: image mask */
3893 /* We can't set both a clip mask and use XSetClipRectangles
3894 because the latter also sets a clip mask. We also can't
3895 trust on the shape extension to be available
3896 (XShapeCombineRegion). So, compute the rectangle to draw
3898 unsigned long mask
= (GCClipMask
| GCClipXOrigin
| GCClipYOrigin
3901 XRectangle clip_rect
, image_rect
, r
;
3903 xgcv
.clip_mask
= s
->img
->mask
;
3904 xgcv
.clip_x_origin
= x
;
3905 xgcv
.clip_y_origin
= y
;
3906 xgcv
.function
= GXcopy
;
3907 XChangeGC (s
->display
, s
->gc
, mask
, &xgcv
);
3909 w32_get_glyph_string_clip_rect (s
, &clip_rect
);
3912 image_rect
.width
= s
->img
->width
;
3913 image_rect
.height
= s
->img
->height
;
3914 if (IntersectRect (&r
, &clip_rect
, &image_rect
))
3915 XCopyArea (s
->display
, s
->img
->pixmap
, s
->window
, s
->gc
,
3916 r
.x
- x
, r
.y
- y
, r
.width
, r
.height
, r
.x
, r
.y
);
3921 HDC compat_hdc
= CreateCompatibleDC (s
->hdc
);
3922 HBRUSH fg_brush
= CreateSolidBrush (s
->gc
->foreground
);
3923 HBRUSH orig_brush
= SelectObject (s
->hdc
, fg_brush
);
3924 HGDIOBJ orig_obj
= SelectObject (compat_hdc
, s
->img
->pixmap
);
3925 x_set_glyph_string_clipping (s
);
3927 SetTextColor (s
->hdc
, s
->gc
->foreground
);
3928 SetBkColor (s
->hdc
, s
->gc
->background
);
3929 #if 0 /* From w32bdf.c (which is from Meadow). */
3930 BitBlt (s
->hdc
, x
, y
, s
->img
->width
, s
->img
->height
,
3931 compat_hdc
, 0, 0, SRCCOPY
);
3932 BitBlt (s
->hdc
, x
, y
, s
->img
->width
, s
->img
->height
,
3933 compat_hdc
, 0, 0, 0xB8074A);
3935 BitBlt (s
->hdc
, x
, y
, s
->img
->width
, s
->img
->height
,
3936 compat_hdc
, 0, 0, 0xE20746);
3938 SelectObject (s
->hdc
, orig_brush
);
3939 DeleteObject (fg_brush
);
3940 SelectObject (compat_hdc
, orig_obj
);
3941 DeleteDC (compat_hdc
);
3943 /* When the image has a mask, we can expect that at
3944 least part of a mouse highlight or a block cursor will
3945 be visible. If the image doesn't have a mask, make
3946 a block cursor visible by drawing a rectangle around
3947 the image. I believe it's looking better if we do
3948 nothing here for mouse-face. */
3949 if (s
->hl
== DRAW_CURSOR
)
3951 int r
= s
->img
->relief
;
3953 w32_draw_rectangle (s
->hdc
, s
->gc
, x
- r
, y
- r
,
3954 s
->img
->width
+ r
*2 - 1, s
->img
->height
+ r
*2 - 1);
3956 w32_set_clip_rectangle (s
->hdc
, NULL
);
3960 w32_draw_rectangle (s
->hdc
, s
->gc
, x
, y
, s
->img
->width
-1,
3961 s
->img
->height
- 1);
3963 RestoreDC (s
->hdc
,-1);
3968 /* Draw a relief around the image glyph string S. */
3971 x_draw_image_relief (s
)
3972 struct glyph_string
*s
;
3974 int x0
, y0
, x1
, y1
, thick
, raised_p
;
3977 int y
= s
->ybase
- image_ascent (s
->img
, s
->face
);
3979 /* If first glyph of S has a left box line, start drawing it to the
3980 right of that line. */
3981 if (s
->face
->box
!= FACE_NO_BOX
3982 && s
->first_glyph
->left_box_line_p
)
3983 x
= s
->x
+ abs (s
->face
->box_line_width
);
3987 /* If there is a margin around the image, adjust x- and y-position
3989 x
+= s
->img
->hmargin
;
3990 y
+= s
->img
->vmargin
;
3992 if (s
->hl
== DRAW_IMAGE_SUNKEN
3993 || s
->hl
== DRAW_IMAGE_RAISED
)
3995 thick
= tool_bar_button_relief
>= 0 ? tool_bar_button_relief
: DEFAULT_TOOL_BAR_BUTTON_RELIEF
;
3996 raised_p
= s
->hl
== DRAW_IMAGE_RAISED
;
4000 thick
= abs (s
->img
->relief
);
4001 raised_p
= s
->img
->relief
> 0;
4006 x1
= x
+ s
->img
->width
+ thick
- 1;
4007 y1
= y
+ s
->img
->height
+ thick
- 1;
4009 x_setup_relief_colors (s
);
4010 w32_get_glyph_string_clip_rect (s
, &r
);
4011 w32_draw_relief_rect (s
->f
, x0
, y0
, x1
, y1
, thick
, raised_p
, 1, 1, &r
);
4015 /* Draw the foreground of image glyph string S to PIXMAP. */
4018 w32_draw_image_foreground_1 (s
, pixmap
)
4019 struct glyph_string
*s
;
4022 HDC hdc
= CreateCompatibleDC (s
->hdc
);
4023 HGDIOBJ orig_hdc_obj
= SelectObject (hdc
, pixmap
);
4025 int y
= s
->ybase
- s
->y
- image_ascent (s
->img
, s
->face
);
4027 /* If first glyph of S has a left box line, start drawing it to the
4028 right of that line. */
4029 if (s
->face
->box
!= FACE_NO_BOX
4030 && s
->first_glyph
->left_box_line_p
)
4031 x
= abs (s
->face
->box_line_width
);
4035 /* If there is a margin around the image, adjust x- and y-position
4037 x
+= s
->img
->hmargin
;
4038 y
+= s
->img
->vmargin
;
4042 #if 0 /* TODO: image mask */
4045 /* We can't set both a clip mask and use XSetClipRectangles
4046 because the latter also sets a clip mask. We also can't
4047 trust on the shape extension to be available
4048 (XShapeCombineRegion). So, compute the rectangle to draw
4050 unsigned long mask
= (GCClipMask
| GCClipXOrigin
| GCClipYOrigin
4054 xgcv
.clip_mask
= s
->img
->mask
;
4055 xgcv
.clip_x_origin
= x
;
4056 xgcv
.clip_y_origin
= y
;
4057 xgcv
.function
= GXcopy
;
4058 XChangeGC (s
->display
, s
->gc
, mask
, &xgcv
);
4060 XCopyArea (s
->display
, s
->img
->pixmap
, pixmap
, s
->gc
,
4061 0, 0, s
->img
->width
, s
->img
->height
, x
, y
);
4062 XSetClipMask (s
->display
, s
->gc
, None
);
4067 HDC compat_hdc
= CreateCompatibleDC (hdc
);
4068 HBRUSH fg_brush
= CreateSolidBrush (s
->gc
->foreground
);
4069 HBRUSH orig_brush
= SelectObject (hdc
, fg_brush
);
4070 HGDIOBJ orig_obj
= SelectObject (compat_hdc
, s
->img
->pixmap
);
4072 SetTextColor (hdc
, s
->gc
->foreground
);
4073 SetBkColor (hdc
, s
->gc
->background
);
4074 #if 0 /* From w32bdf.c (which is from Meadow). */
4075 BitBlt (hdc
, x
, y
, s
->img
->width
, s
->img
->height
,
4076 compat_hdc
, 0, 0, SRCCOPY
);
4077 BitBlt (hdc
, x
, y
, s
->img
->width
, s
->img
->height
,
4078 compat_hdc
, 0, 0, 0xB8074A);
4080 BitBlt (hdc
, x
, y
, s
->img
->width
, s
->img
->height
,
4081 compat_hdc
, 0, 0, 0xE20746);
4083 SelectObject (hdc
, orig_brush
);
4084 DeleteObject (fg_brush
);
4085 SelectObject (compat_hdc
, orig_obj
);
4086 DeleteDC (compat_hdc
);
4088 /* When the image has a mask, we can expect that at
4089 least part of a mouse highlight or a block cursor will
4090 be visible. If the image doesn't have a mask, make
4091 a block cursor visible by drawing a rectangle around
4092 the image. I believe it's looking better if we do
4093 nothing here for mouse-face. */
4094 if (s
->hl
== DRAW_CURSOR
)
4096 int r
= s
->img
->relief
;
4098 w32_draw_rectangle (s
->hdc
, s
->gc
, x
- r
, y
- r
,
4099 s
->img
->width
+ r
*2 - 1, s
->img
->height
+ r
*2 - 1);
4104 w32_draw_rectangle (hdc
, s
->gc
, x
, y
, s
->img
->width
- 1,
4105 s
->img
->height
- 1);
4107 SelectObject (hdc
, orig_hdc_obj
);
4112 /* Draw part of the background of glyph string S. X, Y, W, and H
4113 give the rectangle to draw. */
4116 x_draw_glyph_string_bg_rect (s
, x
, y
, w
, h
)
4117 struct glyph_string
*s
;
4120 #if 0 /* TODO: stipple */
4123 /* Fill background with a stipple pattern. */
4124 XSetFillStyle (s
->display
, s
->gc
, FillOpaqueStippled
);
4125 XFillRectangle (s
->display
, s
->window
, s
->gc
, x
, y
, w
, h
);
4126 XSetFillStyle (s
->display
, s
->gc
, FillSolid
);
4130 x_clear_glyph_string_rect (s
, x
, y
, w
, h
);
4134 /* Draw image glyph string S.
4137 s->x +-------------------------
4140 | +-------------------------
4143 | | +-------------------
4149 x_draw_image_glyph_string (s
)
4150 struct glyph_string
*s
;
4153 int box_line_hwidth
= abs (s
->face
->box_line_width
);
4154 int box_line_vwidth
= max (s
->face
->box_line_width
, 0);
4158 height
= s
->height
- 2 * box_line_vwidth
;
4160 /* Fill background with face under the image. Do it only if row is
4161 taller than image or if image has a clip mask to reduce
4163 s
->stippled_p
= s
->face
->stipple
!= 0;
4164 if (height
> s
->img
->height
4167 #if 0 /* TODO: image mask */
4170 || s
->img
->pixmap
== 0
4171 || s
->width
!= s
->background_width
)
4173 if (box_line_hwidth
&& s
->first_glyph
->left_box_line_p
)
4174 x
= s
->x
+ box_line_hwidth
;
4178 y
= s
->y
+ box_line_vwidth
;
4179 #if 0 /* TODO: image mask */
4182 /* Create a pixmap as large as the glyph string. Fill it
4183 with the background color. Copy the image to it, using
4184 its mask. Copy the temporary pixmap to the display. */
4185 Screen
*screen
= FRAME_X_SCREEN (s
->f
);
4186 int depth
= DefaultDepthOfScreen (screen
);
4188 /* Create a pixmap as large as the glyph string. */
4189 pixmap
= XCreatePixmap (s
->display
, s
->window
,
4190 s
->background_width
,
4193 /* Don't clip in the following because we're working on the
4195 XSetClipMask (s
->display
, s
->gc
, None
);
4197 /* Fill the pixmap with the background color/stipple. */
4200 /* Fill background with a stipple pattern. */
4201 XSetFillStyle (s
->display
, s
->gc
, FillOpaqueStippled
);
4202 XFillRectangle (s
->display
, pixmap
, s
->gc
,
4203 0, 0, s
->background_width
, s
->height
);
4204 XSetFillStyle (s
->display
, s
->gc
, FillSolid
);
4209 XGetGCValues (s
->display
, s
->gc
, GCForeground
| GCBackground
,
4211 XSetForeground (s
->display
, s
->gc
, xgcv
.background
);
4212 XFillRectangle (s
->display
, pixmap
, s
->gc
,
4213 0, 0, s
->background_width
, s
->height
);
4214 XSetForeground (s
->display
, s
->gc
, xgcv
.foreground
);
4219 x_draw_glyph_string_bg_rect (s
, x
, y
, s
->background_width
, height
);
4221 s
->background_filled_p
= 1;
4224 /* Draw the foreground. */
4227 w32_draw_image_foreground_1 (s
, pixmap
);
4228 x_set_glyph_string_clipping (s
);
4230 HDC compat_hdc
= CreateCompatibleDC (s
->hdc
);
4231 HBRUSH fg_brush
= CreateSolidBrush (s
->gc
->foreground
);
4232 HBRUSH orig_brush
= SelectObject (s
->hdc
, fg_brush
);
4233 HGDIOBJ orig_obj
= SelectObject (compat_hdc
, pixmap
);
4235 SetTextColor (s
->hdc
, s
->gc
->foreground
);
4236 SetBkColor (s
->hdc
, s
->gc
->background
);
4237 #if 0 /* From w32bdf.c (which is from Meadow). */
4238 BitBlt (s
->hdc
, s
->x
, s
->y
, s
->background_width
, s
->height
,
4239 compat_hdc
, 0, 0, SRCCOPY
);
4240 BitBlt (s
->hdc
, s
->x
, s
->y
, s
->background_width
, s
->height
,
4241 compat_hdc
, 0, 0, 0xB8074A);
4243 BitBlt (s
->hdc
, s
->x
, s
->y
, s
->background_width
, s
->height
,
4244 compat_hdc
, 0, 0, 0xE20746);
4246 SelectObject (s
->hdc
, orig_brush
);
4247 DeleteObject (fg_brush
);
4248 SelectObject (compat_hdc
, orig_obj
);
4249 DeleteDC (compat_hdc
);
4251 DeleteObject (pixmap
);
4255 x_draw_image_foreground (s
);
4257 /* If we must draw a relief around the image, do it. */
4259 || s
->hl
== DRAW_IMAGE_RAISED
4260 || s
->hl
== DRAW_IMAGE_SUNKEN
)
4261 x_draw_image_relief (s
);
4265 /* Draw stretch glyph string S. */
4268 x_draw_stretch_glyph_string (s
)
4269 struct glyph_string
*s
;
4271 xassert (s
->first_glyph
->type
== STRETCH_GLYPH
);
4272 s
->stippled_p
= s
->face
->stipple
!= 0;
4274 if (s
->hl
== DRAW_CURSOR
4275 && !x_stretch_cursor_p
)
4277 /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
4278 as wide as the stretch glyph. */
4279 int width
= min (CANON_X_UNIT (s
->f
), s
->background_width
);
4282 x_draw_glyph_string_bg_rect (s
, s
->x
, s
->y
, width
, s
->height
);
4284 /* Clear rest using the GC of the original non-cursor face. */
4285 if (width
< s
->background_width
)
4287 XGCValues
*gc
= s
->face
->gc
;
4288 int x
= s
->x
+ width
, y
= s
->y
;
4289 int w
= s
->background_width
- width
, h
= s
->height
;
4293 if (s
->row
->mouse_face_p
4294 && cursor_in_mouse_face_p (s
->w
))
4296 x_set_mouse_face_gc (s
);
4302 w32_get_glyph_string_clip_rect (s
, &r
);
4303 w32_set_clip_rectangle (hdc
, &r
);
4305 #if 0 /* TODO: stipple */
4306 if (s
->face
->stipple
)
4308 /* Fill background with a stipple pattern. */
4309 XSetFillStyle (s
->display
, gc
, FillOpaqueStippled
);
4310 XFillRectangle (s
->display
, s
->window
, gc
, x
, y
, w
, h
);
4311 XSetFillStyle (s
->display
, gc
, FillSolid
);
4316 w32_fill_area (s
->f
, s
->hdc
, gc
->background
, x
, y
, w
, h
);
4320 else if (!s
->background_filled_p
)
4321 x_draw_glyph_string_bg_rect (s
, s
->x
, s
->y
, s
->background_width
,
4324 s
->background_filled_p
= 1;
4328 /* Draw glyph string S. */
4331 x_draw_glyph_string (s
)
4332 struct glyph_string
*s
;
4334 int relief_drawn_p
= 0;
4336 /* If S draws into the background of its successor, draw the
4337 background of the successor first so that S can draw into it.
4338 This makes S->next use XDrawString instead of XDrawImageString. */
4339 if (s
->next
&& s
->right_overhang
&& !s
->for_overlaps_p
)
4341 xassert (s
->next
->img
== NULL
);
4342 x_set_glyph_string_gc (s
->next
);
4343 x_set_glyph_string_clipping (s
->next
);
4344 x_draw_glyph_string_background (s
->next
, 1);
4347 /* Set up S->gc, set clipping and draw S. */
4348 x_set_glyph_string_gc (s
);
4350 /* Draw relief (if any) in advance for char/composition so that the
4351 glyph string can be drawn over it. */
4352 if (!s
->for_overlaps_p
4353 && s
->face
->box
!= FACE_NO_BOX
4354 && (s
->first_glyph
->type
== CHAR_GLYPH
4355 || s
->first_glyph
->type
== COMPOSITE_GLYPH
))
4358 x_set_glyph_string_clipping (s
);
4359 x_draw_glyph_string_background (s
, 1);
4360 x_draw_glyph_string_box (s
);
4361 x_set_glyph_string_clipping (s
);
4365 x_set_glyph_string_clipping (s
);
4367 switch (s
->first_glyph
->type
)
4370 x_draw_image_glyph_string (s
);
4374 x_draw_stretch_glyph_string (s
);
4378 if (s
->for_overlaps_p
)
4379 s
->background_filled_p
= 1;
4381 x_draw_glyph_string_background (s
, 0);
4382 x_draw_glyph_string_foreground (s
);
4385 case COMPOSITE_GLYPH
:
4386 if (s
->for_overlaps_p
|| s
->gidx
> 0)
4387 s
->background_filled_p
= 1;
4389 x_draw_glyph_string_background (s
, 1);
4390 x_draw_composite_glyph_string_foreground (s
);
4397 if (!s
->for_overlaps_p
)
4399 /* Draw underline. */
4400 if (s
->face
->underline_p
4401 && (s
->font
->bdf
|| !s
->font
->tm
.tmUnderlined
))
4403 unsigned long h
= 1;
4404 unsigned long dy
= s
->height
- h
;
4406 /* TODO: Use font information for positioning and thickness
4407 of underline. See OUTLINETEXTMETRIC, and xterm.c. */
4408 if (s
->face
->underline_defaulted_p
)
4410 w32_fill_area (s
->f
, s
->hdc
, s
->gc
->foreground
, s
->x
,
4411 s
->y
+ dy
, s
->width
, 1);
4415 w32_fill_area (s
->f
, s
->hdc
, s
->face
->underline_color
, s
->x
,
4416 s
->y
+ dy
, s
->width
, 1);
4420 /* Draw overline. */
4421 if (s
->face
->overline_p
)
4423 unsigned long dy
= 0, h
= 1;
4425 if (s
->face
->overline_color_defaulted_p
)
4427 w32_fill_area (s
->f
, s
->hdc
, s
->gc
->foreground
, s
->x
,
4428 s
->y
+ dy
, s
->width
, h
);
4432 w32_fill_area (s
->f
, s
->hdc
, s
->face
->underline_color
, s
->x
,
4433 s
->y
+ dy
, s
->width
, h
);
4437 /* Draw strike-through. */
4438 if (s
->face
->strike_through_p
4439 && (s
->font
->bdf
|| !s
->font
->tm
.tmStruckOut
))
4441 unsigned long h
= 1;
4442 unsigned long dy
= (s
->height
- h
) / 2;
4444 if (s
->face
->strike_through_color_defaulted_p
)
4446 w32_fill_area (s
->f
, s
->hdc
, s
->gc
->foreground
, s
->x
, s
->y
+ dy
,
4451 w32_fill_area (s
->f
, s
->hdc
, s
->face
->underline_color
, s
->x
,
4452 s
->y
+ dy
, s
->width
, h
);
4457 if (!relief_drawn_p
&& s
->face
->box
!= FACE_NO_BOX
)
4458 x_draw_glyph_string_box (s
);
4461 /* Reset clipping. */
4462 w32_set_clip_rectangle (s
->hdc
, NULL
);
4466 static int x_fill_composite_glyph_string
P_ ((struct glyph_string
*,
4467 struct face
**, int));
4470 /* Fill glyph string S with composition components specified by S->cmp.
4472 FACES is an array of faces for all components of this composition.
4473 S->gidx is the index of the first component for S.
4474 OVERLAPS_P non-zero means S should draw the foreground only, and
4475 use its physical height for clipping.
4477 Value is the index of a component not in S. */
4480 x_fill_composite_glyph_string (s
, faces
, overlaps_p
)
4481 struct glyph_string
*s
;
4482 struct face
**faces
;
4489 s
->for_overlaps_p
= overlaps_p
;
4491 s
->face
= faces
[s
->gidx
];
4492 s
->font
= s
->face
->font
;
4493 s
->font_info
= FONT_INFO_FROM_ID (s
->f
, s
->face
->font_info_id
);
4495 /* For all glyphs of this composition, starting at the offset
4496 S->gidx, until we reach the end of the definition or encounter a
4497 glyph that requires the different face, add it to S. */
4499 for (i
= s
->gidx
+ 1; i
< s
->cmp
->glyph_len
&& faces
[i
] == s
->face
; ++i
)
4502 /* All glyph strings for the same composition has the same width,
4503 i.e. the width set for the first component of the composition. */
4505 s
->width
= s
->first_glyph
->pixel_width
;
4507 /* If the specified font could not be loaded, use the frame's
4508 default font, but record the fact that we couldn't load it in
4509 the glyph string so that we can draw rectangles for the
4510 characters of the glyph string. */
4511 if (s
->font
== NULL
)
4513 s
->font_not_found_p
= 1;
4514 s
->font
= FRAME_FONT (s
->f
);
4517 /* Adjust base line for subscript/superscript text. */
4518 s
->ybase
+= s
->first_glyph
->voffset
;
4520 xassert (s
->face
&& s
->face
->gc
);
4522 /* This glyph string must always be drawn with 16-bit functions. */
4525 return s
->gidx
+ s
->nchars
;
4529 /* Fill glyph string S from a sequence of character glyphs.
4531 FACE_ID is the face id of the string. START is the index of the
4532 first glyph to consider, END is the index of the last + 1.
4533 OVERLAPS_P non-zero means S should draw the foreground only, and
4534 use its physical height for clipping.
4536 Value is the index of the first glyph not in S. */
4539 x_fill_glyph_string (s
, face_id
, start
, end
, overlaps_p
)
4540 struct glyph_string
*s
;
4542 int start
, end
, overlaps_p
;
4544 struct glyph
*glyph
, *last
;
4546 int glyph_not_available_p
;
4548 xassert (s
->f
== XFRAME (s
->w
->frame
));
4549 xassert (s
->nchars
== 0);
4550 xassert (start
>= 0 && end
> start
);
4552 s
->for_overlaps_p
= overlaps_p
;
4553 glyph
= s
->row
->glyphs
[s
->area
] + start
;
4554 last
= s
->row
->glyphs
[s
->area
] + end
;
4555 voffset
= glyph
->voffset
;
4557 glyph_not_available_p
= glyph
->glyph_not_available_p
;
4560 && glyph
->type
== CHAR_GLYPH
4561 && glyph
->voffset
== voffset
4562 /* Same face id implies same font, nowadays. */
4563 && glyph
->face_id
== face_id
4564 && glyph
->glyph_not_available_p
== glyph_not_available_p
)
4568 s
->face
= x_get_glyph_face_and_encoding (s
->f
, glyph
,
4569 s
->char2b
+ s
->nchars
,
4571 s
->two_byte_p
= two_byte_p
;
4573 xassert (s
->nchars
<= end
- start
);
4574 s
->width
+= glyph
->pixel_width
;
4578 s
->font
= s
->face
->font
;
4579 s
->font_info
= FONT_INFO_FROM_ID (s
->f
, s
->face
->font_info_id
);
4581 /* If the specified font could not be loaded, use the frame's font,
4582 but record the fact that we couldn't load it in
4583 S->font_not_found_p so that we can draw rectangles for the
4584 characters of the glyph string. */
4585 if (s
->font
== NULL
|| glyph_not_available_p
)
4587 s
->font_not_found_p
= 1;
4588 s
->font
= FRAME_FONT (s
->f
);
4591 /* Adjust base line for subscript/superscript text. */
4592 s
->ybase
+= voffset
;
4594 xassert (s
->face
&& s
->face
->gc
);
4595 return glyph
- s
->row
->glyphs
[s
->area
];
4599 /* Fill glyph string S from image glyph S->first_glyph. */
4602 x_fill_image_glyph_string (s
)
4603 struct glyph_string
*s
;
4605 xassert (s
->first_glyph
->type
== IMAGE_GLYPH
);
4606 s
->img
= IMAGE_FROM_ID (s
->f
, s
->first_glyph
->u
.img_id
);
4608 s
->face
= FACE_FROM_ID (s
->f
, s
->first_glyph
->face_id
);
4609 s
->font
= s
->face
->font
;
4610 s
->width
= s
->first_glyph
->pixel_width
;
4612 /* Adjust base line for subscript/superscript text. */
4613 s
->ybase
+= s
->first_glyph
->voffset
;
4617 /* Fill glyph string S from a sequence of stretch glyphs.
4619 ROW is the glyph row in which the glyphs are found, AREA is the
4620 area within the row. START is the index of the first glyph to
4621 consider, END is the index of the last + 1.
4623 Value is the index of the first glyph not in S. */
4626 x_fill_stretch_glyph_string (s
, row
, area
, start
, end
)
4627 struct glyph_string
*s
;
4628 struct glyph_row
*row
;
4629 enum glyph_row_area area
;
4632 struct glyph
*glyph
, *last
;
4633 int voffset
, face_id
;
4635 xassert (s
->first_glyph
->type
== STRETCH_GLYPH
);
4637 glyph
= s
->row
->glyphs
[s
->area
] + start
;
4638 last
= s
->row
->glyphs
[s
->area
] + end
;
4639 face_id
= glyph
->face_id
;
4640 s
->face
= FACE_FROM_ID (s
->f
, face_id
);
4641 s
->font
= s
->face
->font
;
4642 s
->font_info
= FONT_INFO_FROM_ID (s
->f
, s
->face
->font_info_id
);
4643 s
->width
= glyph
->pixel_width
;
4644 voffset
= glyph
->voffset
;
4648 && glyph
->type
== STRETCH_GLYPH
4649 && glyph
->voffset
== voffset
4650 && glyph
->face_id
== face_id
);
4652 s
->width
+= glyph
->pixel_width
;
4654 /* Adjust base line for subscript/superscript text. */
4655 s
->ybase
+= voffset
;
4658 return glyph
- s
->row
->glyphs
[s
->area
];
4662 /* Initialize glyph string S. CHAR2B is a suitably allocated vector
4663 of XChar2b structures for S; it can't be allocated in
4664 x_init_glyph_string because it must be allocated via `alloca'. W
4665 is the window on which S is drawn. ROW and AREA are the glyph row
4666 and area within the row from which S is constructed. START is the
4667 index of the first glyph structure covered by S. HL is a
4668 face-override for drawing S. */
4671 w32_init_glyph_string (s
, hdc
, char2b
, w
, row
, area
, start
, hl
)
4672 struct glyph_string
*s
;
4676 struct glyph_row
*row
;
4677 enum glyph_row_area area
;
4679 enum draw_glyphs_face hl
;
4681 bzero (s
, sizeof *s
);
4683 s
->f
= XFRAME (w
->frame
);
4685 s
->window
= FRAME_W32_WINDOW (s
->f
);
4690 s
->first_glyph
= row
->glyphs
[area
] + start
;
4691 s
->height
= row
->height
;
4692 s
->y
= WINDOW_TO_FRAME_PIXEL_Y (w
, row
->y
);
4694 /* Display the internal border below the tool-bar window. */
4695 if (s
->w
== XWINDOW (s
->f
->tool_bar_window
))
4696 s
->y
-= s
->f
->output_data
.w32
->internal_border_width
;
4698 s
->ybase
= s
->y
+ row
->ascent
;
4702 /* Set background width of glyph string S. START is the index of the
4703 first glyph following S. LAST_X is the right-most x-position + 1
4704 in the drawing area. */
4707 x_set_glyph_string_background_width (s
, start
, last_x
)
4708 struct glyph_string
*s
;
4712 /* If the face of this glyph string has to be drawn to the end of
4713 the drawing area, set S->extends_to_end_of_line_p. */
4714 struct face
*default_face
= FACE_FROM_ID (s
->f
, DEFAULT_FACE_ID
);
4716 if (start
== s
->row
->used
[s
->area
]
4717 && s
->area
== TEXT_AREA
4718 && ((s
->hl
== DRAW_NORMAL_TEXT
4719 && (s
->row
->fill_line_p
4720 || s
->face
->background
!= default_face
->background
4721 || s
->face
->stipple
!= default_face
->stipple
4722 || s
->row
->mouse_face_p
))
4723 || s
->hl
== DRAW_MOUSE_FACE
4724 || ((s
->hl
== DRAW_IMAGE_RAISED
|| s
->hl
== DRAW_IMAGE_SUNKEN
)
4725 && s
->row
->fill_line_p
)))
4726 s
->extends_to_end_of_line_p
= 1;
4728 /* If S extends its face to the end of the line, set its
4729 background_width to the distance to the right edge of the drawing
4731 if (s
->extends_to_end_of_line_p
)
4732 s
->background_width
= last_x
- s
->x
+ 1;
4734 s
->background_width
= s
->width
;
4738 /* Add a glyph string for a stretch glyph to the list of strings
4739 between HEAD and TAIL. START is the index of the stretch glyph in
4740 row area AREA of glyph row ROW. END is the index of the last glyph
4741 in that glyph row area. X is the current output position assigned
4742 to the new glyph string constructed. HL overrides that face of the
4743 glyph; e.g. it is DRAW_CURSOR if a cursor has to be drawn. LAST_X
4744 is the right-most x-position of the drawing area. */
4746 #define BUILD_STRETCH_GLYPH_STRING(hdc, W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X) \
4749 s = (struct glyph_string *) alloca (sizeof *s); \
4750 w32_init_glyph_string (s, hdc, NULL, W, ROW, AREA, START, HL); \
4751 START = x_fill_stretch_glyph_string (s, ROW, AREA, START, END); \
4752 x_append_glyph_string (&HEAD, &TAIL, s); \
4758 /* Add a glyph string for an image glyph to the list of strings
4759 between HEAD and TAIL. START is the index of the image glyph in
4760 row area AREA of glyph row ROW. END is the index of the last glyph
4761 in that glyph row area. X is the current output position assigned
4762 to the new glyph string constructed. HL overrides that face of the
4763 glyph; e.g. it is DRAW_CURSOR if a cursor has to be drawn. LAST_X
4764 is the right-most x-position of the drawing area. */
4766 #define BUILD_IMAGE_GLYPH_STRING(hdc, W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X) \
4769 s = (struct glyph_string *) alloca (sizeof *s); \
4770 w32_init_glyph_string (s, hdc, NULL, W, ROW, AREA, START, HL); \
4771 x_fill_image_glyph_string (s); \
4772 x_append_glyph_string (&HEAD, &TAIL, s); \
4779 /* Add a glyph string for a sequence of character glyphs to the list
4780 of strings between HEAD and TAIL. START is the index of the first
4781 glyph in row area AREA of glyph row ROW that is part of the new
4782 glyph string. END is the index of the last glyph in that glyph row
4783 area. X is the current output position assigned to the new glyph
4784 string constructed. HL overrides that face of the glyph; e.g. it
4785 is DRAW_CURSOR if a cursor has to be drawn. LAST_X is the
4786 right-most x-position of the drawing area. */
4788 #define BUILD_CHAR_GLYPH_STRINGS(hdc, W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X, OVERLAPS_P) \
4794 c = (ROW)->glyphs[AREA][START].u.ch; \
4795 face_id = (ROW)->glyphs[AREA][START].face_id; \
4797 s = (struct glyph_string *) alloca (sizeof *s); \
4798 char2b = (wchar_t *) alloca ((END - START) * sizeof *char2b); \
4799 w32_init_glyph_string (s, hdc, char2b, W, ROW, AREA, START, HL); \
4800 x_append_glyph_string (&HEAD, &TAIL, s); \
4802 START = x_fill_glyph_string (s, face_id, START, END, \
4808 /* Add a glyph string for a composite sequence to the list of strings
4809 between HEAD and TAIL. START is the index of the first glyph in
4810 row area AREA of glyph row ROW that is part of the new glyph
4811 string. END is the index of the last glyph in that glyph row area.
4812 X is the current output position assigned to the new glyph string
4813 constructed. HL overrides that face of the glyph; e.g. it is
4814 DRAW_CURSOR if a cursor has to be drawn. LAST_X is the right-most
4815 x-position of the drawing area. */
4817 #define BUILD_COMPOSITE_GLYPH_STRING(hdc, W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X, OVERLAPS_P) \
4819 int cmp_id = (ROW)->glyphs[AREA][START].u.cmp_id; \
4820 int face_id = (ROW)->glyphs[AREA][START].face_id; \
4821 struct face *base_face = FACE_FROM_ID (XFRAME (w->frame), face_id); \
4822 struct composition *cmp = composition_table[cmp_id]; \
4823 int glyph_len = cmp->glyph_len; \
4825 struct face **faces; \
4826 struct glyph_string *first_s = NULL; \
4829 base_face = base_face->ascii_face; \
4830 char2b = (wchar_t *) alloca ((sizeof *char2b) * glyph_len); \
4831 faces = (struct face **) alloca ((sizeof *faces) * glyph_len); \
4832 /* At first, fill in `char2b' and `faces'. */ \
4833 for (n = 0; n < glyph_len; n++) \
4835 int c = COMPOSITION_GLYPH (cmp, n); \
4836 int this_face_id = FACE_FOR_CHAR (XFRAME (w->frame), base_face, c); \
4837 faces[n] = FACE_FROM_ID (XFRAME (w->frame), this_face_id); \
4838 x_get_char_face_and_encoding (XFRAME (w->frame), c, \
4839 this_face_id, char2b + n, 1); \
4842 /* Make glyph_strings for each glyph sequence that is drawable by \
4843 the same face, and append them to HEAD/TAIL. */ \
4844 for (n = 0; n < cmp->glyph_len;) \
4846 s = (struct glyph_string *) alloca (sizeof *s); \
4847 w32_init_glyph_string (s, hdc, char2b + n, W, ROW, AREA, START, HL); \
4848 x_append_glyph_string (&(HEAD), &(TAIL), s); \
4856 n = x_fill_composite_glyph_string (s, faces, OVERLAPS_P); \
4864 /* Build a list of glyph strings between HEAD and TAIL for the glyphs
4865 of AREA of glyph row ROW on window W between indices START and END.
4866 HL overrides the face for drawing glyph strings, e.g. it is
4867 DRAW_CURSOR to draw a cursor. X and LAST_X are start and end
4868 x-positions of the drawing area.
4870 This is an ugly monster macro construct because we must use alloca
4871 to allocate glyph strings (because x_draw_glyphs can be called
4874 #define BUILD_GLYPH_STRINGS(hdc, W, ROW, AREA, START, END, HEAD, TAIL, HL, X, LAST_X, OVERLAPS_P) \
4877 HEAD = TAIL = NULL; \
4878 while (START < END) \
4880 struct glyph *first_glyph = (ROW)->glyphs[AREA] + START; \
4881 switch (first_glyph->type) \
4884 BUILD_CHAR_GLYPH_STRINGS (hdc, W, ROW, AREA, START, END, \
4885 HEAD, TAIL, HL, X, LAST_X, \
4889 case COMPOSITE_GLYPH: \
4890 BUILD_COMPOSITE_GLYPH_STRING (hdc, W, ROW, AREA, START, \
4891 END, HEAD, TAIL, HL, X, \
4892 LAST_X, OVERLAPS_P); \
4895 case STRETCH_GLYPH: \
4896 BUILD_STRETCH_GLYPH_STRING (hdc, W, ROW, AREA, START, END,\
4897 HEAD, TAIL, HL, X, LAST_X); \
4901 BUILD_IMAGE_GLYPH_STRING (hdc, W, ROW, AREA, START, END, \
4902 HEAD, TAIL, HL, X, LAST_X); \
4909 x_set_glyph_string_background_width (s, START, LAST_X); \
4916 /* Draw glyphs between START and END in AREA of ROW on window W,
4917 starting at x-position X. X is relative to AREA in W. HL is a
4918 face-override with the following meaning:
4920 DRAW_NORMAL_TEXT draw normally
4921 DRAW_CURSOR draw in cursor face
4922 DRAW_MOUSE_FACE draw in mouse face.
4923 DRAW_INVERSE_VIDEO draw in mode line face
4924 DRAW_IMAGE_SUNKEN draw an image with a sunken relief around it
4925 DRAW_IMAGE_RAISED draw an image with a raised relief around it
4927 If OVERLAPS_P is non-zero, draw only the foreground of characters
4928 and clip to the physical height of ROW.
4930 Value is the x-position reached, relative to AREA of W. */
4933 x_draw_glyphs (w
, x
, row
, area
, start
, end
, hl
, overlaps_p
)
4936 struct glyph_row
*row
;
4937 enum glyph_row_area area
;
4939 enum draw_glyphs_face hl
;
4942 struct glyph_string
*head
, *tail
;
4943 struct glyph_string
*s
;
4944 int last_x
, area_width
;
4947 HDC hdc
= get_frame_dc (XFRAME (WINDOW_FRAME (w
)));
4949 /* Let's rather be paranoid than getting a SEGV. */
4950 end
= min (end
, row
->used
[area
]);
4951 start
= max (0, start
);
4952 start
= min (end
, start
);
4954 /* Translate X to frame coordinates. Set last_x to the right
4955 end of the drawing area. */
4956 if (row
->full_width_p
)
4958 /* X is relative to the left edge of W, without scroll bars
4960 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
4961 int window_left_x
= WINDOW_LEFT_MARGIN (w
) * CANON_X_UNIT (f
);
4964 area_width
= XFASTINT (w
->width
) * CANON_X_UNIT (f
);
4965 last_x
= window_left_x
+ area_width
;
4967 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
4969 int width
= FRAME_SCROLL_BAR_WIDTH (f
) * CANON_X_UNIT (f
);
4970 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
4976 x
+= FRAME_INTERNAL_BORDER_WIDTH (f
);
4977 last_x
-= FRAME_INTERNAL_BORDER_WIDTH (f
);
4981 x
= WINDOW_AREA_TO_FRAME_PIXEL_X (w
, area
, x
);
4982 area_width
= window_box_width (w
, area
);
4983 last_x
= WINDOW_AREA_TO_FRAME_PIXEL_X (w
, area
, area_width
);
4986 /* Build a doubly-linked list of glyph_string structures between
4987 head and tail from what we have to draw. Note that the macro
4988 BUILD_GLYPH_STRINGS will modify its start parameter. That's
4989 the reason we use a separate variable `i'. */
4991 BUILD_GLYPH_STRINGS (hdc
, w
, row
, area
, i
, end
, head
, tail
, hl
, x
, last_x
,
4994 x_reached
= tail
->x
+ tail
->background_width
;
4998 /* If there are any glyphs with lbearing < 0 or rbearing > width in
4999 the row, redraw some glyphs in front or following the glyph
5000 strings built above. */
5001 if (head
&& !overlaps_p
&& row
->contains_overlapping_glyphs_p
)
5004 struct glyph_string
*h
, *t
;
5006 /* Compute overhangs for all glyph strings. */
5007 for (s
= head
; s
; s
= s
->next
)
5008 x_compute_glyph_string_overhangs (s
);
5010 /* Prepend glyph strings for glyphs in front of the first glyph
5011 string that are overwritten because of the first glyph
5012 string's left overhang. The background of all strings
5013 prepended must be drawn because the first glyph string
5015 i
= x_left_overwritten (head
);
5019 BUILD_GLYPH_STRINGS (hdc
, w
, row
, area
, j
, start
, h
, t
,
5020 DRAW_NORMAL_TEXT
, dummy_x
, last_x
,
5023 x_compute_overhangs_and_x (t
, head
->x
, 1);
5024 x_prepend_glyph_string_lists (&head
, &tail
, h
, t
);
5027 /* Prepend glyph strings for glyphs in front of the first glyph
5028 string that overwrite that glyph string because of their
5029 right overhang. For these strings, only the foreground must
5030 be drawn, because it draws over the glyph string at `head'.
5031 The background must not be drawn because this would overwrite
5032 right overhangs of preceding glyphs for which no glyph
5034 i
= x_left_overwriting (head
);
5037 BUILD_GLYPH_STRINGS (hdc
, w
, row
, area
, i
, start
, h
, t
,
5038 DRAW_NORMAL_TEXT
, dummy_x
, last_x
,
5040 for (s
= h
; s
; s
= s
->next
)
5041 s
->background_filled_p
= 1;
5042 x_compute_overhangs_and_x (t
, head
->x
, 1);
5043 x_prepend_glyph_string_lists (&head
, &tail
, h
, t
);
5046 /* Append glyphs strings for glyphs following the last glyph
5047 string tail that are overwritten by tail. The background of
5048 these strings has to be drawn because tail's foreground draws
5050 i
= x_right_overwritten (tail
);
5053 BUILD_GLYPH_STRINGS (hdc
, w
, row
, area
, end
, i
, h
, t
,
5054 DRAW_NORMAL_TEXT
, x
, last_x
,
5056 x_compute_overhangs_and_x (h
, tail
->x
+ tail
->width
, 0);
5057 x_append_glyph_string_lists (&head
, &tail
, h
, t
);
5060 /* Append glyph strings for glyphs following the last glyph
5061 string tail that overwrite tail. The foreground of such
5062 glyphs has to be drawn because it writes into the background
5063 of tail. The background must not be drawn because it could
5064 paint over the foreground of following glyphs. */
5065 i
= x_right_overwriting (tail
);
5068 BUILD_GLYPH_STRINGS (hdc
, w
, row
, area
, end
, i
, h
, t
,
5069 DRAW_NORMAL_TEXT
, x
, last_x
,
5071 for (s
= h
; s
; s
= s
->next
)
5072 s
->background_filled_p
= 1;
5073 x_compute_overhangs_and_x (h
, tail
->x
+ tail
->width
, 0);
5074 x_append_glyph_string_lists (&head
, &tail
, h
, t
);
5078 /* Draw all strings. */
5079 for (s
= head
; s
; s
= s
->next
)
5080 x_draw_glyph_string (s
);
5082 if (area
== TEXT_AREA
5083 && !row
->full_width_p
5084 /* When drawing overlapping rows, only the glyph strings'
5085 foreground is drawn, which doesn't erase a cursor
5089 int x0
= head
? head
->x
: x
;
5090 int x1
= tail
? tail
->x
+ tail
->background_width
: x
;
5092 x0
= FRAME_TO_WINDOW_PIXEL_X (w
, x0
);
5093 x1
= FRAME_TO_WINDOW_PIXEL_X (w
, x1
);
5095 if (!row
->full_width_p
&& XFASTINT (w
->left_margin_width
) != 0)
5097 int left_area_width
= window_box_width (w
, LEFT_MARGIN_AREA
);
5098 x0
-= left_area_width
;
5099 x1
-= left_area_width
;
5102 notice_overwritten_cursor (w
, area
, x0
, x1
,
5103 row
->y
, MATRIX_ROW_BOTTOM_Y (row
));
5106 /* Value is the x-position up to which drawn, relative to AREA of W.
5107 This doesn't include parts drawn because of overhangs. */
5108 x_reached
= FRAME_TO_WINDOW_PIXEL_X (w
, x_reached
);
5109 if (!row
->full_width_p
)
5111 if (area
> LEFT_MARGIN_AREA
)
5112 x_reached
-= window_box_width (w
, LEFT_MARGIN_AREA
);
5113 if (area
> TEXT_AREA
)
5114 x_reached
-= window_box_width (w
, TEXT_AREA
);
5117 release_frame_dc (XFRAME (WINDOW_FRAME (w
)), hdc
);
5123 /* Fix the display of area AREA of overlapping row ROW in window W. */
5126 x_fix_overlapping_area (w
, row
, area
)
5128 struct glyph_row
*row
;
5129 enum glyph_row_area area
;
5135 if (area
== LEFT_MARGIN_AREA
)
5137 else if (area
== TEXT_AREA
)
5138 x
= row
->x
+ window_box_width (w
, LEFT_MARGIN_AREA
);
5140 x
= (window_box_width (w
, LEFT_MARGIN_AREA
)
5141 + window_box_width (w
, TEXT_AREA
));
5143 for (i
= 0; i
< row
->used
[area
];)
5145 if (row
->glyphs
[area
][i
].overlaps_vertically_p
)
5147 int start
= i
, start_x
= x
;
5151 x
+= row
->glyphs
[area
][i
].pixel_width
;
5154 while (i
< row
->used
[area
]
5155 && row
->glyphs
[area
][i
].overlaps_vertically_p
);
5157 x_draw_glyphs (w
, start_x
, row
, area
, start
, i
,
5158 DRAW_NORMAL_TEXT
, 1);
5162 x
+= row
->glyphs
[area
][i
].pixel_width
;
5171 /* Output LEN glyphs starting at START at the nominal cursor position.
5172 Advance the nominal cursor over the text. The global variable
5173 updated_window contains the window being updated, updated_row is
5174 the glyph row being updated, and updated_area is the area of that
5175 row being updated. */
5178 x_write_glyphs (start
, len
)
5179 struct glyph
*start
;
5184 xassert (updated_window
&& updated_row
);
5189 hpos
= start
- updated_row
->glyphs
[updated_area
];
5190 x
= x_draw_glyphs (updated_window
, output_cursor
.x
,
5191 updated_row
, updated_area
,
5193 DRAW_NORMAL_TEXT
, 0);
5197 /* Advance the output cursor. */
5198 output_cursor
.hpos
+= len
;
5199 output_cursor
.x
= x
;
5203 /* Insert LEN glyphs from START at the nominal cursor position. */
5206 x_insert_glyphs (start
, len
)
5207 struct glyph
*start
;
5212 int line_height
, shift_by_width
, shifted_region_width
;
5213 struct glyph_row
*row
;
5214 struct glyph
*glyph
;
5215 int frame_x
, frame_y
, hpos
;
5218 xassert (updated_window
&& updated_row
);
5221 f
= XFRAME (WINDOW_FRAME (w
));
5222 hdc
= get_frame_dc (f
);
5224 /* Get the height of the line we are in. */
5226 line_height
= row
->height
;
5228 /* Get the width of the glyphs to insert. */
5230 for (glyph
= start
; glyph
< start
+ len
; ++glyph
)
5231 shift_by_width
+= glyph
->pixel_width
;
5233 /* Get the width of the region to shift right. */
5234 shifted_region_width
= (window_box_width (w
, updated_area
)
5239 frame_x
= window_box_left (w
, updated_area
) + output_cursor
.x
;
5240 frame_y
= WINDOW_TO_FRAME_PIXEL_Y (w
, output_cursor
.y
);
5241 BitBlt (hdc
, frame_x
+ shift_by_width
, frame_y
,
5242 shifted_region_width
, line_height
,
5243 hdc
, frame_x
, frame_y
, SRCCOPY
);
5245 /* Write the glyphs. */
5246 hpos
= start
- row
->glyphs
[updated_area
];
5247 x_draw_glyphs (w
, output_cursor
.x
, row
, updated_area
, hpos
, hpos
+ len
,
5248 DRAW_NORMAL_TEXT
, 0);
5250 /* Advance the output cursor. */
5251 output_cursor
.hpos
+= len
;
5252 output_cursor
.x
+= shift_by_width
;
5253 release_frame_dc (f
, hdc
);
5259 /* Delete N glyphs at the nominal cursor position. Not implemented
5271 f
= SELECTED_FRAME ();
5273 if (! FRAME_W32_P (f
))
5280 /* Erase the current text line from the nominal cursor position
5281 (inclusive) to pixel column TO_X (exclusive). The idea is that
5282 everything from TO_X onward is already erased.
5284 TO_X is a pixel position relative to updated_area of
5285 updated_window. TO_X == -1 means clear to the end of this area. */
5288 x_clear_end_of_line (to_x
)
5292 struct window
*w
= updated_window
;
5293 int max_x
, min_y
, max_y
;
5294 int from_x
, from_y
, to_y
;
5296 xassert (updated_window
&& updated_row
);
5297 f
= XFRAME (w
->frame
);
5299 if (updated_row
->full_width_p
)
5301 max_x
= XFASTINT (w
->width
) * CANON_X_UNIT (f
);
5302 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
5303 && !w
->pseudo_window_p
)
5304 max_x
+= FRAME_SCROLL_BAR_WIDTH (f
) * CANON_X_UNIT (f
);
5307 max_x
= window_box_width (w
, updated_area
);
5308 max_y
= window_text_bottom_y (w
);
5310 /* TO_X == 0 means don't do anything. TO_X < 0 means clear to end
5311 of window. For TO_X > 0, truncate to end of drawing area. */
5317 to_x
= min (to_x
, max_x
);
5319 to_y
= min (max_y
, output_cursor
.y
+ updated_row
->height
);
5321 /* Notice if the cursor will be cleared by this operation. */
5322 if (!updated_row
->full_width_p
)
5323 notice_overwritten_cursor (w
, updated_area
,
5324 output_cursor
.x
, -1,
5326 MATRIX_ROW_BOTTOM_Y (updated_row
));
5328 from_x
= output_cursor
.x
;
5330 /* Translate to frame coordinates. */
5331 if (updated_row
->full_width_p
)
5333 from_x
= WINDOW_TO_FRAME_PIXEL_X (w
, from_x
);
5334 to_x
= WINDOW_TO_FRAME_PIXEL_X (w
, to_x
);
5338 from_x
= WINDOW_AREA_TO_FRAME_PIXEL_X (w
, updated_area
, from_x
);
5339 to_x
= WINDOW_AREA_TO_FRAME_PIXEL_X (w
, updated_area
, to_x
);
5342 min_y
= WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w
);
5343 from_y
= WINDOW_TO_FRAME_PIXEL_Y (w
, max (min_y
, output_cursor
.y
));
5344 to_y
= WINDOW_TO_FRAME_PIXEL_Y (w
, to_y
);
5346 /* Prevent inadvertently clearing to end of the X window. */
5347 if (to_x
> from_x
&& to_y
> from_y
)
5351 hdc
= get_frame_dc (f
);
5353 w32_clear_area (f
, hdc
, from_x
, from_y
, to_x
- from_x
, to_y
- from_y
);
5354 release_frame_dc (f
, hdc
);
5360 /* Clear entire frame. If updating_frame is non-null, clear that
5361 frame. Otherwise clear the selected frame. */
5371 f
= SELECTED_FRAME ();
5373 if (! FRAME_W32_P (f
))
5376 /* Clearing the frame will erase any cursor, so mark them all as no
5378 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f
)));
5379 output_cursor
.hpos
= output_cursor
.vpos
= 0;
5380 output_cursor
.x
= -1;
5382 /* We don't set the output cursor here because there will always
5383 follow an explicit cursor_to. */
5386 w32_clear_window (f
);
5388 /* We have to clear the scroll bars, too. If we have changed
5389 colors or something like that, then they should be notified. */
5390 x_scroll_bar_clear (f
);
5396 /* Make audible bell. */
5399 w32_ring_bell (void)
5403 f
= SELECTED_FRAME ();
5407 if (FRAME_W32_P (f
) && visible_bell
)
5410 HWND hwnd
= FRAME_W32_WINDOW (SELECTED_FRAME ());
5412 for (i
= 0; i
< 5; i
++)
5414 FlashWindow (hwnd
, TRUE
);
5417 FlashWindow (hwnd
, FALSE
);
5420 w32_sys_ring_bell ();
5426 /* Specify how many text lines, from the top of the window,
5427 should be affected by insert-lines and delete-lines operations.
5428 This, and those operations, are used only within an update
5429 that is bounded by calls to x_update_begin and x_update_end. */
5432 w32_set_terminal_window (n
)
5435 /* This function intentionally left blank. */
5440 /***********************************************************************
5442 ***********************************************************************/
5444 /* Perform an insert-lines or delete-lines operation, inserting N
5445 lines or deleting -N lines at vertical position VPOS. */
5448 x_ins_del_lines (vpos
, n
)
5456 f
= SELECTED_FRAME ();
5458 if (! FRAME_W32_P (f
))
5465 /* Scroll part of the display as described by RUN. */
5468 x_scroll_run (w
, run
)
5472 struct frame
*f
= XFRAME (w
->frame
);
5473 int x
, y
, width
, height
, from_y
, to_y
, bottom_y
;
5474 HWND hwnd
= FRAME_W32_WINDOW (f
);
5477 /* Get frame-relative bounding box of the text display area of W,
5478 without mode lines. Include in this box the left and right
5480 window_box (w
, -1, &x
, &y
, &width
, &height
);
5481 width
+= FRAME_X_FRINGE_WIDTH (f
);
5482 x
-= FRAME_X_LEFT_FRINGE_WIDTH (f
);
5484 from_y
= WINDOW_TO_FRAME_PIXEL_Y (w
, run
->current_y
);
5485 to_y
= WINDOW_TO_FRAME_PIXEL_Y (w
, run
->desired_y
);
5486 bottom_y
= y
+ height
;
5490 /* Scrolling up. Make sure we don't copy part of the mode
5491 line at the bottom. */
5492 if (from_y
+ run
->height
> bottom_y
)
5493 height
= bottom_y
- from_y
;
5495 height
= run
->height
;
5496 expect_dirty
= CreateRectRgn (x
, y
+ height
, x
+ width
, bottom_y
);
5500 /* Scolling down. Make sure we don't copy over the mode line.
5502 if (to_y
+ run
->height
> bottom_y
)
5503 height
= bottom_y
- to_y
;
5505 height
= run
->height
;
5506 expect_dirty
= CreateRectRgn (x
, y
, x
+ width
, to_y
);
5511 /* Cursor off. Will be switched on again in x_update_window_end. */
5518 HRGN dirty
= CreateRectRgn (0, 0, 0, 0);
5519 HRGN combined
= CreateRectRgn (0, 0, 0, 0);
5521 from
.left
= to
.left
= x
;
5522 from
.right
= to
.right
= x
+ width
;
5524 from
.bottom
= from_y
+ height
;
5526 to
.bottom
= bottom_y
;
5528 ScrollWindowEx (hwnd
, 0, to_y
- from_y
, &from
, &to
, dirty
,
5529 NULL
, SW_INVALIDATE
);
5531 /* Combine this with what we expect to be dirty. This covers the
5532 case where not all of the region we expect is actually dirty. */
5533 CombineRgn (combined
, dirty
, expect_dirty
, RGN_OR
);
5535 /* If the dirty region is not what we expected, redraw the entire frame. */
5536 if (!EqualRgn (combined
, expect_dirty
))
5537 SET_FRAME_GARBAGED (f
);
5545 /***********************************************************************
5547 ***********************************************************************/
5549 /* Redisplay an exposed area of frame F. X and Y are the upper-left
5550 corner of the exposed rectangle. W and H are width and height of
5551 the exposed area. All are pixel values. W or H zero means redraw
5552 the entire frame. */
5555 expose_frame (f
, x
, y
, w
, h
)
5560 int mouse_face_overwritten_p
= 0;
5562 TRACE ((stderr
, "expose_frame "));
5564 /* No need to redraw if frame will be redrawn soon. */
5565 if (FRAME_GARBAGED_P (f
))
5567 TRACE ((stderr
, " garbaged\n"));
5571 /* If basic faces haven't been realized yet, there is no point in
5572 trying to redraw anything. This can happen when we get an expose
5573 event while Emacs is starting, e.g. by moving another window. */
5574 if (FRAME_FACE_CACHE (f
) == NULL
5575 || FRAME_FACE_CACHE (f
)->used
< BASIC_FACE_ID_SENTINEL
)
5577 TRACE ((stderr
, " no faces\n"));
5581 if (w
== 0 || h
== 0)
5584 r
.right
= CANON_X_UNIT (f
) * f
->width
;
5585 r
.bottom
= CANON_Y_UNIT (f
) * f
->height
;
5595 TRACE ((stderr
, "(%d, %d, %d, %d)\n", r
.left
, r
.top
, r
.right
, r
.bottom
));
5596 mouse_face_overwritten_p
= expose_window_tree (XWINDOW (f
->root_window
), &r
);
5598 if (WINDOWP (f
->tool_bar_window
))
5599 mouse_face_overwritten_p
5600 |= expose_window (XWINDOW (f
->tool_bar_window
), &r
);
5602 /* Some window managers support a focus-follows-mouse style with
5603 delayed raising of frames. Imagine a partially obscured frame,
5604 and moving the mouse into partially obscured mouse-face on that
5605 frame. The visible part of the mouse-face will be highlighted,
5606 then the WM raises the obscured frame. With at least one WM, KDE
5607 2.1, Emacs is not getting any event for the raising of the frame
5608 (even tried with SubstructureRedirectMask), only Expose events.
5609 These expose events will draw text normally, i.e. not
5610 highlighted. Which means we must redo the highlight here.
5611 Subsume it under ``we love X''. --gerd 2001-08-15 */
5612 /* Included in Windows version because Windows most likely does not
5613 do the right thing if any third party tool offers
5614 focus-follows-mouse with delayed raise. --jason 2001-10-12 */
5615 if (mouse_face_overwritten_p
&& !FRAME_GARBAGED_P (f
))
5617 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
5618 if (f
== dpyinfo
->mouse_face_mouse_frame
)
5620 int x
= dpyinfo
->mouse_face_mouse_x
;
5621 int y
= dpyinfo
->mouse_face_mouse_y
;
5622 clear_mouse_face (dpyinfo
);
5623 note_mouse_highlight (f
, x
, y
);
5629 /* Redraw (parts) of all windows in the window tree rooted at W that
5630 intersect R. R contains frame pixel coordinates. */
5633 expose_window_tree (w
, r
)
5637 struct frame
*f
= XFRAME (w
->frame
);
5638 int mouse_face_overwritten_p
= 0;
5640 while (w
&& !FRAME_GARBAGED_P (f
))
5642 if (!NILP (w
->hchild
))
5643 mouse_face_overwritten_p
5644 |= expose_window_tree (XWINDOW (w
->hchild
), r
);
5645 else if (!NILP (w
->vchild
))
5646 mouse_face_overwritten_p
5647 |= expose_window_tree (XWINDOW (w
->vchild
), r
);
5649 mouse_face_overwritten_p
|= expose_window (w
, r
);
5651 w
= NILP (w
->next
) ? NULL
: XWINDOW (w
->next
);
5654 return mouse_face_overwritten_p
;
5658 /* Redraw the part of glyph row area AREA of glyph row ROW on window W
5659 which intersects rectangle R. R is in window-relative coordinates. */
5662 expose_area (w
, row
, r
, area
)
5664 struct glyph_row
*row
;
5666 enum glyph_row_area area
;
5668 struct glyph
*first
= row
->glyphs
[area
];
5669 struct glyph
*end
= row
->glyphs
[area
] + row
->used
[area
];
5671 int first_x
, start_x
, x
;
5673 if (area
== TEXT_AREA
&& row
->fill_line_p
)
5674 /* If row extends face to end of line write the whole line. */
5675 x_draw_glyphs (w
, 0, row
, area
,
5677 DRAW_NORMAL_TEXT
, 0);
5680 /* Set START_X to the window-relative start position for drawing glyphs of
5681 AREA. The first glyph of the text area can be partially visible.
5682 The first glyphs of other areas cannot. */
5683 if (area
== LEFT_MARGIN_AREA
)
5685 else if (area
== TEXT_AREA
)
5686 start_x
= row
->x
+ window_box_width (w
, LEFT_MARGIN_AREA
);
5688 start_x
= (window_box_width (w
, LEFT_MARGIN_AREA
)
5689 + window_box_width (w
, TEXT_AREA
));
5692 /* Find the first glyph that must be redrawn. */
5694 && x
+ first
->pixel_width
< r
->left
)
5696 x
+= first
->pixel_width
;
5700 /* Find the last one. */
5706 x
+= last
->pixel_width
;
5712 x_draw_glyphs (w
, first_x
- start_x
, row
, area
,
5713 first
- row
->glyphs
[area
],
5714 last
- row
->glyphs
[area
],
5715 DRAW_NORMAL_TEXT
, 0);
5720 /* Redraw the parts of the glyph row ROW on window W intersecting
5721 rectangle R. R is in window-relative coordinates. Value is
5722 non-zero if mouse face was overwritten. */
5725 expose_line (w
, row
, r
)
5727 struct glyph_row
*row
;
5730 xassert (row
->enabled_p
);
5732 if (row
->mode_line_p
|| w
->pseudo_window_p
)
5733 x_draw_glyphs (w
, 0, row
, TEXT_AREA
, 0, row
->used
[TEXT_AREA
],
5734 DRAW_NORMAL_TEXT
, 0);
5737 if (row
->used
[LEFT_MARGIN_AREA
])
5738 expose_area (w
, row
, r
, LEFT_MARGIN_AREA
);
5739 if (row
->used
[TEXT_AREA
])
5740 expose_area (w
, row
, r
, TEXT_AREA
);
5741 if (row
->used
[RIGHT_MARGIN_AREA
])
5742 expose_area (w
, row
, r
, RIGHT_MARGIN_AREA
);
5743 x_draw_row_fringe_bitmaps (w
, row
);
5746 return row
->mouse_face_p
;
5750 /* Return non-zero if W's cursor intersects rectangle R. */
5753 x_phys_cursor_in_rect_p (w
, r
)
5758 struct glyph
*cursor_glyph
;
5760 cursor_glyph
= get_phys_cursor_glyph (w
);
5763 cr
.left
= w
->phys_cursor
.x
;
5764 cr
.top
= w
->phys_cursor
.y
;
5765 cr
.right
= cr
.left
+ cursor_glyph
->pixel_width
;
5766 cr
.bottom
= cr
.top
+ w
->phys_cursor_height
;
5767 return IntersectRect (&result
, &cr
, r
);
5774 /* Redraw the part of window W intersection rectagle FR. Pixel
5775 coordinates in FR are frame relative. Call this function with
5776 input blocked. Value is non-zero if the exposure overwrites
5780 expose_window (w
, fr
)
5784 struct frame
*f
= XFRAME (w
->frame
);
5786 int mouse_face_overwritten_p
= 0;
5788 /* If window is not yet fully initialized, do nothing. This can
5789 happen when toolkit scroll bars are used and a window is split.
5790 Reconfiguring the scroll bar will generate an expose for a newly
5792 if (w
->current_matrix
== NULL
)
5795 /* When we're currently updating the window, display and current
5796 matrix usually don't agree. Arrange for a thorough display
5798 if (w
== updated_window
)
5800 SET_FRAME_GARBAGED (f
);
5804 /* Frame-relative pixel rectangle of W. */
5805 wr
.left
= XFASTINT (w
->left
) * CANON_X_UNIT (f
);
5806 wr
.top
= XFASTINT (w
->top
) * CANON_Y_UNIT (f
);
5807 wr
.right
= wr
.left
+ XFASTINT (w
->width
) * CANON_X_UNIT (f
);
5808 wr
.bottom
= wr
.top
+ XFASTINT (w
->height
) * CANON_Y_UNIT (f
);
5810 if (IntersectRect(&r
, fr
, &wr
))
5812 int yb
= window_text_bottom_y (w
);
5813 struct glyph_row
*row
;
5814 int cursor_cleared_p
;
5816 TRACE ((stderr
, "expose_window (%d, %d, %d, %d)\n",
5817 r
.left
, r
.top
, r
.right
, r
.bottom
));
5819 /* Convert to window coordinates. */
5820 r
.left
= FRAME_TO_WINDOW_PIXEL_X (w
, r
.left
);
5821 r
.right
= FRAME_TO_WINDOW_PIXEL_X (w
, r
.right
);
5822 r
.top
= FRAME_TO_WINDOW_PIXEL_Y (w
, r
.top
);
5823 r
.bottom
= FRAME_TO_WINDOW_PIXEL_Y (w
, r
.bottom
);
5825 /* Turn off the cursor. */
5826 if (!w
->pseudo_window_p
5827 && x_phys_cursor_in_rect_p (w
, &r
))
5830 cursor_cleared_p
= 1;
5833 cursor_cleared_p
= 0;
5835 /* Find the first row intersecting the rectangle R. */
5836 for (row
= w
->current_matrix
->rows
;
5841 int y1
= MATRIX_ROW_BOTTOM_Y (row
);
5843 if ((y0
>= r
.top
&& y0
< r
.bottom
)
5844 || (y1
> r
.top
&& y1
< r
.bottom
)
5845 || (r
.top
>= y0
&& r
.top
< y1
)
5846 || (r
.bottom
> y0
&& r
.bottom
< y1
))
5848 if (expose_line (w
, row
, &r
))
5849 mouse_face_overwritten_p
= 1;
5856 /* Display the mode line if there is one. */
5857 if (WINDOW_WANTS_MODELINE_P (w
)
5858 && (row
= MATRIX_MODE_LINE_ROW (w
->current_matrix
),
5860 && row
->y
< r
.bottom
)
5862 if (expose_line (w
, row
, &r
))
5863 mouse_face_overwritten_p
= 1;
5866 if (!w
->pseudo_window_p
)
5868 /* Draw border between windows. */
5869 x_draw_vertical_border (w
);
5871 /* Turn the cursor on again. */
5872 if (cursor_cleared_p
)
5873 x_update_window_cursor (w
, 1);
5877 return mouse_face_overwritten_p
;
5885 x_update_cursor (f
, 1);
5889 frame_unhighlight (f
)
5892 x_update_cursor (f
, 1);
5895 /* The focus has changed. Update the frames as necessary to reflect
5896 the new situation. Note that we can't change the selected frame
5897 here, because the Lisp code we are interrupting might become confused.
5898 Each event gets marked with the frame in which it occurred, so the
5899 Lisp code can tell when the switch took place by examining the events. */
5902 x_new_focus_frame (dpyinfo
, frame
)
5903 struct w32_display_info
*dpyinfo
;
5904 struct frame
*frame
;
5906 struct frame
*old_focus
= dpyinfo
->w32_focus_frame
;
5908 if (frame
!= dpyinfo
->w32_focus_frame
)
5910 /* Set this before calling other routines, so that they see
5911 the correct value of w32_focus_frame. */
5912 dpyinfo
->w32_focus_frame
= frame
;
5914 if (old_focus
&& old_focus
->auto_lower
)
5915 x_lower_frame (old_focus
);
5917 if (dpyinfo
->w32_focus_frame
&& dpyinfo
->w32_focus_frame
->auto_raise
)
5918 pending_autoraise_frame
= dpyinfo
->w32_focus_frame
;
5920 pending_autoraise_frame
= 0;
5923 x_frame_rehighlight (dpyinfo
);
5926 /* Handle an event saying the mouse has moved out of an Emacs frame. */
5929 x_mouse_leave (dpyinfo
)
5930 struct w32_display_info
*dpyinfo
;
5932 x_new_focus_frame (dpyinfo
, dpyinfo
->w32_focus_event_frame
);
5935 /* The focus has changed, or we have redirected a frame's focus to
5936 another frame (this happens when a frame uses a surrogate
5937 mini-buffer frame). Shift the highlight as appropriate.
5939 The FRAME argument doesn't necessarily have anything to do with which
5940 frame is being highlighted or un-highlighted; we only use it to find
5941 the appropriate X display info. */
5944 w32_frame_rehighlight (frame
)
5945 struct frame
*frame
;
5947 if (! FRAME_W32_P (frame
))
5949 x_frame_rehighlight (FRAME_W32_DISPLAY_INFO (frame
));
5953 x_frame_rehighlight (dpyinfo
)
5954 struct w32_display_info
*dpyinfo
;
5956 struct frame
*old_highlight
= dpyinfo
->w32_highlight_frame
;
5958 if (dpyinfo
->w32_focus_frame
)
5960 dpyinfo
->w32_highlight_frame
5961 = ((GC_FRAMEP (FRAME_FOCUS_FRAME (dpyinfo
->w32_focus_frame
)))
5962 ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo
->w32_focus_frame
))
5963 : dpyinfo
->w32_focus_frame
);
5964 if (! FRAME_LIVE_P (dpyinfo
->w32_highlight_frame
))
5966 FRAME_FOCUS_FRAME (dpyinfo
->w32_focus_frame
) = Qnil
;
5967 dpyinfo
->w32_highlight_frame
= dpyinfo
->w32_focus_frame
;
5971 dpyinfo
->w32_highlight_frame
= 0;
5973 if (dpyinfo
->w32_highlight_frame
!= old_highlight
)
5976 frame_unhighlight (old_highlight
);
5977 if (dpyinfo
->w32_highlight_frame
)
5978 frame_highlight (dpyinfo
->w32_highlight_frame
);
5982 /* Keyboard processing - modifier keys, etc. */
5984 /* Convert a keysym to its name. */
5987 x_get_keysym_name (keysym
)
5990 /* Make static so we can always return it */
5991 static char value
[100];
5994 GetKeyNameText (keysym
, value
, 100);
6002 /* Mouse clicks and mouse movement. Rah. */
6004 /* Given a pixel position (PIX_X, PIX_Y) on frame F, return glyph
6005 co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle that the
6006 glyph at X, Y occupies, if BOUNDS != 0. If NOCLIP is non-zero, do
6007 not force the value into range. */
6010 pixel_to_glyph_coords (f
, pix_x
, pix_y
, x
, y
, bounds
, noclip
)
6012 register int pix_x
, pix_y
;
6013 register int *x
, *y
;
6017 /* Support tty mode: if Vwindow_system is nil, behave correctly. */
6018 if (NILP (Vwindow_system
))
6025 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to round down
6026 even for negative values. */
6028 pix_x
-= FONT_WIDTH (FRAME_FONT (f
)) - 1;
6030 pix_y
-= (f
)->output_data
.w32
->line_height
- 1;
6032 pix_x
= PIXEL_TO_CHAR_COL (f
, pix_x
);
6033 pix_y
= PIXEL_TO_CHAR_ROW (f
, pix_y
);
6037 bounds
->left
= CHAR_TO_PIXEL_COL (f
, pix_x
);
6038 bounds
->top
= CHAR_TO_PIXEL_ROW (f
, pix_y
);
6039 bounds
->right
= bounds
->left
+ FONT_WIDTH (FRAME_FONT (f
)) - 1;
6040 bounds
->bottom
= bounds
->top
+ f
->output_data
.w32
->line_height
- 1;
6047 else if (pix_x
> FRAME_WINDOW_WIDTH (f
))
6048 pix_x
= FRAME_WINDOW_WIDTH (f
);
6052 else if (pix_y
> f
->height
)
6061 /* Given HPOS/VPOS in the current matrix of W, return corresponding
6062 frame-relative pixel positions in *FRAME_X and *FRAME_Y. If we
6063 can't tell the positions because W's display is not up to date,
6067 glyph_to_pixel_coords (w
, hpos
, vpos
, frame_x
, frame_y
)
6070 int *frame_x
, *frame_y
;
6074 xassert (hpos
>= 0 && hpos
< w
->current_matrix
->matrix_w
);
6075 xassert (vpos
>= 0 && vpos
< w
->current_matrix
->matrix_h
);
6077 if (display_completed
)
6079 struct glyph_row
*row
= MATRIX_ROW (w
->current_matrix
, vpos
);
6080 struct glyph
*glyph
= row
->glyphs
[TEXT_AREA
];
6081 struct glyph
*end
= glyph
+ min (hpos
, row
->used
[TEXT_AREA
]);
6087 *frame_x
+= glyph
->pixel_width
;
6095 *frame_y
= *frame_x
= 0;
6099 *frame_y
= WINDOW_TO_FRAME_PIXEL_Y (w
, *frame_y
);
6100 *frame_x
= WINDOW_TO_FRAME_PIXEL_X (w
, *frame_x
);
6104 /* Parse a button MESSAGE. The button index is returned in PBUTTON, and
6105 the state in PUP. XBUTTON provides extra information for extended mouse
6106 button messages. Returns FALSE if unable to parse the message. */
6108 parse_button (message
, xbutton
, pbutton
, pup
)
6119 case WM_LBUTTONDOWN
:
6127 case WM_MBUTTONDOWN
:
6128 if (NILP (Vw32_swap_mouse_buttons
))
6135 if (NILP (Vw32_swap_mouse_buttons
))
6141 case WM_RBUTTONDOWN
:
6142 if (NILP (Vw32_swap_mouse_buttons
))
6149 if (NILP (Vw32_swap_mouse_buttons
))
6155 case WM_XBUTTONDOWN
:
6156 button
= xbutton
+ 2;
6160 button
= xbutton
+ 2;
6168 if (pbutton
) *pbutton
= button
;
6174 /* Prepare a mouse-event in *RESULT for placement in the input queue.
6176 If the event is a button press, then note that we have grabbed
6180 construct_mouse_click (result
, msg
, f
)
6181 struct input_event
*result
;
6188 parse_button (msg
->msg
.message
, HIWORD (msg
->msg
.wParam
),
6191 /* Make the event type NO_EVENT; we'll change that when we decide
6193 result
->kind
= MOUSE_CLICK_EVENT
;
6194 result
->code
= button
;
6195 result
->timestamp
= msg
->msg
.time
;
6196 result
->modifiers
= (msg
->dwModifiers
6201 XSETINT (result
->x
, LOWORD (msg
->msg
.lParam
));
6202 XSETINT (result
->y
, HIWORD (msg
->msg
.lParam
));
6203 XSETFRAME (result
->frame_or_window
, f
);
6209 construct_mouse_wheel (result
, msg
, f
)
6210 struct input_event
*result
;
6215 result
->kind
= MOUSE_WHEEL_EVENT
;
6216 result
->code
= (short) HIWORD (msg
->msg
.wParam
);
6217 result
->timestamp
= msg
->msg
.time
;
6218 result
->modifiers
= msg
->dwModifiers
;
6219 p
.x
= LOWORD (msg
->msg
.lParam
);
6220 p
.y
= HIWORD (msg
->msg
.lParam
);
6221 ScreenToClient (msg
->msg
.hwnd
, &p
);
6222 XSETINT (result
->x
, p
.x
);
6223 XSETINT (result
->y
, p
.y
);
6224 XSETFRAME (result
->frame_or_window
, f
);
6230 construct_drag_n_drop (result
, msg
, f
)
6231 struct input_event
*result
;
6243 result
->kind
= DRAG_N_DROP_EVENT
;
6245 result
->timestamp
= msg
->msg
.time
;
6246 result
->modifiers
= msg
->dwModifiers
;
6248 hdrop
= (HDROP
) msg
->msg
.wParam
;
6249 DragQueryPoint (hdrop
, &p
);
6252 p
.x
= LOWORD (msg
->msg
.lParam
);
6253 p
.y
= HIWORD (msg
->msg
.lParam
);
6254 ScreenToClient (msg
->msg
.hwnd
, &p
);
6257 XSETINT (result
->x
, p
.x
);
6258 XSETINT (result
->y
, p
.y
);
6260 num_files
= DragQueryFile (hdrop
, 0xFFFFFFFF, NULL
, 0);
6263 for (i
= 0; i
< num_files
; i
++)
6265 len
= DragQueryFile (hdrop
, i
, NULL
, 0);
6268 name
= alloca (len
+ 1);
6269 DragQueryFile (hdrop
, i
, name
, len
+ 1);
6270 files
= Fcons (DECODE_FILE (build_string (name
)), files
);
6275 XSETFRAME (frame
, f
);
6276 result
->frame_or_window
= Fcons (frame
, files
);
6282 /* Function to report a mouse movement to the mainstream Emacs code.
6283 The input handler calls this.
6285 We have received a mouse movement event, which is given in *event.
6286 If the mouse is over a different glyph than it was last time, tell
6287 the mainstream emacs code by setting mouse_moved. If not, ask for
6288 another motion event, so we can check again the next time it moves. */
6290 static MSG last_mouse_motion_event
;
6291 static Lisp_Object last_mouse_motion_frame
;
6293 static void remember_mouse_glyph
P_ ((struct frame
*, int, int));
6296 note_mouse_movement (frame
, msg
)
6300 int mouse_x
= LOWORD (msg
->lParam
);
6301 int mouse_y
= HIWORD (msg
->lParam
);
6303 last_mouse_movement_time
= msg
->time
;
6304 memcpy (&last_mouse_motion_event
, msg
, sizeof (last_mouse_motion_event
));
6305 XSETFRAME (last_mouse_motion_frame
, frame
);
6307 #if 0 /* Calling Lisp asynchronously is not safe. */
6308 if (mouse_autoselect_window
)
6312 static Lisp_Object last_window
;
6314 window
= window_from_coordinates (frame
, mouse_x
, mouse_y
, &area
, 0);
6316 /* Window will be selected only when it is not selected now and
6317 last mouse movement event was not in it. Minibuffer window
6318 will be selected iff it is active. */
6319 if (!EQ (window
, last_window
)
6320 && !EQ (window
, selected_window
)
6321 && (!MINI_WINDOW_P (XWINDOW (window
))
6322 || (EQ (window
, minibuf_window
) && minibuf_level
> 0)))
6323 Fselect_window (window
);
6329 if (msg
->hwnd
!= FRAME_W32_WINDOW (frame
))
6331 frame
->mouse_moved
= 1;
6332 last_mouse_scroll_bar
= Qnil
;
6333 note_mouse_highlight (frame
, -1, -1);
6336 /* Has the mouse moved off the glyph it was on at the last sighting? */
6337 else if (mouse_x
< last_mouse_glyph
.left
6338 || mouse_x
> last_mouse_glyph
.right
6339 || mouse_y
< last_mouse_glyph
.top
6340 || mouse_y
> last_mouse_glyph
.bottom
)
6342 frame
->mouse_moved
= 1;
6343 last_mouse_scroll_bar
= Qnil
;
6344 note_mouse_highlight (frame
, mouse_x
, mouse_y
);
6345 /* Remember the mouse position here, as w32_mouse_position only
6346 gets called when mouse tracking is enabled but we also need
6347 to keep track of the mouse for help_echo and highlighting at
6349 remember_mouse_glyph (frame
, mouse_x
, mouse_y
);
6354 /************************************************************************
6356 ************************************************************************/
6358 /* Find the glyph under window-relative coordinates X/Y in window W.
6359 Consider only glyphs from buffer text, i.e. no glyphs from overlay
6360 strings. Return in *HPOS and *VPOS the row and column number of
6361 the glyph found. Return in *AREA the glyph area containing X.
6362 Value is a pointer to the glyph found or null if X/Y is not on
6363 text, or we can't tell because W's current matrix is not up to
6366 static struct glyph
*
6367 x_y_to_hpos_vpos (w
, x
, y
, hpos
, vpos
, area
, buffer_only_p
)
6370 int *hpos
, *vpos
, *area
;
6373 struct glyph
*glyph
, *end
;
6374 struct glyph_row
*row
= NULL
;
6375 int x0
, i
, left_area_width
;
6377 /* Find row containing Y. Give up if some row is not enabled. */
6378 for (i
= 0; i
< w
->current_matrix
->nrows
; ++i
)
6380 row
= MATRIX_ROW (w
->current_matrix
, i
);
6381 if (!row
->enabled_p
)
6383 if (y
>= row
->y
&& y
< MATRIX_ROW_BOTTOM_Y (row
))
6390 /* Give up if Y is not in the window. */
6391 if (i
== w
->current_matrix
->nrows
)
6394 /* Get the glyph area containing X. */
6395 if (w
->pseudo_window_p
)
6402 left_area_width
= window_box_width (w
, LEFT_MARGIN_AREA
);
6403 if (x
< left_area_width
)
6405 *area
= LEFT_MARGIN_AREA
;
6408 else if (x
< left_area_width
+ window_box_width (w
, TEXT_AREA
))
6411 x0
= row
->x
+ left_area_width
;
6415 *area
= RIGHT_MARGIN_AREA
;
6416 x0
= left_area_width
+ window_box_width (w
, TEXT_AREA
);
6420 /* Find glyph containing X. */
6421 glyph
= row
->glyphs
[*area
];
6422 end
= glyph
+ row
->used
[*area
];
6425 if (x
< x0
+ glyph
->pixel_width
)
6427 if (w
->pseudo_window_p
)
6429 else if (!buffer_only_p
|| BUFFERP (glyph
->object
))
6433 x0
+= glyph
->pixel_width
;
6440 *hpos
= glyph
- row
->glyphs
[*area
];
6445 /* Convert frame-relative x/y to coordinates relative to window W.
6446 Takes pseudo-windows into account. */
6449 frame_to_window_pixel_xy (w
, x
, y
)
6453 if (w
->pseudo_window_p
)
6455 /* A pseudo-window is always full-width, and starts at the
6456 left edge of the frame, plus a frame border. */
6457 struct frame
*f
= XFRAME (w
->frame
);
6458 *x
-= FRAME_INTERNAL_BORDER_WIDTH_SAFE (f
);
6459 *y
= FRAME_TO_WINDOW_PIXEL_Y (w
, *y
);
6463 *x
= FRAME_TO_WINDOW_PIXEL_X (w
, *x
);
6464 *y
= FRAME_TO_WINDOW_PIXEL_Y (w
, *y
);
6469 /* Take proper action when mouse has moved to the mode or header line of
6470 window W, x-position X. MODE_LINE_P non-zero means mouse is on the
6471 mode line. X is relative to the start of the text display area of
6472 W, so the width of fringes and scroll bars must be subtracted
6473 to get a position relative to the start of the mode line. */
6476 note_mode_line_highlight (w
, x
, mode_line_p
)
6480 struct frame
*f
= XFRAME (w
->frame
);
6481 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
6482 Cursor cursor
= dpyinfo
->vertical_scroll_bar_cursor
;
6483 struct glyph_row
*row
;
6486 row
= MATRIX_MODE_LINE_ROW (w
->current_matrix
);
6488 row
= MATRIX_HEADER_LINE_ROW (w
->current_matrix
);
6492 struct glyph
*glyph
, *end
;
6493 Lisp_Object help
, map
;
6496 /* Find the glyph under X. */
6497 glyph
= row
->glyphs
[TEXT_AREA
];
6498 end
= glyph
+ row
->used
[TEXT_AREA
];
6499 x0
= - (FRAME_LEFT_SCROLL_BAR_WIDTH (f
) * CANON_X_UNIT (f
)
6500 + FRAME_X_LEFT_FRINGE_WIDTH (f
));
6503 && x
>= x0
+ glyph
->pixel_width
)
6505 x0
+= glyph
->pixel_width
;
6510 && STRINGP (glyph
->object
)
6511 && XSTRING (glyph
->object
)->intervals
6512 && glyph
->charpos
>= 0
6513 && glyph
->charpos
< XSTRING (glyph
->object
)->size
)
6515 /* If we're on a string with `help-echo' text property,
6516 arrange for the help to be displayed. This is done by
6517 setting the global variable help_echo to the help string. */
6518 help
= Fget_text_property (make_number (glyph
->charpos
),
6519 Qhelp_echo
, glyph
->object
);
6523 XSETWINDOW (help_echo_window
, w
);
6524 help_echo_object
= glyph
->object
;
6525 help_echo_pos
= glyph
->charpos
;
6528 /* Change the mouse pointer according to what is under X/Y. */
6529 map
= Fget_text_property (make_number (glyph
->charpos
),
6530 Qlocal_map
, glyph
->object
);
6532 cursor
= f
->output_data
.w32
->nontext_cursor
;
6535 map
= Fget_text_property (make_number (glyph
->charpos
),
6536 Qkeymap
, glyph
->object
);
6538 cursor
= f
->output_data
.w32
->nontext_cursor
;
6543 #if 0 /* TODO: mouse cursor */
6544 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
), cursor
);
6549 /* Take proper action when the mouse has moved to position X, Y on
6550 frame F as regards highlighting characters that have mouse-face
6551 properties. Also de-highlighting chars where the mouse was before.
6552 X and Y can be negative or out of range. */
6555 note_mouse_highlight (f
, x
, y
)
6559 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
6565 /* When a menu is active, don't highlight because this looks odd. */
6566 if (popup_activated ())
6569 if (NILP (Vmouse_highlight
)
6570 || !f
->glyphs_initialized_p
)
6573 dpyinfo
->mouse_face_mouse_x
= x
;
6574 dpyinfo
->mouse_face_mouse_y
= y
;
6575 dpyinfo
->mouse_face_mouse_frame
= f
;
6577 if (dpyinfo
->mouse_face_defer
)
6582 dpyinfo
->mouse_face_deferred_gc
= 1;
6586 /* Which window is that in? */
6587 window
= window_from_coordinates (f
, x
, y
, &portion
, 1);
6589 /* If we were displaying active text in another window, clear that. */
6590 if (! EQ (window
, dpyinfo
->mouse_face_window
))
6591 clear_mouse_face (dpyinfo
);
6593 /* Not on a window -> return. */
6594 if (!WINDOWP (window
))
6597 /* Reset help_echo. It will get recomputed below. */
6600 /* Convert to window-relative pixel coordinates. */
6601 w
= XWINDOW (window
);
6602 frame_to_window_pixel_xy (w
, &x
, &y
);
6604 /* Handle tool-bar window differently since it doesn't display a
6606 if (EQ (window
, f
->tool_bar_window
))
6608 note_tool_bar_highlight (f
, x
, y
);
6612 /* Mouse is on the mode or header line? */
6613 if (portion
== 1 || portion
== 3)
6615 note_mode_line_highlight (w
, x
, portion
== 1);
6618 #if 0 /* TODO: mouse cursor */
6620 cursor
= f
->output_data
.x
->horizontal_drag_cursor
;
6622 cursor
= f
->output_data
.x
->text_cursor
;
6624 /* Are we in a window whose display is up to date?
6625 And verify the buffer's text has not changed. */
6626 b
= XBUFFER (w
->buffer
);
6627 if (/* Within text portion of the window. */
6629 && EQ (w
->window_end_valid
, w
->buffer
)
6630 && XFASTINT (w
->last_modified
) == BUF_MODIFF (b
)
6631 && XFASTINT (w
->last_overlay_modified
) == BUF_OVERLAY_MODIFF (b
))
6633 int hpos
, vpos
, pos
, i
, area
;
6634 struct glyph
*glyph
;
6636 Lisp_Object mouse_face
= Qnil
, overlay
= Qnil
, position
;
6637 Lisp_Object
*overlay_vec
= NULL
;
6639 struct buffer
*obuf
;
6640 int obegv
, ozv
, same_region
;
6642 /* Find the glyph under X/Y. */
6643 glyph
= x_y_to_hpos_vpos (w
, x
, y
, &hpos
, &vpos
, &area
, 0);
6645 /* Clear mouse face if X/Y not over text. */
6647 || area
!= TEXT_AREA
6648 || !MATRIX_ROW (w
->current_matrix
, vpos
)->displays_text_p
)
6650 clear_mouse_face (dpyinfo
);
6651 /* TODO: mouse cursor */
6655 pos
= glyph
->charpos
;
6656 object
= glyph
->object
;
6657 if (!STRINGP (object
) && !BUFFERP (object
))
6660 /* If we get an out-of-range value, return now; avoid an error. */
6661 if (BUFFERP (object
) && pos
> BUF_Z (b
))
6664 /* Make the window's buffer temporarily current for
6665 overlays_at and compute_char_face. */
6666 obuf
= current_buffer
;
6673 /* Is this char mouse-active or does it have help-echo? */
6674 position
= make_number (pos
);
6676 if (BUFFERP (object
))
6678 /* Put all the overlays we want in a vector in overlay_vec.
6679 Store the length in len. If there are more than 10, make
6680 enough space for all, and try again. */
6682 overlay_vec
= (Lisp_Object
*) alloca (len
* sizeof (Lisp_Object
));
6683 noverlays
= overlays_at (pos
, 0, &overlay_vec
, &len
, NULL
, NULL
, 0);
6684 if (noverlays
> len
)
6687 overlay_vec
= (Lisp_Object
*) alloca (len
* sizeof (Lisp_Object
));
6688 noverlays
= overlays_at (pos
, 0, &overlay_vec
, &len
, NULL
, NULL
,0);
6691 /* Sort overlays into increasing priority order. */
6692 noverlays
= sort_overlays (overlay_vec
, noverlays
, w
);
6697 same_region
= (EQ (window
, dpyinfo
->mouse_face_window
)
6698 && vpos
>= dpyinfo
->mouse_face_beg_row
6699 && vpos
<= dpyinfo
->mouse_face_end_row
6700 && (vpos
> dpyinfo
->mouse_face_beg_row
6701 || hpos
>= dpyinfo
->mouse_face_beg_col
)
6702 && (vpos
< dpyinfo
->mouse_face_end_row
6703 || hpos
< dpyinfo
->mouse_face_end_col
6704 || dpyinfo
->mouse_face_past_end
));
6706 /* TODO: if (same_region)
6709 /* Check mouse-face highlighting. */
6711 /* If there exists an overlay with mouse-face overlapping
6712 the one we are currently highlighting, we have to
6713 check if we enter the overlapping overlay, and then
6715 || (OVERLAYP (dpyinfo
->mouse_face_overlay
)
6716 && mouse_face_overlay_overlaps (dpyinfo
->mouse_face_overlay
)))
6718 /* Find the highest priority overlay that has a mouse-face
6721 for (i
= noverlays
- 1; i
>= 0 && NILP (overlay
); --i
)
6723 mouse_face
= Foverlay_get (overlay_vec
[i
], Qmouse_face
);
6724 if (!NILP (mouse_face
))
6725 overlay
= overlay_vec
[i
];
6728 /* If we're actually highlighting the same overlay as
6729 before, there's no need to do that again. */
6731 && EQ (overlay
, dpyinfo
->mouse_face_overlay
))
6732 goto check_help_echo
;
6734 dpyinfo
->mouse_face_overlay
= overlay
;
6736 /* Clear the display of the old active region, if any. */
6737 clear_mouse_face (dpyinfo
);
6738 /* TODO: mouse cursor changes. */
6740 /* If no overlay applies, get a text property. */
6742 mouse_face
= Fget_text_property (position
, Qmouse_face
, object
);
6744 /* Handle the overlay case. */
6745 if (!NILP (overlay
))
6747 /* Find the range of text around this char that
6748 should be active. */
6749 Lisp_Object before
, after
;
6752 before
= Foverlay_start (overlay
);
6753 after
= Foverlay_end (overlay
);
6754 /* Record this as the current active region. */
6755 fast_find_position (w
, XFASTINT (before
),
6756 &dpyinfo
->mouse_face_beg_col
,
6757 &dpyinfo
->mouse_face_beg_row
,
6758 &dpyinfo
->mouse_face_beg_x
,
6759 &dpyinfo
->mouse_face_beg_y
, Qnil
);
6761 dpyinfo
->mouse_face_past_end
6762 = !fast_find_position (w
, XFASTINT (after
),
6763 &dpyinfo
->mouse_face_end_col
,
6764 &dpyinfo
->mouse_face_end_row
,
6765 &dpyinfo
->mouse_face_end_x
,
6766 &dpyinfo
->mouse_face_end_y
, Qnil
);
6767 dpyinfo
->mouse_face_window
= window
;
6769 dpyinfo
->mouse_face_face_id
6770 = face_at_buffer_position (w
, pos
, 0, 0,
6771 &ignore
, pos
+ 1, 1);
6773 /* Display it as active. */
6774 show_mouse_face (dpyinfo
, DRAW_MOUSE_FACE
);
6775 /* TODO: mouse cursor changes. */
6777 /* Handle the text property case. */
6778 else if (! NILP (mouse_face
) && BUFFERP (object
))
6780 /* Find the range of text around this char that
6781 should be active. */
6782 Lisp_Object before
, after
, beginning
, end
;
6785 beginning
= Fmarker_position (w
->start
);
6786 end
= make_number (BUF_Z (XBUFFER (object
))
6787 - XFASTINT (w
->window_end_pos
));
6789 = Fprevious_single_property_change (make_number (pos
+ 1),
6793 = Fnext_single_property_change (position
, Qmouse_face
,
6796 /* Record this as the current active region. */
6797 fast_find_position (w
, XFASTINT (before
),
6798 &dpyinfo
->mouse_face_beg_col
,
6799 &dpyinfo
->mouse_face_beg_row
,
6800 &dpyinfo
->mouse_face_beg_x
,
6801 &dpyinfo
->mouse_face_beg_y
, Qnil
);
6802 dpyinfo
->mouse_face_past_end
6803 = !fast_find_position (w
, XFASTINT (after
),
6804 &dpyinfo
->mouse_face_end_col
,
6805 &dpyinfo
->mouse_face_end_row
,
6806 &dpyinfo
->mouse_face_end_x
,
6807 &dpyinfo
->mouse_face_end_y
, Qnil
);
6808 dpyinfo
->mouse_face_window
= window
;
6810 if (BUFFERP (object
))
6811 dpyinfo
->mouse_face_face_id
6812 = face_at_buffer_position (w
, pos
, 0, 0,
6813 &ignore
, pos
+ 1, 1);
6815 /* Display it as active. */
6816 show_mouse_face (dpyinfo
, DRAW_MOUSE_FACE
);
6817 /* TODO: mouse cursor changes. */
6819 else if (!NILP (mouse_face
) && STRINGP (object
))
6824 b
= Fprevious_single_property_change (make_number (pos
+ 1),
6827 e
= Fnext_single_property_change (position
, Qmouse_face
,
6830 b
= make_number (0);
6832 e
= make_number (XSTRING (object
)->size
- 1);
6833 fast_find_string_pos (w
, XINT (b
), object
,
6834 &dpyinfo
->mouse_face_beg_col
,
6835 &dpyinfo
->mouse_face_beg_row
,
6836 &dpyinfo
->mouse_face_beg_x
,
6837 &dpyinfo
->mouse_face_beg_y
, 0);
6838 fast_find_string_pos (w
, XINT (e
), object
,
6839 &dpyinfo
->mouse_face_end_col
,
6840 &dpyinfo
->mouse_face_end_row
,
6841 &dpyinfo
->mouse_face_end_x
,
6842 &dpyinfo
->mouse_face_end_y
, 1);
6843 dpyinfo
->mouse_face_past_end
= 0;
6844 dpyinfo
->mouse_face_window
= window
;
6845 dpyinfo
->mouse_face_face_id
6846 = face_at_string_position (w
, object
, pos
, 0, 0, 0, &ignore
,
6848 show_mouse_face (dpyinfo
, DRAW_MOUSE_FACE
);
6849 /* TODO: mouse cursor changes. */
6851 else if (STRINGP (object
) && NILP (mouse_face
))
6853 /* A string which doesn't have mouse-face, but
6854 the text ``under'' it might have. */
6855 struct glyph_row
*r
= MATRIX_ROW (w
->current_matrix
, vpos
);
6856 int start
= MATRIX_ROW_START_CHARPOS (r
);
6858 pos
= string_buffer_position (w
, object
, start
);
6860 mouse_face
= get_char_property_and_overlay (make_number (pos
),
6864 if (!NILP (mouse_face
) && !NILP (overlay
))
6866 Lisp_Object before
= Foverlay_start (overlay
);
6867 Lisp_Object after
= Foverlay_end (overlay
);
6870 /* Note that we might not be able to find position
6871 BEFORE in the glyph matrix if the overlay is
6872 entirely covered by a `display' property. In
6873 this case, we overshoot. So let's stop in
6874 the glyph matrix before glyphs for OBJECT. */
6875 fast_find_position (w
, XFASTINT (before
),
6876 &dpyinfo
->mouse_face_beg_col
,
6877 &dpyinfo
->mouse_face_beg_row
,
6878 &dpyinfo
->mouse_face_beg_x
,
6879 &dpyinfo
->mouse_face_beg_y
,
6882 dpyinfo
->mouse_face_past_end
6883 = !fast_find_position (w
, XFASTINT (after
),
6884 &dpyinfo
->mouse_face_end_col
,
6885 &dpyinfo
->mouse_face_end_row
,
6886 &dpyinfo
->mouse_face_end_x
,
6887 &dpyinfo
->mouse_face_end_y
,
6889 dpyinfo
->mouse_face_window
= window
;
6890 dpyinfo
->mouse_face_face_id
6891 = face_at_buffer_position (w
, pos
, 0, 0,
6892 &ignore
, pos
+ 1, 1);
6894 /* Display it as active. */
6895 show_mouse_face (dpyinfo
, DRAW_MOUSE_FACE
);
6896 /* TODO: mouse cursor changes. */
6903 /* Look for a `help-echo' property. */
6905 Lisp_Object help
, overlay
;
6907 /* Check overlays first. */
6908 help
= overlay
= Qnil
;
6909 for (i
= noverlays
- 1; i
>= 0 && NILP (help
); --i
)
6911 overlay
= overlay_vec
[i
];
6912 help
= Foverlay_get (overlay
, Qhelp_echo
);
6918 help_echo_window
= window
;
6919 help_echo_object
= overlay
;
6920 help_echo_pos
= pos
;
6924 Lisp_Object object
= glyph
->object
;
6925 int charpos
= glyph
->charpos
;
6927 /* Try text properties. */
6928 if (STRINGP (object
)
6930 && charpos
< XSTRING (object
)->size
)
6932 help
= Fget_text_property (make_number (charpos
),
6933 Qhelp_echo
, object
);
6936 /* If the string itself doesn't specify a help-echo,
6937 see if the buffer text ``under'' it does. */
6939 = MATRIX_ROW (w
->current_matrix
, vpos
);
6940 int start
= MATRIX_ROW_START_CHARPOS (r
);
6941 int pos
= string_buffer_position (w
, object
, start
);
6944 help
= Fget_char_property (make_number (pos
),
6945 Qhelp_echo
, w
->buffer
);
6954 else if (BUFFERP (object
)
6957 help
= Fget_text_property (make_number (charpos
), Qhelp_echo
,
6963 help_echo_window
= window
;
6964 help_echo_object
= object
;
6965 help_echo_pos
= charpos
;
6972 current_buffer
= obuf
;
6976 /* TODO: mouse cursor changes. */
6981 redo_mouse_highlight ()
6983 if (!NILP (last_mouse_motion_frame
)
6984 && FRAME_LIVE_P (XFRAME (last_mouse_motion_frame
)))
6985 note_mouse_highlight (XFRAME (last_mouse_motion_frame
),
6986 LOWORD (last_mouse_motion_event
.lParam
),
6987 HIWORD (last_mouse_motion_event
.lParam
));
6992 /***********************************************************************
6994 ***********************************************************************/
6996 static int x_tool_bar_item
P_ ((struct frame
*, int, int,
6997 struct glyph
**, int *, int *, int *));
6999 /* Tool-bar item index of the item on which a mouse button was pressed
7002 static int last_tool_bar_item
;
7005 /* Get information about the tool-bar item at position X/Y on frame F.
7006 Return in *GLYPH a pointer to the glyph of the tool-bar item in
7007 the current matrix of the tool-bar window of F, or NULL if not
7008 on a tool-bar item. Return in *PROP_IDX the index of the tool-bar
7009 item in F->tool_bar_items. Value is
7011 -1 if X/Y is not on a tool-bar item
7012 0 if X/Y is on the same item that was highlighted before.
7016 x_tool_bar_item (f
, x
, y
, glyph
, hpos
, vpos
, prop_idx
)
7019 struct glyph
**glyph
;
7020 int *hpos
, *vpos
, *prop_idx
;
7022 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
7023 struct window
*w
= XWINDOW (f
->tool_bar_window
);
7026 /* Find the glyph under X/Y. */
7027 *glyph
= x_y_to_hpos_vpos (w
, x
, y
, hpos
, vpos
, &area
, 0);
7031 /* Get the start of this tool-bar item's properties in
7032 f->tool_bar_items. */
7033 if (!tool_bar_item_info (f
, *glyph
, prop_idx
))
7036 /* Is mouse on the highlighted item? */
7037 if (EQ (f
->tool_bar_window
, dpyinfo
->mouse_face_window
)
7038 && *vpos
>= dpyinfo
->mouse_face_beg_row
7039 && *vpos
<= dpyinfo
->mouse_face_end_row
7040 && (*vpos
> dpyinfo
->mouse_face_beg_row
7041 || *hpos
>= dpyinfo
->mouse_face_beg_col
)
7042 && (*vpos
< dpyinfo
->mouse_face_end_row
7043 || *hpos
< dpyinfo
->mouse_face_end_col
7044 || dpyinfo
->mouse_face_past_end
))
7051 /* Handle mouse button event on the tool-bar of frame F, at
7052 frame-relative coordinates X/Y. EVENT_TYPE is either ButtionPress
7056 w32_handle_tool_bar_click (f
, button_event
)
7058 struct input_event
*button_event
;
7060 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
7061 struct window
*w
= XWINDOW (f
->tool_bar_window
);
7062 int hpos
, vpos
, prop_idx
;
7063 struct glyph
*glyph
;
7064 Lisp_Object enabled_p
;
7065 int x
= XFASTINT (button_event
->x
);
7066 int y
= XFASTINT (button_event
->y
);
7068 /* If not on the highlighted tool-bar item, return. */
7069 frame_to_window_pixel_xy (w
, &x
, &y
);
7070 if (x_tool_bar_item (f
, x
, y
, &glyph
, &hpos
, &vpos
, &prop_idx
) != 0)
7073 /* If item is disabled, do nothing. */
7074 enabled_p
= AREF (f
->tool_bar_items
, prop_idx
+ TOOL_BAR_ITEM_ENABLED_P
);
7075 if (NILP (enabled_p
))
7078 if (button_event
->modifiers
& down_modifier
)
7080 /* Show item in pressed state. */
7081 show_mouse_face (dpyinfo
, DRAW_IMAGE_SUNKEN
);
7082 dpyinfo
->mouse_face_image_state
= DRAW_IMAGE_SUNKEN
;
7083 last_tool_bar_item
= prop_idx
;
7087 Lisp_Object key
, frame
;
7088 struct input_event event
;
7090 /* Show item in released state. */
7091 show_mouse_face (dpyinfo
, DRAW_IMAGE_RAISED
);
7092 dpyinfo
->mouse_face_image_state
= DRAW_IMAGE_RAISED
;
7094 key
= AREF (f
->tool_bar_items
, prop_idx
+ TOOL_BAR_ITEM_KEY
);
7096 XSETFRAME (frame
, f
);
7097 event
.kind
= TOOL_BAR_EVENT
;
7098 event
.frame_or_window
= frame
;
7100 kbd_buffer_store_event (&event
);
7102 event
.kind
= TOOL_BAR_EVENT
;
7103 event
.frame_or_window
= frame
;
7105 /* The keyboard buffer doesn't like the up modifier being set. */
7106 event
.modifiers
= button_event
->modifiers
& ~up_modifier
;
7107 kbd_buffer_store_event (&event
);
7108 last_tool_bar_item
= -1;
7113 /* Possibly highlight a tool-bar item on frame F when mouse moves to
7114 tool-bar window-relative coordinates X/Y. Called from
7115 note_mouse_highlight. */
7118 note_tool_bar_highlight (f
, x
, y
)
7122 Lisp_Object window
= f
->tool_bar_window
;
7123 struct window
*w
= XWINDOW (window
);
7124 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
7126 struct glyph
*glyph
;
7127 struct glyph_row
*row
;
7129 Lisp_Object enabled_p
;
7131 enum draw_glyphs_face draw
= DRAW_IMAGE_RAISED
;
7132 int mouse_down_p
, rc
;
7134 /* Function note_mouse_highlight is called with negative x(y
7135 values when mouse moves outside of the frame. */
7136 if (x
<= 0 || y
<= 0)
7138 clear_mouse_face (dpyinfo
);
7142 rc
= x_tool_bar_item (f
, x
, y
, &glyph
, &hpos
, &vpos
, &prop_idx
);
7145 /* Not on tool-bar item. */
7146 clear_mouse_face (dpyinfo
);
7150 /* On same tool-bar item as before. */
7153 clear_mouse_face (dpyinfo
);
7155 /* Mouse is down, but on different tool-bar item? */
7156 mouse_down_p
= (dpyinfo
->grabbed
7157 && f
== last_mouse_frame
7158 && FRAME_LIVE_P (f
));
7160 && last_tool_bar_item
!= prop_idx
)
7163 dpyinfo
->mouse_face_image_state
= DRAW_NORMAL_TEXT
;
7164 draw
= mouse_down_p
? DRAW_IMAGE_SUNKEN
: DRAW_IMAGE_RAISED
;
7166 /* If tool-bar item is not enabled, don't highlight it. */
7167 enabled_p
= AREF (f
->tool_bar_items
, prop_idx
+ TOOL_BAR_ITEM_ENABLED_P
);
7168 if (!NILP (enabled_p
))
7170 /* Compute the x-position of the glyph. In front and past the
7171 image is a space. We include this is the highlighted area. */
7172 row
= MATRIX_ROW (w
->current_matrix
, vpos
);
7173 for (i
= x
= 0; i
< hpos
; ++i
)
7174 x
+= row
->glyphs
[TEXT_AREA
][i
].pixel_width
;
7176 /* Record this as the current active region. */
7177 dpyinfo
->mouse_face_beg_col
= hpos
;
7178 dpyinfo
->mouse_face_beg_row
= vpos
;
7179 dpyinfo
->mouse_face_beg_x
= x
;
7180 dpyinfo
->mouse_face_beg_y
= row
->y
;
7181 dpyinfo
->mouse_face_past_end
= 0;
7183 dpyinfo
->mouse_face_end_col
= hpos
+ 1;
7184 dpyinfo
->mouse_face_end_row
= vpos
;
7185 dpyinfo
->mouse_face_end_x
= x
+ glyph
->pixel_width
;
7186 dpyinfo
->mouse_face_end_y
= row
->y
;
7187 dpyinfo
->mouse_face_window
= window
;
7188 dpyinfo
->mouse_face_face_id
= TOOL_BAR_FACE_ID
;
7190 /* Display it as active. */
7191 show_mouse_face (dpyinfo
, draw
);
7192 dpyinfo
->mouse_face_image_state
= draw
;
7197 /* Set help_echo to a help string.to display for this tool-bar item.
7198 w32_read_socket does the rest. */
7199 help_echo_object
= help_echo_window
= Qnil
;
7201 help_echo
= AREF (f
->tool_bar_items
, prop_idx
+ TOOL_BAR_ITEM_HELP
);
7202 if (NILP (help_echo
))
7203 help_echo
= AREF (f
->tool_bar_items
, prop_idx
+ TOOL_BAR_ITEM_CAPTION
);
7208 /* Find the glyph matrix position of buffer position CHARPOS in window
7209 *W. HPOS, *VPOS, *X, and *Y are set to the positions found. W's
7210 current glyphs must be up to date. If CHARPOS is above window
7211 start return (0, 0, 0, 0). If CHARPOS is after end of W, return end
7212 of last line in W. In the row containing CHARPOS, stop before glyphs
7213 having STOP as object. */
7215 #if 0 /* This is a version of fast_find_position that's more correct
7216 in the presence of hscrolling, for example. I didn't install
7217 it right away because the problem fixed is minor, it failed
7218 in 20.x as well, and I think it's too risky to install
7219 so near the release of 21.1. 2001-09-25 gerd. */
7222 fast_find_position (w
, charpos
, hpos
, vpos
, x
, y
, stop
)
7225 int *hpos
, *vpos
, *x
, *y
;
7228 struct glyph_row
*row
, *first
;
7229 struct glyph
*glyph
, *end
;
7230 int i
, past_end
= 0;
7232 first
= MATRIX_FIRST_TEXT_ROW (w
->current_matrix
);
7233 row
= row_containing_pos (w
, charpos
, first
, NULL
, 0);
7236 if (charpos
< MATRIX_ROW_START_CHARPOS (first
))
7238 *x
= *y
= *hpos
= *vpos
= 0;
7243 row
= MATRIX_ROW (w
->current_matrix
, XFASTINT (w
->window_end_vpos
));
7250 *vpos
= MATRIX_ROW_VPOS (row
, w
->current_matrix
);
7252 glyph
= row
->glyphs
[TEXT_AREA
];
7253 end
= glyph
+ row
->used
[TEXT_AREA
];
7255 /* Skip over glyphs not having an object at the start of the row.
7256 These are special glyphs like truncation marks on terminal
7258 if (row
->displays_text_p
)
7260 && INTEGERP (glyph
->object
)
7261 && !EQ (stop
, glyph
->object
)
7262 && glyph
->charpos
< 0)
7264 *x
+= glyph
->pixel_width
;
7269 && !INTEGERP (glyph
->object
)
7270 && !EQ (stop
, glyph
->object
)
7271 && (!BUFFERP (glyph
->object
)
7272 || glyph
->charpos
< charpos
))
7274 *x
+= glyph
->pixel_width
;
7278 *hpos
= glyph
- row
->glyphs
[TEXT_AREA
];
7285 fast_find_position (w
, pos
, hpos
, vpos
, x
, y
, stop
)
7288 int *hpos
, *vpos
, *x
, *y
;
7293 int maybe_next_line_p
= 0;
7294 int line_start_position
;
7295 int yb
= window_text_bottom_y (w
);
7296 struct glyph_row
*row
, *best_row
;
7297 int row_vpos
, best_row_vpos
;
7300 row
= best_row
= MATRIX_FIRST_TEXT_ROW (w
->current_matrix
);
7301 row_vpos
= best_row_vpos
= MATRIX_ROW_VPOS (row
, w
->current_matrix
);
7305 if (row
->used
[TEXT_AREA
])
7306 line_start_position
= row
->glyphs
[TEXT_AREA
]->charpos
;
7308 line_start_position
= 0;
7310 if (line_start_position
> pos
)
7312 /* If the position sought is the end of the buffer,
7313 don't include the blank lines at the bottom of the window. */
7314 else if (line_start_position
== pos
7315 && pos
== BUF_ZV (XBUFFER (w
->buffer
)))
7317 maybe_next_line_p
= 1;
7320 else if (line_start_position
> 0)
7323 best_row_vpos
= row_vpos
;
7326 if (row
->y
+ row
->height
>= yb
)
7333 /* Find the right column within BEST_ROW. */
7335 current_x
= best_row
->x
;
7336 for (i
= 0; i
< best_row
->used
[TEXT_AREA
]; i
++)
7338 struct glyph
*glyph
= best_row
->glyphs
[TEXT_AREA
] + i
;
7339 int charpos
= glyph
->charpos
;
7341 if (BUFFERP (glyph
->object
))
7346 *vpos
= best_row_vpos
;
7351 else if (charpos
> pos
)
7354 else if (EQ (glyph
->object
, stop
))
7359 current_x
+= glyph
->pixel_width
;
7362 /* If we're looking for the end of the buffer,
7363 and we didn't find it in the line we scanned,
7364 use the start of the following line. */
7365 if (maybe_next_line_p
)
7370 current_x
= best_row
->x
;
7373 *vpos
= best_row_vpos
;
7374 *hpos
= lastcol
+ 1;
7383 /* Find the position of the glyph for position POS in OBJECT in
7384 window W's current matrix, and return in *X/*Y the pixel
7385 coordinates, and return in *HPOS/*VPOS the column/row of the glyph.
7387 RIGHT_P non-zero means return the position of the right edge of the
7388 glyph, RIGHT_P zero means return the left edge position.
7390 If no glyph for POS exists in the matrix, return the position of
7391 the glyph with the next smaller position that is in the matrix, if
7392 RIGHT_P is zero. If RIGHT_P is non-zero, and no glyph for POS
7393 exists in the matrix, return the position of the glyph with the
7394 next larger position in OBJECT.
7396 Value is non-zero if a glyph was found. */
7399 fast_find_string_pos (w
, pos
, object
, hpos
, vpos
, x
, y
, right_p
)
7403 int *hpos
, *vpos
, *x
, *y
;
7406 int yb
= window_text_bottom_y (w
);
7407 struct glyph_row
*r
;
7408 struct glyph
*best_glyph
= NULL
;
7409 struct glyph_row
*best_row
= NULL
;
7412 for (r
= MATRIX_FIRST_TEXT_ROW (w
->current_matrix
);
7413 r
->enabled_p
&& r
->y
< yb
;
7416 struct glyph
*g
= r
->glyphs
[TEXT_AREA
];
7417 struct glyph
*e
= g
+ r
->used
[TEXT_AREA
];
7420 for (gx
= r
->x
; g
< e
; gx
+= g
->pixel_width
, ++g
)
7421 if (EQ (g
->object
, object
))
7423 if (g
->charpos
== pos
)
7430 else if (best_glyph
== NULL
7431 || ((abs (g
->charpos
- pos
)
7432 < abs (best_glyph
->charpos
- pos
))
7435 : g
->charpos
> pos
)))
7449 *hpos
= best_glyph
- best_row
->glyphs
[TEXT_AREA
];
7453 *x
+= best_glyph
->pixel_width
;
7458 *vpos
= best_row
- w
->current_matrix
->rows
;
7461 return best_glyph
!= NULL
;
7465 /* Display the active region described by mouse_face_*
7466 in its mouse-face if HL > 0, in its normal face if HL = 0. */
7469 show_mouse_face (dpyinfo
, draw
)
7470 struct w32_display_info
*dpyinfo
;
7471 enum draw_glyphs_face draw
;
7473 struct window
*w
= XWINDOW (dpyinfo
->mouse_face_window
);
7474 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
7476 if (/* If window is in the process of being destroyed, don't bother
7478 w
->current_matrix
!= NULL
7479 /* Don't update mouse highlight if hidden */
7480 && (draw
!= DRAW_MOUSE_FACE
|| !dpyinfo
->mouse_face_hidden
)
7481 /* Recognize when we are called to operate on rows that don't exist
7482 anymore. This can happen when a window is split. */
7483 && dpyinfo
->mouse_face_end_row
< w
->current_matrix
->nrows
)
7485 int phys_cursor_on_p
= w
->phys_cursor_on_p
;
7486 struct glyph_row
*row
, *first
, *last
;
7488 first
= MATRIX_ROW (w
->current_matrix
, dpyinfo
->mouse_face_beg_row
);
7489 last
= MATRIX_ROW (w
->current_matrix
, dpyinfo
->mouse_face_end_row
);
7491 for (row
= first
; row
<= last
&& row
->enabled_p
; ++row
)
7493 int start_hpos
, end_hpos
, start_x
;
7495 /* For all but the first row, the highlight starts at column 0. */
7498 start_hpos
= dpyinfo
->mouse_face_beg_col
;
7499 start_x
= dpyinfo
->mouse_face_beg_x
;
7508 end_hpos
= dpyinfo
->mouse_face_end_col
;
7510 end_hpos
= row
->used
[TEXT_AREA
];
7512 if (end_hpos
> start_hpos
)
7514 x_draw_glyphs (w
, start_x
, row
, TEXT_AREA
,
7515 start_hpos
, end_hpos
, draw
, 0);
7518 = draw
== DRAW_MOUSE_FACE
|| draw
== DRAW_IMAGE_RAISED
;
7522 /* When we've written over the cursor, arrange for it to
7523 be displayed again. */
7524 if (phys_cursor_on_p
&& !w
->phys_cursor_on_p
)
7525 x_display_cursor (w
, 1,
7526 w
->phys_cursor
.hpos
, w
->phys_cursor
.vpos
,
7527 w
->phys_cursor
.x
, w
->phys_cursor
.y
);
7530 #if 0 /* TODO: mouse cursor */
7531 /* Change the mouse cursor. */
7532 if (draw
== DRAW_NORMAL_TEXT
)
7533 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
7534 f
->output_data
.x
->text_cursor
);
7535 else if (draw
== DRAW_MOUSE_FACE
)
7536 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
7537 f
->output_data
.x
->cross_cursor
);
7539 XDefineCursor (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
7540 f
->output_data
.x
->nontext_cursor
);
7544 /* Clear out the mouse-highlighted active region.
7545 Redraw it un-highlighted first. */
7548 clear_mouse_face (dpyinfo
)
7549 struct w32_display_info
*dpyinfo
;
7553 if (! NILP (dpyinfo
->mouse_face_window
))
7555 show_mouse_face (dpyinfo
, DRAW_NORMAL_TEXT
);
7559 dpyinfo
->mouse_face_beg_row
= dpyinfo
->mouse_face_beg_col
= -1;
7560 dpyinfo
->mouse_face_end_row
= dpyinfo
->mouse_face_end_col
= -1;
7561 dpyinfo
->mouse_face_window
= Qnil
;
7562 dpyinfo
->mouse_face_overlay
= Qnil
;
7567 /* Clear any mouse-face on window W. This function is part of the
7568 redisplay interface, and is called from try_window_id and similar
7569 functions to ensure the mouse-highlight is off. */
7572 x_clear_mouse_face (w
)
7575 struct w32_display_info
*dpyinfo
7576 = FRAME_W32_DISPLAY_INFO (XFRAME (w
->frame
));
7580 XSETWINDOW (window
, w
);
7581 if (EQ (window
, dpyinfo
->mouse_face_window
))
7582 clear_mouse_face (dpyinfo
);
7587 /* Just discard the mouse face information for frame F, if any.
7588 This is used when the size of F is changed. */
7591 cancel_mouse_face (f
)
7595 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
7597 window
= dpyinfo
->mouse_face_window
;
7598 if (! NILP (window
) && XFRAME (XWINDOW (window
)->frame
) == f
)
7600 dpyinfo
->mouse_face_beg_row
= dpyinfo
->mouse_face_beg_col
= -1;
7601 dpyinfo
->mouse_face_end_row
= dpyinfo
->mouse_face_end_col
= -1;
7602 dpyinfo
->mouse_face_window
= Qnil
;
7606 static struct scroll_bar
*x_window_to_scroll_bar ();
7607 static void x_scroll_bar_report_motion ();
7608 static void x_check_fullscreen
P_ ((struct frame
*));
7609 static void x_check_fullscreen_move
P_ ((struct frame
*));
7610 static int glyph_rect
P_ ((struct frame
*f
, int, int, RECT
*));
7613 /* Try to determine frame pixel position and size of the glyph under
7614 frame pixel coordinates X/Y on frame F . Return the position and
7615 size in *RECT. Value is non-zero if we could compute these
7619 glyph_rect (f
, x
, y
, rect
)
7627 window
= window_from_coordinates (f
, x
, y
, &part
, 0);
7630 struct window
*w
= XWINDOW (window
);
7631 struct glyph_row
*r
= MATRIX_FIRST_TEXT_ROW (w
->current_matrix
);
7632 struct glyph_row
*end
= r
+ w
->current_matrix
->nrows
- 1;
7634 frame_to_window_pixel_xy (w
, &x
, &y
);
7636 for (; r
< end
&& r
->enabled_p
; ++r
)
7637 if (r
->y
<= y
&& r
->y
+ r
->height
> y
)
7639 /* Found the row at y. */
7640 struct glyph
*g
= r
->glyphs
[TEXT_AREA
];
7641 struct glyph
*end
= g
+ r
->used
[TEXT_AREA
];
7644 rect
->top
= WINDOW_TO_FRAME_PIXEL_Y (w
, r
->y
);
7645 rect
->bottom
= rect
->top
+ r
->height
;
7649 /* x is to the left of the first glyph in the row. */
7650 rect
->left
= XINT (w
->left
);
7651 rect
->right
= WINDOW_TO_FRAME_PIXEL_X (w
, r
->x
);
7655 for (gx
= r
->x
; g
< end
; gx
+= g
->pixel_width
, ++g
)
7656 if (gx
<= x
&& gx
+ g
->pixel_width
> x
)
7658 /* x is on a glyph. */
7659 rect
->left
= WINDOW_TO_FRAME_PIXEL_X (w
, gx
);
7660 rect
->right
= rect
->left
+ g
->pixel_width
;
7664 /* x is to the right of the last glyph in the row. */
7665 rect
->left
= WINDOW_TO_FRAME_PIXEL_X (w
, gx
);
7666 rect
->right
= XINT (w
->left
) + XINT (w
->width
);
7671 /* The y is not on any row. */
7675 /* Record the position of the mouse in last_mouse_glyph. */
7677 remember_mouse_glyph (f1
, gx
, gy
)
7681 if (!glyph_rect (f1
, gx
, gy
, &last_mouse_glyph
))
7683 int width
= FRAME_SMALLEST_CHAR_WIDTH (f1
);
7684 int height
= FRAME_SMALLEST_FONT_HEIGHT (f1
);
7686 /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
7687 round down even for negative values. */
7693 /* This was the original code from XTmouse_position, but it seems
7694 to give the position of the glyph diagonally next to the one
7695 the mouse is over. */
7696 gx
= (gx
+ width
- 1) / width
* width
;
7697 gy
= (gy
+ height
- 1) / height
* height
;
7699 gx
= gx
/ width
* width
;
7700 gy
= gy
/ height
* height
;
7703 last_mouse_glyph
.left
= gx
;
7704 last_mouse_glyph
.top
= gy
;
7705 last_mouse_glyph
.right
= gx
+ width
;
7706 last_mouse_glyph
.bottom
= gy
+ height
;
7710 /* Return the current position of the mouse.
7711 *fp should be a frame which indicates which display to ask about.
7713 If the mouse movement started in a scroll bar, set *fp, *bar_window,
7714 and *part to the frame, window, and scroll bar part that the mouse
7715 is over. Set *x and *y to the portion and whole of the mouse's
7716 position on the scroll bar.
7718 If the mouse movement started elsewhere, set *fp to the frame the
7719 mouse is on, *bar_window to nil, and *x and *y to the character cell
7722 Set *time to the server time-stamp for the time at which the mouse
7723 was at this position.
7725 Don't store anything if we don't have a valid set of values to report.
7727 This clears the mouse_moved flag, so we can wait for the next mouse
7731 w32_mouse_position (fp
, insist
, bar_window
, part
, x
, y
, time
)
7734 Lisp_Object
*bar_window
;
7735 enum scroll_bar_part
*part
;
7737 unsigned long *time
;
7743 if (! NILP (last_mouse_scroll_bar
) && insist
== 0)
7744 x_scroll_bar_report_motion (fp
, bar_window
, part
, x
, y
, time
);
7749 Lisp_Object frame
, tail
;
7751 /* Clear the mouse-moved flag for every frame on this display. */
7752 FOR_EACH_FRAME (tail
, frame
)
7753 XFRAME (frame
)->mouse_moved
= 0;
7755 last_mouse_scroll_bar
= Qnil
;
7759 /* Now we have a position on the root; find the innermost window
7760 containing the pointer. */
7762 if (FRAME_W32_DISPLAY_INFO (*fp
)->grabbed
&& last_mouse_frame
7763 && FRAME_LIVE_P (last_mouse_frame
))
7765 /* If mouse was grabbed on a frame, give coords for that frame
7766 even if the mouse is now outside it. */
7767 f1
= last_mouse_frame
;
7771 /* Is window under mouse one of our frames? */
7772 f1
= x_any_window_to_frame (FRAME_W32_DISPLAY_INFO (*fp
),
7773 WindowFromPoint (pt
));
7776 /* If not, is it one of our scroll bars? */
7779 struct scroll_bar
*bar
7780 = x_window_to_scroll_bar (WindowFromPoint (pt
));
7784 f1
= XFRAME (WINDOW_FRAME (XWINDOW (bar
->window
)));
7788 if (f1
== 0 && insist
> 0)
7789 f1
= SELECTED_FRAME ();
7793 /* Ok, we found a frame. Store all the values.
7794 last_mouse_glyph is a rectangle used to reduce the
7795 generation of mouse events. To not miss any motion
7796 events, we must divide the frame into rectangles of the
7797 size of the smallest character that could be displayed
7798 on it, i.e. into the same rectangles that matrices on
7799 the frame are divided into. */
7801 #if OLD_REDISPLAY_CODE
7802 int ignore1
, ignore2
;
7804 ScreenToClient (FRAME_W32_WINDOW (f1
), &pt
);
7806 pixel_to_glyph_coords (f1
, pt
.x
, pt
.y
, &ignore1
, &ignore2
,
7808 FRAME_W32_DISPLAY_INFO (f1
)->grabbed
7811 ScreenToClient (FRAME_W32_WINDOW (f1
), &pt
);
7812 remember_mouse_glyph (f1
, pt
.x
, pt
.y
);
7820 *time
= last_mouse_movement_time
;
7829 /* Scroll bar support. */
7831 /* Given a window ID, find the struct scroll_bar which manages it.
7832 This can be called in GC, so we have to make sure to strip off mark
7835 static struct scroll_bar
*
7836 x_window_to_scroll_bar (window_id
)
7841 for (tail
= Vframe_list
;
7842 XGCTYPE (tail
) == Lisp_Cons
;
7845 Lisp_Object frame
, bar
, condemned
;
7847 frame
= XCAR (tail
);
7848 /* All elements of Vframe_list should be frames. */
7849 if (! GC_FRAMEP (frame
))
7852 /* Scan this frame's scroll bar list for a scroll bar with the
7854 condemned
= FRAME_CONDEMNED_SCROLL_BARS (XFRAME (frame
));
7855 for (bar
= FRAME_SCROLL_BARS (XFRAME (frame
));
7856 /* This trick allows us to search both the ordinary and
7857 condemned scroll bar lists with one loop. */
7858 ! GC_NILP (bar
) || (bar
= condemned
,
7861 bar
= XSCROLL_BAR (bar
)->next
)
7862 if (SCROLL_BAR_W32_WINDOW (XSCROLL_BAR (bar
)) == window_id
)
7863 return XSCROLL_BAR (bar
);
7871 /* Set the thumb size and position of scroll bar BAR. We are currently
7872 displaying PORTION out of a whole WHOLE, and our position POSITION. */
7875 w32_set_scroll_bar_thumb (bar
, portion
, position
, whole
)
7876 struct scroll_bar
*bar
;
7877 int portion
, position
, whole
;
7879 Window w
= SCROLL_BAR_W32_WINDOW (bar
);
7880 double range
= VERTICAL_SCROLL_BAR_TOP_RANGE (f
, XINT (bar
->height
));
7881 int sb_page
, sb_pos
;
7882 BOOL draggingp
= !NILP (bar
->dragging
) ? TRUE
: FALSE
;
7886 /* Position scroll bar at rock bottom if the bottom of the
7887 buffer is visible. This avoids shinking the thumb away
7888 to nothing if it is held at the bottom of the buffer. */
7889 if (position
+ portion
>= whole
)
7891 sb_page
= range
* (whole
- position
) / whole
7892 + VERTICAL_SCROLL_BAR_MIN_HANDLE
;
7896 sb_page
= portion
* range
/ whole
+ VERTICAL_SCROLL_BAR_MIN_HANDLE
;
7897 sb_pos
= position
* range
/ whole
;
7907 if (pfnSetScrollInfo
)
7911 si
.cbSize
= sizeof (si
);
7912 /* Only update page size if currently dragging, to reduce
7915 si
.fMask
= SIF_PAGE
;
7917 si
.fMask
= SIF_PAGE
| SIF_POS
;
7921 pfnSetScrollInfo (w
, SB_CTL
, &si
, !draggingp
);
7924 SetScrollPos (w
, SB_CTL
, sb_pos
, !draggingp
);
7930 /************************************************************************
7931 Scroll bars, general
7932 ************************************************************************/
7935 my_create_scrollbar (f
, bar
)
7937 struct scroll_bar
* bar
;
7939 return (HWND
) SendMessage (FRAME_W32_WINDOW (f
),
7940 WM_EMACS_CREATESCROLLBAR
, (WPARAM
) f
,
7944 /*#define ATTACH_THREADS*/
7947 my_show_window (FRAME_PTR f
, HWND hwnd
, int how
)
7949 #ifndef ATTACH_THREADS
7950 return SendMessage (FRAME_W32_WINDOW (f
), WM_EMACS_SHOWWINDOW
,
7951 (WPARAM
) hwnd
, (LPARAM
) how
);
7953 return ShowWindow (hwnd
, how
);
7958 my_set_window_pos (HWND hwnd
, HWND hwndAfter
,
7959 int x
, int y
, int cx
, int cy
, UINT flags
)
7961 #ifndef ATTACH_THREADS
7963 pos
.hwndInsertAfter
= hwndAfter
;
7969 SendMessage (hwnd
, WM_EMACS_SETWINDOWPOS
, (WPARAM
) &pos
, 0);
7971 SetWindowPos (hwnd
, hwndAfter
, x
, y
, cx
, cy
, flags
);
7976 my_set_focus (f
, hwnd
)
7980 SendMessage (FRAME_W32_WINDOW (f
), WM_EMACS_SETFOCUS
,
7985 my_set_foreground_window (hwnd
)
7988 SendMessage (hwnd
, WM_EMACS_SETFOREGROUND
, (WPARAM
) hwnd
, 0);
7992 my_destroy_window (f
, hwnd
)
7996 SendMessage (FRAME_W32_WINDOW (f
), WM_EMACS_DESTROYWINDOW
,
8000 /* Create a scroll bar and return the scroll bar vector for it. W is
8001 the Emacs window on which to create the scroll bar. TOP, LEFT,
8002 WIDTH and HEIGHT are.the pixel coordinates and dimensions of the
8005 static struct scroll_bar
*
8006 x_scroll_bar_create (w
, top
, left
, width
, height
)
8008 int top
, left
, width
, height
;
8010 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
8012 struct scroll_bar
*bar
8013 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE
), Qnil
));
8017 XSETWINDOW (bar
->window
, w
);
8018 XSETINT (bar
->top
, top
);
8019 XSETINT (bar
->left
, left
);
8020 XSETINT (bar
->width
, width
);
8021 XSETINT (bar
->height
, height
);
8022 XSETINT (bar
->start
, 0);
8023 XSETINT (bar
->end
, 0);
8024 bar
->dragging
= Qnil
;
8026 /* Requires geometry to be set before call to create the real window */
8028 hwnd
= my_create_scrollbar (f
, bar
);
8030 if (pfnSetScrollInfo
)
8034 si
.cbSize
= sizeof (si
);
8037 si
.nMax
= VERTICAL_SCROLL_BAR_TOP_RANGE (f
, height
)
8038 + VERTICAL_SCROLL_BAR_MIN_HANDLE
;
8042 pfnSetScrollInfo (hwnd
, SB_CTL
, &si
, FALSE
);
8046 SetScrollRange (hwnd
, SB_CTL
, 0,
8047 VERTICAL_SCROLL_BAR_TOP_RANGE (f
, height
), FALSE
);
8048 SetScrollPos (hwnd
, SB_CTL
, 0, FALSE
);
8051 SET_SCROLL_BAR_W32_WINDOW (bar
, hwnd
);
8053 /* Add bar to its frame's list of scroll bars. */
8054 bar
->next
= FRAME_SCROLL_BARS (f
);
8056 XSETVECTOR (FRAME_SCROLL_BARS (f
), bar
);
8057 if (! NILP (bar
->next
))
8058 XSETVECTOR (XSCROLL_BAR (bar
->next
)->prev
, bar
);
8066 /* Destroy scroll bar BAR, and set its Emacs window's scroll bar to
8070 x_scroll_bar_remove (bar
)
8071 struct scroll_bar
*bar
;
8073 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (bar
->window
)));
8077 /* Destroy the window. */
8078 my_destroy_window (f
, SCROLL_BAR_W32_WINDOW (bar
));
8080 /* Disassociate this scroll bar from its window. */
8081 XWINDOW (bar
->window
)->vertical_scroll_bar
= Qnil
;
8086 /* Set the handle of the vertical scroll bar for WINDOW to indicate
8087 that we are displaying PORTION characters out of a total of WHOLE
8088 characters, starting at POSITION. If WINDOW has no scroll bar,
8091 w32_set_vertical_scroll_bar (w
, portion
, whole
, position
)
8093 int portion
, whole
, position
;
8095 struct frame
*f
= XFRAME (w
->frame
);
8096 struct scroll_bar
*bar
;
8097 int top
, height
, left
, sb_left
, width
, sb_width
;
8098 int window_x
, window_y
, window_width
, window_height
;
8100 /* Get window dimensions. */
8101 window_box (w
, -1, &window_x
, &window_y
, &window_width
, &window_height
);
8103 width
= FRAME_SCROLL_BAR_COLS (f
) * CANON_X_UNIT (f
);
8104 height
= window_height
;
8106 /* Compute the left edge of the scroll bar area. */
8107 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
8108 left
= XINT (w
->left
) + XINT (w
->width
) - FRAME_SCROLL_BAR_COLS (f
);
8110 left
= XFASTINT (w
->left
);
8111 left
*= CANON_X_UNIT (f
);
8112 left
+= FRAME_INTERNAL_BORDER_WIDTH (f
);
8114 /* Compute the width of the scroll bar which might be less than
8115 the width of the area reserved for the scroll bar. */
8116 if (FRAME_SCROLL_BAR_PIXEL_WIDTH (f
) > 0)
8117 sb_width
= FRAME_SCROLL_BAR_PIXEL_WIDTH (f
);
8121 /* Compute the left edge of the scroll bar. */
8122 if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f
))
8123 sb_left
= left
+ width
- sb_width
- (width
- sb_width
) / 2;
8125 sb_left
= left
+ (width
- sb_width
) / 2;
8127 /* Does the scroll bar exist yet? */
8128 if (NILP (w
->vertical_scroll_bar
))
8132 if (width
> 0 && height
> 0)
8134 hdc
= get_frame_dc (f
);
8135 w32_clear_area (f
, hdc
, left
, top
, width
, height
);
8136 release_frame_dc (f
, hdc
);
8140 bar
= x_scroll_bar_create (w
, top
, sb_left
, sb_width
, height
);
8144 /* It may just need to be moved and resized. */
8147 bar
= XSCROLL_BAR (w
->vertical_scroll_bar
);
8148 hwnd
= SCROLL_BAR_W32_WINDOW (bar
);
8150 /* If already correctly positioned, do nothing. */
8151 if ( XINT (bar
->left
) == sb_left
8152 && XINT (bar
->top
) == top
8153 && XINT (bar
->width
) == sb_width
8154 && XINT (bar
->height
) == height
)
8156 /* Redraw after clear_frame. */
8157 if (!my_show_window (f
, hwnd
, SW_NORMAL
))
8158 InvalidateRect (hwnd
, NULL
, FALSE
);
8164 if (width
&& height
)
8166 hdc
= get_frame_dc (f
);
8167 /* Since Windows scroll bars are smaller than the space reserved
8168 for them on the frame, we have to clear "under" them. */
8169 w32_clear_area (f
, hdc
,
8174 release_frame_dc (f
, hdc
);
8176 /* Make sure scroll bar is "visible" before moving, to ensure the
8177 area of the parent window now exposed will be refreshed. */
8178 my_show_window (f
, hwnd
, SW_HIDE
);
8179 MoveWindow (hwnd
, sb_left
+ VERTICAL_SCROLL_BAR_WIDTH_TRIM
,
8180 top
, sb_width
- VERTICAL_SCROLL_BAR_WIDTH_TRIM
* 2,
8181 max (height
, 1), TRUE
);
8182 if (pfnSetScrollInfo
)
8186 si
.cbSize
= sizeof (si
);
8187 si
.fMask
= SIF_RANGE
;
8189 si
.nMax
= VERTICAL_SCROLL_BAR_TOP_RANGE (f
, height
)
8190 + VERTICAL_SCROLL_BAR_MIN_HANDLE
;
8192 pfnSetScrollInfo (hwnd
, SB_CTL
, &si
, FALSE
);
8195 SetScrollRange (hwnd
, SB_CTL
, 0,
8196 VERTICAL_SCROLL_BAR_TOP_RANGE (f
, height
), FALSE
);
8197 my_show_window (f
, hwnd
, SW_NORMAL
);
8198 /* InvalidateRect (w, NULL, FALSE); */
8200 /* Remember new settings. */
8201 XSETINT (bar
->left
, sb_left
);
8202 XSETINT (bar
->top
, top
);
8203 XSETINT (bar
->width
, sb_width
);
8204 XSETINT (bar
->height
, height
);
8209 w32_set_scroll_bar_thumb (bar
, portion
, position
, whole
);
8211 XSETVECTOR (w
->vertical_scroll_bar
, bar
);
8215 /* The following three hooks are used when we're doing a thorough
8216 redisplay of the frame. We don't explicitly know which scroll bars
8217 are going to be deleted, because keeping track of when windows go
8218 away is a real pain - "Can you say set-window-configuration, boys
8219 and girls?" Instead, we just assert at the beginning of redisplay
8220 that *all* scroll bars are to be removed, and then save a scroll bar
8221 from the fiery pit when we actually redisplay its window. */
8223 /* Arrange for all scroll bars on FRAME to be removed at the next call
8224 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
8225 `*redeem_scroll_bar_hook' is applied to its window before the judgment. */
8228 w32_condemn_scroll_bars (frame
)
8231 /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */
8232 while (! NILP (FRAME_SCROLL_BARS (frame
)))
8235 bar
= FRAME_SCROLL_BARS (frame
);
8236 FRAME_SCROLL_BARS (frame
) = XSCROLL_BAR (bar
)->next
;
8237 XSCROLL_BAR (bar
)->next
= FRAME_CONDEMNED_SCROLL_BARS (frame
);
8238 XSCROLL_BAR (bar
)->prev
= Qnil
;
8239 if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame
)))
8240 XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame
))->prev
= bar
;
8241 FRAME_CONDEMNED_SCROLL_BARS (frame
) = bar
;
8246 /* Un-mark WINDOW's scroll bar for deletion in this judgment cycle.
8247 Note that WINDOW isn't necessarily condemned at all. */
8250 w32_redeem_scroll_bar (window
)
8251 struct window
*window
;
8253 struct scroll_bar
*bar
;
8256 /* We can't redeem this window's scroll bar if it doesn't have one. */
8257 if (NILP (window
->vertical_scroll_bar
))
8260 bar
= XSCROLL_BAR (window
->vertical_scroll_bar
);
8262 /* Unlink it from the condemned list. */
8263 f
= XFRAME (WINDOW_FRAME (window
));
8264 if (NILP (bar
->prev
))
8266 /* If the prev pointer is nil, it must be the first in one of
8268 if (EQ (FRAME_SCROLL_BARS (f
), window
->vertical_scroll_bar
))
8269 /* It's not condemned. Everything's fine. */
8271 else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f
),
8272 window
->vertical_scroll_bar
))
8273 FRAME_CONDEMNED_SCROLL_BARS (f
) = bar
->next
;
8275 /* If its prev pointer is nil, it must be at the front of
8276 one or the other! */
8280 XSCROLL_BAR (bar
->prev
)->next
= bar
->next
;
8282 if (! NILP (bar
->next
))
8283 XSCROLL_BAR (bar
->next
)->prev
= bar
->prev
;
8285 bar
->next
= FRAME_SCROLL_BARS (f
);
8287 XSETVECTOR (FRAME_SCROLL_BARS (f
), bar
);
8288 if (! NILP (bar
->next
))
8289 XSETVECTOR (XSCROLL_BAR (bar
->next
)->prev
, bar
);
8292 /* Remove all scroll bars on FRAME that haven't been saved since the
8293 last call to `*condemn_scroll_bars_hook'. */
8296 w32_judge_scroll_bars (f
)
8299 Lisp_Object bar
, next
;
8301 bar
= FRAME_CONDEMNED_SCROLL_BARS (f
);
8303 /* Clear out the condemned list now so we won't try to process any
8304 more events on the hapless scroll bars. */
8305 FRAME_CONDEMNED_SCROLL_BARS (f
) = Qnil
;
8307 for (; ! NILP (bar
); bar
= next
)
8309 struct scroll_bar
*b
= XSCROLL_BAR (bar
);
8311 x_scroll_bar_remove (b
);
8314 b
->next
= b
->prev
= Qnil
;
8317 /* Now there should be no references to the condemned scroll bars,
8318 and they should get garbage-collected. */
8321 /* Handle a mouse click on the scroll bar BAR. If *EMACS_EVENT's kind
8322 is set to something other than NO_EVENT, it is enqueued.
8324 This may be called from a signal handler, so we have to ignore GC
8328 w32_scroll_bar_handle_click (bar
, msg
, emacs_event
)
8329 struct scroll_bar
*bar
;
8331 struct input_event
*emacs_event
;
8333 if (! GC_WINDOWP (bar
->window
))
8336 emacs_event
->kind
= W32_SCROLL_BAR_CLICK_EVENT
;
8337 emacs_event
->code
= 0;
8338 /* not really meaningful to distinguish up/down */
8339 emacs_event
->modifiers
= msg
->dwModifiers
;
8340 emacs_event
->frame_or_window
= bar
->window
;
8341 emacs_event
->arg
= Qnil
;
8342 emacs_event
->timestamp
= msg
->msg
.time
;
8345 int top_range
= VERTICAL_SCROLL_BAR_TOP_RANGE (f
, XINT (bar
->height
));
8347 int dragging
= !NILP (bar
->dragging
);
8349 if (pfnGetScrollInfo
)
8353 si
.cbSize
= sizeof (si
);
8356 pfnGetScrollInfo ((HWND
) msg
->msg
.lParam
, SB_CTL
, &si
);
8360 y
= GetScrollPos ((HWND
) msg
->msg
.lParam
, SB_CTL
);
8362 bar
->dragging
= Qnil
;
8365 last_mouse_scroll_bar_pos
= msg
->msg
.wParam
;
8367 switch (LOWORD (msg
->msg
.wParam
))
8370 emacs_event
->part
= scroll_bar_down_arrow
;
8373 emacs_event
->part
= scroll_bar_up_arrow
;
8376 emacs_event
->part
= scroll_bar_above_handle
;
8379 emacs_event
->part
= scroll_bar_below_handle
;
8382 emacs_event
->part
= scroll_bar_handle
;
8386 emacs_event
->part
= scroll_bar_handle
;
8390 case SB_THUMBPOSITION
:
8391 if (VERTICAL_SCROLL_BAR_TOP_RANGE (f
, XINT (bar
->height
)) <= 0xffff)
8392 y
= HIWORD (msg
->msg
.wParam
);
8394 emacs_event
->part
= scroll_bar_handle
;
8396 /* "Silently" update current position. */
8397 if (pfnSetScrollInfo
)
8401 si
.cbSize
= sizeof (si
);
8404 /* Remember apparent position (we actually lag behind the real
8405 position, so don't set that directly. */
8406 last_scroll_bar_drag_pos
= y
;
8408 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar
), SB_CTL
, &si
, FALSE
);
8411 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar
), SB_CTL
, y
, FALSE
);
8414 /* If this is the end of a drag sequence, then reset the scroll
8415 handle size to normal and do a final redraw. Otherwise do
8419 if (pfnSetScrollInfo
)
8422 int start
= XINT (bar
->start
);
8423 int end
= XINT (bar
->end
);
8425 si
.cbSize
= sizeof (si
);
8426 si
.fMask
= SIF_PAGE
| SIF_POS
;
8427 si
.nPage
= end
- start
+ VERTICAL_SCROLL_BAR_MIN_HANDLE
;
8428 si
.nPos
= last_scroll_bar_drag_pos
;
8429 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar
), SB_CTL
, &si
, TRUE
);
8432 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar
), SB_CTL
, y
, TRUE
);
8436 emacs_event
->kind
= NO_EVENT
;
8440 XSETINT (emacs_event
->x
, y
);
8441 XSETINT (emacs_event
->y
, top_range
);
8447 /* Return information to the user about the current position of the mouse
8448 on the scroll bar. */
8451 x_scroll_bar_report_motion (fp
, bar_window
, part
, x
, y
, time
)
8453 Lisp_Object
*bar_window
;
8454 enum scroll_bar_part
*part
;
8456 unsigned long *time
;
8458 struct scroll_bar
*bar
= XSCROLL_BAR (last_mouse_scroll_bar
);
8459 Window w
= SCROLL_BAR_W32_WINDOW (bar
);
8460 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (bar
->window
)));
8462 int top_range
= VERTICAL_SCROLL_BAR_TOP_RANGE (f
, XINT (bar
->height
));
8467 *bar_window
= bar
->window
;
8469 if (pfnGetScrollInfo
)
8473 si
.cbSize
= sizeof (si
);
8474 si
.fMask
= SIF_POS
| SIF_PAGE
| SIF_RANGE
;
8476 pfnGetScrollInfo (w
, SB_CTL
, &si
);
8478 top_range
= si
.nMax
- si
.nPage
+ 1;
8481 pos
= GetScrollPos (w
, SB_CTL
);
8483 switch (LOWORD (last_mouse_scroll_bar_pos
))
8485 case SB_THUMBPOSITION
:
8487 *part
= scroll_bar_handle
;
8488 if (VERTICAL_SCROLL_BAR_TOP_RANGE (f
, XINT (bar
->height
)) <= 0xffff)
8489 pos
= HIWORD (last_mouse_scroll_bar_pos
);
8492 *part
= scroll_bar_handle
;
8496 *part
= scroll_bar_handle
;
8501 XSETINT (*y
, top_range
);
8504 last_mouse_scroll_bar
= Qnil
;
8506 *time
= last_mouse_movement_time
;
8512 /* The screen has been cleared so we may have changed foreground or
8513 background colors, and the scroll bars may need to be redrawn.
8514 Clear out the scroll bars, and ask for expose events, so we can
8518 x_scroll_bar_clear (f
)
8523 /* We can have scroll bars even if this is 0,
8524 if we just turned off scroll bar mode.
8525 But in that case we should not clear them. */
8526 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
8527 for (bar
= FRAME_SCROLL_BARS (f
); VECTORP (bar
);
8528 bar
= XSCROLL_BAR (bar
)->next
)
8530 HWND window
= SCROLL_BAR_W32_WINDOW (XSCROLL_BAR (bar
));
8531 HDC hdc
= GetDC (window
);
8534 /* Hide scroll bar until ready to repaint. x_scroll_bar_move
8535 arranges to refresh the scroll bar if hidden. */
8536 my_show_window (f
, window
, SW_HIDE
);
8538 GetClientRect (window
, &rect
);
8539 select_palette (f
, hdc
);
8540 w32_clear_rect (f
, hdc
, &rect
);
8541 deselect_palette (f
, hdc
);
8543 ReleaseDC (window
, hdc
);
8548 /* The main W32 event-reading loop - w32_read_socket. */
8550 /* Record the last 100 characters stored
8551 to help debug the loss-of-chars-during-GC problem. */
8553 static int temp_index
;
8554 static short temp_buffer
[100];
8557 /* Read events coming from the W32 shell.
8558 This routine is called by the SIGIO handler.
8559 We return as soon as there are no more events to be read.
8561 Events representing keys are stored in buffer BUFP,
8562 which can hold up to NUMCHARS characters.
8563 We return the number of characters stored into the buffer,
8564 thus pretending to be `read'.
8566 EXPECTED is nonzero if the caller knows input is available.
8568 Some of these messages are reposted back to the message queue since the
8569 system calls the windows proc directly in a context where we cannot return
8570 the data nor can we guarantee the state we are in. So if we dispatch them
8571 we will get into an infinite loop. To prevent this from ever happening we
8572 will set a variable to indicate we are in the read_socket call and indicate
8573 which message we are processing since the windows proc gets called
8574 recursively with different messages by the system.
8578 w32_read_socket (sd
, bufp
, numchars
, expected
)
8580 /* register */ struct input_event
*bufp
;
8581 /* register */ int numchars
;
8585 int check_visibility
= 0;
8588 struct w32_display_info
*dpyinfo
= &one_w32_display_info
;
8590 if (interrupt_input_blocked
)
8592 interrupt_input_pending
= 1;
8596 interrupt_input_pending
= 0;
8599 /* So people can tell when we have read the available input. */
8600 input_signal_count
++;
8603 abort (); /* Don't think this happens. */
8605 /* TODO: tool-bars, ghostscript integration, mouse
8607 while (get_next_msg (&msg
, FALSE
))
8609 switch (msg
.msg
.message
)
8612 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8616 if (msg
.rect
.right
== msg
.rect
.left
||
8617 msg
.rect
.bottom
== msg
.rect
.top
)
8619 /* We may get paint messages even though the client
8620 area is clipped - these are not expose events. */
8621 DebPrint (("clipped frame %p (%s) got WM_PAINT - ignored\n", f
,
8622 XSTRING (f
->name
)->data
));
8624 else if (f
->async_visible
!= 1)
8626 /* Definitely not obscured, so mark as visible. */
8627 f
->async_visible
= 1;
8628 f
->async_iconified
= 0;
8629 SET_FRAME_GARBAGED (f
);
8630 DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f
,
8631 XSTRING (f
->name
)->data
));
8633 /* WM_PAINT serves as MapNotify as well, so report
8634 visibility changes properly. */
8637 bufp
->kind
= DEICONIFY_EVENT
;
8638 XSETFRAME (bufp
->frame_or_window
, f
);
8644 else if (! NILP (Vframe_list
)
8645 && ! NILP (XCDR (Vframe_list
)))
8646 /* Force a redisplay sooner or later to update the
8647 frame titles in case this is the second frame. */
8648 record_asynch_buffer_change ();
8652 HDC hdc
= get_frame_dc (f
);
8654 /* Erase background again for safety. */
8655 w32_clear_rect (f
, hdc
, &msg
.rect
);
8656 release_frame_dc (f
, hdc
);
8660 msg
.rect
.right
- msg
.rect
.left
,
8661 msg
.rect
.bottom
- msg
.rect
.top
);
8666 case WM_INPUTLANGCHANGE
:
8667 /* Generate a language change event. */
8668 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8675 bufp
->kind
= LANGUAGE_CHANGE_EVENT
;
8676 XSETFRAME (bufp
->frame_or_window
, f
);
8678 bufp
->code
= msg
.msg
.wParam
;
8679 bufp
->modifiers
= msg
.msg
.lParam
& 0xffff;
8688 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8690 if (f
&& !f
->iconified
)
8692 if (!dpyinfo
->mouse_face_hidden
&& INTEGERP (Vmouse_highlight
))
8694 dpyinfo
->mouse_face_hidden
= 1;
8695 clear_mouse_face (dpyinfo
);
8698 if (temp_index
== sizeof temp_buffer
/ sizeof (short))
8700 temp_buffer
[temp_index
++] = msg
.msg
.wParam
;
8701 bufp
->kind
= NON_ASCII_KEYSTROKE_EVENT
;
8702 bufp
->code
= msg
.msg
.wParam
;
8703 bufp
->modifiers
= msg
.dwModifiers
;
8704 XSETFRAME (bufp
->frame_or_window
, f
);
8706 bufp
->timestamp
= msg
.msg
.time
;
8715 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8717 if (f
&& !f
->iconified
)
8719 if (!dpyinfo
->mouse_face_hidden
&& INTEGERP (Vmouse_highlight
))
8721 dpyinfo
->mouse_face_hidden
= 1;
8722 clear_mouse_face (dpyinfo
);
8725 if (temp_index
== sizeof temp_buffer
/ sizeof (short))
8727 temp_buffer
[temp_index
++] = msg
.msg
.wParam
;
8728 bufp
->kind
= ASCII_KEYSTROKE_EVENT
;
8729 bufp
->code
= msg
.msg
.wParam
;
8730 bufp
->modifiers
= msg
.dwModifiers
;
8731 XSETFRAME (bufp
->frame_or_window
, f
);
8733 bufp
->timestamp
= msg
.msg
.time
;
8741 previous_help_echo
= help_echo
;
8742 help_echo_object
= help_echo_window
= Qnil
;
8745 if (dpyinfo
->grabbed
&& last_mouse_frame
8746 && FRAME_LIVE_P (last_mouse_frame
))
8747 f
= last_mouse_frame
;
8749 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8751 if (dpyinfo
->mouse_face_hidden
)
8753 dpyinfo
->mouse_face_hidden
= 0;
8754 clear_mouse_face (dpyinfo
);
8758 note_mouse_movement (f
, &msg
.msg
);
8761 /* If we move outside the frame, then we're
8762 certainly no longer on any text in the frame. */
8763 clear_mouse_face (dpyinfo
);
8766 /* If the contents of the global variable help_echo
8767 has changed, generate a HELP_EVENT. */
8768 if (help_echo
!= previous_help_echo
)
8774 XSETFRAME (frame
, f
);
8778 any_help_event_p
= 1;
8779 n
= gen_help_event (bufp
, numchars
, help_echo
, frame
,
8780 help_echo_window
, help_echo_object
,
8782 bufp
+= n
, count
+= n
, numchars
-= n
;
8786 case WM_LBUTTONDOWN
:
8788 case WM_MBUTTONDOWN
:
8790 case WM_RBUTTONDOWN
:
8792 case WM_XBUTTONDOWN
:
8795 /* If we decide we want to generate an event to be seen
8796 by the rest of Emacs, we put it here. */
8797 struct input_event emacs_event
;
8802 emacs_event
.kind
= NO_EVENT
;
8804 if (dpyinfo
->grabbed
&& last_mouse_frame
8805 && FRAME_LIVE_P (last_mouse_frame
))
8806 f
= last_mouse_frame
;
8808 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8812 construct_mouse_click (&emacs_event
, &msg
, f
);
8814 /* Is this in the tool-bar? */
8815 if (WINDOWP (f
->tool_bar_window
)
8816 && XFASTINT (XWINDOW (f
->tool_bar_window
)->height
))
8821 x
= XFASTINT (emacs_event
.x
);
8822 y
= XFASTINT (emacs_event
.y
);
8825 window
= window_from_coordinates (f
, x
, y
, &p
, 1);
8827 if (EQ (window
, f
->tool_bar_window
))
8829 w32_handle_tool_bar_click (f
, &emacs_event
);
8835 if (!dpyinfo
->w32_focus_frame
8836 || f
== dpyinfo
->w32_focus_frame
8839 construct_mouse_click (bufp
, &msg
, f
);
8846 parse_button (msg
.msg
.message
, HIWORD (msg
.msg
.wParam
),
8851 dpyinfo
->grabbed
&= ~ (1 << button
);
8855 dpyinfo
->grabbed
|= (1 << button
);
8856 last_mouse_frame
= f
;
8857 /* Ignore any mouse motion that happened
8858 before this event; any subsequent mouse-movement
8859 Emacs events should reflect only motion after
8865 last_tool_bar_item
= -1;
8871 if (dpyinfo
->grabbed
&& last_mouse_frame
8872 && FRAME_LIVE_P (last_mouse_frame
))
8873 f
= last_mouse_frame
;
8875 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8879 if ((!dpyinfo
->w32_focus_frame
8880 || f
== dpyinfo
->w32_focus_frame
)
8883 construct_mouse_wheel (bufp
, &msg
, f
);
8892 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8896 construct_drag_n_drop (bufp
, &msg
, f
);
8905 struct scroll_bar
*bar
=
8906 x_window_to_scroll_bar ((HWND
)msg
.msg
.lParam
);
8908 if (bar
&& numchars
>= 1)
8910 if (w32_scroll_bar_handle_click (bar
, &msg
, bufp
))
8920 case WM_WINDOWPOSCHANGED
:
8921 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8924 x_check_fullscreen_move(f
);
8925 if (f
->output_data
.w32
->want_fullscreen
& FULLSCREEN_WAIT
)
8926 f
->output_data
.w32
->want_fullscreen
&=
8927 ~(FULLSCREEN_WAIT
|FULLSCREEN_BOTH
);
8929 check_visibility
= 1;
8933 case WM_ACTIVATEAPP
:
8934 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8936 x_check_fullscreen (f
);
8937 check_visibility
= 1;
8941 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8943 if (f
&& !f
->async_iconified
)
8947 x_real_positions (f
, &x
, &y
);
8948 f
->output_data
.w32
->left_pos
= x
;
8949 f
->output_data
.w32
->top_pos
= y
;
8952 check_visibility
= 1;
8956 /* wParam non-zero means Window is about to be shown, 0 means
8957 about to be hidden. */
8958 /* Redo the mouse-highlight after the tooltip has gone. */
8959 if (!msg
.msg
.wParam
&& msg
.msg
.hwnd
== tip_window
)
8962 redo_mouse_highlight ();
8965 /* If window has been obscured or exposed by another window
8966 being maximised or minimised/restored, then recheck
8967 visibility of all frames. Direct changes to our own
8968 windows get handled by WM_SIZE. */
8970 if (msg
.msg
.lParam
!= 0)
8971 check_visibility
= 1;
8974 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8975 f
->async_visible
= msg
.msg
.wParam
;
8979 check_visibility
= 1;
8983 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
8985 /* Inform lisp of whether frame has been iconified etc. */
8988 switch (msg
.msg
.wParam
)
8990 case SIZE_MINIMIZED
:
8991 f
->async_visible
= 0;
8992 f
->async_iconified
= 1;
8994 bufp
->kind
= ICONIFY_EVENT
;
8995 XSETFRAME (bufp
->frame_or_window
, f
);
9002 case SIZE_MAXIMIZED
:
9004 f
->async_visible
= 1;
9005 f
->async_iconified
= 0;
9007 /* wait_reading_process_input will notice this and update
9008 the frame's display structures. */
9009 SET_FRAME_GARBAGED (f
);
9015 /* Reset top and left positions of the Window
9016 here since Windows sends a WM_MOVE message
9017 BEFORE telling us the Window is minimized
9018 when the Window is iconified, with 3000,3000
9020 x_real_positions (f
, &x
, &y
);
9021 f
->output_data
.w32
->left_pos
= x
;
9022 f
->output_data
.w32
->top_pos
= y
;
9024 bufp
->kind
= DEICONIFY_EVENT
;
9025 XSETFRAME (bufp
->frame_or_window
, f
);
9031 else if (! NILP (Vframe_list
)
9032 && ! NILP (XCDR (Vframe_list
)))
9033 /* Force a redisplay sooner or later
9034 to update the frame titles
9035 in case this is the second frame. */
9036 record_asynch_buffer_change ();
9041 if (f
&& !f
->async_iconified
&& msg
.msg
.wParam
!= SIZE_MINIMIZED
)
9049 GetClientRect (msg
.msg
.hwnd
, &rect
);
9051 height
= rect
.bottom
- rect
.top
;
9052 width
= rect
.right
- rect
.left
;
9054 rows
= PIXEL_TO_CHAR_HEIGHT (f
, height
);
9055 columns
= PIXEL_TO_CHAR_WIDTH (f
, width
);
9057 /* TODO: Clip size to the screen dimensions. */
9059 /* Even if the number of character rows and columns has
9060 not changed, the font size may have changed, so we need
9061 to check the pixel dimensions as well. */
9063 if (columns
!= f
->width
9064 || rows
!= f
->height
9065 || width
!= f
->output_data
.w32
->pixel_width
9066 || height
!= f
->output_data
.w32
->pixel_height
)
9068 change_frame_size (f
, rows
, columns
, 0, 1, 0);
9069 SET_FRAME_GARBAGED (f
);
9070 cancel_mouse_face (f
);
9071 f
->output_data
.w32
->pixel_width
= width
;
9072 f
->output_data
.w32
->pixel_height
= height
;
9073 f
->output_data
.w32
->win_gravity
= NorthWestGravity
;
9077 check_visibility
= 1;
9081 f
= x_any_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9084 if (f
== dpyinfo
->mouse_face_mouse_frame
)
9086 /* If we move outside the frame, then we're
9087 certainly no longer on any text in the frame. */
9088 clear_mouse_face (dpyinfo
);
9089 dpyinfo
->mouse_face_mouse_frame
= 0;
9092 /* Generate a nil HELP_EVENT to cancel a help-echo.
9093 Do it only if there's something to cancel.
9094 Otherwise, the startup message is cleared when
9095 the mouse leaves the frame. */
9096 if (any_help_event_p
)
9101 XSETFRAME (frame
, f
);
9103 n
= gen_help_event (bufp
, numchars
,
9104 Qnil
, frame
, Qnil
, Qnil
, 0);
9105 bufp
+= n
, count
+= n
, numchars
-= n
;
9111 f
= x_any_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9113 dpyinfo
->w32_focus_event_frame
= f
;
9116 x_new_focus_frame (dpyinfo
, f
);
9119 dpyinfo
->grabbed
= 0;
9120 check_visibility
= 1;
9124 /* TODO: some of this belongs in MOUSE_LEAVE */
9125 f
= x_top_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9129 if (f
== dpyinfo
->w32_focus_event_frame
)
9130 dpyinfo
->w32_focus_event_frame
= 0;
9132 if (f
== dpyinfo
->w32_focus_frame
)
9133 x_new_focus_frame (dpyinfo
, 0);
9135 if (f
== dpyinfo
->mouse_face_mouse_frame
)
9137 /* If we move outside the frame, then we're
9138 certainly no longer on any text in the frame. */
9139 clear_mouse_face (dpyinfo
);
9140 dpyinfo
->mouse_face_mouse_frame
= 0;
9143 /* Generate a nil HELP_EVENT to cancel a help-echo.
9144 Do it only if there's something to cancel.
9145 Otherwise, the startup message is cleared when
9146 the mouse leaves the frame. */
9147 if (any_help_event_p
)
9152 XSETFRAME (frame
, f
);
9154 n
= gen_help_event (bufp
, numchars
,
9155 Qnil
, frame
, Qnil
, Qnil
, 0);
9156 bufp
+= n
, count
+= n
, numchars
-=n
;
9160 dpyinfo
->grabbed
= 0;
9161 check_visibility
= 1;
9165 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9172 bufp
->kind
= DELETE_WINDOW_EVENT
;
9173 XSETFRAME (bufp
->frame_or_window
, f
);
9182 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9189 bufp
->kind
= MENU_BAR_ACTIVATE_EVENT
;
9190 XSETFRAME (bufp
->frame_or_window
, f
);
9199 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9203 extern void menubar_selection_callback
9204 (FRAME_PTR f
, void * client_data
);
9205 menubar_selection_callback (f
, (void *)msg
.msg
.wParam
);
9208 check_visibility
= 1;
9211 case WM_DISPLAYCHANGE
:
9212 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9216 dpyinfo
->width
= (short) LOWORD (msg
.msg
.lParam
);
9217 dpyinfo
->height
= (short) HIWORD (msg
.msg
.lParam
);
9218 dpyinfo
->n_cbits
= msg
.msg
.wParam
;
9219 DebPrint (("display change: %d %d\n", dpyinfo
->width
,
9223 check_visibility
= 1;
9227 /* Check for messages registered at runtime. */
9228 if (msg
.msg
.message
== msh_mousewheel
)
9230 if (dpyinfo
->grabbed
&& last_mouse_frame
9231 && FRAME_LIVE_P (last_mouse_frame
))
9232 f
= last_mouse_frame
;
9234 f
= x_window_to_frame (dpyinfo
, msg
.msg
.hwnd
);
9238 if ((!dpyinfo
->w32_focus_frame
9239 || f
== dpyinfo
->w32_focus_frame
)
9242 construct_mouse_wheel (bufp
, &msg
, f
);
9253 /* If the focus was just given to an autoraising frame,
9255 /* ??? This ought to be able to handle more than one such frame. */
9256 if (pending_autoraise_frame
)
9258 x_raise_frame (pending_autoraise_frame
);
9259 pending_autoraise_frame
= 0;
9262 /* Check which frames are still visisble, if we have enqueued any user
9263 events or been notified of events that may affect visibility. We
9264 do this here because there doesn't seem to be any direct
9265 notification from Windows that the visibility of a window has
9266 changed (at least, not in all cases). */
9267 if (count
> 0 || check_visibility
)
9269 Lisp_Object tail
, frame
;
9271 FOR_EACH_FRAME (tail
, frame
)
9273 FRAME_PTR f
= XFRAME (frame
);
9274 /* The tooltip has been drawn already. Avoid the
9275 SET_FRAME_GARBAGED below. */
9276 if (EQ (frame
, tip_frame
))
9279 /* Check "visible" frames and mark each as obscured or not.
9280 Note that async_visible is nonzero for unobscured and
9281 obscured frames, but zero for hidden and iconified frames. */
9282 if (FRAME_W32_P (f
) && f
->async_visible
)
9288 /* Query clipping rectangle for the entire window area
9289 (GetWindowDC), not just the client portion (GetDC).
9290 Otherwise, the scrollbars and menubar aren't counted as
9291 part of the visible area of the frame, and we may think
9292 the frame is obscured when really a scrollbar is still
9293 visible and gets WM_PAINT messages above. */
9294 hdc
= GetWindowDC (FRAME_W32_WINDOW (f
));
9295 GetClipBox (hdc
, &clipbox
);
9296 ReleaseDC (FRAME_W32_WINDOW (f
), hdc
);
9299 if (clipbox
.right
== clipbox
.left
9300 || clipbox
.bottom
== clipbox
.top
)
9302 /* Frame has become completely obscured so mark as
9303 such (we do this by setting async_visible to 2 so
9304 that FRAME_VISIBLE_P is still true, but redisplay
9306 f
->async_visible
= 2;
9308 if (!FRAME_OBSCURED_P (f
))
9310 DebPrint (("frame %p (%s) obscured\n", f
,
9311 XSTRING (f
->name
)->data
));
9316 /* Frame is not obscured, so mark it as such. */
9317 f
->async_visible
= 1;
9319 if (FRAME_OBSCURED_P (f
))
9321 SET_FRAME_GARBAGED (f
);
9322 DebPrint (("obscured frame %p (%s) found to be visible\n", f
,
9323 XSTRING (f
->name
)->data
));
9325 /* Force a redisplay sooner or later. */
9326 record_asynch_buffer_change ();
9340 /***********************************************************************
9342 ***********************************************************************/
9344 /* Notice if the text cursor of window W has been overwritten by a
9345 drawing operation that outputs glyphs starting at START_X and
9346 ending at END_X in the line given by output_cursor.vpos.
9347 Coordinates are area-relative. END_X < 0 means all the rest
9348 of the line after START_X has been written. */
9351 notice_overwritten_cursor (w
, area
, x0
, x1
, y0
, y1
)
9353 enum glyph_row_area area
;
9356 if (area
== TEXT_AREA
9357 && w
->phys_cursor_on_p
9358 && y0
<= w
->phys_cursor
.y
9359 && y1
>= w
->phys_cursor
.y
+ w
->phys_cursor_height
9360 && x0
<= w
->phys_cursor
.x
9361 && (x1
< 0 || x1
> w
->phys_cursor
.x
))
9362 w
->phys_cursor_on_p
= 0;
9366 /* Set clipping for output in glyph row ROW. W is the window in which
9367 we operate. GC is the graphics context to set clipping in.
9368 WHOLE_LINE_P non-zero means include the areas used for truncation
9369 mark display and alike in the clipping rectangle.
9371 ROW may be a text row or, e.g., a mode line. Text rows must be
9372 clipped to the interior of the window dedicated to text display,
9373 mode lines must be clipped to the whole window. */
9376 w32_clip_to_row (w
, row
, hdc
, whole_line_p
)
9378 struct glyph_row
*row
;
9382 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
9384 int window_x
, window_y
, window_width
, window_height
;
9386 window_box (w
, -1, &window_x
, &window_y
, &window_width
, &window_height
);
9388 clip_rect
.left
= WINDOW_TO_FRAME_PIXEL_X (w
, 0);
9389 clip_rect
.top
= WINDOW_TO_FRAME_PIXEL_Y (w
, row
->y
);
9390 clip_rect
.top
= max (clip_rect
.top
, window_y
);
9391 clip_rect
.right
= clip_rect
.left
+ window_width
;
9392 clip_rect
.bottom
= clip_rect
.top
+ row
->visible_height
;
9394 /* If clipping to the whole line, including trunc marks, extend
9395 the rectangle to the left and increase its width. */
9398 clip_rect
.left
-= FRAME_X_LEFT_FRINGE_WIDTH (f
);
9399 clip_rect
.right
+= FRAME_X_FRINGE_WIDTH (f
);
9402 w32_set_clip_rectangle (hdc
, &clip_rect
);
9406 /* Draw a hollow box cursor on window W in glyph row ROW. */
9409 x_draw_hollow_cursor (w
, row
)
9411 struct glyph_row
*row
;
9413 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
9417 struct glyph
*cursor_glyph
;
9418 HBRUSH hb
= CreateSolidBrush (f
->output_data
.w32
->cursor_pixel
);
9420 /* Compute frame-relative coordinates from window-relative
9422 rect
.left
= WINDOW_TEXT_TO_FRAME_PIXEL_X (w
, w
->phys_cursor
.x
);
9423 rect
.top
= (WINDOW_TO_FRAME_PIXEL_Y (w
, w
->phys_cursor
.y
)
9424 + row
->ascent
- w
->phys_cursor_ascent
);
9425 rect
.bottom
= rect
.top
+ row
->height
;
9427 /* Get the glyph the cursor is on. If we can't tell because
9428 the current matrix is invalid or such, give up. */
9429 cursor_glyph
= get_phys_cursor_glyph (w
);
9430 if (cursor_glyph
== NULL
)
9433 /* Compute the width of the rectangle to draw. If on a stretch
9434 glyph, and `x-stretch-block-cursor' is nil, don't draw a
9435 rectangle as wide as the glyph, but use a canonical character
9437 wd
= cursor_glyph
->pixel_width
;
9438 if (cursor_glyph
->type
== STRETCH_GLYPH
9439 && !x_stretch_cursor_p
)
9440 wd
= min (CANON_X_UNIT (f
), wd
);
9442 rect
.right
= rect
.left
+ wd
;
9443 hdc
= get_frame_dc (f
);
9444 FrameRect (hdc
, &rect
, hb
);
9447 release_frame_dc (f
, hdc
);
9451 /* Draw a bar cursor on window W in glyph row ROW.
9453 Implementation note: One would like to draw a bar cursor with an
9454 angle equal to the one given by the font property XA_ITALIC_ANGLE.
9455 Unfortunately, I didn't find a font yet that has this property set.
9459 x_draw_bar_cursor (w
, row
, width
, kind
)
9461 struct glyph_row
*row
;
9463 enum text_cursor_kinds kind
;
9465 struct frame
*f
= XFRAME (w
->frame
);
9466 struct glyph
*cursor_glyph
;
9470 /* If cursor is out of bounds, don't draw garbage. This can happen
9471 in mini-buffer windows when switching between echo area glyphs
9473 cursor_glyph
= get_phys_cursor_glyph (w
);
9474 if (cursor_glyph
== NULL
)
9477 /* If on an image, draw like a normal cursor. That's usually better
9478 visible than drawing a bar, esp. if the image is large so that
9479 the bar might not be in the window. */
9480 if (cursor_glyph
->type
== IMAGE_GLYPH
)
9482 struct glyph_row
*row
;
9483 row
= MATRIX_ROW (w
->current_matrix
, w
->phys_cursor
.vpos
);
9484 x_draw_phys_cursor_glyph (w
, row
, DRAW_CURSOR
);
9488 COLORREF cursor_color
= f
->output_data
.w32
->cursor_pixel
;
9489 struct face
*face
= FACE_FROM_ID (f
, cursor_glyph
->face_id
);
9492 width
= f
->output_data
.w32
->cursor_width
;
9493 width
= min (cursor_glyph
->pixel_width
, width
);
9495 /* If the glyph's background equals the color we normally draw
9496 the bar cursor in, the bar cursor in its normal color is
9497 invisible. Use the glyph's foreground color instead in this
9498 case, on the assumption that the glyph's colors are chosen so
9499 that the glyph is legible. */
9500 if (face
->background
== cursor_color
)
9501 cursor_color
= face
->foreground
;
9503 x
= WINDOW_TEXT_TO_FRAME_PIXEL_X (w
, w
->phys_cursor
.x
);
9504 hdc
= get_frame_dc (f
);
9505 w32_clip_to_row (w
, row
, hdc
, 0);
9507 if (kind
== BAR_CURSOR
)
9509 w32_fill_area (f
, hdc
, cursor_color
, x
,
9510 WINDOW_TO_FRAME_PIXEL_Y (w
, w
->phys_cursor
.y
),
9511 width
, row
->height
);
9515 w32_fill_area (f
, hdc
, cursor_color
, x
,
9516 WINDOW_TO_FRAME_PIXEL_Y (w
, w
->phys_cursor
.y
+
9517 row
->height
- width
),
9518 cursor_glyph
->pixel_width
, width
);
9520 release_frame_dc (f
, hdc
);
9525 /* Clear the cursor of window W to background color, and mark the
9526 cursor as not shown. This is used when the text where the cursor
9527 is is about to be rewritten. */
9533 if (FRAME_VISIBLE_P (XFRAME (w
->frame
)) && w
->phys_cursor_on_p
)
9534 x_update_window_cursor (w
, 0);
9538 /* Draw the cursor glyph of window W in glyph row ROW. See the
9539 comment of x_draw_glyphs for the meaning of HL. */
9542 x_draw_phys_cursor_glyph (w
, row
, hl
)
9544 struct glyph_row
*row
;
9545 enum draw_glyphs_face hl
;
9547 /* If cursor hpos is out of bounds, don't draw garbage. This can
9548 happen in mini-buffer windows when switching between echo area
9549 glyphs and mini-buffer. */
9550 if (w
->phys_cursor
.hpos
< row
->used
[TEXT_AREA
])
9552 int on_p
= w
->phys_cursor_on_p
;
9553 x_draw_glyphs (w
, w
->phys_cursor
.x
, row
, TEXT_AREA
,
9554 w
->phys_cursor
.hpos
, w
->phys_cursor
.hpos
+ 1,
9556 w
->phys_cursor_on_p
= on_p
;
9558 /* When we erase the cursor, and ROW is overlapped by other
9559 rows, make sure that these overlapping parts of other rows
9561 if (hl
== DRAW_NORMAL_TEXT
&& row
->overlapped_p
)
9563 if (row
> w
->current_matrix
->rows
9564 && MATRIX_ROW_OVERLAPS_SUCC_P (row
- 1))
9565 x_fix_overlapping_area (w
, row
- 1, TEXT_AREA
);
9567 if (MATRIX_ROW_BOTTOM_Y (row
) < window_text_bottom_y (w
)
9568 && MATRIX_ROW_OVERLAPS_PRED_P (row
+ 1))
9569 x_fix_overlapping_area (w
, row
+ 1, TEXT_AREA
);
9575 /* Erase the image of a cursor of window W from the screen. */
9578 x_erase_phys_cursor (w
)
9581 struct frame
*f
= XFRAME (w
->frame
);
9582 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
9583 int hpos
= w
->phys_cursor
.hpos
;
9584 int vpos
= w
->phys_cursor
.vpos
;
9585 int mouse_face_here_p
= 0;
9586 struct glyph_matrix
*active_glyphs
= w
->current_matrix
;
9587 struct glyph_row
*cursor_row
;
9588 struct glyph
*cursor_glyph
;
9589 enum draw_glyphs_face hl
;
9591 /* No cursor displayed or row invalidated => nothing to do on the
9593 if (w
->phys_cursor_type
== NO_CURSOR
)
9594 goto mark_cursor_off
;
9596 /* VPOS >= active_glyphs->nrows means that window has been resized.
9597 Don't bother to erase the cursor. */
9598 if (vpos
>= active_glyphs
->nrows
)
9599 goto mark_cursor_off
;
9601 /* If row containing cursor is marked invalid, there is nothing we
9603 cursor_row
= MATRIX_ROW (active_glyphs
, vpos
);
9604 if (!cursor_row
->enabled_p
)
9605 goto mark_cursor_off
;
9607 /* If row is completely invisible, don't attempt to delete a cursor which
9608 isn't there. This may happen if cursor is at top of window, and
9609 we switch to a buffer with a header line in that window. */
9610 if (cursor_row
->visible_height
<= 0)
9611 goto mark_cursor_off
;
9613 /* This can happen when the new row is shorter than the old one.
9614 In this case, either x_draw_glyphs or clear_end_of_line
9615 should have cleared the cursor. Note that we wouldn't be
9616 able to erase the cursor in this case because we don't have a
9617 cursor glyph at hand. */
9618 if (w
->phys_cursor
.hpos
>= cursor_row
->used
[TEXT_AREA
])
9619 goto mark_cursor_off
;
9621 /* If the cursor is in the mouse face area, redisplay that when
9622 we clear the cursor. */
9623 if (! NILP (dpyinfo
->mouse_face_window
)
9624 && w
== XWINDOW (dpyinfo
->mouse_face_window
)
9625 && (vpos
> dpyinfo
->mouse_face_beg_row
9626 || (vpos
== dpyinfo
->mouse_face_beg_row
9627 && hpos
>= dpyinfo
->mouse_face_beg_col
))
9628 && (vpos
< dpyinfo
->mouse_face_end_row
9629 || (vpos
== dpyinfo
->mouse_face_end_row
9630 && hpos
< dpyinfo
->mouse_face_end_col
))
9631 /* Don't redraw the cursor's spot in mouse face if it is at the
9632 end of a line (on a newline). The cursor appears there, but
9633 mouse highlighting does not. */
9634 && cursor_row
->used
[TEXT_AREA
] > hpos
)
9635 mouse_face_here_p
= 1;
9637 /* Maybe clear the display under the cursor. */
9638 if (w
->phys_cursor_type
== HOLLOW_BOX_CURSOR
)
9641 int header_line_height
= WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w
);
9644 cursor_glyph
= get_phys_cursor_glyph (w
);
9645 if (cursor_glyph
== NULL
)
9646 goto mark_cursor_off
;
9648 x
= WINDOW_TEXT_TO_FRAME_PIXEL_X (w
, w
->phys_cursor
.x
);
9650 hdc
= get_frame_dc (f
);
9651 w32_clear_area (f
, hdc
, x
,
9652 WINDOW_TO_FRAME_PIXEL_Y (w
, max (header_line_height
,
9654 cursor_glyph
->pixel_width
,
9655 cursor_row
->visible_height
);
9656 release_frame_dc (f
, hdc
);
9659 /* Erase the cursor by redrawing the character underneath it. */
9660 if (mouse_face_here_p
)
9661 hl
= DRAW_MOUSE_FACE
;
9663 hl
= DRAW_NORMAL_TEXT
;
9664 x_draw_phys_cursor_glyph (w
, cursor_row
, hl
);
9667 w
->phys_cursor_on_p
= 0;
9668 w
->phys_cursor_type
= NO_CURSOR
;
9672 /* Non-zero if physical cursor of window W is within mouse face. */
9675 cursor_in_mouse_face_p (w
)
9678 struct w32_display_info
*dpyinfo
9679 = FRAME_W32_DISPLAY_INFO (XFRAME (w
->frame
));
9680 int in_mouse_face
= 0;
9682 if (WINDOWP (dpyinfo
->mouse_face_window
)
9683 && XWINDOW (dpyinfo
->mouse_face_window
) == w
)
9685 int hpos
= w
->phys_cursor
.hpos
;
9686 int vpos
= w
->phys_cursor
.vpos
;
9688 if (vpos
>= dpyinfo
->mouse_face_beg_row
9689 && vpos
<= dpyinfo
->mouse_face_end_row
9690 && (vpos
> dpyinfo
->mouse_face_beg_row
9691 || hpos
>= dpyinfo
->mouse_face_beg_col
)
9692 && (vpos
< dpyinfo
->mouse_face_end_row
9693 || hpos
< dpyinfo
->mouse_face_end_col
9694 || dpyinfo
->mouse_face_past_end
))
9698 return in_mouse_face
;
9702 /* Display or clear cursor of window W. If ON is zero, clear the
9703 cursor. If it is non-zero, display the cursor. If ON is nonzero,
9704 where to put the cursor is specified by HPOS, VPOS, X and Y. */
9707 x_display_and_set_cursor (w
, on
, hpos
, vpos
, x
, y
)
9709 int on
, hpos
, vpos
, x
, y
;
9711 struct frame
*f
= XFRAME (w
->frame
);
9712 int new_cursor_type
;
9713 int new_cursor_width
;
9714 struct glyph_matrix
*current_glyphs
;
9715 struct glyph_row
*glyph_row
;
9716 struct glyph
*glyph
;
9717 int cursor_non_selected
;
9718 int active_cursor
= 1;
9720 /* This is pointless on invisible frames, and dangerous on garbaged
9721 windows and frames; in the latter case, the frame or window may
9722 be in the midst of changing its size, and x and y may be off the
9724 if (! FRAME_VISIBLE_P (f
)
9725 || FRAME_GARBAGED_P (f
)
9726 || vpos
>= w
->current_matrix
->nrows
9727 || hpos
>= w
->current_matrix
->matrix_w
)
9730 /* If cursor is off and we want it off, return quickly. */
9731 if (!on
&& !w
->phys_cursor_on_p
)
9734 current_glyphs
= w
->current_matrix
;
9735 glyph_row
= MATRIX_ROW (current_glyphs
, vpos
);
9736 glyph
= glyph_row
->glyphs
[TEXT_AREA
] + hpos
;
9738 /* If cursor row is not enabled, we don't really know where to
9739 display the cursor. */
9740 if (!glyph_row
->enabled_p
)
9742 w
->phys_cursor_on_p
= 0;
9746 xassert (interrupt_input_blocked
);
9748 /* Set new_cursor_type to the cursor we want to be displayed. In a
9749 mini-buffer window, we want the cursor only to appear if we are
9750 reading input from this window. For the selected window, we want
9751 the cursor type given by the frame parameter. If explicitly
9752 marked off, draw no cursor. In all other cases, we want a hollow
9755 = !NILP (Fbuffer_local_value (Qcursor_in_non_selected_windows
,
9757 new_cursor_width
= -1;
9758 if (cursor_in_echo_area
9759 && FRAME_HAS_MINIBUF_P (f
)
9760 && EQ (FRAME_MINIBUF_WINDOW (f
), echo_area_window
))
9762 if (w
== XWINDOW (echo_area_window
))
9763 new_cursor_type
= FRAME_DESIRED_CURSOR (f
);
9766 if (cursor_non_selected
)
9767 new_cursor_type
= HOLLOW_BOX_CURSOR
;
9769 new_cursor_type
= NO_CURSOR
;
9775 if (f
!= FRAME_W32_DISPLAY_INFO (f
)->w32_highlight_frame
9776 || w
!= XWINDOW (f
->selected_window
))
9780 if (MINI_WINDOW_P (w
)
9781 || !cursor_non_selected
9782 || NILP (XBUFFER (w
->buffer
)->cursor_type
))
9783 new_cursor_type
= NO_CURSOR
;
9785 new_cursor_type
= HOLLOW_BOX_CURSOR
;
9789 struct buffer
*b
= XBUFFER (w
->buffer
);
9791 if (EQ (b
->cursor_type
, Qt
))
9792 new_cursor_type
= FRAME_DESIRED_CURSOR (f
);
9794 new_cursor_type
= x_specified_cursor_type (b
->cursor_type
,
9796 if (w
->cursor_off_p
)
9798 if (new_cursor_type
== FILLED_BOX_CURSOR
)
9799 new_cursor_type
= HOLLOW_BOX_CURSOR
;
9800 else if (new_cursor_type
== BAR_CURSOR
&& new_cursor_width
> 1)
9801 new_cursor_width
= 1;
9803 new_cursor_type
= NO_CURSOR
;
9808 /* If cursor is currently being shown and we don't want it to be or
9809 it is in the wrong place, or the cursor type is not what we want,
9811 if (w
->phys_cursor_on_p
9813 || w
->phys_cursor
.x
!= x
9814 || w
->phys_cursor
.y
!= y
9815 || new_cursor_type
!= w
->phys_cursor_type
9816 || (new_cursor_type
== BAR_CURSOR
9817 && new_cursor_width
!= w
->phys_cursor_width
)))
9818 x_erase_phys_cursor (w
);
9820 /* If the cursor is now invisible and we want it to be visible,
9822 if (on
&& !w
->phys_cursor_on_p
)
9824 w
->phys_cursor_ascent
= glyph_row
->ascent
;
9825 w
->phys_cursor_height
= glyph_row
->height
;
9827 /* Set phys_cursor_.* before x_draw_.* is called because some
9828 of them may need the information. */
9829 w
->phys_cursor
.x
= x
;
9830 w
->phys_cursor
.y
= glyph_row
->y
;
9831 w
->phys_cursor
.hpos
= hpos
;
9832 w
->phys_cursor
.vpos
= vpos
;
9834 /* If the user wants to use the system caret, make sure our own
9835 cursor remains invisible. */
9836 if (w32_use_visible_system_caret
)
9838 if (w
->phys_cursor_type
!= NO_CURSOR
)
9839 x_erase_phys_cursor (w
);
9841 new_cursor_type
= w
->phys_cursor_type
= NO_CURSOR
;
9842 w
->phys_cursor_width
= -1;
9846 w
->phys_cursor_type
= new_cursor_type
;
9847 w
->phys_cursor_width
= new_cursor_width
;
9850 w
->phys_cursor_on_p
= 1;
9852 /* If this is the active cursor, we need to track it with the
9853 system caret, so third party software like screen magnifiers
9854 and speech synthesizers can follow the cursor. */
9857 HWND hwnd
= FRAME_W32_WINDOW (f
);
9860 = WINDOW_TEXT_TO_FRAME_PIXEL_X (w
, w
->phys_cursor
.x
);
9862 = (WINDOW_TO_FRAME_PIXEL_Y (w
, w
->phys_cursor
.y
)
9863 + glyph_row
->ascent
- w
->phys_cursor_ascent
);
9865 /* If the size of the active cursor changed, destroy the old
9867 if (w32_system_caret_hwnd
9868 && (w32_system_caret_height
!= w
->phys_cursor_height
))
9869 PostMessage (hwnd
, WM_EMACS_DESTROY_CARET
, 0, 0);
9871 w32_system_caret_height
= w
->phys_cursor_height
;
9873 /* Move the system caret. */
9874 PostMessage (hwnd
, WM_EMACS_TRACK_CARET
, 0, 0);
9877 switch (new_cursor_type
)
9879 case HOLLOW_BOX_CURSOR
:
9880 x_draw_hollow_cursor (w
, glyph_row
);
9883 case FILLED_BOX_CURSOR
:
9884 x_draw_phys_cursor_glyph (w
, glyph_row
, DRAW_CURSOR
);
9888 x_draw_bar_cursor (w
, glyph_row
, new_cursor_width
, BAR_CURSOR
);
9892 x_draw_bar_cursor (w
, glyph_row
, new_cursor_width
, HBAR_CURSOR
);
9905 /* Display the cursor on window W, or clear it. X and Y are window
9906 relative pixel coordinates. HPOS and VPOS are glyph matrix
9907 positions. If W is not the selected window, display a hollow
9908 cursor. ON non-zero means display the cursor at X, Y which
9909 correspond to HPOS, VPOS, otherwise it is cleared. */
9912 x_display_cursor (w
, on
, hpos
, vpos
, x
, y
)
9914 int on
, hpos
, vpos
, x
, y
;
9917 x_display_and_set_cursor (w
, on
, hpos
, vpos
, x
, y
);
9922 /* Display the cursor on window W, or clear it, according to ON_P.
9923 Don't change the cursor's position. */
9926 x_update_cursor (f
, on_p
)
9930 x_update_cursor_in_window_tree (XWINDOW (f
->root_window
), on_p
);
9934 /* Call x_update_window_cursor with parameter ON_P on all leaf windows
9935 in the window tree rooted at W. */
9938 x_update_cursor_in_window_tree (w
, on_p
)
9944 if (!NILP (w
->hchild
))
9945 x_update_cursor_in_window_tree (XWINDOW (w
->hchild
), on_p
);
9946 else if (!NILP (w
->vchild
))
9947 x_update_cursor_in_window_tree (XWINDOW (w
->vchild
), on_p
);
9949 x_update_window_cursor (w
, on_p
);
9951 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
9956 /* Switch the display of W's cursor on or off, according to the value
9960 x_update_window_cursor (w
, on
)
9964 /* Don't update cursor in windows whose frame is in the process
9965 of being deleted. */
9966 if (w
->current_matrix
)
9969 x_display_and_set_cursor (w
, on
, w
->phys_cursor
.hpos
,
9970 w
->phys_cursor
.vpos
, w
->phys_cursor
.x
,
9982 x_bitmap_icon (f
, icon
)
9988 if (FRAME_W32_WINDOW (f
) == 0)
9992 hicon
= LoadIcon (hinst
, EMACS_CLASS
);
9993 else if (STRINGP (icon
))
9994 hicon
= LoadImage (NULL
, (LPCTSTR
) XSTRING (icon
)->data
, IMAGE_ICON
, 0, 0,
9995 LR_DEFAULTSIZE
| LR_LOADFROMFILE
);
9996 else if (SYMBOLP (icon
))
10000 if (EQ (icon
, intern ("application")))
10001 name
= (LPCTSTR
) IDI_APPLICATION
;
10002 else if (EQ (icon
, intern ("hand")))
10003 name
= (LPCTSTR
) IDI_HAND
;
10004 else if (EQ (icon
, intern ("question")))
10005 name
= (LPCTSTR
) IDI_QUESTION
;
10006 else if (EQ (icon
, intern ("exclamation")))
10007 name
= (LPCTSTR
) IDI_EXCLAMATION
;
10008 else if (EQ (icon
, intern ("asterisk")))
10009 name
= (LPCTSTR
) IDI_ASTERISK
;
10010 else if (EQ (icon
, intern ("winlogo")))
10011 name
= (LPCTSTR
) IDI_WINLOGO
;
10015 hicon
= LoadIcon (NULL
, name
);
10023 PostMessage (FRAME_W32_WINDOW (f
), WM_SETICON
, (WPARAM
) ICON_BIG
,
10030 /************************************************************************
10032 ************************************************************************/
10034 /* Display Error Handling functions not used on W32. Listing them here
10035 helps diff stay in step when comparing w32term.c with xterm.c.
10037 x_error_catcher (display, error)
10038 x_catch_errors (dpy)
10039 x_catch_errors_unwind (old_val)
10040 x_check_errors (dpy, format)
10041 x_had_errors_p (dpy)
10042 x_clear_errors (dpy)
10043 x_uncatch_errors (dpy, count)
10045 x_connection_signal (signalnum)
10046 x_connection_closed (dpy, error_message)
10047 x_error_quitter (display, error)
10048 x_error_handler (display, error)
10049 x_io_error_quitter (display)
10054 /* Changing the font of the frame. */
10056 /* Give frame F the font named FONTNAME as its default font, and
10057 return the full name of that font. FONTNAME may be a wildcard
10058 pattern; in that case, we choose some font that fits the pattern.
10059 The return value shows which font we chose. */
10062 x_new_font (f
, fontname
)
10064 register char *fontname
;
10066 struct font_info
*fontp
10067 = FS_LOAD_FONT (f
, 0, fontname
, -1);
10072 FRAME_FONT (f
) = (XFontStruct
*) (fontp
->font
);
10073 FRAME_BASELINE_OFFSET (f
) = fontp
->baseline_offset
;
10074 FRAME_FONTSET (f
) = -1;
10076 /* Compute the scroll bar width in character columns. */
10077 if (f
->scroll_bar_pixel_width
> 0)
10079 int wid
= FONT_WIDTH (FRAME_FONT (f
));
10080 f
->scroll_bar_cols
= (f
->scroll_bar_pixel_width
+ wid
-1) / wid
;
10084 int wid
= FONT_WIDTH (FRAME_FONT (f
));
10085 f
->scroll_bar_cols
= (14 + wid
- 1) / wid
;
10088 /* Now make the frame display the given font. */
10089 if (FRAME_W32_WINDOW (f
) != 0)
10091 frame_update_line_height (f
);
10092 if (NILP (tip_frame
) || XFRAME (tip_frame
) != f
)
10093 x_set_window_size (f
, 0, f
->width
, f
->height
);
10096 /* If we are setting a new frame's font for the first time,
10097 there are no faces yet, so this font's height is the line height. */
10098 f
->output_data
.w32
->line_height
= FONT_HEIGHT (FRAME_FONT (f
));
10100 return build_string (fontp
->full_name
);
10103 /* Give frame F the fontset named FONTSETNAME as its default font, and
10104 return the full name of that fontset. FONTSETNAME may be a wildcard
10105 pattern; in that case, we choose some fontset that fits the pattern.
10106 The return value shows which fontset we chose. */
10109 x_new_fontset (f
, fontsetname
)
10113 int fontset
= fs_query_fontset (build_string (fontsetname
), 0);
10114 Lisp_Object result
;
10119 if (FRAME_FONTSET (f
) == fontset
)
10120 /* This fontset is already set in frame F. There's nothing more
10122 return fontset_name (fontset
);
10124 result
= x_new_font (f
, (XSTRING (fontset_ascii (fontset
))->data
));
10126 if (!STRINGP (result
))
10127 /* Can't load ASCII font. */
10130 /* Since x_new_font doesn't update any fontset information, do it now. */
10131 FRAME_FONTSET(f
) = fontset
;
10133 return build_string (fontsetname
);
10136 /* Compute actual fringe widths */
10139 x_compute_fringe_widths (f
, redraw
)
10143 int o_left
= f
->output_data
.w32
->left_fringe_width
;
10144 int o_right
= f
->output_data
.w32
->right_fringe_width
;
10145 int o_cols
= f
->output_data
.w32
->fringe_cols
;
10147 Lisp_Object left_fringe
= Fassq (Qleft_fringe
, f
->param_alist
);
10148 Lisp_Object right_fringe
= Fassq (Qright_fringe
, f
->param_alist
);
10149 int left_fringe_width
, right_fringe_width
;
10151 if (!NILP (left_fringe
))
10152 left_fringe
= Fcdr (left_fringe
);
10153 if (!NILP (right_fringe
))
10154 right_fringe
= Fcdr (right_fringe
);
10156 left_fringe_width
= ((NILP (left_fringe
) || !INTEGERP (left_fringe
)) ? 8 :
10157 XINT (left_fringe
));
10158 right_fringe_width
= ((NILP (right_fringe
) || !INTEGERP (right_fringe
)) ? 8 :
10159 XINT (right_fringe
));
10161 if (left_fringe_width
|| right_fringe_width
)
10163 int left_wid
= left_fringe_width
>= 0 ? left_fringe_width
: -left_fringe_width
;
10164 int right_wid
= right_fringe_width
>= 0 ? right_fringe_width
: -right_fringe_width
;
10165 int conf_wid
= left_wid
+ right_wid
;
10166 int font_wid
= FONT_WIDTH (f
->output_data
.w32
->font
);
10167 int cols
= (left_wid
+ right_wid
+ font_wid
-1) / font_wid
;
10168 int real_wid
= cols
* font_wid
;
10169 if (left_wid
&& right_wid
)
10171 if (left_fringe_width
< 0)
10173 /* Left fringe width is fixed, adjust right fringe if necessary */
10174 f
->output_data
.w32
->left_fringe_width
= left_wid
;
10175 f
->output_data
.w32
->right_fringe_width
= real_wid
- left_wid
;
10177 else if (right_fringe_width
< 0)
10179 /* Right fringe width is fixed, adjust left fringe if necessary */
10180 f
->output_data
.w32
->left_fringe_width
= real_wid
- right_wid
;
10181 f
->output_data
.w32
->right_fringe_width
= right_wid
;
10185 /* Adjust both fringes with an equal amount.
10186 Note that we are doing integer arithmetic here, so don't
10187 lose a pixel if the total width is an odd number. */
10188 int fill
= real_wid
- conf_wid
;
10189 f
->output_data
.w32
->left_fringe_width
= left_wid
+ fill
/2;
10190 f
->output_data
.w32
->right_fringe_width
= right_wid
+ fill
- fill
/2;
10193 else if (left_fringe_width
)
10195 f
->output_data
.w32
->left_fringe_width
= real_wid
;
10196 f
->output_data
.w32
->right_fringe_width
= 0;
10200 f
->output_data
.w32
->left_fringe_width
= 0;
10201 f
->output_data
.w32
->right_fringe_width
= real_wid
;
10203 f
->output_data
.w32
->fringe_cols
= cols
;
10204 f
->output_data
.w32
->fringes_extra
= real_wid
;
10208 f
->output_data
.w32
->left_fringe_width
= 0;
10209 f
->output_data
.w32
->right_fringe_width
= 0;
10210 f
->output_data
.w32
->fringe_cols
= 0;
10211 f
->output_data
.w32
->fringes_extra
= 0;
10214 if (redraw
&& FRAME_VISIBLE_P (f
))
10215 if (o_left
!= f
->output_data
.w32
->left_fringe_width
||
10216 o_right
!= f
->output_data
.w32
->right_fringe_width
||
10217 o_cols
!= f
->output_data
.w32
->fringe_cols
)
10221 /***********************************************************************
10222 TODO: W32 Input Methods
10223 ***********************************************************************/
10224 /* Listing missing functions from xterm.c helps diff stay in step.
10226 xim_destroy_callback (xim, client_data, call_data)
10227 xim_open_dpy (dpyinfo, resource_name)
10229 xim_instantiate_callback (display, client_data, call_data)
10230 xim_initialize (dpyinfo, resource_name)
10231 xim_close_dpy (dpyinfo)
10236 /* Calculate the absolute position in frame F
10237 from its current recorded position values and gravity. */
10240 x_calc_absolute_position (f
)
10244 int flags
= f
->output_data
.w32
->size_hint_flags
;
10248 /* Find the position of the outside upper-left corner of
10249 the inner window, with respect to the outer window.
10250 But do this only if we will need the results. */
10251 if (f
->output_data
.w32
->parent_desc
!= FRAME_W32_DISPLAY_INFO (f
)->root_window
)
10254 MapWindowPoints (FRAME_W32_WINDOW (f
),
10255 f
->output_data
.w32
->parent_desc
,
10262 rt
.left
= rt
.right
= rt
.top
= rt
.bottom
= 0;
10265 AdjustWindowRect(&rt
, f
->output_data
.w32
->dwStyle
,
10266 FRAME_EXTERNAL_MENU_BAR (f
));
10269 pt
.x
+= (rt
.right
- rt
.left
);
10270 pt
.y
+= (rt
.bottom
- rt
.top
);
10273 /* Treat negative positions as relative to the leftmost bottommost
10274 position that fits on the screen. */
10275 if (flags
& XNegative
)
10276 f
->output_data
.w32
->left_pos
= (FRAME_W32_DISPLAY_INFO (f
)->width
10277 - 2 * f
->output_data
.w32
->border_width
- pt
.x
10279 + f
->output_data
.w32
->left_pos
);
10281 if (flags
& YNegative
)
10282 f
->output_data
.w32
->top_pos
= (FRAME_W32_DISPLAY_INFO (f
)->height
10283 - 2 * f
->output_data
.w32
->border_width
- pt
.y
10285 + f
->output_data
.w32
->top_pos
);
10286 /* The left_pos and top_pos
10287 are now relative to the top and left screen edges,
10288 so the flags should correspond. */
10289 f
->output_data
.w32
->size_hint_flags
&= ~ (XNegative
| YNegative
);
10292 /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
10293 to really change the position, and 0 when calling from
10294 x_make_frame_visible (in that case, XOFF and YOFF are the current
10295 position values). It is -1 when calling from x_set_frame_parameters,
10296 which means, do adjust for borders but don't change the gravity. */
10299 x_set_offset (f
, xoff
, yoff
, change_gravity
)
10301 register int xoff
, yoff
;
10302 int change_gravity
;
10304 int modified_top
, modified_left
;
10306 if (change_gravity
> 0)
10308 f
->output_data
.w32
->top_pos
= yoff
;
10309 f
->output_data
.w32
->left_pos
= xoff
;
10310 f
->output_data
.w32
->size_hint_flags
&= ~ (XNegative
| YNegative
);
10312 f
->output_data
.w32
->size_hint_flags
|= XNegative
;
10314 f
->output_data
.w32
->size_hint_flags
|= YNegative
;
10315 f
->output_data
.w32
->win_gravity
= NorthWestGravity
;
10317 x_calc_absolute_position (f
);
10320 x_wm_set_size_hint (f
, (long) 0, 0);
10322 modified_left
= f
->output_data
.w32
->left_pos
;
10323 modified_top
= f
->output_data
.w32
->top_pos
;
10325 my_set_window_pos (FRAME_W32_WINDOW (f
),
10327 modified_left
, modified_top
,
10329 SWP_NOZORDER
| SWP_NOSIZE
| SWP_NOACTIVATE
);
10334 /* Check if we need to resize the frame due to a fullscreen request.
10335 If so needed, resize the frame. */
10337 x_check_fullscreen (f
)
10340 if (f
->output_data
.w32
->want_fullscreen
& FULLSCREEN_BOTH
)
10342 int width
, height
, ign
;
10344 x_real_positions (f
, &f
->output_data
.w32
->left_pos
,
10345 &f
->output_data
.w32
->top_pos
);
10347 x_fullscreen_adjust (f
, &width
, &height
, &ign
, &ign
);
10349 /* We do not need to move the window, it shall be taken care of
10350 when setting WM manager hints.
10351 If the frame is visible already, the position is checked by
10352 x_check_fullscreen_move. */
10353 if (f
->width
!= width
|| f
->height
!= height
)
10355 change_frame_size (f
, height
, width
, 0, 1, 0);
10356 SET_FRAME_GARBAGED (f
);
10357 cancel_mouse_face (f
);
10359 /* Wait for the change of frame size to occur */
10360 f
->output_data
.w32
->want_fullscreen
|= FULLSCREEN_WAIT
;
10365 /* If frame parameters are set after the frame is mapped, we need to move
10366 the window. This is done in xfns.c.
10367 Some window managers moves the window to the right position, some
10368 moves the outer window manager window to the specified position.
10369 Here we check that we are in the right spot. If not, make a second
10370 move, assuming we are dealing with the second kind of window manager. */
10372 x_check_fullscreen_move (f
)
10375 if (f
->output_data
.w32
->want_fullscreen
& FULLSCREEN_MOVE_WAIT
)
10377 int expect_top
= f
->output_data
.w32
->top_pos
;
10378 int expect_left
= f
->output_data
.w32
->left_pos
;
10380 if (f
->output_data
.w32
->want_fullscreen
& FULLSCREEN_HEIGHT
)
10382 if (f
->output_data
.w32
->want_fullscreen
& FULLSCREEN_WIDTH
)
10385 if (expect_top
!= f
->output_data
.w32
->top_pos
10386 || expect_left
!= f
->output_data
.w32
->left_pos
)
10387 x_set_offset (f
, expect_left
, expect_top
, 1);
10389 /* Just do this once */
10390 f
->output_data
.w32
->want_fullscreen
&= ~FULLSCREEN_MOVE_WAIT
;
10395 /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
10396 wanted positions of the WM window (not emacs window).
10397 Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
10398 window (FRAME_X_WINDOW).
10401 x_fullscreen_adjust (f
, width
, height
, top_pos
, left_pos
)
10408 int newwidth
= f
->width
, newheight
= f
->height
;
10410 *top_pos
= f
->output_data
.w32
->top_pos
;
10411 *left_pos
= f
->output_data
.w32
->left_pos
;
10413 if (f
->output_data
.w32
->want_fullscreen
& FULLSCREEN_HEIGHT
)
10417 ph
= FRAME_X_DISPLAY_INFO (f
)->height
;
10418 newheight
= PIXEL_TO_CHAR_HEIGHT (f
, ph
);
10419 ph
= CHAR_TO_PIXEL_HEIGHT (f
, newheight
)
10420 - f
->output_data
.w32
->y_pixels_diff
;
10421 newheight
= PIXEL_TO_CHAR_HEIGHT (f
, ph
);
10425 if (f
->output_data
.w32
->want_fullscreen
& FULLSCREEN_WIDTH
)
10429 pw
= FRAME_X_DISPLAY_INFO (f
)->width
;
10430 newwidth
= PIXEL_TO_CHAR_WIDTH (f
, pw
);
10431 pw
= CHAR_TO_PIXEL_WIDTH (f
, newwidth
)
10432 - f
->output_data
.w32
->x_pixels_diff
;
10433 newwidth
= PIXEL_TO_CHAR_WIDTH (f
, pw
);
10438 *height
= newheight
;
10442 /* Call this to change the size of frame F's x-window.
10443 If CHANGE_GRAVITY is 1, we change to top-left-corner window gravity
10444 for this size change and subsequent size changes.
10445 Otherwise we leave the window gravity unchanged. */
10448 x_set_window_size (f
, change_gravity
, cols
, rows
)
10450 int change_gravity
;
10453 int pixelwidth
, pixelheight
;
10457 check_frame_size (f
, &rows
, &cols
);
10458 f
->output_data
.w32
->vertical_scroll_bar_extra
10459 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f
)
10461 : (FRAME_SCROLL_BAR_COLS (f
) * FONT_WIDTH (f
->output_data
.w32
->font
)));
10463 x_compute_fringe_widths (f
, 0);
10465 pixelwidth
= CHAR_TO_PIXEL_WIDTH (f
, cols
);
10466 pixelheight
= CHAR_TO_PIXEL_HEIGHT (f
, rows
);
10468 f
->output_data
.w32
->win_gravity
= NorthWestGravity
;
10469 x_wm_set_size_hint (f
, (long) 0, 0);
10474 rect
.left
= rect
.top
= 0;
10475 rect
.right
= pixelwidth
;
10476 rect
.bottom
= pixelheight
;
10478 AdjustWindowRect(&rect
, f
->output_data
.w32
->dwStyle
,
10479 FRAME_EXTERNAL_MENU_BAR (f
));
10481 my_set_window_pos (FRAME_W32_WINDOW (f
),
10484 rect
.right
- rect
.left
,
10485 rect
.bottom
- rect
.top
,
10486 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
10489 /* Now, strictly speaking, we can't be sure that this is accurate,
10490 but the window manager will get around to dealing with the size
10491 change request eventually, and we'll hear how it went when the
10492 ConfigureNotify event gets here.
10494 We could just not bother storing any of this information here,
10495 and let the ConfigureNotify event set everything up, but that
10496 might be kind of confusing to the Lisp code, since size changes
10497 wouldn't be reported in the frame parameters until some random
10498 point in the future when the ConfigureNotify event arrives.
10500 We pass 1 for DELAY since we can't run Lisp code inside of
10502 change_frame_size (f
, rows
, cols
, 0, 1, 0);
10503 PIXEL_WIDTH (f
) = pixelwidth
;
10504 PIXEL_HEIGHT (f
) = pixelheight
;
10506 /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
10507 receive in the ConfigureNotify event; if we get what we asked
10508 for, then the event won't cause the screen to become garbaged, so
10509 we have to make sure to do it here. */
10510 SET_FRAME_GARBAGED (f
);
10512 /* If cursor was outside the new size, mark it as off. */
10513 mark_window_cursors_off (XWINDOW (f
->root_window
));
10515 /* Clear out any recollection of where the mouse highlighting was,
10516 since it might be in a place that's outside the new frame size.
10517 Actually checking whether it is outside is a pain in the neck,
10518 so don't try--just let the highlighting be done afresh with new size. */
10519 cancel_mouse_face (f
);
10524 /* Mouse warping. */
10526 void x_set_mouse_pixel_position (struct frame
*f
, int pix_x
, int pix_y
);
10529 x_set_mouse_position (f
, x
, y
)
10535 pix_x
= CHAR_TO_PIXEL_COL (f
, x
) + FONT_WIDTH (f
->output_data
.w32
->font
) / 2;
10536 pix_y
= CHAR_TO_PIXEL_ROW (f
, y
) + f
->output_data
.w32
->line_height
/ 2;
10538 if (pix_x
< 0) pix_x
= 0;
10539 if (pix_x
> PIXEL_WIDTH (f
)) pix_x
= PIXEL_WIDTH (f
);
10541 if (pix_y
< 0) pix_y
= 0;
10542 if (pix_y
> PIXEL_HEIGHT (f
)) pix_y
= PIXEL_HEIGHT (f
);
10544 x_set_mouse_pixel_position (f
, pix_x
, pix_y
);
10548 x_set_mouse_pixel_position (f
, pix_x
, pix_y
)
10557 GetClientRect (FRAME_W32_WINDOW (f
), &rect
);
10558 pt
.x
= rect
.left
+ pix_x
;
10559 pt
.y
= rect
.top
+ pix_y
;
10560 ClientToScreen (FRAME_W32_WINDOW (f
), &pt
);
10562 SetCursorPos (pt
.x
, pt
.y
);
10568 /* focus shifting, raising and lowering. */
10571 x_focus_on_frame (f
)
10574 struct w32_display_info
*dpyinfo
= &one_w32_display_info
;
10576 /* Give input focus to frame. */
10579 /* Try not to change its Z-order if possible. */
10580 if (x_window_to_frame (dpyinfo
, GetForegroundWindow ()))
10581 my_set_focus (f
, FRAME_W32_WINDOW (f
));
10584 my_set_foreground_window (FRAME_W32_WINDOW (f
));
10589 x_unfocus_frame (f
)
10594 /* Raise frame F. */
10601 /* Strictly speaking, raise-frame should only change the frame's Z
10602 order, leaving input focus unchanged. This is reasonable behaviour
10603 on X where the usual policy is point-to-focus. However, this
10604 behaviour would be very odd on Windows where the usual policy is
10607 On X, if the mouse happens to be over the raised frame, it gets
10608 input focus anyway (so the window with focus will never be
10609 completely obscured) - if not, then just moving the mouse over it
10610 is sufficient to give it focus. On Windows, the user must actually
10611 click on the frame (preferrably the title bar so as not to move
10612 point), which is more awkward. Also, no other Windows program
10613 raises a window to the top but leaves another window (possibly now
10614 completely obscured) with input focus.
10616 Because there is a system setting on Windows that allows the user
10617 to choose the point to focus policy, we make the strict semantics
10618 optional, but by default we grab focus when raising. */
10620 if (NILP (Vw32_grab_focus_on_raise
))
10622 /* The obvious call to my_set_window_pos doesn't work if Emacs is
10623 not already the foreground application: the frame is raised
10624 above all other frames belonging to us, but not above the
10625 current top window. To achieve that, we have to resort to this
10626 more cumbersome method. */
10628 HDWP handle
= BeginDeferWindowPos (2);
10631 DeferWindowPos (handle
,
10632 FRAME_W32_WINDOW (f
),
10635 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
10637 DeferWindowPos (handle
,
10638 GetForegroundWindow (),
10639 FRAME_W32_WINDOW (f
),
10641 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
10643 EndDeferWindowPos (handle
);
10648 my_set_foreground_window (FRAME_W32_WINDOW (f
));
10654 /* Lower frame F. */
10660 my_set_window_pos (FRAME_W32_WINDOW (f
),
10663 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
10668 w32_frame_raise_lower (f
, raise_flag
)
10672 if (! FRAME_W32_P (f
))
10681 /* Change of visibility. */
10683 /* This tries to wait until the frame is really visible.
10684 However, if the window manager asks the user where to position
10685 the frame, this will return before the user finishes doing that.
10686 The frame will not actually be visible at that time,
10687 but it will become visible later when the window manager
10688 finishes with it. */
10691 x_make_frame_visible (f
)
10698 type
= x_icon_type (f
);
10700 x_bitmap_icon (f
, type
);
10702 if (! FRAME_VISIBLE_P (f
))
10704 /* We test FRAME_GARBAGED_P here to make sure we don't
10705 call x_set_offset a second time
10706 if we get to x_make_frame_visible a second time
10707 before the window gets really visible. */
10708 if (! FRAME_ICONIFIED_P (f
)
10709 && ! f
->output_data
.w32
->asked_for_visible
)
10710 x_set_offset (f
, f
->output_data
.w32
->left_pos
, f
->output_data
.w32
->top_pos
, 0);
10712 f
->output_data
.w32
->asked_for_visible
= 1;
10714 /* my_show_window (f, FRAME_W32_WINDOW (f), f->async_iconified ? SW_RESTORE : SW_SHOW); */
10715 my_show_window (f
, FRAME_W32_WINDOW (f
), SW_SHOWNORMAL
);
10718 /* Synchronize to ensure Emacs knows the frame is visible
10719 before we do anything else. We do this loop with input not blocked
10720 so that incoming events are handled. */
10725 /* This must come after we set COUNT. */
10728 XSETFRAME (frame
, f
);
10730 /* Wait until the frame is visible. Process X events until a
10731 MapNotify event has been seen, or until we think we won't get a
10732 MapNotify at all.. */
10733 for (count
= input_signal_count
+ 10;
10734 input_signal_count
< count
&& !FRAME_VISIBLE_P (f
);)
10736 /* Force processing of queued events. */
10737 /* TODO: x_sync equivalent? */
10739 /* Machines that do polling rather than SIGIO have been observed
10740 to go into a busy-wait here. So we'll fake an alarm signal
10741 to let the handler know that there's something to be read.
10742 We used to raise a real alarm, but it seems that the handler
10743 isn't always enabled here. This is probably a bug. */
10744 if (input_polling_used ())
10746 /* It could be confusing if a real alarm arrives while processing
10747 the fake one. Turn it off and let the handler reset it. */
10748 int old_poll_suppress_count
= poll_suppress_count
;
10749 poll_suppress_count
= 1;
10750 poll_for_input_1 ();
10751 poll_suppress_count
= old_poll_suppress_count
;
10754 FRAME_SAMPLE_VISIBILITY (f
);
10758 /* Change from mapped state to withdrawn state. */
10760 /* Make the frame visible (mapped and not iconified). */
10762 x_make_frame_invisible (f
)
10765 /* Don't keep the highlight on an invisible frame. */
10766 if (FRAME_W32_DISPLAY_INFO (f
)->w32_highlight_frame
== f
)
10767 FRAME_W32_DISPLAY_INFO (f
)->w32_highlight_frame
= 0;
10771 my_show_window (f
, FRAME_W32_WINDOW (f
), SW_HIDE
);
10773 /* We can't distinguish this from iconification
10774 just by the event that we get from the server.
10775 So we can't win using the usual strategy of letting
10776 FRAME_SAMPLE_VISIBILITY set this. So do it by hand,
10777 and synchronize with the server to make sure we agree. */
10779 FRAME_ICONIFIED_P (f
) = 0;
10780 f
->async_visible
= 0;
10781 f
->async_iconified
= 0;
10786 /* Change window state from mapped to iconified. */
10789 x_iconify_frame (f
)
10794 /* Don't keep the highlight on an invisible frame. */
10795 if (FRAME_W32_DISPLAY_INFO (f
)->w32_highlight_frame
== f
)
10796 FRAME_W32_DISPLAY_INFO (f
)->w32_highlight_frame
= 0;
10798 if (f
->async_iconified
)
10803 type
= x_icon_type (f
);
10805 x_bitmap_icon (f
, type
);
10807 /* Simulate the user minimizing the frame. */
10808 SendMessage (FRAME_W32_WINDOW (f
), WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
10814 /* Free X resources of frame F. */
10817 x_free_frame_resources (f
)
10820 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
10824 if (FRAME_W32_WINDOW (f
))
10825 my_destroy_window (f
, FRAME_W32_WINDOW (f
));
10827 free_frame_menubar (f
);
10829 unload_color (f
, f
->output_data
.x
->foreground_pixel
);
10830 unload_color (f
, f
->output_data
.x
->background_pixel
);
10831 unload_color (f
, f
->output_data
.w32
->cursor_pixel
);
10832 unload_color (f
, f
->output_data
.w32
->cursor_foreground_pixel
);
10833 unload_color (f
, f
->output_data
.w32
->border_pixel
);
10834 unload_color (f
, f
->output_data
.w32
->mouse_pixel
);
10835 if (f
->output_data
.w32
->white_relief
.allocated_p
)
10836 unload_color (f
, f
->output_data
.w32
->white_relief
.pixel
);
10837 if (f
->output_data
.w32
->black_relief
.allocated_p
)
10838 unload_color (f
, f
->output_data
.w32
->black_relief
.pixel
);
10840 if (FRAME_FACE_CACHE (f
))
10841 free_frame_faces (f
);
10843 xfree (f
->output_data
.w32
);
10844 f
->output_data
.w32
= NULL
;
10846 if (f
== dpyinfo
->w32_focus_frame
)
10847 dpyinfo
->w32_focus_frame
= 0;
10848 if (f
== dpyinfo
->w32_focus_event_frame
)
10849 dpyinfo
->w32_focus_event_frame
= 0;
10850 if (f
== dpyinfo
->w32_highlight_frame
)
10851 dpyinfo
->w32_highlight_frame
= 0;
10853 if (f
== dpyinfo
->mouse_face_mouse_frame
)
10855 dpyinfo
->mouse_face_beg_row
10856 = dpyinfo
->mouse_face_beg_col
= -1;
10857 dpyinfo
->mouse_face_end_row
10858 = dpyinfo
->mouse_face_end_col
= -1;
10859 dpyinfo
->mouse_face_window
= Qnil
;
10860 dpyinfo
->mouse_face_deferred_gc
= 0;
10861 dpyinfo
->mouse_face_mouse_frame
= 0;
10868 /* Destroy the window of frame F. */
10870 x_destroy_window (f
)
10873 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
10875 x_free_frame_resources (f
);
10877 dpyinfo
->reference_count
--;
10881 /* Setting window manager hints. */
10883 /* Set the normal size hints for the window manager, for frame F.
10884 FLAGS is the flags word to use--or 0 meaning preserve the flags
10885 that the window now has.
10886 If USER_POSITION is nonzero, we set the USPosition
10887 flag (this is useful when FLAGS is 0). */
10889 x_wm_set_size_hint (f
, flags
, user_position
)
10894 Window window
= FRAME_W32_WINDOW (f
);
10898 SetWindowLong (window
, WND_FONTWIDTH_INDEX
, FONT_WIDTH (f
->output_data
.w32
->font
));
10899 SetWindowLong (window
, WND_LINEHEIGHT_INDEX
, f
->output_data
.w32
->line_height
);
10900 SetWindowLong (window
, WND_BORDER_INDEX
, f
->output_data
.w32
->internal_border_width
);
10901 SetWindowLong (window
, WND_SCROLLBAR_INDEX
, f
->output_data
.w32
->vertical_scroll_bar_extra
);
10906 /* Window manager things */
10907 x_wm_set_icon_position (f
, icon_x
, icon_y
)
10909 int icon_x
, icon_y
;
10912 Window window
= FRAME_W32_WINDOW (f
);
10914 f
->display
.x
->wm_hints
.flags
|= IconPositionHint
;
10915 f
->display
.x
->wm_hints
.icon_x
= icon_x
;
10916 f
->display
.x
->wm_hints
.icon_y
= icon_y
;
10918 XSetWMHints (FRAME_X_DISPLAY (f
), window
, &f
->display
.x
->wm_hints
);
10923 /***********************************************************************
10925 ***********************************************************************/
10927 /* The following functions are listed here to help diff stay in step
10928 with xterm.c. See w32fns.c for definitions.
10930 x_get_font_info (f, font_idx)
10931 x_list_fonts (f, pattern, size, maxnames)
10937 /* Check that FONT is valid on frame F. It is if it can be found in F's
10941 x_check_font (f
, font
)
10946 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
10948 xassert (font
!= NULL
);
10950 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
10951 if (dpyinfo
->font_table
[i
].name
10952 && font
== dpyinfo
->font_table
[i
].font
)
10955 xassert (i
< dpyinfo
->n_fonts
);
10958 #endif /* GLYPH_DEBUG != 0 */
10960 /* Set *W to the minimum width, *H to the minimum font height of FONT.
10961 Note: There are (broken) X fonts out there with invalid XFontStruct
10962 min_bounds contents. For example, handa@etl.go.jp reports that
10963 "-adobe-courier-medium-r-normal--*-180-*-*-m-*-iso8859-1" fonts
10964 have font->min_bounds.width == 0. */
10967 x_font_min_bounds (font
, w
, h
)
10972 * TODO: Windows does not appear to offer min bound, only
10973 * average and maximum width, and maximum height.
10975 *h
= FONT_HEIGHT (font
);
10976 *w
= FONT_WIDTH (font
);
10980 /* Compute the smallest character width and smallest font height over
10981 all fonts available on frame F. Set the members smallest_char_width
10982 and smallest_font_height in F's x_display_info structure to
10983 the values computed. Value is non-zero if smallest_font_height or
10984 smallest_char_width become smaller than they were before. */
10987 x_compute_min_glyph_bounds (f
)
10991 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
10993 int old_width
= dpyinfo
->smallest_char_width
;
10994 int old_height
= dpyinfo
->smallest_font_height
;
10996 dpyinfo
->smallest_font_height
= 100000;
10997 dpyinfo
->smallest_char_width
= 100000;
10999 for (i
= 0; i
< dpyinfo
->n_fonts
; ++i
)
11000 if (dpyinfo
->font_table
[i
].name
)
11002 struct font_info
*fontp
= dpyinfo
->font_table
+ i
;
11005 font
= (XFontStruct
*) fontp
->font
;
11006 xassert (font
!= (XFontStruct
*) ~0);
11007 x_font_min_bounds (font
, &w
, &h
);
11009 dpyinfo
->smallest_font_height
= min (dpyinfo
->smallest_font_height
, h
);
11010 dpyinfo
->smallest_char_width
= min (dpyinfo
->smallest_char_width
, w
);
11013 xassert (dpyinfo
->smallest_char_width
> 0
11014 && dpyinfo
->smallest_font_height
> 0);
11016 return (dpyinfo
->n_fonts
== 1
11017 || dpyinfo
->smallest_char_width
< old_width
11018 || dpyinfo
->smallest_font_height
< old_height
);
11021 /* The following functions are listed here to help diff stay in step
11022 with xterm.c. See w32fns.c for definitions.
11024 x_load_font (f, fontname, size)
11025 x_query_font (f, fontname)
11026 x_find_ccl_program (fontp)
11030 /***********************************************************************
11032 ***********************************************************************/
11034 static int w32_initialized
= 0;
11037 w32_initialize_display_info (display_name
)
11038 Lisp_Object display_name
;
11040 struct w32_display_info
*dpyinfo
= &one_w32_display_info
;
11042 bzero (dpyinfo
, sizeof (*dpyinfo
));
11044 /* Put it on w32_display_name_list. */
11045 w32_display_name_list
= Fcons (Fcons (display_name
, Qnil
),
11046 w32_display_name_list
);
11047 dpyinfo
->name_list_element
= XCAR (w32_display_name_list
);
11049 dpyinfo
->w32_id_name
11050 = (char *) xmalloc (XSTRING (Vinvocation_name
)->size
11051 + XSTRING (Vsystem_name
)->size
11053 sprintf (dpyinfo
->w32_id_name
, "%s@%s",
11054 XSTRING (Vinvocation_name
)->data
, XSTRING (Vsystem_name
)->data
);
11056 /* Default Console mode values - overridden when running in GUI mode
11057 with values obtained from system metrics. */
11060 dpyinfo
->height_in
= 1;
11061 dpyinfo
->width_in
= 1;
11062 dpyinfo
->n_planes
= 1;
11063 dpyinfo
->n_cbits
= 4;
11064 dpyinfo
->n_fonts
= 0;
11065 dpyinfo
->smallest_font_height
= 1;
11066 dpyinfo
->smallest_char_width
= 1;
11068 dpyinfo
->mouse_face_beg_row
= dpyinfo
->mouse_face_beg_col
= -1;
11069 dpyinfo
->mouse_face_end_row
= dpyinfo
->mouse_face_end_col
= -1;
11070 dpyinfo
->mouse_face_face_id
= DEFAULT_FACE_ID
;
11071 dpyinfo
->mouse_face_window
= Qnil
;
11072 dpyinfo
->mouse_face_overlay
= Qnil
;
11073 dpyinfo
->mouse_face_hidden
= 0;
11074 /* TODO: dpyinfo->gray */
11078 struct w32_display_info
*
11079 w32_term_init (display_name
, xrm_option
, resource_name
)
11080 Lisp_Object display_name
;
11082 char *resource_name
;
11084 struct w32_display_info
*dpyinfo
;
11089 if (!w32_initialized
)
11092 w32_initialized
= 1;
11103 argv
[argc
++] = "-xrm";
11104 argv
[argc
++] = xrm_option
;
11108 w32_initialize_display_info (display_name
);
11110 dpyinfo
= &one_w32_display_info
;
11112 /* Put this display on the chain. */
11113 dpyinfo
->next
= x_display_list
;
11114 x_display_list
= dpyinfo
;
11116 hdc
= GetDC (GetDesktopWindow ());
11118 dpyinfo
->height
= GetDeviceCaps (hdc
, VERTRES
);
11119 dpyinfo
->width
= GetDeviceCaps (hdc
, HORZRES
);
11120 dpyinfo
->root_window
= GetDesktopWindow ();
11121 dpyinfo
->n_planes
= GetDeviceCaps (hdc
, PLANES
);
11122 dpyinfo
->n_cbits
= GetDeviceCaps (hdc
, BITSPIXEL
);
11123 dpyinfo
->resx
= GetDeviceCaps (hdc
, LOGPIXELSX
);
11124 dpyinfo
->resy
= GetDeviceCaps (hdc
, LOGPIXELSY
);
11125 dpyinfo
->has_palette
= GetDeviceCaps (hdc
, RASTERCAPS
) & RC_PALETTE
;
11126 dpyinfo
->image_cache
= make_image_cache ();
11127 dpyinfo
->height_in
= dpyinfo
->height
/ dpyinfo
->resx
;
11128 dpyinfo
->width_in
= dpyinfo
->width
/ dpyinfo
->resy
;
11129 ReleaseDC (GetDesktopWindow (), hdc
);
11131 /* initialise palette with white and black */
11134 w32_defined_color (0, "white", &color
, 1);
11135 w32_defined_color (0, "black", &color
, 1);
11138 /* Create Row Bitmaps and store them for later use. */
11139 left_bmp
= CreateBitmap (left_width
, left_height
, 1, 1, left_bits
);
11140 ov_bmp
= CreateBitmap (ov_width
, ov_height
, 1, 1, ov_bits
);
11141 right_bmp
= CreateBitmap (right_width
, right_height
, 1, 1, right_bits
);
11142 continued_bmp
= CreateBitmap (continued_width
, continued_height
, 1,
11143 1, continued_bits
);
11144 continuation_bmp
= CreateBitmap (continuation_width
, continuation_height
,
11145 1, 1, continuation_bits
);
11146 zv_bmp
= CreateBitmap (zv_width
, zv_height
, 1, 1, zv_bits
);
11148 #ifndef F_SETOWN_BUG
11150 #ifdef F_SETOWN_SOCK_NEG
11151 /* stdin is a socket here */
11152 fcntl (connection
, F_SETOWN
, -getpid ());
11153 #else /* ! defined (F_SETOWN_SOCK_NEG) */
11154 fcntl (connection
, F_SETOWN
, getpid ());
11155 #endif /* ! defined (F_SETOWN_SOCK_NEG) */
11156 #endif /* ! defined (F_SETOWN) */
11157 #endif /* F_SETOWN_BUG */
11160 if (interrupt_input
)
11161 init_sigio (connection
);
11162 #endif /* ! defined (SIGIO) */
11169 /* Get rid of display DPYINFO, assuming all frames are already gone. */
11172 x_delete_display (dpyinfo
)
11173 struct w32_display_info
*dpyinfo
;
11175 /* Discard this display from w32_display_name_list and w32_display_list.
11176 We can't use Fdelq because that can quit. */
11177 if (! NILP (w32_display_name_list
)
11178 && EQ (XCAR (w32_display_name_list
), dpyinfo
->name_list_element
))
11179 w32_display_name_list
= XCDR (w32_display_name_list
);
11184 tail
= w32_display_name_list
;
11185 while (CONSP (tail
) && CONSP (XCDR (tail
)))
11187 if (EQ (XCAR (XCDR (tail
)), dpyinfo
->name_list_element
))
11189 XSETCDR (tail
, XCDR (XCDR (tail
)));
11192 tail
= XCDR (tail
);
11196 /* free palette table */
11198 struct w32_palette_entry
* plist
;
11200 plist
= dpyinfo
->color_list
;
11203 struct w32_palette_entry
* pentry
= plist
;
11204 plist
= plist
->next
;
11207 dpyinfo
->color_list
= NULL
;
11208 if (dpyinfo
->palette
)
11209 DeleteObject(dpyinfo
->palette
);
11211 xfree (dpyinfo
->font_table
);
11212 xfree (dpyinfo
->w32_id_name
);
11214 /* Destroy row bitmaps. */
11215 DeleteObject (left_bmp
);
11216 DeleteObject (ov_bmp
);
11217 DeleteObject (right_bmp
);
11218 DeleteObject (continued_bmp
);
11219 DeleteObject (continuation_bmp
);
11220 DeleteObject (zv_bmp
);
11223 /* Set up use of W32. */
11225 DWORD
w32_msg_worker ();
11228 x_flush (struct frame
* f
)
11229 { /* Nothing to do */ }
11231 static struct redisplay_interface w32_redisplay_interface
=
11236 x_clear_end_of_line
,
11238 x_after_update_window_line
,
11239 x_update_window_begin
,
11240 x_update_window_end
,
11243 x_clear_mouse_face
,
11244 x_get_glyph_overhangs
,
11245 x_fix_overlapping_area
11251 rif
= &w32_redisplay_interface
;
11253 /* MSVC does not type K&R functions with no arguments correctly, and
11254 so we must explicitly cast them. */
11255 clear_frame_hook
= (void (*)(void)) x_clear_frame
;
11256 ring_bell_hook
= (void (*)(void)) w32_ring_bell
;
11257 update_begin_hook
= x_update_begin
;
11258 update_end_hook
= x_update_end
;
11260 read_socket_hook
= w32_read_socket
;
11262 frame_up_to_date_hook
= w32_frame_up_to_date
;
11264 mouse_position_hook
= w32_mouse_position
;
11265 frame_rehighlight_hook
= w32_frame_rehighlight
;
11266 frame_raise_lower_hook
= w32_frame_raise_lower
;
11267 set_vertical_scroll_bar_hook
= w32_set_vertical_scroll_bar
;
11268 condemn_scroll_bars_hook
= w32_condemn_scroll_bars
;
11269 redeem_scroll_bar_hook
= w32_redeem_scroll_bar
;
11270 judge_scroll_bars_hook
= w32_judge_scroll_bars
;
11271 estimate_mode_line_height_hook
= x_estimate_mode_line_height
;
11273 scroll_region_ok
= 1; /* we'll scroll partial frames */
11274 char_ins_del_ok
= 1;
11275 line_ins_del_ok
= 1; /* we'll just blt 'em */
11276 fast_clear_end_of_line
= 1; /* X does this well */
11277 memory_below_frame
= 0; /* we don't remember what scrolls
11281 w32_system_caret_hwnd
= NULL
;
11282 w32_system_caret_height
= 0;
11283 w32_system_caret_x
= 0;
11284 w32_system_caret_y
= 0;
11286 last_tool_bar_item
= -1;
11287 any_help_event_p
= 0;
11289 /* Initialize input mode: interrupt_input off, no flow control, allow
11290 8 bit character input, standard quit char. */
11291 Fset_input_mode (Qnil
, Qnil
, make_number (2), Qnil
);
11293 /* Create the window thread - it will terminate itself or when the app terminates */
11297 dwMainThreadId
= GetCurrentThreadId ();
11298 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
11299 GetCurrentProcess (), &hMainThread
, 0, TRUE
, DUPLICATE_SAME_ACCESS
);
11301 /* Wait for thread to start */
11306 PeekMessage (&msg
, NULL
, 0, 0, PM_NOREMOVE
);
11308 hWindowsThread
= CreateThread (NULL
, 0,
11309 (LPTHREAD_START_ROUTINE
) w32_msg_worker
,
11310 0, 0, &dwWindowsThreadId
);
11312 GetMessage (&msg
, NULL
, WM_EMACS_DONE
, WM_EMACS_DONE
);
11315 /* It is desirable that mainThread should have the same notion of
11316 focus window and active window as windowsThread. Unfortunately, the
11317 following call to AttachThreadInput, which should do precisely what
11318 we need, causes major problems when Emacs is linked as a console
11319 program. Unfortunately, we have good reasons for doing that, so
11320 instead we need to send messages to windowsThread to make some API
11321 calls for us (ones that affect, or depend on, the active/focus
11323 #ifdef ATTACH_THREADS
11324 AttachThreadInput (dwMainThreadId
, dwWindowsThreadId
, TRUE
);
11327 /* Dynamically link to optional system components. */
11329 HANDLE user_lib
= LoadLibrary ("user32.dll");
11331 #define LOAD_PROC(fn) pfn##fn = (void *) GetProcAddress (user_lib, #fn)
11333 /* New proportional scroll bar functions. */
11334 LOAD_PROC (SetScrollInfo
);
11335 LOAD_PROC (GetScrollInfo
);
11339 FreeLibrary (user_lib
);
11341 /* If using proportional scroll bars, ensure handle is at least 5 pixels;
11342 otherwise use the fixed height. */
11343 vertical_scroll_bar_min_handle
= (pfnSetScrollInfo
!= NULL
) ? 5 :
11344 GetSystemMetrics (SM_CYVTHUMB
);
11346 /* For either kind of scroll bar, take account of the arrows; these
11347 effectively form the border of the main scroll bar range. */
11348 vertical_scroll_bar_top_border
= vertical_scroll_bar_bottom_border
11349 = GetSystemMetrics (SM_CYVSCROLL
);
11356 staticpro (&w32_display_name_list
);
11357 w32_display_name_list
= Qnil
;
11359 staticpro (&last_mouse_scroll_bar
);
11360 last_mouse_scroll_bar
= Qnil
;
11362 staticpro (&Qvendor_specific_keysyms
);
11363 Qvendor_specific_keysyms
= intern ("vendor-specific-keysyms");
11365 DEFVAR_INT ("w32-num-mouse-buttons",
11366 &Vw32_num_mouse_buttons
,
11367 doc
: /* Number of physical mouse buttons. */);
11368 Vw32_num_mouse_buttons
= Qnil
;
11370 DEFVAR_LISP ("w32-swap-mouse-buttons",
11371 &Vw32_swap_mouse_buttons
,
11372 doc
: /* Swap the mapping of middle and right mouse buttons.
11373 When nil, middle button is mouse-2 and right button is mouse-3. */);
11374 Vw32_swap_mouse_buttons
= Qnil
;
11376 DEFVAR_LISP ("w32-grab-focus-on-raise",
11377 &Vw32_grab_focus_on_raise
,
11378 doc
: /* Raised frame grabs input focus.
11379 When t, `raise-frame' grabs input focus as well. This fits well
11380 with the normal Windows click-to-focus policy, but might not be
11381 desirable when using a point-to-focus policy. */);
11382 Vw32_grab_focus_on_raise
= Qt
;
11384 DEFVAR_LISP ("w32-capslock-is-shiftlock",
11385 &Vw32_capslock_is_shiftlock
,
11386 doc
: /* Apply CapsLock state to non character input keys.
11387 When nil, CapsLock only affects normal character input keys. */);
11388 Vw32_capslock_is_shiftlock
= Qnil
;
11390 DEFVAR_LISP ("w32-recognize-altgr",
11391 &Vw32_recognize_altgr
,
11392 doc
: /* Recognize right-alt and left-ctrl as AltGr.
11393 When nil, the right-alt and left-ctrl key combination is
11394 interpreted normally. */);
11395 Vw32_recognize_altgr
= Qt
;
11397 DEFVAR_BOOL ("w32-enable-unicode-output",
11398 &w32_enable_unicode_output
,
11399 doc
: /* Enable the use of Unicode for text output if non-nil.
11400 Unicode output may prevent some third party applications for displaying
11401 Far-East Languages on Windows 95/98 from working properly.
11402 NT uses Unicode internally anyway, so this flag will probably have no
11403 affect on NT machines. */);
11404 w32_enable_unicode_output
= 1;
11407 staticpro (&help_echo
);
11408 help_echo_object
= Qnil
;
11409 staticpro (&help_echo_object
);
11410 help_echo_window
= Qnil
;
11411 staticpro (&help_echo_window
);
11412 previous_help_echo
= Qnil
;
11413 staticpro (&previous_help_echo
);
11414 help_echo_pos
= -1;
11416 DEFVAR_BOOL ("mouse-autoselect-window", &mouse_autoselect_window
,
11417 doc
: /* *Non-nil means autoselect window with mouse pointer. */);
11418 mouse_autoselect_window
= 0;
11420 DEFVAR_BOOL ("w32-use-visible-system-caret",
11421 &w32_use_visible_system_caret
,
11422 doc
: /* Flag to make the system caret visible.
11423 When this is non-nil, Emacs will indicate the position of point by
11424 using the system caret instead of drawing its own cursor. Some screen
11425 reader software does not track the system cursor properly when it is
11426 invisible, and gets confused by Emacs drawing its own cursor, so this
11427 variable is initialized to t when Emacs detects that screen reader
11428 software is running as it starts up.
11430 When this variable is set, other variables affecting the appearance of
11431 the cursor have no effect. */);
11433 /* Initialize w32_use_visible_system_caret based on whether a screen
11434 reader is in use. */
11435 if (!SystemParametersInfo (SPI_GETSCREENREADER
, 0,
11436 &w32_use_visible_system_caret
, 0))
11437 w32_use_visible_system_caret
= 0;
11439 DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p
,
11440 doc
: /* *Non-nil means draw block cursor as wide as the glyph under it.
11441 For example, if a block cursor is over a tab, it will be drawn as
11442 wide as that tab on the display. */);
11443 x_stretch_cursor_p
= 0;
11445 DEFVAR_BOOL ("x-use-underline-position-properties",
11446 &x_use_underline_position_properties
,
11447 doc
: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
11448 nil means ignore them. If you encounter fonts with bogus
11449 UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
11450 to 4.1, set this to nil. */);
11451 x_use_underline_position_properties
= 1;
11453 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars
,
11454 doc
: /* If not nil, Emacs uses toolkit scroll bars. */);
11455 Vx_toolkit_scroll_bars
= Qt
;
11457 staticpro (&last_mouse_motion_frame
);
11458 last_mouse_motion_frame
= Qnil
;