aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorKaroly Lorentey2006-06-12 07:27:12 +0000
committerKaroly Lorentey2006-06-12 07:27:12 +0000
commit476e9367ec1f440aa23904b7bc482ea4a3b8041c (patch)
tree4f7f5a5e9a6668f908834bb6e216c8fa3727d4b3 /src/w32term.c
parenta13f8f50d4cc544d3bbfa78568e82ce09e68bded (diff)
parent6b519504c3297595101628e823e72c91e562ab45 (diff)
downloademacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.tar.gz
emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.zip
Merged from emacs@sv.gnu.org.
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-294 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-295 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-296 Update from CVS: admin/FOR-RELEASE: Update refcard section. * emacs@sv.gnu.org/emacs--devo--0--patch-297 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-298 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-299 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-300 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-301 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-302 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-303 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-304 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-103 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-104 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-570
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c240
1 files changed, 91 insertions, 149 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 05fd303f4d1..f85a5334022 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;
@@ -2389,20 +2363,29 @@ x_draw_stretch_glyph_string (s)
2389 { 2363 {
2390 /* If `x-stretch-block-cursor' is nil, don't draw a block cursor 2364 /* If `x-stretch-block-cursor' is nil, don't draw a block cursor
2391 as wide as the stretch glyph. */ 2365 as wide as the stretch glyph. */
2392 int width = min (FRAME_COLUMN_WIDTH (s->f), s->background_width); 2366 int width, background_width = s->background_width;
2367 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
2368
2369 if (x < left_x)
2370 {
2371 background_width -= left_x - x;
2372 x = left_x;
2373 }
2374 width = min (FRAME_COLUMN_WIDTH (s->f), background_width);
2393 2375
2394 /* Draw cursor. */ 2376 /* Draw cursor. */
2395 x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height); 2377 x_draw_glyph_string_bg_rect (s, x, s->y, width, s->height);
2396 2378
2397 /* Clear rest using the GC of the original non-cursor face. */ 2379 /* Clear rest using the GC of the original non-cursor face. */
2398 if (width < s->background_width) 2380 if (width < background_width)
2399 { 2381 {
2400 XGCValues *gc = s->face->gc; 2382 XGCValues *gc = s->face->gc;
2401 int x = s->x + width, y = s->y; 2383 int y = s->y;
2402 int w = s->background_width - width, h = s->height; 2384 int w = background_width - width, h = s->height;
2403 RECT r; 2385 RECT r;
2404 HDC hdc = s->hdc; 2386 HDC hdc = s->hdc;
2405 2387
2388 x += width;
2406 if (s->row->mouse_face_p 2389 if (s->row->mouse_face_p
2407 && cursor_in_mouse_face_p (s->w)) 2390 && cursor_in_mouse_face_p (s->w))
2408 { 2391 {
@@ -2431,8 +2414,18 @@ x_draw_stretch_glyph_string (s)
2431 } 2414 }
2432 } 2415 }
2433 else if (!s->background_filled_p) 2416 else if (!s->background_filled_p)
2434 x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width, 2417 {
2435 s->height); 2418 int background_width = s->background_width;
2419 int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
2420
2421 if (x < left_x)
2422 {
2423 background_width -= left_x - x;
2424 x = left_x;
2425 }
2426 if (background_width > 0)
2427 x_draw_glyph_string_bg_rect (s, x, s->y, background_width, s->height);
2428 }
2436 2429
2437 s->background_filled_p = 1; 2430 s->background_filled_p = 1;
2438} 2431}
@@ -3468,6 +3461,7 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
3468 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 3461 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
3469 int sb_page, sb_pos; 3462 int sb_page, sb_pos;
3470 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE; 3463 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE;
3464 SCROLLINFO si;
3471 3465
3472 if (whole) 3466 if (whole)
3473 { 3467 {
@@ -3492,24 +3486,17 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
3492 3486
3493 BLOCK_INPUT; 3487 BLOCK_INPUT;
3494 3488
3495 if (pfnSetScrollInfo) 3489 si.cbSize = sizeof (si);
3496 { 3490 /* Only update page size if currently dragging, to reduce
3497 SCROLLINFO si; 3491 flicker effects. */
3498 3492 if (draggingp)
3499 si.cbSize = sizeof (si); 3493 si.fMask = SIF_PAGE;
3500 /* Only update page size if currently dragging, to reduce
3501 flicker effects. */
3502 if (draggingp)
3503 si.fMask = SIF_PAGE;
3504 else
3505 si.fMask = SIF_PAGE | SIF_POS;
3506 si.nPage = sb_page;
3507 si.nPos = sb_pos;
3508
3509 pfnSetScrollInfo (w, SB_CTL, &si, !draggingp);
3510 }
3511 else 3494 else
3512 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);
3513 3500
3514 UNBLOCK_INPUT; 3501 UNBLOCK_INPUT;
3515} 3502}
@@ -3598,6 +3585,7 @@ x_scroll_bar_create (w, top, left, width, height)
3598{ 3585{
3599 struct frame *f = XFRAME (WINDOW_FRAME (w)); 3586 struct frame *f = XFRAME (WINDOW_FRAME (w));
3600 HWND hwnd; 3587 HWND hwnd;
3588 SCROLLINFO si;
3601 struct scroll_bar *bar 3589 struct scroll_bar *bar
3602 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); 3590 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
3603 3591
@@ -3616,26 +3604,15 @@ x_scroll_bar_create (w, top, left, width, height)
3616 3604
3617 hwnd = my_create_scrollbar (f, bar); 3605 hwnd = my_create_scrollbar (f, bar);
3618 3606
3619 if (pfnSetScrollInfo) 3607 si.cbSize = sizeof (si);
3620 { 3608 si.fMask = SIF_ALL;
3621 SCROLLINFO si; 3609 si.nMin = 0;
3622 3610 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3623 si.cbSize = sizeof (si); 3611 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3624 si.fMask = SIF_ALL; 3612 si.nPage = si.nMax;
3625 si.nMin = 0; 3613 si.nPos = 0;
3626 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3627 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3628 si.nPage = si.nMax;
3629 si.nPos = 0;
3630 3614
3631 pfnSetScrollInfo (hwnd, SB_CTL, &si, FALSE); 3615 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3632 }
3633 else
3634 {
3635 SetScrollRange (hwnd, SB_CTL, 0,
3636 VERTICAL_SCROLL_BAR_TOP_RANGE (f, height), FALSE);
3637 SetScrollPos (hwnd, SB_CTL, 0, FALSE);
3638 }
3639 3616
3640 SET_SCROLL_BAR_W32_WINDOW (bar, hwnd); 3617 SET_SCROLL_BAR_W32_WINDOW (bar, hwnd);
3641 3618
@@ -3744,6 +3721,8 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
3744 else 3721 else
3745 { 3722 {
3746 HDC hdc; 3723 HDC hdc;
3724 SCROLLINFO si;
3725
3747 BLOCK_INPUT; 3726 BLOCK_INPUT;
3748 if (width && height) 3727 if (width && height)
3749 { 3728 {
@@ -3763,21 +3742,15 @@ w32_set_vertical_scroll_bar (w, portion, whole, position)
3763 MoveWindow (hwnd, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 3742 MoveWindow (hwnd, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
3764 top, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 3743 top, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
3765 max (height, 1), TRUE); 3744 max (height, 1), TRUE);
3766 if (pfnSetScrollInfo)
3767 {
3768 SCROLLINFO si;
3769 3745
3770 si.cbSize = sizeof (si); 3746 si.cbSize = sizeof (si);
3771 si.fMask = SIF_RANGE; 3747 si.fMask = SIF_RANGE;
3772 si.nMin = 0; 3748 si.nMin = 0;
3773 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height) 3749 si.nMax = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height)
3774 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3750 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3751
3752 SetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3775 3753
3776 pfnSetScrollInfo (hwnd, SB_CTL, &si, FALSE);
3777 }
3778 else
3779 SetScrollRange (hwnd, SB_CTL, 0,
3780 VERTICAL_SCROLL_BAR_TOP_RANGE (f, height), FALSE);
3781 my_show_window (f, hwnd, SW_NORMAL); 3754 my_show_window (f, hwnd, SW_NORMAL);
3782 /* InvalidateRect (w, NULL, FALSE); */ 3755 /* InvalidateRect (w, NULL, FALSE); */
3783 3756
@@ -3929,19 +3902,13 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
3929 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));
3930 int y; 3903 int y;
3931 int dragging = !NILP (bar->dragging); 3904 int dragging = !NILP (bar->dragging);
3905 SCROLLINFO si;
3932 3906
3933 if (pfnGetScrollInfo) 3907 si.cbSize = sizeof (si);
3934 { 3908 si.fMask = SIF_POS;
3935 SCROLLINFO si;
3936
3937 si.cbSize = sizeof (si);
3938 si.fMask = SIF_POS;
3939 3909
3940 pfnGetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si); 3910 GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
3941 y = si.nPos; 3911 y = si.nPos;
3942 }
3943 else
3944 y = GetScrollPos ((HWND) msg->msg.lParam, SB_CTL);
3945 3912
3946 bar->dragging = Qnil; 3913 bar->dragging = Qnil;
3947 3914
@@ -3978,21 +3945,18 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
3978 emacs_event->part = scroll_bar_handle; 3945 emacs_event->part = scroll_bar_handle;
3979 3946
3980 /* "Silently" update current position. */ 3947 /* "Silently" update current position. */
3981 if (pfnSetScrollInfo) 3948 {
3982 { 3949 SCROLLINFO si;
3983 SCROLLINFO si;
3984 3950
3985 si.cbSize = sizeof (si); 3951 si.cbSize = sizeof (si);
3986 si.fMask = SIF_POS; 3952 si.fMask = SIF_POS;
3987 si.nPos = y; 3953 si.nPos = y;
3988 /* Remember apparent position (we actually lag behind the real 3954 /* Remember apparent position (we actually lag behind the real
3989 position, so don't set that directly. */ 3955 position, so don't set that directly. */
3990 last_scroll_bar_drag_pos = y; 3956 last_scroll_bar_drag_pos = y;
3991 3957
3992 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE); 3958 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE);
3993 } 3959 }
3994 else
3995 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, y, FALSE);
3996 break; 3960 break;
3997 case SB_ENDSCROLL: 3961 case SB_ENDSCROLL:
3998 /* 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
@@ -4000,20 +3964,15 @@ w32_scroll_bar_handle_click (bar, msg, emacs_event)
4000 nothing. */ 3964 nothing. */
4001 if (dragging) 3965 if (dragging)
4002 { 3966 {
4003 if (pfnSetScrollInfo) 3967 SCROLLINFO si;
4004 { 3968 int start = XINT (bar->start);
4005 SCROLLINFO si; 3969 int end = XINT (bar->end);
4006 int start = XINT (bar->start); 3970
4007 int end = XINT (bar->end); 3971 si.cbSize = sizeof (si);
4008 3972 si.fMask = SIF_PAGE | SIF_POS;
4009 si.cbSize = sizeof (si); 3973 si.nPage = end - start + VERTICAL_SCROLL_BAR_MIN_HANDLE;
4010 si.fMask = SIF_PAGE | SIF_POS; 3974 si.nPos = last_scroll_bar_drag_pos;
4011 si.nPage = end - start + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3975 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
4012 si.nPos = last_scroll_bar_drag_pos;
4013 pfnSetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
4014 }
4015 else
4016 SetScrollPos (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, y, TRUE);
4017 } 3976 }
4018 /* fall through */ 3977 /* fall through */
4019 default: 3978 default:
@@ -4044,25 +4003,19 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4044 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 4003 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
4045 int pos; 4004 int pos;
4046 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;
4047 4007
4048 BLOCK_INPUT; 4008 BLOCK_INPUT;
4049 4009
4050 *fp = f; 4010 *fp = f;
4051 *bar_window = bar->window; 4011 *bar_window = bar->window;
4052 4012
4053 if (pfnGetScrollInfo) 4013 si.cbSize = sizeof (si);
4054 { 4014 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
4055 SCROLLINFO si;
4056
4057 si.cbSize = sizeof (si);
4058 si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
4059 4015
4060 pfnGetScrollInfo (w, SB_CTL, &si); 4016 GetScrollInfo (w, SB_CTL, &si);
4061 pos = si.nPos; 4017 pos = si.nPos;
4062 top_range = si.nMax - si.nPage + 1; 4018 top_range = si.nMax - si.nPage + 1;
4063 }
4064 else
4065 pos = GetScrollPos (w, SB_CTL);
4066 4019
4067 switch (LOWORD (last_mouse_scroll_bar_pos)) 4020 switch (LOWORD (last_mouse_scroll_bar_pos))
4068 { 4021 {
@@ -4931,7 +4884,7 @@ x_draw_hollow_cursor (w, row)
4931 struct frame *f = XFRAME (WINDOW_FRAME (w)); 4884 struct frame *f = XFRAME (WINDOW_FRAME (w));
4932 HDC hdc; 4885 HDC hdc;
4933 RECT rect; 4886 RECT rect;
4934 int h; 4887 int left, top, h;
4935 struct glyph *cursor_glyph; 4888 struct glyph *cursor_glyph;
4936 HBRUSH hb = CreateSolidBrush (f->output_data.w32->cursor_pixel); 4889 HBRUSH hb = CreateSolidBrush (f->output_data.w32->cursor_pixel);
4937 4890
@@ -4942,8 +4895,9 @@ x_draw_hollow_cursor (w, row)
4942 return; 4895 return;
4943 4896
4944 /* Compute frame-relative coordinates for phys cursor. */ 4897 /* Compute frame-relative coordinates for phys cursor. */
4945 rect.left = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 4898 get_phys_cursor_geometry (w, row, cursor_glyph, &left, &top, &h);
4946 rect.top = get_phys_cursor_geometry (w, row, cursor_glyph, &h); 4899 rect.left = left;
4900 rect.top = top;
4947 rect.bottom = rect.top + h; 4901 rect.bottom = rect.top + h;
4948 rect.right = rect.left + w->phys_cursor_width; 4902 rect.right = rect.left + w->phys_cursor_width;
4949 4903
@@ -6390,26 +6344,14 @@ w32_initialize ()
6390 AttachThreadInput (dwMainThreadId, dwWindowsThreadId, TRUE); 6344 AttachThreadInput (dwMainThreadId, dwWindowsThreadId, TRUE);
6391#endif 6345#endif
6392 6346
6393 /* Dynamically link to optional system components. */ 6347 /* Load system settings. */
6394 { 6348 {
6395 HANDLE user_lib = LoadLibrary ("user32.dll");
6396 UINT smoothing_type; 6349 UINT smoothing_type;
6397 BOOL smoothing_enabled; 6350 BOOL smoothing_enabled;
6398 6351
6399#define LOAD_PROC(fn) pfn##fn = (void *) GetProcAddress (user_lib, #fn)
6400
6401 /* New proportional scroll bar functions. */
6402 LOAD_PROC (SetScrollInfo);
6403 LOAD_PROC (GetScrollInfo);
6404
6405#undef LOAD_PROC
6406
6407 FreeLibrary (user_lib);
6408
6409 /* If using proportional scroll bars, ensure handle is at least 5 pixels; 6352 /* If using proportional scroll bars, ensure handle is at least 5 pixels;
6410 otherwise use the fixed height. */ 6353 otherwise use the fixed height. */
6411 vertical_scroll_bar_min_handle = (pfnSetScrollInfo != NULL) ? 5 : 6354 vertical_scroll_bar_min_handle = 5;
6412 GetSystemMetrics (SM_CYVTHUMB);
6413 6355
6414 /* For either kind of scroll bar, take account of the arrows; these 6356 /* For either kind of scroll bar, take account of the arrows; these
6415 effectively form the border of the main scroll bar range. */ 6357 effectively form the border of the main scroll bar range. */