aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2003-10-11 23:01:55 +0000
committerJason Rumney2003-10-11 23:01:55 +0000
commit66f30e44e9ae789b61cea9e446e78172da20733a (patch)
tree9cdf216ef6b63bbf6bde76234867d8faf34fb929 /src
parentb7a6fc07912aa448be19b85d7db46f10abd74235 (diff)
downloademacs-66f30e44e9ae789b61cea9e446e78172da20733a.tar.gz
emacs-66f30e44e9ae789b61cea9e446e78172da20733a.zip
(w32_encode_char): New charset parameter. font_info.encoding becomes
encoding_type. (x_get_font_repertory): New function. Warning: stub only! (x_new_font): Return quickly if font already set. (x_new_fontset): fontsetname parameter is Lisp_Object. Use new fs_query_fontset. Try new_fontset_from_font_name. Use fontset_name for return value.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c223
1 files changed, 159 insertions, 64 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 35952e03347..d800a9cca5f 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -24,25 +24,21 @@ Boston, MA 02111-1307, USA. */
24#include <stdio.h> 24#include <stdio.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include "lisp.h" 26#include "lisp.h"
27#include "charset.h"
28#include "blockinput.h" 27#include "blockinput.h"
29
30#include "w32heap.h"
31#include "w32term.h" 28#include "w32term.h"
32#include "w32bdf.h"
33#include <shellapi.h>
34 29
35#include "systty.h" 30#include "systty.h"
36#include "systime.h" 31#include "systime.h"
37#include "atimer.h"
38#include "keymap.h"
39 32
40#include <ctype.h> 33#include <ctype.h>
41#include <errno.h> 34#include <errno.h>
42#include <setjmp.h> 35#include <setjmp.h>
43#include <sys/stat.h> 36#include <sys/stat.h>
44 37
45#include "keyboard.h" 38#include "charset.h"
39#include "character.h"
40#include "coding.h"
41#include "ccl.h"
46#include "frame.h" 42#include "frame.h"
47#include "dispextern.h" 43#include "dispextern.h"
48#include "fontset.h" 44#include "fontset.h"
@@ -53,9 +49,15 @@ Boston, MA 02111-1307, USA. */
53#include "disptab.h" 49#include "disptab.h"
54#include "buffer.h" 50#include "buffer.h"
55#include "window.h" 51#include "window.h"
52#include "keyboard.h"
56#include "intervals.h" 53#include "intervals.h"
57#include "composite.h" 54#include "process.h"
58#include "coding.h" 55#include "atimer.h"
56#include "keymap.h"
57
58#include "w32heap.h"
59#include "w32bdf.h"
60#include <shellapi.h>
59 61
60#define abs(x) ((x) < 0 ? -(x) : (x)) 62#define abs(x) ((x) < 0 ? -(x) : (x))
61 63
@@ -748,7 +750,8 @@ w32_reset_terminal_modes (void)
748 750
749static XCharStruct *w32_per_char_metric P_ ((XFontStruct *, 751static XCharStruct *w32_per_char_metric P_ ((XFontStruct *,
750 wchar_t *, int)); 752 wchar_t *, int));
751static int w32_encode_char P_ ((int, wchar_t *, struct font_info *, int *)); 753static int w32_encode_char P_ ((int, wchar_t *, struct font_info *,
754 struct charset *, int *));
752 755
753 756
754/* Get metrics of character CHAR2B in FONT. Value is always non-null. 757/* Get metrics of character CHAR2B in FONT. Value is always non-null.
@@ -895,7 +898,17 @@ w32_per_char_metric (font, char2b, font_type)
895 BOOL retval; 898 BOOL retval;
896 899
897 xassert (font && char2b); 900 xassert (font && char2b);
898 xassert (font_type != UNKNOWN_FONT); 901
902 /* TODO: This function is currently called through the RIF, and in
903 some cases font_type is UNKNOWN_FONT. We currently allow the
904 cached metrics to be used, which seems to work, but in cases
905 where font_type is UNKNOWN_FONT, we probably haven't encoded
906 char2b appropriately. All callers need checking to see what they
907 are passing. This is most likely to affect variable width fonts
908 outside the Latin-1 range, particularly in languages like Thai
909 that rely on rbearing and lbearing to provide composition. I
910 don't think that is working currently anyway, but we don't seem
911 to have anyone testing such languages on Windows. */
899 912
900 /* Handle the common cases quickly. */ 913 /* Handle the common cases quickly. */
901 if (!font->bdf && font->per_char == NULL) 914 if (!font->bdf && font->per_char == NULL)
@@ -904,6 +917,8 @@ w32_per_char_metric (font, char2b, font_type)
904 else if (!font->bdf && *char2b < 128) 917 else if (!font->bdf && *char2b < 128)
905 return &font->per_char[*char2b]; 918 return &font->per_char[*char2b];
906 919
920 xassert (font_type != UNKNOWN_FONT);
921
907 pcm = &font->scratch; 922 pcm = &font->scratch;
908 923
909 if (font_type == BDF_1D_FONT) 924 if (font_type == BDF_1D_FONT)
@@ -990,13 +1005,13 @@ w32_use_unicode_for_codepage (codepage)
990 the two-byte form of C. Encoding is returned in *CHAR2B. */ 1005 the two-byte form of C. Encoding is returned in *CHAR2B. */
991 1006
992static int /* enum w32_char_font_type */ 1007static int /* enum w32_char_font_type */
993w32_encode_char (c, char2b, font_info, two_byte_p) 1008w32_encode_char (c, char2b, font_info, charset, two_byte_p)
994 int c; 1009 int c;
995 wchar_t *char2b; 1010 wchar_t *char2b;
996 struct font_info *font_info; 1011 struct font_info *font_info;
1012 struct charset *charset;
997 int * two_byte_p; 1013 int * two_byte_p;
998{ 1014{
999 struct charset *charset = CHAR_CHARSET (c);
1000 int codepage; 1015 int codepage;
1001 int unicode_p = 0; 1016 int unicode_p = 0;
1002 int internal_two_byte_p = 0; 1017 int internal_two_byte_p = 0;
@@ -1035,11 +1050,11 @@ w32_encode_char (c, char2b, font_info, two_byte_p)
1035 else 1050 else
1036 STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]); 1051 STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]);
1037 } 1052 }
1038 else if (font_info->encoding[charset]) 1053 else if (font_info->encoding_type)
1039 { 1054 {
1040 /* Fixed encoding scheme. See fontset.h for the meaning of the 1055 /* Fixed encoding scheme. See fontset.h for the meaning of the
1041 encoding numbers. */ 1056 encoding numbers. */
1042 int enc = font_info->encoding[charset]; 1057 unsigned char enc = font_info->encoding_type;
1043 1058
1044 if ((enc == 1 || enc == 2) 1059 if ((enc == 1 || enc == 2)
1045 && CHARSET_DIMENSION (charset) == 2) 1060 && CHARSET_DIMENSION (charset) == 2)
@@ -1094,6 +1109,103 @@ w32_encode_char (c, char2b, font_info, two_byte_p)
1094} 1109}
1095 1110
1096 1111
1112/* Return a char-table whose elements are t if the font FONT_INFO
1113 contains a glyph for the corresponding character, and nil if not.
1114
1115 Fixme: For the moment, this function works only for fonts whose
1116 glyph encoding is the same as Unicode (e.g. ISO10646-1 fonts). */
1117
1118Lisp_Object
1119x_get_font_repertory (f, font_info)
1120 FRAME_PTR f;
1121 struct font_info *font_info;
1122{
1123#if 0 /* TODO: New function, convert to Windows. */
1124 XFontStruct *font = (XFontStruct *) font_info->font;
1125 Lisp_Object table;
1126 int min_byte1, max_byte1, min_byte2, max_byte2;
1127
1128 table = Fmake_char_table (Qnil, Qnil);
1129
1130 min_byte1 = font->min_byte1;
1131 max_byte1 = font->max_byte1;
1132 min_byte2 = font->min_char_or_byte2;
1133 max_byte2 = font->max_char_or_byte2;
1134 if (min_byte1 == 0 && max_byte1 == 0)
1135 {
1136 if (! font->per_char || font->all_chars_exist == True)
1137 char_table_set_range (table, min_byte2, max_byte2, Qt);
1138 else
1139 {
1140 XCharStruct *pcm = font->per_char;
1141 int from = -1;
1142 int i;
1143
1144 for (i = min_byte2; i <= max_byte2; i++, pcm++)
1145 {
1146 if (pcm->width == 0 && pcm->rbearing == pcm->lbearing)
1147 {
1148 if (from >= 0)
1149 {
1150 char_table_set_range (table, from, i - 1, Qt);
1151 from = -1;
1152 }
1153 }
1154 else if (from < 0)
1155 from = i;
1156 }
1157 if (from >= 0)
1158 char_table_set_range (table, from, i - 1, Qt);
1159 }
1160 }
1161 else
1162 {
1163 if (! font->per_char || font->all_chars_exist == True)
1164 {
1165 int i;
1166
1167 for (i = min_byte1; i <= max_byte1; i++)
1168 char_table_set_range (table,
1169 (i << 8) | min_byte2, (i << 8) | max_byte2,
1170 Qt);
1171 }
1172 else
1173 {
1174 XCharStruct *pcm = font->per_char;
1175 int i;
1176
1177 for (i = min_byte1; i <= max_byte1; i++)
1178 {
1179 int from = -1;
1180 int j;
1181
1182 for (j = min_byte2; j <= max_byte2; j++, pcm++)
1183 {
1184 if (pcm->width == 0 && pcm->rbearing == pcm->lbearing)
1185 {
1186 if (from >= 0)
1187 {
1188 char_table_set_range (table, (i << 8) | from,
1189 (i << 8) | (j - 1), Qt);
1190 from = -1;
1191 }
1192 }
1193 else if (from < 0)
1194 from = j;
1195 }
1196 if (from >= 0)
1197 char_table_set_range (table, (i << 8) | from,
1198 (i << 8) | (j - 1), Qt);
1199 }
1200 }
1201 }
1202
1203 return table;
1204#else
1205 return Fmake_char_table (Qnil, Qnil);
1206#endif
1207}
1208
1097 1209
1098/*********************************************************************** 1210/***********************************************************************
1099 Glyph display 1211 Glyph display
@@ -3050,7 +3162,6 @@ note_mouse_movement (frame, msg)
3050static struct scroll_bar *x_window_to_scroll_bar (); 3162static struct scroll_bar *x_window_to_scroll_bar ();
3051static void x_scroll_bar_report_motion (); 3163static void x_scroll_bar_report_motion ();
3052static void x_check_fullscreen P_ ((struct frame *)); 3164static void x_check_fullscreen P_ ((struct frame *));
3053static void x_check_fullscreen_move P_ ((struct frame *));
3054static int glyph_rect P_ ((struct frame *f, int, int, RECT *)); 3165static int glyph_rect P_ ((struct frame *f, int, int, RECT *));
3055 3166
3056 3167
@@ -4462,7 +4573,6 @@ w32_read_socket (sd, bufp, numchars, expected)
4462 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4573 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4463 if (f) 4574 if (f)
4464 { 4575 {
4465 x_check_fullscreen_move(f);
4466 if (f->want_fullscreen & FULLSCREEN_WAIT) 4576 if (f->want_fullscreen & FULLSCREEN_WAIT)
4467 f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH); 4577 f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH);
4468 } 4578 }
@@ -4776,7 +4886,7 @@ w32_read_socket (sd, bufp, numchars, expected)
4776 if (msg.msg.message == msh_mousewheel) 4886 if (msg.msg.message == msh_mousewheel)
4777 { 4887 {
4778 /* Forward MSH_MOUSEWHEEL as WM_MOUSEWHEEL. */ 4888 /* Forward MSH_MOUSEWHEEL as WM_MOUSEWHEEL. */
4779 msg.msg.message == WM_MOUSEWHEEL; 4889 msg.msg.message = WM_MOUSEWHEEL;
4780 prepend_msg (&msg); 4890 prepend_msg (&msg);
4781 } 4891 }
4782 break; 4892 break;
@@ -5234,6 +5344,11 @@ x_new_font (f, fontname)
5234 if (!fontp) 5344 if (!fontp)
5235 return Qnil; 5345 return Qnil;
5236 5346
5347 if (FRAME_FONT (f) == (XFontStruct *) (fontp->font))
5348 /* This font is already set in frame F. There's nothing more to
5349 do. */
5350 return build_string (fontp->full_name);
5351
5237 FRAME_FONT (f) = (XFontStruct *) (fontp->font); 5352 FRAME_FONT (f) = (XFontStruct *) (fontp->font);
5238 FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset; 5353 FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
5239 FRAME_FONTSET (f) = -1; 5354 FRAME_FONTSET (f) = -1;
@@ -5266,37 +5381,49 @@ x_new_font (f, fontname)
5266 return build_string (fontp->full_name); 5381 return build_string (fontp->full_name);
5267} 5382}
5268 5383
5269/* Give frame F the fontset named FONTSETNAME as its default font, and 5384/* Give frame F the fontset named FONTSETNAME as its default fontset,
5270 return the full name of that fontset. FONTSETNAME may be a wildcard 5385 and return the full name of that fontset. FONTSETNAME may be a
5271 pattern; in that case, we choose some fontset that fits the pattern. 5386 wildcard pattern; in that case, we choose some fontset that fits
5272 The return value shows which fontset we chose. */ 5387 the pattern. FONTSETNAME may be a font name for ASCII characters;
5388 in that case, we create a fontset from that font name.
5389
5390 The return value shows which fontset we chose.
5391 If FONTSETNAME specifies the default fontset, return Qt.
5392 If an ASCII font in the specified fontset can't be loaded, return
5393 Qnil. */
5273 5394
5274Lisp_Object 5395Lisp_Object
5275x_new_fontset (f, fontsetname) 5396x_new_fontset (f, fontsetname)
5276 struct frame *f; 5397 struct frame *f;
5277 char *fontsetname; 5398 Lisp_Object fontsetname;
5278{ 5399{
5279 int fontset = fs_query_fontset (build_string (fontsetname), 0); 5400 int fontset = fs_query_fontset (fontsetname, 0);
5280 Lisp_Object result; 5401 Lisp_Object result;
5281 5402
5282 if (fontset < 0) 5403 if (fontset > 0 && FRAME_FONTSET(f) == fontset)
5283 return Qnil;
5284
5285 if (FRAME_FONTSET (f) == fontset)
5286 /* This fontset is already set in frame F. There's nothing more 5404 /* This fontset is already set in frame F. There's nothing more
5287 to do. */ 5405 to do. */
5288 return fontset_name (fontset); 5406 return fontset_name (fontset);
5407 else if (fontset == 0)
5408 /* The default fontset can't be the default font. */
5409 return Qt;
5289 5410
5290 result = x_new_font (f, (SDATA (fontset_ascii (fontset)))); 5411 if (fontset > 0)
5412 result = x_new_font (f, (SDATA (fontset_ascii (fontset))));
5413 else
5414 result = x_new_font (f, SDATA (fontsetname));
5291 5415
5292 if (!STRINGP (result)) 5416 if (!STRINGP (result))
5293 /* Can't load ASCII font. */ 5417 /* Can't load ASCII font. */
5294 return Qnil; 5418 return Qnil;
5295 5419
5420 if (fontset < 0)
5421 fontset = new_fontset_from_font_name (result);
5422
5296 /* Since x_new_font doesn't update any fontset information, do it now. */ 5423 /* Since x_new_font doesn't update any fontset information, do it now. */
5297 FRAME_FONTSET(f) = fontset; 5424 FRAME_FONTSET(f) = fontset;
5298 5425
5299 return build_string (fontsetname); 5426 return fontset_name (fontset);
5300} 5427}
5301 5428
5302 5429
@@ -5428,9 +5555,7 @@ x_check_fullscreen (f)
5428 x_fullscreen_adjust (f, &width, &height, &ign, &ign); 5555 x_fullscreen_adjust (f, &width, &height, &ign, &ign);
5429 5556
5430 /* We do not need to move the window, it shall be taken care of 5557 /* We do not need to move the window, it shall be taken care of
5431 when setting WM manager hints. 5558 when setting WM manager hints. */
5432 If the frame is visible already, the position is checked by
5433 x_check_fullscreen_move. */
5434 if (FRAME_COLS (f) != width || FRAME_LINES (f) != height) 5559 if (FRAME_COLS (f) != width || FRAME_LINES (f) != height)
5435 { 5560 {
5436 change_frame_size (f, height, width, 0, 1, 0); 5561 change_frame_size (f, height, width, 0, 1, 0);
@@ -5443,36 +5568,6 @@ x_check_fullscreen (f)
5443 } 5568 }
5444} 5569}
5445 5570
5446/* If frame parameters are set after the frame is mapped, we need to move
5447 the window. This is done in xfns.c.
5448 Some window managers moves the window to the right position, some
5449 moves the outer window manager window to the specified position.
5450 Here we check that we are in the right spot. If not, make a second
5451 move, assuming we are dealing with the second kind of window manager. */
5452static void
5453x_check_fullscreen_move (f)
5454 struct frame *f;
5455{
5456 if (f->want_fullscreen & FULLSCREEN_MOVE_WAIT)
5457 {
5458 int expect_top = f->top_pos;
5459 int expect_left = f->left_pos;
5460
5461 if (f->want_fullscreen & FULLSCREEN_HEIGHT)
5462 expect_top = 0;
5463 if (f->want_fullscreen & FULLSCREEN_WIDTH)
5464 expect_left = 0;
5465
5466 if (expect_top != f->top_pos
5467 || expect_left != f->left_pos)
5468 x_set_offset (f, expect_left, expect_top, 1);
5469
5470 /* Just do this once */
5471 f->want_fullscreen &= ~FULLSCREEN_MOVE_WAIT;
5472 }
5473}
5474
5475
5476/* Call this to change the size of frame F's x-window. 5571/* Call this to change the size of frame F's x-window.
5477 If CHANGE_GRAVITY is 1, we change to top-left-corner window gravity 5572 If CHANGE_GRAVITY is 1, we change to top-left-corner window gravity
5478 for this size change and subsequent size changes. 5573 for this size change and subsequent size changes.