annotate src/redisplay-x.c @ 4594:2986723ac32d

Update comment.
author Stephen J. Turnbull <stephen@xemacs.org>
date Mon, 02 Feb 2009 23:31:09 +0900
parents 3d2a9b62e044
children 11daf37dae4d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* X output and frame manipulation routines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1994 Lucid, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1204
diff changeset
5 Copyright (C) 2002, 2003 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 /* Author: Chuck Thompson */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 /* Lots of work done by Ben Wing for Mule */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "debug.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
35 #include "device-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "faces.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
37 #include "file-coding.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
38 #include "frame-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "gutter.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "redisplay.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include "sysdep.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "window.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
43
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
44 #include "mule-ccl.h"
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
45 #include "charset.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
46
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
47 #include "console-x-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
48 #include "glyphs-x.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
49 #include "objects-x-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
50 #include "xgccache.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
51
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
52 #include "EmacsFrame.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
53 #include "EmacsFrameP.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 #include "sysproc.h" /* for select() */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
57 #include <X11/bitmaps/gray>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 /* Number of pixels below each line. */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
60 int x_interline_space; /* #### this needs to be implemented, but per-font */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #define EOL_CURSOR_WIDTH 5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 static void x_output_vertical_divider (struct window *w, int clear);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 static void x_output_blank (struct window *w, struct display_line *dl,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 struct rune *rb, int start_pixpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 int cursor_start, int cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 static void x_output_hline (struct window *w, struct display_line *dl,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 struct rune *rb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 static void x_output_eol_cursor (struct window *w, struct display_line *dl,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 int xpos, face_index findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 static void x_clear_frame (struct frame *f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 static void x_clear_frame_windows (Lisp_Object window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
75 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
76 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
77 ? ((unsigned long) (x)) : ((unsigned long) (y)))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
78 #endif /* USE_XFT */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
79
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
81 /* Note: We do not use the Xmb*() functions and XFontSets, nor the
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
82 Motif XFontLists and CompoundStrings.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
83 Those functions are generally losing for a number of reasons.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
84 Most important, they only support one locale (e.g. you could
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
85 display Japanese and ASCII text, but not mixed Japanese/Chinese
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
86 text). You could maybe call setlocale() frequently to try to deal
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
87 with this, but that would generally fail because an XFontSet is
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
88 tied to one locale and won't have the other character sets in it.
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
89
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
90 fontconfig (the font database for Xft) has some specifier-like
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
91 properties, but it's not sufficient (witness the existence of
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
92 Pango). Pango might do the trick, but it's not a cross-platform
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
93 solution; it would need significant advantages to be worth the
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
94 effort.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
95 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
97 /* #### Break me out into a separate header */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 struct textual_run
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 Lisp_Object charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 unsigned char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 int dimension;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 /* Separate out the text in DYN into a series of textual runs of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 particular charset. Also convert the characters as necessary into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 the format needed by XDrawImageString(), XDrawImageString16(), et
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
109 al. This means converting to one or two byte format, possibly
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
110 tweaking the high bits, and possibly running a CCL program. You
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 must pre-allocate the space used and pass it in. (This is done so
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
112 you can ALLOCA () the space.) (sizeof(bufchar) * len) bytes must be
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
113 allocated for TEXT_STORAGE and (len * sizeof (struct textual_run))
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
114 bytes of RUN_STORAGE, where LEN is the length of the dynarr.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
115
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
116 bufchar might not be fixed width (in the case of UTF-8).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 Returns the number of runs actually used. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
120 /* Notes on Xft implementation
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
121
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
122 - With Unicode, we're no longer going to have repertoires reified as
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
123 charsets. (Not that we ever really did, what with corporate variants,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
124 and so on.) So we really should be querying the face for the desired
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
125 font, rather than the character for the charset, and that's what would
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
126 determine the separation into runs.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
127 - The widechar versions of fontconfig (and therefore Xft) functions
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
128 seem to be just bigendian Unicode. So there's actually no need to use
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
129 the 8-bit versions in computing runs and runes, it would seem.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
130 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
131
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
132 #if !defined(USE_XFT) && !defined(MULE)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 static int
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
134 separate_textual_runs_nomule (unsigned char *text_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
135 struct textual_run *run_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
136 const Ichar *str, Charcount len,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
137 struct face_cachel *UNUSED(cachel))
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
138 {
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
139 int i;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
140 if (!len)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
141 return 0;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
142
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
143 run_storage[0].ptr = text_storage;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
144 run_storage[0].len = len;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
145 run_storage[0].dimension = 1;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
146 run_storage[0].charset = Qnil;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
147
3909
3d2a9b62e044 [xemacs-hg @ 2007-04-16 14:22:39 by stephent]
stephent
parents: 3896
diff changeset
148 while (len--)
3d2a9b62e044 [xemacs-hg @ 2007-04-16 14:22:39 by stephent]
stephent
parents: 3896
diff changeset
149 *text_storage++ = *str++;
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
150 return 1;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
151 }
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
152 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
153
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
154 #if defined(USE_XFT) && !defined(MULE)
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
155 /*
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
156 Note that in this configuration the "Croatian hack" of using an 8-bit,
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
157 non-Latin-1 font to get localized display without Mule simply isn't
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
158 available. That's by design -- Unicode does not aid or abet that kind
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
159 of punning.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
160 This means that the cast to XftChar16 gives the correct "conversion" to
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
161 UCS-2.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
162 #### Is there an alignment issue with text_storage?
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
163 */
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
164 static int
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
165 separate_textual_runs_xft_nomule (unsigned char *text_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
166 struct textual_run *run_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
167 const Ichar *str, Charcount len,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
168 struct face_cachel *UNUSED(cachel))
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
169 {
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
170 int i;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
171 if (!len)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
172 return 0;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
173
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
174 run_storage[0].ptr = text_storage;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
175 run_storage[0].len = len;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
176 run_storage[0].dimension = 2;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
177 run_storage[0].charset = Qnil;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
178
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
179 for (i = 0; i < len; i++)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
180 {
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
181 *(XftChar16 *)text_storage = str[i];
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
182 text_storage += sizeof(XftChar16);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
183 }
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
184 return 1;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
185 }
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
186 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
187
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
188 #if defined(USE_XFT) && defined(MULE)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
189 static int
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
190 separate_textual_runs_xft_mule (unsigned char *text_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
191 struct textual_run *run_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
192 const Ichar *str, Charcount len,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
193 struct face_cachel *UNUSED(cachel))
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
194 {
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
195 Lisp_Object prev_charset = Qunbound;
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
196 int runs_so_far = 0, i;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
197
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
198 run_storage[0].ptr = text_storage;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
199 run_storage[0].len = len;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
200 run_storage[0].dimension = 2;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
201 run_storage[0].charset = Qnil;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
202
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
203 for (i = 0; i < len; i++)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
204 {
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
205 Ichar ch = str[i];
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
206 Lisp_Object charset = ichar_charset(ch);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
207 int ucs = ichar_to_unicode(ch);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
208
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
209 /* If UCS is less than zero or greater than 0xFFFF, set ucs2 to
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
210 REPLACMENT CHARACTER. */
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
211 /* That means we can't handle characters outside of the BMP for now */
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
212 ucs = (ucs & ~0xFFFF) ? 0xFFFD : ucs;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
213
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
214 if (!EQ (charset, prev_charset))
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
215 {
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
216 if (runs_so_far)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
217 run_storage[runs_so_far-1].len = (text_storage - run_storage[runs_so_far-1].ptr) >> 1;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
218 run_storage[runs_so_far].ptr = text_storage;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
219 run_storage[runs_so_far].dimension = 2;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
220 run_storage[runs_so_far].charset = charset;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
221 prev_charset = charset;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
222 runs_so_far++;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
223 }
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
224
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
225 *(XftChar16 *)text_storage = ucs;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
226 text_storage += sizeof(XftChar16);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
227 }
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
228
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
229 if (runs_so_far)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
230 run_storage[runs_so_far-1].len = (text_storage - run_storage[runs_so_far-1].ptr) >> 1;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
231 return runs_so_far;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
232 }
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
233 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
234
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
235 #if !defined(USE_XFT) && defined(MULE)
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
236 /*
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
237 This is the most complex function of this group, due to the various
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
238 indexing schemes used by different fonts. For our purposes, they
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
239 fall into three classes. Some fonts are indexed compatibly with ISO
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
240 2022; those fonts just use the Mule internal representation directly
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
241 (typically the high bit must be reset; this is determined by the `graphic'
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
242 flag). Some fonts are indexed by Unicode, specifically by UCS-2. These
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
243 are all translated using `ichar_to_unicode'. Finally some fonts have
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
244 irregular indexes, and must be translated ad hoc. In XEmacs ad hoc
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
245 translations are accomplished with CCL programs. */
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
246 static int
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
247 separate_textual_runs_mule (unsigned char *text_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
248 struct textual_run *run_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
249 const Ichar *str, Charcount len,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
250 struct face_cachel *cachel)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 {
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
252 Lisp_Object prev_charset = Qunbound;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
253 int runs_so_far = 0, i;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
254 Ibyte charset_leading_byte = LEADING_BYTE_ASCII;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
255 int dimension = 1, graphic = 0, need_ccl_conversion = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
256 Lisp_Object ccl_prog;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 struct ccl_program char_converter;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
258
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
259 int translate_to_ucs_2 = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 for (i = 0; i < len; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
263 Ichar ch = str[i];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 Lisp_Object charset;
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
265 int byte1, byte2; /* BREAKUP_ICHAR dereferences the addresses
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
266 of its arguments as pointer to int. */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
267 BREAKUP_ICHAR (ch, charset, byte1, byte2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 if (!EQ (charset, prev_charset))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 {
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
271 /* At this point, dimension' and `prev_charset' refer to just-
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
272 completed run. `runs_so_far' and `text_storage' refer to the
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
273 run about to start. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 if (runs_so_far)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 {
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
276 /* Update metadata for previous run. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 run_storage[runs_so_far - 1].len =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 text_storage - run_storage[runs_so_far - 1].ptr;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
279 if (2 == dimension) run_storage[runs_so_far - 1].len >>= 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
281
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
282 /* Compute metadata for current run.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
283 First, classify font.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
284 If the font is indexed by UCS-2, set `translate_to_ucs_2'.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
285 Else if the charset has a CCL program, set `need_ccl_conversion'.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
286 Else if the font is indexed by an ISO 2022 "graphic register",
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
287 set `graphic'.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
288 These flags are almost mutually exclusive, but we're sloppy
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
289 about resetting "shadowed" flags. So the flags must be checked
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
290 in the proper order in computing byte1 and byte2, below. */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
291 charset_leading_byte = XCHARSET_LEADING_BYTE(charset);
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
292 translate_to_ucs_2 =
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
293 bit_vector_bit (FACE_CACHEL_FONT_FINAL_STAGE (cachel),
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
294 charset_leading_byte - MIN_LEADING_BYTE);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
295 if (translate_to_ucs_2)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
296 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
297 dimension = 2;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
298 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
299 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
300 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
301 dimension = XCHARSET_DIMENSION (charset);
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
302
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
303 /* Check for CCL charset.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
304 If setup_ccl_program fails, we'll get a garbaged display.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
305 This should never happen, and even if it does, it should
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
306 be harmless (unless the X server has buggy handling of
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
307 characters undefined in the font). It may be marginally
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
308 more useful to users and debuggers than substituting a
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
309 fixed replacement character. */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
310 ccl_prog = XCHARSET_CCL_PROGRAM (charset);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
311 if ((!NILP (ccl_prog))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
312 && (setup_ccl_program (&char_converter, ccl_prog) >= 0))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
313 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
314 need_ccl_conversion = 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
315 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
316 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
317 {
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
318 /* The charset must have an ISO 2022-compatible font index.
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
319 There are 2 "registers" (what such fonts use as index).
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
320 GL (graphic == 0) has the high bit of each octet reset,
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
321 GR (graphic == 1) has it set. */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
322 graphic = XCHARSET_GRAPHIC (charset);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
323 need_ccl_conversion = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
324 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
325 }
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
326
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
327 /* Initialize metadata for current run. */
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
328 run_storage[runs_so_far].ptr = text_storage;
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
329 run_storage[runs_so_far].charset = charset;
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
330 run_storage[runs_so_far].dimension = dimension;
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
331
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
332 /* Update loop variables. */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
333 prev_charset = charset;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
334 runs_so_far++;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
335 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
336
3896
7bde3a686fda [xemacs-hg @ 2007-04-05 02:27:09 by stephent]
stephent
parents: 3895
diff changeset
337 /* Must check flags in this order. See comment above. */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
338 if (translate_to_ucs_2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 {
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
340 int ucs = ichar_to_unicode(ch);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
341 /* If UCS is less than zero or greater than 0xFFFF, set ucs2 to
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
342 REPLACMENT CHARACTER. */
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
343 ucs = (ucs & ~0xFFFF) ? 0xFFFD : ucs;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
344
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
345 byte1 = ucs >> 8;
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
346 byte2 = ucs;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 }
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
348 else if (need_ccl_conversion)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 {
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
350 char_converter.reg[0] = charset_leading_byte;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 char_converter.reg[1] = byte1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 char_converter.reg[2] = byte2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 byte1 = char_converter.reg[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 byte2 = char_converter.reg[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 }
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
357 else if (graphic == 0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
358 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
359 byte1 &= 0x7F;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
360 byte2 &= 0x7F;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
361 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
362 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
363 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
364 byte1 |= 0x80;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
365 byte2 |= 0x80;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
366 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
367
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
368 *text_storage++ = (unsigned char)byte1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
369
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
370 if (2 == dimension) *text_storage++ = (unsigned char)byte2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 if (runs_so_far)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 run_storage[runs_so_far - 1].len =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 text_storage - run_storage[runs_so_far - 1].ptr;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
377 /* Dimension retains the relevant value for the run before it. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
378 if (2 == dimension)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 run_storage[runs_so_far - 1].len >>= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 return runs_so_far;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 }
3895
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
384 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
385
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
386 static int
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
387 separate_textual_runs (unsigned char *text_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
388 struct textual_run *run_storage,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
389 const Ichar *str, Charcount len,
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
390 struct face_cachel *cachel)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
391 {
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
392 #if defined(USE_XFT) && defined(MULE)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
393 return separate_textual_runs_xft_mule(text_storage, run_storage, str, len, cachel);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
394 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
395 #if defined(USE_XFT) && !defined(MULE)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
396 return separate_textual_runs_xft_nomule(text_storage, run_storage, str, len, cachel);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
397 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
398 #if !defined(USE_XFT) && defined(MULE)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
399 return separate_textual_runs_mule(text_storage, run_storage, str, len, cachel);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
400 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
401 #if !defined(USE_XFT) && !defined(MULE)
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
402 return separate_textual_runs_nomule(text_storage, run_storage, str, len, cachel);
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
403 #endif
a3c2418313d5 [xemacs-hg @ 2007-04-05 02:09:06 by stephent]
stephent
parents: 3696
diff changeset
404 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 /****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 /* */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 /* X output routines */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 /* */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 /****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 static int
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
413 x_text_width_single_run (struct frame * USED_IF_XFT (f),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
414 struct face_cachel *cachel, struct textual_run *run)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
417 Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 if (!fi->proportional_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 return fi->width * run->len;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
420 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
421 else if (FONT_INSTANCE_X_XFTFONT(fi))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
422 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
423 static XGlyphInfo glyphinfo;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
424 struct device *d = XDEVICE (f->device);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
425 Display *dpy = DEVICE_X_DISPLAY (d);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
426
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
427 if (run->dimension == 2) {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
428 XftTextExtents16 (dpy,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
429 FONT_INSTANCE_X_XFTFONT(fi),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
430 (XftChar16 *) run->ptr, run->len, &glyphinfo);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
431 } else {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
432 XftTextExtents8 (dpy,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
433 FONT_INSTANCE_X_XFTFONT(fi),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
434 run->ptr, run->len, &glyphinfo);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
435 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
436
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
437 return glyphinfo.xOff;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
438 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
439 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
440 else if (FONT_INSTANCE_X_FONT (fi))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 if (run->dimension == 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 return XTextWidth16 (FONT_INSTANCE_X_FONT (fi),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (XChar2b *) run->ptr, run->len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 return XTextWidth (FONT_INSTANCE_X_FONT (fi),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (char *) run->ptr, run->len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
449 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
450 abort();
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
451 return 0; /* shut up GCC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 x_text_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
457 Given a string and a merged face, return the string's length in pixels
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
458 when displayed in the fonts associated with the face.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
461 /* #### Break me out into a separate header */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
462 int x_text_width (struct frame *f, struct face_cachel *cachel,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
463 const Ichar *str, Charcount len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
464 int
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
465 x_text_width (struct frame *f, struct face_cachel *cachel,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
466 const Ichar *str, Charcount len)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
468 /* !!#### Needs review */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 int width_so_far = 0;
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 826
diff changeset
470 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 struct textual_run *runs = alloca_array (struct textual_run, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 int nruns;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
475 nruns = separate_textual_runs (text_storage, runs, str, len,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
476 cachel);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 for (i = 0; i < nruns; i++)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
479 width_so_far += x_text_width_single_run (f, cachel, runs + i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 return width_so_far;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 x_divider_height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 Return the height of the horizontal divider. This is a function because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 divider_height is a device method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 #### If we add etched horizontal divider lines this will have to get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 smarter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 x_divider_height (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 x_eol_cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 Return the width of the end-of-line cursor. This is a function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 because eol_cursor_width is a device method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 x_eol_cursor_width (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 return EOL_CURSOR_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 /*****************************************************************************
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
512 x_window_output_begin
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 Perform any necessary initialization prior to an update.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
517 x_window_output_begin (struct window *UNUSED (w))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 /*****************************************************************************
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 x_window_output_end
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 Perform any necessary flushing of queues when an update has completed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
527 x_window_output_end (struct window *w)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
529 if (!(check_if_pending_expose_event (WINDOW_XDEVICE (w))))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
530 XFlush (DEVICE_X_DISPLAY (WINDOW_XDEVICE (w)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 x_output_display_block
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 Given a display line, a block number for that start line, output all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 runes between start and end in the specified display block.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 x_output_display_block (struct window *w, struct display_line *dl, int block,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 int start, int end, int start_pixpos, int cursor_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 int cursor_width, int cursor_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
544 #ifndef USE_XFT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 struct frame *f = XFRAME (w->frame);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
546 #endif
3479
2b84dd8eb906 [xemacs-hg @ 2006-06-27 22:59:37 by james]
james
parents: 3439
diff changeset
547 Ichar_dynarr *buf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 Lisp_Object window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 rune_dynarr *rba = db->runes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 struct rune *rb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 int elt = start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 face_index findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 int xpos, width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 MULE is not defined */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
560 window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 rb = Dynarr_atp (rba, start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 if (!rb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 /* Nothing to do so don't do anything. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 xpos = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 if (rb->type == RUNE_CHAR)
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
570 charset = ichar_charset (rb->object.chr.ch);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 if (end < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 end = Dynarr_length (rba);
3479
2b84dd8eb906 [xemacs-hg @ 2006-06-27 22:59:37 by james]
james
parents: 3439
diff changeset
574 buf = Dynarr_new (Ichar);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 while (elt < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 rb = Dynarr_atp (rba, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 if (rb->findex == findex && rb->type == RUNE_CHAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 && rb->object.chr.ch != '\n' && rb->cursor_type != CURSOR_ON
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
582 && EQ (charset, ichar_charset (rb->object.chr.ch)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 Dynarr_add (buf, rb->object.chr.ch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 width += rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 if (Dynarr_length (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 x_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 findex, 0, cursor_start, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 xpos = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 Dynarr_reset (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 if (rb->type == RUNE_CHAR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 xpos = rb->xpos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
605 charset = ichar_charset (rb->object.chr.ch);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 if (rb->cursor_type == CURSOR_ON)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 if (rb->object.chr.ch == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 x_output_eol_cursor (w, dl, xpos, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 Dynarr_add (buf, rb->object.chr.ch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 x_output_string (w, dl, buf, xpos, 0, start_pixpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 rb->width, findex, 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 cursor_start, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 Dynarr_reset (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 xpos += rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 else if (rb->object.chr.ch == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 /* Clear in case a cursor was formerly here. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
629 redisplay_clear_region (window, findex, xpos,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 DISPLAY_LINE_YPOS (dl),
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
631 rb->width,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 DISPLAY_LINE_HEIGHT (dl));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 if (rb->type == RUNE_BLANK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 x_output_blank (w, dl, rb, start_pixpos, cursor_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 /* #### Our flagging of when we need to redraw the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 modeline shadows sucks. Since RUNE_HLINE is only used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 by the modeline at the moment it is a good bet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 that if it gets redrawn then we should also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 redraw the shadows. This won't be true forever.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 We borrow the shadow_thickness_changed flag for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 w->shadow_thickness_changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 x_output_hline (w, dl, rb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 if (elt < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 rb = Dynarr_atp (rba, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 xpos = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 else if (rb->type == RUNE_DGLYPH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 Lisp_Object instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 struct display_box dbox;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 struct display_glyph_area dga;
819
6504113e7c2d [xemacs-hg @ 2002-04-25 18:03:23 by andyp]
andyp
parents: 800
diff changeset
668
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
819
6504113e7c2d [xemacs-hg @ 2002-04-25 18:03:23 by andyp]
andyp
parents: 800
diff changeset
670 rb->object.dglyph.yoffset, start_pixpos,
6504113e7c2d [xemacs-hg @ 2002-04-25 18:03:23 by andyp]
andyp
parents: 800
diff changeset
671 rb->width, &dbox, &dga);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
673 window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 instance = glyph_image_instance (rb->object.dglyph.glyph,
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
675 window, ERROR_ME_DEBUG_WARN, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 if (IMAGE_INSTANCEP (instance))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680 switch (XIMAGE_INSTANCE_TYPE (instance))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682 case IMAGE_MONO_PIXMAP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683 case IMAGE_COLOR_PIXMAP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 cursor_start, cursor_width,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
686 cursor_height, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
687 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
689 case IMAGE_WIDGET:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
690 if (EQ (XIMAGE_INSTANCE_WIDGET_TYPE (instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
691 Qlayout))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
692 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
693 redisplay_output_layout (window, instance, &dbox, &dga, findex,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
694 cursor_start, cursor_width,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
695 cursor_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
696 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
697 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
698 case IMAGE_SUBWINDOW:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
699 redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
700 cursor_start, cursor_width,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
701 cursor_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
702 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
704 case IMAGE_NOTHING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 /* nothing is as nothing does */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
708 case IMAGE_TEXT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 case IMAGE_POINTER:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
710 default:
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
711 ABORT ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
712 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
713 IMAGE_INSTANCE_OPTIMIZE_OUTPUT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
714 (XIMAGE_INSTANCE (instance)) = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
715 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 xpos += rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 else
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2367
diff changeset
721 ABORT ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 if (Dynarr_length (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 x_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 0, cursor_start, cursor_width, cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 if (dl->modeline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 && !EQ (Qzero, w->modeline_shadow_thickness)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
731 #ifndef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
732 /* This optimization doesn't work right with some Xft fonts, which
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
733 leave antialiasing turds at the boundary. I don't know if this
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
734 is an Xft bug or not, but I think it is. See x_output_string. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 && (f->clear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 || f->windows_structure_changed
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
737 || w->shadow_thickness_changed)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
738 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
739 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 bevel_modeline (w, dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 Dynarr_free (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 x_bevel_area
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 448
diff changeset
748 Draw shadows for the given area in the given face.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 x_bevel_area (struct window *w, face_index findex,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 int x, int y, int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 int shadow_thickness, int edges, enum edge_style style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 Pixel top_shadow_pixel, bottom_shadow_pixel, background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 Lisp_Object tmp_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 XColor tmp_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 GC top_shadow_gc, bottom_shadow_gc, background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 int use_pixmap = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 int flip_gcs = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 assert (shadow_thickness >=0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 /* First, get the GC's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 top_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 bottom_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 background_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 background_pixel, ef->core.background_pixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 gcv.background = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 mask = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 /* If we can't distinguish one of the shadows (the color is the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 background), it's better to use a pixmap to generate a dithered gray. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 if (top_shadow_pixel == background_pixel ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 bottom_shadow_pixel == background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 use_pixmap = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 if (use_pixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 if (DEVICE_X_GRAY_PIXMAP (d) == None)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 DEVICE_X_GRAY_PIXMAP (d) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 gray_width, gray_height, 1, 0, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 gcv.foreground = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 /* this is needed because the GC draws with a pixmap here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 gcv.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 (mask | GCStipple | GCFillStyle));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 bottom_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 flip_gcs = (bottom_shadow_pixel ==
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 gcv.foreground = top_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 gcv.foreground = bottom_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 bottom_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 if (use_pixmap && flip_gcs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 GC tmp_gc = bottom_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 bottom_shadow_gc = top_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 top_shadow_gc = tmp_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 gcv.foreground = background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 /* possibly revert the GC's This will give a depressed look to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 divider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 if (style == EDGE_ETCHED_IN || style == EDGE_BEVEL_IN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 GC temp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 temp = top_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 top_shadow_gc = bottom_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 bottom_shadow_gc = temp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 shadow_thickness /= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 x_output_shadows (f, x, y, width, height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 top_shadow_gc, bottom_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 background_gc, shadow_thickness, edges);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 x_output_shadows (f, x + shadow_thickness, y + shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 width - 2*shadow_thickness, height - 2*shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 bottom_shadow_gc, top_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 background_gc, shadow_thickness, edges);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 x_get_gc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 Given a number of parameters return a GC with those properties.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 static GC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 x_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, Lisp_Object bg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 Lisp_Object bg_pmap, Lisp_Object lwidth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 /* Make absolutely sure that we don't pick up a clipping region in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 the GC returned by this function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 gcv.clip_mask = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 gcv.clip_x_origin = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 gcv.clip_y_origin = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 gcv.fill_style = FillSolid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 mask = GCGraphicsExposures | GCClipMask | GCClipXOrigin | GCClipYOrigin;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 mask |= GCFillStyle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
893 if (!NILP (font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
894 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
895 /* Only set the font if it's a core font */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
896 /* the renderfont will be set elsewhere (not part of gc) */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
897 && !FONT_INSTANCE_X_XFTFONT (XFONT_INSTANCE (font))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
898 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
899 )
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 gcv.font = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))->fid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 mask |= GCFont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 /* evil kludge! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 if (!NILP (fg) && !COLOR_INSTANCEP (fg) && !INTP (fg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
908 /* #### I fixed one case where this was getting hit. It was a
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 bad macro expansion (compiler bug). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
910 stderr_out ("Help! x_get_gc got a bogus fg value! fg = ");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 debug_print (fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 fg = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 if (!NILP (fg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 if (COLOR_INSTANCEP (fg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 gcv.foreground = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (fg)).pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 gcv.foreground = XINT (fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 mask |= GCForeground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 if (!NILP (bg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 if (COLOR_INSTANCEP (bg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 gcv.background = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (bg)).pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 gcv.background = XINT (bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 mask |= GCBackground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 /* This special case comes from a request to draw text with a face which has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 the dim property. We'll use a stippled foreground GC. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 if (EQ (bg_pmap, Qdim))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 assert (DEVICE_X_GRAY_PIXMAP (d) != None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 gcv.fill_style = FillStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 mask |= (GCFillStyle | GCStipple);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 else if (IMAGE_INSTANCEP (bg_pmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 gcv.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 gcv.stipple = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 mask |= (GCStipple | GCFillStyle);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 gcv.fill_style = FillTiled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 gcv.tile = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 mask |= (GCTile | GCFillStyle);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 if (!NILP (lwidth))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 gcv.line_width = XINT (lwidth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 mask |= GCLineWidth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
966 #if 0
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
967 debug_out ("\nx_get_gc: calling gc_cache_lookup\n");
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
968 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 return gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 x_output_string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 Given a string and a starting position, output that string in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 given face. If cursor is true, draw a cursor around the string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 Correctly handles multiple charsets in the string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 The meaning of the parameters is something like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 W Window that the text is to be displayed in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 DL Display line that this text is on. The values in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 structure are used to determine the vertical position and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 clipping range of the text.
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
985 BUF Dynamic array of Ichars specifying what is actually to be
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 drawn.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 XPOS X position in pixels where the text should start being drawn.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 XOFFSET Number of pixels to be chopped off the left side of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 text. The effect is as if the text were shifted to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 left this many pixels and clipped at XPOS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 CLIP_START Clip everything left of this X position.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 WIDTH Clip everything right of XPOS + WIDTH.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 FINDEX Index for the face cache element describing how to display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 the text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 CURSOR #### I don't understand this. There's something
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 strange and overcomplexified with this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 Chuck, explain please?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 CURSOR_START Starting X position of cursor.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 CURSOR_WIDTH Width of cursor in pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 CURSOR_HEIGHT Height of cursor in pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 Starting Y position of cursor is the top of the text line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 The cursor is drawn sometimes whether or not CURSOR is set. ???
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 x_output_string (struct window *w, struct display_line *dl,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1007 Ichar_dynarr *buf, int xpos, int xoffset, int clip_start,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 int width, face_index findex, int cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 int cursor_start, int cursor_width, int cursor_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 /* General variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 struct device *d = XDEVICE (f->device);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1014 Lisp_Object window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 int clip_end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 /* Cursor-related variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 int cursor_clip;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 WINDOW_BUFFER (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 struct face_cachel *cursor_cachel = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 /* Text-related variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 Lisp_Object bg_pmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 GC bgc, gc;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1030 int height = DISPLAY_LINE_HEIGHT (dl);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1031 int ypos = DISPLAY_LINE_YPOS (dl);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 int len = Dynarr_length (buf);
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 826
diff changeset
1033 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 struct textual_run *runs = alloca_array (struct textual_run, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 int nruns;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1039 int use_x_font = 1; /* #### bogus!!
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1040 The logic of this function needs review! */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1041 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1042 Colormap cmap = DEVICE_X_COLORMAP (d);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1043 Visual *visual = DEVICE_X_VISUAL (d);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1044 static XftColor fg, bg;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1045 XftDraw *xftDraw;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1046
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1047 /* Lazily initialize frame's xftDraw member. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1048 if (!FRAME_X_XFTDRAW (f)) {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1049 FRAME_X_XFTDRAW (f) = XftDrawCreate (dpy, x_win, visual, cmap);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1050 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1051 xftDraw = FRAME_X_XFTDRAW (f);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1052
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1053 /* #### This will probably cause asserts when passed a Lisp integer for a
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1054 color. See ca. line 759 this file.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1055 #### Maybe xft_convert_color should take an XColor, not a pixel. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1056 #define XFT_FROB_LISP_COLOR(color, dim) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1057 xft_convert_color (dpy, cmap, visual, \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1058 COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)).pixel, \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1059 (dim))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1060 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 if (width < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 width = x_text_width (f, cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 /* Regularize the variables passed in. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 if (clip_start < xpos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 clip_start = xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 clip_end = xpos + width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 if (clip_start >= clip_end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 /* It's all clipped out. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 xpos -= xoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 /* make sure the area we are about to display is subwindow free. */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1077 redisplay_unmap_subwindows_maybe (f, clip_start, ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1078 clip_end - clip_start, height);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 cursor_clip = (cursor_start >= clip_start &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 cursor_start < clip_end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 /* This cursor code is really a mess. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 if (!NILP (w->text_cursor_visible_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 && (cursor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 || cursor_clip
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 || (cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 && (cursor_start + cursor_width >= clip_start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 && !NILP (bar_cursor_value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 /* These have to be in separate statements in order to avoid a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 compiler bug. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 face_index sucks = get_builtin_face_cache_index (w, Vtext_cursor_face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 cursor_cachel = WINDOW_FACE_CACHEL (w, sucks);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 /* We have to reset this since any call to WINDOW_FACE_CACHEL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 may cause the cache to resize and any pointers to it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 become invalid. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 cachel = WINDOW_FACE_CACHEL (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 #ifdef HAVE_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 if (cursor && focus && (cursor_start == clip_start) && cursor_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 XIM_SetSpotLocation (f, xpos - 2, dl->ypos + dl->descent - 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 #endif /* HAVE_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 bg_pmap = cachel->background_pixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 if (!IMAGE_INSTANCEP (bg_pmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 bg_pmap = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 if ((cursor && focus && NILP (bar_cursor_value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 && !NILP (w->text_cursor_visible_p)) || NILP (bg_pmap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 bgc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 else
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1116 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1117 bgc = x_get_gc (d, Qnil, cachel->foreground, cachel->background,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1118 bg_pmap, Qnil);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1119 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 if (bgc)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1122 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1123 XFillRectangle (dpy, x_win, bgc, clip_start,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1124 ypos, clip_end - clip_start,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1125 height);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1126 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1127
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1128 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3479
diff changeset
1129 Dynarr_length (buf), cachel);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 for (i = 0; i < nruns; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1134 Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 int this_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 int need_clipping;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 if (EQ (font, Vthe_null_font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1141 this_width = x_text_width_single_run (f, cachel, runs + i);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 need_clipping = (dl->clip || clip_start > xpos ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 clip_end < xpos + this_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 /* XDrawImageString only clears the area equal to the height of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 the given font. It is possible that a font is being displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 on a line taller than it is, so this would cause us to fail to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 clear some areas. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 if ((int) fi->height < (int) (height + dl->clip + dl->top_clip))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 int clear_start = max (xpos, clip_start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 int clear_end = min (xpos + this_width, clip_end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 if (cursor)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 int ypos1_line, ypos1_string, ypos2_line, ypos2_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 ypos1_string = dl->ypos - fi->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 ypos2_string = dl->ypos + fi->descent;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1160 ypos1_line = ypos;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1161 ypos2_line = ypos1_line + height;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 /* Make sure we don't clear below the real bottom of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 if (ypos1_string > ypos2_line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 ypos1_string = ypos2_line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 if (ypos2_string > ypos2_line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 ypos2_string = ypos2_line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 if (ypos1_line < ypos1_string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 redisplay_clear_region (window, findex, clear_start, ypos1_line,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 clear_end - clear_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 ypos1_string - ypos1_line);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 if (ypos2_line > ypos2_string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 redisplay_clear_region (window, findex, clear_start, ypos2_string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 clear_end - clear_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 ypos2_line - ypos2_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 redisplay_clear_region (window, findex, clear_start,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1187 ypos, clear_end - clear_start,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 if (cursor && cursor_cachel && focus && NILP (bar_cursor_value))
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1193 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1194 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1195 fg = XFT_FROB_LISP_COLOR (cursor_cachel->foreground, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1196 bg = XFT_FROB_LISP_COLOR (cursor_cachel->background, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1197 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1198 gc = x_get_gc (d, font, cursor_cachel->foreground,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1199 cursor_cachel->background, Qnil, Qnil);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1200 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 else if (cachel->dim)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 /* Ensure the gray bitmap exists */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 if (DEVICE_X_GRAY_PIXMAP (d) == None)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 DEVICE_X_GRAY_PIXMAP (d) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 XCreateBitmapFromData (dpy, x_win, (char *)gray_bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 gray_width, gray_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 /* Request a GC with the gray stipple pixmap to draw dimmed text */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1210 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1211 fg = XFT_FROB_LISP_COLOR (cachel->foreground, 1);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1212 bg = XFT_FROB_LISP_COLOR (cachel->background, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1213 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 gc = x_get_gc (d, font, cachel->foreground, cachel->background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 Qdim, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 else
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1218 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1219 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1220 fg = XFT_FROB_LISP_COLOR (cachel->foreground, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1221 bg = XFT_FROB_LISP_COLOR (cachel->background, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1222 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1223 gc = x_get_gc (d, font, cachel->foreground, cachel->background,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1224 Qnil, Qnil);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1225 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1226 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1227 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1228 XftFont *rf = FONT_INSTANCE_X_XFTFONT (fi);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1230 if (rf)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1231 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1232 use_x_font = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1233 if (need_clipping)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1234 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1235 Region clip_reg = XCreateRegion();
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1236 XRectangle clip_box = { clip_start, ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1237 clip_end - clip_start, height };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1239 XUnionRectWithRegion (&clip_box, clip_reg, clip_reg);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1240 XftDrawSetClip(xftDraw, clip_reg);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1241 XDestroyRegion(clip_reg);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1242 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1244 if (!bgc)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1245 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1246 /* #### Neither rect_height nor XftTextExtents as computed
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1247 below handles the vertical space taken up by antialiasing,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1248 which for some fonts (eg, Bitstream Vera Sans Mono-16 on
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1249 my Mac PowerBook G4) leaves behind orphaned dots on
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1250 insertion or deletion earlier in the line, especially in
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1251 the case of the underscore character.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1252 Interestingly, insertion or deletion of a single character
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1253 immediately after a refresh does not leave any droppings,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1254 but any further insertions or deletions do.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1255 While adding a pixel to rect_height (mostly) takes care of
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1256 this, it trashes aggressively laid-out elements like the
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1257 modeline (overwriting part of the bevel).
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1258 OK, unconditionally redraw the bevel, and increment
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1259 rect_height by 1. See x_output_display_block. -- sjt */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1260 struct textual_run *run = &runs[i];
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1261 int rect_width = x_text_width_single_run (f, cachel, run);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1262 #ifndef USE_XFTTEXTENTS_TO_AVOID_FONT_DROPPINGS
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1263 int rect_height = FONT_INSTANCE_ASCENT(fi)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1264 + FONT_INSTANCE_DESCENT(fi) + 1;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1265 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1266 int rect_height = FONT_INSTANCE_ASCENT(fi)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1267 + FONT_INSTANCE_DESCENT(fi);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1268 XGlyphInfo gi;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1269 if (run->dimension == 2) {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1270 XftTextExtents16 (dpy,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1271 FONT_INSTANCE_X_XFTFONT(fi),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1272 (XftChar16 *) run->ptr, run->len, &gi);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1273 } else {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1274 XftTextExtents8 (dpy,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1275 FONT_INSTANCE_X_XFTFONT(fi),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1276 run->ptr, run->len, &gi);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1277 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1278 rect_height = rect_height > gi.height
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1279 ? rect_height : gi.height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1280 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1282 XftDrawRect (xftDraw, &bg,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1283 xpos, ypos, rect_width, rect_height);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1284 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1285
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1286 if (runs[i].dimension == 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1287 XftDrawString8 (xftDraw, &fg, rf, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1288 runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1289 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1290 XftDrawString16 (xftDraw, &fg, rf, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1291 (XftChar16 *) runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1292 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1293 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1294 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1295 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1296 if (use_x_font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1297 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1298 if (need_clipping)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1299 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1300 XRectangle clip_box[1];
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1301
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1302 clip_box[0].x = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1303 clip_box[0].y = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1304 clip_box[0].width = clip_end - clip_start;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1305 clip_box[0].height = height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1306
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1307 XSetClipRectangles (dpy, gc, clip_start, ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1308 clip_box, 1, YXBanded);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1309 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1310
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1311 if (runs[i].dimension == 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1312 (bgc ? XDrawString : XDrawImageString)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1313 (dpy, x_win, gc, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1314 (char *) runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1315 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1316 (bgc ? XDrawString16 : XDrawImageString16)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1317 (dpy, x_win, gc, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1318 (XChar2b *) runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1319 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1320 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 /* We draw underlines in the same color as the text. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 if (cachel->underline)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1325 int upos, uthick;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1326 unsigned long upos_ext, uthick_ext;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1327 XFontStruct *fs =
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1328 use_x_font ? FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)) : 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1329 /* #### the logic of the next two may be suboptimal: we may want
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1330 to use the POSITION and/or THICKNESS information with Xft */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1331 if (fs && XGetFontProperty (fs, XA_UNDERLINE_POSITION, &upos_ext))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1332 upos = (int) upos_ext;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1333 else
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1334 upos = dl->descent / 2;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1335 if (fs && XGetFontProperty (fs, XA_UNDERLINE_THICKNESS, &uthick_ext))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1336 uthick = (int) uthick_ext;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1337 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 uthick = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 if (dl->ypos + upos < dl->ypos + dl->descent - dl->clip)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 uthick = dl->descent - dl->clip - upos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 if (uthick == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 XDrawLine (dpy, x_win, gc, xpos, dl->ypos + upos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 xpos + this_width, dl->ypos + upos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 else if (uthick > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 XFillRectangle (dpy, x_win, gc, xpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 dl->ypos + upos, this_width, uthick);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1357 if (cachel->strikethru)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1358 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1359 int ascent, descent, upos, uthick;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1360 unsigned long ascent_ext, descent_ext, uthick_ext;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1361 XFontStruct *fs = FONT_INSTANCE_X_FONT (fi);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1362
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1363 if (!use_x_font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1364 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1365 ascent = dl->ascent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1366 descent = dl->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1367 uthick = 1;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1368 }
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1369 else
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1370 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1371 if (!XGetFontProperty (fs, XA_STRIKEOUT_ASCENT, &ascent_ext))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1372 ascent = fs->ascent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1373 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1374 ascent = (int) ascent_ext;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1375 if (!XGetFontProperty (fs, XA_STRIKEOUT_DESCENT, &descent_ext))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1376 descent = fs->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1377 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1378 descent = (int) descent_ext;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1379 if (!XGetFontProperty (fs, XA_UNDERLINE_THICKNESS, &uthick_ext))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1380 uthick = 1;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1381 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1382 uthick = (int) uthick_ext;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1383 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1385 upos = ascent - ((ascent + descent) / 2) + 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1387 /* Generally, upos will be positive (above the baseline),so
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1388 subtract */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1389 if (dl->ypos - upos < dl->ypos + dl->descent - dl->clip)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1390 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1391 if (dl->ypos - upos + uthick > dl->ypos + dl->descent - dl->clip)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1392 uthick = dl->descent - dl->clip + upos;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1393
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1394 if (uthick == 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 XDrawLine (dpy, x_win, gc, xpos, dl->ypos - upos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 xpos + this_width, dl->ypos - upos);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1397 else if (uthick > 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 XFillRectangle (dpy, x_win, gc, xpos, dl->ypos + upos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 this_width, uthick);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1400 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1401 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 /* Restore the GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 if (need_clipping)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1406 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1407 if (!use_x_font)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1408 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1409 XftDrawSetClip(xftDraw, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1410 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1411 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1412 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1413 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1414 XSetClipMask (dpy, gc, None);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1415 XSetClipOrigin (dpy, gc, 0, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1416 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1417 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1418 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 /* If we are actually superimposing the cursor then redraw with just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 the appropriate section highlighted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 if (cursor_clip && !cursor && focus && cursor_cachel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1425 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1426 if (!use_x_font) /* Xft */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1427 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1428 XftFont *rf = FONT_INSTANCE_X_XFTFONT (fi);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1429
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1430 { /* set up clipping */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1431 Region clip_reg = XCreateRegion();
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1432 XRectangle clip_box = { cursor_start, ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1433 cursor_width, height };
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1434
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1435 XUnionRectWithRegion (&clip_box, clip_reg, clip_reg);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1436 XftDrawSetClip(xftDraw, clip_reg);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1437 XDestroyRegion(clip_reg);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1438 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1439 { /* draw background rectangle & draw text */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1440 int rect_height = FONT_INSTANCE_ASCENT(fi)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1441 + FONT_INSTANCE_DESCENT(fi);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1442 int rect_width = x_text_width_single_run(f, cachel, &runs[i]);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1443 XftColor xft_color;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1445 xft_color = XFT_FROB_LISP_COLOR (cursor_cachel->background, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1446 XftDrawRect (xftDraw, &xft_color,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1447 xpos, ypos, rect_width, rect_height);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1449 xft_color = XFT_FROB_LISP_COLOR (cursor_cachel->foreground, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1450 if (runs[i].dimension == 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1451 XftDrawString8 (xftDraw, &xft_color, rf, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1452 runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1453 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1454 XftDrawString16 (xftDraw, &xft_color, rf, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1455 (XftChar16 *) runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1456 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1457
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1458 XftDrawSetClip(xftDraw, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1459 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1460 else /* core font, not Xft */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1461 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1462 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1463 GC cgc;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1464 XRectangle clip_box[1];
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1465
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1466 cgc = x_get_gc (d, font, cursor_cachel->foreground,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1467 cursor_cachel->background, Qnil, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1469 clip_box[0].x = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1470 clip_box[0].y = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1471 clip_box[0].width = cursor_width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1472 clip_box[0].height = height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1473
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1474 XSetClipRectangles (dpy, cgc, cursor_start, ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1475 clip_box, 1, YXBanded);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1476 if (runs[i].dimension == 1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1477 XDrawImageString (dpy, x_win, cgc, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1478 (char *) runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1479 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1480 XDrawImageString16 (dpy, x_win, cgc, xpos, dl->ypos,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1481 (XChar2b *) runs[i].ptr, runs[i].len);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1482
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1483 XSetClipMask (dpy, cgc, None);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1484 XSetClipOrigin (dpy, cgc, 0, 0);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1485 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1486 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1487 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 xpos += this_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 /* Draw the non-focus box or bar-cursor as needed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 /* Can't this logic be simplified? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 if (cursor_cachel
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 && ((cursor && !focus && NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 || (cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 && (cursor_start + cursor_width >= clip_start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 && !NILP (bar_cursor_value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 int tmp_height, tmp_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 int need_clipping = (cursor_start < clip_start
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 || clip_end < cursor_start + cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 /* #### This value is correct (as far as I know) because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 all of the times we need to draw this cursor, we will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 be called with exactly one character, so we know we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 can always use runs[0].
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 This is bogus as all hell, however. The cursor handling in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 this function is way bogus and desperately needs to be
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1513 cleaned up. (In particular, the drawing of the cursor should
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 really really be separated out of this function. This may be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 a bit tricky now because this function itself does way too
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 much stuff, a lot of which needs to be moved into
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1517 redisplay.c.) This is the only way to be able to easily add
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 new cursor types or (e.g.) make the bar cursor be able to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 span two characters instead of overlaying just one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 int bogusly_obtained_ascent_value =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 XFONT_INSTANCE (FACE_CACHEL_FONT (cachel, runs[0].charset))->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 if (!NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 make_int (bar_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 gc = x_get_gc (d, Qnil, cursor_cachel->background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 tmp_y = dl->ypos - bogusly_obtained_ascent_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 tmp_height = cursor_height;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1536 if (tmp_y + tmp_height > (int) (ypos + height))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1538 tmp_y = ypos + height - tmp_height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1539 if (tmp_y < (int) ypos)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1540 tmp_y = ypos;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1541 tmp_height = ypos + height - tmp_y;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 if (need_clipping)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 XRectangle clip_box[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 clip_box[0].x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 clip_box[0].y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 clip_box[0].width = clip_end - clip_start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 clip_box[0].height = tmp_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 XSetClipRectangles (dpy, gc, clip_start, tmp_y,
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1552 /* #### why not Unsorted? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1553 clip_box, 1, YXBanded);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 if (!focus && NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 XDrawRectangle (dpy, x_win, gc, cursor_start, tmp_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 cursor_width - 1, tmp_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 else if (focus && !NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 XDrawLine (dpy, x_win, gc, cursor_start + bar_width - 1, tmp_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 cursor_start + bar_width - 1, tmp_y + tmp_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 /* Restore the GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 if (need_clipping)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 XSetClipMask (dpy, gc, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 XSetClipOrigin (dpy, gc, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1574
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1575 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1576 #undef XFT_FROB_LISP_COLOR
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1577 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
1578
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1582 x_output_x_pixmap (struct frame *f, Lisp_Image_Instance *p, int x,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 int y, int xoffset, int yoffset,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1584 int width, int height, unsigned long fg, unsigned long bg,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 GC override_gc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 unsigned long pixmap_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 if (!override_gc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 gcv.foreground = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 gcv.background = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 pixmap_mask = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 if (IMAGE_INSTANCE_X_MASK (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 gcv.function = GXcopy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 gcv.clip_mask = IMAGE_INSTANCE_X_MASK (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 gcv.clip_x_origin = x - xoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 gcv.clip_y_origin = y - yoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 pixmap_mask |= (GCFunction | GCClipMask | GCClipXOrigin |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 GCClipYOrigin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 /* Can't set a clip rectangle because we already have a mask.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 Is it possible to get an equivalent effect by changing the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 args to XCopyArea below rather than messing with a clip box?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 - dkindred@cs.cmu.edu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 Yes. We don't clip at all now - andy@xemacs.org
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, pixmap_mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 gc = override_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624 /* override_gc might have a mask already--we don't want to nuke it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 Maybe we can insist that override_gc have no mask, or use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 one of the suggestions above. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 /* depth of 0 means it's a bitmap, not a pixmap, and we should use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 XCopyPlane (1 = current foreground color, 0 = background) instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 of XCopyArea, which means that the bits in the pixmap are actual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 pixel values, instead of symbolic of fg/bg. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 if (IMAGE_INSTANCE_PIXMAP_DEPTH (p) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1635 XCopyArea (dpy,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1636 IMAGE_INSTANCE_X_PIXMAP_SLICE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 yoffset, width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 height, x, y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1643 XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 xoffset, yoffset, width, height, x, y, 1L);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 x_output_pixmap (struct window *w, Lisp_Object image_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 struct display_box *db, struct display_glyph_area *dga,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 face_index findex, int cursor_start, int cursor_width,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
1653 int cursor_height, int UNUSED (bg_pixmap))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 struct device *d = XDEVICE (f->device);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1657 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1661
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 /* Output the pixmap. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 Lisp_Object tmp_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 XColor tmp_bcolor, tmp_fcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 tmp_bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 x_output_x_pixmap (f, p, db->xpos, db->ypos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 dga->xoffset, dga->yoffset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 dga->width, dga->height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 tmp_fcolor.pixel, tmp_bcolor.pixel, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 /* Draw a cursor over top of the pixmap. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 if (cursor_width && cursor_height && (cursor_start >= db->xpos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 && !NILP (w->text_cursor_visible_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 && (cursor_start < db->xpos + dga->width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 struct face_cachel *cursor_cachel =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 WINDOW_FACE_CACHEL (w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 get_builtin_face_cache_index
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 (w, Vtext_cursor_face));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 if (cursor_width > db->xpos + dga->width - cursor_start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 cursor_width = db->xpos + dga->width - cursor_start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 if (focus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 XFillRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 XDrawRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 x_output_vertical_divider
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 Draw a vertical divider down the right side of the given window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 x_output_vertical_divider (struct window *w, int clear)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 Lisp_Object tmp_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 XColor tmp_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 GC background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 enum edge_style style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 int x, y1, y2, width, shadow_thickness, spacing, line_width;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1729 face_index div_face =
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1730 get_builtin_face_cache_index (w, Vvertical_divider_face);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 width = window_divider_width (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 shadow_thickness = XINT (w->vertical_divider_shadow_thickness);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 spacing = XINT (w->vertical_divider_spacing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 line_width = XINT (w->vertical_divider_line_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 x = WINDOW_RIGHT (w) - width;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1737 y1 = WINDOW_TOP (w);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1738 y2 = WINDOW_BOTTOM (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 /* First, get the GC's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 gcv.background = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 gcv.foreground = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 mask = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 /* Clear the divider area first. This needs to be done when a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 window split occurs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 if (clear)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 XClearArea (dpy, x_win, x, y1, width, y2 - y1, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 /* Draw the divider line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 XFillRectangle (dpy, x_win, background_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 x + spacing + shadow_thickness, y1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 line_width, y2 - y1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 if (shadow_thickness < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 shadow_thickness = -shadow_thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 style = EDGE_BEVEL_IN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 style = EDGE_BEVEL_OUT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 x_bevel_area (w, div_face, x + spacing, y1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 width - 2 * spacing, y2 - y1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 shadow_thickness, EDGE_ALL, style);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 x_output_blank
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 Output a blank by clearing the area it covers in the foreground color
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 of its face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 x_output_blank (struct window *w, struct display_line *dl, struct rune *rb,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 int start_pixpos, int cursor_start, int cursor_width)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 struct face_cachel *cursor_cachel =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 WINDOW_FACE_CACHEL (w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 get_builtin_face_cache_index
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 (w, Vtext_cursor_face));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 Lisp_Object bg_pmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 Lisp_Object buffer = WINDOW_BUFFER (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 int x = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 int y = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 int width = rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 int height = DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 /* Unmap all subwindows in the area we are going to blank. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 redisplay_unmap_subwindows_maybe (f, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 if (start_pixpos > x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 if (start_pixpos >= (x + width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 width -= (start_pixpos - x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 x = start_pixpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 if (!IMAGE_INSTANCEP (bg_pmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 bg_pmap = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 if (NILP (bg_pmap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex), bg_pmap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833 Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 XFillRectangle (dpy, x_win, gc, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 /* If this rune is marked as having the cursor, then it is actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 representing a tab. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 if (!NILP (w->text_cursor_visible_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 && (rb->cursor_type == CURSOR_ON
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 || (cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 && (cursor_start + cursor_width > x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 && cursor_start < (x + width))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 int cursor_height, cursor_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1847 Lisp_Font_Instance *fi;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 fi = XFONT_INSTANCE (FACE_CACHEL_FONT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 (WINDOW_FACE_CACHEL (w, rb->findex),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 Vcharset_ascii));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 cursor_y = dl->ypos - fi->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 cursor_height = fi->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 if (cursor_y + cursor_height > y + height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 cursor_height = y + height - cursor_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 if (focus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 if (NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 XFillRectangle (dpy, x_win, gc, cursor_start, cursor_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 fi->width, cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 make_int (bar_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 XDrawLine (dpy, x_win, gc, cursor_start + bar_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 cursor_y, cursor_start + bar_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 cursor_y + cursor_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 else if (NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 XDrawRectangle (dpy, x_win, gc, cursor_start, cursor_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 fi->width - 1, cursor_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 x_output_hline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 Output a horizontal line in the foreground of its face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 x_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 int x = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 int width = rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 int height = DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 int ypos1, ypos2, ypos3, ypos4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 ypos1 = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 ypos2 = ypos1 + rb->object.hline.yoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 ypos3 = ypos2 + rb->object.hline.thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 ypos4 = dl->ypos + dl->descent - dl->clip;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 /* First clear the area not covered by the line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 if (height - rb->object.hline.thickness > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_FOREGROUND (w, rb->findex),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 if (ypos2 - ypos1 > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 XFillRectangle (dpy, x_win, gc, x, ypos1, width, ypos2 - ypos1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 if (ypos4 - ypos3 > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 XFillRectangle (dpy, x_win, gc, x, ypos1, width, ypos2 - ypos1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 /* Now draw the line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 gc = x_get_gc (d, Qnil, WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 if (ypos2 < ypos1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 ypos2 = ypos1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 if (ypos3 > ypos4)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 ypos3 = ypos4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 if (ypos3 - ypos2 > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 XFillRectangle (dpy, x_win, gc, x, ypos2, width, ypos3 - ypos2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 x_output_shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 Draw a shadow around the given area using the given GC's. It is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 callers responsibility to set the GC's appropriately.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 x_output_shadows (struct frame *f, int x, int y, int width, int height,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
1944 GC top_shadow_gc, GC bottom_shadow_gc,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
1945 GC UNUSED (background_gc), int shadow_thickness, int edges)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1950 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 XSegment top_shadow[20], bottom_shadow[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 int elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 if (shadow_thickness > 10)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 shadow_thickness = 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 else if (shadow_thickness < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 shadow_thickness = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 if (shadow_thickness > (width / 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 shadow_thickness = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 if (shadow_thickness > (height / 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 shadow_thickness = height / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 for (elt = 0; elt < shadow_thickness; elt++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 int seg1 = elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 int seg2 = (edges & EDGE_TOP) ? elt + shadow_thickness : elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 int bot_seg2 = (edges & EDGE_BOTTOM) ? elt + shadow_thickness : elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 if (edges & EDGE_TOP)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972 top_shadow[seg1].x1 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973 top_shadow[seg1].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 top_shadow[seg1].y1 = top_shadow[seg1].y2 = y + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 if (edges & EDGE_LEFT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 top_shadow[seg2].x1 = top_shadow[seg2].x2 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 top_shadow[seg2].y1 = y + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 top_shadow[seg2].y2 = y + height - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 if (edges & EDGE_BOTTOM)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 bottom_shadow[seg1].x1 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 bottom_shadow[seg1].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 bottom_shadow[seg1].y1 = bottom_shadow[seg1].y2 = y + height - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 if (edges & EDGE_RIGHT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 bottom_shadow[bot_seg2].x1 = bottom_shadow[bot_seg2].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 bottom_shadow[bot_seg2].y1 = y + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 bottom_shadow[bot_seg2].y2 = y + height - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 XDrawSegments (dpy, x_win, top_shadow_gc, top_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 ((edges & EDGE_TOP) ? shadow_thickness : 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 + ((edges & EDGE_LEFT) ? shadow_thickness : 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999 XDrawSegments (dpy, x_win, bottom_shadow_gc, bottom_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 ((edges & EDGE_BOTTOM) ? shadow_thickness : 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 + ((edges & EDGE_RIGHT) ? shadow_thickness : 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2003
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 x_generate_shadow_pixels
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 Given three pixels (top shadow, bottom shadow, background) massage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 the top and bottom shadow colors to guarantee that they differ. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 background pixels are not allowed to be modified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 This function modifies its parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 This code is modified from code blatantly stolen from lwlib/xlwmenu.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 ? ((unsigned long) (x)) : ((unsigned long) (y)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 x_generate_shadow_pixels (struct frame *f, unsigned long *top_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020 unsigned long *bottom_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 unsigned long background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 unsigned long core_background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 Colormap cmap = DEVICE_X_COLORMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 Visual *visual = DEVICE_X_VISUAL (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 XColor topc, botc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 int top_frobbed = 0, bottom_frobbed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 /* If the top shadow is the same color as the background, try to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 adjust it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 if (*top_shadow == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 topc.pixel = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 XQueryColor (dpy, cmap, &topc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 /* don't overflow/wrap! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 topc.red = MINL (65535, (unsigned long) topc.red * 6 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 topc.green = MINL (65535, (unsigned long) topc.green * 6 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 topc.blue = MINL (65535, (unsigned long) topc.blue * 6 / 5);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
2042 if (x_allocate_nearest_color (dpy, cmap, visual, &topc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 *top_shadow = topc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 top_frobbed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 /* If the bottom shadow is the same color as the background, try to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 adjust it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 if (*bottom_shadow == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 botc.pixel = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 XQueryColor (dpy, cmap, &botc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 botc.red = (unsigned short) ((unsigned long) botc.red * 3 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 botc.green = (unsigned short) ((unsigned long) botc.green * 3 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 botc.blue = (unsigned short) ((unsigned long) botc.blue * 3 / 5);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2500
diff changeset
2058 if (x_allocate_nearest_color (dpy, cmap, visual, &botc))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 *bottom_shadow = botc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061 bottom_frobbed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 /* If we had to adjust both shadows, then we have to do some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 additional work. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 if (top_frobbed && bottom_frobbed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 if (bot_avg > top_avg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 Pixel tmp = *top_shadow;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 *top_shadow = *bottom_shadow;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 *bottom_shadow = tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 else if (topc.pixel == botc.pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 if (botc.pixel == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 *top_shadow = core_background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 *bottom_shadow = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 /****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 x_clear_region
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 Clear the area in the box defined by the given parameters using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 given face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
2095 x_clear_region (Lisp_Object UNUSED (locale), struct device* d,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2232
diff changeset
2096 struct frame* f, face_index UNUSED (findex),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 int x, int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 Lisp_Object background_pixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 Display *dpy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 Window x_win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 GC gc = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 if (!UNBOUNDP (background_pixmap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 gc = x_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 if (gc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 XFillRectangle (dpy, x_win, gc, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 XClearArea (dpy, x_win, x, y, width, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2119 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120 x_output_eol_cursor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 Draw a cursor at the end of a line. The end-of-line cursor is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 narrower than the normal cursor.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 x_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 face_index findex)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 Lisp_Object window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 face_index elt = get_builtin_face_cache_index (w, Vtext_cursor_face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2137 struct face_cachel *cursor_cachel = WINDOW_FACE_CACHEL (w, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 WINDOW_BUFFER (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 int x = xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 int y = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145 int width = EOL_CURSOR_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2146 int height = DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 int cursor_height, cursor_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 int defheight, defascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
2150 window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 redisplay_clear_region (window, findex, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 if (NILP (w->text_cursor_visible_p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158 default_face_font_info (window, &defascent, 0, &defheight, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2160 /* make sure the cursor is entirely contained between y and y+height */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2161 cursor_height = min (defheight, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 cursor_y = max (y, min (y + height - cursor_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2163 dl->ypos - defascent));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 if (focus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 #ifdef HAVE_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2168 XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 #endif /* HAVE_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2171 if (NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173 XFillRectangle (dpy, x_win, gc, x, cursor_y, width, cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2175 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2179 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2180 make_int (bar_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181 XDrawLine (dpy, x_win, gc, x + bar_width - 1, cursor_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2182 x + bar_width - 1, cursor_y + cursor_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185 else if (NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 XDrawRectangle (dpy, x_win, gc, x, cursor_y, width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 cursor_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 x_clear_frame_window (Lisp_Object window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 struct window *w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197 if (!NILP (w->vchild))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 x_clear_frame_windows (w->vchild);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 if (!NILP (w->hchild))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205 x_clear_frame_windows (w->hchild);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
2209 redisplay_clear_to_window_end (w, WINDOW_TEXT_TOP (w),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 WINDOW_TEXT_BOTTOM (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 x_clear_frame_windows (Lisp_Object window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2216 for (; !NILP (window); window = XWINDOW (window)->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217 x_clear_frame_window (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2220 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 x_clear_frame (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226 int x, y, width, height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 x = FRAME_LEFT_BORDER_START (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 width = (FRAME_PIXWIDTH (f) - FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 /* #### This adjustment by 1 should be being done in the macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 There is some small differences between when the menubar is on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 and off that we still need to deal with. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2237 y = FRAME_TOP_BORDER_START (f) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2238 height = (FRAME_PIXHEIGHT (f) - FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f)) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 XClearArea (dpy, x_win, x, y, width, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
2245 frame = wrap_frame (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 if (!UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vdefault_face, frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vleft_margin_face, frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vright_margin_face, frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2250 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2251 x_clear_frame_windows (f->root_window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
2254 if (!(check_if_pending_expose_event (d)))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
2255 XFlush (DEVICE_X_DISPLAY (d));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 /* briefly swap the foreground and background colors.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 x_flash (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2264 Display *dpy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 Window win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268 XColor tmp_fcolor, tmp_bcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 Lisp_Object tmp_pixel, frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270 struct frame *f = device_selected_frame (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 Widget shell = FRAME_X_SHELL_WIDGET (f);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2273 int flash_height;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
2275 frame = wrap_frame (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2279 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280 tmp_bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 dpy = XtDisplay (shell);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 memset (&gcv, ~0, sizeof (XGCValues)); /* initialize all slots to ~0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 gcv.foreground = (tmp_fcolor.pixel ^ tmp_bcolor.pixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 gcv.function = GXxor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (XDEVICE (f->device)), &gcv,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 (GCForeground | GCFunction | GCGraphicsExposures));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2290 default_face_height_and_width (frame, &flash_height, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2291
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2292 /* If window is tall, flash top and bottom line. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2293 if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2294 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2295 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2296 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2297 XFillRectangle (dpy, win, gc, w->pixel_left,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2298 w->pixel_top + w->pixel_height - flash_height,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2299 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2300 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2301 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2302 /* If it is short, flash it all. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2303 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2304 w->pixel_width, w->pixel_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2305
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 XSync (dpy, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 #ifdef HAVE_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310 int usecs = 100000;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311 struct timeval tv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 tv.tv_sec = usecs / 1000000L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313 tv.tv_usec = usecs % 1000000L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314 /* I'm sure someone is going to complain about this... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 select (0, 0, 0, 0, &tv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2317 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2318 #ifdef HAVE_POLL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 poll (0, 0, 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 #else /* !HAVE_POLL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 bite me
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322 #endif /* HAVE_POLL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2323 #endif /* HAVE_SELECT */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2325 /* If window is tall, flash top and bottom line. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2326 if (EQ (Vvisible_bell, Qtop_bottom) && w->pixel_height > 3 * flash_height)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2327 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2328 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2329 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2330 XFillRectangle (dpy, win, gc, w->pixel_left,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2331 w->pixel_top + w->pixel_height - flash_height,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2332 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2333 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2334 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2335 /* If it is short, flash it all. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2336 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2337 w->pixel_width, w->pixel_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2338
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2339 XSync (dpy, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2341 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2342 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2344 /* Make audible bell. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2347 x_ring_bell (struct device *d, int volume, int pitch, int duration)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349 Display *display = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2351 if (volume < 0) volume = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2352 else if (volume > 100) volume = 100;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 if (pitch < 0 && duration < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 XBell (display, (volume * 2) - 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2356 XFlush (display);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2358 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2359 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2360 XKeyboardState state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2361 XKeyboardControl ctl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362 XSync (display, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 /* #### grab server? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2364 XGetKeyboardControl (display, &state);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365
664
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 647
diff changeset
2366 ctl.bell_pitch = (pitch >= 0 ? pitch : (int) state.bell_pitch);
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 647
diff changeset
2367 ctl.bell_duration = (duration >= 0 ? duration : (int) state.bell_duration);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370 XBell (display, (volume * 2) - 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 ctl.bell_pitch = state.bell_pitch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2373 ctl.bell_duration = state.bell_duration;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376 /* #### ungrab server? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 XSync (display, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2387 console_type_create_redisplay_x (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2388 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389 /* redisplay methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 CONSOLE_HAS_METHOD (x, text_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391 CONSOLE_HAS_METHOD (x, output_display_block);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 CONSOLE_HAS_METHOD (x, divider_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 CONSOLE_HAS_METHOD (x, eol_cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2394 CONSOLE_HAS_METHOD (x, output_vertical_divider);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395 CONSOLE_HAS_METHOD (x, clear_region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 CONSOLE_HAS_METHOD (x, clear_frame);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2397 CONSOLE_HAS_METHOD (x, window_output_begin);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2398 CONSOLE_HAS_METHOD (x, window_output_end);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 CONSOLE_HAS_METHOD (x, flash);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400 CONSOLE_HAS_METHOD (x, ring_bell);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401 CONSOLE_HAS_METHOD (x, bevel_area);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 CONSOLE_HAS_METHOD (x, output_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 CONSOLE_HAS_METHOD (x, output_pixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404 }