annotate src/xfns.c @ 389:6e0510766e66

Initial revision
author Jim Blandy <jimb@redhat.com>
date Wed, 14 Aug 1991 01:04:47 +0000
parents
children a60eafebd43f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Functions for the X window system.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 Copyright (C) 1989 Free Software Foundation.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 /* Completely rewritten by Richard Stallman. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 /* Rewritten for X11 by Joseph Arceneaux */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 #include <stdio.h>
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include <signal.h>
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 #include "config.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 #include "lisp.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #include "xterm.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #include "screen.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #include "window.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 #include "buffer.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 #include "dispextern.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #include "xscrollbar.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #ifdef HAVE_X_WINDOWS
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 extern void abort ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 void x_set_screen_param ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #define min(a,b) ((a) < (b) ? (a) : (b))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #define max(a,b) ((a) > (b) ? (a) : (b))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 /* X Resource data base */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 static XrmDatabase xrdb;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 /* The class of this X application. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 #define EMACS_CLASS "Emacs"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 /* The class of Emacs screens. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 #define SCREEN_CLASS "Screen"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 /* Title name and application name for X stuff. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 extern char *id_name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 extern Lisp_Object invocation_name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 /* The background and shape of the mouse pointer, and shape when not
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 over text or in the modeline. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 /* Color of chars displayed in cursor box. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 Lisp_Object Vx_cursor_fore_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 /* If non-nil, use vertical bar cursor. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 Lisp_Object Vbar_cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 /* The X Visual we are using for X windows (the default) */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 Visual *screen_visual;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 /* How many screens this X display has. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 int x_screen_count;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 /* The vendor supporting this X server. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 Lisp_Object Vx_vendor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 /* The vendor's release number for this X server. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 int x_release;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 /* Height of this X screen in pixels. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 int x_screen_height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 /* Height of this X screen in millimeters. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 int x_screen_height_mm;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 /* Width of this X screen in pixels. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 int x_screen_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 /* Width of this X screen in millimeters. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 int x_screen_width_mm;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 /* Does this X screen do backing store? */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 Lisp_Object Vx_backing_store;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 /* Does this X screen do save-unders? */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 int x_save_under;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 /* Number of planes for this screen. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 int x_screen_planes;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 /* X Visual type of this screen. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 Lisp_Object Vx_screen_visual;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 /* Non nil if no window manager is in use. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 Lisp_Object Vx_no_window_manager;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 static char *x_visual_strings[] =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 "StaticGray",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 "GrayScale",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 "StaticColor",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 "PseudoColor",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 "TrueColor",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 "DirectColor"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 /* `t' if a mouse button is depressed. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 Lisp_Object Vmouse_depressed;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 /* Atom for indicating window state to the window manager. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 Atom Xatom_wm_change_state;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 /* When emacs became the selection owner. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 extern Time x_begin_selection_own;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 /* The value of the current emacs selection. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 extern Lisp_Object Vx_selection_value;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 /* Emacs' selection property identifier. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 extern Atom Xatom_emacs_selection;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 /* Clipboard selection atom. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 extern Atom Xatom_clipboard_selection;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 /* Clipboard atom. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 extern Atom Xatom_clipboard;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 /* Atom for indicating incremental selection transfer. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 extern Atom Xatom_incremental;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 /* Atom for indicating multiple selection request list */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 extern Atom Xatom_multiple;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 /* Atom for what targets emacs handles. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 extern Atom Xatom_targets;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 /* Atom for indicating timstamp selection request */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 extern Atom Xatom_timestamp;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 /* Atom requesting we delete our selection. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 extern Atom Xatom_delete;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 /* Selection magic. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 extern Atom Xatom_insert_selection;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 /* Type of property for INSERT_SELECTION. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 extern Atom Xatom_pair;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 /* More selection magic. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 extern Atom Xatom_insert_property;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 /* Atom for indicating property type TEXT */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 extern Atom Xatom_text;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 #else /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 /* Default size of an Emacs window without scroll bar. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 static char *default_window = "=80x24+0+0";
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 #define MAXICID 80
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 char iconidentity[MAXICID];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 #define ICONTAG "emacs@"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 char minibuffer_iconidentity[MAXICID];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 #define MINIBUFFER_ICONTAG "minibuffer@"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 #endif /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 /* The last 23 bits of the timestamp of the last mouse button event. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 Time mouse_timestamp;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 Lisp_Object Qundefined_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 Lisp_Object Qx_screen_parameter;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 extern Lisp_Object Vwindow_system_version;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 /* Mouse map for clicks in windows. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 extern Lisp_Object Vglobal_mouse_map;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 /* Points to table of defined typefaces. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 struct face *x_face_table[MAX_FACES_AND_GLYPHS];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 /* Return the Emacs screen-object corresponding to an X window.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 It could be the screen's main window or an icon window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 struct screen *
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 x_window_to_screen (wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 int wdesc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 Lisp_Object tail, screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 for (tail = Vscreen_list; CONSP (tail); tail = XCONS (tail)->cdr)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 screen = XCONS (tail)->car;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 if (XTYPE (screen) != Lisp_Screen)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 s = XSCREEN (screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 if (s->display.x->window_desc == wdesc
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 || s->display.x->icon_desc == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 return 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 /* A symbol indicating which part of the screen the mouse is in. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 Lisp_Object Vmouse_screen_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 Lisp_Object Qtext_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 Lisp_Object Qmodeline_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 Lisp_Object Qvscrollbar_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 Lisp_Object Qvslider_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 Lisp_Object Qvthumbup_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 Lisp_Object Qvthumbdown_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 Lisp_Object Qhscrollbar_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 Lisp_Object Qhslider_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 Lisp_Object Qhthumbleft_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 Lisp_Object Qhthumbright_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 /* Map an X window that implements a scroll bar to the Emacs screen it
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 belongs to. Also store in *PART a symbol identifying which part of
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 the scroll bar it is. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 struct screen *
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 x_window_to_scrollbar (wdesc, part_ptr, prefix_ptr)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 int wdesc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 Lisp_Object *part_ptr;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 enum scroll_bar_prefix *prefix_ptr;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 Lisp_Object tail, screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 for (tail = Vscreen_list; CONSP (tail); tail = XCONS (tail)->cdr)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 screen = XCONS (tail)->car;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 if (XTYPE (screen) != Lisp_Screen)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 s = XSCREEN (screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 if (part_ptr == 0 && prefix_ptr == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 if (s->display.x->v_scrollbar == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 *part_ptr = Qvscrollbar_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 *prefix_ptr = VSCROLL_BAR_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 else if (s->display.x->v_slider == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 *part_ptr = Qvslider_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 *prefix_ptr = VSCROLL_SLIDER_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 else if (s->display.x->v_thumbup == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 *part_ptr = Qvthumbup_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 *prefix_ptr = VSCROLL_THUMBUP_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 else if (s->display.x->v_thumbdown == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 *part_ptr = Qvthumbdown_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 *prefix_ptr = VSCROLL_THUMBDOWN_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 else if (s->display.x->h_scrollbar == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 *part_ptr = Qhscrollbar_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 *prefix_ptr = HSCROLL_BAR_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 else if (s->display.x->h_slider == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 *part_ptr = Qhslider_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 *prefix_ptr = HSCROLL_SLIDER_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 else if (s->display.x->h_thumbleft == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 *part_ptr = Qhthumbleft_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 *prefix_ptr = HSCROLL_THUMBLEFT_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 else if (s->display.x->h_thumbright == wdesc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 *part_ptr = Qhthumbright_part;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 *prefix_ptr = HSCROLL_THUMBRIGHT_PREFIX;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 return s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 return 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 /* Connect the screen-parameter names for X screens
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 to the ways of passing the parameter values to the window system.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 The name of a parameter, as a Lisp symbol,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 has an `x-screen-parameter' property which is an integer in Lisp
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 but can be interpreted as an `enum x_screen_parm' in C. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 enum x_screen_parm
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 X_PARM_FOREGROUND_COLOR,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 X_PARM_BACKGROUND_COLOR,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 X_PARM_MOUSE_COLOR,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 X_PARM_CURSOR_COLOR,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 X_PARM_BORDER_COLOR,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 X_PARM_ICON_TYPE,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 X_PARM_FONT,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 X_PARM_BORDER_WIDTH,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 X_PARM_INTERNAL_BORDER_WIDTH,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 X_PARM_NAME,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 X_PARM_AUTORAISE,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 X_PARM_AUTOLOWER,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 X_PARM_VERT_SCROLLBAR,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 X_PARM_HORIZ_SCROLLBAR,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 struct x_screen_parm_table
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 char *name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 void (*setter)( /* struct screen *screen, Lisp_Object val, oldval */ );
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 void x_set_foreground_color ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 void x_set_background_color ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 void x_set_mouse_color ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 void x_set_cursor_color ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 void x_set_border_color ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 void x_set_icon_type ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 void x_set_font ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 void x_set_border_width ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 void x_set_internal_border_width ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 void x_set_name ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 void x_set_autoraise ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 void x_set_autolower ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 void x_set_vertical_scrollbar ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 void x_set_horizontal_scrollbar ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 static struct x_screen_parm_table x_screen_parms[] =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 "foreground-color", x_set_foreground_color,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 "background-color", x_set_background_color,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 "mouse-color", x_set_mouse_color,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 "cursor-color", x_set_cursor_color,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 "border-color", x_set_border_color,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 "icon-type", x_set_icon_type,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 "font", x_set_font,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 "border-width", x_set_border_width,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 "internal-border-width", x_set_internal_border_width,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 "name", x_set_name,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 "autoraise", x_set_autoraise,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 "autolower", x_set_autolower,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 "vertical-scrollbar", x_set_vertical_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 "horizontal-scrollbar", x_set_horizontal_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 /* Attach the `x-screen-parameter' properties to
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 the Lisp symbol names of parameters relevant to X. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 init_x_parm_symbols ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 int i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 Qx_screen_parameter = intern ("x-screen-parameter");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 for (i = 0; i < sizeof (x_screen_parms)/sizeof (x_screen_parms[0]); i++)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 Fput (intern (x_screen_parms[i].name), Qx_screen_parameter,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 make_number (i));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 /* Report to X that a screen parameter of screen S is being set or changed.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 PARAM is the symbol that says which parameter.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 VAL is the new value.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 OLDVAL is the old value.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 If the parameter is not specially recognized, do nothing;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 otherwise the `x_set_...' function for this parameter. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 x_set_screen_param (s, param, val, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 register struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 Lisp_Object param;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 register Lisp_Object val;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 register Lisp_Object oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 register Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 tem = Fget (param, Qx_screen_parameter);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 if (XTYPE (tem) == Lisp_Int
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 && XINT (tem) >= 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 && XINT (tem) < sizeof (x_screen_parms)/sizeof (x_screen_parms[0]))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 (*x_screen_parms[XINT (tem)].setter)(s, val, oldval);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 /* Insert a description of internally-recorded parameters of screen X
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 into the parameter alist *ALISTPTR that is to be given to the user.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 Only parameters that are specific to the X window system
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 and whose values are not correctly recorded in the screen's
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 param_alist need to be considered here. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 x_report_screen_params (s, alistptr)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 Lisp_Object *alistptr;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 char buf[16];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 store_in_alist (alistptr, "left", make_number (s->display.x->left_pos));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 store_in_alist (alistptr, "top", make_number (s->display.x->top_pos));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 store_in_alist (alistptr, "border-width",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 make_number (s->display.x->border_width));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 store_in_alist (alistptr, "internal-border-width",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 make_number (s->display.x->internal_border_width));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 sprintf (buf, "%d", s->display.x->window_desc);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 store_in_alist (alistptr, "window-id",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 build_string (buf));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 /* Decide if color named COLOR is valid for the display
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 associated with the selected screen. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 int
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 defined_color (color, color_def)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 char *color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 Color *color_def;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 register int foo;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 Colormap screen_colormap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 screen_colormap
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 = DefaultColormap (x_current_display, XDefaultScreen (x_current_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 foo = XParseColor (x_current_display, screen_colormap,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 color, color_def)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 && XAllocColor (x_current_display, screen_colormap, color_def);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 foo = XParseColor (color, color_def) && XGetHardwareColor (color_def);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 if (foo)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 return 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 return 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 /* Given a string ARG naming a color, compute a pixel value from it
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 suitable for screen S.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 If S is not a color screen, return DEF (default) regardless of what
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 ARG says. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 int
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 x_decode_color (arg, def)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 Lisp_Object arg;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 int def;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 Color cdef;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 CHECK_STRING (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 if (strcmp (XSTRING (arg)->data, "black") == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 return BLACK_PIX_DEFAULT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 else if (strcmp (XSTRING (arg)->data, "white") == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 return WHITE_PIX_DEFAULT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 if (XFASTINT (x_screen_planes) <= 2)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 return def;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 if (DISPLAY_CELLS <= 2)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 return def;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 if (defined_color (XSTRING (arg)->data, &cdef))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 return cdef.pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 Fsignal (Qundefined_color, Fcons (arg, Qnil));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 /* Functions called only from `x_set_screen_param'
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 to set individual parameters.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 If s->display.x->window_desc is 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 the screen is being created and its X-window does not exist yet.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 In that case, just record the parameter's new value
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 in the standard place; do not attempt to change the window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 x_set_foreground_color (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 s->display.x->foreground_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 XSetForeground (x_current_display, s->display.x->normal_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 s->display.x->foreground_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 XSetBackground (x_current_display, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 s->display.x->foreground_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 if (s->display.x->v_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 XSetWindowBorder (x_current_display, s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 s->display.x->foreground_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 slider_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 gray_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 up_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 up_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 down_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 down_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->v_thumbup,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->v_thumbdown,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->v_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 XClearWindow (XDISPLAY s->display.x->v_thumbup);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 XClearWindow (XDISPLAY s->display.x->v_thumbdown);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 XClearWindow (XDISPLAY s->display.x->v_slider);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 XFreePixmap (x_current_display, down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 XFreePixmap (x_current_display, up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 XFreePixmap (x_current_display, slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 if (s->display.x->h_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 XSetWindowBorder (x_current_display, s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 s->display.x->foreground_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 slider_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 gray_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 left_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 up_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 right_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 down_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->h_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->h_thumbleft,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 left_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->h_thumbright,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 right_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 XClearWindow (XDISPLAY s->display.x->h_thumbleft);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 XClearWindow (XDISPLAY s->display.x->h_thumbright);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 XClearWindow (XDISPLAY s->display.x->h_slider);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 XFreePixmap (x_current_display, slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 XFreePixmap (x_current_display, left_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 XFreePixmap (x_current_display, right_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 #endif /* HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 if (s->visible)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 redraw_screen (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 x_set_background_color (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 Pixmap temp;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 int mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 s->display.x->background_pixel = x_decode_color (arg, WHITE_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 /* The main screen. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 XSetBackground (x_current_display, s->display.x->normal_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 XSetForeground (x_current_display, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 XSetWindowBackground (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 /* Scroll bars. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 if (s->display.x->v_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 XSetWindowBackground (x_current_display, s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 slider_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 gray_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 up_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 up_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 down_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 down_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->v_thumbup,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->v_thumbdown,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->v_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 XClearWindow (XDISPLAY s->display.x->v_thumbup);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 XClearWindow (XDISPLAY s->display.x->v_thumbdown);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 XClearWindow (XDISPLAY s->display.x->v_slider);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 XFreePixmap (x_current_display, down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 XFreePixmap (x_current_display, up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 XFreePixmap (x_current_display, slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 if (s->display.x->h_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 XSetWindowBackground (x_current_display, s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 slider_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 gray_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 left_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 up_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 right_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 XCreatePixmapFromBitmapData (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 down_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->h_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->h_thumbleft,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 left_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 XSetWindowBackgroundPixmap (XDISPLAY s->display.x->h_thumbright,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 right_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 XClearWindow (XDISPLAY s->display.x->h_thumbleft);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 XClearWindow (XDISPLAY s->display.x->h_thumbright);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 XClearWindow (XDISPLAY s->display.x->h_slider);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 XFreePixmap (x_current_display, slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 XFreePixmap (x_current_display, left_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 XFreePixmap (x_current_display, right_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 temp = XMakeTile (s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 XChangeBackground (s->display.x->window_desc, temp);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 XFreePixmap (temp);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 if (s->visible)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 redraw_screen (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 x_set_mouse_color (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 Cursor cursor, nontext_cursor, mode_cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 int mask_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 if (!EQ (Qnil, arg))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 s->display.x->mouse_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 mask_color = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 /* No invisible pointers. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 if (mask_color == s->display.x->mouse_pixel
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 && mask_color == s->display.x->background_pixel)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 s->display.x->mouse_pixel = s->display.x->foreground_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 if (!EQ (Qnil, Vx_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 CHECK_NUMBER (Vx_pointer_shape, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 cursor = XCreateFontCursor (x_current_display, XINT (Vx_pointer_shape));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 cursor = XCreateFontCursor (x_current_display, XC_xterm);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 if (!EQ (Qnil, Vx_nontext_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 CHECK_NUMBER (Vx_nontext_pointer_shape, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 nontext_cursor = XCreateFontCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 XINT (Vx_nontext_pointer_shape));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 nontext_cursor = XCreateFontCursor (x_current_display, XC_left_ptr);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771 if (!EQ (Qnil, Vx_mode_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 CHECK_NUMBER (Vx_mode_pointer_shape, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 mode_cursor = XCreateFontCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 XINT (Vx_mode_pointer_shape));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 mode_cursor = XCreateFontCursor (x_current_display, XC_xterm);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 XColor fore_color, back_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 fore_color.pixel = s->display.x->mouse_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 back_color.pixel = mask_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785 XQueryColor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 DefaultColormap (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 DefaultScreen (x_current_display)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 &fore_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 XQueryColor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 DefaultColormap (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791 DefaultScreen (x_current_display)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793 XRecolorCursor (x_current_display, cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 &fore_color, &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 XRecolorCursor (x_current_display, nontext_cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 &fore_color, &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
797 XRecolorCursor (x_current_display, mode_cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
798 &fore_color, &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
799 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800 #else /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
801 cursor = XCreateCursor (16, 16, MouseCursor, MouseMask,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803 s->display.x->mouse_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805 GXcopy);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806 #endif /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 XDefineCursor (XDISPLAY s->display.x->window_desc, cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 if (cursor != s->display.x->text_cursor && s->display.x->text_cursor != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 XFreeCursor (XDISPLAY s->display.x->text_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 s->display.x->text_cursor = cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 if (nontext_cursor != s->display.x->nontext_cursor
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 && s->display.x->nontext_cursor != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
819 XFreeCursor (XDISPLAY s->display.x->nontext_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 s->display.x->nontext_cursor = nontext_cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 if (mode_cursor != s->display.x->modeline_cursor
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 && s->display.x->modeline_cursor != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824 XFreeCursor (XDISPLAY s->display.x->modeline_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825 s->display.x->modeline_cursor = mode_cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 #endif /* HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 XFlushQueue ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
831
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
833 x_set_cursor_color (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
834 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 unsigned long fore_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
839 if (!EQ (Vx_cursor_fore_pixel, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
840 fore_pixel = x_decode_color (Vx_cursor_fore_pixel, WHITE_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
842 fore_pixel = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
843 s->display.x->cursor_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844 /* No invisible cursors */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845 if (s->display.x->cursor_pixel == s->display.x->background_pixel)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 s->display.x->cursor_pixel == s->display.x->mouse_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
848 if (s->display.x->cursor_pixel == fore_pixel)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849 fore_pixel = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
853 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 XSetBackground (x_current_display, s->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 s->display.x->cursor_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 XSetForeground (x_current_display, s->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859 fore_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 #endif /* HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863 if (s->visible)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865 x_display_cursor (s, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 x_display_cursor (s, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871 /* Set the border-color of screen S to value described by ARG.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872 ARG can be a string naming a color.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 The border-color is used for the border that is drawn by the X server.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
874 Note that this does not fully take effect if done before
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875 S has an x-window; it must be redone when the window is created.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
876
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 Note: this is done in two routines because of the way X10 works.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
878
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 Note: under X11, this is normally the province of the window manager,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880 and so emacs' border colors may be overridden. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 x_set_border_color (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
884 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
885 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
886 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 unsigned char *str;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 int pix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 CHECK_STRING (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 str = XSTRING (arg)->data;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 #ifndef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 if (!strcmp (str, "grey") || !strcmp (str, "Grey")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 || !strcmp (str, "gray") || !strcmp (str, "Gray"))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 pix = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 #endif /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 pix = x_decode_color (arg, BLACK_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 x_set_border_pixel (s, pix);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905 /* Set the border-color of screen S to pixel value PIX.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 Note that this does not fully take effect if done before
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 S has an x-window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 x_set_border_pixel (s, pix)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 int pix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
912 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913 s->display.x->border_pixel = pix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 if (s->display.x->window_desc != 0 && s->display.x->border_width > 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 Pixmap temp;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 int mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 XSetWindowBorder (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923 pix);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
924 if (s->display.x->h_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
925 XSetWindowBorder (x_current_display, s->display.x->h_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 pix);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
927 if (s->display.x->v_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928 XSetWindowBorder (x_current_display, s->display.x->v_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 pix);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 if (pix < 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 temp = XMakePixmap ((Bitmap) XStoreBitmap (16, 16, gray_bits),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 temp = XMakeTile (pix);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 XChangeBorder (s->display.x->window_desc, temp);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937 XFreePixmap (XDISPLAY temp);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941 if (s->visible)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942 redraw_screen (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
946 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947 x_set_icon_type (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
951 Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 int result;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 if (EQ (oldval, Qnil) == EQ (arg, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
956
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
958 if (NULL (arg))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
959 result = x_text_icon (s, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 result = x_bitmap_icon (s, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 if (result)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 error ("No icon window available.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
967 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
968
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
969 /* If the window was unmapped (and its icon was mapped),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970 the new icon is not mapped, so map the window in its stead. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 if (s->visible)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 XMapWindow (XDISPLAY s->display.x->window_desc);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 XFlushQueue ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
975 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
978 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979 x_set_font (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 unsigned char *name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 int result;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
986 CHECK_STRING (arg, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
987 name = XSTRING (arg)->data;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
988
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
989 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
990 result = x_new_font (s, name);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
991 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
992
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
993 if (result)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
994 error ("Font \"%s\" is not defined", name);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
995 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
997 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998 x_set_border_width (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
999 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1000 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1001 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1002 CHECK_NUMBER (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004 if (XINT (arg) == s->display.x->border_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1006
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1008 error ("Cannot change the border width of a window");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1009
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1010 s->display.x->border_width = XINT (arg);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1011 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1012
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1013 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014 x_set_internal_border_width (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1015 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1016 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1017 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1018 int mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1019 int old = s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1020
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1021 CHECK_NUMBER (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1022 s->display.x->internal_border_width = XINT (arg);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1023 if (s->display.x->internal_border_width < 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1024 s->display.x->internal_border_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1025
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1026 if (s->display.x->internal_border_width == old)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1027 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1029 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1030 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1031 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1032 x_set_window_size (s, s->width, s->height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1033 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1034 x_set_resize_hint (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1035 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1036 XFlushQueue ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1037 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1038 SET_SCREEN_GARBAGED (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1039 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1040 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1041
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1042 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1043 x_set_name (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1044 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1045 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1046 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1047 CHECK_STRING (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1048
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1049 if (s->display.x->window_desc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1050 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1051 s->name = arg;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1052 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1053 XStoreName (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1054 (char *) XSTRING (arg)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1055 XSetIconName (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1056 (char *) XSTRING (arg)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1057 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1058 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1059 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1060
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1061 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1062 x_set_autoraise (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1063 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1064 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 s->auto_raise = !EQ (Qnil, arg);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1067 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 x_set_autolower (s, arg, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1071 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1072 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1073 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1074 s->auto_lower = !EQ (Qnil, arg);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1075 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1076
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1077 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1078 int n_faces;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1079
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1080 x_set_face (scr, font, background, foreground, stipple)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1081 struct screen *scr;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1082 XFontStruct *font;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1083 unsigned long background, foreground;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1084 Pixmap stipple;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1085 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1086 XGCValues gc_values;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1087 GC temp_gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1088 unsigned long gc_mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1089 struct face *new_face;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1090 unsigned int width = 16;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1091 unsigned int height = 16;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1092
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1093 if (n_faces == MAX_FACES_AND_GLYPHS)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1094 return 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1095
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1096 /* Create the Graphics Context. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1097 gc_values.font = font->fid;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1098 gc_values.foreground = foreground;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1099 gc_values.background = background;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1100 gc_values.line_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1101 gc_mask = GCLineWidth | GCFont | GCForeground | GCBackground;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1102 if (stipple)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1103 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1104 gc_values.stipple
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1105 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1106 (char *) stipple, width, height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1107 gc_mask |= GCStipple;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1108 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1109
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1110 temp_gc = XCreateGC (x_current_display, scr->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1111 gc_mask, &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1112 if (!temp_gc)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1113 return 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1114 new_face = (struct face *) xmalloc (sizeof (struct face));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1115 if (!new_face)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1116 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1117 XFreeGC (x_current_display, temp_gc);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1118 return 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1119 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1120
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1121 new_face->font = font;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1122 new_face->foreground = foreground;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1123 new_face->background = background;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1124 new_face->face_gc = temp_gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1125 if (stipple)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1126 new_face->stipple = gc_values.stipple;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1127
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1128 x_face_table[++n_faces] = new_face;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1129 return 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1130 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1131
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1132 x_set_glyph (scr, glyph)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1133 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1134 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1135
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1136 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1137 DEFUN ("x-set-face-font", Fx_set_face_font, Sx_set_face_font, 4, 2, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1138 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1139 in colors FOREGROUND and BACKGROUND.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1140 (face_code, font_name, foreground, background)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1141 Lisp_Object face_code;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1142 Lisp_Object font_name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1143 Lisp_Object foreground;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1144 Lisp_Object background;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1145 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1146 register struct face *fp; /* Current face info. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1147 register int fn; /* Face number. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1148 register FONT_TYPE *f; /* Font data structure. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1149 unsigned char *newname;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1150 int fg, bg;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1151 GC temp_gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1152 XGCValues gc_values;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1153
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1154 /* Need to do something about this. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1155 Drawable drawable = selected_screen->display.x->window_desc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1156
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1157 CHECK_NUMBER (face_code, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1158 CHECK_STRING (font_name, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1159
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1160 if (EQ (foreground, Qnil) || EQ (background, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1161 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1162 fg = selected_screen->display.x->foreground_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1163 bg = selected_screen->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1164 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1165 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1166 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1167 CHECK_NUMBER (foreground, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1168 CHECK_NUMBER (background, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1169
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1170 fg = x_decode_color (XINT (foreground), BLACK_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1171 bg = x_decode_color (XINT (background), WHITE_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1172 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1173
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1174 fn = XINT (face_code);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1175 if ((fn < 1) || (fn > 255))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1176 error ("Invalid face code, %d", fn);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1177
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1178 newname = XSTRING (font_name)->data;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1179 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1180 f = (*newname == 0 ? 0 : XGetFont (newname));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1181 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1182 if (f == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1183 error ("Font \"%s\" is not defined", newname);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1184
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1185 fp = x_face_table[fn];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1186 if (fp == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1187 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1188 x_face_table[fn] = fp = (struct face *) xmalloc (sizeof (struct face));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1189 bzero (fp, sizeof (struct face));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1190 fp->face_type = x_pixmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1191 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1192 else if (FACE_IS_FONT (fn))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1193 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1194 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1195 XFreeGC (FACE_FONT (fn));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1196 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1197 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1198 else if (FACE_IS_IMAGE (fn)) /* This should not happen... */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1199 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1200 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1201 XFreePixmap (x_current_display, FACE_IMAGE (fn));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1202 fp->face_type = x_font;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1203 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1204 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1205 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1206 abort ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1207
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1208 fp->face_GLYPH.font_desc.font = f;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1209 gc_values.font = f->fid;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1210 gc_values.foreground = fg;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1211 gc_values.background = bg;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1212 fp->face_GLYPH.font_desc.face_gc = XCreateGC (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1213 drawable, GCFont | GCForeground
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1214 | GCBackground, &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1215 fp->face_GLYPH.font_desc.font_width = FONT_WIDTH (f);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1216 fp->face_GLYPH.font_desc.font_height = FONT_HEIGHT (f);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1217
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1218 return face_code;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1219 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1220 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1221 #else /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1222 DEFUN ("x-set-face", Fx_set_face, Sx_set_face, 4, 4, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1223 "Specify face table entry FACE-CODE to be the font named by FONT,\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1224 in colors FOREGROUND and BACKGROUND.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1225 (face_code, font_name, foreground, background)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1226 Lisp_Object face_code;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1227 Lisp_Object font_name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1228 Lisp_Object foreground;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1229 Lisp_Object background;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1230 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1231 register struct face *fp; /* Current face info. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1232 register int fn; /* Face number. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1233 register FONT_TYPE *f; /* Font data structure. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1234 unsigned char *newname;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1235
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1236 CHECK_NUMBER (face_code, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1237 CHECK_STRING (font_name, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1238
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1239 fn = XINT (face_code);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1240 if ((fn < 1) || (fn > 255))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1241 error ("Invalid face code, %d", fn);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1242
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1243 /* Ask the server to find the specified font. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1244 newname = XSTRING (font_name)->data;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1245 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1246 f = (*newname == 0 ? 0 : XGetFont (newname));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1247 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1248 if (f == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1249 error ("Font \"%s\" is not defined", newname);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1250
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1251 /* Get the face structure for face_code in the face table.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1252 Make sure it exists. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1253 fp = x_face_table[fn];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1254 if (fp == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1255 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1256 x_face_table[fn] = fp = (struct face *) xmalloc (sizeof (struct face));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1257 bzero (fp, sizeof (struct face));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1258 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1259
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1260 /* If this face code already exists, get rid of the old font. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1261 if (fp->font != 0 && fp->font != f)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1262 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1263 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1264 XLoseFont (fp->font);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1265 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1266 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1267
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1268 /* Store the specified information in FP. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1269 fp->fg = x_decode_color (foreground, BLACK_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1270 fp->bg = x_decode_color (background, WHITE_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1271 fp->font = f;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1272
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1273 return face_code;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1274 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1275 #endif /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1276
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1277 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1278 /* This is excluded because there is no painless way
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1279 to get or to remember the name of the font. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1280
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1281 DEFUN ("x-get-face", Fx_get_face, Sx_get_face, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1282 "Get data defining face code FACE. FACE is an integer.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1283 The value is a list (FONT FG-COLOR BG-COLOR).")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1284 (face)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1285 Lisp_Object face;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1286 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1287 register struct face *fp; /* Current face info. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1288 register int fn; /* Face number. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1289
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1290 CHECK_NUMBER (face, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1291 fn = XINT (face);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1292 if ((fn < 1) || (fn > 255))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1293 error ("Invalid face code, %d", fn);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1294
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1295 /* Make sure the face table exists and this face code is defined. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1296 if (x_face_table == 0 || x_face_table[fn] == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1297 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1298
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1299 fp = x_face_table[fn];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1300
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1301 return Fcons (build_string (fp->name),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1302 Fcons (make_number (fp->fg),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1303 Fcons (make_number (fp->bg), Qnil)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1304 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1305 #endif /* 0 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1306
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1307 /* Subroutines of creating an X screen. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1308
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1309 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1310 extern char *x_get_string_resource ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1311 extern XrmDatabase x_load_resources ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1312
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1313 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 1, 3, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1314 "Retrieve the value of ATTRIBUTE from the X defaults database. This\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1315 searches using a key of the form \"INSTANCE.ATTRIBUTE\", with class\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1316 \"Emacs\", where INSTANCE is the name under which Emacs was invoked.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1317 \n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1318 Optional arguments COMPONENT and CLASS specify the component for which\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1319 we should look up ATTRIBUTE. When specified, Emacs searches using a\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320 key of the form INSTANCE.COMPONENT.ATTRIBUTE, with class \"Emacs.CLASS\".")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 (attribute, name, class)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1322 Lisp_Object attribute, name, class;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1323 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1324 register char *value;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1325 char *name_key;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1326 char *class_key;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1327
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1328 CHECK_STRING (attribute, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329 if (!NULL (name))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 CHECK_STRING (name, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 if (!NULL (class))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 CHECK_STRING (class, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1333 if (NULL (name) != NULL (class))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1334 error ("x-get-resource: must specify both NAME and CLASS or neither");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1336 name_key = (char *) alloca (XSTRING (invocation_name)->size + 1
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1337 + (NULL (name) ? 0 : XSTRING (name)->size + 1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1338 + XSTRING (attribute)->size + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1339
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340 if (NULL (name))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 sprintf (name_key, "%s.%s",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343 XSTRING (invocation_name)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1344 XSTRING (attribute)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 class_key = EMACS_CLASS;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1349 class_key = (char *) alloca (sizeof (EMACS_CLASS)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1350 + XSTRING (class)->size + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1351
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1352 sprintf (name_key, "%s.%s.%s",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1353 XSTRING (invocation_name)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1354 XSTRING (name)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 XSTRING (attribute)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356 sprintf (class_key, "%s.%s",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357 XSTRING (invocation_name)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1358 XSTRING (class)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1359 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1361 value = x_get_string_resource (xrdb, name_key, class_key);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1362
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1363 if (value != (char *) 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 return build_string (value);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1365 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1366 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1367 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1368
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1369 #else /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1370
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371 DEFUN ("x-get-default", Fx_get_default, Sx_get_default, 1, 2, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1372 "Get X default ATTRIBUTE from the system, or nil if no default.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1373 Value is a string (when not nil) and ATTRIBUTE is also a string.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1374 The defaults are specified in the file `~/.Xdefaults'.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1375 (arg, name)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1376 Lisp_Object arg, name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1377 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1378 register unsigned char *value;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1379
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1380 CHECK_STRING (arg, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1381
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1382 value = (unsigned char *) XGetDefault (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1383 XSTRING (invocation_name)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1384 XSTRING (arg)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1385 if (value == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1386 /* Try reversing last two args, in case this is the buggy version of X. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1387 value = (unsigned char *) XGetDefault (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1388 XSTRING (arg)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1389 XSTRING (invocation_name)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390 if (value != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1391 return build_string (value);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1392 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1393 return (Qnil);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1394 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1395
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1396 #define Fx_get_resource Fx_get_default
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1397
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398 #endif /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1400 /* Return the value of parameter PARAM.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1401 First search ALIST, then the X defaults database.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1402 If XPROPNAME starts with `#', convert the X default to an integer;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1403 otherwise, to a string.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404 If no X-default is specified, return nil. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406 static Lisp_Object
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 x_get_arg (alist, param, screen_name, xpropname)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1408 Lisp_Object alist, param, screen_name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 char *xpropname;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 register Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1412
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413 tem = Fassq (param, alist);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1414 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 tem = Fassq (param, Vdefault_screen_alist);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1417 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 if (xpropname == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419 return tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1420
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421 if (*xpropname == '#')
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1422 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1423 tem = Fx_get_resource (build_string (xpropname + 1),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424 screen_name, SCREEN_CLASS);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 return make_number (atoi (XSTRING (tem)->data));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1428 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1429
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1430 if (*xpropname == '?')
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432 tem = Fx_get_resource (build_string (xpropname + 1),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433 screen_name, SCREEN_CLASS);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1434 if (XTYPE (tem) == Lisp_String)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1435 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1436 tem = Fdowncase (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1437 if (!strcmp (XSTRING (tem)->data, "on")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1438 || !strcmp (XSTRING (tem)->data, "true"))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1439 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1440 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1442 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1443
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444 return Fx_get_resource (build_string (xpropname),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1445 screen_name, SCREEN_CLASS);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1447 return Fcdr (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1449
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1450 /* Record in screen S the specified or default value according to ALIST
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1451 of the parameter named PARAM (a Lisp symbol).
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1452 If no value is specified for PARAM, look for an X default for XPROP
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1453 on the screen named NAME.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1454 If that is not found either, use the value DEFLT. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1456 static Lisp_Object
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1457 x_default_parameter (s, alist, propname, deflt, xprop)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1458 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1459 Lisp_Object alist;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1460 char *propname;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1461 Lisp_Object deflt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1462 char *xprop;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1463 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1464 Lisp_Object propsym = intern (propname);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1465 Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1466
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1467 tem = x_get_arg (alist, propsym, s->name, xprop);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1468 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1469 tem = deflt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1470 store_screen_param (s, propsym, tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1471 x_set_screen_param (s, propsym, tem, Qnil);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1472 return tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1473 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1474
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1475 DEFUN ("x-geometry", Fx_geometry, Sx_geometry, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1476 "Parse an X-style geometry string STRING.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1477 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1478 (string)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1479 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1480 int geometry, x, y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1481 unsigned int width, height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1482 Lisp_Object values[4];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1483
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1484 CHECK_STRING (string, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1485
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1486 geometry = XParseGeometry ((char *) XSTRING (string)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1487 &x, &y, &width, &height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1488
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1489 switch (geometry & 0xf) /* Mask out {X,Y}Negative */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1490 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491 case (XValue | YValue):
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1492 /* What's one pixel among friends?
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1493 Perhaps fix this some day by returning symbol `extreme-top'... */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1494 if (x == 0 && (geometry & XNegative))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1495 x = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1496 if (y == 0 && (geometry & YNegative))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1497 y = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1498 values[0] = Fcons (intern ("left"), make_number (x));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1499 values[1] = Fcons (intern ("top"), make_number (y));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1500 return Flist (2, values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1501 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1502
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1503 case (WidthValue | HeightValue):
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1504 values[0] = Fcons (intern ("width"), make_number (width));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1505 values[1] = Fcons (intern ("height"), make_number (height));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1506 return Flist (2, values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1507 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1508
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1509 case (XValue | YValue | WidthValue | HeightValue):
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1510 if (x == 0 && (geometry & XNegative))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1511 x = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1512 if (y == 0 && (geometry & YNegative))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1513 y = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1514 values[0] = Fcons (intern ("width"), make_number (width));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1515 values[1] = Fcons (intern ("height"), make_number (height));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1516 values[2] = Fcons (intern ("left"), make_number (x));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1517 values[3] = Fcons (intern ("top"), make_number (y));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1518 return Flist (4, values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1519 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1520
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1521 case 0:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1522 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1523
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1524 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1525 error ("Must specify x and y value, and/or width and height");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1526 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1527 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1528
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1529 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1530 /* Calculate the desired size and position of this window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1531 or set rubber-band prompting if none. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1532
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1533 #define DEFAULT_ROWS 40
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1534 #define DEFAULT_COLS 80
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1535
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1536 static
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1537 x_figure_window_size (s, parms)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1538 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1539 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1540 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1541 register Lisp_Object tem0, tem1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 int height, width, left, top;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1543 register int geometry;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1544 long window_prompting = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1545
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1546 /* Default values if we fall through.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1547 Actually, if that happens we should get
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1548 window manager prompting. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1549 s->width = DEFAULT_COLS;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1550 s->height = DEFAULT_ROWS;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1551 s->display.x->top_pos = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1552 s->display.x->left_pos = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1553
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1554 tem0 = x_get_arg (parms, intern ("height"), s->name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1555 tem1 = x_get_arg (parms, intern ("width"), s->name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1556 if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1557 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1558 CHECK_NUMBER (tem0, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1559 CHECK_NUMBER (tem1, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1560 s->height = XINT (tem0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1561 s->width = XINT (tem1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1562 window_prompting |= USSize;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1563 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1564 else if (! EQ (tem0, Qnil) || ! EQ (tem1, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1565 error ("Must specify *both* height and width");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1566
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1567 s->display.x->pixel_width = (FONT_WIDTH (s->display.x->font) * s->width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1568 + 2 * s->display.x->internal_border_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1569 s->display.x->pixel_height = (FONT_HEIGHT (s->display.x->font) * s->height
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1570 + 2 * s->display.x->internal_border_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1571
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1572 tem0 = x_get_arg (parms, intern ("top"), s->name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1573 tem1 = x_get_arg (parms, intern ("left"), s->name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1574 if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1575 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1576 CHECK_NUMBER (tem0, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1577 CHECK_NUMBER (tem1, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1578 s->display.x->top_pos = XINT (tem0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1579 s->display.x->left_pos = XINT (tem1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1580 x_calc_absolute_position (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1581 window_prompting |= USPosition;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1582 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1583 else if (! EQ (tem0, Qnil) || ! EQ (tem1, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1584 error ("Must specify *both* top and left corners");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1585
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1586 switch (window_prompting)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1587 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1588 case USSize | USPosition:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1589 return window_prompting;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1590 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 case USSize: /* Got the size, need the position. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1593 window_prompting |= PPosition;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1594 return window_prompting;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1596
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1597 case USPosition: /* Got the position, need the size. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598 window_prompting |= PSize;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1599 return window_prompting;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1600 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1601
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1602 case 0: /* Got nothing, take both from geometry. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603 window_prompting |= PPosition | PSize;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1604 return window_prompting;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1605 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1606
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1607 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1608 /* Somehow a bit got set in window_prompting that we didn't
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1609 put there. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1610 abort ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1611 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1612 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1613
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1614 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1615 x_window (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1616 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618 XSetWindowAttributes attributes;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619 unsigned long attribute_mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1620 XClassHint class_hints;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1621
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1622 attributes.background_pixel = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1623 attributes.border_pixel = s->display.x->border_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1624 attributes.bit_gravity = StaticGravity;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1625 attributes.backing_store = NotUseful;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1626 attributes.save_under = True;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1627 attributes.event_mask = STANDARD_EVENT_SET;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1628 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1629 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1630 | CWBackingStore | CWSaveUnder
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1631 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1632 | CWEventMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1633
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1634 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1635 s->display.x->window_desc
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1636 = XCreateWindow (x_current_display, ROOT_WINDOW,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1637 s->display.x->left_pos,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1638 s->display.x->top_pos,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1639 PIXEL_WIDTH (s), PIXEL_HEIGHT (s),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640 s->display.x->border_width,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641 CopyFromParent, /* depth */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1642 InputOutput, /* class */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1643 screen_visual, /* set in Fx_open_connection */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1644 attribute_mask, &attributes);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1645
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1646 class_hints.res_name = id_name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1647 class_hints.res_class = EMACS_CLASS;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1648 XSetClassHint (x_current_display, s->display.x->window_desc, &class_hints);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1649
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1650 XDefineCursor (XDISPLAY s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1651 s->display.x->text_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1652 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1653
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1654 if (s->display.x->window_desc == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1655 error ("Unable to create window.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1656 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1657
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1658 /* Handle the icon stuff for this window. Perhaps later we might
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1659 want an x_set_icon_position which can be called interactively as
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1660 well. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1661
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1662 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1663 x_icon (s, parms)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1664 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1665 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1666 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1667 register Lisp_Object tem0,tem1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1668 XWMHints hints;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1669
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1670 /* Set the position of the icon. Note that twm groups all
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1671 icons in an icon window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1672 tem0 = x_get_arg (parms, intern ("icon-left"), s->name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1673 tem1 = x_get_arg (parms, intern ("icon-top"), s->name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1674 if (!EQ (tem0, Qnil) && !EQ (tem1, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1675 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1676 CHECK_NUMBER (tem0, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1677 CHECK_NUMBER (tem1, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1678 hints.icon_x = XINT (tem0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1679 hints.icon_x = XINT (tem0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1680 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 else if (!EQ (tem0, Qnil) || !EQ (tem1, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1682 error ("Both left and top icon corners of icon must be specified");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1683 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1684 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1685 hints.icon_x = s->display.x->left_pos;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1686 hints.icon_y = s->display.x->top_pos;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1687 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1688
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1689 /* Start up iconic or window? */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1690 tem0 = x_get_arg (parms, intern ("iconic-startup"), s->name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1691 if (!EQ (tem0, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1692 hints.initial_state = IconicState;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1693 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1694 hints.initial_state = NormalState; /* the default, actually. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1695 hints.input = False;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1696
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1697 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1698 hints.flags = StateHint | IconPositionHint | InputHint;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1699 XSetWMHints (x_current_display, s->display.x->window_desc, &hints);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1700 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1701 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1702
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1703 /* Make the GC's needed for this window, setting the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1704 background, border and mouse colors; also create the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1705 mouse cursor and the gray border tile. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1706
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1707 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1708 x_make_gc (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1709 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1710 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1711 XGCValues gc_values;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1712 GC temp_gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1713 XImage tileimage;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1714 static char cursor_bits[] =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1715 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1716 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1717 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1718 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1719 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1720 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1721
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1722 /* Create the GC's of this screen.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1723 Note that many default values are used. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1724
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1725 /* Normal video */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1726 gc_values.font = s->display.x->font->fid;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1727 gc_values.foreground = s->display.x->foreground_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1728 gc_values.background = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1729 gc_values.line_width = 0; /* Means 1 using fast algorithm. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1730 s->display.x->normal_gc = XCreateGC (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1731 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1732 GCLineWidth | GCFont
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1733 | GCForeground | GCBackground,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1734 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1735
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1736 /* Reverse video style. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1737 gc_values.foreground = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1738 gc_values.background = s->display.x->foreground_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1739 s->display.x->reverse_gc = XCreateGC (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1740 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1741 GCFont | GCForeground | GCBackground
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1742 | GCLineWidth,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1743 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1744
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1745 /* Cursor has cursor-color background, background-color foreground. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1746 gc_values.foreground = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1747 gc_values.background = s->display.x->cursor_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1748 gc_values.fill_style = FillOpaqueStippled;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1749 gc_values.stipple
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1750 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1751 cursor_bits, 16, 16);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1752 s->display.x->cursor_gc
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1753 = XCreateGC (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1754 (GCFont | GCForeground | GCBackground
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1755 | GCFillStyle | GCStipple | GCLineWidth),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1756 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1757
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1758 /* Create the gray border tile used when the pointer is not in
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1759 the screen. Since this depends on the screen's pixel values,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1760 this must be done on a per-screen basis. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1761 s->display.x->border_tile =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1762 XCreatePixmap (x_current_display, ROOT_WINDOW, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1763 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1764 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1765 gc_values.foreground = s->display.x->foreground_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1766 gc_values.background = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1767 temp_gc = XCreateGC (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1768 (Drawable) s->display.x->border_tile,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1769 GCForeground | GCBackground, &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1770
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1771 /* These are things that should be determined by the server, in
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1772 Fx_open_connection */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1773 tileimage.height = 16;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1774 tileimage.width = 16;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1775 tileimage.xoffset = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1776 tileimage.format = XYBitmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1777 tileimage.data = gray_bits;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1778 tileimage.byte_order = LSBFirst;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1779 tileimage.bitmap_unit = 8;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1780 tileimage.bitmap_bit_order = LSBFirst;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1781 tileimage.bitmap_pad = 8;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1782 tileimage.bytes_per_line = (16 + 7) >> 3;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1783 tileimage.depth = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1784 XPutImage (x_current_display, s->display.x->border_tile, temp_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1785 &tileimage, 0, 0, 0, 0, 16, 16);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1786 XFreeGC (x_current_display, temp_gc);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1787 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1788 #endif /* HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1789
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1790 DEFUN ("x-create-screen", Fx_create_screen, Sx_create_screen,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1791 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1792 "Make a new X window, which is considered a \"screen\" in Emacs terms.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1793 Return an Emacs screen object representing the X window.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1794 ALIST is an alist of screen parameters.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1795 The value of ``x-screen-defaults'' is an additional alist\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1796 of default parameters which apply when not overridden by ALIST.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1797 If the parameters specify that the screen should not have a minibuffer,\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1798 then ``global-minibuffer-screen'' must be a screen whose minibuffer can\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1799 be shared by the new screen.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1800 (parms)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1801 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1802 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1803 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1804 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1805 Lisp_Object screen, tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1806 Lisp_Object name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1807 int minibuffer_only = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1808 long window_prompting = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1809 int width, height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1810
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1811 if (x_current_display == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1812 error ("X windows are not in use or not initialized");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1813
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1814 name = Fassq (intern ("name"), parms);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1815 if (NULL (name))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1816 name = build_string (id_name);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1817 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1818 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1819 if (XTYPE (name) != Lisp_Cons)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1820 /* Fassq should always return nil or a cons! */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1821 abort ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1822 name = XCONS (name)->cdr;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1823 if (XTYPE (name) != Lisp_String)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1824 error ("x-create-screen: name parameter must be a string.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1825 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1826
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1827 tem = x_get_arg (parms, intern ("minibuffer"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1828 if (EQ (tem, intern ("none")))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1829 s = make_screen_without_minibuffer (Qnil);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1830 else if (EQ (tem, intern ("only")))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1831 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1832 s = make_minibuffer_screen ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1833 minibuffer_only = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1834 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1835 else if (! EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1836 s = make_screen_without_minibuffer (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1837 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1838 s = make_screen (1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1839
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1840 /* Set the name; the functions to which we pass s expect the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1841 name to be set. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1842 XSET (s->name, Lisp_String, name);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1844 XSET (screen, Lisp_Screen, s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1845 s->output_method = output_x_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1846 s->display.x = (struct x_display *) xmalloc (sizeof (struct x_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847 bzero (s->display.x, sizeof (struct x_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1848
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849 /* Extract the window parameters from the supplied values
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1850 that are needed to determine window geometry. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1851 x_default_parameter (s, parms, "font",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852 build_string ("9x15"), "font");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1853 x_default_parameter (s, parms, "background-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1854 build_string ("white"), "background");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855 x_default_parameter (s, parms, "border-width",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1856 make_number (2), "#BorderWidth");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1857 x_default_parameter (s, parms, "internal-border-width",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1858 make_number (4), "#InternalBorderWidth");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1859
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1860 /* Also do the stuff which must be set before the window exists. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1861 x_default_parameter (s, parms, "foreground-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1862 build_string ("black"), "foreground");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1863 x_default_parameter (s, parms, "mouse-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1864 build_string ("black"), "mouse");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1865 x_default_parameter (s, parms, "cursor-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1866 build_string ("black"), "cursor");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1867 x_default_parameter (s, parms, "border-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1868 build_string ("black"), "border");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1869
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1870 /* Need to do icon type, auto-raise, auto-lower. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1871
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1872 s->display.x->parent_desc = ROOT_WINDOW;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1873 window_prompting = x_figure_window_size (s, parms);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1874
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1875 x_window (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1876 x_icon (s, parms);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1877 x_make_gc (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1879 /* Dimensions, especially s->height, must be done via change_screen_size.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1880 Change will not be effected unless different from the current
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1881 s->height. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1882 width = s->width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1883 height = s->height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1884 s->height = s->width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1885 change_screen_size (s, height, width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1886 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1887 x_wm_set_size_hint (s, window_prompting);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1888 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1889
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1890 tem = x_get_arg (parms, intern ("unsplittable"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1891 s->no_split = minibuffer_only || EQ (tem, Qt);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1892
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1893 /* Now handle the rest of the parameters. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1894 x_default_parameter (s, parms, "name",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1895 build_string (id_name), "Title");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1896 x_default_parameter (s, parms, "horizontal-scroll-bar",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1897 Qnil, "?HScrollBar");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1898 x_default_parameter (s, parms, "vertical-scroll-bar",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1899 Qnil, "?VScrollBar");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1900
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1901 /* Make the window appear on the screen and enable display. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1902 if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), name, 0), Qt))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1903 x_make_screen_visible (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1904
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1905 return screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1906 #else /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1907 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1908 Lisp_Object screen, tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1909 Lisp_Object name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1910 int pixelwidth, pixelheight;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1911 Cursor cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1912 int height, width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1913 Window parent;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1914 Pixmap temp;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1915 int minibuffer_only = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1916 Lisp_Object vscroll, hscroll;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1917
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1918 if (x_current_display == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1919 error ("X windows are not in use or not initialized");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1920
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1921 name = Fassq (intern ("name"), parms);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1922
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1923 tem = x_get_arg (parms, intern ("minibuffer"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1924 if (EQ (tem, intern ("none")))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1925 s = make_screen_without_minibuffer (Qnil);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1926 else if (EQ (tem, intern ("only")))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1927 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1928 s = make_minibuffer_screen ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1929 minibuffer_only = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1930 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1931 else if (! EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1932 s = make_screen_without_minibuffer (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1933 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1934 s = make_screen (1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1935
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1936 parent = ROOT_WINDOW;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1937
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1938 XSET (screen, Lisp_Screen, s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1939 s->output_method = output_x_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1940 s->display.x = (struct x_display *) xmalloc (sizeof (struct x_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1941 bzero (s->display.x, sizeof (struct x_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1942
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1943 /* Some temprorary default values for height and width. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1944 width = 80;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1945 height = 40;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1946 s->display.x->left_pos = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1947 s->display.x->top_pos = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1948
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1949 /* Give the screen a default name (which may be overridden with PARMS). */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1950
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1951 strncpy (iconidentity, ICONTAG, MAXICID);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1952 if (gethostname (&iconidentity[sizeof (ICONTAG) - 1],
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1953 (MAXICID - 1) - sizeof (ICONTAG)))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1954 iconidentity[sizeof (ICONTAG) - 2] = '\0';
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1955 s->name = build_string (iconidentity);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1956
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1957 /* Extract some window parameters from the supplied values.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1958 These are the parameters that affect window geometry. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1959
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1960 tem = x_get_arg (parms, intern ("font"), name, "BodyFont");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1961 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1962 tem = build_string ("9x15");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1963 x_set_font (s, tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1964 x_default_parameter (s, parms, "border-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1965 build_string ("black"), "Border");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1966 x_default_parameter (s, parms, "background-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1967 build_string ("white"), "Background");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1968 x_default_parameter (s, parms, "foreground-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1969 build_string ("black"), "Foreground");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1970 x_default_parameter (s, parms, "mouse-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1971 build_string ("black"), "Mouse");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1972 x_default_parameter (s, parms, "cursor-color",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1973 build_string ("black"), "Cursor");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1974 x_default_parameter (s, parms, "border-width",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1975 make_number (2), "#BorderWidth");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1976 x_default_parameter (s, parms, "internal-border-width",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1977 make_number (4), "#InternalBorderWidth");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1978 x_default_parameter (s, parms, "auto-raise",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1979 Qnil, "?AutoRaise");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1980
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1981 hscroll = x_get_arg (parms, intern ("horizontal-scroll-bar"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1982 vscroll = x_get_arg (parms, intern ("vertical-scroll-bar"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1983
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1984 if (s->display.x->internal_border_width < 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1985 s->display.x->internal_border_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1986
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1987 tem = x_get_arg (parms, intern ("window-id"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988 if (!EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1989 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1990 WINDOWINFO_TYPE wininfo;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1991 int nchildren;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1992 Window *children, root;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1993
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1994 CHECK_STRING (tem, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1995 s->display.x->window_desc = (Window) atoi (XSTRING (tem)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1996
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1997 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1998 XGetWindowInfo (s->display.x->window_desc, &wininfo);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1999 XQueryTree (s->display.x->window_desc, &parent, &nchildren, &children);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2000 free (children);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2001 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2002
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2003 height = (wininfo.height - 2 * s->display.x->internal_border_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2004 / FONT_HEIGHT (s->display.x->font);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2005 width = (wininfo.width - 2 * s->display.x->internal_border_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2006 / FONT_WIDTH (s->display.x->font);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2007 s->display.x->left_pos = wininfo.x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2008 s->display.x->top_pos = wininfo.y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2009 s->visible = wininfo.mapped != 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2010 s->display.x->border_width = wininfo.bdrwidth;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2011 s->display.x->parent_desc = parent;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2012 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2013 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2014 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2015 tem = x_get_arg (parms, intern ("parent-id"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2016 if (!EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2017 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2018 CHECK_STRING (tem, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2019 parent = (Window) atoi (XSTRING (tem)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2020 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2021 s->display.x->parent_desc = parent;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2022 tem = x_get_arg (parms, intern ("height"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2023 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2024 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2025 tem = x_get_arg (parms, intern ("width"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2026 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2027 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2028 tem = x_get_arg (parms, intern ("top"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2029 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2030 tem = x_get_arg (parms, intern ("left"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2031 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2032 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2033 /* Now TEM is nil if no edge or size was specified.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2034 In that case, we must do rubber-banding. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2035 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2036 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2037 tem = x_get_arg (parms, intern ("geometry"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2038 x_rubber_band (s,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2039 &s->display.x->left_pos, &s->display.x->top_pos,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2040 &width, &height,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2041 (XTYPE (tem) == Lisp_String
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 ? (char *) XSTRING (tem)->data : ""),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2043 XSTRING (s->name)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2044 !NULL (hscroll), !NULL (vscroll));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2045 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2046 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2047 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2048 /* Here if at least one edge or size was specified.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2049 Demand that they all were specified, and use them. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2050 tem = x_get_arg (parms, intern ("height"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2051 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2052 error ("Height not specified");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2053 CHECK_NUMBER (tem, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2054 height = XINT (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2055
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2056 tem = x_get_arg (parms, intern ("width"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2057 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2058 error ("Width not specified");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2059 CHECK_NUMBER (tem, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2060 width = XINT (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2061
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2062 tem = x_get_arg (parms, intern ("top"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2063 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2064 error ("Top position not specified");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2065 CHECK_NUMBER (tem, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2066 s->display.x->left_pos = XINT (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2067
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2068 tem = x_get_arg (parms, intern ("left"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2069 if (EQ (tem, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2070 error ("Left position not specified");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2071 CHECK_NUMBER (tem, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2072 s->display.x->top_pos = XINT (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2073 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2074
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2075 pixelwidth = (width * FONT_WIDTH (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2076 + 2 * s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2077 + (!NULL (vscroll) ? VSCROLL_WIDTH : 0));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2078 pixelheight = (height * FONT_HEIGHT (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2079 + 2 * s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2080 + (!NULL (hscroll) ? HSCROLL_HEIGHT : 0));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2081
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2082 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2083 s->display.x->window_desc
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2084 = XCreateWindow (parent,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2085 s->display.x->left_pos, /* Absolute horizontal offset */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2086 s->display.x->top_pos, /* Absolute Vertical offset */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2087 pixelwidth, pixelheight,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2088 s->display.x->border_width,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2089 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2090 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2091 if (s->display.x->window_desc == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2092 error ("Unable to create window.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2093 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2094
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2095 /* Install the now determined height and width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2096 in the windows and in phys_lines and desired_lines. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2097 /* ??? jla version had 1 here instead of 0. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2098 change_screen_size (s, height, width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2099 XSelectInput (s->display.x->window_desc, KeyPressed | ExposeWindow
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2100 | ButtonPressed | ButtonReleased | ExposeRegion | ExposeCopy
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2101 | EnterWindow | LeaveWindow | UnmapWindow );
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2102 x_set_resize_hint (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2103
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2104 /* Tell the server the window's default name. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2105
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2106 XStoreName (XDISPLAY s->display.x->window_desc, XSTRING (s->name)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2107 /* Now override the defaults with all the rest of the specified
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2108 parms. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2109 tem = x_get_arg (parms, intern ("unsplittable"), name, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2110 s->no_split = minibuffer_only || EQ (tem, Qt);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2111
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2112 /* Do not create an icon window if the caller says not to */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2113 if (!EQ (x_get_arg (parms, intern ("suppress-icon"), name, 0), Qt)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2114 || s->display.x->parent_desc != ROOT_WINDOW)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2115 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2116 x_text_icon (s, iconidentity);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2117 x_default_parameter (s, parms, "icon-type", Qnil, "?BitmapIcon");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2118 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2119
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2120 /* Tell the X server the previously set values of the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2121 background, border and mouse colors; also create the mouse cursor. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2122 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2123 temp = XMakeTile (s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2124 XChangeBackground (s->display.x->window_desc, temp);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2125 XFreePixmap (temp);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2126 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2127 x_set_border_pixel (s, s->display.x->border_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2128
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2129 x_set_mouse_color (s, Qnil, Qnil);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2130
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2131 /* Now override the defaults with all the rest of the specified parms. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2132
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2133 Fmodify_screen_parameters (screen, parms);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2134
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2135 if (!NULL (vscroll))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2136 install_vertical_scrollbar (s, pixelwidth, pixelheight);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2137 if (!NULL (hscroll))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2138 install_horizontal_scrollbar (s, pixelwidth, pixelheight);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2139
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2140 /* Make the window appear on the screen and enable display. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2141
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2142 if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), name, 0), Qt))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2143 x_make_window_visible (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2144 SCREEN_GARBAGED (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2145
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2146 return screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2147 #endif /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2148 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2149
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2150 DEFUN ("focus-screen", Ffocus_screen, Sfocus_screen, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2151 "Set the focus on SCREEN.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2152 (screen)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2153 Lisp_Object screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2154 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2155 CHECK_SCREEN (screen, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2156
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2157 if (SCREEN_IS_X (XSCREEN (screen)))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2158 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2159 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2160 x_focus_on_screen (XSCREEN (screen));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2161 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2162 return screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2163 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2164
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2165 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2166 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2167
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2168 DEFUN ("unfocus-screen", Funfocus_screen, Sunfocus_screen, 0, 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2169 "If a screen has been focused, release it.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2170 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2171 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2172 if (x_focus_screen)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2173 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2174 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2175 x_unfocus_screen (x_focus_screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2176 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2177 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2178
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2179 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2180 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2181
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2182 #ifndef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2183 /* Computes an X-window size and position either from geometry GEO
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2184 or with the mouse.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2185
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2186 S is a screen. It specifies an X window which is used to
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2187 determine which display to compute for. Its font, borders
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2188 and colors control how the rectangle will be displayed.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2189
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2190 X and Y are where to store the positions chosen.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2191 WIDTH and HEIGHT are where to store the sizes chosen.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2192
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2193 GEO is the geometry that may specify some of the info.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2194 STR is a prompt to display.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2195 HSCROLL and VSCROLL say whether we have horiz and vert scroll bars. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2196
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2197 int
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2198 x_rubber_band (s, x, y, width, height, geo, str, hscroll, vscroll)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2199 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2200 int *x, *y, *width, *height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2201 char *geo;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2202 char *str;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2203 int hscroll, vscroll;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2204 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2205 OpaqueFrame frame;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2206 Window tempwindow;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2207 WindowInfo wininfo;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2208 int border_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2209 int background_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2210 Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2211 int mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2212
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2213 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2214
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2215 background_color = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2216 border_color = s->display.x->border_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2217
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2218 frame.bdrwidth = s->display.x->border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2219 frame.border = XMakeTile (border_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2220 frame.background = XMakeTile (background_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2221 tempwindow = XCreateTerm (str, "emacs", geo, default_window, &frame, 10, 5,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2222 (2 * s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2223 + (vscroll ? VSCROLL_WIDTH : 0)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2224 (2 * s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2225 + (hscroll ? HSCROLL_HEIGHT : 0)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2226 width, height, s->display.x->font,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2227 FONT_WIDTH (s->display.x->font),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2228 FONT_HEIGHT (s->display.x->font));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2229 XFreePixmap (frame.border);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2230 XFreePixmap (frame.background);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2231
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2232 if (tempwindow != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2233 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2234 XQueryWindow (tempwindow, &wininfo);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2235 XDestroyWindow (tempwindow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2236 *x = wininfo.x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2237 *y = wininfo.y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2238 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2239
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2240 /* Coordinates we got are relative to the root window.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2241 Convert them to coordinates relative to desired parent window
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2242 by scanning from there up to the root. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2243 tempwindow = s->display.x->parent_desc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2244 while (tempwindow != ROOT_WINDOW)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2245 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2246 int nchildren;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2247 Window *children;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2248 XQueryWindow (tempwindow, &wininfo);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2249 *x -= wininfo.x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2250 *y -= wininfo.y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2251 XQueryTree (tempwindow, &tempwindow, &nchildren, &children);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2252 free (children);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2253 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2254
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2255 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2256 return tempwindow != 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2257 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2258 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2259
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2260 /* Set whether screen S has a horizontal scroll bar.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2261 VAL is t or nil to specify it. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2262
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2263 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2264 x_set_horizontal_scrollbar (s, val, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2265 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2266 Lisp_Object val, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2267 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2268 if (!NULL (val))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2269 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2270 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2271 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2272 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2273 s->display.x->h_scrollbar_height = HSCROLL_HEIGHT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2274 x_set_window_size (s, s->width, s->height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2275 install_horizontal_scrollbar (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2276 SET_SCREEN_GARBAGED (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2277 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2278 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2279 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2280 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2281 if (s->display.x->h_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2282 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2283 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2284 s->display.x->h_scrollbar_height = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2285 XDestroyWindow (XDISPLAY s->display.x->h_scrollbar);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2286 s->display.x->h_scrollbar = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2287 x_set_window_size (s, s->width, s->height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2288 s->garbaged++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2289 screen_garbaged++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2290 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2291 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2292 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2293
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2294 /* Set whether screen S has a vertical scroll bar.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2295 VAL is t or nil to specify it. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2296
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2297 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2298 x_set_vertical_scrollbar (s, val, oldval)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2299 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2300 Lisp_Object val, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2301 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2302 if (!NULL (val))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2303 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2304 if (s->display.x->window_desc != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2305 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2306 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2307 s->display.x->v_scrollbar_width = VSCROLL_WIDTH;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2308 x_set_window_size (s, s->width, s->height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2309 install_vertical_scrollbar (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2310 SET_SCREEN_GARBAGED (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2311 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2312 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2313 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2314 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2315 if (s->display.x->v_scrollbar != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2316 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2317 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2318 s->display.x->v_scrollbar_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2319 XDestroyWindow (XDISPLAY s->display.x->v_scrollbar);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2320 s->display.x->v_scrollbar = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2321 x_set_window_size (s, s->width, s->height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2322 SET_SCREEN_GARBAGED (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2323 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2324 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2325 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2326
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2327 /* Create the X windows for a vertical scroll bar
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2328 for a screen X that already has an X window but no scroll bar. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2329
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2330 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2331 install_vertical_scrollbar (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2332 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2333 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2334 int ibw = s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2335 Window parent;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2336 XColor fore_color, back_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2337 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2338 int pix_x, pix_y, width, height, border;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2339
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2340 height = s->display.x->pixel_height - ibw - 2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2341 width = VSCROLL_WIDTH - 2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2342 pix_x = s->display.x->pixel_width - ibw/2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2343 pix_y = ibw / 2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2344 border = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2345
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2346 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2347 up_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2348 XCreatePixmapFromBitmapData (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2349 up_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2350 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2351 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2352 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2353 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2354
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2355 down_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2356 XCreatePixmapFromBitmapData (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2357 down_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2358 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2359 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2360 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2361 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2362
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2363 slider_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2364 XCreatePixmapFromBitmapData (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2365 gray_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2366 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2367 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2368 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2369 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2370
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2371 /* These cursor shapes will be installed when the mouse enters
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2372 the appropriate window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2373
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2374 up_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_up_arrow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2375 down_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_down_arrow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2376 v_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_v_double_arrow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2377
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2378 s->display.x->v_scrollbar =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2379 XCreateSimpleWindow (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2380 pix_x, pix_y, width, height, border,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2381 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2382 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2383 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2384 XDefineCursor (x_current_display, s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2385 v_double_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2386
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2387 /* Create slider window */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2388 s->display.x->v_slider =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2389 XCreateSimpleWindow (x_current_display, s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2390 0, VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2391 VSCROLL_WIDTH - 4, VSCROLL_WIDTH - 4,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2392 1, s->display.x->border_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2393 s->display.x->foreground_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2394 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2395 XDefineCursor (x_current_display, s->display.x->v_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2396 v_double_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2397 XSetWindowBackgroundPixmap (x_current_display, s->display.x->v_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2398 slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2399
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2400 s->display.x->v_thumbup =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2401 XCreateSimpleWindow (x_current_display, s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2402 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2403 VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2404 0, s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2405 s->display.x-> background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2406 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2407 XDefineCursor (x_current_display, s->display.x->v_thumbup,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2408 up_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2409 XSetWindowBackgroundPixmap (x_current_display, s->display.x->v_thumbup,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2410 up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2411
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2412 s->display.x->v_thumbdown =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2413 XCreateSimpleWindow (x_current_display, s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2414 0, height - VSCROLL_WIDTH + 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2415 VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2416 0, s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2417 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2418 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2419 XDefineCursor (x_current_display, s->display.x->v_thumbdown,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2420 down_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2421 XSetWindowBackgroundPixmap (x_current_display, s->display.x->v_thumbdown,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2422 down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2423
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2424 fore_color.pixel = s->display.x->mouse_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2425 back_color.pixel = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2426 XQueryColor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2427 DefaultColormap (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2428 DefaultScreen (x_current_display)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2429 &fore_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2430 XQueryColor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2431 DefaultColormap (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2432 DefaultScreen (x_current_display)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2433 &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2434 XRecolorCursor (x_current_display, up_arrow_cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2435 &fore_color, &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2436 XRecolorCursor (x_current_display, down_arrow_cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2437 &fore_color, &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2438 XRecolorCursor (x_current_display, v_double_arrow_cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2439 &fore_color, &back_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2440
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2441 XFreePixmap (x_current_display, slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2442 XFreePixmap (x_current_display, up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2443 XFreePixmap (x_current_display, down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2444 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2445
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2446 XSelectInput (x_current_display, s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2447 ButtonPressMask | ButtonReleaseMask
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2448 | PointerMotionMask | PointerMotionHintMask
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2449 | EnterWindowMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2450 XSelectInput (x_current_display, s->display.x->v_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2451 ButtonPressMask | ButtonReleaseMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2452 XSelectInput (x_current_display, s->display.x->v_thumbdown,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2453 ButtonPressMask | ButtonReleaseMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2454 XSelectInput (x_current_display, s->display.x->v_thumbup,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2455 ButtonPressMask | ButtonReleaseMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2456 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2457
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2458 /* This should be done at the same time as the main window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2459 XMapWindow (x_current_display, s->display.x->v_scrollbar);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2460 XMapSubwindows (x_current_display, s->display.x->v_scrollbar);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2461 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2462 #else /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2463 Bitmap b;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2464 Pixmap fore_tile, back_tile, bord_tile;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2465 static short up_arrow_bits[] = {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2466 0x0000, 0x0180, 0x03c0, 0x07e0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2467 0x0ff0, 0x1ff8, 0x3ffc, 0x7ffe,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2468 0x0180, 0x0180, 0x0180, 0x0180,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2469 0x0180, 0x0180, 0x0180, 0xffff};
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2470 static short down_arrow_bits[] = {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2471 0xffff, 0x0180, 0x0180, 0x0180,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2472 0x0180, 0x0180, 0x0180, 0x0180,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2473 0x7ffe, 0x3ffc, 0x1ff8, 0x0ff0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2474 0x07e0, 0x03c0, 0x0180, 0x0000};
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2475
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2476 fore_tile = XMakeTile (s->display.x->foreground_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2477 back_tile = XMakeTile (s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2478 bord_tile = XMakeTile (s->display.x->border_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2479
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2480 b = XStoreBitmap (VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, up_arrow_bits);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2481 up_arrow_pixmap = XMakePixmap (b,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2482 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2483 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2484 XFreeBitmap (b);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2485
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2486 b = XStoreBitmap (VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, down_arrow_bits);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2487 down_arrow_pixmap = XMakePixmap (b,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2488 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2489 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2490 XFreeBitmap (b);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2491
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2492 ibw = s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2493
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2494 s->display.x->v_scrollbar = XCreateWindow (s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2495 width - VSCROLL_WIDTH - ibw/2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2496 ibw/2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2497 VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2498 height - ibw - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2499 1, bord_tile, back_tile);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2500
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2501 s->display.x->v_scrollbar_width = VSCROLL_WIDTH;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2502
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2503 s->display.x->v_thumbup = XCreateWindow (s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2504 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2505 VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2506 VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2507 0, 0, up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2508 XTileAbsolute (s->display.x->v_thumbup);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2509
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2510 s->display.x->v_thumbdown = XCreateWindow (s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2511 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2512 height - ibw - VSCROLL_WIDTH,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2513 VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2514 VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2515 0, 0, down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2516 XTileAbsolute (s->display.x->v_thumbdown);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2517
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2518 s->display.x->v_slider = XCreateWindow (s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2519 0, VSCROLL_WIDTH - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2520 VSCROLL_WIDTH - 4,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2521 VSCROLL_WIDTH - 4,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2522 1, back_tile, fore_tile);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2523
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2524 XSelectInput (s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2525 (ButtonPressed | ButtonReleased | KeyPressed));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2526 XSelectInput (s->display.x->v_thumbup,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2527 (ButtonPressed | ButtonReleased | KeyPressed));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2528
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2529 XSelectInput (s->display.x->v_thumbdown,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2530 (ButtonPressed | ButtonReleased | KeyPressed));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2531
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2532 XMapWindow (s->display.x->v_thumbup);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2533 XMapWindow (s->display.x->v_thumbdown);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2534 XMapWindow (s->display.x->v_slider);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2535 XMapWindow (s->display.x->v_scrollbar);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2536
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2537 XFreePixmap (fore_tile);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2538 XFreePixmap (back_tile);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2539 XFreePixmap (up_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2540 XFreePixmap (down_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2541 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2542 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2543
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2544 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2545 install_horizontal_scrollbar (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2546 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2547 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2548 int ibw = s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2549 Window parent;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2550 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2551 int pix_x, pix_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2552 int width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2553
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2554 pix_x = ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2555 pix_y = PIXEL_HEIGHT (s) - HSCROLL_HEIGHT - ibw ;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2556 width = PIXEL_WIDTH (s) - 2 * ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2557 if (s->display.x->v_scrollbar_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2558 width -= (s->display.x->v_scrollbar_width + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2559
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2560 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2561 left_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2562 XCreatePixmapFromBitmapData (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2563 left_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2564 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2565 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2566 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2567 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2568
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2569 right_arrow_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2570 XCreatePixmapFromBitmapData (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2571 right_arrow_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2572 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2573 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2574 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2575 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2576
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2577 slider_pixmap =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2578 XCreatePixmapFromBitmapData (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2579 gray_bits, 16, 16,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2580 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2581 s->display.x->background_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582 DefaultDepth (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2583 XDefaultScreen (x_current_display)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2584
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2585 left_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_left_arrow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2586 right_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_right_arrow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2587 h_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_h_double_arrow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2588
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2589 s->display.x->h_scrollbar =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2590 XCreateSimpleWindow (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2591 pix_x, pix_y,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2592 width - ibw - 2, HSCROLL_HEIGHT - 2, 1,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2593 s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2594 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2595 XDefineCursor (x_current_display, s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2596 h_double_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2597
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2598 s->display.x->h_slider =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2599 XCreateSimpleWindow (x_current_display, s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2600 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2601 HSCROLL_HEIGHT - 4, HSCROLL_HEIGHT - 4,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2602 1, s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2603 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2604 XDefineCursor (x_current_display, s->display.x->h_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2605 h_double_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2606 XSetWindowBackgroundPixmap (x_current_display, s->display.x->h_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2607 slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2608
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2609 s->display.x->h_thumbleft =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2610 XCreateSimpleWindow (x_current_display, s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2611 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2612 HSCROLL_HEIGHT - 2, HSCROLL_HEIGHT - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2613 0, s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2614 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2615 XDefineCursor (x_current_display, s->display.x->h_thumbleft,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2616 left_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2617 XSetWindowBackgroundPixmap (x_current_display, s->display.x->h_thumbleft,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2618 left_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2619
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2620 s->display.x->h_thumbright =
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2621 XCreateSimpleWindow (x_current_display, s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2622 width - ibw - HSCROLL_HEIGHT, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2623 HSCROLL_HEIGHT - 2, HSCROLL_HEIGHT -2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2624 0, s->display.x->foreground_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2625 s->display.x->background_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2626 XDefineCursor (x_current_display, s->display.x->h_thumbright,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2627 right_arrow_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2628 XSetWindowBackgroundPixmap (x_current_display, s->display.x->h_thumbright,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2629 right_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2630
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2631 XFreePixmap (x_current_display, slider_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2632 XFreePixmap (x_current_display, left_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2633 XFreePixmap (x_current_display, right_arrow_pixmap);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2634
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2635 XSelectInput (x_current_display, s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2636 ButtonPressMask | ButtonReleaseMask
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2637 | PointerMotionMask | PointerMotionHintMask
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2638 | EnterWindowMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2639 XSelectInput (x_current_display, s->display.x->h_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2640 ButtonPressMask | ButtonReleaseMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2641 XSelectInput (x_current_display, s->display.x->h_thumbright,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2642 ButtonPressMask | ButtonReleaseMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2643 XSelectInput (x_current_display, s->display.x->h_thumbleft,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2644 ButtonPressMask | ButtonReleaseMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2645
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2646 XMapWindow (x_current_display, s->display.x->h_scrollbar);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2647 XMapSubwindows (x_current_display, s->display.x->h_scrollbar);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2648 #else /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2649 Bitmap b;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2650 Pixmap fore_tile, back_tile, bord_tile;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2651 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2652 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2653
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2654 #ifndef HAVE_X11 /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2655 #define XMoveResizeWindow XConfigureWindow
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2656 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2657
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2658 /* Adjust the displayed position in the scroll bar for window W. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2659
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2660 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2661 adjust_scrollbars (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2662 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2663 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2664 int pos;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2665 int first_char_in_window, char_beyond_window, chars_in_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2666 int chars_in_buffer, buffer_size;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2667 struct window *w = XWINDOW (SCREEN_SELECTED_WINDOW (s));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2668
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2669 if (s->output_method != output_x_window)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2670 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2671
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2672 if (s->display.x->v_scrollbar != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2673 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2674 int h, height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2675 struct buffer *b = XBUFFER (w->buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2676
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2677 buffer_size = Z - BEG;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2678 chars_in_buffer = ZV - BEGV;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2679 first_char_in_window = marker_position (w->start);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2680 char_beyond_window = buffer_size + 1 - XFASTINT (w->window_end_pos);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2681 chars_in_window = char_beyond_window - first_char_in_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2682
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2683 /* Calculate height of scrollbar area */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2684
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2685 height = s->height * FONT_HEIGHT (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2686 + s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2687 - 2 * (s->display.x->v_scrollbar_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2688
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2689 /* Figure starting position for the scrollbar slider */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2690
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2691 if (chars_in_buffer <= 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2692 pos = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2693 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2694 pos = ((first_char_in_window - BEGV - BEG) * height
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2695 / chars_in_buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2696 pos = max (0, pos);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2697 pos = min (pos, height - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2698
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2699 /* Figure length of the slider */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2700
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2701 if (chars_in_buffer <= 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2702 h = height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2703 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2704 h = (chars_in_window * height) / chars_in_buffer;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2705 h = min (h, height - pos);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2706 h = max (h, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2707
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2708 /* Add thumbup offset to starting position of slider */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2709
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2710 pos += (s->display.x->v_scrollbar_width - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2711
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2712 XMoveResizeWindow (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2713 s->display.x->v_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2714 0, pos,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2715 s->display.x->v_scrollbar_width - 4, h);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2716 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2717
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2718 if (s->display.x->h_scrollbar != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2719 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2720 int l, length; /* Length of the scrollbar area */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2721
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2722 length = s->width * FONT_WIDTH (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2723 + s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2724 - 2 * (s->display.x->h_scrollbar_height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2725
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2726 /* Starting position for horizontal slider */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727 if (! w->hscroll)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2728 pos = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2729 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2730 pos = (w->hscroll * length) / (w->hscroll + s->width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2731 pos = max (0, pos);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2732 pos = min (pos, length - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2733
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2734 /* Length of slider */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2735 l = length - pos;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2736
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2737 /* Add thumbup offset */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2738 pos += (s->display.x->h_scrollbar_height - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2739
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2740 XMoveResizeWindow (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2741 s->display.x->h_slider,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2742 pos, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2743 l, s->display.x->h_scrollbar_height - 4);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2744 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2745 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2746
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2747 /* Adjust the size of the scroll bars of screen S,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2748 when the screen size has changed. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2749
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2750 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2751 x_resize_scrollbars (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2752 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2753 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2754 int ibw = s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2755 int pixelwidth, pixelheight;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2756
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2757 if (s == 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2758 || s->display.x == 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2759 || (s->display.x->v_scrollbar == 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2760 && s->display.x->h_scrollbar == 0))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2761 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2762
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2763 /* Get the size of the screen. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2764 pixelwidth = (s->width * FONT_WIDTH (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2765 + 2 * ibw + s->display.x->v_scrollbar_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2766 pixelheight = (s->height * FONT_HEIGHT (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2767 + 2 * ibw + s->display.x->h_scrollbar_height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2768
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2769 if (s->display.x->v_scrollbar_width && s->display.x->v_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2770 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2771 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2772 XMoveResizeWindow (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2773 s->display.x->v_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2774 pixelwidth - s->display.x->v_scrollbar_width - ibw/2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2775 ibw/2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2776 s->display.x->v_scrollbar_width - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2777 pixelheight - ibw - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2778 XMoveWindow (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2779 s->display.x->v_thumbdown, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2780 pixelheight - ibw - s->display.x->v_scrollbar_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2781 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2782 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2783
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2784 if (s->display.x->h_scrollbar_height && s->display.x->h_scrollbar)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2785 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2786 if (s->display.x->v_scrollbar_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2787 pixelwidth -= s->display.x->v_scrollbar_width + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2788
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2789 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2790 XMoveResizeWindow (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2791 s->display.x->h_scrollbar,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2792 ibw / 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2793 pixelheight - s->display.x->h_scrollbar_height - ibw / 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2794 pixelwidth - ibw - 2,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2795 s->display.x->h_scrollbar_height - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2796 XMoveWindow (XDISPLAY
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2797 s->display.x->h_thumbright,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2798 pixelwidth - ibw - s->display.x->h_scrollbar_height, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2799 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2800 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2802
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2803 x_pixel_width (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2804 register struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2805 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806 return PIXEL_WIDTH (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2808
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809 x_pixel_height (s)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2810 register struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2811 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2812 return PIXEL_HEIGHT (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2813 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2814
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2815 DEFUN ("x-defined-color", Fx_defined_color, Sx_defined_color, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2816 "Return t if the current X display supports the color named COLOR.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2817 (color)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2818 Lisp_Object color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2819 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2820 Color foo;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2821
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2822 CHECK_STRING (color, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2823
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2824 if (defined_color (XSTRING (color)->data, &foo))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2825 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2826 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2827 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2828 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2829
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2830 DEFUN ("x-color-display-p", Fx_color_display_p, Sx_color_display_p, 0, 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2831 "Return t if the X display used currently supports color.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2832 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2833 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2834 if (XINT (x_screen_planes) <= 2)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2835 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2836
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2837 switch (screen_visual->class)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2838 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2839 case StaticColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2840 case PseudoColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2841 case TrueColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2842 case DirectColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2843 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2844
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2845 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2846 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2847 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2848 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2849
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2850 DEFUN ("x-pixel-width", Fx_pixel_width, Sx_pixel_width, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2851 "Return the width in pixels of screen S.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2852 (screen)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2853 Lisp_Object screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2854 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2855 CHECK_SCREEN (screen, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2856 return make_number (XSCREEN (screen)->display.x->pixel_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2857 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2858
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2859 DEFUN ("x-pixel-height", Fx_pixel_height, Sx_pixel_height, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2860 "Return the height in pixels of screen S.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2861 (screen)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2862 Lisp_Object screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2863 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2864 CHECK_SCREEN (screen, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2865 return make_number (XSCREEN (screen)->display.x->pixel_height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2866 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2867
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2868 /* Draw a rectangle on the screen with left top corner including
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2869 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2870 CHARS by LINES wide and long and is the color of the cursor. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2871
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2872 void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2873 x_rectangle (s, gc, left_char, top_char, chars, lines)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2874 register struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2875 GC gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2876 register int top_char, left_char, chars, lines;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2877 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2878 int width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2879 int height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2880 int left = (left_char * FONT_WIDTH (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2881 + s->display.x->internal_border_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2882 int top = (top_char * FONT_HEIGHT (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2883 + s->display.x->internal_border_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2884
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2885 if (chars < 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2886 width = FONT_WIDTH (s->display.x->font) / 2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2887 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2888 width = FONT_WIDTH (s->display.x->font) * chars;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2889 if (lines < 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2890 height = FONT_HEIGHT (s->display.x->font) / 2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2891 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2892 height = FONT_HEIGHT (s->display.x->font) * lines;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2893
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2894 XDrawRectangle (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2895 gc, left, top, width, height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2896 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2897
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2898 DEFUN ("x-draw-rectangle", Fx_draw_rectangle, Sx_draw_rectangle, 5, 5, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2899 "Draw a rectangle on SCREEN between coordinates specified by\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2900 numbers X0, Y0, X1, Y1 in the cursor pixel.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2901 (screen, X0, Y0, X1, Y1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2902 register Lisp_Object screen, X0, X1, Y0, Y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2903 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2904 register int x0, y0, x1, y1, top, left, n_chars, n_lines;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2905
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2906 CHECK_SCREEN (screen, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2907 CHECK_NUMBER (X0, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2908 CHECK_NUMBER (Y0, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2909 CHECK_NUMBER (X1, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2910 CHECK_NUMBER (Y1, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2911
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2912 x0 = XINT (X0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2913 x1 = XINT (X1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2914 y0 = XINT (Y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2915 y1 = XINT (Y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2916
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2917 if (y1 > y0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2918 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2919 top = y0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2920 n_lines = y1 - y0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2921 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2922 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2923 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2924 top = y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2925 n_lines = y0 - y1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2926 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2927
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2928 if (x1 > x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2929 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2930 left = x0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2931 n_chars = x1 - x0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2932 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2933 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2934 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2935 left = x1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2936 n_chars = x0 - x1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2937 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2938
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2939 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2940 x_rectangle (XSCREEN (screen), XSCREEN (screen)->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2941 left, top, n_chars, n_lines);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2942 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2943
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2944 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2945 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2946
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2947 DEFUN ("x-erase-rectangle", Fx_erase_rectangle, Sx_erase_rectangle, 5, 5, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2948 "Draw a rectangle drawn on SCREEN between coordinates\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2949 X0, Y0, X1, Y1 in the regular background-pixel.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2950 (screen, X0, Y0, X1, Y1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2951 register Lisp_Object screen, X0, Y0, X1, Y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2952 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2953 register int x0, y0, x1, y1, top, left, n_chars, n_lines;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2954
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2955 CHECK_SCREEN (screen, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2956 CHECK_NUMBER (X0, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2957 CHECK_NUMBER (Y0, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2958 CHECK_NUMBER (X1, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2959 CHECK_NUMBER (Y1, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2960
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2961 x0 = XINT (X0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2962 x1 = XINT (X1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2963 y0 = XINT (Y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2964 y1 = XINT (Y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2965
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2966 if (y1 > y0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2967 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2968 top = y0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2969 n_lines = y1 - y0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2970 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2971 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2972 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2973 top = y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2974 n_lines = y0 - y1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2975 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2976
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2977 if (x1 > x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2978 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2979 left = x0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2980 n_chars = x1 - x0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2981 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2982 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2983 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2984 left = x1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2985 n_chars = x0 - x1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2986 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2987
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2988 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2989 x_rectangle (XSCREEN (screen), XSCREEN (screen)->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2990 left, top, n_chars, n_lines);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2991 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2992
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2993 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2994 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2995
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2996 /* Draw lines around the text region beginning at the character position
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2997 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2998 pixel and line characteristics. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2999
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3000 #define line_len(line) (SCREEN_CURRENT_GLYPHS (s)->used[(line)])
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3001
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3002 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3003 outline_region (s, gc, top_x, top_y, bottom_x, bottom_y)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3004 register struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3005 GC gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3006 int top_x, top_y, bottom_x, bottom_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3007 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3008 register int ibw = s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3009 register int font_w = FONT_WIDTH (s->display.x->font);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3010 register int font_h = FONT_HEIGHT (s->display.x->font);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3011 int y = top_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3012 int x = line_len (y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3013 XPoint *pixel_points = (XPoint *)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3014 alloca (((bottom_y - top_y + 2) * 4) * sizeof (XPoint));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3015 register XPoint *this_point = pixel_points;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3016
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3017 /* Do the horizontal top line/lines */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3018 if (top_x == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3019 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3020 this_point->x = ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3021 this_point->y = ibw + (font_h * top_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3022 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3023 if (x == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3024 this_point->x = ibw + (font_w / 2); /* Half-size for newline chars. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3025 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3026 this_point->x = ibw + (font_w * x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3027 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3028 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3029 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3030 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3031 this_point->x = ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3032 this_point->y = ibw + (font_h * (top_y + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3033 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3034 this_point->x = ibw + (font_w * top_x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3035 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3036 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3037 this_point->x = (this_point - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3038 this_point->y = ibw + (font_h * top_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3039 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3040 this_point->x = ibw + (font_w * x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3041 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3042 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3043
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3044 /* Now do the right side. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3045 while (y < bottom_y)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3046 { /* Right vertical edge */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3047 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3048 this_point->x = (this_point - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3049 this_point->y = ibw + (font_h * (y + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3050 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3051
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3052 y++; /* Horizontal connection to next line */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3053 x = line_len (y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3054 if (x == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3055 this_point->x = ibw + (font_w / 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3056 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3057 this_point->x = ibw + (font_w * x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3058
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3059 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3060 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3061
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3062 /* Now do the bottom and connect to the top left point. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3063 this_point->x = ibw + (font_w * (bottom_x + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3064
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3065 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3066 this_point->x = (this_point - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3067 this_point->y = ibw + (font_h * (bottom_y + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3068 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3069 this_point->x = ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3070 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3071 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3072 this_point->x = pixel_points->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3073 this_point->y = pixel_points->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3074
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3075 XDrawLines (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3076 gc, pixel_points,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3077 (this_point - pixel_points + 1), CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3078 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3079
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3080 DEFUN ("x-contour-region", Fx_contour_region, Sx_contour_region, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3081 "Highlight the region between point and the character under the mouse\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3082 selected screen.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3083 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3084 register Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3085 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3086 register int x0, y0, x1, y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3087 register struct screen *s = selected_screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3088 register int p1, p2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3089
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3090 CHECK_CONS (event, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3091
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3092 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3093 x0 = XINT (Fcar (Fcar (event)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3094 y0 = XINT (Fcar (Fcdr (Fcar (event))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3095
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3096 /* If the mouse is past the end of the line, don't that area. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3097 /* ReWrite this... */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3098
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3099 x1 = s->cursor_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3100 y1 = s->cursor_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3101
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3102 if (y1 > y0) /* point below mouse */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3103 outline_region (s, s->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3104 x0, y0, x1, y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3105 else if (y1 < y0) /* point above mouse */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3106 outline_region (s, s->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3107 x1, y1, x0, y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3108 else /* same line: draw horizontal rectangle */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3109 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3110 if (x1 > x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3111 x_rectangle (s, s->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3112 x0, y0, (x1 - x0 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3113 else if (x1 < x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3114 x_rectangle (s, s->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3115 x1, y1, (x0 - x1 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3116 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3117
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3118 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3119 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3120
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3121 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3122 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3123
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3124 DEFUN ("x-uncontour-region", Fx_uncontour_region, Sx_uncontour_region, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3125 "Erase any highlighting of the region between point and the character\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3126 at X, Y on the selected screen.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3127 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3128 register Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3129 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3130 register int x0, y0, x1, y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3131 register struct screen *s = selected_screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3132
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3133 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3134 x0 = XINT (Fcar (Fcar (event)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3135 y0 = XINT (Fcar (Fcdr (Fcar (event))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3136 x1 = s->cursor_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3137 y1 = s->cursor_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3138
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3139 if (y1 > y0) /* point below mouse */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3140 outline_region (s, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3141 x0, y0, x1, y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3142 else if (y1 < y0) /* point above mouse */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3143 outline_region (s, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3144 x1, y1, x0, y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3145 else /* same line: draw horizontal rectangle */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3146 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3147 if (x1 > x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3148 x_rectangle (s, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3149 x0, y0, (x1 - x0 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3150 else if (x1 < x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3151 x_rectangle (s, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3152 x1, y1, (x0 - x1 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3153 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3154 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3155
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3156 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3157 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3158
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3159 extern unsigned int x_mouse_x, x_mouse_y, x_mouse_grabbed;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3160 extern Lisp_Object unread_command_char;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3161
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3162 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3163 int contour_begin_x, contour_begin_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3164 int contour_end_x, contour_end_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3165 int contour_npoints;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3166
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3167 /* Clip the top part of the contour lines down (and including) line Y_POS.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3168 If X_POS is in the middle (rather than at the end) of the line, drop
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3169 down a line at that character. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3170
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3171 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3172 clip_contour_top (y_pos, x_pos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3173 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3174 register XPoint *begin = contour_lines[y_pos].top_left;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3175 register XPoint *end;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3176 register int npoints;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3177 register struct display_line *line = selected_screen->phys_lines[y_pos + 1];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3178
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3179 if (x_pos >= line->len - 1) /* Draw one, straight horizontal line. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3180 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3181 end = contour_lines[y_pos].top_right;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3182 npoints = (end - begin + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3183 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3184 contour_erase_gc, begin_erase, npoints, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3185
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3186 bcopy (end, begin + 1, contour_last_point - end + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3187 contour_last_point -= (npoints - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3188 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3189 contour_erase_gc, begin, 2, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3190 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3191
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3192 /* Now, update contour_lines structure. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3193 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3194 /* ______. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3195 else /* |________*/
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3196 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3197 register XPoint *p = begin + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3198 end = contour_lines[y_pos].bottom_right;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3199 npoints = (end - begin + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3200 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3201 contour_erase_gc, begin_erase, npoints, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3202
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3203 p->y = begin->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3204 p->x = ibw + (font_w * (x_pos + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3205 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3206 p->y = begin->y + font_h;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3207 p->x = (p - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3208 bcopy (end, begin + 3, contour_last_point - end + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3209 contour_last_point -= (npoints - 5);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3210 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3211 contour_erase_gc, begin, 4, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3212 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3213
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3214 /* Now, update contour_lines structure. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3215 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3216 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3217
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3218 /* Erase the top horzontal lines of the contour, and then extend
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3219 the contour upwards. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3220
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3221 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3222 extend_contour_top (line)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3223 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3224 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3225
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3226 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3227 clip_contour_bottom (x_pos, y_pos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3228 int x_pos, y_pos;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3229 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3230 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3231
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3232 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3233 extend_contour_bottom (x_pos, y_pos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3234 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3235 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3236
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3237 DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3238 "")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3239 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3240 Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3241 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3242 register struct screen *s = selected_screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3243 register int point_x = s->cursor_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3244 register int point_y = s->cursor_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3245 register int mouse_below_point;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3246 register Lisp_Object obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3247 register int x_contour_x, x_contour_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3248
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3249 x_contour_x = x_mouse_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3250 x_contour_y = x_mouse_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3251 if (x_contour_y > point_y || (x_contour_y == point_y
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3252 && x_contour_x > point_x))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3253 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3254 mouse_below_point = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3255 outline_region (s, s->display.x->cursor_gc, point_x, point_y,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3256 x_contour_x, x_contour_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3257 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3258 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3259 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3260 mouse_below_point = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3261 outline_region (s, s->display.x->cursor_gc, x_contour_x, x_contour_y,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3262 point_x, point_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3263 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3264
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3265 while (1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3266 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3267 obj = read_char (-1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3268 if (XTYPE (obj) != Lisp_Cons)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3269 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3270
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3271 if (mouse_below_point)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3272 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3273 if (x_mouse_y <= point_y) /* Flipped. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3274 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3275 mouse_below_point = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3276
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3277 outline_region (s, s->display.x->reverse_gc, point_x, point_y,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3278 x_contour_x, x_contour_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3279 outline_region (s, s->display.x->cursor_gc, x_mouse_x, x_mouse_y,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3280 point_x, point_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3281 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3282 else if (x_mouse_y < x_contour_y) /* Bottom clipped. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3283 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3284 clip_contour_bottom (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3285 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3286 else if (x_mouse_y > x_contour_y) /* Bottom extended. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3287 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3288 extend_bottom_contour (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3289 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3290
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3291 x_contour_x = x_mouse_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3292 x_contour_y = x_mouse_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3293 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3294 else /* mouse above or same line as point */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3295 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3296 if (x_mouse_y >= point_y) /* Flipped. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3297 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3298 mouse_below_point = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3299
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3300 outline_region (s, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3301 x_contour_x, x_contour_y, point_x, point_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3302 outline_region (s, s->display.x->cursor_gc, point_x, point_y,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3303 x_mouse_x, x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3304 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3305 else if (x_mouse_y > x_contour_y) /* Top clipped. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3306 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3307 clip_contour_top (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3308 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3309 else if (x_mouse_y < x_contour_y) /* Top extended. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3310 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3311 extend_contour_top (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3312 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3313 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3314 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3315
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3316 unread_command_char = obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3317 if (mouse_below_point)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3318 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3319 contour_begin_x = point_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3320 contour_begin_y = point_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3321 contour_end_x = x_contour_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3322 contour_end_y = x_contour_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3323 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3324 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3325 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3326 contour_begin_x = x_contour_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3327 contour_begin_y = x_contour_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3328 contour_end_x = point_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3329 contour_end_y = point_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3330 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3331 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3332 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3333
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3334 DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3335 "")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3336 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3337 Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3338 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3339 register Lisp_Object obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3340 struct screen *s = selected_screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3341 register struct window *w = XWINDOW (selected_window);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3342 register GC line_gc = s->display.x->cursor_gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3343 register GC erase_gc = s->display.x->reverse_gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3344 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3345 char dash_list[] = {6, 4, 6, 4};
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3346 int dashes = 4;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3347 XGCValues gc_values;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3348 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3349 register int previous_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3350 register int line = (x_mouse_y + 1) * FONT_HEIGHT (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3351 + s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3352 register int left = s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3353 + (w->left
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3354 * FONT_WIDTH (s->display.x->font));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3355 register int right = left + (w->width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3356 * FONT_WIDTH (s->display.x->font))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3357 - s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3358
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3359 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3360 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3361 gc_values.foreground = s->display.x->cursor_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3362 gc_values.background = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3363 gc_values.line_width = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3364 gc_values.line_style = LineOnOffDash;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3365 gc_values.cap_style = CapRound;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3366 gc_values.join_style = JoinRound;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3367
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3368 line_gc = XCreateGC (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3369 GCLineStyle | GCJoinStyle | GCCapStyle
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3370 | GCLineWidth | GCForeground | GCBackground,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3371 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3372 XSetDashes (x_current_display, line_gc, 0, dash_list, dashes);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3373 gc_values.foreground = s->display.x->background_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3374 gc_values.background = s->display.x->foreground_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3375 erase_gc = XCreateGC (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3376 GCLineStyle | GCJoinStyle | GCCapStyle
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3377 | GCLineWidth | GCForeground | GCBackground,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3378 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3379 XSetDashes (x_current_display, erase_gc, 0, dash_list, dashes);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3380 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3381
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3382 while (1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3383 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3384 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3385 if (x_mouse_y >= XINT (w->top)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3386 && x_mouse_y < XINT (w->top) + XINT (w->height) - 1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3387 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3388 previous_y = x_mouse_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3389 line = (x_mouse_y + 1) * FONT_HEIGHT (s->display.x->font)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3390 + s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3391 XDrawLine (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3392 line_gc, left, line, right, line);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3393 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3394 XFlushQueue ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3395 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3396
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3397 do
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3398 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3399 obj = read_char (-1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3400 if ((XTYPE (obj) != Lisp_Cons)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3401 || (! EQ (Fcar (Fcdr (Fcdr (obj))),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3402 intern ("vertical-scroll-bar")))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3403 || x_mouse_grabbed)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3404 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3405 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3406 XDrawLine (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3407 erase_gc, left, line, right, line);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3408 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3409 unread_command_char = obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3410 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3411 XFreeGC (x_current_display, line_gc);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3412 XFreeGC (x_current_display, erase_gc);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3413 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3414 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3415 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3416 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3417 while (x_mouse_y == previous_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3418
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3419 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3420 XDrawLine (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3421 erase_gc, left, line, right, line);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3422 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3423 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3424 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3425
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3426 static Cursor grabbed_cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3427
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3428 DEFUN ("x-grab-pointer", Fx_grab_pointer, Sx_grab_pointer, 0, 2, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3429 "Grab the pointer and restrict it to its current window. If optional\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3430 SHAPE is non-nil, change the pointer shape to that. If second optional\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3431 argument MOUSE-ONLY is non-nil, ignore keyboard events during the grab.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3432 (shape, ignore_keyboard)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3433 Lisp_Object shape, ignore_keyboard;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3434 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3435 Window w;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3436 int pointer_mode, result;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3437
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3438 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3439 if (! NULL (ignore_keyboard))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3440 pointer_mode = GrabModeSync;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3441 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3442 pointer_mode = GrabModeAsync;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3443
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3444 if (! NULL (shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3445 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3446 CHECK_NUMBER (shape, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3447 grabbed_cursor = XCreateFontCursor (x_current_display, XINT (shape));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3448 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3449
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3450 /* Determine which window to confine the mouse to. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3451 if (EQ (Vmouse_screen_part, Qtext_part) || EQ (Vmouse_screen_part, Qmodeline_part))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3452 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3453 w = x_focus_screen->display.x->window_desc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3454 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3455 else if (EQ (Vmouse_screen_part, Qvscrollbar_part)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3456 || EQ (Vmouse_screen_part, Qvslider_part))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3457 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3458 w = x_focus_screen->display.x->v_scrollbar;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3459 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3460 else if (EQ (Vmouse_screen_part, Qvthumbup_part))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3461 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3462 w = x_focus_screen->display.x->v_thumbup;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3463 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3464 else if (EQ (Vmouse_screen_part, Qvthumbdown_part))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3465 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3466 w = x_focus_screen->display.x->v_thumbdown;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3467 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3468 else if (EQ (Vmouse_screen_part, Qhscrollbar_part)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3469 || EQ (Vmouse_screen_part, Qhslider_part))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3470 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3471 w = x_focus_screen->display.x->h_scrollbar;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3472 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3473 else if (EQ (Vmouse_screen_part, Qhthumbleft_part))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3474 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3475 w = x_focus_screen->display.x->h_thumbleft;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3476 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3477 else if (EQ (Vmouse_screen_part, Qhthumbright_part))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3478 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3479 w = x_focus_screen->display.x->h_thumbright;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3480 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3481 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3482 abort ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3483
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3484 result = XGrabPointer (x_current_display, w,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3485 False,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3486 ButtonMotionMask | ButtonPressMask
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3487 | ButtonReleaseMask | PointerMotionHintMask,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3488 GrabModeAsync, /* Keep pointer events flowing */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3489 pointer_mode, /* Stall keyboard events */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3490 w, /* Stay in this window */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3491 grabbed_cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3492 CurrentTime);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3493 if (result == GrabSuccess)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3494 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3495 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3496 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3497 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3498
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3499 XFreeCursor (x_current_display, grabbed_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3500 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3501 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3502 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3503
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3504 DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, Sx_ungrab_pointer, 0, 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3505 "Release the pointer.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3506 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3507 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3508 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3509 XUngrabPointer (x_current_display, CurrentTime);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3510
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3511 if (! ((int) grabbed_cursor))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3512 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3513 XFreeCursor (x_current_display, grabbed_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3514 grabbed_cursor = (Cursor) 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3515 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3516
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3517 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3518 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3519 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3520
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3521 /* Offset in buffer of character under the pointer, or 0. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3522 int mouse_buffer_offset;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3523
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3524 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3525 /* These keep track of the rectangle following the pointer. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3526 int mouse_track_top, mouse_track_left, mouse_track_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3527
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3528 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3529 "Track the pointer.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3530 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3531 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3532 static Cursor current_pointer_shape;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3533 SCREEN_PTR s = x_mouse_screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3534
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3535 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3536 if (EQ (Vmouse_screen_part, Qtext_part)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3537 && (current_pointer_shape != s->display.x->nontext_cursor))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3538 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3539 unsigned char c;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3540 struct buffer *buf;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3541
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3542 current_pointer_shape = s->display.x->nontext_cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3543 XDefineCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3544 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3545 current_pointer_shape);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3546
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3547 buf = XBUFFER (XWINDOW (Vmouse_window)->buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3548 c = *(BUF_CHAR_ADDRESS (buf, mouse_buffer_offset));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3549 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3550 else if (EQ (Vmouse_screen_part, Qmodeline_part)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3551 && (current_pointer_shape != s->display.x->modeline_cursor))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3552 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3553 current_pointer_shape = s->display.x->modeline_cursor;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3554 XDefineCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3555 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3556 current_pointer_shape);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3557 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3558
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3559 XFlushQueue ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3560 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3561 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3562 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3563
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3564 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3565 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3566 "Draw rectangle around character under mouse pointer, if there is one.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3567 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3568 Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3569 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3570 struct window *w = XWINDOW (Vmouse_window);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3571 struct screen *s = XSCREEN (WINDOW_SCREEN (w));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3572 struct buffer *b = XBUFFER (w->buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3573 Lisp_Object obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3574
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3575 if (! EQ (Vmouse_window, selected_window))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3576 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3577
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3578 if (EQ (event, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3579 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3580 int x, y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3581
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3582 x_read_mouse_position (selected_screen, &x, &y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3583 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3584
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3585 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3586 mouse_track_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3587 mouse_track_left = mouse_track_top = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3588
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3589 do
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3590 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3591 if ((x_mouse_x != mouse_track_left
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3592 && (x_mouse_x < mouse_track_left
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3593 || x_mouse_x > (mouse_track_left + mouse_track_width)))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3594 || x_mouse_y != mouse_track_top)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3595 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3596 int hp = 0; /* Horizontal position */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3597 int len = SCREEN_CURRENT_GLYPHS (s)->used[x_mouse_y];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3598 int p = SCREEN_CURRENT_GLYPHS (s)->bufp[x_mouse_y];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3599 int tab_width = XINT (b->tab_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3600 int ctl_arrow_p = !NULL (b->ctl_arrow);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3601 unsigned char c;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3602 int mode_line_vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3603 int in_mode_line = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3604
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3605 if (! SCREEN_CURRENT_GLYPHS (s)->enable[x_mouse_y])
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3606 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3607
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3608 /* Erase previous rectangle. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3609 if (mouse_track_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3610 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3611 x_rectangle (s, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3612 mouse_track_left, mouse_track_top,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3613 mouse_track_width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3614
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3615 if ((mouse_track_left == s->phys_cursor_x
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3616 || mouse_track_left == s->phys_cursor_x - 1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3617 && mouse_track_top == s->phys_cursor_y)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3618 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3619 x_display_cursor (s, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3620 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3621 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3622
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3623 mouse_track_left = x_mouse_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3624 mouse_track_top = x_mouse_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3625 mouse_track_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3626
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3627 if (mouse_track_left > len) /* Past the end of line. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3628 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3629
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3630 if (mouse_track_top == mode_line_vpos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3631 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3632 in_mode_line = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3633 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3634 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3635
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3636 if (tab_width <= 0 || tab_width > 20) tab_width = 8;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3637 do
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3638 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3639 c = FETCH_CHAR (p);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3640 if (len == s->width && hp == len - 1 && c != '\n')
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3641 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3642
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3643 switch (c)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3644 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3645 case '\t':
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3646 mouse_track_width = tab_width - (hp % tab_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3647 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3648 hp += mouse_track_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3649 if (hp > x_mouse_x)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3650 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3651 mouse_track_left = hp - mouse_track_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3652 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3653 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3654 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3655
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3656 case '\n':
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3657 mouse_track_width = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3658 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3659
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3660 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3661 if (ctl_arrow_p && (c < 040 || c == 0177))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3662 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3663 if (p > ZV)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3664 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3665
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3666 mouse_track_width = 2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3667 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3668 hp +=2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3669 if (hp > x_mouse_x)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3670 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3671 mouse_track_left = hp - mouse_track_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3672 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3673 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3674 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3675 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3676 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3677 mouse_track_width = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3678 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3679 hp++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3680 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3681 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3682 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3683 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3684 while (hp <= x_mouse_x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3685
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3686 draw_or_not:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3687 if (mouse_track_width) /* Over text; use text pointer shape. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3688 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3689 XDefineCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3690 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3691 s->display.x->text_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3692 x_rectangle (s, s->display.x->cursor_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3693 mouse_track_left, mouse_track_top,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3694 mouse_track_width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3695 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3696 else if (in_mode_line)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3697 XDefineCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3698 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3699 s->display.x->modeline_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3700 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3701 XDefineCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3702 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3703 s->display.x->nontext_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3704 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3705
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3706 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3707 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3708
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3709 obj = read_char (-1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3710 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3711 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3712 while (XTYPE (obj) == Lisp_Cons /* Mouse event */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3713 && EQ (Fcar (Fcdr (Fcdr (obj))), Qnil) /* Not scrollbar */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3714 && EQ (Vmouse_depressed, Qnil) /* Only motion events */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3715 && EQ (Vmouse_window, selected_window) /* In this window */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3716 && x_mouse_screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3717
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3718 unread_command_char = obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3719
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3720 if (mouse_track_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3721 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3722 x_rectangle (s, s->display.x->reverse_gc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3723 mouse_track_left, mouse_track_top,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3724 mouse_track_width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3725 mouse_track_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3726 if ((mouse_track_left == s->phys_cursor_x
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3727 || mouse_track_left - 1 == s->phys_cursor_x)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3728 && mouse_track_top == s->phys_cursor_y)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3729 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3730 x_display_cursor (s, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3731 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3732 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3733 XDefineCursor (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3734 s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3735 s->display.x->nontext_cursor);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3736 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3737 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3738
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3739 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3740 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3741 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3742
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3743 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3744 #include "glyphs.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3745
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3746 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3747 on the screen S at position X, Y. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3748
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3749 x_draw_pixmap (s, x, y, image_data, width, height)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3750 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3751 int x, y, width, height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3752 char *image_data;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3753 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3754 Pixmap image;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3755
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3756 image = XCreateBitmapFromData (x_current_display,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3757 s->display.x->window_desc, image_data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3758 width, height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3759 XCopyPlane (x_current_display, image, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3760 s->display.x->normal_gc, 0, 0, width, height, x, y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3761 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3762 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3763
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3764 x_read_mouse_position (s, x, y)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3765 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3766 int *x, *y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3767 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3768 Window w;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3769 int ix, iy;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3770 int ibw = s->display.x->internal_border_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3771
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3772 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3773 Window root_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3774 int root_x, root_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3775 unsigned int keys_and_buttons;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3776
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3777 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3778 if (XQueryPointer (x_current_display, s->display.x->window_desc,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3779 &root_window, &w, &root_x, &root_y, &ix, &iy,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3780 &keys_and_buttons) == False)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3781 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3782 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3783 error ("Pointer not on same screen as window.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3784 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3785 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3786 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3787 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3788 XQueryMouse (s->display.x->window_desc, &ix, &iy, &w);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3789 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3790 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3791
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3792 x_mouse_x = *x = (ix - ibw) / FONT_WIDTH (s->display.x->font);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3793 x_mouse_y = *y = (iy - ibw) / FONT_HEIGHT (s->display.x->font);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3794 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3795
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3796 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3797
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3798 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3799 #define XMouseEvent XEvent
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3800 #define WhichMouseButton xbutton.button
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3801 #define MouseWindow xbutton.window
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3802 #define MouseX xbutton.x
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3803 #define MouseY xbutton.y
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3804 #define MouseTime xbutton.time
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3805 #define ButtonReleased ButtonRelease
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3806 #define ButtonPressed ButtonPress
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3807 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3808 #define XMouseEvent XButtonEvent
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3809 #define WhichMouseButton detail
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3810 #define MouseWindow window
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3811 #define MouseX x
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3812 #define MouseY y
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3813 #define MouseTime time
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3814 #endif /* X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3815
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3816 DEFUN ("x-mouse-events", Fx_mouse_events, Sx_mouse_events, 0, 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3817 "Return number of pending mouse events from X window system.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3818 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3819 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3820 return make_number (queue_event_count (&x_mouse_queue));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3821 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3822
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3823 /* Encode the mouse button events in the form expected by the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3824 mouse code in Lisp. For X11, this means moving the masks around. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3825
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3826 static int
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3827 encode_mouse_button (mouse_event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3828 XMouseEvent mouse_event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3829 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3830 register int event_code;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3831 register char key_mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3832
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3833 event_code = mouse_event.detail & 3;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3834 key_mask = (mouse_event.detail >> 8) & 0xf0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3835 event_code |= key_mask >> 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3836 if (mouse_event.type == ButtonReleased) event_code |= 0x04;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3837 return event_code;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3838 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3839
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3840 DEFUN ("x-get-mouse-event", Fx_get_mouse_event, Sx_get_mouse_event,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3841 0, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3842 "Get next mouse event out of mouse event buffer.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3843 Optional ARG non-nil means return nil immediately if no pending event;\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3844 otherwise, wait for an event. Returns a four-part list:\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3845 ((X-POS Y-POS) WINDOW SCREEN-PART KEYSEQ TIMESTAMP).\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3846 Normally X-POS and Y-POS are the position of the click on the screen\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3847 (measured in characters and lines), and WINDOW is the window clicked in.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3848 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3849 If SCREEN-PART is non-nil, the event was on a scrollbar;\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3850 then Y-POS is really the total length of the scrollbar, while X-POS is\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3851 the relative position of the scrollbar's value within that total length,\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3852 and a third element OFFSET appears in that list: the height of the thumb-up\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3853 area at the top of the scroll bar.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3854 SCREEN-PART is one of the following symbols:\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3855 `vertical-scrollbar', `vertical-thumbup', `vertical-thumbdown',\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3856 `horizontal-scrollbar', `horizontal-thumbleft', `horizontal-thumbright'.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3857 TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3858 the mouse event.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3859 (arg)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3860 Lisp_Object arg;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3861 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3862 XMouseEvent xrep;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3863 register int com_letter;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3864 register Lisp_Object tempx;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3865 register Lisp_Object tempy;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3866 Lisp_Object part, pos, timestamp;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3867 int prefix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3868 struct screen *s;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3869
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3870 int tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3871
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3872 while (1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3873 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3874 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3875 tem = dequeue_event (&xrep, &x_mouse_queue);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3876 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3877
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3878 if (tem)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3879 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3880 switch (xrep.type)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3881 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3882 case ButtonPressed:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3883 case ButtonReleased:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3884
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3885 com_letter = encode_mouse_button (xrep);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3886 mouse_timestamp = xrep.MouseTime;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3887
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3888 if ((s = x_window_to_screen (xrep.MouseWindow)) != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3889 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3890 Lisp_Object screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3891
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3892 if (s->display.x->icon_desc == xrep.MouseWindow)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3893 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3894 x_make_screen_visible (s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3895 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3896 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3897
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3898 XSET (tempx, Lisp_Int,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3899 min (s->width-1, max (0, (xrep.MouseX - s->display.x->internal_border_width)/FONT_WIDTH (s->display.x->font))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3900 XSET (tempy, Lisp_Int,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3901 min (s->height-1, max (0, (xrep.MouseY - s->display.x->internal_border_width)/FONT_HEIGHT (s->display.x->font))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3902 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3903 XSET (screen, Lisp_Screen, s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3904
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3905 pos = Fcons (tempx, Fcons (tempy, Qnil));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3906 Vmouse_window
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3907 = Flocate_window_from_coordinates (screen, pos);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3908
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3909 Vmouse_event
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3910 = Fcons (pos,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3911 Fcons (Vmouse_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3912 Fcons (Qnil,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3913 Fcons (Fchar_to_string (make_number (com_letter)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3914 Fcons (timestamp, Qnil)))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3915 return Vmouse_event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3916 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3917 else if ((s = x_window_to_scrollbar (xrep.MouseWindow, &part, &prefix)) != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3918 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3919 int pos, len;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3920 Lisp_Object keyseq;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3921 char *partname;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3922
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3923 keyseq = concat2 (Fchar_to_string (make_number (prefix)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3924 Fchar_to_string (make_number (com_letter)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3925
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3926 pos = xrep.MouseY - (s->display.x->v_scrollbar_width - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3927 XSET (tempx, Lisp_Int, pos);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3928 len = ((FONT_HEIGHT (s->display.x->font) * s->height)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3929 + s->display.x->internal_border_width
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3930 - (2 * (s->display.x->v_scrollbar_width - 2)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3931 XSET (tempy, Lisp_Int, len);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3932 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3933 Vmouse_window = s->selected_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3934 Vmouse_event
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3935 = Fcons (Fcons (tempx, Fcons (tempy,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3936 Fcons (make_number (s->display.x->v_scrollbar_width - 2),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3937 Qnil))),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3938 Fcons (Vmouse_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3939 Fcons (intern (part),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3940 Fcons (keyseq, Fcons (timestamp,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3941 Qnil)))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3942 return Vmouse_event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3943 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3944 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3945 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3946
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3947 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3948 case MotionNotify:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3949
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3950 com_letter = x11_encode_mouse_button (xrep);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3951 if ((s = x_window_to_screen (xrep.MouseWindow)) != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3952 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3953 Lisp_Object screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3954
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3955 XSET (tempx, Lisp_Int,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3956 min (s->width-1,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3957 max (0, (xrep.MouseX - s->display.x->internal_border_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3958 / FONT_WIDTH (s->display.x->font))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3959 XSET (tempy, Lisp_Int,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3960 min (s->height-1,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3961 max (0, (xrep.MouseY - s->display.x->internal_border_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3962 / FONT_HEIGHT (s->display.x->font))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3963
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3964 XSET (screen, Lisp_Screen, s);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3965 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3966
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3967 pos = Fcons (tempx, Fcons (tempy, Qnil));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3968 Vmouse_window
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3969 = Flocate_window_from_coordinates (screen, pos);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3970
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3971 Vmouse_event
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3972 = Fcons (pos,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3973 Fcons (Vmouse_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3974 Fcons (Qnil,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3975 Fcons (Fchar_to_string (make_number (com_letter)),
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3976 Fcons (timestamp, Qnil)))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3977 return Vmouse_event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3978 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3979
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3980 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3981 #endif /* HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3982
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3983 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3984 if (s = x_window_to_screen (xrep.MouseWindow))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3985 Vmouse_window = s->selected_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3986 else if (s = x_window_to_scrollbar (xrep.MouseWindow, &part, &prefix))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3987 Vmouse_window = s->selected_window;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3988 return Vmouse_event = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3989 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3990 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3991
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3992 if (!NULL (arg))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3993 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3994
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3995 /* Wait till we get another mouse event. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3996 wait_reading_process_input (0, 0, 2, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3997 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3998 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3999 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4000
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4001
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4002 #ifndef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4003 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer, Sx_store_cut_buffer,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4004 1, 1, "sStore text in cut buffer: ",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4005 "Store contents of STRING into the cut buffer of the X window system.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4006 (string)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4007 register Lisp_Object string;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4008 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4009 int mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4010
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4011 CHECK_STRING (string, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4012 if (selected_screen->output_method != output_x_window)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4013 error ("Selected screen does not understand X protocol.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4014
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4015 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4016 XStoreBytes ((char *) XSTRING (string)->data, XSTRING (string)->size);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4017 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4018
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4019 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4020 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4021
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4022 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer, Sx_get_cut_buffer, 0, 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4023 "Return contents of cut buffer of the X window system, as a string.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4024 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4025 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4026 int len;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4027 register Lisp_Object string;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4028 int mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4029 register char *d;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4030
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4031 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4032 d = XFetchBytes (&len);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4033 string = make_string (d, len);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4034 XFree (d);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4035 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4036 return string;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4037 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4038 #endif /* X10 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4039
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4040 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4041 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4042 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4043 KEYSYM is a string which conforms to the X keysym definitions found\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4044 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4045 list of strings specifying modifier keys such as Control_L, which must\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4046 also be depressed for NEWSTRING to appear.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4047 (x_keysym, modifiers, newstring)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4048 register Lisp_Object x_keysym;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4049 register Lisp_Object modifiers;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4050 register Lisp_Object newstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4051 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4052 char *rawstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4053 register KeySym keysym, modifier_list[16];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4054
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4055 CHECK_STRING (x_keysym, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4056 CHECK_STRING (newstring, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4057
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4058 keysym = XStringToKeysym ((char *) XSTRING (x_keysym)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4059 if (keysym == NoSymbol)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4060 error ("Keysym does not exist");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4061
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4062 if (NULL (modifiers))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4063 XRebindKeysym (x_current_display, keysym, modifier_list, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4064 XSTRING (newstring)->data, XSTRING (newstring)->size);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4065 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4066 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4067 register Lisp_Object rest, mod;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4068 register int i = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4069
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4070 for (rest = modifiers; !NULL (rest); rest = Fcdr (rest))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4071 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4072 if (i == 16)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4073 error ("Can't have more than 16 modifiers");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4074
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4075 mod = Fcar (rest);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4076 CHECK_STRING (mod, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4077 modifier_list[i] = XStringToKeysym ((char *) XSTRING (mod)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4078 if (modifier_list[i] == NoSymbol
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4079 || !IsModifierKey (modifier_list[i]))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4080 error ("Element is not a modifier keysym");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4081 i++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4082 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4083
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4084 XRebindKeysym (x_current_display, keysym, modifier_list, i,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4085 XSTRING (newstring)->data, XSTRING (newstring)->size);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4086 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4087
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4088 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4089 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4090
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4091 DEFUN ("x-rebind-keys", Fx_rebind_keys, Sx_rebind_keys, 2, 2, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4092 "Rebind KEYCODE to list of strings STRINGS.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4093 STRINGS should be a list of 16 elements, one for each shift combination.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4094 nil as element means don't change.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4095 See the documentation of `x-rebind-key' for more information.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4096 (keycode, strings)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4097 register Lisp_Object keycode;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4098 register Lisp_Object strings;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4099 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4100 register Lisp_Object item;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4101 register unsigned char *rawstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4102 KeySym rawkey, modifier[1];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4103 int strsize;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4104 register unsigned i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4105
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4106 CHECK_NUMBER (keycode, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4107 CHECK_CONS (strings, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4108 rawkey = (KeySym) ((unsigned) (XINT (keycode))) & 255;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4109 for (i = 0; i <= 15; strings = Fcdr (strings), i++)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4110 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4111 item = Fcar (strings);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4112 if (!NULL (item))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4113 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4114 CHECK_STRING (item, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4115 strsize = XSTRING (item)->size;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4116 rawstring = (unsigned char *) xmalloc (strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4117 bcopy (XSTRING (item)->data, rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4118 modifier[1] = 1 << i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4119 XRebindKeysym (x_current_display, rawkey, modifier, 1,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4120 rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4121 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4122 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4123 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4124 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4125 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4126 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4127 "Rebind KEYCODE, with shift bits SHIFT-MASK, to new string NEWSTRING.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4128 KEYCODE and SHIFT-MASK should be numbers representing the X keyboard code\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4129 and shift mask respectively. NEWSTRING is an arbitrary string of keystrokes.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4130 If SHIFT-MASK is nil, then KEYCODE's key will be bound to NEWSTRING for\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4131 all shift combinations.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4132 Shift Lock 1 Shift 2\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4133 Meta 4 Control 8\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4134 \n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4135 For values of KEYCODE, see /usr/lib/Xkeymap.txt (remember that the codes\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4136 in that file are in octal!)\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4137 \n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4138 NOTE: due to an X bug, this function will not take effect unless one has\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4139 a `~/.Xkeymap' file. (See the documentation for the `keycomp' program.)\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4140 This problem will be fixed in X version 11.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4141
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4142 (keycode, shift_mask, newstring)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4143 register Lisp_Object keycode;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4144 register Lisp_Object shift_mask;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4145 register Lisp_Object newstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4146 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4147 char *rawstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4148 int keysym, rawshift;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4149 int i, strsize;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4150
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4151 CHECK_NUMBER (keycode, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4152 if (!NULL (shift_mask))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4153 CHECK_NUMBER (shift_mask, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4154 CHECK_STRING (newstring, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4155 strsize = XSTRING (newstring)->size;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4156 rawstring = (char *) xmalloc (strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4157 bcopy (XSTRING (newstring)->data, rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4158
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4159 keysym = ((unsigned) (XINT (keycode))) & 255;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4160
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4161 if (NULL (shift_mask))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4162 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4163 for (i = 0; i <= 15; i++)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4164 XRebindCode (keysym, i<<11, rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4165 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4166 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4167 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4168 rawshift = (((unsigned) (XINT (shift_mask))) & 15) << 11;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4169 XRebindCode (keysym, rawshift, rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4170 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4171 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4172 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4173
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4174 DEFUN ("x-rebind-keys", Fx_rebind_keys, Sx_rebind_keys, 2, 2, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4175 "Rebind KEYCODE to list of strings STRINGS.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4176 STRINGS should be a list of 16 elements, one for each shift combination.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4177 nil as element means don't change.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4178 See the documentation of `x-rebind-key' for more information.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4179 (keycode, strings)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4180 register Lisp_Object keycode;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4181 register Lisp_Object strings;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4182 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4183 register Lisp_Object item;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4184 register char *rawstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4185 KeySym rawkey, modifier[1];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4186 int strsize;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4187 register unsigned i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4188
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4189 CHECK_NUMBER (keycode, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4190 CHECK_CONS (strings, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4191 rawkey = (KeySym) ((unsigned) (XINT (keycode))) & 255;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4192 for (i = 0; i <= 15; strings = Fcdr (strings), i++)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4193 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4194 item = Fcar (strings);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4195 if (!NULL (item))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4196 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4197 CHECK_STRING (item, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4198 strsize = XSTRING (item)->size;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4199 rawstring = (char *) xmalloc (strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4200 bcopy (XSTRING (item)->data, rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4201 XRebindCode (rawkey, i << 11, rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4202 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4203 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4204 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4205 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4206 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4207
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4208 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4209 Visual *
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4210 select_visual (screen, depth)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4211 Screen *screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4212 unsigned int *depth;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4213 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4214 Visual *v;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4215 XVisualInfo *vinfo, vinfo_template;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4216 int n_visuals;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4217
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4218 v = DefaultVisualOfScreen (screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4219 vinfo_template.visualid = XVisualIDFromVisual (v);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4220 vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4221 &n_visuals);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4222 if (n_visuals != 1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4223 fatal ("Can't get proper X visual info");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4224
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4225 if ((1 << vinfo->depth) == vinfo->colormap_size)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4226 *depth = vinfo->depth;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4227 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4228 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4229 int i = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4230 int n = vinfo->colormap_size - 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4231 while (n)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4232 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4233 n = n >> 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4234 i++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4235 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4236 *depth = i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4237 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4238
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4239 XFree ((char *) vinfo);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4240 return v;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4241 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4242 #endif /* HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4243
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4244 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4245 1, 2, 0, "Open a connection to an X server.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4246 DISPLAY is the name of the display to connect to. Optional second\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4247 arg XRM_STRING is a string of resources in xrdb format.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4248 (display, xrm_string)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4249 Lisp_Object display, xrm_string;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4250 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4251 unsigned int n_planes;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4252 register Screen *x_screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4253 unsigned char *xrm_option;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4254
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4255 CHECK_STRING (display, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4256 if (x_current_display != 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4257 error ("X server connection is already initialized");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4258
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4259 /* This is what opens the connection and sets x_current_display.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4260 This also initializes many symbols, such as those used for input. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4261 x_term_init (XSTRING (display)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4262
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4263 Qtext_part = intern ("text-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4264 Qmodeline_part = intern ("modeline-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4265 Qvscrollbar_part = intern ("vscrollbar-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4266 Qvslider_part = intern ("vslider-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4267 Qvthumbup_part = intern ("vthumbup-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4268 Qvthumbdown_part = intern ("vthumbdown-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4269 Qhscrollbar_part = intern ("hscrollbar-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4270 Qhslider_part = intern ("hslider-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4271 Qhthumbleft_part = intern ("hthumbleft-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4272 Qhthumbright_part = intern ("hthumbright-part");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4273
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4274 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4275 XFASTINT (Vwindow_system_version) = 11;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4276
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4277 if (!EQ (xrm_string, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4278 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4279 CHECK_STRING (xrm_string, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4280 xrm_option = (unsigned char *) XSTRING (xrm_string);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4281 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4282 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4283 xrm_option = (unsigned char *) 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4284 xrdb = x_load_resources (x_current_display, xrm_option, EMACS_CLASS);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4285 x_current_display->db = xrdb;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4286
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4287 x_screen = DefaultScreenOfDisplay (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4288
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4289 x_screen_count = make_number (ScreenCount (x_current_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4290 Vx_vendor = build_string (ServerVendor (x_current_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4291 x_release = make_number (VendorRelease (x_current_display));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4292
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4293 x_screen_height = make_number (HeightOfScreen (x_screen));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4294 x_screen_height_mm = make_number (HeightMMOfScreen (x_screen));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4295 x_screen_width = make_number (WidthOfScreen (x_screen));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4296 x_screen_width_mm = make_number (WidthMMOfScreen (x_screen));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4297
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4298 switch (DoesBackingStore (x_screen))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4299 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4300 case Always:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4301 Vx_backing_store = intern ("Always");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4302 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4303
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4304 case WhenMapped:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4305 Vx_backing_store = intern ("WhenMapped");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4306 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4307
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4308 case NotUseful:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4309 Vx_backing_store = intern ("NotUseful");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4310 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4311
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4312 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4313 error ("Strange value for BackingStore.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4314 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4315 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4316
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4317 if (DoesSaveUnders (x_screen) == True)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4318 x_save_under = Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4319 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4320 x_save_under = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4321
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4322 screen_visual = select_visual (x_screen, &n_planes);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4323 x_screen_planes = make_number (n_planes);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4324 Vx_screen_visual = intern (x_visual_strings [screen_visual->class]);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4325
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4326 /* X Atoms used by emacs. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4327 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4328 Xatom_emacs_selection = XInternAtom (x_current_display, "_EMACS_SELECTION_",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4329 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4330 Xatom_clipboard = XInternAtom (x_current_display, "CLIPBOARD",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4331 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4332 Xatom_clipboard_selection = XInternAtom (x_current_display, "_EMACS_CLIPBOARD_",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4333 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4334 Xatom_wm_change_state = XInternAtom (x_current_display, "WM_CHANGE_STATE",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4335 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4336 Xatom_incremental = XInternAtom (x_current_display, "INCR",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4337 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4338 Xatom_multiple = XInternAtom (x_current_display, "MULTIPLE",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4339 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4340 Xatom_targets = XInternAtom (x_current_display, "TARGETS",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4341 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4342 Xatom_timestamp = XInternAtom (x_current_display, "TIMESTAMP",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4343 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4344 Xatom_delete = XInternAtom (x_current_display, "DELETE",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4345 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4346 Xatom_insert_selection = XInternAtom (x_current_display, "INSERT_SELECTION",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4347 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4348 Xatom_pair = XInternAtom (x_current_display, "XA_ATOM_PAIR",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4349 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4350 Xatom_insert_property = XInternAtom (x_current_display, "INSERT_PROPERTY",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4351 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4352 Xatom_text = XInternAtom (x_current_display, "TEXT",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4353 False);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4354 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4355 #else /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4356 XFASTINT (Vwindow_system_version) = 10;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4357 #endif /* not HAVE_X11 */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4358 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4359 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4360
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4361 DEFUN ("x-close-current-connection", Fx_close_current_connection,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4362 Sx_close_current_connection,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4363 0, 0, 0, "Close the connection to the current X server.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4364 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4365 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4366 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4367 /* This is ONLY used when killing emacs; For switching displays
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4368 we'll have to take care of setting CloseDownMode elsewhere. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4369
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4370 if (x_current_display)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4371 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4372 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4373 XSetCloseDownMode (x_current_display, DestroyAll);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4374 XCloseDisplay (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4375 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4376 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4377 fatal ("No current X display connection to close\n");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4378 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4379 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4380 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4381
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4382 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4383 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4384 If ON is nil, allow buffering of requests.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4385 Turning on synchronization prohibits the Xlib routines from buffering\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4386 requests and seriously degrades performance, but makes debugging much\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4387 easier.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4388 (on)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4389 Lisp_Object on;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4390 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4391 XSynchronize (x_current_display, !EQ (on, Qnil));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4392
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4393 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4394 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4395
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4396
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4397 syms_of_xfns ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4398 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4399 init_x_parm_symbols ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4400
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4401 /* This is zero if not using X windows. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4402 x_current_display = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4403
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4404 Qundefined_color = intern ("undefined-color");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4405 Fput (Qundefined_color, Qerror_conditions,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4406 Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4407 Fput (Qundefined_color, Qerror_message,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4408 build_string ("Undefined color"));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4409
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4410 DEFVAR_INT ("mouse-x-position", &x_mouse_x,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4411 "The X coordinate of the mouse position, in characters.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4412 x_mouse_x = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4413
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4414 DEFVAR_INT ("mouse-y-position", &x_mouse_y,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4415 "The Y coordinate of the mouse position, in characters.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4416 x_mouse_y = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4417
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4418 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4419 "The buffer offset of the character under the pointer.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4420 mouse_buffer_offset = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4421
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4422 DEFVAR_LISP ("mouse-screen-part", &Vmouse_screen_part,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4423 "A symbol indicating the part of the screen the mouse is in.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4424 Vmouse_screen_part = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4425
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4426 DEFVAR_INT ("x-pointer-shape", &Vx_pointer_shape,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4427 "The shape of the pointer when over text.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4428 Vx_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4429
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4430 DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4431 "The shape of the pointer when not over text.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4432 Vx_nontext_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4433
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4434 DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4435 "The shape of the pointer when not over text.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4436 Vx_mode_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4437
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4438 DEFVAR_LISP ("x-bar-cursor", &Vbar_cursor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4439 "*If non-nil, use a vertical bar cursor. Otherwise, use the traditional box.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4440 Vbar_cursor = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4441
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4442 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4443 "A string indicating the foreground color of the cursor box.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4444 Vx_cursor_fore_pixel = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4445
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4446 DEFVAR_LISP ("mouse-grabbed", &Vmouse_depressed,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4447 "Non-nil if a mouse button is currently depressed.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4448 Vmouse_depressed = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4449
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4450 DEFVAR_INT ("x-screen-count", &x_screen_count,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4451 "The number of screens associated with the current display.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4452 DEFVAR_INT ("x-release", &x_release,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4453 "The release number of the X server in use.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4454 DEFVAR_LISP ("x-vendor", &Vx_vendor,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4455 "The vendor supporting the X server in use.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4456 DEFVAR_INT ("x-screen-height", &x_screen_height,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4457 "The height of this X screen in pixels.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4458 DEFVAR_INT ("x-screen-height-mm", &x_screen_height_mm,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4459 "The height of this X screen in millimeters.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4460 DEFVAR_INT ("x-screen-width", &x_screen_width,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4461 "The width of this X screen in pixels.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4462 DEFVAR_INT ("x-screen-width-mm", &x_screen_width_mm,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4463 "The width of this X screen in millimeters.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4464 DEFVAR_LISP ("x-backing-store", &Vx_backing_store,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4465 "The backing store capability of this screen.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4466 Values can be the symbols Always, WhenMapped, or NotUseful.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4467 DEFVAR_BOOL ("x-save-under", &x_save_under,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4468 "*Non-nil means this X screen supports the SaveUnder feature.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4469 DEFVAR_INT ("x-screen-planes", &x_screen_planes,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4470 "The number of planes this monitor supports.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4471 DEFVAR_LISP ("x-screen-visual", &Vx_screen_visual,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4472 "The default X visual for this X screen.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4473 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4474 "t if no X window manager is in use.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4475
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4476 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4477 defsubr (&Sx_get_resource);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4478 defsubr (&Sx_pixel_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4479 defsubr (&Sx_pixel_height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4480 defsubr (&Sx_draw_rectangle);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4481 defsubr (&Sx_erase_rectangle);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4482 defsubr (&Sx_contour_region);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4483 defsubr (&Sx_uncontour_region);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4484 defsubr (&Sx_color_display_p);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4485 defsubr (&Sx_defined_color);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4486 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4487 defsubr (&Sx_track_pointer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4488 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4489 defsubr (&Sx_grab_pointer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4490 defsubr (&Sx_ungrab_pointer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4491 #else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4492 defsubr (&Sx_get_default);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4493 defsubr (&Sx_store_cut_buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4494 defsubr (&Sx_get_cut_buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4495 defsubr (&Sx_set_face);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4496 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4497 defsubr (&Sx_geometry);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4498 defsubr (&Sx_create_screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4499 defsubr (&Sfocus_screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4500 defsubr (&Sunfocus_screen);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4501 defsubr (&Sx_horizontal_line);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4502 defsubr (&Sx_rebind_key);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4503 defsubr (&Sx_rebind_keys);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4504 defsubr (&Sx_open_connection);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4505 defsubr (&Sx_close_current_connection);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4506 defsubr (&Sx_synchronize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4507
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4508 /* This was used in the old event interface which used a separate
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4509 event queue.*/
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4510 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4511 defsubr (&Sx_mouse_events);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4512 defsubr (&Sx_get_mouse_event);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4513 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4514 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4515
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4516 #endif /* HAVE_X_WINDOWS */