aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2006-06-05 21:20:59 +0000
committerJason Rumney2006-06-05 21:20:59 +0000
commit818a1a5d1f108a6969c766c216712a8260ff4489 (patch)
treed7a5ee31f407add06257d29bfc610b7a6ee160e8 /src
parent94856834ef3129eb58e6faa5f9144849d7637524 (diff)
downloademacs-818a1a5d1f108a6969c766c216712a8260ff4489.tar.gz
emacs-818a1a5d1f108a6969c766c216712a8260ff4489.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c200
1 files changed, 61 insertions, 139 deletions
diff --git a/src/w32term.c b/src/w32term.c
index c55a4cc715c..f691b4cb9a8 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -146,32 +146,6 @@ HANDLE hWindowsThread = NULL;
146DWORD dwMainThreadId = 0; 146DWORD dwMainThreadId = 0;
147HANDLE hMainThread = NULL; 147HANDLE hMainThread = NULL;
148 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
158typedef 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;
168typedef SCROLLINFO CONST FAR *LPCSCROLLINFO;
169#endif /* SIF_ALL */
170
171/* Dynamic linking to new proportional scroll bar functions. */
172int (PASCAL *pfnSetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
173BOOL (PASCAL *pfnGetScrollInfo) (HWND hwnd, int fnBar, LPSCROLLINFO lpsi);
174
175int vertical_scroll_bar_min_handle; 149int vertical_scroll_bar_min_handle;
176int vertical_scroll_bar_top_border; 150int vertical_scroll_bar_top_border;
177int vertical_scroll_bar_bottom_border; 151int vertical_scroll_bar_bottom_border;
@@ -3487,6 +3461,7 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
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 {
@@ -3511,24 +3486,17 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
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}
@@ -3617,6 +3585,7 @@ x_scroll_bar_create (w, 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
@@ -3635,26 +3604,15 @@ x_scroll_bar_create (w, top, left, width, height)
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;
3610 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3611 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3612 si.nPage = si.nMax;
3613 si.nPos = 0;
3641 3614
3642 si.cbSize = sizeof (si); 3615 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3643 si.fMask = SIF_ALL;
3644 si.nMin = 0;
3645 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3646 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
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
@@ -3763,6 +3721,8 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
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 {
@@ -3782,21 +3742,15 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
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)
3786 {
3787 SCROLLINFO si;
3788 3745
3789 si.cbSize = sizeof (si); 3746 si.cbSize = sizeof (si);
3790 si.fMask = SIF_RANGE; 3747 si.fMask = SIF_RANGE;
3791 si.nMin = 0; 3748 si.nMin = 0;
3792 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height) 3749 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3793 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3750 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3751
3752 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3794 3753
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
@@ -3948,19 +3902,13 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
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);
3905 SCROLLINFO si;
3951 3906
3952 if (pfnGetScrollInfo) 3907 si.cbSize = sizeof (si);
3953 { 3908 si.fMask = SIF_POS;
3954 SCROLLINFO si;
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
@@ -3997,21 +3945,18 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
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;
4003 3950
4004 si.cbSize = sizeof (si); 3951 si.cbSize = sizeof (si);
4005 si.fMask = SIF_POS; 3952 si.fMask = SIF_POS;
4006 si.nPos = y; 3953 si.nPos = y;
4007 /* Remember apparent position (we actually lag behind the real 3954 /* Remember apparent position (we actually lag behind the real
4008 position, so don't set that directly. */ 3955 position, so don't set that directly. */
4009 last_scroll_bar_drag_pos = y; 3956 last_scroll_bar_drag_pos = y;
4010 3957
4011 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); 3958 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE);
4012 } 3959 }
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
@@ -4019,20 +3964,15 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
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:
@@ -4063,25 +4003,19 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
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;
4075 4015
4076 si.cbSize = sizeof (si); 4016 GetScrollInfo (w, SB_CTL, &si);
4077 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE; 4017 pos = si.nPos;
4078 4018 top_range = si.nMax - si.nPage + 1;
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 {
@@ -6409,26 +6343,14 @@ w32_initialize ()
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. */