aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c224
1 files changed, 89 insertions, 135 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 305527946fb..0a7007cc8f4 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -173,32 +173,6 @@ HANDLE hWindowsThread = NULL;
173DWORD dwMainThreadId = 0; 173DWORD dwMainThreadId = 0;
174HANDLE hMainThread = NULL; 174HANDLE hMainThread = NULL;
175 175
176#ifndef SIF_ALL
177/* These definitions are new with Windows 95. */
178#define SIF_RANGE 0x0001
179#define SIF_PAGE 0x0002
180#define SIF_POS 0x0004
181#define SIF_DISABLENOSCROLL 0x0008
182#define SIF_TRACKPOS 0x0010
183#define SIF_ALL (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS)
184
185typedef struct tagSCROLLINFO
186{
187 UINT cbSize;
188 UINT fMask;
189 int nMin;
190 int nMax;
191 UINT nPage;
192 int nPos;
193 int nTrackPos;
194} SCROLLINFO, FAR *LPSCROLLINFO;
195typedef SCROLLINFO CONST FAR *LPCSCROLLINFO;
196#endif /* SIF_ALL */
197
198/* Dynamic linking to new proportional scroll bar functions. */
199int (PASCAL *pfnSetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
200BOOL (PASCAL *pfnGetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi);
201
202int vertical_scroll_bar_min_handle; 176int vertical_scroll_bar_min_handle;
203int vertical_scroll_bar_top_border; 177int vertical_scroll_bar_top_border;
204int vertical_scroll_bar_bottom_border; 178int vertical_scroll_bar_bottom_border;
@@ -2540,20 +2514,29 @@ x_draw_stretch_glyph_string (s)
2540 { 2514 {
2541 /* If `x-stretch-block-cursor' is nil, don't draw a block cursor 2515 /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
2542 as wide as the stretch glyph. */ 2516 as wide as the stretch glyph. */
2543 int width = min (FRAME_COLUMN_WIDTH (s->f), s->background_width); 2517 int width, background_width = s->background_width;
2518 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
2519
2520 if (x < left_x)
2521 {
2522 background_width -= left_x - x;
2523 x = left_x;
2524 }
2525 width = min (FRAME_COLUMN_WIDTH (s->f), background_width);
2544 2526
2545 /* Draw cursor. */ 2527 /* Draw cursor. */
2546 x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height); 2528 x_draw_glyph_string_bg_rect (s, x, s->y, width, s->height);
2547 2529
2548 /* Clear rest using the GC of the original non-cursor face. */ 2530 /* Clear rest using the GC of the original non-cursor face. */
2549 if (width < s->background_width) 2531 if (width < background_width)
2550 { 2532 {
2551 XGCValues *gc = s->face->gc; 2533 XGCValues *gc = s->face->gc;
2552 int x = s->x + width, y = s->y; 2534 int y = s->y;
2553 int w = s->background_width - width, h = s->height; 2535 int w = background_width - width, h = s->height;
2554 RECT r; 2536 RECT r;
2555 HDC hdc = s->hdc; 2537 HDC hdc = s->hdc;
2556 2538
2539 x += width;
2557 if (s->row->mouse_face_p 2540 if (s->row->mouse_face_p
2558 && cursor_in_mouse_face_p (s->w)) 2541 && cursor_in_mouse_face_p (s->w))
2559 { 2542 {
@@ -2582,8 +2565,18 @@ x_draw_stretch_glyph_string (s)
2582 } 2565 }
2583 } 2566 }
2584 else if (!s->background_filled_p) 2567 else if (!s->background_filled_p)
2585 x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width, 2568 {
2586 s->height); 2569 int background_width = s->background_width;
2570 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
2571
2572 if (x < left_x)
2573 {
2574 background_width -= left_x - x;
2575 x = left_x;
2576 }
2577 if (background_width > 0)
2578 x_draw_glyph_string_bg_rect (s, x, s->y, background_width, s->height);
2579 }
2587 2580
2588 s->background_filled_p = 1; 2581 s->background_filled_p = 1;
2589} 2582}
@@ -3619,6 +3612,7 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
3619 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 3612 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
3620 int sb_page, sb_pos; 3613 int sb_page, sb_pos;
3621 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE; 3614 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE;
3615 SCROLLINFO si;
3622 3616
3623 if (whole) 3617 if (whole)
3624 { 3618 {
@@ -3643,24 +3637,17 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
3643 3637
3644 BLOCK_INPUT; 3638 BLOCK_INPUT;
3645 3639
3646 if (pfnSetScrollInfo) 3640 si.cbSize = sizeof (si);
3647 { 3641 /* Only update page size if currently dragging, to reduce
3648 SCROLLINFO si; 3642 flicker effects. */
3649 3643 if (draggingp)
3650 si.cbSize = sizeof (si); 3644 si.fMask = SIF_PAGE;
3651 /* Only update page size if currently dragging, to reduce
3652 flicker effects. */
3653 if (draggingp)
3654 si.fMask = SIF_PAGE;
3655 else
3656 si.fMask = SIF_PAGE | SIF_POS;
3657 si.nPage = sb_page;
3658 si.nPos = sb_pos;
3659
3660 pfnSetScrollInfo (w, SB_CTL, &si, !draggingp);
3661 }
3662 else 3645 else
3663 SetScrollPos (w, SB_CTL, sb_pos, !draggingp); 3646 si.fMask = SIF_PAGE | SIF_POS;
3647 si.nPage = sb_page;
3648 si.nPos = sb_pos;
3649
3650 SetScrollInfo (w, SB_CTL, &si, !draggingp);
3664 3651
3665 UNBLOCK_INPUT; 3652 UNBLOCK_INPUT;
3666} 3653}
@@ -3749,6 +3736,7 @@ x_scroll_bar_create (w, top, left, width, height)
3749{ 3736{
3750 struct frame *f = XFRAME (WINDOW_FRAME (w)); 3737 struct frame *f = XFRAME (WINDOW_FRAME (w));
3751 HWND hwnd; 3738 HWND hwnd;
3739 SCROLLINFO si;
3752 struct scroll_bar *bar 3740 struct scroll_bar *bar
3753 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); 3741 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
3754 3742
@@ -3767,26 +3755,15 @@ x_scroll_bar_create (w, top, left, width, height)
3767 3755
3768 hwnd = my_create_scrollbar (f, bar); 3756 hwnd = my_create_scrollbar (f, bar);
3769 3757
3770 if (pfnSetScrollInfo) 3758 si.cbSize = sizeof (si);
3771 { 3759 si.fMask = SIF_ALL;
3772 SCROLLINFO si; 3760 si.nMin = 0;
3761 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3762 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3763 si.nPage = si.nMax;
3764 si.nPos = 0;
3773 3765
3774 si.cbSize = sizeof (si); 3766 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3775 si.fMask = SIF_ALL;
3776 si.nMin = 0;
3777 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3778 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3779 si.nPage = si.nMax;
3780 si.nPos = 0;
3781
3782 pfnSetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3783 }
3784 else
3785 {
3786 SetScrollRange (hwnd, SB_CTL, 0,
3787 VERTICAL_SCROLL_BAR_TOP_RANGE (f, height), FALSE);
3788 SetScrollPos (hwnd, SB_CTL, 0, FALSE);
3789 }
3790 3767
3791 SET_SCROLL_BAR_W32_WINDOW (bar, hwnd); 3768 SET_SCROLL_BAR_W32_WINDOW (bar, hwnd);
3792 3769
@@ -3895,6 +3872,8 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
3895 else 3872 else
3896 { 3873 {
3897 HDC hdc; 3874 HDC hdc;
3875 SCROLLINFO si;
3876
3898 BLOCK_INPUT; 3877 BLOCK_INPUT;
3899 if (width && height) 3878 if (width && height)
3900 { 3879 {
@@ -3914,21 +3893,15 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
3914 MoveWindow (hwnd, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 3893 MoveWindow (hwnd, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
3915 top, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 3894 top, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
3916 max (height, 1), TRUE); 3895 max (height, 1), TRUE);
3917 if (pfnSetScrollInfo)
3918 {
3919 SCROLLINFO si;
3920 3896
3921 si.cbSize = sizeof (si); 3897 si.cbSize = sizeof (si);
3922 si.fMask = SIF_RANGE; 3898 si.fMask = SIF_RANGE;
3923 si.nMin = 0; 3899 si.nMin = 0;
3924 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height) 3900 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3925 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3901 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3902
3903 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3926 3904
3927 pfnSetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3928 }
3929 else
3930 SetScrollRange (hwnd, SB_CTL, 0,
3931 VERTICAL_SCROLL_BAR_TOP_RANGE (f, height), FALSE);
3932 my_show_window (f, hwnd, SW_NORMAL); 3905 my_show_window (f, hwnd, SW_NORMAL);
3933 /* InvalidateRect (w, NULL, FALSE); */ 3906 /* InvalidateRect (w, NULL, FALSE); */
3934 3907
@@ -4080,19 +4053,13 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
4080 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 4053 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
4081 int y; 4054 int y;
4082 int dragging = !NILP (bar->dragging); 4055 int dragging = !NILP (bar->dragging);
4056 SCROLLINFO si;
4083 4057
4084 if (pfnGetScrollInfo) 4058 si.cbSize = sizeof (si);
4085 { 4059 si.fMask = SIF_POS;
4086 SCROLLINFO si;
4087
4088 si.cbSize = sizeof (si);
4089 si.fMask = SIF_POS;
4090 4060
4091 pfnGetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si); 4061 GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
4092 y = si.nPos; 4062 y = si.nPos;
4093 }
4094 else
4095 y = GetScrollPos ((HWND) msg->msg.lParam, SB_CTL);
4096 4063
4097 bar->dragging = Qnil; 4064 bar->dragging = Qnil;
4098 4065
@@ -4129,21 +4096,18 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
4129 emacs_event->part = scroll_bar_handle; 4096 emacs_event->part = scroll_bar_handle;
4130 4097
4131 /* "Silently" update current position. */ 4098 /* "Silently" update current position. */
4132 if (pfnSetScrollInfo) 4099 {
4133 { 4100 SCROLLINFO si;
4134 SCROLLINFO si;
4135 4101
4136 si.cbSize = sizeof (si); 4102 si.cbSize = sizeof (si);
4137 si.fMask = SIF_POS; 4103 si.fMask = SIF_POS;
4138 si.nPos = y; 4104 si.nPos = y;
4139 /* Remember apparent position (we actually lag behind the real 4105 /* Remember apparent position (we actually lag behind the real
4140 position, so don't set that directly. */ 4106 position, so don't set that directly. */
4141 last_scroll_bar_drag_pos = y; 4107 last_scroll_bar_drag_pos = y;
4142 4108
4143 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); 4109 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE);
4144 } 4110 }
4145 else
4146 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, y, FALSE);
4147 break; 4111 break;
4148 case SB_ENDSCROLL: 4112 case SB_ENDSCROLL:
4149 /* If this is the end of a drag sequence, then reset the scroll 4113 /* If this is the end of a drag sequence, then reset the scroll
@@ -4151,20 +4115,15 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
4151 nothing. */ 4115 nothing. */
4152 if (dragging) 4116 if (dragging)
4153 { 4117 {
4154 if (pfnSetScrollInfo) 4118 SCROLLINFO si;
4155 { 4119 int start = XINT (bar->start);
4156 SCROLLINFO si; 4120 int end = XINT (bar->end);
4157 int start = XINT (bar->start); 4121
4158 int end = XINT (bar->end); 4122 si.cbSize = sizeof (si);
4159 4123 si.fMask = SIF_PAGE | SIF_POS;
4160 si.cbSize = sizeof (si); 4124 si.nPage = end - start + VERTICAL_SCROLL_BAR_MIN_HANDLE;
4161 si.fMask = SIF_PAGE | SIF_POS; 4125 si.nPos = last_scroll_bar_drag_pos;
4162 si.nPage = end - start + VERTICAL_SCROLL_BAR_MIN_HANDLE; 4126 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
4163 si.nPos = last_scroll_bar_drag_pos;
4164 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
4165 }
4166 else
4167 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, y, TRUE);
4168 } 4127 }
4169 /* fall through */ 4128 /* fall through */
4170 default: 4129 default:
@@ -4195,25 +4154,19 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4195 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 4154 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
4196 int pos; 4155 int pos;
4197 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 4156 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
4157 SCROLLINFO si;
4198 4158
4199 BLOCK_INPUT; 4159 BLOCK_INPUT;
4200 4160
4201 *fp = f; 4161 *fp = f;
4202 *bar_window = bar->window; 4162 *bar_window = bar->window;
4203 4163
4204 if (pfnGetScrollInfo) 4164 si.cbSize = sizeof (si);
4205 { 4165 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
4206 SCROLLINFO si;
4207
4208 si.cbSize = sizeof (si);
4209 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
4210 4166
4211 pfnGetScrollInfo (w, SB_CTL, &si); 4167 GetScrollInfo (w, SB_CTL, &si);
4212 pos = si.nPos; 4168 pos = si.nPos;
4213 top_range = si.nMax - si.nPage + 1; 4169 top_range = si.nMax - si.nPage + 1;
4214 }
4215 else
4216 pos = GetScrollPos (w, SB_CTL);
4217 4170
4218 switch (LOWORD (last_mouse_scroll_bar_pos)) 4171 switch (LOWORD (last_mouse_scroll_bar_pos))
4219 { 4172 {
@@ -5082,7 +5035,7 @@ x_draw_hollow_cursor (w, row)
5082 struct frame *f = XFRAME (WINDOW_FRAME (w)); 5035 struct frame *f = XFRAME (WINDOW_FRAME (w));
5083 HDC hdc; 5036 HDC hdc;
5084 RECT rect; 5037 RECT rect;
5085 int h; 5038 int left, top, h;
5086 struct glyph *cursor_glyph; 5039 struct glyph *cursor_glyph;
5087 HBRUSH hb = CreateSolidBrush (f->output_data.w32->cursor_pixel); 5040 HBRUSH hb = CreateSolidBrush (f->output_data.w32->cursor_pixel);
5088 5041
@@ -5093,8 +5046,9 @@ x_draw_hollow_cursor (w, row)
5093 return; 5046 return;
5094 5047
5095 /* Compute frame-relative coordinates for phys cursor. */ 5048 /* Compute frame-relative coordinates for phys cursor. */
5096 rect.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 5049 get_phys_cursor_geometry (w, row, cursor_glyph, &left, &top, &h);
5097 rect.top = get_phys_cursor_geometry (w, row, cursor_glyph, &h); 5050 rect.left = left;
5051 rect.top = top;
5098 rect.bottom = rect.top + h; 5052 rect.bottom = rect.top + h;
5099 rect.right = rect.left + w->phys_cursor_width; 5053 rect.right = rect.left + w->phys_cursor_width;
5100 5054