comparison src/w32term.c @ 27889:51d0b4b8fc6a

(w32_display_info_for_display): Remove unused function. (w32_draw_bitmap): Use pre-built bitmaps. (w32_initialize_display_info): New function to initialize parts of display info that are common to both GUI and console frames. (w32_term_init): Use w32_initialize_display_info. Do not set Vw32_num_mouse_buttons here, as it is not called for console frames. Build bitmaps for indicating truncated lines etc. (x_delete_display): Destroy pre-built bitmaps.
author Jason Rumney <jasonr@gnu.org>
date Sun, 27 Feb 2000 21:26:58 +0000
parents 5fe002cf4b37
children da3a30362526
comparison
equal deleted inserted replaced
27888:3e1c17057b79 27889:51d0b4b8fc6a
32 #include "w32bdf.h" 32 #include "w32bdf.h"
33 #include <shellapi.h> 33 #include <shellapi.h>
34 34
35 #include "systty.h" 35 #include "systty.h"
36 #include "systime.h" 36 #include "systime.h"
37 #include "atimer.h"
37 38
38 #include <ctype.h> 39 #include <ctype.h>
39 #include <errno.h> 40 #include <errno.h>
40 #include <setjmp.h> 41 #include <setjmp.h>
41 #include <sys/stat.h> 42 #include <sys/stat.h>
87 88
88 #define zv_width 8 89 #define zv_width 8
89 #define zv_height 8 90 #define zv_height 8
90 static unsigned short zv_bits[] = { 91 static unsigned short zv_bits[] = {
91 0x00, 0x00, 0x78, 0x78, 0x78, 0x78, 0x00, 0x00}; 92 0x00, 0x00, 0x78, 0x78, 0x78, 0x78, 0x00, 0x00};
93 static HBITMAP zv_bmp;
92 94
93 /* An arrow like this: `<-'. */ 95 /* An arrow like this: `<-'. */
94 96
95 #define left_width 8 97 #define left_width 8
96 #define left_height 8 98 #define left_height 8
97 static unsigned short left_bits[] = { 99 static unsigned short left_bits[] = {
98 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18}; 100 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
101 static HBITMAP left_bmp;
99 102
100 /* Right truncation arrow bitmap `->'. */ 103 /* Right truncation arrow bitmap `->'. */
101 104
102 #define right_width 8 105 #define right_width 8
103 #define right_height 8 106 #define right_height 8
104 static unsigned short right_bits[] = { 107 static unsigned short right_bits[] = {
105 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18}; 108 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
109 static HBITMAP right_bmp;
106 110
107 /* Marker for continued lines. */ 111 /* Marker for continued lines. */
108 112
109 #define continued_width 8 113 #define continued_width 8
110 #define continued_height 8 114 #define continued_height 8
111 static unsigned short continued_bits[] = { 115 static unsigned short continued_bits[] = {
112 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e}; 116 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
117 static HBITMAP continued_bmp;
113 118
114 /* Marker for continuation lines. */ 119 /* Marker for continuation lines. */
115 120
116 #define continuation_width 8 121 #define continuation_width 8
117 #define continuation_height 8 122 #define continuation_height 8
118 static unsigned short continuation_bits[] = { 123 static unsigned short continuation_bits[] = {
119 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c}; 124 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
125 static HBITMAP continuation_bmp;
120 126
121 /* Overlay arrow bitmap. */ 127 /* Overlay arrow bitmap. */
122 128
123 #if 0 129 #if 0
124 /* A bomb. */ 130 /* A bomb. */
130 /* A triangular arrow. */ 136 /* A triangular arrow. */
131 #define ov_width 8 137 #define ov_width 8
132 #define ov_height 8 138 #define ov_height 8
133 static unsigned short ov_bits[] = { 139 static unsigned short ov_bits[] = {
134 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0}; 140 0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
135
136 #endif 141 #endif
142 static HBITMAP ov_bmp;
137 143
138 extern Lisp_Object Qhelp_echo; 144 extern Lisp_Object Qhelp_echo;
139 145
140 146
141 /* Non-zero means Emacs uses toolkit scroll bars. */ 147 /* Non-zero means Emacs uses toolkit scroll bars. */
163 int x_stretch_cursor_p; 169 int x_stretch_cursor_p;
164 170
165 #define CP_DEFAULT 1004 171 #define CP_DEFAULT 1004
166 172
167 extern unsigned int msh_mousewheel; 173 extern unsigned int msh_mousewheel;
174 extern int inhibit_busy_cursor;
168 175
169 extern void free_frame_menubar (); 176 extern void free_frame_menubar ();
170 177
171 extern Lisp_Object Vwindow_system; 178 extern Lisp_Object Vwindow_system;
172 179
462 } 469 }
463 else 470 else
464 SelectClipRgn (hdc, NULL); 471 SelectClipRgn (hdc, NULL);
465 } 472 }
466 473
467 /* Return the struct w32_display_info. */
468
469 struct w32_display_info *
470 w32_display_info_for_display ()
471 {
472 return (&one_w32_display_info);
473 }
474
475 474
476 /* Draw a hollow rectangle at the specified position. */ 475 /* Draw a hollow rectangle at the specified position. */
477 void 476 void
478 w32_draw_rectangle (HDC hdc, XGCValues *gc, int x, int y, 477 w32_draw_rectangle (HDC hdc, XGCValues *gc, int x, int y,
479 int width, int height) 478 int width, int height)
745 { 744 {
746 struct frame *f = XFRAME (WINDOW_FRAME (w)); 745 struct frame *f = XFRAME (WINDOW_FRAME (w));
747 Window window = FRAME_W32_WINDOW (f); 746 Window window = FRAME_W32_WINDOW (f);
748 HDC compat_hdc; 747 HDC compat_hdc;
749 int x, y, wd, h, dy; 748 int x, y, wd, h, dy;
750 unsigned short *bits;
751 HBITMAP pixmap; 749 HBITMAP pixmap;
752 HBRUSH fg_brush, orig_brush; 750 HBRUSH fg_brush, orig_brush;
753 HANDLE horig_obj; 751 HANDLE horig_obj;
754 struct face *face; 752 struct face *face;
755 753
759 switch (which) 757 switch (which)
760 { 758 {
761 case LEFT_TRUNCATION_BITMAP: 759 case LEFT_TRUNCATION_BITMAP:
762 wd = left_width; 760 wd = left_width;
763 h = left_height; 761 h = left_height;
764 bits = left_bits; 762 pixmap = left_bmp;
765 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0) 763 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
766 - wd 764 - wd
767 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2); 765 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2);
768 break; 766 break;
769 767
770 case OVERLAY_ARROW_BITMAP: 768 case OVERLAY_ARROW_BITMAP:
771 wd = ov_width; 769 wd = ov_width;
772 h = ov_height; 770 h = ov_height;
773 bits = ov_bits; 771 pixmap = ov_bmp;
774 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0) 772 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
775 - wd 773 - wd
776 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2); 774 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2);
777 break; 775 break;
778 776
779 case RIGHT_TRUNCATION_BITMAP: 777 case RIGHT_TRUNCATION_BITMAP:
780 wd = right_width; 778 wd = right_width;
781 h = right_height; 779 h = right_height;
782 bits = right_bits; 780 pixmap = right_bmp;
783 x = window_box_right (w, -1); 781 x = window_box_right (w, -1);
784 x += (FRAME_X_RIGHT_FLAGS_AREA_WIDTH (f) - wd) / 2; 782 x += (FRAME_X_RIGHT_FLAGS_AREA_WIDTH (f) - wd) / 2;
785 break; 783 break;
786 784
787 case CONTINUED_LINE_BITMAP: 785 case CONTINUED_LINE_BITMAP:
788 wd = continued_width; 786 wd = continued_width;
789 h = continued_height; 787 h = continued_height;
790 bits = continued_bits; 788 pixmap = continued_bmp;
791 x = window_box_right (w, -1); 789 x = window_box_right (w, -1);
792 x += (FRAME_X_RIGHT_FLAGS_AREA_WIDTH (f) - wd) / 2; 790 x += (FRAME_X_RIGHT_FLAGS_AREA_WIDTH (f) - wd) / 2;
793 break; 791 break;
794 792
795 case CONTINUATION_LINE_BITMAP: 793 case CONTINUATION_LINE_BITMAP:
796 wd = continuation_width; 794 wd = continuation_width;
797 h = continuation_height; 795 h = continuation_height;
798 bits = continuation_bits; 796 pixmap = continuation_bmp;
799 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0) 797 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
800 - wd 798 - wd
801 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2); 799 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2);
802 break; 800 break;
803 801
804 case ZV_LINE_BITMAP: 802 case ZV_LINE_BITMAP:
805 wd = zv_width; 803 wd = zv_width;
806 h = zv_height; 804 h = zv_height;
807 bits = zv_bits; 805 pixmap = zv_bmp;
808 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0) 806 x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
809 - wd 807 - wd
810 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2); 808 - (FRAME_X_LEFT_FLAGS_AREA_WIDTH (f) - wd) / 2);
811 break; 809 break;
812 810
817 /* Convert to frame coordinates. Set dy to the offset in the row to 815 /* Convert to frame coordinates. Set dy to the offset in the row to
818 start drawing the bitmap. */ 816 start drawing the bitmap. */
819 y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 817 y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
820 dy = (row->height - h) / 2; 818 dy = (row->height - h) / 2;
821 819
822 /* Draw the bitmap. I believe these small pixmaps can be cached 820 /* Draw the bitmap. */
823 by the server. */
824 face = FACE_FROM_ID (f, BITMAP_AREA_FACE_ID); 821 face = FACE_FROM_ID (f, BITMAP_AREA_FACE_ID);
825 pixmap = CreateBitmap (wd, h, 1, 1, bits);
826 822
827 compat_hdc = CreateCompatibleDC (hdc); 823 compat_hdc = CreateCompatibleDC (hdc);
828 SaveDC (hdc); 824 SaveDC (hdc);
829 fg_brush = CreateSolidBrush (FRAME_FOREGROUND_PIXEL (f)); 825 fg_brush = CreateSolidBrush (FRAME_FOREGROUND_PIXEL (f));
830 orig_brush = SelectObject (hdc, fg_brush); 826 orig_brush = SelectObject (hdc, fg_brush);
836 #else 832 #else
837 BitBlt (hdc, x, y + dy, wd, h, compat_hdc, 0, 0, 0xB8074A); 833 BitBlt (hdc, x, y + dy, wd, h, compat_hdc, 0, 0, 0xB8074A);
838 #endif 834 #endif
839 SelectObject (compat_hdc, horig_obj); 835 SelectObject (compat_hdc, horig_obj);
840 SelectObject (hdc, orig_brush); 836 SelectObject (hdc, orig_brush);
841 DeleteObject (pixmap);
842 DeleteObject (fg_brush); 837 DeleteObject (fg_brush);
843 DeleteDC (compat_hdc); 838 DeleteDC (compat_hdc);
844 RestoreDC (hdc, -1); 839 RestoreDC (hdc, -1);
845 } 840 }
846 841
9546 Initialization 9541 Initialization
9547 ***********************************************************************/ 9542 ***********************************************************************/
9548 9543
9549 static int w32_initialized = 0; 9544 static int w32_initialized = 0;
9550 9545
9551 struct w32_display_info * 9546 void
9552 w32_term_init (display_name, xrm_option, resource_name) 9547 w32_initialize_display_info (display_name)
9553 Lisp_Object display_name; 9548 Lisp_Object display_name;
9554 char *xrm_option; 9549 {
9555 char *resource_name; 9550 struct w32_display_info *dpyinfo = &one_w32_display_info;
9556 { 9551
9557 struct w32_display_info *dpyinfo; 9552 bzero (dpyinfo, sizeof (*dpyinfo));
9558 HDC hdc; 9553
9559 9554 /* Put it on w32_display_name_list. */
9560 BLOCK_INPUT;
9561
9562 if (!w32_initialized)
9563 {
9564 w32_initialize ();
9565 w32_initialized = 1;
9566 }
9567
9568 {
9569 int argc = 0;
9570 char *argv[3];
9571
9572 argv[0] = "";
9573 argc = 1;
9574 if (xrm_option)
9575 {
9576 argv[argc++] = "-xrm";
9577 argv[argc++] = xrm_option;
9578 }
9579 }
9580
9581 dpyinfo = &one_w32_display_info;
9582
9583 /* Put this display on the chain. */
9584 dpyinfo->next = NULL;
9585
9586 /* Put it on w32_display_name_list as well, to keep them parallel. */
9587 w32_display_name_list = Fcons (Fcons (display_name, Qnil), 9555 w32_display_name_list = Fcons (Fcons (display_name, Qnil),
9588 w32_display_name_list); 9556 w32_display_name_list);
9589 dpyinfo->name_list_element = XCAR (w32_display_name_list); 9557 dpyinfo->name_list_element = XCAR (w32_display_name_list);
9590 9558
9591 dpyinfo->w32_id_name 9559 dpyinfo->w32_id_name
9593 + XSTRING (Vsystem_name)->size 9561 + XSTRING (Vsystem_name)->size
9594 + 2); 9562 + 2);
9595 sprintf (dpyinfo->w32_id_name, "%s@%s", 9563 sprintf (dpyinfo->w32_id_name, "%s@%s",
9596 XSTRING (Vinvocation_name)->data, XSTRING (Vsystem_name)->data); 9564 XSTRING (Vinvocation_name)->data, XSTRING (Vsystem_name)->data);
9597 9565
9598 #if 0 9566 /* Default Console mode values - overridden when running in GUI mode
9599 xrdb = x_load_resources (dpyinfo->display, xrm_option, 9567 with values obtained from system metrics. */
9600 resource_name, EMACS_CLASS); 9568 dpyinfo->resx = 1;
9569 dpyinfo->resy = 1;
9570 dpyinfo->height_in = 1;
9571 dpyinfo->width_in = 1;
9572 dpyinfo->n_planes = 1;
9573 dpyinfo->n_cbits = 4;
9574 dpyinfo->n_fonts = 0;
9575 dpyinfo->smallest_font_height = 1;
9576 dpyinfo->smallest_char_width = 1;
9577
9578 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
9579 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
9580 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
9581 dpyinfo->mouse_face_window = Qnil;
9582
9583 /* NTEMACS_TODO: dpyinfo->gray */
9584
9585 }
9586
9587 struct w32_display_info *
9588 w32_term_init (display_name, xrm_option, resource_name)
9589 Lisp_Object display_name;
9590 char *xrm_option;
9591 char *resource_name;
9592 {
9593 struct w32_display_info *dpyinfo;
9594 HDC hdc;
9601 9595
9602 /* Put the rdb where we can find it in a way that works on 9596 BLOCK_INPUT;
9603 all versions. */ 9597
9604 dpyinfo->xrdb = xrdb; 9598 if (!w32_initialized)
9605 #endif 9599 {
9600 w32_initialize ();
9601 w32_initialized = 1;
9602 }
9603
9604 {
9605 int argc = 0;
9606 char *argv[3];
9607
9608 argv[0] = "";
9609 argc = 1;
9610 if (xrm_option)
9611 {
9612 argv[argc++] = "-xrm";
9613 argv[argc++] = xrm_option;
9614 }
9615 }
9616
9617 w32_initialize_display_info (display_name);
9618
9619 dpyinfo = &one_w32_display_info;
9620
9606 hdc = GetDC (GetDesktopWindow ()); 9621 hdc = GetDC (GetDesktopWindow ());
9607 9622
9608 dpyinfo->height = GetDeviceCaps (hdc, VERTRES); 9623 dpyinfo->height = GetDeviceCaps (hdc, VERTRES);
9609 dpyinfo->width = GetDeviceCaps (hdc, HORZRES); 9624 dpyinfo->width = GetDeviceCaps (hdc, HORZRES);
9610 dpyinfo->root_window = GetDesktopWindow (); 9625 dpyinfo->root_window = GetDesktopWindow ();
9611 dpyinfo->n_planes = GetDeviceCaps (hdc, PLANES); 9626 dpyinfo->n_planes = GetDeviceCaps (hdc, PLANES);
9612 dpyinfo->n_cbits = GetDeviceCaps (hdc, BITSPIXEL); 9627 dpyinfo->n_cbits = GetDeviceCaps (hdc, BITSPIXEL);
9613 dpyinfo->resx = GetDeviceCaps (hdc, LOGPIXELSX); 9628 dpyinfo->resx = GetDeviceCaps (hdc, LOGPIXELSX);
9614 dpyinfo->resy = GetDeviceCaps (hdc, LOGPIXELSY); 9629 dpyinfo->resy = GetDeviceCaps (hdc, LOGPIXELSY);
9615 dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE; 9630 dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE;
9616 dpyinfo->grabbed = 0;
9617 dpyinfo->reference_count = 0;
9618 dpyinfo->font_table = NULL;
9619 dpyinfo->n_fonts = 0;
9620 dpyinfo->font_table_size = 0;
9621 dpyinfo->bitmaps = 0;
9622 dpyinfo->bitmaps_size = 0;
9623 dpyinfo->bitmaps_last = 0;
9624 dpyinfo->scratch_cursor_gc = NULL;
9625 dpyinfo->mouse_face_mouse_frame = 0;
9626 dpyinfo->mouse_face_deferred_gc = 0;
9627 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
9628 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
9629 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
9630 dpyinfo->mouse_face_window = Qnil;
9631 dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0;
9632 dpyinfo->mouse_face_defer = 0;
9633 dpyinfo->w32_focus_frame = 0;
9634 dpyinfo->w32_focus_event_frame = 0;
9635 dpyinfo->w32_highlight_frame = 0;
9636 dpyinfo->image_cache = make_image_cache (); 9631 dpyinfo->image_cache = make_image_cache ();
9637 dpyinfo->height_in = dpyinfo->height / dpyinfo->resx; 9632 dpyinfo->height_in = dpyinfo->height / dpyinfo->resx;
9638 dpyinfo->width_in = dpyinfo->width / dpyinfo->resy; 9633 dpyinfo->width_in = dpyinfo->width / dpyinfo->resy;
9639 ReleaseDC (GetDesktopWindow (), hdc); 9634 ReleaseDC (GetDesktopWindow (), hdc);
9640 /* NTEMACS_TODO: dpyinfo->gray */
9641 /* Determine if there is a middle mouse button, to allow parse_button
9642 to decide whether right mouse events should be mouse-2 or
9643 mouse-3. */
9644 XSETINT (Vw32_num_mouse_buttons, GetSystemMetrics (SM_CMOUSEBUTTONS));
9645 9635
9646 /* initialise palette with white and black */ 9636 /* initialise palette with white and black */
9647 { 9637 {
9648 COLORREF color; 9638 COLORREF color;
9649 w32_defined_color (0, "white", &color, 1); 9639 w32_defined_color (0, "white", &color, 1);
9650 w32_defined_color (0, "black", &color, 1); 9640 w32_defined_color (0, "black", &color, 1);
9651 } 9641 }
9642
9643 /* Create Row Bitmaps and store them for later use. */
9644 left_bmp = CreateBitmap (left_width, left_height, 1, 1, left_bits);
9645 ov_bmp = CreateBitmap (ov_width, ov_height, 1, 1, ov_bits);
9646 right_bmp = CreateBitmap (right_width, right_height, 1, 1, right_bits);
9647 continued_bmp = CreateBitmap (continued_width, continued_height, 1,
9648 1, continued_bits);
9649 continuation_bmp = CreateBitmap (continuation_width, continuation_height,
9650 1, 1, continuation_bits);
9651 zv_bmp = CreateBitmap (zv_width, zv_height, 1, 1, zv_bits);
9652 9652
9653 #ifndef F_SETOWN_BUG 9653 #ifndef F_SETOWN_BUG
9654 #ifdef F_SETOWN 9654 #ifdef F_SETOWN
9655 #ifdef F_SETOWN_SOCK_NEG 9655 #ifdef F_SETOWN_SOCK_NEG
9656 /* stdin is a socket here */ 9656 /* stdin is a socket here */
9687 Lisp_Object tail; 9687 Lisp_Object tail;
9688 9688
9689 tail = w32_display_name_list; 9689 tail = w32_display_name_list;
9690 while (CONSP (tail) && CONSP (XCDR (tail))) 9690 while (CONSP (tail) && CONSP (XCDR (tail)))
9691 { 9691 {
9692 if (EQ (XCAR (XCDR (tail)), 9692 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
9693 dpyinfo->name_list_element))
9694 { 9693 {
9695 XCDR (tail) = XCDR (XCDR (tail)); 9694 XCDR (tail) = XCDR (XCDR (tail));
9696 break; 9695 break;
9697 } 9696 }
9698 tail = XCDR (tail); 9697 tail = XCDR (tail);
9714 if (dpyinfo->palette) 9713 if (dpyinfo->palette)
9715 DeleteObject(dpyinfo->palette); 9714 DeleteObject(dpyinfo->palette);
9716 } 9715 }
9717 xfree (dpyinfo->font_table); 9716 xfree (dpyinfo->font_table);
9718 xfree (dpyinfo->w32_id_name); 9717 xfree (dpyinfo->w32_id_name);
9718
9719 /* Destroy row bitmaps. */
9720 DeleteObject (left_bmp);
9721 DeleteObject (ov_bmp);
9722 DeleteObject (right_bmp);
9723 DeleteObject (continued_bmp);
9724 DeleteObject (continuation_bmp);
9725 DeleteObject (zv_bmp);
9719 } 9726 }
9720 9727
9721 /* Set up use of W32. */ 9728 /* Set up use of W32. */
9722 9729
9723 DWORD w32_msg_worker (); 9730 DWORD w32_msg_worker ();