comparison src/w32term.c @ 90428:a8190f7e546e

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 285-296) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: admin/FOR-RELEASE: Update refcard section. * gnus--rel--5.10 (patch 102-104) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-64
author Miles Bader <miles@gnu.org>
date Wed, 07 Jun 2006 18:05:10 +0000
parents 2ecafc6d5db7 4a38eb2f741d
children 6194dc57516d
comparison
equal deleted inserted replaced
90427:ddb25860d044 90428:a8190f7e546e
170 170
171 DWORD dwWindowsThreadId = 0; 171 DWORD dwWindowsThreadId = 0;
172 HANDLE hWindowsThread = NULL; 172 HANDLE hWindowsThread = NULL;
173 DWORD dwMainThreadId = 0; 173 DWORD dwMainThreadId = 0;
174 HANDLE hMainThread = NULL; 174 HANDLE hMainThread = NULL;
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
185 typedef 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;
195 typedef SCROLLINFO CONST FAR *LPCSCROLLINFO;
196 #endif /* SIF_ALL */
197
198 /* Dynamic linking to new proportional scroll bar functions. */
199 int (PASCAL *pfnSetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
200 BOOL (PASCAL *pfnGetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi);
201 175
202 int vertical_scroll_bar_min_handle; 176 int vertical_scroll_bar_min_handle;
203 int vertical_scroll_bar_top_border; 177 int vertical_scroll_bar_top_border;
204 int vertical_scroll_bar_bottom_border; 178 int vertical_scroll_bar_bottom_border;
205 179
2538 if (s->hl == DRAW_CURSOR 2512 if (s->hl == DRAW_CURSOR
2539 && !x_stretch_cursor_p) 2513 && !x_stretch_cursor_p)
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 {
2560 x_set_mouse_face_gc (s); 2543 x_set_mouse_face_gc (s);
2561 gc = s->gc; 2544 gc = s->gc;
2580 w32_fill_area (s->f, s->hdc, gc->background, x, y, w, h); 2563 w32_fill_area (s->f, s->hdc, gc->background, x, y, w, h);
2581 } 2564 }
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 }
2590 2583
2591 2584
3617 { 3610 {
3618 Window w = SCROLL_BAR_W32_WINDOW (bar); 3611 Window w = SCROLL_BAR_W32_WINDOW (bar);
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 {
3625 /* Position scroll bar at rock bottom if the bottom of the 3619 /* Position scroll bar at rock bottom if the bottom of the
3626 buffer is visible. This avoids shinking the thumb away 3620 buffer is visible. This avoids shinking the thumb away
3641 sb_pos = 0; 3635 sb_pos = 0;
3642 } 3636 }
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 }
3667 3654
3668 3655
3747 struct window *w; 3734 struct window *w;
3748 int top, left, width, height; 3735 int 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
3755 BLOCK_INPUT; 3743 BLOCK_INPUT;
3756 3744
3765 3753
3766 /* Requires geometry to be set before call to create the real window */ 3754 /* Requires geometry to be set before call to create the real window */
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;
3773 3761 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3774 si.cbSize = sizeof (si); 3762 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3775 si.fMask = SIF_ALL; 3763 si.nPage = si.nMax;
3776 si.nMin = 0; 3764 si.nPos = 0;
3777 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height) 3765
3778 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3766 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
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
3793 /* Add bar to its frame's list of scroll bars. */ 3770 /* Add bar to its frame's list of scroll bars. */
3794 bar->next = FRAME_SCROLL_BARS (f); 3771 bar->next = FRAME_SCROLL_BARS (f);
3893 InvalidateRect (hwnd, NULL, FALSE); 3870 InvalidateRect (hwnd, NULL, FALSE);
3894 } 3871 }
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 {
3901 hdc = get_frame_dc (f); 3880 hdc = get_frame_dc (f);
3902 /* Since Windows scroll bars are smaller than the space reserved 3881 /* Since Windows scroll bars are smaller than the space reserved
3912 area of the parent window now exposed will be refreshed. */ 3891 area of the parent window now exposed will be refreshed. */
3913 my_show_window (f, hwnd, SW_HIDE); 3892 my_show_window (f, hwnd, SW_HIDE);
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) 3896
3918 { 3897 si.cbSize = sizeof (si);
3919 SCROLLINFO si; 3898 si.fMask = SIF_RANGE;
3920 3899 si.nMin = 0;
3921 si.cbSize = sizeof (si); 3900 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3922 si.fMask = SIF_RANGE; 3901 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3923 si.nMin = 0; 3902
3924 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height) 3903 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3925 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3904
3926
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
3935 /* Remember new settings. */ 3908 /* Remember new settings. */
3936 XSETINT (bar->left, sb_left); 3909 XSETINT (bar->left, sb_left);
4078 4051
4079 { 4052 {
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);
4083 4056 SCROLLINFO si;
4084 if (pfnGetScrollInfo) 4057
4085 { 4058 si.cbSize = sizeof (si);
4086 SCROLLINFO si; 4059 si.fMask = SIF_POS;
4087 4060
4088 si.cbSize = sizeof (si); 4061 GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
4089 si.fMask = SIF_POS; 4062 y = si.nPos;
4090
4091 pfnGetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
4092 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
4099 4066
4100 last_mouse_scroll_bar_pos = msg->msg.wParam; 4067 last_mouse_scroll_bar_pos = msg->msg.wParam;
4127 y = HIWORD (msg->msg.wParam); 4094 y = HIWORD (msg->msg.wParam);
4128 bar->dragging = Qt; 4095 bar->dragging = Qt;
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; 4101
4135 4102 si.cbSize = sizeof (si);
4136 si.cbSize = sizeof (si); 4103 si.fMask = SIF_POS;
4137 si.fMask = SIF_POS; 4104 si.nPos = y;
4138 si.nPos = y; 4105 /* Remember apparent position (we actually lag behind the real
4139 /* Remember apparent position (we actually lag behind the real 4106 position, so don't set that directly. */
4140 position, so don't set that directly. */ 4107 last_scroll_bar_drag_pos = y;
4141 last_scroll_bar_drag_pos = y; 4108
4142 4109 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE);
4143 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); 4110 }
4144 }
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
4150 handle size to normal and do a final redraw. Otherwise do 4114 handle size to normal and do a final redraw. Otherwise do
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:
4171 emacs_event->kind = NO_EVENT; 4130 emacs_event->kind = NO_EVENT;
4172 return FALSE; 4131 return FALSE;
4193 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 4152 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4194 Window w = SCROLL_BAR_W32_WINDOW (bar); 4153 Window w = SCROLL_BAR_W32_WINDOW (bar);
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; 4166
4207 4167 GetScrollInfo (w, SB_CTL, &si);
4208 si.cbSize = sizeof (si); 4168 pos = si.nPos;
4209 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE; 4169 top_range = si.nMax - si.nPage + 1;
4210
4211 pfnGetScrollInfo (w, SB_CTL, &si);
4212 pos = si.nPos;
4213 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 {
4220 case SB_THUMBPOSITION: 4173 case SB_THUMBPOSITION:
4221 case SB_THUMBTRACK: 4174 case SB_THUMBTRACK:
5080 struct glyph_row *row; 5033 struct glyph_row *row;
5081 { 5034 {
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
5089 /* Get the glyph the cursor is on. If we can't tell because 5042 /* Get the glyph the cursor is on. If we can't tell because
5090 the current matrix is invalid or such, give up. */ 5043 the current matrix is invalid or such, give up. */
5091 cursor_glyph = get_phys_cursor_glyph (w); 5044 cursor_glyph = get_phys_cursor_glyph (w);
5092 if (cursor_glyph == NULL) 5045 if (cursor_glyph == NULL)
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
5101 hdc = get_frame_dc (f); 5055 hdc = get_frame_dc (f);
5102 /* Set clipping, draw the rectangle, and reset clipping again. */ 5056 /* Set clipping, draw the rectangle, and reset clipping again. */