diff options
| author | Geoff Voelker | 1996-01-21 00:22:24 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1996-01-21 00:22:24 +0000 |
| commit | ad35c03238c3b8e8041aaf87730678211423751d (patch) | |
| tree | ccf327c8a742a30c3aab8ca21687b36f9862246b /src | |
| parent | 61102050ba53404f3994a36b6b5ce66b2d564056 (diff) | |
| download | emacs-ad35c03238c3b8e8041aaf87730678211423751d.tar.gz emacs-ad35c03238c3b8e8041aaf87730678211423751d.zip | |
(win32_fill_rect): Remove unused variable.
(x_iconify_frame): Conform to coding style.
(x_draw_box): Don't trim right and bottom.
(x_wm_set_size_hint): Use specific CRIT_MSG critical section.
(win32_fill_rect, dumpglyphs, do_line_dance, x_draw_box):
Use Get/ReleaseFrameDC.
(win32_update_begin): Regenerate palette if required.
(w32_read_socket): Use FALSE. Handle WM_PALETTECHANGED.
(win32_term_init): Use GetDC directly.
Enable palette in display structure.
Predefine white and black.
(x_delete_display): Free palette table.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 98 |
1 files changed, 63 insertions, 35 deletions
diff --git a/src/w32term.c b/src/w32term.c index 49a56b0e429..bdb764feb8d 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -195,7 +195,6 @@ win32_fill_rect (f, _hdc, pix, lprect) | |||
| 195 | { | 195 | { |
| 196 | HDC hdc; | 196 | HDC hdc; |
| 197 | HBRUSH hb; | 197 | HBRUSH hb; |
| 198 | HANDLE oldobj; | ||
| 199 | RECT rect; | 198 | RECT rect; |
| 200 | 199 | ||
| 201 | if (_hdc) | 200 | if (_hdc) |
| @@ -203,18 +202,15 @@ win32_fill_rect (f, _hdc, pix, lprect) | |||
| 203 | else | 202 | else |
| 204 | { | 203 | { |
| 205 | if (!f) return; | 204 | if (!f) return; |
| 206 | hdc = my_get_dc (FRAME_WIN32_WINDOW (f)); | 205 | hdc = GetFrameDC (f); |
| 207 | } | 206 | } |
| 208 | 207 | ||
| 209 | hb = CreateSolidBrush (pix); | 208 | hb = CreateSolidBrush (pix); |
| 210 | oldobj = SelectObject (hdc, hb); | ||
| 211 | |||
| 212 | FillRect (hdc, lprect, hb); | 209 | FillRect (hdc, lprect, hb); |
| 213 | SelectObject (hdc, oldobj); | ||
| 214 | DeleteObject (hb); | 210 | DeleteObject (hb); |
| 215 | 211 | ||
| 216 | if (!_hdc) | 212 | if (!_hdc) |
| 217 | ReleaseDC (FRAME_WIN32_WINDOW (f), hdc); | 213 | ReleaseFrameDC (f, hdc); |
| 218 | } | 214 | } |
| 219 | 215 | ||
| 220 | void | 216 | void |
| @@ -222,7 +218,7 @@ win32_clear_window (f) | |||
| 222 | FRAME_PTR f; | 218 | FRAME_PTR f; |
| 223 | { | 219 | { |
| 224 | RECT rect; | 220 | RECT rect; |
| 225 | 221 | ||
| 226 | GetClientRect (FRAME_WIN32_WINDOW (f), &rect); | 222 | GetClientRect (FRAME_WIN32_WINDOW (f), &rect); |
| 227 | win32_clear_rect (f, NULL, &rect); | 223 | win32_clear_rect (f, NULL, &rect); |
| 228 | } | 224 | } |
| @@ -249,6 +245,14 @@ win32_update_begin (f) | |||
| 249 | 245 | ||
| 250 | BLOCK_INPUT; | 246 | BLOCK_INPUT; |
| 251 | 247 | ||
| 248 | /* Regenerate display palette before drawing if list of requested | ||
| 249 | colors has changed. */ | ||
| 250 | if (FRAME_WIN32_DISPLAY_INFO (f)->regen_palette) | ||
| 251 | { | ||
| 252 | win32_regenerate_palette (f); | ||
| 253 | FRAME_WIN32_DISPLAY_INFO (f)->regen_palette = FALSE; | ||
| 254 | } | ||
| 255 | |||
| 252 | if (f == FRAME_WIN32_DISPLAY_INFO (f)->mouse_face_mouse_frame) | 256 | if (f == FRAME_WIN32_DISPLAY_INFO (f)->mouse_face_mouse_frame) |
| 253 | { | 257 | { |
| 254 | /* Don't do highlighting for mouse motion during the update. */ | 258 | /* Don't do highlighting for mouse motion during the update. */ |
| @@ -418,7 +422,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground) | |||
| 418 | int orig_left = left; | 422 | int orig_left = left; |
| 419 | HDC hdc; | 423 | HDC hdc; |
| 420 | 424 | ||
| 421 | hdc = my_get_dc (window); | 425 | hdc = GetFrameDC (f); |
| 422 | 426 | ||
| 423 | while (n > 0) | 427 | while (n > 0) |
| 424 | { | 428 | { |
| @@ -571,7 +575,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground) | |||
| 571 | } | 575 | } |
| 572 | } | 576 | } |
| 573 | 577 | ||
| 574 | ReleaseDC (window, hdc); | 578 | ReleaseFrameDC (f, hdc); |
| 575 | } | 579 | } |
| 576 | 580 | ||
| 577 | 581 | ||
| @@ -828,7 +832,7 @@ do_line_dance () | |||
| 828 | 832 | ||
| 829 | x_display_cursor (updating_frame, 0); | 833 | x_display_cursor (updating_frame, 0); |
| 830 | 834 | ||
| 831 | hdc = my_get_dc (FRAME_WIN32_WINDOW (f)); | 835 | hdc = GetFrameDC (f); |
| 832 | 836 | ||
| 833 | for (i = 0; i < ht; ++i) | 837 | for (i = 0; i < ht; ++i) |
| 834 | if (line_dance[i] != -1 && (distance = line_dance[i]-i) > 0) | 838 | if (line_dance[i] != -1 && (distance = line_dance[i]-i) > 0) |
| @@ -862,7 +866,7 @@ do_line_dance () | |||
| 862 | i = j+1; | 866 | i = j+1; |
| 863 | } | 867 | } |
| 864 | 868 | ||
| 865 | ReleaseDC (FRAME_WIN32_WINDOW (f), hdc); | 869 | ReleaseFrameDC (f, hdc); |
| 866 | 870 | ||
| 867 | for (i = 0; i < ht; ++i) | 871 | for (i = 0; i < ht; ++i) |
| 868 | if (line_dance[i] == -1) | 872 | if (line_dance[i] == -1) |
| @@ -2272,7 +2276,7 @@ w32_read_socket (sd, bufp, numchars, waitp, expected) | |||
| 2272 | if (numchars <= 0) | 2276 | if (numchars <= 0) |
| 2273 | abort (); /* Don't think this happens. */ | 2277 | abort (); /* Don't think this happens. */ |
| 2274 | 2278 | ||
| 2275 | while (get_next_msg (&msg, 0)) | 2279 | while (get_next_msg (&msg, FALSE)) |
| 2276 | { | 2280 | { |
| 2277 | switch (msg.msg.message) | 2281 | switch (msg.msg.message) |
| 2278 | { | 2282 | { |
| @@ -2308,6 +2312,12 @@ w32_read_socket (sd, bufp, numchars, waitp, expected) | |||
| 2308 | } | 2312 | } |
| 2309 | 2313 | ||
| 2310 | break; | 2314 | break; |
| 2315 | case WM_PALETTECHANGED: | ||
| 2316 | f = x_window_to_frame (dpyinfo, msg.msg.hwnd); | ||
| 2317 | if (f) | ||
| 2318 | /* Realize palette - will force update if needed. */ | ||
| 2319 | ReleaseFrameDC (f, GetFrameDC (f)); | ||
| 2320 | break; | ||
| 2311 | case WM_KEYDOWN: | 2321 | case WM_KEYDOWN: |
| 2312 | case WM_SYSKEYDOWN: | 2322 | case WM_SYSKEYDOWN: |
| 2313 | f = x_window_to_frame (dpyinfo, msg.msg.hwnd); | 2323 | f = x_window_to_frame (dpyinfo, msg.msg.hwnd); |
| @@ -2443,7 +2453,7 @@ w32_read_socket (sd, bufp, numchars, waitp, expected) | |||
| 2443 | int width; | 2453 | int width; |
| 2444 | int height; | 2454 | int height; |
| 2445 | 2455 | ||
| 2446 | GetClientRect(msg.msg.hwnd, &rect); | 2456 | GetClientRect (msg.msg.hwnd, &rect); |
| 2447 | 2457 | ||
| 2448 | height = rect.bottom - rect.top + 1; | 2458 | height = rect.bottom - rect.top + 1; |
| 2449 | width = rect.right - rect.left + 1; | 2459 | width = rect.right - rect.left + 1; |
| @@ -2636,25 +2646,19 @@ x_draw_box (f) | |||
| 2636 | HBRUSH hb; | 2646 | HBRUSH hb; |
| 2637 | HDC hdc; | 2647 | HDC hdc; |
| 2638 | 2648 | ||
| 2639 | hdc = my_get_dc (FRAME_WIN32_WINDOW (f)); | 2649 | hdc = GetFrameDC (f); |
| 2640 | 2650 | ||
| 2641 | hb = CreateSolidBrush (f->output_data.win32->cursor_pixel); | 2651 | hb = CreateSolidBrush (f->output_data.win32->cursor_pixel); |
| 2642 | 2652 | ||
| 2643 | rect.left = CHAR_TO_PIXEL_COL (f, curs_x); | 2653 | rect.left = CHAR_TO_PIXEL_COL (f, curs_x); |
| 2644 | rect.top = CHAR_TO_PIXEL_ROW (f, curs_y); | 2654 | rect.top = CHAR_TO_PIXEL_ROW (f, curs_y); |
| 2645 | rect.right = rect.left + FONT_WIDTH (f->output_data.win32->font) - 1; | 2655 | rect.right = rect.left + FONT_WIDTH (f->output_data.win32->font); |
| 2646 | rect.bottom = rect.top + f->output_data.win32->line_height - 1; | 2656 | rect.bottom = rect.top + f->output_data.win32->line_height; |
| 2647 | 2657 | ||
| 2648 | /* rect.left++; */ | ||
| 2649 | /* rect.top++; */ | ||
| 2650 | rect.right--; | ||
| 2651 | rect.bottom--; | ||
| 2652 | |||
| 2653 | FrameRect (hdc, &rect, hb); | 2658 | FrameRect (hdc, &rect, hb); |
| 2654 | |||
| 2655 | DeleteObject (hb); | 2659 | DeleteObject (hb); |
| 2656 | 2660 | ||
| 2657 | ReleaseDC (FRAME_WIN32_WINDOW (f), hdc); | 2661 | ReleaseFrameDC (f, hdc); |
| 2658 | } | 2662 | } |
| 2659 | 2663 | ||
| 2660 | /* Clear the cursor of frame F to background color, | 2664 | /* Clear the cursor of frame F to background color, |
| @@ -3016,8 +3020,8 @@ x_calc_absolute_position (f) | |||
| 3016 | rt.left = rt.right = rt.top = rt.bottom = 0; | 3020 | rt.left = rt.right = rt.top = rt.bottom = 0; |
| 3017 | 3021 | ||
| 3018 | BLOCK_INPUT; | 3022 | BLOCK_INPUT; |
| 3019 | AdjustWindowRect(&rt, f->output_data.win32->dwStyle, | 3023 | AdjustWindowRect (&rt, f->output_data.win32->dwStyle, |
| 3020 | FRAME_EXTERNAL_MENU_BAR (f)); | 3024 | FRAME_EXTERNAL_MENU_BAR (f)); |
| 3021 | UNBLOCK_INPUT; | 3025 | UNBLOCK_INPUT; |
| 3022 | 3026 | ||
| 3023 | pt.x += (rt.right - rt.left); | 3027 | pt.x += (rt.right - rt.left); |
| @@ -3124,8 +3128,8 @@ x_set_window_size (f, change_gravity, cols, rows) | |||
| 3124 | rect.right = pixelwidth; | 3128 | rect.right = pixelwidth; |
| 3125 | rect.bottom = pixelheight; | 3129 | rect.bottom = pixelheight; |
| 3126 | 3130 | ||
| 3127 | AdjustWindowRect(&rect, f->output_data.win32->dwStyle, | 3131 | AdjustWindowRect (&rect, f->output_data.win32->dwStyle, |
| 3128 | FRAME_EXTERNAL_MENU_BAR (f)); | 3132 | FRAME_EXTERNAL_MENU_BAR (f)); |
| 3129 | 3133 | ||
| 3130 | /* All windows have an extra pixel */ | 3134 | /* All windows have an extra pixel */ |
| 3131 | 3135 | ||
| @@ -3368,7 +3372,8 @@ x_make_frame_invisible (f) | |||
| 3368 | 3372 | ||
| 3369 | /* Change window state from mapped to iconified. */ | 3373 | /* Change window state from mapped to iconified. */ |
| 3370 | 3374 | ||
| 3371 | void x_iconify_frame (f) | 3375 | void |
| 3376 | x_iconify_frame (f) | ||
| 3372 | struct frame *f; | 3377 | struct frame *f; |
| 3373 | { | 3378 | { |
| 3374 | int result; | 3379 | int result; |
| @@ -3442,12 +3447,12 @@ x_wm_set_size_hint (f, flags, user_position) | |||
| 3442 | 3447 | ||
| 3443 | flexlines = f->height; | 3448 | flexlines = f->height; |
| 3444 | 3449 | ||
| 3445 | enter_crit (); | 3450 | enter_crit (CRIT_MSG); |
| 3446 | 3451 | ||
| 3447 | SetWindowLong (window, WND_X_UNITS_INDEX, FONT_WIDTH (f->output_data.win32->font)); | 3452 | SetWindowLong (window, WND_X_UNITS_INDEX, FONT_WIDTH (f->output_data.win32->font)); |
| 3448 | SetWindowLong (window, WND_Y_UNITS_INDEX, f->output_data.win32->line_height); | 3453 | SetWindowLong (window, WND_Y_UNITS_INDEX, f->output_data.win32->line_height); |
| 3449 | 3454 | ||
| 3450 | leave_crit (); | 3455 | leave_crit (CRIT_MSG); |
| 3451 | } | 3456 | } |
| 3452 | 3457 | ||
| 3453 | /* Window manager things */ | 3458 | /* Window manager things */ |
| @@ -3500,7 +3505,7 @@ win32_term_init (display_name, xrm_option, resource_name) | |||
| 3500 | char *defaultvalue; | 3505 | char *defaultvalue; |
| 3501 | struct win32_display_info *dpyinfo; | 3506 | struct win32_display_info *dpyinfo; |
| 3502 | HDC hdc; | 3507 | HDC hdc; |
| 3503 | 3508 | ||
| 3504 | BLOCK_INPUT; | 3509 | BLOCK_INPUT; |
| 3505 | 3510 | ||
| 3506 | if (!win32_initialized) | 3511 | if (!win32_initialized) |
| @@ -3531,7 +3536,7 @@ win32_term_init (display_name, xrm_option, resource_name) | |||
| 3531 | win32_display_name_list = Fcons (Fcons (display_name, Qnil), | 3536 | win32_display_name_list = Fcons (Fcons (display_name, Qnil), |
| 3532 | win32_display_name_list); | 3537 | win32_display_name_list); |
| 3533 | dpyinfo->name_list_element = XCONS (win32_display_name_list)->car; | 3538 | dpyinfo->name_list_element = XCONS (win32_display_name_list)->car; |
| 3534 | 3539 | ||
| 3535 | dpyinfo->win32_id_name | 3540 | dpyinfo->win32_id_name |
| 3536 | = (char *) xmalloc (XSTRING (Vinvocation_name)->size | 3541 | = (char *) xmalloc (XSTRING (Vinvocation_name)->size |
| 3537 | + XSTRING (Vsystem_name)->size | 3542 | + XSTRING (Vsystem_name)->size |
| @@ -3547,7 +3552,7 @@ win32_term_init (display_name, xrm_option, resource_name) | |||
| 3547 | all versions. */ | 3552 | all versions. */ |
| 3548 | dpyinfo->xrdb = xrdb; | 3553 | dpyinfo->xrdb = xrdb; |
| 3549 | #endif | 3554 | #endif |
| 3550 | hdc = my_get_dc (GetDesktopWindow ()); | 3555 | hdc = GetDC (GetDesktopWindow ()); |
| 3551 | 3556 | ||
| 3552 | dpyinfo->height = GetDeviceCaps (hdc, VERTRES); | 3557 | dpyinfo->height = GetDeviceCaps (hdc, VERTRES); |
| 3553 | dpyinfo->width = GetDeviceCaps (hdc, HORZRES); | 3558 | dpyinfo->width = GetDeviceCaps (hdc, HORZRES); |
| @@ -3556,6 +3561,7 @@ win32_term_init (display_name, xrm_option, resource_name) | |||
| 3556 | dpyinfo->n_cbits = GetDeviceCaps (hdc, BITSPIXEL); | 3561 | dpyinfo->n_cbits = GetDeviceCaps (hdc, BITSPIXEL); |
| 3557 | dpyinfo->height_in = GetDeviceCaps (hdc, LOGPIXELSX); | 3562 | dpyinfo->height_in = GetDeviceCaps (hdc, LOGPIXELSX); |
| 3558 | dpyinfo->width_in = GetDeviceCaps (hdc, LOGPIXELSY); | 3563 | dpyinfo->width_in = GetDeviceCaps (hdc, LOGPIXELSY); |
| 3564 | dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE; | ||
| 3559 | dpyinfo->grabbed = 0; | 3565 | dpyinfo->grabbed = 0; |
| 3560 | dpyinfo->reference_count = 0; | 3566 | dpyinfo->reference_count = 0; |
| 3561 | dpyinfo->n_fonts = 0; | 3567 | dpyinfo->n_fonts = 0; |
| @@ -3577,6 +3583,13 @@ win32_term_init (display_name, xrm_option, resource_name) | |||
| 3577 | 3583 | ||
| 3578 | ReleaseDC (GetDesktopWindow (), hdc); | 3584 | ReleaseDC (GetDesktopWindow (), hdc); |
| 3579 | 3585 | ||
| 3586 | /* initialise palette with white and black */ | ||
| 3587 | { | ||
| 3588 | COLORREF color; | ||
| 3589 | defined_color (0, "white", &color, 1); | ||
| 3590 | defined_color (0, "black", &color, 1); | ||
| 3591 | } | ||
| 3592 | |||
| 3580 | #ifndef F_SETOWN_BUG | 3593 | #ifndef F_SETOWN_BUG |
| 3581 | #ifdef F_SETOWN | 3594 | #ifdef F_SETOWN |
| 3582 | #ifdef F_SETOWN_SOCK_NEG | 3595 | #ifdef F_SETOWN_SOCK_NEG |
| @@ -3626,6 +3639,21 @@ x_delete_display (dpyinfo) | |||
| 3626 | } | 3639 | } |
| 3627 | } | 3640 | } |
| 3628 | 3641 | ||
| 3642 | /* free palette table */ | ||
| 3643 | { | ||
| 3644 | struct win32_palette_entry * plist; | ||
| 3645 | |||
| 3646 | plist = dpyinfo->p_colors_in_use; | ||
| 3647 | while (plist) | ||
| 3648 | { | ||
| 3649 | struct win32_palette_entry * pentry = plist; | ||
| 3650 | plist = plist->next; | ||
| 3651 | xfree (pentry); | ||
| 3652 | } | ||
| 3653 | dpyinfo->p_colors_in_use = NULL; | ||
| 3654 | if (dpyinfo->h_palette) | ||
| 3655 | DeleteObject (dpyinfo->h_palette); | ||
| 3656 | } | ||
| 3629 | xfree (dpyinfo->font_table); | 3657 | xfree (dpyinfo->font_table); |
| 3630 | xfree (dpyinfo->win32_id_name); | 3658 | xfree (dpyinfo->win32_id_name); |
| 3631 | } | 3659 | } |