\f
/* Fringe bitmaps. */
-static HBITMAP fringe_bmp[MAX_FRINGE_BITMAPS];
+static int max_fringe_bmp = 0;
+static HBITMAP *fringe_bmp = 0;
/* Non-nil means Emacs uses toolkit scroll bars. */
static RECT last_mouse_glyph;
static Lisp_Object last_mouse_press_frame;
-Lisp_Object Vw32_num_mouse_buttons;
+int w32_num_mouse_buttons;
Lisp_Object Vw32_swap_mouse_buttons;
static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
enum text_cursor_kinds));
-static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, HDC));
+static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, int, HDC));
static Lisp_Object Qvendor_specific_keysyms;
output_cursor.vpos,
output_cursor.x, output_cursor.y);
- x_draw_vertical_border (w);
-
- draw_window_fringes (w);
+ if (draw_window_fringes (w, 1))
+ x_draw_vertical_border (w);
UNBLOCK_INPUT;
}
int oldVH = row->visible_height;
row->visible_height = p->h;
row->y -= rowY - p->y;
- w32_clip_to_row (w, row, hdc);
+ w32_clip_to_row (w, row, -1, hdc);
row->y = oldY;
row->visible_height = oldVH;
}
else
- w32_clip_to_row (w, row, hdc);
+ w32_clip_to_row (w, row, -1, hdc);
if (p->bx >= 0 && !p->overlay_p)
{
p->bx, p->by, p->nx, p->ny);
}
- if (p->which)
+ if (p->which && p->which < max_fringe_bmp)
{
HBITMAP pixmap = fringe_bmp[p->which];
HDC compat_hdc;
unsigned short *bits;
int h, wd;
{
+ if (which >= max_fringe_bmp)
+ {
+ int i = max_fringe_bmp;
+ max_fringe_bmp = which + 20;
+ fringe_bmp = (HBITMAP *) xrealloc (fringe_bmp, max_fringe_bmp * sizeof (HBITMAP));
+ while (i < max_fringe_bmp)
+ fringe_bmp[i++] = 0;
+ }
+
fringe_bmp[which] = CreateBitmap (wd, h, 1, 1, bits);
}
w32_destroy_fringe_bitmap (which)
int which;
{
+ if (which >= max_fringe_bmp)
+ return;
+
if (fringe_bmp[which])
DeleteObject (fringe_bmp[which]);
fringe_bmp[which] = 0;
}
-
static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
static void x_set_glyph_string_gc P_ ((struct glyph_string *));
static void x_draw_glyph_string_background P_ ((struct glyph_string *,
static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
int, int, int));
static void w32_draw_relief_rect P_ ((struct frame *, int, int, int, int,
- int, int, int, int, RECT *));
+ int, int, int, int, int, int,
+ RECT *));
static void w32_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
int, int, int, RECT *));
static void
w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
- raised_p, left_p, right_p, clip_rect)
+ raised_p, top_p, bot_p, left_p, right_p, clip_rect)
struct frame *f;
- int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p;
+ int left_x, top_y, right_x, bottom_y, width;
+ int top_p, bot_p, left_p, right_p, raised_p;
RECT *clip_rect;
{
int i;
w32_set_clip_rectangle (hdc, clip_rect);
/* Top. */
- for (i = 0; i < width; ++i)
- w32_fill_area (f, hdc, gc.foreground,
- left_x + i * left_p, top_y + i,
- right_x - left_x - i * (left_p + right_p ) + 1, 1);
+ if (top_p)
+ for (i = 0; i < width; ++i)
+ w32_fill_area (f, hdc, gc.foreground,
+ left_x + i * left_p, top_y + i,
+ right_x - left_x - i * (left_p + right_p ) + 1, 1);
/* Left. */
if (left_p)
gc.foreground = f->output_data.w32->white_relief.gc->foreground;
/* Bottom. */
- for (i = 0; i < width; ++i)
- w32_fill_area (f, hdc, gc.foreground,
- left_x + i * left_p, bottom_y - i,
- right_x - left_x - i * (left_p + right_p) + 1, 1);
+ if (bot_p)
+ for (i = 0; i < width; ++i)
+ w32_fill_area (f, hdc, gc.foreground,
+ left_x + i * left_p, bottom_y - i,
+ right_x - left_x - i * (left_p + right_p) + 1, 1);
/* Right. */
if (right_p)
{
x_setup_relief_colors (s);
w32_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
- width, raised_p, left_p, right_p, &clip_rect);
+ width, raised_p, 1, 1, left_p, right_p, &clip_rect);
}
}
x_draw_image_foreground (s)
struct glyph_string *s;
{
- int x;
- int y = s->ybase - image_ascent (s->img, s->face);
+ int x = s->x;
+ int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
/* If first glyph of S has a left box line, start drawing it to the
right of that line. */
if (s->face->box != FACE_NO_BOX
- && s->first_glyph->left_box_line_p)
- x = s->x + abs (s->face->box_line_width);
- else
- x = s->x;
+ && s->first_glyph->left_box_line_p
+ && s->slice.x == 0)
+ x += abs (s->face->box_line_width);
/* If there is a margin around the image, adjust x- and y-position
by that margin. */
- x += s->img->hmargin;
- y += s->img->vmargin;
+ if (s->slice.x == 0)
+ x += s->img->hmargin;
+ if (s->slice.y == 0)
+ y += s->img->vmargin;
SaveDC (s->hdc);
SetTextColor (s->hdc, RGB (255, 255, 255));
SetBkColor (s->hdc, RGB (0, 0, 0));
- BitBlt (s->hdc, x, y, s->img->width, s->img->height,
- compat_hdc, 0, 0, SRCINVERT);
- BitBlt (s->hdc, x, y, s->img->width, s->img->height,
- mask_dc, 0, 0, SRCAND);
- BitBlt (s->hdc, x, y, s->img->width, s->img->height,
- compat_hdc, 0, 0, SRCINVERT);
+ BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+ compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
+ BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+ mask_dc, s->slice.x, s->slice.y, SRCAND);
+ BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+ compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
SelectObject (mask_dc, mask_orig_obj);
DeleteDC (mask_dc);
SetTextColor (s->hdc, s->gc->foreground);
SetBkColor (s->hdc, s->gc->background);
- BitBlt (s->hdc, x, y, s->img->width, s->img->height,
- compat_hdc, 0, 0, SRCCOPY);
+ BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+ compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
/* When the image has a mask, we can expect that at
least part of a mouse highlight or a block cursor will
int r = s->img->relief;
if (r < 0) r = -r;
w32_draw_rectangle (s->hdc, s->gc, x - r, y - r ,
- s->img->width + r*2 - 1, s->img->height + r*2 - 1);
+ s->slice.width + r*2 - 1,
+ s->slice.height + r*2 - 1);
}
}
DeleteDC (compat_hdc);
}
else
- w32_draw_rectangle (s->hdc, s->gc, x, y, s->img->width -1,
- s->img->height - 1);
+ w32_draw_rectangle (s->hdc, s->gc, x, y,
+ s->slice.width - 1, s->slice.height - 1);
RestoreDC (s->hdc ,-1);
}
-
/* Draw a relief around the image glyph string S. */
static void
{
int x0, y0, x1, y1, thick, raised_p;
RECT r;
- int x;
- int y = s->ybase - image_ascent (s->img, s->face);
+ int x = s->x;
+ int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
/* If first glyph of S has a left box line, start drawing it to the
right of that line. */
if (s->face->box != FACE_NO_BOX
- && s->first_glyph->left_box_line_p)
- x = s->x + abs (s->face->box_line_width);
- else
- x = s->x;
+ && s->first_glyph->left_box_line_p
+ && s->slice.x == 0)
+ x += abs (s->face->box_line_width);
/* If there is a margin around the image, adjust x- and y-position
by that margin. */
- x += s->img->hmargin;
- y += s->img->vmargin;
+ if (s->slice.x == 0)
+ x += s->img->hmargin;
+ if (s->slice.y == 0)
+ y += s->img->vmargin;
if (s->hl == DRAW_IMAGE_SUNKEN
|| s->hl == DRAW_IMAGE_RAISED)
x0 = x - thick;
y0 = y - thick;
- x1 = x + s->img->width + thick - 1;
- y1 = y + s->img->height + thick - 1;
+ x1 = x + s->slice.width + thick - 1;
+ y1 = y + s->slice.height + thick - 1;
x_setup_relief_colors (s);
get_glyph_string_clip_rect (s, &r);
- w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);
+ w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
+ s->slice.y == 0,
+ s->slice.y + s->slice.height == s->img->height,
+ s->slice.x == 0,
+ s->slice.x + s->slice.width == s->img->width,
+ &r);
}
{
HDC hdc = CreateCompatibleDC (s->hdc);
HGDIOBJ orig_hdc_obj = SelectObject (hdc, pixmap);
- int x;
- int y = s->ybase - s->y - image_ascent (s->img, s->face);
+ int x = 0;
+ int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
/* If first glyph of S has a left box line, start drawing it to the
right of that line. */
if (s->face->box != FACE_NO_BOX
- && s->first_glyph->left_box_line_p)
- x = abs (s->face->box_line_width);
- else
- x = 0;
+ && s->first_glyph->left_box_line_p
+ && s->slice.x == 0)
+ x += abs (s->face->box_line_width);
/* If there is a margin around the image, adjust x- and y-position
by that margin. */
- x += s->img->hmargin;
- y += s->img->vmargin;
+ if (s->slice.x == 0)
+ x += s->img->hmargin;
+ if (s->slice.y == 0)
+ y += s->img->vmargin;
if (s->img->pixmap)
{
SetTextColor (hdc, RGB (0, 0, 0));
SetBkColor (hdc, RGB (255, 255, 255));
- BitBlt (hdc, x, y, s->img->width, s->img->height,
- compat_hdc, 0, 0, SRCINVERT);
- BitBlt (hdc, x, y, s->img->width, s->img->height,
- mask_dc, 0, 0, SRCAND);
- BitBlt (hdc, x, y, s->img->width, s->img->height,
- compat_hdc, 0, 0, SRCINVERT);
+ BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+ compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
+ BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+ mask_dc, s->slice.x, s->slice.y, SRCAND);
+ BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+ compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
SelectObject (mask_dc, mask_orig_obj);
DeleteDC (mask_dc);
SetTextColor (hdc, s->gc->foreground);
SetBkColor (hdc, s->gc->background);
- BitBlt (hdc, x, y, s->img->width, s->img->height,
- compat_hdc, 0, 0, SRCCOPY);
+ BitBlt (hdc, x, y, s->slice.width, s->slice.height,
+ compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
/* When the image has a mask, we can expect that at
least part of a mouse highlight or a block cursor will
{
int r = s->img->relief;
if (r < 0) r = -r;
- w32_draw_rectangle (hdc, s->gc, x - r, y - r ,
- s->img->width + r*2 - 1, s->img->height + r*2 - 1);
+ w32_draw_rectangle (hdc, s->gc, x - r, y - r,
+ s->slice.width + r*2 - 1,
+ s->slice.height + r*2 - 1);
}
}
DeleteDC (compat_hdc);
}
else
- w32_draw_rectangle (hdc, s->gc, x, y, s->img->width - 1,
- s->img->height - 1);
+ w32_draw_rectangle (hdc, s->gc, x, y,
+ s->slice.width - 1, s->slice.height - 1);
SelectObject (hdc, orig_hdc_obj);
DeleteDC (hdc);
taller than image or if image has a clip mask to reduce
flickering. */
s->stippled_p = s->face->stipple != 0;
- if (height > s->img->height
+ if (height > s->slice.height
|| s->img->hmargin
|| s->img->vmargin
|| s->img->mask
|| s->img->pixmap == 0
|| s->width != s->background_width)
{
- if (box_line_hwidth && s->first_glyph->left_box_line_p)
- x = s->x + box_line_hwidth;
- else
- x = s->x;
+ x = s->x;
+ if (s->first_glyph->left_box_line_p
+ && s->slice.x == 0)
+ x += box_line_hwidth;
+
+ y = s->y;
+ if (s->slice.y == 0)
+ y += box_line_vwidth;
- y = s->y + box_line_vwidth;
#if 0 /* TODO: figure out if we need to do this on Windows. */
if (s->img->mask)
{
}
else
{
- w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x,
+ w32_fill_area (s->f, s->hdc, s->face->overline_color, s->x,
s->y + dy, s->width, h);
}
}
/* If the dirty region is not what we expected, redraw the entire frame. */
if (!EqualRgn (combined, expect_dirty))
SET_FRAME_GARBAGED (f);
+
+ DeleteObject (dirty);
+ DeleteObject (combined);
}
UNBLOCK_INPUT;
+ DeleteObject (expect_dirty);
}
if (old_focus && old_focus->auto_lower)
x_lower_frame (old_focus);
-
-
-
-
-
-
-
-
if (dpyinfo->w32_focus_frame && dpyinfo->w32_focus_frame->auto_raise)
pending_autoraise_frame = dpyinfo->w32_focus_frame;
else
/* So people can tell when we have read the available input. */
input_signal_count++;
- /* TODO: tool-bars, ghostscript integration, mouse
- cursors. */
+ /* TODO: ghostscript integration. */
while (get_next_msg (&msg, FALSE))
{
struct input_event inev;
{
if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
{
- dpyinfo->mouse_face_hidden = 1;
clear_mouse_face (dpyinfo);
+ dpyinfo->mouse_face_hidden = 1;
}
if (temp_index == sizeof temp_buffer / sizeof (short))
{
if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
{
- dpyinfo->mouse_face_hidden = 1;
clear_mouse_face (dpyinfo);
+ dpyinfo->mouse_face_hidden = 1;
}
if (temp_index == sizeof temp_buffer / sizeof (short))
/* If the contents of the global variable help_echo_string
has changed, generate a HELP_EVENT. */
+#if 0 /* The below is an invalid comparison when USE_LISP_UNION_TYPE.
+ But it was originally changed to this to fix a bug, so I have
+ not removed it completely in case the bug is still there. */
if (help_echo_string != previous_help_echo_string ||
(!NILP (help_echo_string) && !STRINGP (help_echo_string) && f->mouse_moved))
+#else /* This is what xterm.c does. */
+ if (!NILP (help_echo_string)
+ || !NILP (previous_help_echo_string))
do_help = 1;
-
+#endif
break;
case WM_LBUTTONDOWN:
if (tool_bar_p
|| (dpyinfo->w32_focus_frame
- && f == dpyinfo->w32_focus_frame))
+ && f != dpyinfo->w32_focus_frame))
inev.kind = NO_EVENT;
}
f->async_visible = 1;
f->async_iconified = 0;
- /* wait_reading_process_input will notice this and update
+ /* wait_reading_process_output will notice this and update
the frame's display structures. */
SET_FRAME_GARBAGED (f);
if (f)
x_new_focus_frame (dpyinfo, f);
-
dpyinfo->grabbed = 0;
check_visibility = 1;
break;
if (do_help > 0)
{
- if (help_echo_string == Qnil)
+ if (NILP (help_echo_string))
{
help_echo_object = help_echo_window = Qnil;
help_echo_pos = -1;
}
-
+
any_help_event_p = 1;
gen_help_event (help_echo_string, frame, help_echo_window,
help_echo_object, help_echo_pos);
}
-
\f
/***********************************************************************
Text Cursor
mode lines must be clipped to the whole window. */
static void
-w32_clip_to_row (w, row, hdc)
+w32_clip_to_row (w, row, area, hdc)
struct window *w;
struct glyph_row *row;
+ int area;
HDC hdc;
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
RECT clip_rect;
- int window_y, window_width;
+ int window_x, window_y, window_width;
- window_box (w, -1, 0, &window_y, &window_width, 0);
+ window_box (w, area, &window_x, &window_y, &window_width, 0);
- clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0);
+ clip_rect.left = window_x;
clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
clip_rect.top = max (clip_rect.top, window_y);
clip_rect.right = clip_rect.left + window_width;
struct frame *f = XFRAME (WINDOW_FRAME (w));
HDC hdc;
RECT rect;
- int wd;
+ int wd, h;
struct glyph *cursor_glyph;
HBRUSH hb = CreateSolidBrush (f->output_data.w32->cursor_pixel);
+ /* Get the glyph the cursor is on. If we can't tell because
+ the current matrix is invalid or such, give up. */
+ cursor_glyph = get_phys_cursor_glyph (w);
+ if (cursor_glyph == NULL)
+ return;
+
/* Compute frame-relative coordinates from window-relative
coordinates. */
rect.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
rect.top = (WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y)
+ row->ascent - w->phys_cursor_ascent);
- rect.bottom = rect.top + row->height;
- /* Get the glyph the cursor is on. If we can't tell because
- the current matrix is invalid or such, give up. */
- cursor_glyph = get_phys_cursor_glyph (w);
- if (cursor_glyph == NULL)
- return;
+ /* Compute the proper height and ascent of the rectangle, based
+ on the actual glyph. Using the full height of the row looks
+ bad when there are tall images on that row. */
+ h = max (min (FRAME_LINE_HEIGHT (f), row->height),
+ cursor_glyph->ascent + cursor_glyph->descent);
+ if (h < row->height)
+ rect.top += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h;
+ h--;
+
+ rect.bottom = rect.top + h;
/* Compute the width of the rectangle to draw. If on a stretch
glyph, and `x-stretch-block-cursor' is nil, don't draw a
rectangle as wide as the glyph, but use a canonical character
width instead. */
- wd = cursor_glyph->pixel_width;
+ wd = cursor_glyph->pixel_width; /* TODO: Why off by one compared with X? */
if (cursor_glyph->type == STRETCH_GLYPH
&& !x_stretch_cursor_p)
wd = min (FRAME_COLUMN_WIDTH (f), wd);
rect.right = rect.left + wd;
hdc = get_frame_dc (f);
/* Set clipping, draw the rectangle, and reset clipping again. */
- w32_clip_to_row (w, row, hdc);
+ w32_clip_to_row (w, row, TEXT_AREA, hdc);
FrameRect (hdc, &rect, hb);
DeleteObject (hb);
w32_set_clip_rectangle (hdc, NULL);
hdc = get_frame_dc (f);
- w32_clip_to_row (w, row, hdc);
+ w32_clip_to_row (w, row, TEXT_AREA, hdc);
if (kind == BAR_CURSOR)
{
x_calc_absolute_position (f)
struct frame *f;
{
- POINT pt;
int flags = f->size_hint_flags;
- pt.x = pt.y = 0;
-
- /* Find the position of the outside upper-left corner of
- the inner window, with respect to the outer window.
- But do this only if we will need the results. */
- if (f->output_data.w32->parent_desc != FRAME_W32_DISPLAY_INFO (f)->root_window)
- {
- BLOCK_INPUT;
- MapWindowPoints (FRAME_W32_WINDOW (f),
- f->output_data.w32->parent_desc,
- &pt, 1);
- UNBLOCK_INPUT;
- }
-
- {
- RECT rt;
- rt.left = rt.right = rt.top = rt.bottom = 0;
-
- BLOCK_INPUT;
- AdjustWindowRect(&rt, f->output_data.w32->dwStyle,
- FRAME_EXTERNAL_MENU_BAR (f));
- UNBLOCK_INPUT;
-
- pt.x += (rt.right - rt.left);
- pt.y += (rt.bottom - rt.top);
- }
-
/* Treat negative positions as relative to the leftmost bottommost
position that fits on the screen. */
if (flags & XNegative)
f->left_pos = (FRAME_W32_DISPLAY_INFO (f)->width
- - 2 * f->border_width - pt.x
- FRAME_PIXEL_WIDTH (f)
+ f->left_pos);
if (flags & YNegative)
f->top_pos = (FRAME_W32_DISPLAY_INFO (f)->height
- - 2 * f->border_width - pt.y
- FRAME_PIXEL_HEIGHT (f)
+ f->top_pos);
/* The left_pos and top_pos
Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
DEFVAR_INT ("w32-num-mouse-buttons",
- &Vw32_num_mouse_buttons,
+ &w32_num_mouse_buttons,
doc: /* Number of physical mouse buttons. */);
- Vw32_num_mouse_buttons = Qnil;
+ w32_num_mouse_buttons = 2;
DEFVAR_LISP ("w32-swap-mouse-buttons",
&Vw32_swap_mouse_buttons,