Changeset 3997
- Timestamp:
- 2005年12月13日 22時48分17秒 (3 years ago)
- Files:
-
- trunk/src/ChangeLog.Meadow (modified) (1 diff)
- trunk/src/dispnew.c (modified) (9 diffs)
- trunk/src/eval.c (modified) (1 diff)
- trunk/src/frame.c (modified) (2 diffs)
- trunk/src/image.c (modified) (2 diffs)
- trunk/src/mw32fns.c (modified) (17 diffs)
- trunk/src/mw32font.c (modified) (2 diffs)
- trunk/src/mw32sync.h (modified) (1 diff)
- trunk/src/mw32term.c (modified) (14 diffs)
- trunk/src/mw32term.h (modified) (8 diffs)
- trunk/src/window.c (modified) (6 diffs)
- trunk/src/xdisp.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/ChangeLog.Meadow
r3996 r3997 1 2005-12-13 Kyotaro HORIGUCHI <horiguti@meadowy.org> 2 3 * dispnew.c (adjust_glyphs): Remove W32_BLOCK_INPUT, 4 W32_UNBLOCK_INPUT. 5 (free_glyphs): Ditto. 6 (update_single_window): Ditto. 7 (change_frame_size_1): Ditto. 8 (update_frame): Ditto. Do GET_FRAME_HDC(), RELEASE_FRAME_HDC(). 9 10 * mw32term.c (main_thread_hdc): New variable. 11 (main_thread_hdc_nestlevel): Ditto. 12 (main_thread_hdc_hwnd): Ditto. 13 (mw32_destroy_frame_hdc): Release main thread DC on destroying the 14 owner frame. 15 (mw32_set_caret): Remove W32_BLOCK_INPUT/W32_UNBLOCK_INPUT. Avoid 16 unnecessary call to message thread. 17 (MW32_update_begin): Changed. Do blocking of caret. 18 (MW32_update_end): Changed. Do unblocking of caret. 19 (MW32_frame_up_to_date): Remove W32_BLOCK_INPUT/W32_UNBLOCK_INPUT. 20 (mw32_get_ime_font_property): Remove treatment for 21 W32_BLOCK_INPUT. 22 (mw32_process_main_thread_message<WM_EMACS_EXPOSE_FRAME>): 23 Removed. 24 (unwind_get_device_capability): Alter RELEASE_TEMP_HDC with 25 RELEASE_FRAME_HDC. 26 (mw32-get-device-capability): Alter GET_TEMP_HDC with 27 GET_FRAME_HDC. 28 29 * mw32term.h (main_thread_hdc): New extern. 30 (main_thread_hdc_nestlevel): Ditto. 31 (main_thread_hdc_hwnd): Ditto. 32 (struct mw32_output): Rename member hdc_refcount to hdc_nestlevel, 33 message_thread_hdc to hdc. Removed members message_thread_hdc and 34 message_thread_hdc_refcount. 35 (FRAME_HDC): Changed. 36 (GET_FRAME_HDC): Changed. 37 (RELEASE_FRAME_HDC): Ditto. 38 (GET_TEMP_HDC): Removed. 39 (RELEASE_TEMP_HDC): Ditto. 40 (CLEANUP_FRAME_HDC): New macro. 41 (FRAME_HDC_VALID_P): Changed. 42 (update_begin_hook): New extern. 43 (update_end_hook): Ditto. 44 45 * mw32sync.h (main_thread_id): New extern. 46 (W32_BLOCK_INPUT): Removed. 47 (W32_UNBLOCK_INPUT): Removed. 48 49 * mw32fns.c (mw32m_new_focus_frame): Variable name for hdc is 50 changed. Remove W32_BLOCK_INPUT/W32_UNBLOCK_INPUT. 51 (mw32_WndProc<WM_ERASEBKGND>): Variable names for hdc are changed. 52 (mw32_WndProc<WM_PAINT>): Variable name for hdc is changed. Remove 53 W32_BLOCK_INPUT/W32_UNBLOCK_INPUT. 54 (mw32_WndProc<WM_SETFOCUS>): Synchronizing caret state. 55 (mw32_WndProc<WM_KILLFOCUS>): Ditto. 56 (mw32_WndProc<WM_EMACS_SETCARET>): Changed. 57 (x-create-frame): Variable names for hdc are changed. Replace 58 GET_TEMP_HDC with GET_FRAME_HDC. Also for RELEASE_*. 59 (mw32_create_tip_frame)Variable names for hdc are changed. 60 61 * mw32font.c (mw32_load_lf): Replace GET_TEMP_HDC with 62 GET_FRAME_HDC. Also for RELEASE_*. 63 64 * image.c (get_image_data_from_icon): Ditto. 65 66 * xdisp.c (redisplay_internal): Cleanup main thread hdc. 67 68 * frame.c (delete-frame): Use GET_FRAME_HDC to block message 69 thread as alternative of W32_BLOCK_INPUT. 70 71 * window.c (delete_window): Remove 72 W32_BLOCK_INPUT/W32_UNBLOCK_INPUT. 73 (set-window-configuration): Ditto. 74 1 75 2005-12-01 MIYOSHI Masanori <miyoshi@meadowy.org> 2 76 trunk/src/dispnew.c
r3978 r3997 2081 2081 /* Block input so that expose events and other events that access 2082 2082 glyph matrices are not processed while we are changing them. */ 2083 #ifdef MEADOW2084 W32_BLOCK_INPUT;2085 #endif2086 2083 BLOCK_INPUT; 2087 2084 … … 2097 2094 2098 2095 UNBLOCK_INPUT; 2099 #ifdef MEADOW2100 W32_UNBLOCK_INPUT;2101 #endif2102 2096 } 2103 2097 … … 2494 2488 /* Block interrupt input so that we don't get surprised by an X 2495 2489 event while we're in an inconsistent state. */ 2496 #ifdef MEADOW2497 W32_BLOCK_INPUT;2498 #endif2499 2490 BLOCK_INPUT; 2500 2491 f->glyphs_initialized_p = 0; … … 2543 2534 2544 2535 UNBLOCK_INPUT; 2545 #ifdef MEADOW2546 W32_UNBLOCK_INPUT;2547 #endif2548 2536 } 2549 2537 } … … 3848 3836 3849 3837 #ifdef MEADOW 3850 W32_BLOCK_INPUT;3838 GET_FRAME_HDC (f); 3851 3839 #endif 3852 3840 if (FRAME_WINDOW_P (f)) … … 3928 3916 } 3929 3917 #ifdef MEADOW 3930 W32_UNBLOCK_INPUT;3918 RELEASE_FRAME_HDC (f); 3931 3919 #endif 3932 3920 … … 3987 3975 /* Update W. */ 3988 3976 update_begin (f); 3989 #ifdef MEADOW3990 W32_BLOCK_INPUT;3991 #endif3992 3977 update_window (w, force_p); 3993 #ifdef MEADOW3994 W32_UNBLOCK_INPUT;3995 #endif3996 3978 update_end (f); 3997 3979 … … 6211 6193 return; 6212 6194 6213 #ifdef MEADOW6214 W32_BLOCK_INPUT;6215 #endif6216 6195 BLOCK_INPUT; 6217 6196 … … 6282 6261 6283 6262 UNBLOCK_INPUT; 6284 #ifdef MEADOW6285 W32_UNBLOCK_INPUT;6286 #endif6287 6263 6288 6264 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); trunk/src/eval.c
r3945 r3997 1601 1601 if (gc_in_progress || waiting_for_input) 1602 1602 abort (); 1603 1604 #ifdef MEADOW1605 if (W32_SELF_INPUT_BLOCKED_P)1606 W32_UNBLOCK_INPUT;1607 #endif /* MEADOW */1608 1603 1609 1604 if (NILP (error_symbol)) trunk/src/frame.c
r3982 r3997 1277 1277 /* during destroying the windows, 1278 1278 we must block the message loop. */ 1279 W32_BLOCK_INPUT;1279 GET_FRAME_HDC (f); /* Use only side effect */ 1280 1280 #endif 1281 1281 /* Free glyphs. … … 1290 1290 f->root_window = Qnil; 1291 1291 #ifdef MEADOW 1292 W32_UNBLOCK_INPUT;1292 RELEASE_FRAME_HDC (f); 1293 1293 #endif 1294 1294 trunk/src/image.c
r3990 r3997 10105 10105 unsigned char *bmpdata; 10106 10106 struct frame *f = SELECTED_FRAME (); 10107 HDC hdc = GET_ TEMP_HDC (f);10107 HDC hdc = GET_FRAME_HDC (f); 10108 10108 HDC cdc = CreateCompatibleDC (hdc); 10109 10109 … … 10135 10135 DeleteDC (cdc); 10136 10136 10137 RELEASE_ TEMP_HDC (f);10137 RELEASE_FRAME_HDC (f); 10138 10138 } 10139 10139 trunk/src/mw32fns.c
r3996 r3997 1698 1698 hdc1 = GetDC (FRAME_MW32_WINDOW (f)); 1699 1699 mw32_setup_default_hdc (hdc1); 1700 f->output_data.mw32-> message_thread_hdc = hdc1;1700 f->output_data.mw32->hdc = hdc1; 1701 1701 } 1702 1702 else … … 1707 1707 hdc2 = GetDC (FRAME_MW32_WINDOW (fold)); 1708 1708 mw32_setup_default_hdc (hdc2); 1709 fold->output_data.mw32-> message_thread_hdc = hdc2;1709 fold->output_data.mw32->hdc = hdc2; 1710 1710 } 1711 1711 else 1712 1712 hdc2 = INVALID_HANDLE_VALUE; 1713 1713 1714 W32_BLOCK_INPUT;1715 1714 mw32_new_focus_frame (dpyinfo, f); 1716 W32_UNBLOCK_INPUT;1717 1715 1718 1716 if (hdc1 != INVALID_HANDLE_VALUE) 1719 1717 { 1720 f->output_data.mw32-> message_thread_hdc = INVALID_HANDLE_VALUE;1718 f->output_data.mw32->hdc = INVALID_HANDLE_VALUE; 1721 1719 ReleaseDC (FRAME_MW32_WINDOW (f), hdc1); 1722 1720 } 1723 1721 if (hdc2 != INVALID_HANDLE_VALUE) 1724 1722 { 1725 fold->output_data.mw32-> message_thread_hdc = INVALID_HANDLE_VALUE;1723 fold->output_data.mw32->hdc = INVALID_HANDLE_VALUE; 1726 1724 ReleaseDC (FRAME_MW32_WINDOW (fold), hdc2); 1727 1725 } … … 1940 1938 HDC ohdc; 1941 1939 1942 orefcount = f->output_data.mw32-> message_thread_hdc_refcount;1943 ohdc = f->output_data.mw32-> message_thread_hdc;1944 1945 f->output_data.mw32-> message_thread_hdc = (HDC) wParam;1946 f->output_data.mw32-> message_thread_hdc_refcount= 1;1940 orefcount = f->output_data.mw32->hdc_nestlevel; 1941 ohdc = f->output_data.mw32->hdc; 1942 1943 f->output_data.mw32->hdc = (HDC) wParam; 1944 f->output_data.mw32->hdc_nestlevel = 1; 1947 1945 1948 1946 GetClientRect (FRAME_MW32_WINDOW (f), &rect); … … 1950 1948 rect.right, rect.bottom); 1951 1949 1952 f->output_data.mw32-> message_thread_hdc = ohdc;1953 f->output_data.mw32-> message_thread_hdc_refcount= orefcount;1950 f->output_data.mw32->hdc = ohdc; 1951 f->output_data.mw32->hdc_nestlevel = orefcount; 1954 1952 1955 1953 return 0; … … 1975 1973 /* Avoid conflicting with drawing in main thread. */ 1976 1974 EnterCriticalSection (&(f->output_data.mw32->hdc_critsec)); 1977 if ( f->output_data.mw32->hdc == INVALID_HANDLE_VALUE)1975 if (main_thread_hdc == INVALID_HANDLE_VALUE) 1978 1976 { 1979 1977 BeginPaint (FRAME_MW32_WINDOW (f), &ps); … … 1983 1981 GetClientRect (FRAME_MW32_WINDOW (f), &rc); 1984 1982 1985 W32_BLOCK_INPUT;1986 1987 1983 expose_frame (f, 1988 1984 rc.left, rc.top, 1989 1985 rc.right - rc.left, 1990 1986 rc.bottom - rc.top); 1991 W32_UNBLOCK_INPUT; 1987 1992 1988 RELEASE_FRAME_HDC (f); 1993 1989 EndPaint (FRAME_MW32_WINDOW (f), &ps); … … 2017 2013 2018 2014 mw32_update_frame_alpha (f); 2015 2016 /* Synchronize caret state */ 2017 if (CARET_CURSOR_P (XWINDOW (f->selected_window)->phys_cursor_type) 2018 && MW32_FRAME_CARET_SHOWN (f)) 2019 { 2020 DestroyCaret (); 2021 MW32_FRAME_CARET_STATE (f) = NO_CARET; 2022 MW32_FRAME_CARET_BLOCKED (f) = FALSE; 2023 PostMessage (hwnd, WM_EMACS_SETCARET, (WPARAM)SHOWN_CARET, (LPARAM)0); 2024 } 2019 2025 return 0; 2020 2026 … … 2025 2031 DestroyCaret (); 2026 2032 MW32_FRAME_CARET_STATE (f) = NO_CARET; 2033 MW32_FRAME_CARET_BLOCKED (f) = FALSE; 2027 2034 } 2028 2035 … … 2031 2038 2032 2039 /* reset mouse face and help echo. */ 2040 mw32_update_frame_alpha (f); 2041 2033 2042 PostMessage (hwnd, WM_EMACS_CLEAR_MOUSE_FACE, 2034 2043 (WPARAM) 1, (LPARAM) 0); 2035 2044 2036 mw32_update_frame_alpha (f);2037 2045 return 0; 2038 2046 … … 2552 2560 DestroyCaret (); 2553 2561 MW32_FRAME_CARET_STATE (last_cursor_frame) = NO_CARET; 2562 MW32_FRAME_CARET_BLOCKED (last_cursor_frame) = FALSE; 2554 2563 } 2555 2564 last_cursor_frame = f; … … 2579 2588 if (wParam == BLOCK_CARET) 2580 2589 { 2590 if (MW32_FRAME_CARET_BLOCKED (f)) 2591 goto setcaret_end; 2592 2581 2593 MW32_FRAME_CARET_BLOCKED (f) = TRUE; 2582 2594 … … 2590 2602 if (wParam == UNBLOCK_CARET) 2591 2603 { 2604 if (!MW32_FRAME_CARET_BLOCKED (f)) 2605 goto setcaret_end; 2606 2592 2607 MW32_FRAME_CARET_BLOCKED (f) = FALSE; 2593 2594 if (MW32_FRAME_CARET_SHOWN (f) 2595 || MW32_FRAME_CARET_STATE (f) == TOBESHOWN_CARET) 2596 { 2597 if (ShowCaret (hwnd) == 0) 2598 MW32_FRAME_CARET_STATE (f) = TOBESHOWN_CARET; 2599 else 2600 MW32_FRAME_CARET_STATE (f) = SHOWN_CARET; 2601 } 2602 goto setcaret_end; 2608 wParam = MW32_FRAME_CARET_SHOWN (f) ? SHOWN_CARET : HIDDEN_CARET; 2609 MW32_FRAME_CARET_STATE (f) = HIDDEN_CARET; 2603 2610 } 2604 2611 … … 2612 2619 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y) 2613 2620 + w->phys_cursor_height - caret_height; 2614 2615 if (caret_spec_changed) 2616 { 2617 if (MW32_FRAME_CARET_STATE (f) > NO_CARET) 2618 { 2619 DestroyCaret (); 2620 MW32_FRAME_CARET_STATE (f) = NO_CARET; 2621 } 2622 } 2623 2624 if (MW32_FRAME_CARET_STATE (f) == NO_CARET) 2625 { 2626 CreateCaret (hwnd, 2627 MW32_FRAME_CARET_BITMAP (f), 2628 FRAME_CURSOR_WIDTH (f), 2629 caret_height); 2630 MW32_FRAME_CARET_STATE (f) = HIDDEN_CARET; 2631 MW32_FRAME_CARET_BLOCKED (f) = FALSE; 2632 last_phys_cursor_height = w->phys_cursor_height; 2633 last_cursor_width = FRAME_CURSOR_WIDTH (f); 2634 last_cursor_height = MW32_FRAME_CARET_HEIGHT (f); 2635 last_bitmap = MW32_FRAME_CARET_BITMAP (f); 2636 } 2637 2638 SetCaretPos (caret_xpos, caret_ypos); 2639 2640 if (MW32_FRAME_CARET_SHOWN (f)) 2641 goto setcaret_end; 2642 MW32_FRAME_CARET_STATE (f) = SHOWN_CARET; 2643 if (! MW32_FRAME_CARET_BLOCKED (f)) 2644 { 2645 if (ShowCaret (hwnd) == 0) 2646 MW32_FRAME_CARET_STATE (f) = TOBESHOWN_CARET; 2647 } 2621 int retry_count = 2; /* Magic number */ 2622 2623 do { 2624 if (caret_spec_changed) 2625 { 2626 if (MW32_FRAME_CARET_STATE (f) > NO_CARET) 2627 { 2628 DestroyCaret (); 2629 MW32_FRAME_CARET_STATE (f) = NO_CARET; 2630 /* Caret is immediately re-created, so it should not 2631 unblock caret. */ 2632 } 2633 caret_spec_changed = FALSE; 2634 } 2635 2636 if (MW32_FRAME_CARET_STATE (f) == NO_CARET) 2637 { 2638 CreateCaret (hwnd, 2639 MW32_FRAME_CARET_BITMAP (f), 2640 FRAME_CURSOR_WIDTH (f), 2641 caret_height); 2642 MW32_FRAME_CARET_STATE (f) = HIDDEN_CARET; 2643 MW32_FRAME_CARET_BLOCKED (f) = FALSE; 2644 last_phys_cursor_height = w->phys_cursor_height; 2645 last_cursor_width = FRAME_CURSOR_WIDTH (f); 2646 last_cursor_height = MW32_FRAME_CARET_HEIGHT (f); 2647 last_bitmap = MW32_FRAME_CARET_BITMAP (f); 2648 } 2649 2650 SetCaretPos (caret_xpos, caret_ypos); 2651 2652 if (MW32_FRAME_CARET_SHOWN (f)) 2653 goto setcaret_end; 2654 MW32_FRAME_CARET_STATE (f) = SHOWN_CARET; 2655 if (! MW32_FRAME_CARET_BLOCKED (f) && ShowCaret (hwnd) == 0) 2656 { 2657 if (GetLastError () == ERROR_ACCESS_DENIED) 2658 caret_spec_changed = TRUE; /* Retry showcaret */ 2659 else 2660 MW32_FRAME_CARET_STATE (f) = TOBESHOWN_CARET; 2661 } 2662 } while (caret_spec_changed && retry_count-- > 0); 2648 2663 } 2649 2664 else … … 2921 2936 f->output_data.mw32->menubar_handle = INVALID_HANDLE_VALUE; 2922 2937 f->output_data.mw32->hdc = INVALID_HANDLE_VALUE; 2923 f->output_data.mw32->hdc_refcount = 0; 2924 f->output_data.mw32->message_thread_hdc = INVALID_HANDLE_VALUE; 2925 f->output_data.mw32->message_thread_hdc_refcount = 0; 2938 f->output_data.mw32->hdc_nestlevel = 0; 2926 2939 f->output_data.mw32->frame_moving_or_sizing = 0; 2927 2940 f->output_data.mw32->setcaret_event = CreateEvent (NULL, TRUE, FALSE, NULL); … … 3043 3056 } 3044 3057 3045 GET_ TEMP_HDC (f);3058 GET_FRAME_HDC (f); 3046 3059 3047 3060 /* Extract the window parameters from the supplied values … … 3251 3264 Vwindow_list = Qnil; 3252 3265 3253 RELEASE_ TEMP_HDC (f);3266 RELEASE_FRAME_HDC (f); 3254 3267 return unbind_to (count, frame); 3255 3268 } … … 3999 4012 f->output_data.mw32->menubar_handle = INVALID_HANDLE_VALUE; 4000 4013 f->output_data.mw32->hdc = INVALID_HANDLE_VALUE; 4001 f->output_data.mw32->hdc_refcount = 0; 4002 f->output_data.mw32->message_thread_hdc = INVALID_HANDLE_VALUE; 4003 f->output_data.mw32->message_thread_hdc_refcount = 0; 4014 f->output_data.mw32->hdc_nestlevel = 0; 4004 4015 InitializeCriticalSection (&(f->output_data.mw32->hdc_critsec)); 4005 4016 trunk/src/mw32font.c
r3990 r3997 1467 1467 MW32LogicalFont *plf = NULL;; 1468 1468 1469 GET_ TEMP_HDC (f);1469 GET_FRAME_HDC (f); 1470 1470 1471 1471 for (i = 0; i < mw32_lf_loader_num; i++) … … 1483 1483 } 1484 1484 1485 RELEASE_ TEMP_HDC (f);1485 RELEASE_FRAME_HDC (f); 1486 1486 return plf; 1487 1487 } trunk/src/mw32sync.h
r3421 r3997 8 8 extern HANDLE keyboard_handle; 9 9 extern HANDLE interrupt_handle; 10 11 #define W32_BLOCK_INPUT \ 12 do { \ 13 EnterCriticalSection(&critsec_message); \ 14 block_input_ownthread = GetCurrentThreadId ();\ 15 } while (0); 16 #define W32_UNBLOCK_INPUT \ 17 do { \ 18 block_input_ownthread = 0; \ 19 LeaveCriticalSection(&critsec_message); \ 20 } while (0); 21 #define W32_SELF_INPUT_BLOCKED_P \ 22 (block_input_ownthread == GetCurrentThreadId ()) 10 extern DWORD main_thread_id; 23 11 24 12 #define W32_BLOCK_EVENT EnterCriticalSection(&critsec_access_event) trunk/src/mw32term.c
r3996 r3997 194 194 HWND mw32_frame_window; 195 195 196 /* Window's DC that is used by main thread. */ 197 HDC main_thread_hdc = INVALID_HANDLE_VALUE; 198 199 /* Nesting level of main_thread_hdc. */ 200 int main_thread_hdc_nestlevel = 0; 201 202 /* hwnd for main_thread_hdc to use on release. */ 203 HWND main_thread_hdc_hwnd = INVALID_HANDLE_VALUE; 196 204 197 205 /* The scroll bar in which the last X motion event occurred. … … 393 401 mw32_destroy_frame_hdc (struct frame *f) 394 402 { 403 if (main_thread_hdc != INVALID_HANDLE_VALUE) 404 ReleaseDC (FRAME_MW32_WINDOW (f), main_thread_hdc); 395 405 if (f->output_data.mw32->hdc != INVALID_HANDLE_VALUE) 396 406 ReleaseDC (FRAME_MW32_WINDOW (f), f->output_data.mw32->hdc); 407 main_thread_hdc = INVALID_HANDLE_VALUE; 397 408 f->output_data.mw32->hdc = INVALID_HANDLE_VALUE; 398 409 } … … 461 472 mw32_set_caret (struct frame *f, int state) 462 473 { 463 MSG msg; 464 int unblock = FALSE; 465 enum frame_caret_state current_state; 466 467 current_state = MW32_FRAME_CARET_STATE (f); 468 if (current_state == NO_CARET 474 int blocked = FALSE; 475 476 if (MW32_FRAME_CARET_STATE (f) == NO_CARET 469 477 && (state == BLOCK_CARET || state == UNBLOCK_CARET)) return; 470 478 479 if (MW32_FRAME_CARET_BLOCKED (f)) 480 { 481 if (state == BLOCK_CARET) 482 return; 483 484 if (state == SHOWN_CARET || state == HIDDEN_CARET) 485 { 486 MW32_FRAME_CARET_STATE (f) = state; 487 return; 488 } 489 } 471 490 if (state == BLOCK_CARET || state == HIDDEN_CARET) 472 491 ResetEvent (f->output_data.mw32->setcaret_event); 473 474 if (W32_SELF_INPUT_BLOCKED_P)475 {476 W32_UNBLOCK_INPUT;477 unblock = TRUE;478 }479 492 480 493 SEND_INFORM_MESSAGE (FRAME_MW32_WINDOW (f), … … 485 498 if (state == BLOCK_CARET || state == HIDDEN_CARET) 486 499 WaitForSingleObject (f->output_data.mw32->setcaret_event, 10); 487 488 if (unblock)489 W32_BLOCK_INPUT;490 500 } 491 501 … … 526 536 if (FRAME_MW32_P (f)) 527 537 { 528 HDC *phdc; 529 int *pcount; 530 531 538 MW32_BLOCK_CARET (f); 532 539 if (MW32_MAIN_THREAD_P ()) 533 540 { 534 int block = FALSE; 535 536 if (W32_SELF_INPUT_BLOCKED_P) 541 if (main_thread_hdc != INVALID_HANDLE_VALUE) 537 542 { 538 W32_UNBLOCK_INPUT; 539 block = TRUE; 543 if (main_thread_hdc_nestlevel > GET_FRAME_HDC_LEVEL_LIMIT) 544 abort(); 545 main_thread_hdc_nestlevel++; 546 return; 540 547 } 541 548 549 main_thread_hdc_hwnd = FRAME_MW32_WINDOW (f); 542 550 EnterCriticalSection (&(f->output_data.mw32->hdc_critsec)); 543 phdc = &f->output_data.mw32->hdc;551 main_thread_hdc = GetDC (main_thread_hdc_hwnd); 544 552 LeaveCriticalSection (&(f->output_data.mw32->hdc_critsec)); 545 553 546 if (block) 547 W32_BLOCK_INPUT; 548 549 pcount = &f->output_data.mw32->hdc_refcount; 554 main_thread_hdc_nestlevel = 1; 555 mw32_setup_default_hdc (main_thread_hdc); 550 556 } 551 557 else 552 558 { 553 phdc = &f->output_data.mw32->message_thread_hdc; 554 pcount = &f->output_data.mw32->message_thread_hdc_refcount; 559 if (f->output_data.mw32->hdc != INVALID_HANDLE_VALUE) 560 { 561 if (f->output_data.mw32->hdc_nestlevel 562 > GET_FRAME_HDC_LEVEL_LIMIT) 563 abort (); 564 f->output_data.mw32->hdc_nestlevel++; 565 return; 566 } 567 568 f->output_data.mw32->hdc = GetDC (FRAME_MW32_WINDOW (f)); 569 f->output_data.mw32->hdc_nestlevel = 1; 570 mw32_setup_default_hdc (f->output_data.mw32->hdc); 555 571 } 556 557 if (*phdc != INVALID_HANDLE_VALUE)558 {559 if (*pcount > GET_FRAME_HDC_LEVEL_LIMIT)560 abort ();561 (*pcount)++;562 return;563 }564 565 *phdc = GetDC (FRAME_MW32_WINDOW (f));566 *pcount = 1;567 mw32_setup_default_hdc (*phdc);568 569 MW32_BLOCK_CARET (f);570 572 } 571 573 } … … 632 634 Lisp_Object window; 633 635 HDC *phdc; 636 HWND hwnd; 634 637 int *pcount; 635 638 … … 638 641 if (MW32_MAIN_THREAD_P ()) 639 642 { 640 phdc = &f->output_data.mw32->hdc; 641 pcount = &f->output_data.mw32->hdc_refcount; 643 phdc = &main_thread_hdc; 644 pcount = &main_thread_hdc_nestlevel; 645 hwnd = main_thread_hdc_hwnd; 642 646 } 643 647 else 644 648 { 645 phdc = &f->output_data.mw32->message_thread_hdc; 646 pcount = &f->output_data.mw32->message_thread_hdc_refcount; 649 phdc = &(f->output_data.mw32->hdc); 650 pcount = &(f->output_data.mw32->hdc_nestlevel); 651 hwnd = FRAME_MW32_WINDOW (f); 647 652 } 648 649 if (*p hdc != INVALID_HANDLE_VALUE)653 654 if (*pcount > 1) 650 655 { 651 if (*pcount > 1) 652 { 653 (*pcount)--; 654 return; 655 } 656 657 MW32_UNBLOCK_CARET (f); 656 (*pcount)--; 657 return; 658 658 } 659 660 MW32_UNBLOCK_CARET (f); 661 ReleaseDC (hwnd, *phdc); 662 *phdc = INVALID_HANDLE_VALUE; 659 663 660 664 /* Synchronize selected_window's caret state */ … … 668 672 mw32_set_caret (f, SHOWN_CARET); 669 673 } 670 671 if (*phdc == INVALID_HANDLE_VALUE || *pcount > 1)672 abort();673 674 ReleaseDC (FRAME_MW32_WINDOW (f), *phdc);675 *phdc = INVALID_HANDLE_VALUE;676 *pcount = 0;677 674 } 678 675 } … … 814 811 { 815 812 BLOCK_INPUT; 816 W32_BLOCK_INPUT; 813 817 814 if (dpyinfo->mouse_face_mouse_frame) 818 815 note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, … … 820 817 dpyinfo->mouse_face_mouse_y); 821 818 dpyinfo->mouse_face_deferred_gc = 0; 822 W32_UNBLOCK_INPUT; 819 823 820 UNBLOCK_INPUT; 824 821 } … … 4130 4127 lf.lfHeight = (int) (XFLOATINT (height) * FRAME_LINE_HEIGHT (f)); 4131 4128 } 4132 if (W32_SELF_INPUT_BLOCKED_P) 4133 { 4134 W32_UNBLOCK_INPUT; 4135 SEND_MSGTHREAD_INFORM_MESSAGE (WM_EMACS_MODIFY_IME_FONT_PROP, 4136 (WPARAM) lf.lfHeight, 0); 4137 W32_BLOCK_INPUT; 4138 } 4139 else 4140 { 4141 SEND_MSGTHREAD_INFORM_MESSAGE (WM_EMACS_MODIFY_IME_FONT_PROP, 4142 (WPARAM) lf.lfHeight, 0); 4143 } 4129 4130 SEND_MSGTHREAD_INFORM_MESSAGE (WM_EMACS_MODIFY_IME_FONT_PROP, 4131 (WPARAM) lf.lfHeight, 0); 4144 4132 } 4145 4133 … … 4188 4176 break; 4189 4177 } 4190 4191 case WM_EMACS_EXPOSE_FRAME:4192 {4193 HDC hdc;4194 RECT rc;4195 struct frame *f = (struct frame *)msg.wParam;4196 4197 hdc = GET_FRAME_HDC (f);4198 mw32_setup_default_hdc (hdc);4199 4200 GetClientRect (FRAME_MW32_WINDOW (f), &rc);4201 4202 W32_BLOCK_INPUT;4203 expose_frame (f,4204 rc.left, rc.top,4205 rc.right - rc.left,4206 rc.bottom - rc.top);4207 W32_UNBLOCK_INPUT;4208 RELEASE_FRAME_HDC (f);4209 }4210 break;4211 4178 } 4212 4179 if (pwait_msg && (pwait_msg->message == msg.message)) … … 6532 6499 Lisp_Object data; 6533 6500 { 6534 RELEASE_ TEMP_HDC (XFRAME (data));6501 RELEASE_FRAME_HDC (XFRAME (data)); 6535 6502 6536 6503 return Qnil; … … 6559 6526 record_unwind_protect (unwind_get_device_capability, frame); 6560 6527 6561 hdc = GET_ TEMP_HDC (XFRAME (frame));6528 hdc = GET_FRAME_HDC (XFRAME (frame)); 6562 6529 6563 6530 if (EQ (item, intern ("width-in-mm"))) trunk/src/mw32term.h
r3985 r3997 319 319 extern int unibyte_display_via_language_environment; 320 320 321 /* Window's DC that is used by main thread. */ 322 extern HDC main_thread_hdc; 323 324 /* Nesting level of main_thread_hdc. */ 325 extern int main_thread_hdc_nestlevel; 326 327 /* hwnd for main_thread_hdc to use on release. */ 328 extern HWND main_thread_hdc_hwnd; 329 321 330 #define GET_MW32_DISPLAY_INFO(arg) (mw32_display_list) 322 331 … … 379 388 HDC hdc; 380 389 381 /* Refernce count of hdc. */ 382 int hdc_refcount; 383 384 /* Window's DC that is used for message thread. */ 385 HDC message_thread_hdc; 386 387 /* Reference count of message_thread_hdc. */ 388 int message_thread_hdc_refcount; 390 /* Nesting level of hdc. */ 391 int hdc_nestlevel; 389 392 390 393 /* Critical section to synchronize processces using hdc for this … … 525 528 (! FRAME_WINDOW_P (f)? INVALID_HANDLE_VALUE: \ 526 529 (MW32_MAIN_THREAD_P() ? \ 527 ( ((f)->output_data.mw32->hdc != INVALID_HANDLE_VALUE)\528 ? (f)->output_data.mw32->hdc\530 (main_thread_hdc != INVALID_HANDLE_VALUE \ 531 ? main_thread_hdc \ 529 532 : (abort (), INVALID_HANDLE_VALUE)) \ 530 : (((f)->output_data.mw32-> message_thread_hdc\533 : (((f)->output_data.mw32->hdc \ 531 534 != INVALID_HANDLE_VALUE) \ 532 ? (f)->output_data.mw32-> message_thread_hdc\535 ? (f)->output_data.mw32->hdc \ 533 536 : (abort(), INVALID_HANDLE_VALUE)))) 534 537 … … 538 541 (! FRAME_WINDOW_P (f)? INVALID_HANDLE_VALUE: \ 539 542 (MW32_MAIN_THREAD_P() \ 540 ?(((f)->output_data.mw32->hdc != INVALID_HANDLE_VALUE) \ 541 ?(((f)->output_data.mw32->hdc_refcount++>GET_FRAME_HDC_LEVEL_LIMIT) \ 543 ?(main_thread_hdc != INVALID_HANDLE_VALUE \ 544 ?((main_thread_hdc_nestlevel++ > GET_FRAME_HDC_LEVEL_LIMIT) \ 545 ?(abort(), INVALID_HANDLE_VALUE) \ 546 :main_thread_hdc) \ 547 :(update_begin_hook (f), main_thread_hdc)) \ 548 :(((f)->output_data.mw32->hdc != INVALID_HANDLE_VALUE) \ 549 ?(((f)->output_data.mw32->hdc_nestlevel++ \ 550 > GET_FRAME_HDC_LEVEL_LIMIT) \ 542 551 ?(abort(), INVALID_HANDLE_VALUE) \ 543 552 :(f)->output_data.mw32->hdc) \ 544 :(update_begin_hook (f), (f)->output_data.mw32->hdc)) \ 545 :(((f)->output_data.mw32->message_thread_hdc != INVALID_HANDLE_VALUE) \ 546 ?(((f)->output_data.mw32->message_thread_hdc_refcount++ \ 547 > GET_FRAME_HDC_LEVEL_LIMIT) \ 548 ?(abort(), INVALID_HANDLE_VALUE) \ 549 :(f)->output_data.mw32->message_thread_hdc) \ 550 :(update_begin_hook (f), (f)->output_data.mw32->message_thread_hdc)))) 551 552 #define GET_TEMP_HDC(f) \ 553 (! FRAME_WINDOW_P (f)? INVALID_HANDLE_VALUE: \ 554 (MW32_MAIN_THREAD_P() ? \ 555 (((f)->output_data.mw32->hdc != INVALID_HANDLE_VALUE) \ 556 ? ((f)->output_data.mw32->hdc_refcount++,(f)->output_data.mw32->hdc) \ 557 : ((f)->output_data.mw32->hdc_refcount = 1, \ 558 (f)->output_data.mw32->hdc = GetDC (FRAME_MW32_WINDOW (f)))) \ 559 : (((f)->output_data.mw32->message_thread_hdc != INVALID_HANDLE_VALUE) \ 560 ? ((f)->output_data.mw32->message_thread_hdc_refcount++, \ 561 (f)->output_data.mw32->message_thread_hdc) \ 562 : ((f)->output_data.mw32->message_thread_hdc_refcount = 1, \ 563 (f)->output_data.mw32->message_thread_hdc \ 564 = GetDC (FRAME_MW32_WINDOW (f)))))) 553 :(update_begin_hook (f), (f)->output_data.mw32->hdc)))) 554 565 555 566 556 #define RELEASE_FRAME_HDC(f) \ … … 571 561 if (MW32_MAIN_THREAD_P ()) \ 572 562 { \ 573 phdc = & ((f)->output_data.mw32->hdc);\574 pcount = & ((f)->output_data.mw32->hdc_refcount);\563 phdc = &main_thread_hdc; \ 564 pcount = &main_thread_hdc_nestlevel; \ 575 565 } \ 576 566 else \ 577 567 { \ 578 phdc = &((f)->output_data.mw32-> message_thread_hdc);\579 pcount = &((f)->output_data.mw32-> message_thread_hdc_refcount);\568 phdc = &((f)->output_data.mw32->hdc); \ 569 pcount = &((f)->output_data.mw32->hdc_nestlevel); \ 580 570 } \ 581 571 if (*phdc == INVALID_HANDLE_VALUE) \ … … 590 580 } 591 581 592 #define RELEASE_TEMP_HDC(f) \ 582 /* GET/RELEASE_FRAME_HDC is sometimes used asymmetrical becaulse of 583 signalling. This macro does force release of hdc. */ 584 #define CLEANUP_FRAME_HDC(f) \ 593 585 if (FRAME_WINDOW_P (f)) \ 594 586 { \ 595 int *pcount; \596 HDC *phdc; \597 587 if (MW32_MAIN_THREAD_P ()) \ 598 588 { \ 599 phdc = &((f)->output_data.mw32->hdc); \ 600 pcount = &((f)->output_data.mw32->hdc_refcount); \ 589 if (main_thread_hdc != INVALID_HANDLE_VALUE) \ 590 { \ 591 main_thread_hdc_nestlevel = 1; &n
