aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-07-20 17:44:22 +0000
committerRichard M. Stallman1997-07-20 17:44:22 +0000
commit8c1a6a84ca839b567d38ffab7ed6803bc8cccac4 (patch)
treeeceb53abf05cdf6d5dfc908d1fdef40f9396ac80
parent149f002ee2a91f242ae99029161d623b963c1892 (diff)
downloademacs-8c1a6a84ca839b567d38ffab7ed6803bc8cccac4.tar.gz
emacs-8c1a6a84ca839b567d38ffab7ed6803bc8cccac4.zip
(XTread_socket) <ClientMessage>:
For wm_take_focus, use x_any_window_to_frame. Don't use FRAME_XIC if it is null, here. (dumpglyphs): Use 8-bit output to X, rather than 16-bit, if the character values permit that.
-rw-r--r--src/xterm.c80
1 files changed, 56 insertions, 24 deletions
diff --git a/src/xterm.c b/src/xterm.c
index b8c88bcaf65..573f939d836 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -543,8 +543,11 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
543 struct cmpchar_info *cmpcharp; 543 struct cmpchar_info *cmpcharp;
544{ 544{
545 /* Holds characters to be displayed. */ 545 /* Holds characters to be displayed. */
546 XChar2b *buf = (XChar2b *) alloca (FRAME_WINDOW_WIDTH (f) * sizeof (*buf)); 546 XChar2b *x_2byte_buffer
547 register XChar2b *cp; /* Steps through buf[]. */ 547 = (XChar2b *) alloca (FRAME_WINDOW_WIDTH (f) * sizeof (*x_2byte_buffer));
548 register XChar2b *cp; /* Steps through x_2byte_buffer[]. */
549 char *x_1byte_buffer
550 = (char *) alloca (FRAME_WINDOW_WIDTH (f) * sizeof (*x_1byte_buffer));
548 register int tlen = GLYPH_TABLE_LENGTH; 551 register int tlen = GLYPH_TABLE_LENGTH;
549 register Lisp_Object *tbase = GLYPH_TABLE_BASE; 552 register Lisp_Object *tbase = GLYPH_TABLE_BASE;
550 Window window = FRAME_X_WINDOW (f); 553 Window window = FRAME_X_WINDOW (f);
@@ -592,10 +595,10 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
592 595
593 /* Find the run of consecutive glyphs which can be drawn with 596 /* Find the run of consecutive glyphs which can be drawn with
594 the same GC (i.e. the same charset and the same face-code). 597 the same GC (i.e. the same charset and the same face-code).
595 Extract their character codes into BUF. 598 Extract their character codes into X_2BYTE_BUFFER.
596 If CMPCHARP is not NULL, face-code is not checked because we 599 If CMPCHARP is not NULL, face-code is not checked because we
597 use only the face specified in `cmpcharp->face_work'. */ 600 use only the face specified in `cmpcharp->face_work'. */
598 cp = buf; 601 cp = x_2byte_buffer;
599 while (n > 0) 602 while (n > 0)
600 { 603 {
601 int this_charset, c1, c2; 604 int this_charset, c1, c2;
@@ -619,7 +622,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
619 } 622 }
620 623
621 /* LEN gets the length of the run. */ 624 /* LEN gets the length of the run. */
622 len = cp - buf; 625 len = cp - x_2byte_buffer;
623 /* Now output this run of chars, with the font and pixel values 626 /* Now output this run of chars, with the font and pixel values
624 determined by the face code CF. */ 627 determined by the face code CF. */
625 { 628 {
@@ -725,7 +728,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
725 struct ccl_program *ccl = fontp->font_encoder; 728 struct ccl_program *ccl = fontp->font_encoder;
726 729
727 if (CHARSET_DIMENSION (charset) == 1) 730 if (CHARSET_DIMENSION (charset) == 1)
728 for (cp = buf; cp < buf + len; cp++) 731 for (cp = x_2byte_buffer; cp < x_2byte_buffer + len; cp++)
729 { 732 {
730 ccl->reg[0] = charset; 733 ccl->reg[0] = charset;
731 ccl->reg[1] = cp->byte2; 734 ccl->reg[1] = cp->byte2;
@@ -733,7 +736,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
733 cp->byte2 = ccl->reg[1]; 736 cp->byte2 = ccl->reg[1];
734 } 737 }
735 else 738 else
736 for (cp = buf; cp < buf + len; cp++) 739 for (cp = x_2byte_buffer; cp < x_2byte_buffer + len; cp++)
737 { 740 {
738 ccl->reg[0] = charset; 741 ccl->reg[0] = charset;
739 ccl->reg[1] = cp->byte1, ccl->reg[2] = cp->byte2; 742 ccl->reg[1] = cp->byte1, ccl->reg[2] = cp->byte2;
@@ -746,10 +749,10 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
746 int enc = fontp->encoding[charset]; 749 int enc = fontp->encoding[charset];
747 750
748 if ((enc == 1 || enc == 2) && CHARSET_DIMENSION (charset) == 2) 751 if ((enc == 1 || enc == 2) && CHARSET_DIMENSION (charset) == 2)
749 for (cp = buf; cp < buf + len; cp++) 752 for (cp = x_2byte_buffer; cp < x_2byte_buffer + len; cp++)
750 cp->byte1 |= 0x80; 753 cp->byte1 |= 0x80;
751 if (enc == 1 || enc == 3) 754 if (enc == 1 || enc == 3)
752 for (cp = buf; cp < buf + len; cp++) 755 for (cp = x_2byte_buffer; cp < x_2byte_buffer + len; cp++)
753 cp->byte2 |= 0x80; 756 cp->byte2 |= 0x80;
754 } 757 }
755 } 758 }
@@ -769,7 +772,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
769 font = NULL; 772 font = NULL;
770 else 773 else
771 { 774 {
772 for (cp = buf; cp < buf + len; cp++) 775 for (cp = x_2byte_buffer; cp < x_2byte_buffer + len; cp++)
773 cp->byte2 |= 0x80; 776 cp->byte2 |= 0x80;
774 } 777 }
775 } 778 }
@@ -913,24 +916,50 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
913 if (background_filled) 916 if (background_filled)
914 XDrawString16 (FRAME_X_DISPLAY (f), window, gc, 917 XDrawString16 (FRAME_X_DISPLAY (f), window, gc,
915 left + glyph_width * i, 918 left + glyph_width * i,
916 top + baseline, buf + i, 1); 919 top + baseline, x_2byte_buffer + i, 1);
917 else 920 else
918 XDrawImageString16 (FRAME_X_DISPLAY (f), window, gc, 921 XDrawImageString16 (FRAME_X_DISPLAY (f), window, gc,
919 left + glyph_width * i, 922 left + glyph_width * i,
920 top + baseline, buf + i, 1); 923 top + baseline, x_2byte_buffer + i, 1);
921 } 924 }
922 else 925 else
923 { 926 {
924 if (background_filled) 927 /* See if this whole buffer can be output as 8-bit chars.
925 XDrawString16 (FRAME_X_DISPLAY (f), window, gc, 928 If so, copy x_2byte_buffer to x_1byte_buffer
926 left, top + baseline, buf, len); 929 and do it as 8-bit chars. */
930 for (i = 0; i < len; i++)
931 {
932 if (x_2byte_buffer[i].byte1 != 0)
933 break;
934 x_1byte_buffer[i] = x_2byte_buffer[i].byte2;
935 }
936
937 if (i == len)
938 {
939 if (background_filled)
940 XDrawString (FRAME_X_DISPLAY (f), window, gc,
941 left, top + baseline, x_1byte_buffer, len);
942 else
943 XDrawImageString (FRAME_X_DISPLAY (f), window, gc,
944 left, top + baseline, x_1byte_buffer, len);
945 }
927 else 946 else
928 XDrawImageString16 (FRAME_X_DISPLAY (f), window, gc, 947 {
929 left, top + baseline, buf, len); 948 /* We can't output them as 8-bit chars,
949 so do it as 16-bit chars. */
950
951 if (background_filled)
952 XDrawString16 (FRAME_X_DISPLAY (f), window, gc,
953 left, top + baseline, x_2byte_buffer, len);
954 else
955 XDrawImageString16 (FRAME_X_DISPLAY (f), window, gc,
956 left, top + baseline, x_2byte_buffer, len);
957 }
930 } 958 }
931 } 959 }
932 else 960 else
933 { 961 {
962 /* Handle composite characters. */
934 XCharStruct *pcm; /* Pointer to per char metric info. */ 963 XCharStruct *pcm; /* Pointer to per char metric info. */
935 964
936 if ((cmpcharp->cmp_rule || relative_compose) 965 if ((cmpcharp->cmp_rule || relative_compose)
@@ -950,7 +979,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
950 } 979 }
951 else 980 else
952 { 981 {
953 pcm = PER_CHAR_METRIC (font, buf); 982 pcm = PER_CHAR_METRIC (font, x_2byte_buffer);
954 highest = pcm->ascent + 1; 983 highest = pcm->ascent + 1;
955 lowest = - pcm->descent; 984 lowest = - pcm->descent;
956 } 985 }
@@ -960,7 +989,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
960 * FONT_WIDTH (f->output_data.x->font)); 989 * FONT_WIDTH (f->output_data.x->font));
961 /* Draw the first character at the normal position. */ 990 /* Draw the first character at the normal position. */
962 XDrawString16 (FRAME_X_DISPLAY (f), window, gc, 991 XDrawString16 (FRAME_X_DISPLAY (f), window, gc,
963 left + x_offset, top + baseline, buf, 1); 992 left + x_offset, top + baseline, x_2byte_buffer, 1);
964 i = 1; 993 i = 1;
965 gidx++; 994 gidx++;
966 } 995 }
@@ -973,7 +1002,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
973 1002
974 if (relative_compose) 1003 if (relative_compose)
975 { 1004 {
976 pcm = PER_CHAR_METRIC (font, buf + i); 1005 pcm = PER_CHAR_METRIC (font, x_2byte_buffer + i);
977 if (- pcm->descent >= relative_compose) 1006 if (- pcm->descent >= relative_compose)
978 { 1007 {
979 /* Draw above the current glyphs. */ 1008 /* Draw above the current glyphs. */
@@ -999,7 +1028,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
999 gref = gref / 3 + (gref == 4) * 2; 1028 gref = gref / 3 + (gref == 4) * 2;
1000 nref = nref / 3 + (nref == 4) * 2; 1029 nref = nref / 3 + (nref == 4) * 2;
1001 1030
1002 pcm = PER_CHAR_METRIC (font, buf + i); 1031 pcm = PER_CHAR_METRIC (font, x_2byte_buffer + i);
1003 bottom = ((gref == 0 ? highest : gref == 1 ? 0 1032 bottom = ((gref == 0 ? highest : gref == 1 ? 0
1004 : gref == 2 ? lowest 1033 : gref == 2 ? lowest
1005 : (highest + lowest) / 2) 1034 : (highest + lowest) / 2)
@@ -1017,7 +1046,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp)
1017 } 1046 }
1018 XDrawString16 (FRAME_X_DISPLAY (f), window, gc, 1047 XDrawString16 (FRAME_X_DISPLAY (f), window, gc,
1019 left + x_offset, top + baseline - y_offset, 1048 left + x_offset, top + baseline - y_offset,
1020 buf + i, 1); 1049 x_2byte_buffer + i, 1);
1021 } 1050 }
1022 } 1051 }
1023 if (require_clipping) 1052 if (require_clipping)
@@ -3792,13 +3821,16 @@ XTread_socket (sd, bufp, numchars, expected)
3792 if (event.xclient.data.l[0] 3821 if (event.xclient.data.l[0]
3793 == dpyinfo->Xatom_wm_take_focus) 3822 == dpyinfo->Xatom_wm_take_focus)
3794 { 3823 {
3795 f = x_window_to_frame (dpyinfo, event.xclient.window); 3824 /* Use x_any_window_to_frame because this
3825 could be the shell widget window
3826 if the frame has no title bar. */
3827 f = x_any_window_to_frame (dpyinfo, event.xclient.window);
3796 /* Since we set WM_TAKE_FOCUS, we must call 3828 /* Since we set WM_TAKE_FOCUS, we must call
3797 XSetInputFocus explicitly. But not if f is null, 3829 XSetInputFocus explicitly. But not if f is null,
3798 since that might be an event for a deleted frame. */ 3830 since that might be an event for a deleted frame. */
3799#ifdef HAVE_X_I18N 3831#ifdef HAVE_X_I18N
3800 /* Not quite sure this is needed -pd */ 3832 /* Not quite sure this is needed -pd */
3801 if (f) 3833 if (f && FRAME_XIC (f))
3802 XSetICFocus (FRAME_XIC (f)); 3834 XSetICFocus (FRAME_XIC (f));
3803#endif 3835#endif
3804 if (f) 3836 if (f)