aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorJason Rumney2000-02-27 21:26:58 +0000
committerJason Rumney2000-02-27 21:26:58 +0000
commitf7737f5dcf2c7736deefb7404249fb9b93f49764 (patch)
tree228e27422a3bb97c1cd262693c84d08ac1232682 /src/w32term.c
parent3855860a6f445e07f36371dc07775cabbfe6ecea (diff)
downloademacs-f7737f5dcf2c7736deefb7404249fb9b93f49764.tar.gz
emacs-f7737f5dcf2c7736deefb7404249fb9b93f49764.zip
(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.
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c147
1 files changed, 77 insertions, 70 deletions
diff --git a/src/w32term.c b/src/w32term.c
index a052be06df8..f59f80e9482 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */
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>
@@ -89,6 +90,7 @@ enum bitmap_type
89#define zv_height 8 90#define zv_height 8
90static unsigned short zv_bits[] = { 91static unsigned short zv_bits[] = {
91 0x00, 0x00, 0x78, 0x78, 0x78, 0x78, 0x00, 0x00}; 92 0x00, 0x00, 0x78, 0x78, 0x78, 0x78, 0x00, 0x00};
93static HBITMAP zv_bmp;
92 94
93/* An arrow like this: `<-'. */ 95/* An arrow like this: `<-'. */
94 96
@@ -96,6 +98,7 @@ static unsigned short zv_bits[] = {
96#define left_height 8 98#define left_height 8
97static unsigned short left_bits[] = { 99static unsigned short left_bits[] = {
98 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18}; 100 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
101static HBITMAP left_bmp;
99 102
100/* Right truncation arrow bitmap `->'. */ 103/* Right truncation arrow bitmap `->'. */
101 104
@@ -103,6 +106,7 @@ static unsigned short left_bits[] = {
103#define right_height 8 106#define right_height 8
104static unsigned short right_bits[] = { 107static unsigned short right_bits[] = {
105 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18}; 108 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
109static HBITMAP right_bmp;
106 110
107/* Marker for continued lines. */ 111/* Marker for continued lines. */
108 112
@@ -110,6 +114,7 @@ static unsigned short right_bits[] = {
110#define continued_height 8 114#define continued_height 8
111static unsigned short continued_bits[] = { 115static unsigned short continued_bits[] = {
112 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e}; 116 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
117static HBITMAP continued_bmp;
113 118
114/* Marker for continuation lines. */ 119/* Marker for continuation lines. */
115 120
@@ -117,6 +122,7 @@ static unsigned short continued_bits[] = {
117#define continuation_height 8 122#define continuation_height 8
118static unsigned short continuation_bits[] = { 123static unsigned short continuation_bits[] = {
119 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c}; 124 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
125static HBITMAP continuation_bmp;
120 126
121/* Overlay arrow bitmap. */ 127/* Overlay arrow bitmap. */
122 128
@@ -132,8 +138,8 @@ static unsigned short ov_bits[] = {
132#define ov_height 8 138#define ov_height 8
133static unsigned short ov_bits[] = { 139static 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
142static HBITMAP ov_bmp;
137 143
138extern Lisp_Object Qhelp_echo; 144extern Lisp_Object Qhelp_echo;
139 145
@@ -165,6 +171,7 @@ int x_stretch_cursor_p;
165#define CP_DEFAULT 1004 171#define CP_DEFAULT 1004
166 172
167extern unsigned int msh_mousewheel; 173extern unsigned int msh_mousewheel;
174extern int inhibit_busy_cursor;
168 175
169extern void free_frame_menubar (); 176extern void free_frame_menubar ();
170 177
@@ -464,14 +471,6 @@ w32_set_clip_rectangle (HDC hdc, RECT *rect)
464 SelectClipRgn (hdc, NULL); 471 SelectClipRgn (hdc, NULL);
465} 472}
466 473
467/* Return the struct w32_display_info. */
468
469struct w32_display_info *
470w32_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. */
477void 476void
@@ -747,7 +746,6 @@ w32_draw_bitmap (w, hdc, row, which)
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;
@@ -761,7 +759,7 @@ w32_draw_bitmap (w, hdc, row, which)
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);
@@ -770,7 +768,7 @@ w32_draw_bitmap (w, hdc, row, which)
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);
@@ -779,7 +777,7 @@ w32_draw_bitmap (w, hdc, row, which)
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;
@@ -787,7 +785,7 @@ w32_draw_bitmap (w, hdc, row, which)
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;
@@ -795,7 +793,7 @@ w32_draw_bitmap (w, hdc, row, which)
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);
@@ -804,7 +802,7 @@ w32_draw_bitmap (w, hdc, row, which)
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);
@@ -819,10 +817,8 @@ w32_draw_bitmap (w, hdc, row, which)
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);
@@ -838,7 +834,6 @@ w32_draw_bitmap (w, hdc, row, which)
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);
@@ -9548,6 +9543,47 @@ x_wm_set_icon_position (f, icon_x, icon_y)
9548 9543
9549static int w32_initialized = 0; 9544static int w32_initialized = 0;
9550 9545
9546void
9547w32_initialize_display_info (display_name)
9548 Lisp_Object display_name;
9549{
9550 struct w32_display_info *dpyinfo = &one_w32_display_info;
9551
9552 bzero (dpyinfo, sizeof (*dpyinfo));
9553
9554 /* Put it on w32_display_name_list. */
9555 w32_display_name_list = Fcons (Fcons (display_name, Qnil),
9556 w32_display_name_list);
9557 dpyinfo->name_list_element = XCAR (w32_display_name_list);
9558
9559 dpyinfo->w32_id_name
9560 = (char *) xmalloc (XSTRING (Vinvocation_name)->size
9561 + XSTRING (Vsystem_name)->size
9562 + 2);
9563 sprintf (dpyinfo->w32_id_name, "%s@%s",
9564 XSTRING (Vinvocation_name)->data, XSTRING (Vsystem_name)->data);
9565
9566 /* Default Console mode values - overridden when running in GUI mode
9567 with values obtained from system metrics. */
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
9551struct w32_display_info * 9587struct w32_display_info *
9552w32_term_init (display_name, xrm_option, resource_name) 9588w32_term_init (display_name, xrm_option, resource_name)
9553 Lisp_Object display_name; 9589 Lisp_Object display_name;
@@ -9578,31 +9614,10 @@ w32_term_init (display_name, xrm_option, resource_name)
9578 } 9614 }
9579 } 9615 }
9580 9616
9581 dpyinfo = &one_w32_display_info; 9617 w32_initialize_display_info (display_name);
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),
9588 w32_display_name_list);
9589 dpyinfo->name_list_element = XCAR (w32_display_name_list);
9590
9591 dpyinfo->w32_id_name
9592 = (char *) xmalloc (XSTRING (Vinvocation_name)->size
9593 + XSTRING (Vsystem_name)->size
9594 + 2);
9595 sprintf (dpyinfo->w32_id_name, "%s@%s",
9596 XSTRING (Vinvocation_name)->data, XSTRING (Vsystem_name)->data);
9597 9618
9598#if 0 9619 dpyinfo = &one_w32_display_info;
9599 xrdb = x_load_resources (dpyinfo->display, xrm_option,
9600 resource_name, EMACS_CLASS);
9601 9620
9602 /* Put the rdb where we can find it in a way that works on
9603 all versions. */
9604 dpyinfo->xrdb = xrdb;
9605#endif
9606 hdc = GetDC (GetDesktopWindow ()); 9621 hdc = GetDC (GetDesktopWindow ());
9607 9622
9608 dpyinfo->height = GetDeviceCaps (hdc, VERTRES); 9623 dpyinfo->height = GetDeviceCaps (hdc, VERTRES);
@@ -9613,35 +9628,10 @@ w32_term_init (display_name, xrm_option, resource_name)
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 {
@@ -9650,6 +9640,16 @@ w32_term_init (display_name, xrm_option, resource_name)
9650 w32_defined_color (0, "black", &color, 1); 9640 w32_defined_color (0, "black", &color, 1);
9651 } 9641 }
9652 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
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
@@ -9689,8 +9689,7 @@ x_delete_display (dpyinfo)
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;
@@ -9716,6 +9715,14 @@ x_delete_display (dpyinfo)
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. */