comparison src/w32term.c @ 71236:4a38eb2f741d

(w32_set_scroll_bar_thumb, x_scroll_bar_create) (w32_set_vertical_scroll_bar, w32_scroll_bar_handle_click) (x_scroll_bar_report_motion): Remove workarounds for versions of Windows NT < 3.51. [!SIF_ALL]: Remove. (pfnSetScrollInfo, pfnGetScrollInfo): Remove. (w32_initialize): Don't dynamically load Get/SetScrollInfo.
author Jason Rumney <jasonr@gnu.org>
date Mon, 05 Jun 2006 21:20:59 +0000
parents 67dc3a0454b2
children d1eb48dbd3e6 46b1096093f5 a8190f7e546e
comparison
equal deleted inserted replaced
71235:a2e78f6a049e 71236:4a38eb2f741d
143 143
144 DWORD dwWindowsThreadId = 0; 144 DWORD dwWindowsThreadId = 0;
145 HANDLE hWindowsThread = NULL; 145 HANDLE hWindowsThread = NULL;
146 DWORD dwMainThreadId = 0; 146 DWORD dwMainThreadId = 0;
147 HANDLE hMainThread = NULL; 147 HANDLE hMainThread = NULL;
148
149 #ifndef SIF_ALL
150 /* These definitions are new with Windows 95. */
151 #define SIF_RANGE 0x0001
152 #define SIF_PAGE 0x0002
153 #define SIF_POS 0x0004
154 #define SIF_DISABLENOSCROLL 0x0008
155 #define SIF_TRACKPOS 0x0010
156 #define SIF_ALL (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS)
157
158 typedef struct tagSCROLLINFO
159 {
160 UINT cbSize;
161 UINT fMask;
162 int nMin;
163 int nMax;
164 UINT nPage;
165 int nPos;
166 int nTrackPos;
167 } SCROLLINFO, FAR *LPSCROLLINFO;
168 typedef SCROLLINFO CONST FAR *LPCSCROLLINFO;
169 #endif /* SIF_ALL */
170
171 /* Dynamic linking to new proportional scroll bar functions. */
172 int (PASCAL *pfnSetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
173 BOOL (PASCAL *pfnGetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi);
174 148
175 int vertical_scroll_bar_min_handle; 149 int vertical_scroll_bar_min_handle;
176 int vertical_scroll_bar_top_border; 150 int vertical_scroll_bar_top_border;
177 int vertical_scroll_bar_bottom_border; 151 int vertical_scroll_bar_bottom_border;
178 152
3485 { 3459 {
3486 Window w = SCROLL_BAR_W32_WINDOW (bar); 3460 Window w = SCROLL_BAR_W32_WINDOW (bar);
3487 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 3461 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
3488 int sb_page, sb_pos; 3462 int sb_page, sb_pos;
3489 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE; 3463 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE;
3464 SCROLLINFO si;
3490 3465
3491 if (whole) 3466 if (whole)
3492 { 3467 {
3493 /* Position scroll bar at rock bottom if the bottom of the 3468 /* Position scroll bar at rock bottom if the bottom of the
3494 buffer is visible. This avoids shinking the thumb away 3469 buffer is visible. This avoids shinking the thumb away
3509 sb_pos = 0; 3484 sb_pos = 0;
3510 } 3485 }
3511 3486
3512 BLOCK_INPUT; 3487 BLOCK_INPUT;
3513 3488
3514 if (pfnSetScrollInfo) 3489 si.cbSize = sizeof (si);
3515 { 3490 /* Only update page size if currently dragging, to reduce
3516 SCROLLINFO si; 3491 flicker effects. */
3517 3492 if (draggingp)
3518 si.cbSize = sizeof (si); 3493 si.fMask = SIF_PAGE;
3519 /* Only update page size if currently dragging, to reduce
3520 flicker effects. */
3521 if (draggingp)
3522 si.fMask = SIF_PAGE;
3523 else
3524 si.fMask = SIF_PAGE | SIF_POS;
3525 si.nPage = sb_page;
3526 si.nPos = sb_pos;
3527
3528 pfnSetScrollInfo (w, SB_CTL, &si, !draggingp);
3529 }
3530 else 3494 else
3531 SetScrollPos (w, SB_CTL, sb_pos, !draggingp); 3495 si.fMask = SIF_PAGE | SIF_POS;
3496 si.nPage = sb_page;
3497 si.nPos = sb_pos;
3498
3499 SetScrollInfo (w, SB_CTL, &si, !draggingp);
3532 3500
3533 UNBLOCK_INPUT; 3501 UNBLOCK_INPUT;
3534 } 3502 }
3535 3503
3536 3504
3615 struct window *w; 3583 struct window *w;
3616 int top, left, width, height; 3584 int top, left, width, height;
3617 { 3585 {
3618 struct frame *f = XFRAME (WINDOW_FRAME (w)); 3586 struct frame *f = XFRAME (WINDOW_FRAME (w));
3619 HWND hwnd; 3587 HWND hwnd;
3588 SCROLLINFO si;
3620 struct scroll_bar *bar 3589 struct scroll_bar *bar
3621 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); 3590 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
3622 3591
3623 BLOCK_INPUT; 3592 BLOCK_INPUT;
3624 3593
3633 3602
3634 /* Requires geometry to be set before call to create the real window */ 3603 /* Requires geometry to be set before call to create the real window */
3635 3604
3636 hwnd = my_create_scrollbar (f, bar); 3605 hwnd = my_create_scrollbar (f, bar);
3637 3606
3638 if (pfnSetScrollInfo) 3607 si.cbSize = sizeof (si);
3639 { 3608 si.fMask = SIF_ALL;
3640 SCROLLINFO si; 3609 si.nMin = 0;
3641 3610 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3642 si.cbSize = sizeof (si); 3611 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3643 si.fMask = SIF_ALL; 3612 si.nPage = si.nMax;
3644 si.nMin = 0; 3613 si.nPos = 0;
3645 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height) 3614
3646 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3615 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3647 si.nPage = si.nMax;
3648 si.nPos = 0;
3649
3650 pfnSetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3651 }
3652 else
3653 {
3654 SetScrollRange (hwnd, SB_CTL, 0,
3655 VERTICAL_SCROLL_BAR_TOP_RANGE (f, height), FALSE);
3656 SetScrollPos (hwnd, SB_CTL, 0, FALSE);
3657 }
3658 3616
3659 SET_SCROLL_BAR_W32_WINDOW (bar, hwnd); 3617 SET_SCROLL_BAR_W32_WINDOW (bar, hwnd);
3660 3618
3661 /* Add bar to its frame's list of scroll bars. */ 3619 /* Add bar to its frame's list of scroll bars. */
3662 bar->next = FRAME_SCROLL_BARS (f); 3620 bar->next = FRAME_SCROLL_BARS (f);
3761 InvalidateRect (hwnd, NULL, FALSE); 3719 InvalidateRect (hwnd, NULL, FALSE);
3762 } 3720 }
3763 else 3721 else
3764 { 3722 {
3765 HDC hdc; 3723 HDC hdc;
3724 SCROLLINFO si;
3725
3766 BLOCK_INPUT; 3726 BLOCK_INPUT;
3767 if (width && height) 3727 if (width && height)
3768 { 3728 {
3769 hdc = get_frame_dc (f); 3729 hdc = get_frame_dc (f);
3770 /* Since Windows scroll bars are smaller than the space reserved 3730 /* Since Windows scroll bars are smaller than the space reserved
3780 area of the parent window now exposed will be refreshed. */ 3740 area of the parent window now exposed will be refreshed. */
3781 my_show_window (f, hwnd, SW_HIDE); 3741 my_show_window (f, hwnd, SW_HIDE);
3782 MoveWindow (hwnd, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 3742 MoveWindow (hwnd, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
3783 top, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 3743 top, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
3784 max (height, 1), TRUE); 3744 max (height, 1), TRUE);
3785 if (pfnSetScrollInfo) 3745
3786 { 3746 si.cbSize = sizeof (si);
3787 SCROLLINFO si; 3747 si.fMask = SIF_RANGE;
3788 3748 si.nMin = 0;
3789 si.cbSize = sizeof (si); 3749 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3790 si.fMask = SIF_RANGE; 3750 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3791 si.nMin = 0; 3751
3792 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height) 3752 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3793 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3753
3794
3795 pfnSetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3796 }
3797 else
3798 SetScrollRange (hwnd, SB_CTL, 0,
3799 VERTICAL_SCROLL_BAR_TOP_RANGE (f, height), FALSE);
3800 my_show_window (f, hwnd, SW_NORMAL); 3754 my_show_window (f, hwnd, SW_NORMAL);
3801 /* InvalidateRect (w, NULL, FALSE); */ 3755 /* InvalidateRect (w, NULL, FALSE); */
3802 3756
3803 /* Remember new settings. */ 3757 /* Remember new settings. */
3804 XSETINT (bar->left, sb_left); 3758 XSETINT (bar->left, sb_left);
3946 3900
3947 { 3901 {
3948 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 3902 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
3949 int y; 3903 int y;
3950 int dragging = !NILP (bar->dragging); 3904 int dragging = !NILP (bar->dragging);
3951 3905 SCROLLINFO si;
3952 if (pfnGetScrollInfo) 3906
3953 { 3907 si.cbSize = sizeof (si);
3954 SCROLLINFO si; 3908 si.fMask = SIF_POS;
3955 3909
3956 si.cbSize = sizeof (si); 3910 GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
3957 si.fMask = SIF_POS; 3911 y = si.nPos;
3958
3959 pfnGetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
3960 y = si.nPos;
3961 }
3962 else
3963 y = GetScrollPos ((HWND) msg->msg.lParam, SB_CTL);
3964 3912
3965 bar->dragging = Qnil; 3913 bar->dragging = Qnil;
3966 3914
3967 3915
3968 last_mouse_scroll_bar_pos = msg->msg.wParam; 3916 last_mouse_scroll_bar_pos = msg->msg.wParam;
3995 y = HIWORD (msg->msg.wParam); 3943 y = HIWORD (msg->msg.wParam);
3996 bar->dragging = Qt; 3944 bar->dragging = Qt;
3997 emacs_event->part = scroll_bar_handle; 3945 emacs_event->part = scroll_bar_handle;
3998 3946
3999 /* "Silently" update current position. */ 3947 /* "Silently" update current position. */
4000 if (pfnSetScrollInfo) 3948 {
4001 { 3949 SCROLLINFO si;
4002 SCROLLINFO si; 3950
4003 3951 si.cbSize = sizeof (si);
4004 si.cbSize = sizeof (si); 3952 si.fMask = SIF_POS;
4005 si.fMask = SIF_POS; 3953 si.nPos = y;
4006 si.nPos = y; 3954 /* Remember apparent position (we actually lag behind the real
4007 /* Remember apparent position (we actually lag behind the real 3955 position, so don't set that directly. */
4008 position, so don't set that directly. */ 3956 last_scroll_bar_drag_pos = y;
4009 last_scroll_bar_drag_pos = y; 3957
4010 3958 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE);
4011 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); 3959 }
4012 }
4013 else
4014 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, y, FALSE);
4015 break; 3960 break;
4016 case SB_ENDSCROLL: 3961 case SB_ENDSCROLL:
4017 /* If this is the end of a drag sequence, then reset the scroll 3962 /* If this is the end of a drag sequence, then reset the scroll
4018 handle size to normal and do a final redraw. Otherwise do 3963 handle size to normal and do a final redraw. Otherwise do
4019 nothing. */ 3964 nothing. */
4020 if (dragging) 3965 if (dragging)
4021 { 3966 {
4022 if (pfnSetScrollInfo) 3967 SCROLLINFO si;
4023 { 3968 int start = XINT (bar->start);
4024 SCROLLINFO si; 3969 int end = XINT (bar->end);
4025 int start = XINT (bar->start); 3970
4026 int end = XINT (bar->end); 3971 si.cbSize = sizeof (si);
4027 3972 si.fMask = SIF_PAGE | SIF_POS;
4028 si.cbSize = sizeof (si); 3973 si.nPage = end - start + VERTICAL_SCROLL_BAR_MIN_HANDLE;
4029 si.fMask = SIF_PAGE | SIF_POS; 3974 si.nPos = last_scroll_bar_drag_pos;
4030 si.nPage = end - start + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3975 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
4031 si.nPos = last_scroll_bar_drag_pos;
4032 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
4033 }
4034 else
4035 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, y, TRUE);
4036 } 3976 }
4037 /* fall through */ 3977 /* fall through */
4038 default: 3978 default:
4039 emacs_event->kind = NO_EVENT; 3979 emacs_event->kind = NO_EVENT;
4040 return FALSE; 3980 return FALSE;
4061 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 4001 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4062 Window w = SCROLL_BAR_W32_WINDOW (bar); 4002 Window w = SCROLL_BAR_W32_WINDOW (bar);
4063 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 4003 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
4064 int pos; 4004 int pos;
4065 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 4005 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
4006 SCROLLINFO si;
4066 4007
4067 BLOCK_INPUT; 4008 BLOCK_INPUT;
4068 4009
4069 *fp = f; 4010 *fp = f;
4070 *bar_window = bar->window; 4011 *bar_window = bar->window;
4071 4012
4072 if (pfnGetScrollInfo) 4013 si.cbSize = sizeof (si);
4073 { 4014 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
4074 SCROLLINFO si; 4015
4075 4016 GetScrollInfo (w, SB_CTL, &si);
4076 si.cbSize = sizeof (si); 4017 pos = si.nPos;
4077 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE; 4018 top_range = si.nMax - si.nPage + 1;
4078
4079 pfnGetScrollInfo (w, SB_CTL, &si);
4080 pos = si.nPos;
4081 top_range = si.nMax - si.nPage + 1;
4082 }
4083 else
4084 pos = GetScrollPos (w, SB_CTL);
4085 4019
4086 switch (LOWORD (last_mouse_scroll_bar_pos)) 4020 switch (LOWORD (last_mouse_scroll_bar_pos))
4087 { 4021 {
4088 case SB_THUMBPOSITION: 4022 case SB_THUMBPOSITION:
4089 case SB_THUMBTRACK: 4023 case SB_THUMBTRACK:
6407 window state. */ 6341 window state. */
6408 #ifdef ATTACH_THREADS 6342 #ifdef ATTACH_THREADS
6409 AttachThreadInput (dwMainThreadId, dwWindowsThreadId, TRUE); 6343 AttachThreadInput (dwMainThreadId, dwWindowsThreadId, TRUE);
6410 #endif 6344 #endif
6411 6345
6412 /* Dynamically link to optional system components. */ 6346 /* Load system settings. */
6413 { 6347 {
6414 HANDLE user_lib = LoadLibrary ("user32.dll");
6415 UINT smoothing_type; 6348 UINT smoothing_type;
6416 BOOL smoothing_enabled; 6349 BOOL smoothing_enabled;
6417 6350
6418 #define LOAD_PROC(fn) pfn##fn = (void *) GetProcAddress (user_lib, #fn)
6419
6420 /* New proportional scroll bar functions. */
6421 LOAD_PROC (SetScrollInfo);
6422 LOAD_PROC (GetScrollInfo);
6423
6424 #undef LOAD_PROC
6425
6426 FreeLibrary (user_lib);
6427
6428 /* If using proportional scroll bars, ensure handle is at least 5 pixels; 6351 /* If using proportional scroll bars, ensure handle is at least 5 pixels;
6429 otherwise use the fixed height. */ 6352 otherwise use the fixed height. */
6430 vertical_scroll_bar_min_handle = (pfnSetScrollInfo != NULL) ? 5 : 6353 vertical_scroll_bar_min_handle = 5;
6431 GetSystemMetrics (SM_CYVTHUMB);
6432 6354
6433 /* For either kind of scroll bar, take account of the arrows; these 6355 /* For either kind of scroll bar, take account of the arrows; these
6434 effectively form the border of the main scroll bar range. */ 6356 effectively form the border of the main scroll bar range. */
6435 vertical_scroll_bar_top_border = vertical_scroll_bar_bottom_border 6357 vertical_scroll_bar_top_border = vertical_scroll_bar_bottom_border
6436 = GetSystemMetrics (SM_CYVSCROLL); 6358 = GetSystemMetrics (SM_CYVSCROLL);