annotate src/redisplay-x.c @ 1309:00abb1091204

[xemacs-hg @ 2003-02-17 14:50:55 by stephent] charsets-in-region optimization <874r73qa2b.fsf@tleepslib.sk.tsukuba.ac.jp> wid-edit.el synch <87znovote9.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Mon, 17 Feb 2003 14:51:02 +0000
parents e22b0213b713
children b531bf8658e9
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.
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
5 Copyright (C) 2002 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 #ifdef MULE
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
45 #include "mule-ccl.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
46 #endif
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
47
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
48 #include "console-x-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
49 #include "glyphs-x.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
50 #include "objects-x-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
51 #include "xgccache.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
52
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
53 #include "EmacsFrame.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
54 #include "EmacsFrameP.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 #include "sysproc.h" /* for select() */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
58 #include <X11/bitmaps/gray>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 /* Number of pixels below each line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 int x_interline_space; /* #### implement me */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #define EOL_CURSOR_WIDTH 5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 static void x_output_vertical_divider (struct window *w, int clear);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 static void x_output_blank (struct window *w, struct display_line *dl,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 struct rune *rb, int start_pixpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 int cursor_start, int cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 static void x_output_hline (struct window *w, struct display_line *dl,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 struct rune *rb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 static void x_redraw_exposed_window (struct window *w, int x, int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 int width, int height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 static void x_redraw_exposed_windows (Lisp_Object window, int x, int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 int width, int height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 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
76 int xpos, face_index findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 static void x_clear_frame (struct frame *f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 static void x_clear_frame_windows (Lisp_Object window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 /* Note: We do not use the Xmb*() functions and XFontSets.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 Those functions are generally losing for a number of reasons:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 1) They only support one locale (e.g. you could display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 Japanese and ASCII text, but not mixed Japanese/Chinese
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 text). You could maybe call setlocale() frequently
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 to try to deal with this, but that would generally
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 fail because an XFontSet is tied to one locale and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 won't have the other character sets in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 2) Not all (or even very many) OS's support the useful
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 locales. For example, as far as I know SunOS and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 Solaris only support the Japanese locale if you get the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 special Asian-language version of the OS. Yuck yuck
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 yuck. Linux doesn't support the Japanese locale at
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 all.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 3) The locale support in X only exists in R5, not in R4.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (Not sure how big of a problem this is: how many
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 people are using R4?)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 4) Who knows if the multi-byte text format (which is locale-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 specific) is even the same for the same locale on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 different OS's? It's not even documented anywhere that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 I can find what the multi-byte text format for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 Japanese locale under SunOS and Solaris is, but I assume
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 it's EUC.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 struct textual_run
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 Lisp_Object charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 unsigned char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 int dimension;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 /* 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
116 particular charset. Also convert the characters as necessary into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 the format needed by XDrawImageString(), XDrawImageString16(), et
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 al. (This means converting to one or two byte format, possibly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 tweaking the high bits, and possibly running a CCL program.) You
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 must pre-allocate the space used and pass it in. (This is done so
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 826
diff changeset
121 you can ALLOCA () the space.) You need to allocate (2 * len) bytes
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 of TEXT_STORAGE and (len * sizeof (struct textual_run)) bytes of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 RUN_STORAGE, where LEN is the length of the dynarr.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 Returns the number of runs actually used. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 separate_textual_runs (unsigned char *text_storage,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 struct textual_run *run_storage,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
130 const Ichar *str, Charcount len)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 possible valid charset when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 MULE is not defined */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 int runs_so_far = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 struct ccl_program char_converter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 int need_ccl_conversion = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 for (i = 0; i < len; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
144 Ichar ch = str[i];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 Lisp_Object charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 int byte1, byte2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 int dimension;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 int graphic;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
150 BREAKUP_ICHAR (ch, charset, byte1, byte2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 dimension = XCHARSET_DIMENSION (charset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 graphic = XCHARSET_GRAPHIC (charset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 if (!EQ (charset, prev_charset))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 run_storage[runs_so_far].ptr = text_storage;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 run_storage[runs_so_far].charset = charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 run_storage[runs_so_far].dimension = dimension;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 if (runs_so_far)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 run_storage[runs_so_far - 1].len =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 text_storage - run_storage[runs_so_far - 1].ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 if (run_storage[runs_so_far - 1].dimension == 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 run_storage[runs_so_far - 1].len >>= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 runs_so_far++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 prev_charset = charset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
172 if ((!NILP (ccl_prog))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
173 && (setup_ccl_program (&char_converter, ccl_prog) >= 0))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
174 need_ccl_conversion = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 if (graphic == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 byte1 &= 0x7F;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 byte2 &= 0x7F;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 else if (graphic == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 byte1 |= 0x80;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 byte2 |= 0x80;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 if (need_ccl_conversion)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 char_converter.reg[0] = XCHARSET_ID (charset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 char_converter.reg[1] = byte1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 char_converter.reg[2] = byte2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 byte1 = char_converter.reg[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 byte2 = char_converter.reg[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 *text_storage++ = (unsigned char) byte1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 if (dimension == 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 *text_storage++ = (unsigned char) byte2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 if (runs_so_far)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 run_storage[runs_so_far - 1].len =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 text_storage - run_storage[runs_so_far - 1].ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 if (run_storage[runs_so_far - 1].dimension == 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 run_storage[runs_so_far - 1].len >>= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 return runs_so_far;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 /****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 /* */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 /* X output routines */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 /* */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 /****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 x_text_width_single_run (struct face_cachel *cachel, struct textual_run *run)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
226 Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 if (!fi->proportional_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 return fi->width * run->len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 if (run->dimension == 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 return XTextWidth16 (FONT_INSTANCE_X_FONT (fi),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 (XChar2b *) run->ptr, run->len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 return XTextWidth (FONT_INSTANCE_X_FONT (fi),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 (char *) run->ptr, run->len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 x_text_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 Given a string and a face, return the string's length in pixels when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 displayed in the font associated with the face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 static int
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
248 x_text_width (struct frame *f, struct face_cachel *cachel, const Ichar *str,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 Charcount len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 int width_so_far = 0;
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 826
diff changeset
252 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 struct textual_run *runs = alloca_array (struct textual_run, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 int nruns;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 nruns = separate_textual_runs (text_storage, runs, str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 for (i = 0; i < nruns; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 width_so_far += x_text_width_single_run (cachel, runs + i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 return width_so_far;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 x_divider_height
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 Return the height of the horizontal divider. This is a function because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 divider_height is a device method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 #### If we add etched horizontal divider lines this will have to get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 smarter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 x_divider_height (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 x_eol_cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 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
284 because eol_cursor_width is a device method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 x_eol_cursor_width (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 return EOL_CURSOR_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 /*****************************************************************************
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
293 x_window_output_begin
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 Perform any necessary initialization prior to an update.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
298 x_window_output_begin (struct window *w)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 /*****************************************************************************
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303 x_window_output_end
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 Perform any necessary flushing of queues when an update has completed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
308 x_window_output_end (struct window *w)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
310 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
311 XFlush (DEVICE_X_DISPLAY (WINDOW_XDEVICE (w)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 x_output_display_block
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 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
318 runes between start and end in the specified display block.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 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
322 int start, int end, int start_pixpos, int cursor_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 int cursor_width, int cursor_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 struct frame *f = XFRAME (w->frame);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
326 Ichar_dynarr *buf = Dynarr_new (Ichar);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 Lisp_Object window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 struct display_block *db = Dynarr_atp (dl->display_blocks, block);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 rune_dynarr *rba = db->runes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 struct rune *rb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 int elt = start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 face_index findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 int xpos, width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 MULE is not defined */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
339 window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 rb = Dynarr_atp (rba, start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 if (!rb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 /* Nothing to do so don't do anything. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 xpos = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 if (rb->type == RUNE_CHAR)
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
349 charset = ichar_charset (rb->object.chr.ch);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 if (end < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 end = Dynarr_length (rba);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 Dynarr_reset (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 while (elt < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 rb = Dynarr_atp (rba, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 if (rb->findex == findex && rb->type == RUNE_CHAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 && 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
361 && EQ (charset, ichar_charset (rb->object.chr.ch)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 Dynarr_add (buf, rb->object.chr.ch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 width += rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 if (Dynarr_length (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 x_output_string (w, dl, buf, xpos, 0, start_pixpos, width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 findex, 0, cursor_start, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 xpos = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 Dynarr_reset (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 if (rb->type == RUNE_CHAR)
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 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 xpos = rb->xpos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
384 charset = ichar_charset (rb->object.chr.ch);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 if (rb->cursor_type == CURSOR_ON)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 if (rb->object.chr.ch == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 x_output_eol_cursor (w, dl, xpos, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 Dynarr_add (buf, rb->object.chr.ch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 x_output_string (w, dl, buf, xpos, 0, start_pixpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 rb->width, findex, 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 cursor_start, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 Dynarr_reset (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 xpos += rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 else if (rb->object.chr.ch == '\n')
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 /* Clear in case a cursor was formerly here. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
408 redisplay_clear_region (window, findex, xpos,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 DISPLAY_LINE_YPOS (dl),
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
410 rb->width,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 DISPLAY_LINE_HEIGHT (dl));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 if (rb->type == RUNE_BLANK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 x_output_blank (w, dl, rb, start_pixpos, cursor_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 /* #### Our flagging of when we need to redraw the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 modeline shadows sucks. Since RUNE_HLINE is only used
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 by the modeline at the moment it is a good bet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 that if it gets redrawn then we should also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 redraw the shadows. This won't be true forever.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 We borrow the shadow_thickness_changed flag for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 w->shadow_thickness_changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 x_output_hline (w, dl, rb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 elt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 if (elt < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 rb = Dynarr_atp (rba, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 xpos = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 }
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 else if (rb->type == RUNE_DGLYPH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 Lisp_Object instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 struct display_box dbox;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 struct display_glyph_area dga;
819
6504113e7c2d [xemacs-hg @ 2002-04-25 18:03:23 by andyp]
andyp
parents: 800
diff changeset
447
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 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
449 rb->object.dglyph.yoffset, start_pixpos,
6504113e7c2d [xemacs-hg @ 2002-04-25 18:03:23 by andyp]
andyp
parents: 800
diff changeset
450 rb->width, &dbox, &dga);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
452 window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 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
454 window, ERROR_ME_DEBUG_WARN, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 findex = rb->findex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 if (IMAGE_INSTANCEP (instance))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 switch (XIMAGE_INSTANCE_TYPE (instance))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
461 case IMAGE_MONO_PIXMAP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
462 case IMAGE_COLOR_PIXMAP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
463 redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 cursor_start, cursor_width,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
465 cursor_height, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
468 case IMAGE_WIDGET:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
469 if (EQ (XIMAGE_INSTANCE_WIDGET_TYPE (instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 Qlayout))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472 redisplay_output_layout (window, instance, &dbox, &dga, findex,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 cursor_start, cursor_width,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 cursor_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 case IMAGE_SUBWINDOW:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 cursor_start, cursor_width,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 cursor_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 case IMAGE_NOTHING:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484 /* nothing is as nothing does */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
487 case IMAGE_TEXT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
488 case IMAGE_POINTER:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
489 default:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
490 abort ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
491 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
492 IMAGE_INSTANCE_OPTIMIZE_OUTPUT
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
493 (XIMAGE_INSTANCE (instance)) = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
494 }
428
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 xpos += rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 elt++;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 abort ();
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 if (Dynarr_length (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 x_output_string (w, dl, buf, xpos, 0, start_pixpos, width, findex,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 0, cursor_start, cursor_width, cursor_height);
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 /* #### This is really conditionalized well for optimized
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 performance. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 if (dl->modeline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 && !EQ (Qzero, w->modeline_shadow_thickness)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 && (f->clear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 || f->windows_structure_changed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 || w->shadow_thickness_changed))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 bevel_modeline (w, dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 Dynarr_free (buf);
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 x_bevel_area
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 448
diff changeset
523 Draw shadows for the given area in the given face.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 x_bevel_area (struct window *w, face_index findex,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 int x, int y, int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 int shadow_thickness, int edges, enum edge_style style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 struct device *d = XDEVICE (f->device);
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 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 Pixel top_shadow_pixel, bottom_shadow_pixel, background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 Lisp_Object tmp_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 XColor tmp_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 GC top_shadow_gc, bottom_shadow_gc, background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 int use_pixmap = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 int flip_gcs = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 assert (shadow_thickness >=0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 /* First, get the GC's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 top_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 bottom_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 background_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 background_pixel, ef->core.background_pixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 gcv.background = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 mask = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 /* 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
567 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
568 if (top_shadow_pixel == background_pixel ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 bottom_shadow_pixel == background_pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 use_pixmap = 1;
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 (use_pixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 if (DEVICE_X_GRAY_PIXMAP (d) == None)
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 DEVICE_X_GRAY_PIXMAP (d) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 gray_width, gray_height, 1, 0, 1);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 gcv.foreground = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 /* this is needed because the GC draws with a pixmap here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 gcv.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (mask | GCStipple | GCFillStyle));
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 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 bottom_shadow_pixel = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 flip_gcs = (bottom_shadow_pixel ==
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 gcv.foreground = top_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 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
601 }
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 gcv.foreground = bottom_shadow_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 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
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 if (use_pixmap && flip_gcs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 GC tmp_gc = bottom_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 bottom_shadow_gc = top_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 top_shadow_gc = tmp_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 }
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 gcv.foreground = background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 /* 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
617 divider */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 if (style == EDGE_ETCHED_IN || style == EDGE_BEVEL_IN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 GC temp;
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 temp = top_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 top_shadow_gc = bottom_shadow_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 bottom_shadow_gc = temp;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 shadow_thickness /= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 x_output_shadows (f, x, y, width, height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 top_shadow_gc, bottom_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 background_gc, shadow_thickness, edges);
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 if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 x_output_shadows (f, x + shadow_thickness, y + shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 width - 2*shadow_thickness, height - 2*shadow_thickness,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 bottom_shadow_gc, top_shadow_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 background_gc, shadow_thickness, edges);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 x_get_gc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 Given a number of parameters return a GC with those properties.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 static GC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 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
652 Lisp_Object bg_pmap, Lisp_Object lwidth)
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 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 unsigned long mask;
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 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 /* 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
660 the GC returned by this function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 gcv.clip_mask = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 gcv.clip_x_origin = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 gcv.clip_y_origin = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 gcv.fill_style = FillSolid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 mask = GCGraphicsExposures | GCClipMask | GCClipXOrigin | GCClipYOrigin;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 mask |= GCFillStyle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 if (!NILP (font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 gcv.font = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))->fid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 mask |= GCFont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 /* evil kludge! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 if (!NILP (fg) && !COLOR_INSTANCEP (fg) && !INTP (fg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 /* #### I fixed once case where this was getting it. It was a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 bad macro expansion (compiler bug). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 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
680 debug_print (fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 fg = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 if (!NILP (fg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 if (COLOR_INSTANCEP (fg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 gcv.foreground = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (fg)).pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 gcv.foreground = XINT (fg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 mask |= GCForeground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 if (!NILP (bg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 if (COLOR_INSTANCEP (bg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 gcv.background = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (bg)).pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 gcv.background = XINT (bg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 mask |= GCBackground;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 /* 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
703 the dim property. We'll use a stippled foreground GC. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 if (EQ (bg_pmap, Qdim))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 assert (DEVICE_X_GRAY_PIXMAP (d) != None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 gcv.fill_style = FillStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 mask |= (GCFillStyle | GCStipple);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 else if (IMAGE_INSTANCEP (bg_pmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
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 gcv.fill_style = FillOpaqueStippled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 gcv.stipple = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 mask |= (GCStipple | GCFillStyle);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 else
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 gcv.fill_style = FillTiled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 gcv.tile = XIMAGE_INSTANCE_X_PIXMAP (bg_pmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 mask |= (GCTile | GCFillStyle);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 }
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 (!NILP (lwidth))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 gcv.line_width = XINT (lwidth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 mask |= GCLineWidth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 return gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 x_output_string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 Given a string and a starting position, output that string in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 given face. If cursor is true, draw a cursor around the string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 Correctly handles multiple charsets in the string.
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 The meaning of the parameters is something like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 W Window that the text is to be displayed in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 DL Display line that this text is on. The values in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 structure are used to determine the vertical position and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 clipping range of the text.
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
751 BUF Dynamic array of Ichars specifying what is actually to be
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 drawn.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 XPOS X position in pixels where the text should start being drawn.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 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
755 text. The effect is as if the text were shifted to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 left this many pixels and clipped at XPOS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 CLIP_START Clip everything left of this X position.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 WIDTH Clip everything right of XPOS + WIDTH.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 FINDEX Index for the face cache element describing how to display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 the text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 CURSOR #### I don't understand this. There's something
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 strange and overcomplexified with this variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 Chuck, explain please?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 CURSOR_START Starting X position of cursor.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 CURSOR_WIDTH Width of cursor in pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 CURSOR_HEIGHT Height of cursor in pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 Starting Y position of cursor is the top of the text line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 The cursor is drawn sometimes whether or not CURSOR is set. ???
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 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
773 Ichar_dynarr *buf, int xpos, int xoffset, int clip_start,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 int width, face_index findex, int cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 int cursor_start, int cursor_width, int cursor_height)
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 /* General variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 Lisp_Object device;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 Lisp_Object window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
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 int clip_end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 /* Cursor-related variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 int cursor_clip;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 WINDOW_BUFFER (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 struct face_cachel *cursor_cachel = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 /* Text-related variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 Lisp_Object bg_pmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 GC bgc, gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 int height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 int len = Dynarr_length (buf);
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 826
diff changeset
799 unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 struct textual_run *runs = alloca_array (struct textual_run, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 int nruns;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
805 device = wrap_device (d);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
806 window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 if (width < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 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
810 height = DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 /* Regularize the variables passed in. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 if (clip_start < xpos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 clip_start = xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 clip_end = xpos + width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 if (clip_start >= clip_end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 /* It's all clipped out. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 xpos -= xoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 /* make sure the area we are about to display is subwindow free. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 redisplay_unmap_subwindows_maybe (f, clip_start, DISPLAY_LINE_YPOS (dl),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 clip_end - clip_start, DISPLAY_LINE_HEIGHT (dl));
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 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 Dynarr_length (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 cursor_clip = (cursor_start >= clip_start &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 cursor_start < clip_end);
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 /* This cursor code is really a mess. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 if (!NILP (w->text_cursor_visible_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 && (cursor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 || cursor_clip
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 || (cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 && (cursor_start + cursor_width >= clip_start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 && !NILP (bar_cursor_value))))
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 /* These have to be in separate statements in order to avoid a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 compiler bug. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 face_index sucks = get_builtin_face_cache_index (w, Vtext_cursor_face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 cursor_cachel = WINDOW_FACE_CACHEL (w, sucks);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 /* We have to reset this since any call to WINDOW_FACE_CACHEL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 may cause the cache to resize and any pointers to it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 become invalid. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 cachel = WINDOW_FACE_CACHEL (w, findex);
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 #ifdef HAVE_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 if (cursor && focus && (cursor_start == clip_start) && cursor_height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 XIM_SetSpotLocation (f, xpos - 2, dl->ypos + dl->descent - 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 #endif /* HAVE_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 bg_pmap = cachel->background_pixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 if (!IMAGE_INSTANCEP (bg_pmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 bg_pmap = Qnil;
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 if ((cursor && focus && NILP (bar_cursor_value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 && !NILP (w->text_cursor_visible_p)) || NILP (bg_pmap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 bgc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 bgc = x_get_gc (d, Qnil, cachel->foreground, cachel->background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 bg_pmap, Qnil);
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 if (bgc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 XFillRectangle (dpy, x_win, bgc, clip_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 DISPLAY_LINE_YPOS (dl), clip_end - clip_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 for (i = 0; i < nruns; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
877 Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 int this_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 int need_clipping;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 if (EQ (font, Vthe_null_font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 this_width = x_text_width_single_run (cachel, runs + i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 need_clipping = (dl->clip || clip_start > xpos ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 clip_end < xpos + this_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 /* XDrawImageString only clears the area equal to the height of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 the given font. It is possible that a font is being displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 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
891 clear some areas. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 if ((int) fi->height < (int) (height + dl->clip + dl->top_clip))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 int clear_start = max (xpos, clip_start);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 int clear_end = min (xpos + this_width, clip_end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 if (cursor)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 int ypos1_line, ypos1_string, ypos2_line, ypos2_string;
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 ypos1_string = dl->ypos - fi->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 ypos2_string = dl->ypos + fi->descent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 ypos1_line = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 ypos2_line = ypos1_line + DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 /* Make sure we don't clear below the real bottom of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 if (ypos1_string > ypos2_line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 ypos1_string = ypos2_line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 if (ypos2_string > ypos2_line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 ypos2_string = ypos2_line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 if (ypos1_line < ypos1_string)
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 redisplay_clear_region (window, findex, clear_start, ypos1_line,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 clear_end - clear_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 ypos1_string - ypos1_line);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 if (ypos2_line > ypos2_string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 redisplay_clear_region (window, findex, clear_start, ypos2_string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 clear_end - clear_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 ypos2_line - ypos2_string);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 redisplay_clear_region (window, findex, clear_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 DISPLAY_LINE_YPOS (dl), clear_end - clear_start,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 height);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 if (cursor && cursor_cachel && focus && NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 gc = x_get_gc (d, font, cursor_cachel->foreground,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 cursor_cachel->background, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 else if (cachel->dim)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 /* Ensure the gray bitmap exists */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 if (DEVICE_X_GRAY_PIXMAP (d) == None)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 DEVICE_X_GRAY_PIXMAP (d) =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 XCreateBitmapFromData (dpy, x_win, (char *)gray_bits,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 gray_width, gray_height);
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 /* Request a GC with the gray stipple pixmap to draw dimmed text */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 gc = x_get_gc (d, font, cachel->foreground, cachel->background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 Qdim, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 gc = x_get_gc (d, font, cachel->foreground, cachel->background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 Qnil, Qnil);
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 if (need_clipping)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 XRectangle clip_box[1];
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 clip_box[0].x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 clip_box[0].y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 clip_box[0].width = clip_end - clip_start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 clip_box[0].height = height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 XSetClipRectangles (dpy, gc, clip_start, DISPLAY_LINE_YPOS (dl),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 clip_box, 1, Unsorted);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 if (runs[i].dimension == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 (bgc ? XDrawString : XDrawImageString) (dpy, x_win, gc, xpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 dl->ypos, (char *) runs[i].ptr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 runs[i].len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 (bgc ? XDrawString16 : XDrawImageString16) (dpy, x_win, gc, xpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 dl->ypos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 (XChar2b *) runs[i].ptr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 runs[i].len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 /* We draw underlines in the same color as the text. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 if (cachel->underline)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
980 int upos, uthick;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
981 unsigned long upos_ext, uthick_ext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 XFontStruct *xfont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font));
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
985 if (!XGetFontProperty (xfont, XA_UNDERLINE_POSITION, &upos_ext))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 upos = dl->descent / 2;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
987 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
988 upos = (int) upos_ext;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
989 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick_ext))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 uthick = 1;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
991 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
992 uthick = (int) uthick_ext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 if (dl->ypos + upos < dl->ypos + dl->descent - dl->clip)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 uthick = dl->descent - dl->clip - upos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 if (uthick == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 XDrawLine (dpy, x_win, gc, xpos, dl->ypos + upos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 xpos + this_width, dl->ypos + upos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 else if (uthick > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 XFillRectangle (dpy, x_win, gc, xpos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 dl->ypos + upos, this_width, uthick);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 }
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
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1012 if (cachel->strikethru)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1013 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1014 int ascent, descent, upos, uthick;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1015 unsigned long ascent_ext, descent_ext, uthick_ext;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1016 XFontStruct *xfont;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1018 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font));
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1019
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1020 if (!XGetFontProperty (xfont, XA_STRIKEOUT_ASCENT, &ascent_ext))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1021 ascent = xfont->ascent;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1022 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1023 ascent = (int) ascent_ext;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1024 if (!XGetFontProperty (xfont, XA_STRIKEOUT_DESCENT, &descent_ext))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1025 descent = xfont->descent;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1026 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1027 descent = (int) descent_ext;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1028 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick_ext))
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1029 uthick = 1;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1030 else
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1031 uthick = (int) uthick_ext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1033 upos = ascent - ((ascent + descent) / 2) + 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1035 /* 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
1036 subtract */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1037 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
1038 {
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1039 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
1040 uthick = dl->descent - dl->clip + upos;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1041
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1042 if (uthick == 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 XDrawLine (dpy, x_win, gc, xpos, dl->ypos - upos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 xpos + this_width, dl->ypos - upos);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1045 else if (uthick > 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 XFillRectangle (dpy, x_win, gc, xpos, dl->ypos + upos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 this_width, uthick);
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1048 }
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1049 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 /* Restore the GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 if (need_clipping)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 XSetClipMask (dpy, gc, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 XSetClipOrigin (dpy, gc, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 /* If we are actually superimposing the cursor then redraw with just
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 the appropriate section highlighted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 if (cursor_clip && !cursor && focus && cursor_cachel)
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 GC cgc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 XRectangle clip_box[1];
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 cgc = x_get_gc (d, font, cursor_cachel->foreground,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 cursor_cachel->background, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 clip_box[0].x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 clip_box[0].y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 clip_box[0].width = cursor_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 clip_box[0].height = height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 XSetClipRectangles (dpy, cgc, cursor_start, DISPLAY_LINE_YPOS (dl),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 clip_box, 1, Unsorted);
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 if (runs[i].dimension == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 XDrawImageString (dpy, x_win, cgc, xpos, dl->ypos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 (char *) runs[i].ptr, runs[i].len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 XDrawImageString16 (dpy, x_win, cgc, xpos, dl->ypos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 (XChar2b *) runs[i].ptr, runs[i].len);
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 XSetClipMask (dpy, cgc, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 XSetClipOrigin (dpy, cgc, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 xpos += this_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 /* Draw the non-focus box or bar-cursor as needed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 /* Can't this logic be simplified? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 if (cursor_cachel
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 && ((cursor && !focus && NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 || (cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 && (cursor_start + cursor_width >= clip_start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 && !NILP (bar_cursor_value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 int tmp_height, tmp_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 int need_clipping = (cursor_start < clip_start
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 || clip_end < cursor_start + cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 /* #### This value is correct (as far as I know) because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 all of the times we need to draw this cursor, we will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 be called with exactly one character, so we know we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 can always use runs[0].
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 This is bogus as all hell, however. The cursor handling in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 this function is way bogus and desperately needs to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 cleaned up. (In particular, the drawing of the cursor should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 really really be separated out of this function. This may be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 a bit tricky now because this function itself does way too
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 much stuff, a lot of which needs to be moved into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 redisplay.c) This is the only way to be able to easily add
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 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
1116 span two characters instead of overlaying just one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 int bogusly_obtained_ascent_value =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 XFONT_INSTANCE (FACE_CACHEL_FONT (cachel, runs[0].charset))->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 if (!NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 make_int (bar_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 gc = x_get_gc (d, Qnil, cursor_cachel->background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 }
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 tmp_y = dl->ypos - bogusly_obtained_ascent_value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 tmp_height = cursor_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 if (tmp_y + tmp_height > (int) (DISPLAY_LINE_YPOS(dl) + height))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 tmp_y = DISPLAY_LINE_YPOS (dl) + height - tmp_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 if (tmp_y < (int) DISPLAY_LINE_YPOS (dl))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 tmp_y = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 tmp_height = DISPLAY_LINE_YPOS (dl) + height - tmp_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 if (need_clipping)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 XRectangle clip_box[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 clip_box[0].x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 clip_box[0].y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 clip_box[0].width = clip_end - clip_start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 clip_box[0].height = tmp_height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 XSetClipRectangles (dpy, gc, clip_start, tmp_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 clip_box, 1, Unsorted);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 if (!focus && NILP (bar_cursor_value))
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 XDrawRectangle (dpy, x_win, gc, cursor_start, tmp_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 cursor_width - 1, tmp_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 else if (focus && !NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 XDrawLine (dpy, x_win, gc, cursor_start + bar_width - 1, tmp_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 cursor_start + bar_width - 1, tmp_y + tmp_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 }
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 /* Restore the GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 if (need_clipping)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 XSetClipMask (dpy, gc, None);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 XSetClipOrigin (dpy, gc, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 }
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 }
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 void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1173 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
1174 int y, int xoffset, int yoffset,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1175 int width, int height, unsigned long fg, unsigned long bg,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 GC override_gc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 unsigned long pixmap_mask;
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 if (!override_gc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 gcv.foreground = fg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 gcv.background = bg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 pixmap_mask = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 if (IMAGE_INSTANCE_X_MASK (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 gcv.function = GXcopy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 gcv.clip_mask = IMAGE_INSTANCE_X_MASK (p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 gcv.clip_x_origin = x - xoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 gcv.clip_y_origin = y - yoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 pixmap_mask |= (GCFunction | GCClipMask | GCClipXOrigin |
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 GCClipYOrigin);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 /* Can't set a clip rectangle because we already have a mask.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 Is it possible to get an equivalent effect by changing the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 args to XCopyArea below rather than messing with a clip box?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 - dkindred@cs.cmu.edu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 Yes. We don't clip at all now - andy@xemacs.org
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, pixmap_mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 gc = override_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 /* 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
1216 Maybe we can insist that override_gc have no mask, or use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 one of the suggestions above. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 /* 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
1221 XCopyPlane (1 = current foreground color, 0 = background) instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 of XCopyArea, which means that the bits in the pixmap are actual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 pixel values, instead of symbolic of fg/bg. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 if (IMAGE_INSTANCE_PIXMAP_DEPTH (p) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1226 XCopyArea (dpy,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1227 IMAGE_INSTANCE_X_PIXMAP_SLICE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 yoffset, width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 height, x, y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1234 XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 xoffset, yoffset, width, height, x, y, 1L);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 x_output_pixmap (struct window *w, Lisp_Object image_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 struct display_box *db, struct display_glyph_area *dga,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 face_index findex, int cursor_start, int cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 int cursor_height, int bg_pixmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 struct device *d = XDEVICE (f->device);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1248 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1252
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 /* Output the pixmap. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 Lisp_Object tmp_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 XColor tmp_bcolor, tmp_fcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 tmp_bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 x_output_x_pixmap (f, p, db->xpos, db->ypos,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 dga->xoffset, dga->yoffset,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 dga->width, dga->height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 tmp_fcolor.pixel, tmp_bcolor.pixel, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 /* Draw a cursor over top of the pixmap. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 if (cursor_width && cursor_height && (cursor_start >= db->xpos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 && !NILP (w->text_cursor_visible_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 && (cursor_start < db->xpos + dga->width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 struct face_cachel *cursor_cachel =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 WINDOW_FACE_CACHEL (w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 get_builtin_face_cache_index
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 (w, Vtext_cursor_face));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 if (cursor_width > db->xpos + dga->width - cursor_start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 cursor_width = db->xpos + dga->width - cursor_start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 if (focus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 XFillRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 XDrawRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 x_output_vertical_divider
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 Draw a vertical divider down the right side of the given window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 x_output_vertical_divider (struct window *w, int clear)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 Lisp_Object tmp_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 XColor tmp_color;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 GC background_gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 enum edge_style style;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 unsigned long mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 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
1320 face_index div_face =
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 450
diff changeset
1321 get_builtin_face_cache_index (w, Vvertical_divider_face);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 width = window_divider_width (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 shadow_thickness = XINT (w->vertical_divider_shadow_thickness);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 spacing = XINT (w->vertical_divider_spacing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 line_width = XINT (w->vertical_divider_line_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 x = WINDOW_RIGHT (w) - width;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1328 y1 = WINDOW_TOP (w);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1329 y2 = WINDOW_BOTTOM (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 memset (&gcv, ~0, sizeof (XGCValues));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 /* First, get the GC's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 gcv.background = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 gcv.foreground = tmp_color.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 mask = GCForeground | GCBackground | GCGraphicsExposures;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 /* Clear the divider area first. This needs to be done when a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 window split occurs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 if (clear)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 XClearArea (dpy, x_win, x, y1, width, y2 - y1, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 /* Draw the divider line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 XFillRectangle (dpy, x_win, background_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 x + spacing + shadow_thickness, y1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 line_width, y2 - y1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 if (shadow_thickness < 0)
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 shadow_thickness = -shadow_thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 style = EDGE_BEVEL_IN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 style = EDGE_BEVEL_OUT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 /* Draw the shadows around the divider line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 x_bevel_area (w, div_face, x + spacing, y1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 width - 2 * spacing, y2 - y1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 shadow_thickness, EDGE_ALL, style);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 x_output_blank
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 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
1373 of its face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 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
1377 int start_pixpos, int cursor_start, int cursor_width)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 struct face_cachel *cursor_cachel =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 WINDOW_FACE_CACHEL (w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 get_builtin_face_cache_index
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 (w, Vtext_cursor_face));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 Lisp_Object bg_pmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 Lisp_Object buffer = WINDOW_BUFFER (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 int x = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 int y = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 int width = rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 int height = DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 /* Unmap all subwindows in the area we are going to blank. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 redisplay_unmap_subwindows_maybe (f, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 if (start_pixpos > x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 if (start_pixpos >= (x + width))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 width -= (start_pixpos - x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 x = start_pixpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 bg_pmap = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, rb->findex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 if (!IMAGE_INSTANCEP (bg_pmap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 || !IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 bg_pmap = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 if (NILP (bg_pmap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 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
1420 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 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
1423 WINDOW_FACE_CACHEL_BACKGROUND (w, rb->findex), bg_pmap,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 XFillRectangle (dpy, x_win, gc, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 /* 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
1429 representing a tab. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 if (!NILP (w->text_cursor_visible_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 && (rb->cursor_type == CURSOR_ON
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 || (cursor_width
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 && (cursor_start + cursor_width > x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 && cursor_start < (x + width))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 int cursor_height, cursor_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 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
1438 Lisp_Font_Instance *fi;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 fi = XFONT_INSTANCE (FACE_CACHEL_FONT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 (WINDOW_FACE_CACHEL (w, rb->findex),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 Vcharset_ascii));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 cursor_y = dl->ypos - fi->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 cursor_height = fi->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 if (cursor_y + cursor_height > y + height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 cursor_height = y + height - cursor_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 if (focus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 if (NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 XFillRectangle (dpy, x_win, gc, cursor_start, cursor_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 fi->width, cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 make_int (bar_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 XDrawLine (dpy, x_win, gc, cursor_start + bar_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 cursor_y, cursor_start + bar_width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 cursor_y + cursor_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 else if (NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 XDrawRectangle (dpy, x_win, gc, cursor_start, cursor_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 fi->width - 1, cursor_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 x_output_hline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 Output a horizontal line in the foreground of its face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 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
1484 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 GC gc;
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 int x = rb->xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 int width = rb->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 int height = DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 int ypos1, ypos2, ypos3, ypos4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 ypos1 = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 ypos2 = ypos1 + rb->object.hline.yoffset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 ypos3 = ypos2 + rb->object.hline.thickness;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 ypos4 = dl->ypos + dl->descent - dl->clip;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 /* First clear the area not covered by the line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 if (height - rb->object.hline.thickness > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 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
1506 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 if (ypos2 - ypos1 > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 XFillRectangle (dpy, x_win, gc, x, ypos1, width, ypos2 - ypos1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 if (ypos4 - ypos3 > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 XFillRectangle (dpy, x_win, gc, x, ypos1, width, ypos2 - ypos1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 /* Now draw the line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 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
1516 Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 if (ypos2 < ypos1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 ypos2 = ypos1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 if (ypos3 > ypos4)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 ypos3 = ypos4;
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 (ypos3 - ypos2 > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 XFillRectangle (dpy, x_win, gc, x, ypos2, width, ypos3 - ypos2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526
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 x_output_shadows
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 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
1531 callers responsibility to set the GC's appropriately.
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 x_output_shadows (struct frame *f, int x, int y, int width, int height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 GC top_shadow_gc, GC bottom_shadow_gc, GC background_gc,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 int shadow_thickness, int edges)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
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 XSegment top_shadow[20], bottom_shadow[20];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 int elt;
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 if (shadow_thickness > 10)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 shadow_thickness = 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 else if (shadow_thickness < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 shadow_thickness = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 if (shadow_thickness > (width / 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 shadow_thickness = width / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 if (shadow_thickness > (height / 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 shadow_thickness = height / 2;
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 for (elt = 0; elt < shadow_thickness; elt++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 int seg1 = elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 int seg2 = (edges & EDGE_TOP) ? elt + shadow_thickness : elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 int bot_seg2 = (edges & EDGE_BOTTOM) ? elt + shadow_thickness : elt;
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 if (edges & EDGE_TOP)
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 top_shadow[seg1].x1 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 top_shadow[seg1].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 top_shadow[seg1].y1 = top_shadow[seg1].y2 = y + elt;
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 if (edges & EDGE_LEFT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 top_shadow[seg2].x1 = top_shadow[seg2].x2 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 top_shadow[seg2].y1 = y + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 top_shadow[seg2].y2 = y + height - elt - 1;
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 if (edges & EDGE_BOTTOM)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 bottom_shadow[seg1].x1 = x + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 bottom_shadow[seg1].x2 = x + width - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 bottom_shadow[seg1].y1 = bottom_shadow[seg1].y2 = y + height - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 if (edges & EDGE_RIGHT)
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 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
1582 bottom_shadow[bot_seg2].y1 = y + elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 bottom_shadow[bot_seg2].y2 = y + height - elt - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 }
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 XDrawSegments (dpy, x_win, top_shadow_gc, top_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 ((edges & EDGE_TOP) ? shadow_thickness : 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 + ((edges & EDGE_LEFT) ? shadow_thickness : 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 XDrawSegments (dpy, x_win, bottom_shadow_gc, bottom_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 ((edges & EDGE_BOTTOM) ? shadow_thickness : 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 + ((edges & EDGE_RIGHT) ? shadow_thickness : 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 }
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 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 x_generate_shadow_pixels
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 Given three pixels (top shadow, bottom shadow, background) massage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 the top and bottom shadow colors to guarantee that they differ. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 background pixels are not allowed to be modified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 This function modifies its parameters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 This code is modified from code blatantly stolen from lwlib/xlwmenu.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 ? ((unsigned long) (x)) : ((unsigned long) (y)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 x_generate_shadow_pixels (struct frame *f, unsigned long *top_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 unsigned long *bottom_shadow,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 unsigned long background,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 unsigned long core_background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 Colormap cmap = DEVICE_X_COLORMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 Visual *visual = DEVICE_X_VISUAL (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 XColor topc, botc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 int top_frobbed = 0, bottom_frobbed = 0;
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 /* 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
1624 adjust it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 if (*top_shadow == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 topc.pixel = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 XQueryColor (dpy, cmap, &topc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 /* don't overflow/wrap! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 topc.red = MINL (65535, (unsigned long) topc.red * 6 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 topc.green = MINL (65535, (unsigned long) topc.green * 6 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 topc.blue = MINL (65535, (unsigned long) topc.blue * 6 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 if (allocate_nearest_color (dpy, cmap, visual, &topc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 *top_shadow = topc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 top_frobbed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 /* 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
1641 adjust it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 if (*bottom_shadow == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 botc.pixel = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 XQueryColor (dpy, cmap, &botc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 botc.red = (unsigned short) ((unsigned long) botc.red * 3 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 botc.green = (unsigned short) ((unsigned long) botc.green * 3 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 botc.blue = (unsigned short) ((unsigned long) botc.blue * 3 / 5);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 if (allocate_nearest_color (dpy, cmap, visual, &botc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 *bottom_shadow = botc.pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 bottom_frobbed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 /* 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
1657 additional work. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 if (top_frobbed && bottom_frobbed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 int top_avg = ((topc.red / 3) + (topc.green / 3) + (topc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 int bot_avg = ((botc.red / 3) + (botc.green / 3) + (botc.blue / 3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 if (bot_avg > top_avg)
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 Pixel tmp = *top_shadow;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 *top_shadow = *bottom_shadow;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 *bottom_shadow = tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 else if (topc.pixel == botc.pixel)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 if (botc.pixel == background)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 *top_shadow = core_background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 *bottom_shadow = background;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 x_redraw_exposed_window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 Given a bounding box for an area that needs to be redrawn, determine
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 what parts of what lines are contained within and re-output their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 contents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 x_redraw_exposed_window (struct window *w, int x, int y, int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 int line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 int start_x, start_y, end_x, end_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 int orig_windows_structure_changed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 display_line_dynarr *cdla = window_display_lines (w, CURRENT_DISP);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 if (!NILP (w->vchild))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 x_redraw_exposed_windows (w->vchild, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 else if (!NILP (w->hchild))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 x_redraw_exposed_windows (w->hchild, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 return;
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 /* If the window doesn't intersect the exposed region, we're done here. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 if (x >= WINDOW_RIGHT (w) || (x + width) <= WINDOW_LEFT (w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 || y >= WINDOW_BOTTOM (w) || (y + height) <= WINDOW_TOP (w))
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 return;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 start_x = max (WINDOW_LEFT (w), x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 end_x = min (WINDOW_RIGHT (w), (x + width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 start_y = max (WINDOW_TOP (w), y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 end_y = min (WINDOW_BOTTOM (w), y + height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 /* We do this to make sure that the 3D modelines get redrawn if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 they are in the exposed region. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 orig_windows_structure_changed = f->windows_structure_changed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 f->windows_structure_changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
1726 redisplay_clear_top_of_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 if (window_needs_vertical_divider (w))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 x_output_vertical_divider (w, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 }
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 for (line = 0; line < Dynarr_length (cdla); line++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 struct display_line *cdl = Dynarr_atp (cdla, line);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 int top_y = cdl->ypos - cdl->ascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 int bottom_y = cdl->ypos + cdl->descent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 if (bottom_y >= start_y)
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 if (top_y > end_y)
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 if (line == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 output_display_line (w, 0, cdla, line, start_x, end_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 }
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 f->windows_structure_changed = orig_windows_structure_changed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 /* If there have never been any face cache_elements created, then this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 expose event doesn't actually have anything to do. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 if (Dynarr_largest (w->face_cachels))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 redisplay_clear_bottom_of_window (w, cdla, start_y, end_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 }
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 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 x_redraw_exposed_windows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 For each window beneath the given window in the window hierarchy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 ensure that it is redrawn if necessary after an Expose event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 x_redraw_exposed_windows (Lisp_Object window, int x, int y, int width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 int height)
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 for (; !NILP (window); window = XWINDOW (window)->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 x_redraw_exposed_window (XWINDOW (window), x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775
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 x_redraw_exposed_area
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 For each window on the given frame, ensure that any area in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 Exposed area is redrawn.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 x_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 /* If any window on the frame has had its face cache reset then the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 redisplay structures are effectively invalid. If we attempt to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 use them we'll blow up. We mark the frame as changed to ensure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 that redisplay will do a full update. This probably isn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 necessary but it can't hurt. */
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 #ifdef HAVE_TOOLBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 /* #### We would rather put these off as well but there is currently
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 no combination of flags which will force an unchanged toolbar to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 redraw anyhow. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 redraw_exposed_gutters (f, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 if (!f->window_face_cache_reset)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 x_redraw_exposed_windows (f->root_window, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
1803 if (!(check_if_pending_expose_event (FRAME_XDEVICE (f))))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
1804 XFlush (DEVICE_X_DISPLAY (FRAME_XDEVICE (f)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 MARK_FRAME_CHANGED (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809
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 x_clear_region
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 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
1814 given face.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 x_clear_region (Lisp_Object locale, struct device* d, struct frame* f, face_index findex,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 int x, int y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 Lisp_Object background_pixmap)
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 Display *dpy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 Window x_win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 GC gc = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 if (!UNBOUNDP (background_pixmap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 gc = x_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 if (gc)
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 XClearArea (dpy, x_win, x, y, width, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 x_output_eol_cursor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 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
1844 narrower than the normal cursor.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 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
1848 face_index findex)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 struct frame *f = XFRAME (w->frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 Lisp_Object window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 face_index elt = get_builtin_face_cache_index (w, Vtext_cursor_face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 struct face_cachel *cursor_cachel = WINDOW_FACE_CACHEL (w, elt);
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 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 WINDOW_BUFFER (w));
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 int x = xpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 int y = DISPLAY_LINE_YPOS (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 int width = EOL_CURSOR_WIDTH;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 int height = DISPLAY_LINE_HEIGHT (dl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 int cursor_height, cursor_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 int defheight, defascent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
1871 window = wrap_window (w);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 redisplay_clear_region (window, findex, x, y, width, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 if (NILP (w->text_cursor_visible_p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 return;
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 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 default_face_font_info (window, &defascent, 0, &defheight, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 /* make sure the cursor is entirely contained between y and y+height */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 cursor_height = min (defheight, height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 cursor_y = max (y, min (y + height - cursor_height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 dl->ypos - defascent));
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 if (focus)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 #ifdef HAVE_XIM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 #endif /* HAVE_XIM */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 if (NILP (bar_cursor_value))
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 XFillRectangle (dpy, x_win, gc, x, cursor_y, width, cursor_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 make_int (bar_width));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 XDrawLine (dpy, x_win, gc, x + bar_width - 1, cursor_y,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 x + bar_width - 1, cursor_y + cursor_height - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 }
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 else if (NILP (bar_cursor_value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 XDrawRectangle (dpy, x_win, gc, x, cursor_y, width - 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 cursor_height - 1);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 x_clear_frame_window (Lisp_Object window)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 struct window *w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 if (!NILP (w->vchild))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 x_clear_frame_windows (w->vchild);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 if (!NILP (w->hchild))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 x_clear_frame_windows (w->hchild);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1930 redisplay_clear_to_window_end (w, WINDOW_TEXT_TOP (w),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 WINDOW_TEXT_BOTTOM (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 x_clear_frame_windows (Lisp_Object window)
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 for (; !NILP (window); window = XWINDOW (window)->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 x_clear_frame_window (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 x_clear_frame (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 int x, y, width, height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 Lisp_Object frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1950 x = FRAME_LEFT_BORDER_START (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951 width = (FRAME_PIXWIDTH (f) - FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 /* #### This adjustment by 1 should be being done in the macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 There is some small differences between when the menubar is on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 and off that we still need to deal with. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 y = FRAME_TOP_BORDER_START (f) - 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 height = (FRAME_PIXHEIGHT (f) - FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) -
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f)) + 1;
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 XClearArea (dpy, x_win, x, y, width, height, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
1966 frame = wrap_frame (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 if (!UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vdefault_face, frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vleft_margin_face, frame))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 || !UNBOUNDP (FACE_BACKGROUND_PIXMAP (Vright_margin_face, frame)))
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 x_clear_frame_windows (f->root_window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
1975 if (!(check_if_pending_expose_event (d)))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 872
diff changeset
1976 XFlush (DEVICE_X_DISPLAY (d));
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 /* briefly swap the foreground and background colors.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 */
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 x_flash (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 Display *dpy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 Window win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 XGCValues gcv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 GC gc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 XColor tmp_fcolor, tmp_bcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 Lisp_Object tmp_pixel, frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 struct frame *f = device_selected_frame (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 struct window *w = XWINDOW (FRAME_ROOT_WINDOW (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 Widget shell = FRAME_X_SHELL_WIDGET (f);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1994 int flash_height;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 664
diff changeset
1996 frame = wrap_frame (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 tmp_bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
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 dpy = XtDisplay (shell);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 win = XtWindow (FRAME_X_TEXT_WIDGET (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 memset (&gcv, ~0, sizeof (XGCValues)); /* initialize all slots to ~0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 gcv.foreground = (tmp_fcolor.pixel ^ tmp_bcolor.pixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 gcv.function = GXxor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 gcv.graphics_exposures = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (XDEVICE (f->device)), &gcv,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 (GCForeground | GCFunction | GCGraphicsExposures));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2011 default_face_height_and_width (frame, &flash_height, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2012
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2013 /* If window is tall, flash top and bottom line. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2014 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
2015 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2016 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2017 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2018 XFillRectangle (dpy, win, gc, w->pixel_left,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2019 w->pixel_top + w->pixel_height - flash_height,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2020 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2021 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2022 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2023 /* If it is short, flash it all. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2024 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2025 w->pixel_width, w->pixel_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2026
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 XSync (dpy, False);
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 #ifdef HAVE_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 int usecs = 100000;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 struct timeval tv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 tv.tv_sec = usecs / 1000000L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 tv.tv_usec = usecs % 1000000L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 /* I'm sure someone is going to complain about this... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 select (0, 0, 0, 0, &tv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 #ifdef HAVE_POLL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 poll (0, 0, 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 #else /* !HAVE_POLL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 bite me
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 #endif /* HAVE_POLL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 #endif /* HAVE_SELECT */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2046 /* If window is tall, flash top and bottom line. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2047 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
2048 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2049 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2050 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2051 XFillRectangle (dpy, win, gc, w->pixel_left,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2052 w->pixel_top + w->pixel_height - flash_height,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2053 w->pixel_width, flash_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2054 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2055 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2056 /* If it is short, flash it all. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2057 XFillRectangle (dpy, win, gc, w->pixel_left, w->pixel_top,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2058 w->pixel_width, w->pixel_height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2059
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 XSync (dpy, False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 return 1;
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 /* Make audible bell. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 x_ring_bell (struct device *d, int volume, int pitch, int duration)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070 Display *display = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 if (volume < 0) volume = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 else if (volume > 100) volume = 100;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 if (pitch < 0 && duration < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 XBell (display, (volume * 2) - 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 XFlush (display);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 XKeyboardState state;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 XKeyboardControl ctl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 XSync (display, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 /* #### grab server? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 XGetKeyboardControl (display, &state);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086
664
6e99cc8c6ca5 [xemacs-hg @ 2001-09-18 05:04:26 by ben]
ben
parents: 647
diff changeset
2087 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
2088 ctl.bell_duration = (duration >= 0 ? duration : (int) state.bell_duration);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
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 XBell (display, (volume * 2) - 100);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 ctl.bell_pitch = state.bell_pitch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 ctl.bell_duration = state.bell_duration;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 XChangeKeyboardControl (display, KBBellPitch|KBBellDuration, &ctl);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 /* #### ungrab server? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 XSync (display, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 console_type_create_redisplay_x (void)
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 /* redisplay methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 CONSOLE_HAS_METHOD (x, text_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112 CONSOLE_HAS_METHOD (x, output_display_block);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 CONSOLE_HAS_METHOD (x, divider_height);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 CONSOLE_HAS_METHOD (x, eol_cursor_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 CONSOLE_HAS_METHOD (x, output_vertical_divider);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 CONSOLE_HAS_METHOD (x, clear_region);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 CONSOLE_HAS_METHOD (x, clear_frame);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2118 CONSOLE_HAS_METHOD (x, window_output_begin);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2119 CONSOLE_HAS_METHOD (x, window_output_end);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120 CONSOLE_HAS_METHOD (x, flash);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 CONSOLE_HAS_METHOD (x, ring_bell);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 CONSOLE_HAS_METHOD (x, bevel_area);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 CONSOLE_HAS_METHOD (x, output_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 CONSOLE_HAS_METHOD (x, output_pixmap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 }