aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2000-08-20 21:08:43 +0000
committerJason Rumney2000-08-20 21:08:43 +0000
commit158cba563f2eed5806264f624559af2e50a54a3f (patch)
tree13c1b6cd40e06e155071982984707510357b9359 /src
parent5a7ab57adc40e2bc5147d7015bde32f163821d4f (diff)
downloademacs-158cba563f2eed5806264f624559af2e50a54a3f.tar.gz
emacs-158cba563f2eed5806264f624559af2e50a54a3f.zip
(help_echo_window): New variable.
(syms_of_w32term): staticpro it. (note_mode_line_highlight): Set it. (XTextExtents16): Removed as there is no equivalent on W32. (x_compute_glyph_string_overhangs): Incomplete body removed, as the X way of doing this will not work for W32. (w32_intersect_rectangles): Removed. Use IntersectRect API call. (x_draw_image_foreground): Avoid drawing outside of the clip area when image doesn't have a mask. (note_mouse_highlight): Process overlays in the right order of priority. Set help_echo_window. (x_draw_bar_cursor): If cursor is on an image, draw a box cursor because that's more visible for large images.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c165
1 files changed, 59 insertions, 106 deletions
diff --git a/src/w32term.c b/src/w32term.c
index ba2b14d19ff..b1dee9274c6 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -161,6 +161,7 @@ int x_toolkit_scroll_bars_p;
161 (The display is done in read_char.) */ 161 (The display is done in read_char.) */
162 162
163static Lisp_Object help_echo; 163static Lisp_Object help_echo;
164static Lisp_Object help_echo_window;
164static Lisp_Object help_echo_object; 165static Lisp_Object help_echo_object;
165static int help_echo_pos; 166static int help_echo_pos;
166 167
@@ -383,7 +384,6 @@ static void w32_frame_rehighlight P_ ((struct frame *));
383static void x_frame_rehighlight P_ ((struct w32_display_info *)); 384static void x_frame_rehighlight P_ ((struct w32_display_info *));
384static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 385static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
385static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int)); 386static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int));
386static int w32_intersect_rectangles P_ ((RECT *, RECT *, RECT *));
387static void expose_frame P_ ((struct frame *, int, int, int, int)); 387static void expose_frame P_ ((struct frame *, int, int, int, int));
388static void expose_window_tree P_ ((struct window *, RECT *)); 388static void expose_window_tree P_ ((struct window *, RECT *));
389static void expose_window P_ ((struct window *, RECT *)); 389static void expose_window P_ ((struct window *, RECT *));
@@ -470,13 +470,6 @@ void XGetGCValues (void* ignore, XGCValues *gc,
470 XChangeGC (ignore, xgcv, mask, gc); 470 XChangeGC (ignore, xgcv, mask, gc);
471} 471}
472 472
473void XTextExtents16 (XFontStruct *font, wchar_t *text, int nchars,
474 int *direction,int *font_ascent,
475 int *font_descent, XCharStruct *cs)
476{
477 /* NTEMACS_TODO: Use GetTextMetrics to do this and inline it below. */
478}
479
480static void 473static void
481w32_set_clip_rectangle (HDC hdc, RECT *rect) 474w32_set_clip_rectangle (HDC hdc, RECT *rect)
482{ 475{
@@ -1158,7 +1151,7 @@ w32_per_char_metric (hdc, font, char2b, font_type)
1158 else if (!w32_enable_unicode_output) 1151 else if (!w32_enable_unicode_output)
1159 font_type = ANSI_FONT; 1152 font_type = ANSI_FONT;
1160 else 1153 else
1161 font_type = UNICODE_FONT; /* NTEMACS_TODO: Need encoding? */ 1154 font_type = UNICODE_FONT;
1162 } 1155 }
1163 1156
1164 pcm = (XCharStruct *) xmalloc (sizeof (XCharStruct)); 1157 pcm = (XCharStruct *) xmalloc (sizeof (XCharStruct));
@@ -2648,16 +2641,9 @@ static INLINE void
2648x_compute_glyph_string_overhangs (s) 2641x_compute_glyph_string_overhangs (s)
2649 struct glyph_string *s; 2642 struct glyph_string *s;
2650{ 2643{
2651 if (s->cmp == NULL 2644 /* NTEMACS_TODO: Windows does not appear to have a method for
2652 && s->first_glyph->type == CHAR_GLYPH) 2645 getting this info without getting the ABC widths for each
2653 { 2646 individual character and working it out manually. */
2654 XCharStruct cs;
2655 int direction, font_ascent, font_descent;
2656 XTextExtents16 (s->font, s->char2b, s->nchars, &direction,
2657 &font_ascent, &font_descent, &cs);
2658 s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0;
2659 s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0;
2660 }
2661} 2647}
2662 2648
2663 2649
@@ -3366,7 +3352,7 @@ x_draw_image_foreground (s)
3366 image_rect.y = y; 3352 image_rect.y = y;
3367 image_rect.width = s->img->width; 3353 image_rect.width = s->img->width;
3368 image_rect.height = s->img->height; 3354 image_rect.height = s->img->height;
3369 if (w32_intersect_rectangles (&clip_rect, &image_rect, &r)) 3355 if (IntersectRect (&r, &clip_rect, &image_rect))
3370 XCopyArea (s->display, s->img->pixmap, s->window, s->gc, 3356 XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
3371 r.x - x, r.y - y, r.width, r.height, r.x, r.y); 3357 r.x - x, r.y - y, r.width, r.height, r.x, r.y);
3372 } 3358 }
@@ -3377,6 +3363,7 @@ x_draw_image_foreground (s)
3377 HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground); 3363 HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground);
3378 HBRUSH orig_brush = SelectObject (s->hdc, fg_brush); 3364 HBRUSH orig_brush = SelectObject (s->hdc, fg_brush);
3379 HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap); 3365 HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap);
3366 x_set_glyph_string_clipping (s);
3380 3367
3381 SetTextColor (s->hdc, s->gc->foreground); 3368 SetTextColor (s->hdc, s->gc->foreground);
3382 SetBkColor (s->hdc, s->gc->background); 3369 SetBkColor (s->hdc, s->gc->background);
@@ -3401,6 +3388,7 @@ x_draw_image_foreground (s)
3401 if (s->hl == DRAW_CURSOR) 3388 if (s->hl == DRAW_CURSOR)
3402 w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width - 1, 3389 w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width - 1,
3403 s->img->height - 1); 3390 s->img->height - 1);
3391 w32_set_clip_rectangle(s->hdc, NULL);
3404 } 3392 }
3405 } 3393 }
3406 else 3394 else
@@ -4968,7 +4956,7 @@ expose_frame (f, x, y, w, h)
4968 window_rect.right = window_x + window_width; 4956 window_rect.right = window_x + window_width;
4969 window_rect.bottom = window_y + window_height; 4957 window_rect.bottom = window_y + window_height;
4970 4958
4971 if (w32_intersect_rectangles (&r, &window_rect, &intersection_rect)) 4959 if (IntersectRect (&intersection_rect, &r, &window_rect))
4972 expose_window (w, &intersection_rect); 4960 expose_window (w, &intersection_rect);
4973 } 4961 }
4974} 4962}
@@ -5010,7 +4998,7 @@ expose_window_tree (w, r)
5010 window_rect.bottom = window_rect.top 4998 window_rect.bottom = window_rect.top
5011 + window_height + CURRENT_MODE_LINE_HEIGHT (w); 4999 + window_height + CURRENT_MODE_LINE_HEIGHT (w);
5012 5000
5013 if (w32_intersect_rectangles (r, &window_rect, &intersection_rect)) 5001 if (IntersectRect (&intersection_rect, r, &window_rect))
5014 expose_window (w, &intersection_rect); 5002 expose_window (w, &intersection_rect);
5015 } 5003 }
5016 5004
@@ -5128,7 +5116,7 @@ x_phys_cursor_in_rect_p (w, r)
5128 cr.top = w->phys_cursor.y; 5116 cr.top = w->phys_cursor.y;
5129 cr.right = cr.left + cursor_glyph->pixel_width; 5117 cr.right = cr.left + cursor_glyph->pixel_width;
5130 cr.bottom = cr.top + w->phys_cursor_height; 5118 cr.bottom = cr.top + w->phys_cursor_height;
5131 return w32_intersect_rectangles (&cr, r, &result); 5119 return IntersectRect (&result, &cr, r);
5132 } 5120 }
5133 else 5121 else
5134 return 0; 5122 return 0;
@@ -5213,60 +5201,6 @@ expose_window (w, r)
5213 } 5201 }
5214} 5202}
5215 5203
5216
5217/* Determine the intersection of two rectangles R1 and R2. Return
5218 the intersection in *RESULT. Value is non-zero if RESULT is not
5219 empty. */
5220
5221static int
5222w32_intersect_rectangles (r1, r2, result)
5223 RECT *r1, *r2, *result;
5224{
5225 RECT *left, *right;
5226 RECT *upper, *lower;
5227 int intersection_p = 0;
5228
5229 /* Rerrange so that R1 is the left-most rectangle. */
5230 if (r1->left < r2->left)
5231 left = r1, right = r2;
5232 else
5233 left = r2, right = r1;
5234
5235 /* X0 of the intersection is right.x0, if this is inside R1,
5236 otherwise there is no intersection. */
5237 if (right->left <= left->right)
5238 {
5239 result->left = right->left;
5240
5241 /* The right end of the intersection is the minimum of the
5242 the right ends of left and right. */
5243 result->right = min (left->right, right->right);
5244
5245 /* Same game for Y. */
5246 if (r1->top < r2->top)
5247 upper = r1, lower = r2;
5248 else
5249 upper = r2, lower = r1;
5250
5251 /* The upper end of the intersection is lower.y0, if this is inside
5252 of upper. Otherwise, there is no intersection. */
5253 if (lower->top <= upper->bottom)
5254 {
5255 result->top = lower->top;
5256
5257 /* The lower end of the intersection is the minimum of the lower
5258 ends of upper and lower. */
5259 result->bottom = min (lower->bottom, upper->bottom);
5260 intersection_p = 1;
5261 }
5262 }
5263
5264 return intersection_p;
5265}
5266
5267
5268
5269
5270 5204
5271static void 5205static void
5272frame_highlight (f) 5206frame_highlight (f)
@@ -5867,6 +5801,7 @@ note_mode_line_highlight (w, x, mode_line_p)
5867 if (!NILP (help)) 5801 if (!NILP (help))
5868 { 5802 {
5869 help_echo = help; 5803 help_echo = help;
5804 XSETWINDOW (help_echo_window, w);
5870 help_echo_object = glyph->object; 5805 help_echo_object = glyph->object;
5871 help_echo_pos = glyph->charpos; 5806 help_echo_pos = glyph->charpos;
5872 } 5807 }
@@ -6020,6 +5955,7 @@ note_mouse_highlight (f, x, y)
6020 noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL,0); 5955 noverlays = overlays_at (pos, 0, &overlay_vec, &len, NULL, NULL,0);
6021 } 5956 }
6022 5957
5958 /* Sort overlays into increasing priority order. */
6023 noverlays = sort_overlays (overlay_vec, noverlays, w); 5959 noverlays = sort_overlays (overlay_vec, noverlays, w);
6024 5960
6025 /* Check mouse-face highlighting. */ 5961 /* Check mouse-face highlighting. */
@@ -6037,7 +5973,7 @@ note_mouse_highlight (f, x, y)
6037 5973
6038 /* Find the highest priority overlay that has a mouse-face prop. */ 5974 /* Find the highest priority overlay that has a mouse-face prop. */
6039 overlay = Qnil; 5975 overlay = Qnil;
6040 for (i = 0; i < noverlays; i++) 5976 for (i = noverlays - 1; i >= 0; --i)
6041 { 5977 {
6042 mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face); 5978 mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
6043 if (!NILP (mouse_face)) 5979 if (!NILP (mouse_face))
@@ -6123,17 +6059,21 @@ note_mouse_highlight (f, x, y)
6123 6059
6124 /* Look for a `help-echo' property. */ 6060 /* Look for a `help-echo' property. */
6125 { 6061 {
6126 Lisp_Object help; 6062 Lisp_Object help, overlay;
6127 6063
6128 /* Check overlays first. */ 6064 /* Check overlays first. */
6129 help = Qnil; 6065 help = Qnil;
6130 for (i = 0; i < noverlays && NILP (help); ++i) 6066 for (i = noverlays - 1; i >= 0 && NILP (help); --i)
6131 help = Foverlay_get (overlay_vec[i], Qhelp_echo); 6067 {
6068 overlay = overlay_vec[i];
6069 help = Foverlay_get (overlay, Qhelp_echo);
6070 }
6132 6071
6133 if (!NILP (help)) 6072 if (!NILP (help))
6134 { 6073 {
6135 help_echo = help; 6074 help_echo = help;
6136 help_echo_object = w->buffer; 6075 help_echo_window = window;
6076 help_echo_object = overlay;
6137 help_echo_pos = pos; 6077 help_echo_pos = pos;
6138 } 6078 }
6139 else 6079 else
@@ -6151,6 +6091,7 @@ note_mouse_highlight (f, x, y)
6151 if (!NILP (help)) 6091 if (!NILP (help))
6152 { 6092 {
6153 help_echo = help; 6093 help_echo = help;
6094 help_echo_window = window;
6154 help_echo_object = glyph->object; 6095 help_echo_object = glyph->object;
6155 help_echo_pos = glyph->charpos; 6096 help_echo_pos = glyph->charpos;
6156 } 6097 }
@@ -6385,7 +6326,7 @@ note_tool_bar_highlight (f, x, y)
6385 6326
6386 /* Set help_echo to a help string.to display for this tool-bar item. 6327 /* Set help_echo to a help string.to display for this tool-bar item.
6387 w32_read_socket does the rest. */ 6328 w32_read_socket does the rest. */
6388 help_echo_object = Qnil; 6329 help_echo_object = help_echo_window = Qnil;
6389 help_echo_pos = -1; 6330 help_echo_pos = -1;
6390 help_echo = (XVECTOR (f->current_tool_bar_items) 6331 help_echo = (XVECTOR (f->current_tool_bar_items)
6391 ->contents[prop_idx + TOOL_BAR_ITEM_HELP]); 6332 ->contents[prop_idx + TOOL_BAR_ITEM_HELP]);
@@ -7701,7 +7642,8 @@ w32_read_socket (sd, bufp, numchars, expected)
7701 7642
7702 case WM_MOUSEMOVE: 7643 case WM_MOUSEMOVE:
7703 previous_help_echo = help_echo; 7644 previous_help_echo = help_echo;
7704 help_echo = Qnil; 7645 help_echo = help_echo_object = help_echo_window = Qnil;
7646 help_echo_pos = -1;
7705 7647
7706 if (dpyinfo->grabbed && last_mouse_frame 7648 if (dpyinfo->grabbed && last_mouse_frame
7707 && FRAME_LIVE_P (last_mouse_frame)) 7649 && FRAME_LIVE_P (last_mouse_frame))
@@ -7732,7 +7674,7 @@ w32_read_socket (sd, bufp, numchars, expected)
7732 frame = Qnil; 7674 frame = Qnil;
7733 7675
7734 any_help_event_p = 1; 7676 any_help_event_p = 1;
7735 n = gen_help_event (bufp, help_echo, frame, 7677 n = gen_help_event (bufp, help_echo, frame, help_echo_window,
7736 help_echo_object, help_echo_pos); 7678 help_echo_object, help_echo_pos);
7737 bufp += n, count += n, numchars -= n; 7679 bufp += n, count += n, numchars -= n;
7738 } 7680 }
@@ -8059,7 +8001,7 @@ w32_read_socket (sd, bufp, numchars, expected)
8059 int n; 8001 int n;
8060 8002
8061 XSETFRAME (frame, f); 8003 XSETFRAME (frame, f);
8062 n = gen_help_event (bufp, Qnil, frame, Qnil, 0); 8004 n = gen_help_event (bufp, Qnil, frame, Qnil, Qnil, 0);
8063 bufp += n, count += n, numchars -=n; 8005 bufp += n, count += n, numchars -=n;
8064 } 8006 }
8065 } 8007 }
@@ -8364,18 +8306,31 @@ x_draw_bar_cursor (w, row, width)
8364 if (cursor_glyph == NULL) 8306 if (cursor_glyph == NULL)
8365 return; 8307 return;
8366 8308
8367 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 8309 /* If on an image, draw like a normal cursor. That's usually better
8310 visible than drawing a bar, esp. if the image is large so that
8311 the bar might not be in the window. */
8312 if (cursor_glyph->type == IMAGE_GLYPH)
8313 {
8314 struct glyph_row *row;
8315 row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos);
8316 x_draw_phys_cursor_glyph (w, row, DRAW_CURSOR);
8317 }
8318 else
8319 {
8368 8320
8369 if (width < 0) 8321 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
8370 width = f->output_data.w32->cursor_width;
8371 8322
8372 hdc = get_frame_dc (f); 8323 if (width < 0)
8373 w32_fill_area (f, hdc, f->output_data.w32->cursor_pixel, 8324 width = f->output_data.w32->cursor_width;
8374 x, 8325
8375 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), 8326 hdc = get_frame_dc (f);
8376 min (cursor_glyph->pixel_width, width), 8327 w32_fill_area (f, hdc, f->output_data.w32->cursor_pixel,
8377 row->height); 8328 x,
8378 release_frame_dc (f, hdc); 8329 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
8330 min (cursor_glyph->pixel_width, width),
8331 row->height);
8332 release_frame_dc (f, hdc);
8333 }
8379 } 8334 }
8380} 8335}
8381 8336
@@ -8902,17 +8857,12 @@ x_font_min_bounds (font, w, h)
8902 XFontStruct *font; 8857 XFontStruct *font;
8903 int *w, *h; 8858 int *w, *h;
8904{ 8859{
8860 /*
8861 * NTEMACS_TODO: Windows does not appear to offer min bound, only
8862 * average and maximum width, and maximum height.
8863 */
8905 *h = FONT_HEIGHT (font); 8864 *h = FONT_HEIGHT (font);
8906 *w = FONT_WIDTH (font); 8865 *w = FONT_WIDTH (font);
8907#if 0 /* NTEMACS_TODO: min/max bounds of Windows fonts */
8908 *w = font->min_bounds.width;
8909
8910 /* Try to handle the case where FONT->min_bounds has invalid
8911 contents. Since the only font known to have invalid min_bounds
8912 is fixed-width, use max_bounds if min_bounds seems to be invalid. */
8913 if (*w <= 0)
8914 *w = font->max_bounds.width;
8915#endif
8916} 8866}
8917 8867
8918 8868
@@ -9002,7 +8952,7 @@ x_calc_absolute_position (f)
9002 - 2 * f->output_data.w32->border_width - pt.x 8952 - 2 * f->output_data.w32->border_width - pt.x
9003 - PIXEL_WIDTH (f) 8953 - PIXEL_WIDTH (f)
9004 + f->output_data.w32->left_pos); 8954 + f->output_data.w32->left_pos);
9005 /* NTEMACS_TODO: Subtract menubar height? */ 8955
9006 if (flags & YNegative) 8956 if (flags & YNegative)
9007 f->output_data.w32->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height 8957 f->output_data.w32->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height
9008 - 2 * f->output_data.w32->border_width - pt.y 8958 - 2 * f->output_data.w32->border_width - pt.y
@@ -9877,8 +9827,11 @@ affect on NT machines.");
9877 staticpro (&help_echo); 9827 staticpro (&help_echo);
9878 help_echo_object = Qnil; 9828 help_echo_object = Qnil;
9879 staticpro (&help_echo_object); 9829 staticpro (&help_echo_object);
9830 help_echo_window = Qnil;
9831 staticpro (&help_echo_window);
9880 previous_help_echo = Qnil; 9832 previous_help_echo = Qnil;
9881 staticpro (&previous_help_echo); 9833 staticpro (&previous_help_echo);
9834 help_echo_pos = -1;
9882 9835
9883 DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p, 9836 DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p,
9884 "*Non-nil means draw block cursor as wide as the glyph under it.\n\ 9837 "*Non-nil means draw block cursor as wide as the glyph under it.\n\