Mercurial > emacs
annotate src/xfns.c @ 815:6aabed5f5d58
entered into RCS
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Fri, 17 Jul 1992 20:35:53 +0000 |
parents | 538c0bcb418e |
children | 1dd126823b36 |
rev | line source |
---|---|
389 | 1 /* Functions for the X window system. |
708 | 2 Copyright (C) 1989, 1992 Free Software Foundation. |
389 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
708 | 8 the Free Software Foundation; either version 2, or (at your option) |
389 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 /* Completely rewritten by Richard Stallman. */ | |
21 | |
22 /* Rewritten for X11 by Joseph Arceneaux */ | |
23 | |
24 #if 0 | |
25 #include <stdio.h> | |
26 #endif | |
27 #include <signal.h> | |
28 #include "config.h" | |
29 #include "lisp.h" | |
30 #include "xterm.h" | |
771 | 31 #include "frame.h" |
389 | 32 #include "window.h" |
33 #include "buffer.h" | |
34 #include "dispextern.h" | |
35 #include "xscrollbar.h" | |
515 | 36 #include "keyboard.h" |
389 | 37 |
38 #ifdef HAVE_X_WINDOWS | |
39 extern void abort (); | |
40 | |
771 | 41 void x_set_frame_param (); |
389 | 42 |
43 #define min(a,b) ((a) < (b) ? (a) : (b)) | |
44 #define max(a,b) ((a) > (b) ? (a) : (b)) | |
45 | |
46 #ifdef HAVE_X11 | |
47 /* X Resource data base */ | |
48 static XrmDatabase xrdb; | |
49 | |
50 /* The class of this X application. */ | |
51 #define EMACS_CLASS "Emacs" | |
52 | |
53 /* Title name and application name for X stuff. */ | |
398 | 54 extern char *x_id_name; |
389 | 55 extern Lisp_Object invocation_name; |
56 | |
57 /* The background and shape of the mouse pointer, and shape when not | |
58 over text or in the modeline. */ | |
59 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape; | |
60 | |
61 /* Color of chars displayed in cursor box. */ | |
62 Lisp_Object Vx_cursor_fore_pixel; | |
63 | |
64 /* If non-nil, use vertical bar cursor. */ | |
65 Lisp_Object Vbar_cursor; | |
66 | |
67 /* The X Visual we are using for X windows (the default) */ | |
68 Visual *screen_visual; | |
69 | |
70 /* How many screens this X display has. */ | |
71 int x_screen_count; | |
72 | |
73 /* The vendor supporting this X server. */ | |
74 Lisp_Object Vx_vendor; | |
75 | |
76 /* The vendor's release number for this X server. */ | |
77 int x_release; | |
78 | |
79 /* Height of this X screen in pixels. */ | |
80 int x_screen_height; | |
81 | |
82 /* Height of this X screen in millimeters. */ | |
83 int x_screen_height_mm; | |
84 | |
85 /* Width of this X screen in pixels. */ | |
86 int x_screen_width; | |
87 | |
88 /* Width of this X screen in millimeters. */ | |
89 int x_screen_width_mm; | |
90 | |
91 /* Does this X screen do backing store? */ | |
92 Lisp_Object Vx_backing_store; | |
93 | |
94 /* Does this X screen do save-unders? */ | |
95 int x_save_under; | |
96 | |
97 /* Number of planes for this screen. */ | |
98 int x_screen_planes; | |
99 | |
100 /* X Visual type of this screen. */ | |
101 Lisp_Object Vx_screen_visual; | |
102 | |
103 /* Non nil if no window manager is in use. */ | |
104 Lisp_Object Vx_no_window_manager; | |
105 | |
106 static char *x_visual_strings[] = | |
107 { | |
108 "StaticGray", | |
109 "GrayScale", | |
110 "StaticColor", | |
111 "PseudoColor", | |
112 "TrueColor", | |
113 "DirectColor" | |
114 }; | |
115 | |
116 /* `t' if a mouse button is depressed. */ | |
117 | |
118 Lisp_Object Vmouse_depressed; | |
119 | |
700
6a15fb0422ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
697
diff
changeset
|
120 extern unsigned int x_mouse_x, x_mouse_y, x_mouse_grabbed; |
6a15fb0422ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
697
diff
changeset
|
121 extern Lisp_Object unread_command_char; |
6a15fb0422ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
697
diff
changeset
|
122 |
389 | 123 /* Atom for indicating window state to the window manager. */ |
124 Atom Xatom_wm_change_state; | |
125 | |
126 /* When emacs became the selection owner. */ | |
127 extern Time x_begin_selection_own; | |
128 | |
129 /* The value of the current emacs selection. */ | |
130 extern Lisp_Object Vx_selection_value; | |
131 | |
132 /* Emacs' selection property identifier. */ | |
133 extern Atom Xatom_emacs_selection; | |
134 | |
135 /* Clipboard selection atom. */ | |
136 extern Atom Xatom_clipboard_selection; | |
137 | |
138 /* Clipboard atom. */ | |
139 extern Atom Xatom_clipboard; | |
140 | |
141 /* Atom for indicating incremental selection transfer. */ | |
142 extern Atom Xatom_incremental; | |
143 | |
144 /* Atom for indicating multiple selection request list */ | |
145 extern Atom Xatom_multiple; | |
146 | |
147 /* Atom for what targets emacs handles. */ | |
148 extern Atom Xatom_targets; | |
149 | |
150 /* Atom for indicating timstamp selection request */ | |
151 extern Atom Xatom_timestamp; | |
152 | |
153 /* Atom requesting we delete our selection. */ | |
154 extern Atom Xatom_delete; | |
155 | |
156 /* Selection magic. */ | |
157 extern Atom Xatom_insert_selection; | |
158 | |
159 /* Type of property for INSERT_SELECTION. */ | |
160 extern Atom Xatom_pair; | |
161 | |
162 /* More selection magic. */ | |
163 extern Atom Xatom_insert_property; | |
164 | |
165 /* Atom for indicating property type TEXT */ | |
166 extern Atom Xatom_text; | |
167 | |
641 | 168 /* Communication with window managers. */ |
169 extern Atom Xatom_wm_protocols; | |
170 | |
171 /* Kinds of protocol things we may receive. */ | |
172 extern Atom Xatom_wm_take_focus; | |
173 extern Atom Xatom_wm_save_yourself; | |
174 extern Atom Xatom_wm_delete_window; | |
175 | |
176 /* Other WM communication */ | |
642 | 177 extern Atom Xatom_wm_configure_denied; /* When our config request is denied */ |
178 extern Atom Xatom_wm_window_moved; /* When the WM moves us. */ | |
641 | 179 |
389 | 180 #else /* X10 */ |
181 | |
182 /* Default size of an Emacs window without scroll bar. */ | |
183 static char *default_window = "=80x24+0+0"; | |
184 | |
185 #define MAXICID 80 | |
186 char iconidentity[MAXICID]; | |
187 #define ICONTAG "emacs@" | |
188 char minibuffer_iconidentity[MAXICID]; | |
189 #define MINIBUFFER_ICONTAG "minibuffer@" | |
190 | |
191 #endif /* X10 */ | |
192 | |
193 /* The last 23 bits of the timestamp of the last mouse button event. */ | |
194 Time mouse_timestamp; | |
195 | |
196 Lisp_Object Qundefined_color; | |
771 | 197 Lisp_Object Qx_frame_parameter; |
389 | 198 |
199 extern Lisp_Object Vwindow_system_version; | |
200 | |
201 /* Mouse map for clicks in windows. */ | |
202 extern Lisp_Object Vglobal_mouse_map; | |
203 | |
204 /* Points to table of defined typefaces. */ | |
205 struct face *x_face_table[MAX_FACES_AND_GLYPHS]; | |
206 | |
771 | 207 /* Return the Emacs frame-object corresponding to an X window. |
208 It could be the frame's main window or an icon window. */ | |
209 | |
210 struct frame * | |
211 x_window_to_frame (wdesc) | |
389 | 212 int wdesc; |
213 { | |
771 | 214 Lisp_Object tail, frame; |
215 struct frame *f; | |
216 | |
217 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) | |
389 | 218 { |
771 | 219 frame = XCONS (tail)->car; |
220 if (XTYPE (frame) != Lisp_Frame) | |
389 | 221 continue; |
771 | 222 f = XFRAME (frame); |
223 if (f->display.x->window_desc == wdesc | |
224 || f->display.x->icon_desc == wdesc) | |
225 return f; | |
389 | 226 } |
227 return 0; | |
228 } | |
229 | |
771 | 230 /* Map an X window that implements a scroll bar to the Emacs frame it |
389 | 231 belongs to. Also store in *PART a symbol identifying which part of |
232 the scroll bar it is. */ | |
233 | |
771 | 234 struct frame * |
389 | 235 x_window_to_scrollbar (wdesc, part_ptr, prefix_ptr) |
236 int wdesc; | |
237 Lisp_Object *part_ptr; | |
238 enum scroll_bar_prefix *prefix_ptr; | |
239 { | |
771 | 240 Lisp_Object tail, frame; |
241 struct frame *f; | |
242 | |
243 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) | |
389 | 244 { |
771 | 245 frame = XCONS (tail)->car; |
246 if (XTYPE (frame) != Lisp_Frame) | |
389 | 247 continue; |
248 | |
771 | 249 f = XFRAME (frame); |
389 | 250 if (part_ptr == 0 && prefix_ptr == 0) |
771 | 251 return f; |
252 | |
253 if (f->display.x->v_scrollbar == wdesc) | |
389 | 254 { |
255 *part_ptr = Qvscrollbar_part; | |
256 *prefix_ptr = VSCROLL_BAR_PREFIX; | |
771 | 257 return f; |
389 | 258 } |
771 | 259 else if (f->display.x->v_slider == wdesc) |
389 | 260 { |
261 *part_ptr = Qvslider_part; | |
262 *prefix_ptr = VSCROLL_SLIDER_PREFIX; | |
771 | 263 return f; |
389 | 264 } |
771 | 265 else if (f->display.x->v_thumbup == wdesc) |
389 | 266 { |
267 *part_ptr = Qvthumbup_part; | |
268 *prefix_ptr = VSCROLL_THUMBUP_PREFIX; | |
771 | 269 return f; |
389 | 270 } |
771 | 271 else if (f->display.x->v_thumbdown == wdesc) |
389 | 272 { |
273 *part_ptr = Qvthumbdown_part; | |
274 *prefix_ptr = VSCROLL_THUMBDOWN_PREFIX; | |
771 | 275 return f; |
389 | 276 } |
771 | 277 else if (f->display.x->h_scrollbar == wdesc) |
389 | 278 { |
279 *part_ptr = Qhscrollbar_part; | |
280 *prefix_ptr = HSCROLL_BAR_PREFIX; | |
771 | 281 return f; |
389 | 282 } |
771 | 283 else if (f->display.x->h_slider == wdesc) |
389 | 284 { |
285 *part_ptr = Qhslider_part; | |
286 *prefix_ptr = HSCROLL_SLIDER_PREFIX; | |
771 | 287 return f; |
389 | 288 } |
771 | 289 else if (f->display.x->h_thumbleft == wdesc) |
389 | 290 { |
291 *part_ptr = Qhthumbleft_part; | |
292 *prefix_ptr = HSCROLL_THUMBLEFT_PREFIX; | |
771 | 293 return f; |
389 | 294 } |
771 | 295 else if (f->display.x->h_thumbright == wdesc) |
389 | 296 { |
297 *part_ptr = Qhthumbright_part; | |
298 *prefix_ptr = HSCROLL_THUMBRIGHT_PREFIX; | |
771 | 299 return f; |
389 | 300 } |
301 } | |
302 return 0; | |
303 } | |
304 | |
771 | 305 /* Connect the frame-parameter names for X frames |
389 | 306 to the ways of passing the parameter values to the window system. |
307 | |
308 The name of a parameter, as a Lisp symbol, | |
771 | 309 has an `x-frame-parameter' property which is an integer in Lisp |
310 but can be interpreted as an `enum x_frame_parm' in C. */ | |
311 | |
312 enum x_frame_parm | |
389 | 313 { |
314 X_PARM_FOREGROUND_COLOR, | |
315 X_PARM_BACKGROUND_COLOR, | |
316 X_PARM_MOUSE_COLOR, | |
317 X_PARM_CURSOR_COLOR, | |
318 X_PARM_BORDER_COLOR, | |
319 X_PARM_ICON_TYPE, | |
320 X_PARM_FONT, | |
321 X_PARM_BORDER_WIDTH, | |
322 X_PARM_INTERNAL_BORDER_WIDTH, | |
323 X_PARM_NAME, | |
324 X_PARM_AUTORAISE, | |
325 X_PARM_AUTOLOWER, | |
326 X_PARM_VERT_SCROLLBAR, | |
327 X_PARM_HORIZ_SCROLLBAR, | |
328 }; | |
329 | |
330 | |
771 | 331 struct x_frame_parm_table |
389 | 332 { |
333 char *name; | |
771 | 334 void (*setter)( /* struct frame *frame, Lisp_Object val, oldval */ ); |
389 | 335 }; |
336 | |
337 void x_set_foreground_color (); | |
338 void x_set_background_color (); | |
339 void x_set_mouse_color (); | |
340 void x_set_cursor_color (); | |
341 void x_set_border_color (); | |
342 void x_set_icon_type (); | |
343 void x_set_font (); | |
344 void x_set_border_width (); | |
345 void x_set_internal_border_width (); | |
346 void x_set_name (); | |
347 void x_set_autoraise (); | |
348 void x_set_autolower (); | |
349 void x_set_vertical_scrollbar (); | |
350 void x_set_horizontal_scrollbar (); | |
351 | |
771 | 352 static struct x_frame_parm_table x_frame_parms[] = |
389 | 353 { |
354 "foreground-color", x_set_foreground_color, | |
355 "background-color", x_set_background_color, | |
356 "mouse-color", x_set_mouse_color, | |
357 "cursor-color", x_set_cursor_color, | |
358 "border-color", x_set_border_color, | |
359 "icon-type", x_set_icon_type, | |
360 "font", x_set_font, | |
361 "border-width", x_set_border_width, | |
362 "internal-border-width", x_set_internal_border_width, | |
363 "name", x_set_name, | |
364 "autoraise", x_set_autoraise, | |
365 "autolower", x_set_autolower, | |
366 "vertical-scrollbar", x_set_vertical_scrollbar, | |
367 "horizontal-scrollbar", x_set_horizontal_scrollbar, | |
368 }; | |
369 | |
771 | 370 /* Attach the `x-frame-parameter' properties to |
389 | 371 the Lisp symbol names of parameters relevant to X. */ |
372 | |
373 init_x_parm_symbols () | |
374 { | |
375 int i; | |
376 | |
771 | 377 Qx_frame_parameter = intern ("x-frame-parameter"); |
378 | |
379 for (i = 0; i < sizeof (x_frame_parms)/sizeof (x_frame_parms[0]); i++) | |
380 Fput (intern (x_frame_parms[i].name), Qx_frame_parameter, | |
389 | 381 make_number (i)); |
382 } | |
383 | |
771 | 384 /* Report to X that a frame parameter of frame F is being set or changed. |
389 | 385 PARAM is the symbol that says which parameter. |
386 VAL is the new value. | |
387 OLDVAL is the old value. | |
388 If the parameter is not specially recognized, do nothing; | |
389 otherwise the `x_set_...' function for this parameter. */ | |
390 | |
391 void | |
771 | 392 x_set_frame_param (f, param, val, oldval) |
393 register struct frame *f; | |
389 | 394 Lisp_Object param; |
395 register Lisp_Object val; | |
396 register Lisp_Object oldval; | |
397 { | |
398 register Lisp_Object tem; | |
771 | 399 tem = Fget (param, Qx_frame_parameter); |
389 | 400 if (XTYPE (tem) == Lisp_Int |
401 && XINT (tem) >= 0 | |
771 | 402 && XINT (tem) < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])) |
403 (*x_frame_parms[XINT (tem)].setter)(f, val, oldval); | |
389 | 404 } |
405 | |
771 | 406 /* Insert a description of internally-recorded parameters of frame X |
389 | 407 into the parameter alist *ALISTPTR that is to be given to the user. |
408 Only parameters that are specific to the X window system | |
771 | 409 and whose values are not correctly recorded in the frame's |
389 | 410 param_alist need to be considered here. */ |
411 | |
771 | 412 x_report_frame_params (f, alistptr) |
413 struct frame *f; | |
389 | 414 Lisp_Object *alistptr; |
415 { | |
416 char buf[16]; | |
417 | |
771 | 418 store_in_alist (alistptr, "left", make_number (f->display.x->left_pos)); |
419 store_in_alist (alistptr, "top", make_number (f->display.x->top_pos)); | |
389 | 420 store_in_alist (alistptr, "border-width", |
771 | 421 make_number (f->display.x->border_width)); |
389 | 422 store_in_alist (alistptr, "internal-border-width", |
771 | 423 make_number (f->display.x->internal_border_width)); |
424 sprintf (buf, "%d", f->display.x->window_desc); | |
389 | 425 store_in_alist (alistptr, "window-id", |
426 build_string (buf)); | |
427 } | |
428 | |
429 /* Decide if color named COLOR is valid for the display | |
771 | 430 associated with the selected frame. */ |
389 | 431 int |
432 defined_color (color, color_def) | |
433 char *color; | |
434 Color *color_def; | |
435 { | |
436 register int foo; | |
437 Colormap screen_colormap; | |
438 | |
439 BLOCK_INPUT; | |
440 #ifdef HAVE_X11 | |
441 screen_colormap | |
442 = DefaultColormap (x_current_display, XDefaultScreen (x_current_display)); | |
443 | |
444 foo = XParseColor (x_current_display, screen_colormap, | |
445 color, color_def) | |
446 && XAllocColor (x_current_display, screen_colormap, color_def); | |
447 #else | |
448 foo = XParseColor (color, color_def) && XGetHardwareColor (color_def); | |
449 #endif /* not HAVE_X11 */ | |
450 UNBLOCK_INPUT; | |
451 | |
452 if (foo) | |
453 return 1; | |
454 else | |
455 return 0; | |
456 } | |
457 | |
458 /* Given a string ARG naming a color, compute a pixel value from it | |
771 | 459 suitable for screen F. |
460 If F is not a color screen, return DEF (default) regardless of what | |
389 | 461 ARG says. */ |
462 | |
463 int | |
464 x_decode_color (arg, def) | |
465 Lisp_Object arg; | |
466 int def; | |
467 { | |
468 Color cdef; | |
469 | |
470 CHECK_STRING (arg, 0); | |
471 | |
472 if (strcmp (XSTRING (arg)->data, "black") == 0) | |
473 return BLACK_PIX_DEFAULT; | |
474 else if (strcmp (XSTRING (arg)->data, "white") == 0) | |
475 return WHITE_PIX_DEFAULT; | |
476 | |
477 #ifdef HAVE_X11 | |
485 | 478 if (XFASTINT (x_screen_planes) == 1) |
389 | 479 return def; |
480 #else | |
485 | 481 if (DISPLAY_CELLS == 1) |
389 | 482 return def; |
483 #endif | |
484 | |
485 if (defined_color (XSTRING (arg)->data, &cdef)) | |
486 return cdef.pixel; | |
487 else | |
488 Fsignal (Qundefined_color, Fcons (arg, Qnil)); | |
489 } | |
490 | |
771 | 491 /* Functions called only from `x_set_frame_param' |
389 | 492 to set individual parameters. |
493 | |
771 | 494 If f->display.x->window_desc is 0, |
495 the frame is being created and its X-window does not exist yet. | |
389 | 496 In that case, just record the parameter's new value |
497 in the standard place; do not attempt to change the window. */ | |
498 | |
499 void | |
771 | 500 x_set_foreground_color (f, arg, oldval) |
501 struct frame *f; | |
389 | 502 Lisp_Object arg, oldval; |
503 { | |
771 | 504 f->display.x->foreground_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); |
505 if (f->display.x->window_desc != 0) | |
389 | 506 { |
507 #ifdef HAVE_X11 | |
508 BLOCK_INPUT; | |
771 | 509 XSetForeground (x_current_display, f->display.x->normal_gc, |
510 f->display.x->foreground_pixel); | |
511 XSetBackground (x_current_display, f->display.x->reverse_gc, | |
512 f->display.x->foreground_pixel); | |
513 if (f->display.x->v_scrollbar) | |
389 | 514 { |
515 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap; | |
516 | |
771 | 517 XSetWindowBorder (x_current_display, f->display.x->v_scrollbar, |
518 f->display.x->foreground_pixel); | |
389 | 519 |
520 slider_pixmap = | |
771 | 521 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 522 gray_bits, 16, 16, |
771 | 523 f->display.x->foreground_pixel, |
524 f->display.x->background_pixel, | |
389 | 525 DefaultDepth (x_current_display, |
526 XDefaultScreen (x_current_display))); | |
527 up_arrow_pixmap = | |
771 | 528 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 529 up_arrow_bits, 16, 16, |
771 | 530 f->display.x->foreground_pixel, |
531 f->display.x->background_pixel, | |
389 | 532 DefaultDepth (x_current_display, |
533 XDefaultScreen (x_current_display))); | |
534 down_arrow_pixmap = | |
771 | 535 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 536 down_arrow_bits, 16, 16, |
771 | 537 f->display.x->foreground_pixel, |
538 f->display.x->background_pixel, | |
389 | 539 DefaultDepth (x_current_display, |
540 XDefaultScreen (x_current_display))); | |
541 | |
771 | 542 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbup, |
389 | 543 up_arrow_pixmap); |
771 | 544 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbdown, |
389 | 545 down_arrow_pixmap); |
771 | 546 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_slider, |
389 | 547 slider_pixmap); |
548 | |
771 | 549 XClearWindow (XDISPLAY f->display.x->v_thumbup); |
550 XClearWindow (XDISPLAY f->display.x->v_thumbdown); | |
551 XClearWindow (XDISPLAY f->display.x->v_slider); | |
389 | 552 |
553 XFreePixmap (x_current_display, down_arrow_pixmap); | |
554 XFreePixmap (x_current_display, up_arrow_pixmap); | |
555 XFreePixmap (x_current_display, slider_pixmap); | |
556 } | |
771 | 557 if (f->display.x->h_scrollbar) |
389 | 558 { |
559 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap; | |
560 | |
771 | 561 XSetWindowBorder (x_current_display, f->display.x->h_scrollbar, |
562 f->display.x->foreground_pixel); | |
389 | 563 |
564 slider_pixmap = | |
771 | 565 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 566 gray_bits, 16, 16, |
771 | 567 f->display.x->foreground_pixel, |
568 f->display.x->background_pixel, | |
389 | 569 DefaultDepth (x_current_display, |
570 XDefaultScreen (x_current_display))); | |
571 | |
572 left_arrow_pixmap = | |
771 | 573 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 574 up_arrow_bits, 16, 16, |
771 | 575 f->display.x->foreground_pixel, |
576 f->display.x->background_pixel, | |
389 | 577 DefaultDepth (x_current_display, |
578 XDefaultScreen (x_current_display))); | |
579 right_arrow_pixmap = | |
771 | 580 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 581 down_arrow_bits, 16, 16, |
771 | 582 f->display.x->foreground_pixel, |
583 f->display.x->background_pixel, | |
389 | 584 DefaultDepth (x_current_display, |
585 XDefaultScreen (x_current_display))); | |
586 | |
771 | 587 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_slider, |
389 | 588 slider_pixmap); |
771 | 589 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbleft, |
389 | 590 left_arrow_pixmap); |
771 | 591 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbright, |
389 | 592 right_arrow_pixmap); |
593 | |
771 | 594 XClearWindow (XDISPLAY f->display.x->h_thumbleft); |
595 XClearWindow (XDISPLAY f->display.x->h_thumbright); | |
596 XClearWindow (XDISPLAY f->display.x->h_slider); | |
389 | 597 |
598 XFreePixmap (x_current_display, slider_pixmap); | |
599 XFreePixmap (x_current_display, left_arrow_pixmap); | |
600 XFreePixmap (x_current_display, right_arrow_pixmap); | |
601 } | |
602 UNBLOCK_INPUT; | |
603 #endif /* HAVE_X11 */ | |
771 | 604 if (f->visible) |
605 redraw_frame (f); | |
389 | 606 } |
607 } | |
608 | |
609 void | |
771 | 610 x_set_background_color (f, arg, oldval) |
611 struct frame *f; | |
389 | 612 Lisp_Object arg, oldval; |
613 { | |
614 Pixmap temp; | |
615 int mask; | |
616 | |
771 | 617 f->display.x->background_pixel = x_decode_color (arg, WHITE_PIX_DEFAULT); |
618 | |
619 if (f->display.x->window_desc != 0) | |
389 | 620 { |
621 BLOCK_INPUT; | |
622 #ifdef HAVE_X11 | |
771 | 623 /* The main frame area. */ |
624 XSetBackground (x_current_display, f->display.x->normal_gc, | |
625 f->display.x->background_pixel); | |
626 XSetForeground (x_current_display, f->display.x->reverse_gc, | |
627 f->display.x->background_pixel); | |
628 XSetWindowBackground (x_current_display, f->display.x->window_desc, | |
629 f->display.x->background_pixel); | |
389 | 630 |
631 /* Scroll bars. */ | |
771 | 632 if (f->display.x->v_scrollbar) |
389 | 633 { |
634 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap; | |
635 | |
771 | 636 XSetWindowBackground (x_current_display, f->display.x->v_scrollbar, |
637 f->display.x->background_pixel); | |
389 | 638 |
639 slider_pixmap = | |
771 | 640 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 641 gray_bits, 16, 16, |
771 | 642 f->display.x->foreground_pixel, |
643 f->display.x->background_pixel, | |
389 | 644 DefaultDepth (x_current_display, |
645 XDefaultScreen (x_current_display))); | |
646 up_arrow_pixmap = | |
771 | 647 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 648 up_arrow_bits, 16, 16, |
771 | 649 f->display.x->foreground_pixel, |
650 f->display.x->background_pixel, | |
389 | 651 DefaultDepth (x_current_display, |
652 XDefaultScreen (x_current_display))); | |
653 down_arrow_pixmap = | |
771 | 654 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 655 down_arrow_bits, 16, 16, |
771 | 656 f->display.x->foreground_pixel, |
657 f->display.x->background_pixel, | |
389 | 658 DefaultDepth (x_current_display, |
659 XDefaultScreen (x_current_display))); | |
660 | |
771 | 661 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbup, |
389 | 662 up_arrow_pixmap); |
771 | 663 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbdown, |
389 | 664 down_arrow_pixmap); |
771 | 665 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_slider, |
389 | 666 slider_pixmap); |
667 | |
771 | 668 XClearWindow (XDISPLAY f->display.x->v_thumbup); |
669 XClearWindow (XDISPLAY f->display.x->v_thumbdown); | |
670 XClearWindow (XDISPLAY f->display.x->v_slider); | |
389 | 671 |
672 XFreePixmap (x_current_display, down_arrow_pixmap); | |
673 XFreePixmap (x_current_display, up_arrow_pixmap); | |
674 XFreePixmap (x_current_display, slider_pixmap); | |
675 } | |
771 | 676 if (f->display.x->h_scrollbar) |
389 | 677 { |
678 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap; | |
679 | |
771 | 680 XSetWindowBackground (x_current_display, f->display.x->h_scrollbar, |
681 f->display.x->background_pixel); | |
389 | 682 |
683 slider_pixmap = | |
771 | 684 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 685 gray_bits, 16, 16, |
771 | 686 f->display.x->foreground_pixel, |
687 f->display.x->background_pixel, | |
389 | 688 DefaultDepth (x_current_display, |
689 XDefaultScreen (x_current_display))); | |
690 | |
691 left_arrow_pixmap = | |
771 | 692 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 693 up_arrow_bits, 16, 16, |
771 | 694 f->display.x->foreground_pixel, |
695 f->display.x->background_pixel, | |
389 | 696 DefaultDepth (x_current_display, |
697 XDefaultScreen (x_current_display))); | |
698 right_arrow_pixmap = | |
771 | 699 XCreatePixmapFromBitmapData (XDISPLAY f->display.x->window_desc, |
389 | 700 down_arrow_bits, 16, 16, |
771 | 701 f->display.x->foreground_pixel, |
702 f->display.x->background_pixel, | |
389 | 703 DefaultDepth (x_current_display, |
704 XDefaultScreen (x_current_display))); | |
705 | |
771 | 706 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_slider, |
389 | 707 slider_pixmap); |
771 | 708 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbleft, |
389 | 709 left_arrow_pixmap); |
771 | 710 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbright, |
389 | 711 right_arrow_pixmap); |
712 | |
771 | 713 XClearWindow (XDISPLAY f->display.x->h_thumbleft); |
714 XClearWindow (XDISPLAY f->display.x->h_thumbright); | |
715 XClearWindow (XDISPLAY f->display.x->h_slider); | |
389 | 716 |
717 XFreePixmap (x_current_display, slider_pixmap); | |
718 XFreePixmap (x_current_display, left_arrow_pixmap); | |
719 XFreePixmap (x_current_display, right_arrow_pixmap); | |
720 } | |
721 #else | |
771 | 722 temp = XMakeTile (f->display.x->background_pixel); |
723 XChangeBackground (f->display.x->window_desc, temp); | |
389 | 724 XFreePixmap (temp); |
725 #endif /* not HAVE_X11 */ | |
726 UNBLOCK_INPUT; | |
727 | |
771 | 728 if (f->visible) |
729 redraw_frame (f); | |
389 | 730 } |
731 } | |
732 | |
733 void | |
771 | 734 x_set_mouse_color (f, arg, oldval) |
735 struct frame *f; | |
389 | 736 Lisp_Object arg, oldval; |
737 { | |
738 Cursor cursor, nontext_cursor, mode_cursor; | |
739 int mask_color; | |
740 | |
741 if (!EQ (Qnil, arg)) | |
771 | 742 f->display.x->mouse_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); |
743 mask_color = f->display.x->background_pixel; | |
389 | 744 /* No invisible pointers. */ |
771 | 745 if (mask_color == f->display.x->mouse_pixel |
746 && mask_color == f->display.x->background_pixel) | |
747 f->display.x->mouse_pixel = f->display.x->foreground_pixel; | |
389 | 748 |
749 BLOCK_INPUT; | |
750 #ifdef HAVE_X11 | |
751 if (!EQ (Qnil, Vx_pointer_shape)) | |
752 { | |
753 CHECK_NUMBER (Vx_pointer_shape, 0); | |
754 cursor = XCreateFontCursor (x_current_display, XINT (Vx_pointer_shape)); | |
755 } | |
756 else | |
757 cursor = XCreateFontCursor (x_current_display, XC_xterm); | |
758 | |
759 if (!EQ (Qnil, Vx_nontext_pointer_shape)) | |
760 { | |
761 CHECK_NUMBER (Vx_nontext_pointer_shape, 0); | |
762 nontext_cursor = XCreateFontCursor (x_current_display, | |
763 XINT (Vx_nontext_pointer_shape)); | |
764 } | |
765 else | |
766 nontext_cursor = XCreateFontCursor (x_current_display, XC_left_ptr); | |
767 | |
768 if (!EQ (Qnil, Vx_mode_pointer_shape)) | |
769 { | |
770 CHECK_NUMBER (Vx_mode_pointer_shape, 0); | |
771 mode_cursor = XCreateFontCursor (x_current_display, | |
772 XINT (Vx_mode_pointer_shape)); | |
773 } | |
774 else | |
775 mode_cursor = XCreateFontCursor (x_current_display, XC_xterm); | |
776 | |
777 { | |
778 XColor fore_color, back_color; | |
779 | |
771 | 780 fore_color.pixel = f->display.x->mouse_pixel; |
389 | 781 back_color.pixel = mask_color; |
782 XQueryColor (x_current_display, | |
783 DefaultColormap (x_current_display, | |
784 DefaultScreen (x_current_display)), | |
785 &fore_color); | |
786 XQueryColor (x_current_display, | |
787 DefaultColormap (x_current_display, | |
788 DefaultScreen (x_current_display)), | |
789 &back_color); | |
790 XRecolorCursor (x_current_display, cursor, | |
791 &fore_color, &back_color); | |
792 XRecolorCursor (x_current_display, nontext_cursor, | |
793 &fore_color, &back_color); | |
794 XRecolorCursor (x_current_display, mode_cursor, | |
795 &fore_color, &back_color); | |
796 } | |
797 #else /* X10 */ | |
798 cursor = XCreateCursor (16, 16, MouseCursor, MouseMask, | |
799 0, 0, | |
771 | 800 f->display.x->mouse_pixel, |
801 f->display.x->background_pixel, | |
389 | 802 GXcopy); |
803 #endif /* X10 */ | |
804 | |
771 | 805 if (f->display.x->window_desc != 0) |
389 | 806 { |
771 | 807 XDefineCursor (XDISPLAY f->display.x->window_desc, cursor); |
389 | 808 } |
809 | |
771 | 810 if (cursor != f->display.x->text_cursor && f->display.x->text_cursor != 0) |
811 XFreeCursor (XDISPLAY f->display.x->text_cursor); | |
812 f->display.x->text_cursor = cursor; | |
389 | 813 #ifdef HAVE_X11 |
771 | 814 if (nontext_cursor != f->display.x->nontext_cursor |
815 && f->display.x->nontext_cursor != 0) | |
816 XFreeCursor (XDISPLAY f->display.x->nontext_cursor); | |
817 f->display.x->nontext_cursor = nontext_cursor; | |
818 | |
819 if (mode_cursor != f->display.x->modeline_cursor | |
820 && f->display.x->modeline_cursor != 0) | |
821 XFreeCursor (XDISPLAY f->display.x->modeline_cursor); | |
822 f->display.x->modeline_cursor = mode_cursor; | |
389 | 823 #endif /* HAVE_X11 */ |
824 | |
825 XFlushQueue (); | |
826 UNBLOCK_INPUT; | |
827 } | |
828 | |
829 void | |
771 | 830 x_set_cursor_color (f, arg, oldval) |
831 struct frame *f; | |
389 | 832 Lisp_Object arg, oldval; |
833 { | |
834 unsigned long fore_pixel; | |
835 | |
836 if (!EQ (Vx_cursor_fore_pixel, Qnil)) | |
837 fore_pixel = x_decode_color (Vx_cursor_fore_pixel, WHITE_PIX_DEFAULT); | |
838 else | |
771 | 839 fore_pixel = f->display.x->background_pixel; |
840 f->display.x->cursor_pixel = x_decode_color (arg, BLACK_PIX_DEFAULT); | |
389 | 841 /* No invisible cursors */ |
771 | 842 if (f->display.x->cursor_pixel == f->display.x->background_pixel) |
389 | 843 { |
771 | 844 f->display.x->cursor_pixel == f->display.x->mouse_pixel; |
845 if (f->display.x->cursor_pixel == fore_pixel) | |
846 fore_pixel = f->display.x->background_pixel; | |
389 | 847 } |
848 | |
771 | 849 if (f->display.x->window_desc != 0) |
389 | 850 { |
851 #ifdef HAVE_X11 | |
852 BLOCK_INPUT; | |
771 | 853 XSetBackground (x_current_display, f->display.x->cursor_gc, |
854 f->display.x->cursor_pixel); | |
855 XSetForeground (x_current_display, f->display.x->cursor_gc, | |
389 | 856 fore_pixel); |
857 UNBLOCK_INPUT; | |
858 #endif /* HAVE_X11 */ | |
859 | |
771 | 860 if (f->visible) |
389 | 861 { |
771 | 862 x_display_cursor (f, 0); |
863 x_display_cursor (f, 1); | |
389 | 864 } |
865 } | |
866 } | |
867 | |
771 | 868 /* Set the border-color of frame F to value described by ARG. |
389 | 869 ARG can be a string naming a color. |
870 The border-color is used for the border that is drawn by the X server. | |
871 Note that this does not fully take effect if done before | |
771 | 872 F has an x-window; it must be redone when the window is created. |
389 | 873 |
874 Note: this is done in two routines because of the way X10 works. | |
875 | |
876 Note: under X11, this is normally the province of the window manager, | |
877 and so emacs' border colors may be overridden. */ | |
878 | |
879 void | |
771 | 880 x_set_border_color (f, arg, oldval) |
881 struct frame *f; | |
389 | 882 Lisp_Object arg, oldval; |
883 { | |
884 unsigned char *str; | |
885 int pix; | |
886 | |
887 CHECK_STRING (arg, 0); | |
888 str = XSTRING (arg)->data; | |
889 | |
890 #ifndef HAVE_X11 | |
891 if (!strcmp (str, "grey") || !strcmp (str, "Grey") | |
892 || !strcmp (str, "gray") || !strcmp (str, "Gray")) | |
893 pix = -1; | |
894 else | |
895 #endif /* X10 */ | |
896 | |
897 pix = x_decode_color (arg, BLACK_PIX_DEFAULT); | |
898 | |
771 | 899 x_set_border_pixel (f, pix); |
389 | 900 } |
901 | |
771 | 902 /* Set the border-color of frame F to pixel value PIX. |
389 | 903 Note that this does not fully take effect if done before |
771 | 904 F has an x-window. */ |
905 | |
906 x_set_border_pixel (f, pix) | |
907 struct frame *f; | |
389 | 908 int pix; |
909 { | |
771 | 910 f->display.x->border_pixel = pix; |
911 | |
912 if (f->display.x->window_desc != 0 && f->display.x->border_width > 0) | |
389 | 913 { |
914 Pixmap temp; | |
915 int mask; | |
916 | |
917 BLOCK_INPUT; | |
918 #ifdef HAVE_X11 | |
771 | 919 XSetWindowBorder (x_current_display, f->display.x->window_desc, |
389 | 920 pix); |
771 | 921 if (f->display.x->h_scrollbar) |
922 XSetWindowBorder (x_current_display, f->display.x->h_slider, | |
389 | 923 pix); |
771 | 924 if (f->display.x->v_scrollbar) |
925 XSetWindowBorder (x_current_display, f->display.x->v_slider, | |
389 | 926 pix); |
927 #else | |
928 if (pix < 0) | |
929 temp = XMakePixmap ((Bitmap) XStoreBitmap (16, 16, gray_bits), | |
930 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT); | |
931 else | |
932 temp = XMakeTile (pix); | |
771 | 933 XChangeBorder (f->display.x->window_desc, temp); |
389 | 934 XFreePixmap (XDISPLAY temp); |
935 #endif /* not HAVE_X11 */ | |
936 UNBLOCK_INPUT; | |
937 | |
771 | 938 if (f->visible) |
939 redraw_frame (f); | |
389 | 940 } |
941 } | |
942 | |
943 void | |
771 | 944 x_set_icon_type (f, arg, oldval) |
945 struct frame *f; | |
389 | 946 Lisp_Object arg, oldval; |
947 { | |
948 Lisp_Object tem; | |
949 int result; | |
950 | |
951 if (EQ (oldval, Qnil) == EQ (arg, Qnil)) | |
952 return; | |
953 | |
954 BLOCK_INPUT; | |
485 | 955 if (NILP (arg)) |
771 | 956 result = x_text_icon (f, 0); |
389 | 957 else |
771 | 958 result = x_bitmap_icon (f, 0); |
389 | 959 |
960 if (result) | |
961 { | |
962 error ("No icon window available."); | |
963 UNBLOCK_INPUT; | |
964 } | |
965 | |
966 /* If the window was unmapped (and its icon was mapped), | |
967 the new icon is not mapped, so map the window in its stead. */ | |
771 | 968 if (f->visible) |
969 XMapWindow (XDISPLAY f->display.x->window_desc); | |
389 | 970 |
971 XFlushQueue (); | |
972 UNBLOCK_INPUT; | |
973 } | |
974 | |
975 void | |
771 | 976 x_set_font (f, arg, oldval) |
977 struct frame *f; | |
389 | 978 Lisp_Object arg, oldval; |
979 { | |
980 unsigned char *name; | |
981 int result; | |
982 | |
983 CHECK_STRING (arg, 1); | |
984 name = XSTRING (arg)->data; | |
985 | |
986 BLOCK_INPUT; | |
771 | 987 result = x_new_font (f, name); |
389 | 988 UNBLOCK_INPUT; |
989 | |
990 if (result) | |
991 error ("Font \"%s\" is not defined", name); | |
992 } | |
993 | |
994 void | |
771 | 995 x_set_border_width (f, arg, oldval) |
996 struct frame *f; | |
389 | 997 Lisp_Object arg, oldval; |
998 { | |
999 CHECK_NUMBER (arg, 0); | |
1000 | |
771 | 1001 if (XINT (arg) == f->display.x->border_width) |
389 | 1002 return; |
1003 | |
771 | 1004 if (f->display.x->window_desc != 0) |
389 | 1005 error ("Cannot change the border width of a window"); |
1006 | |
771 | 1007 f->display.x->border_width = XINT (arg); |
389 | 1008 } |
1009 | |
1010 void | |
771 | 1011 x_set_internal_border_width (f, arg, oldval) |
1012 struct frame *f; | |
389 | 1013 Lisp_Object arg, oldval; |
1014 { | |
1015 int mask; | |
771 | 1016 int old = f->display.x->internal_border_width; |
389 | 1017 |
1018 CHECK_NUMBER (arg, 0); | |
771 | 1019 f->display.x->internal_border_width = XINT (arg); |
1020 if (f->display.x->internal_border_width < 0) | |
1021 f->display.x->internal_border_width = 0; | |
1022 | |
1023 if (f->display.x->internal_border_width == old) | |
389 | 1024 return; |
1025 | |
771 | 1026 if (f->display.x->window_desc != 0) |
389 | 1027 { |
1028 BLOCK_INPUT; | |
771 | 1029 x_set_window_size (f, f->width, f->height); |
389 | 1030 #if 0 |
771 | 1031 x_set_resize_hint (f); |
389 | 1032 #endif |
1033 XFlushQueue (); | |
1034 UNBLOCK_INPUT; | |
771 | 1035 SET_FRAME_GARBAGED (f); |
389 | 1036 } |
1037 } | |
1038 | |
1039 void | |
771 | 1040 x_set_name (f, arg, oldval) |
1041 struct frame *f; | |
389 | 1042 Lisp_Object arg, oldval; |
1043 { | |
1044 CHECK_STRING (arg, 0); | |
1045 | |
727 | 1046 /* Don't change the name if it's already ARG. */ |
771 | 1047 if (! NILP (Fstring_equal (arg, f->name))) |
727 | 1048 return; |
1049 | |
771 | 1050 if (f->display.x->window_desc) |
389 | 1051 { |
708 | 1052 #ifdef HAVE_X11 |
1053 XTextProperty prop; | |
1054 prop.value = XSTRING (arg)->data; | |
1055 prop.encoding = XA_STRING; | |
1056 prop.format = 8; | |
1057 prop.nitems = XSTRING (arg)->size; | |
1058 BLOCK_INPUT; | |
771 | 1059 XSetWMName (XDISPLAY f->display.x->window_desc, &prop); |
1060 XSetWMIconName (XDISPLAY f->display.x->window_desc, &prop); | |
708 | 1061 UNBLOCK_INPUT; |
1062 #else | |
389 | 1063 BLOCK_INPUT; |
771 | 1064 XStoreName (XDISPLAY f->display.x->window_desc, |
389 | 1065 (char *) XSTRING (arg)->data); |
771 | 1066 XSetIconName (XDISPLAY f->display.x->window_desc, |
389 | 1067 (char *) XSTRING (arg)->data); |
1068 UNBLOCK_INPUT; | |
708 | 1069 #endif |
389 | 1070 } |
727 | 1071 |
771 | 1072 f->name = arg; |
389 | 1073 } |
1074 | |
1075 void | |
771 | 1076 x_set_autoraise (f, arg, oldval) |
1077 struct frame *f; | |
389 | 1078 Lisp_Object arg, oldval; |
1079 { | |
771 | 1080 f->auto_raise = !EQ (Qnil, arg); |
389 | 1081 } |
1082 | |
1083 void | |
771 | 1084 x_set_autolower (f, arg, oldval) |
1085 struct frame *f; | |
389 | 1086 Lisp_Object arg, oldval; |
1087 { | |
771 | 1088 f->auto_lower = !EQ (Qnil, arg); |
389 | 1089 } |
1090 | |
1091 #ifdef HAVE_X11 | |
1092 int n_faces; | |
1093 | |
1094 x_set_face (scr, font, background, foreground, stipple) | |
771 | 1095 struct frame *scr; |
389 | 1096 XFontStruct *font; |
1097 unsigned long background, foreground; | |
1098 Pixmap stipple; | |
1099 { | |
1100 XGCValues gc_values; | |
1101 GC temp_gc; | |
1102 unsigned long gc_mask; | |
1103 struct face *new_face; | |
1104 unsigned int width = 16; | |
1105 unsigned int height = 16; | |
1106 | |
1107 if (n_faces == MAX_FACES_AND_GLYPHS) | |
1108 return 1; | |
1109 | |
1110 /* Create the Graphics Context. */ | |
1111 gc_values.font = font->fid; | |
1112 gc_values.foreground = foreground; | |
1113 gc_values.background = background; | |
1114 gc_values.line_width = 0; | |
1115 gc_mask = GCLineWidth | GCFont | GCForeground | GCBackground; | |
1116 if (stipple) | |
1117 { | |
1118 gc_values.stipple | |
1119 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW, | |
1120 (char *) stipple, width, height); | |
1121 gc_mask |= GCStipple; | |
1122 } | |
1123 | |
1124 temp_gc = XCreateGC (x_current_display, scr->display.x->window_desc, | |
1125 gc_mask, &gc_values); | |
1126 if (!temp_gc) | |
1127 return 1; | |
1128 new_face = (struct face *) xmalloc (sizeof (struct face)); | |
1129 if (!new_face) | |
1130 { | |
1131 XFreeGC (x_current_display, temp_gc); | |
1132 return 1; | |
1133 } | |
1134 | |
1135 new_face->font = font; | |
1136 new_face->foreground = foreground; | |
1137 new_face->background = background; | |
1138 new_face->face_gc = temp_gc; | |
1139 if (stipple) | |
1140 new_face->stipple = gc_values.stipple; | |
1141 | |
1142 x_face_table[++n_faces] = new_face; | |
1143 return 1; | |
1144 } | |
1145 | |
1146 x_set_glyph (scr, glyph) | |
1147 { | |
1148 } | |
1149 | |
1150 #if 0 | |
1151 DEFUN ("x-set-face-font", Fx_set_face_font, Sx_set_face_font, 4, 2, 0, | |
1152 "Specify face table entry FACE-CODE to be the font named by FONT,\n\ | |
1153 in colors FOREGROUND and BACKGROUND.") | |
1154 (face_code, font_name, foreground, background) | |
1155 Lisp_Object face_code; | |
1156 Lisp_Object font_name; | |
1157 Lisp_Object foreground; | |
1158 Lisp_Object background; | |
1159 { | |
1160 register struct face *fp; /* Current face info. */ | |
1161 register int fn; /* Face number. */ | |
1162 register FONT_TYPE *f; /* Font data structure. */ | |
1163 unsigned char *newname; | |
1164 int fg, bg; | |
1165 GC temp_gc; | |
1166 XGCValues gc_values; | |
1167 | |
1168 /* Need to do something about this. */ | |
771 | 1169 Drawable drawable = selected_frame->display.x->window_desc; |
389 | 1170 |
1171 CHECK_NUMBER (face_code, 1); | |
1172 CHECK_STRING (font_name, 2); | |
1173 | |
1174 if (EQ (foreground, Qnil) || EQ (background, Qnil)) | |
1175 { | |
771 | 1176 fg = selected_frame->display.x->foreground_pixel; |
1177 bg = selected_frame->display.x->background_pixel; | |
389 | 1178 } |
1179 else | |
1180 { | |
1181 CHECK_NUMBER (foreground, 0); | |
1182 CHECK_NUMBER (background, 1); | |
1183 | |
1184 fg = x_decode_color (XINT (foreground), BLACK_PIX_DEFAULT); | |
1185 bg = x_decode_color (XINT (background), WHITE_PIX_DEFAULT); | |
1186 } | |
1187 | |
1188 fn = XINT (face_code); | |
1189 if ((fn < 1) || (fn > 255)) | |
1190 error ("Invalid face code, %d", fn); | |
1191 | |
1192 newname = XSTRING (font_name)->data; | |
1193 BLOCK_INPUT; | |
1194 f = (*newname == 0 ? 0 : XGetFont (newname)); | |
1195 UNBLOCK_INPUT; | |
1196 if (f == 0) | |
1197 error ("Font \"%s\" is not defined", newname); | |
1198 | |
1199 fp = x_face_table[fn]; | |
1200 if (fp == 0) | |
1201 { | |
1202 x_face_table[fn] = fp = (struct face *) xmalloc (sizeof (struct face)); | |
1203 bzero (fp, sizeof (struct face)); | |
1204 fp->face_type = x_pixmap; | |
1205 } | |
1206 else if (FACE_IS_FONT (fn)) | |
1207 { | |
1208 BLOCK_INPUT; | |
1209 XFreeGC (FACE_FONT (fn)); | |
1210 UNBLOCK_INPUT; | |
1211 } | |
1212 else if (FACE_IS_IMAGE (fn)) /* This should not happen... */ | |
1213 { | |
1214 BLOCK_INPUT; | |
1215 XFreePixmap (x_current_display, FACE_IMAGE (fn)); | |
1216 fp->face_type = x_font; | |
1217 UNBLOCK_INPUT; | |
1218 } | |
1219 else | |
1220 abort (); | |
1221 | |
1222 fp->face_GLYPH.font_desc.font = f; | |
1223 gc_values.font = f->fid; | |
1224 gc_values.foreground = fg; | |
1225 gc_values.background = bg; | |
1226 fp->face_GLYPH.font_desc.face_gc = XCreateGC (x_current_display, | |
1227 drawable, GCFont | GCForeground | |
1228 | GCBackground, &gc_values); | |
1229 fp->face_GLYPH.font_desc.font_width = FONT_WIDTH (f); | |
1230 fp->face_GLYPH.font_desc.font_height = FONT_HEIGHT (f); | |
1231 | |
1232 return face_code; | |
1233 } | |
1234 #endif | |
1235 #else /* X10 */ | |
1236 DEFUN ("x-set-face", Fx_set_face, Sx_set_face, 4, 4, 0, | |
1237 "Specify face table entry FACE-CODE to be the font named by FONT,\n\ | |
1238 in colors FOREGROUND and BACKGROUND.") | |
1239 (face_code, font_name, foreground, background) | |
1240 Lisp_Object face_code; | |
1241 Lisp_Object font_name; | |
1242 Lisp_Object foreground; | |
1243 Lisp_Object background; | |
1244 { | |
1245 register struct face *fp; /* Current face info. */ | |
1246 register int fn; /* Face number. */ | |
1247 register FONT_TYPE *f; /* Font data structure. */ | |
1248 unsigned char *newname; | |
1249 | |
1250 CHECK_NUMBER (face_code, 1); | |
1251 CHECK_STRING (font_name, 2); | |
1252 | |
1253 fn = XINT (face_code); | |
1254 if ((fn < 1) || (fn > 255)) | |
1255 error ("Invalid face code, %d", fn); | |
1256 | |
1257 /* Ask the server to find the specified font. */ | |
1258 newname = XSTRING (font_name)->data; | |
1259 BLOCK_INPUT; | |
1260 f = (*newname == 0 ? 0 : XGetFont (newname)); | |
1261 UNBLOCK_INPUT; | |
1262 if (f == 0) | |
1263 error ("Font \"%s\" is not defined", newname); | |
1264 | |
1265 /* Get the face structure for face_code in the face table. | |
1266 Make sure it exists. */ | |
1267 fp = x_face_table[fn]; | |
1268 if (fp == 0) | |
1269 { | |
1270 x_face_table[fn] = fp = (struct face *) xmalloc (sizeof (struct face)); | |
1271 bzero (fp, sizeof (struct face)); | |
1272 } | |
1273 | |
1274 /* If this face code already exists, get rid of the old font. */ | |
1275 if (fp->font != 0 && fp->font != f) | |
1276 { | |
1277 BLOCK_INPUT; | |
1278 XLoseFont (fp->font); | |
1279 UNBLOCK_INPUT; | |
1280 } | |
1281 | |
1282 /* Store the specified information in FP. */ | |
1283 fp->fg = x_decode_color (foreground, BLACK_PIX_DEFAULT); | |
1284 fp->bg = x_decode_color (background, WHITE_PIX_DEFAULT); | |
1285 fp->font = f; | |
1286 | |
1287 return face_code; | |
1288 } | |
1289 #endif /* X10 */ | |
1290 | |
1291 #if 0 | |
1292 /* This is excluded because there is no painless way | |
1293 to get or to remember the name of the font. */ | |
1294 | |
1295 DEFUN ("x-get-face", Fx_get_face, Sx_get_face, 1, 1, 0, | |
1296 "Get data defining face code FACE. FACE is an integer.\n\ | |
1297 The value is a list (FONT FG-COLOR BG-COLOR).") | |
1298 (face) | |
1299 Lisp_Object face; | |
1300 { | |
1301 register struct face *fp; /* Current face info. */ | |
1302 register int fn; /* Face number. */ | |
1303 | |
1304 CHECK_NUMBER (face, 1); | |
1305 fn = XINT (face); | |
1306 if ((fn < 1) || (fn > 255)) | |
1307 error ("Invalid face code, %d", fn); | |
1308 | |
1309 /* Make sure the face table exists and this face code is defined. */ | |
1310 if (x_face_table == 0 || x_face_table[fn] == 0) | |
1311 return Qnil; | |
1312 | |
1313 fp = x_face_table[fn]; | |
1314 | |
1315 return Fcons (build_string (fp->name), | |
1316 Fcons (make_number (fp->fg), | |
1317 Fcons (make_number (fp->bg), Qnil))); | |
1318 } | |
1319 #endif /* 0 */ | |
1320 | |
771 | 1321 /* Subroutines of creating an X frame. */ |
389 | 1322 |
1323 #ifdef HAVE_X11 | |
1324 extern char *x_get_string_resource (); | |
1325 extern XrmDatabase x_load_resources (); | |
1326 | |
1327 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 1, 3, 0, | |
1328 "Retrieve the value of ATTRIBUTE from the X defaults database. This\n\ | |
1329 searches using a key of the form \"INSTANCE.ATTRIBUTE\", with class\n\ | |
1330 \"Emacs\", where INSTANCE is the name under which Emacs was invoked.\n\ | |
1331 \n\ | |
1332 Optional arguments COMPONENT and CLASS specify the component for which\n\ | |
1333 we should look up ATTRIBUTE. When specified, Emacs searches using a\n\ | |
1334 key of the form INSTANCE.COMPONENT.ATTRIBUTE, with class \"Emacs.CLASS\".") | |
1335 (attribute, name, class) | |
1336 Lisp_Object attribute, name, class; | |
1337 { | |
1338 register char *value; | |
1339 char *name_key; | |
1340 char *class_key; | |
1341 | |
1342 CHECK_STRING (attribute, 0); | |
485 | 1343 if (!NILP (name)) |
389 | 1344 CHECK_STRING (name, 1); |
485 | 1345 if (!NILP (class)) |
389 | 1346 CHECK_STRING (class, 2); |
485 | 1347 if (NILP (name) != NILP (class)) |
389 | 1348 error ("x-get-resource: must specify both NAME and CLASS or neither"); |
1349 | |
485 | 1350 if (NILP (name)) |
389 | 1351 { |
398 | 1352 name_key = (char *) alloca (XSTRING (invocation_name)->size + 1 |
1353 + XSTRING (attribute)->size + 1); | |
1354 | |
389 | 1355 sprintf (name_key, "%s.%s", |
1356 XSTRING (invocation_name)->data, | |
1357 XSTRING (attribute)->data); | |
1358 class_key = EMACS_CLASS; | |
1359 } | |
1360 else | |
1361 { | |
398 | 1362 name_key = (char *) alloca (XSTRING (invocation_name)->size + 1 |
1363 + XSTRING (name)->size + 1 | |
1364 + XSTRING (attribute)->size + 1); | |
1365 | |
389 | 1366 class_key = (char *) alloca (sizeof (EMACS_CLASS) |
1367 + XSTRING (class)->size + 1); | |
1368 | |
1369 sprintf (name_key, "%s.%s.%s", | |
1370 XSTRING (invocation_name)->data, | |
1371 XSTRING (name)->data, | |
1372 XSTRING (attribute)->data); | |
1373 sprintf (class_key, "%s.%s", | |
1374 XSTRING (invocation_name)->data, | |
1375 XSTRING (class)->data); | |
1376 } | |
1377 | |
1378 value = x_get_string_resource (xrdb, name_key, class_key); | |
1379 | |
1380 if (value != (char *) 0) | |
1381 return build_string (value); | |
1382 else | |
1383 return Qnil; | |
1384 } | |
1385 | |
1386 #else /* X10 */ | |
1387 | |
398 | 1388 DEFUN ("x-get-default", Fx_get_default, Sx_get_default, 1, 1, 0, |
389 | 1389 "Get X default ATTRIBUTE from the system, or nil if no default.\n\ |
1390 Value is a string (when not nil) and ATTRIBUTE is also a string.\n\ | |
1391 The defaults are specified in the file `~/.Xdefaults'.") | |
398 | 1392 (arg) |
1393 Lisp_Object arg; | |
389 | 1394 { |
1395 register unsigned char *value; | |
1396 | |
1397 CHECK_STRING (arg, 1); | |
1398 | |
1399 value = (unsigned char *) XGetDefault (XDISPLAY | |
1400 XSTRING (invocation_name)->data, | |
1401 XSTRING (arg)->data); | |
1402 if (value == 0) | |
1403 /* Try reversing last two args, in case this is the buggy version of X. */ | |
1404 value = (unsigned char *) XGetDefault (XDISPLAY | |
1405 XSTRING (arg)->data, | |
1406 XSTRING (invocation_name)->data); | |
1407 if (value != 0) | |
1408 return build_string (value); | |
1409 else | |
1410 return (Qnil); | |
1411 } | |
1412 | |
398 | 1413 #define Fx_get_resource(attribute, name, class) Fx_get_default(attribute) |
389 | 1414 |
1415 #endif /* X10 */ | |
1416 | |
398 | 1417 /* Types we might convert a resource string into. */ |
1418 enum resource_types | |
1419 { | |
1420 number, boolean, string, | |
1421 }; | |
1422 | |
389 | 1423 /* Return the value of parameter PARAM. |
398 | 1424 |
771 | 1425 First search ALIST, then Vdefault_frame_alist, then the X defaults |
641 | 1426 database, using ATTRIBUTE as the attribute name. |
398 | 1427 |
1428 Convert the resource to the type specified by desired_type. | |
1429 | |
1430 If no default is specified, return nil. */ | |
389 | 1431 |
1432 static Lisp_Object | |
641 | 1433 x_get_arg (alist, param, attribute, type) |
1434 Lisp_Object alist, param; | |
398 | 1435 char *attribute; |
1436 enum resource_types type; | |
389 | 1437 { |
1438 register Lisp_Object tem; | |
1439 | |
1440 tem = Fassq (param, alist); | |
1441 if (EQ (tem, Qnil)) | |
771 | 1442 tem = Fassq (param, Vdefault_frame_alist); |
398 | 1443 if (EQ (tem, Qnil) && attribute) |
389 | 1444 { |
641 | 1445 tem = Fx_get_resource (build_string (attribute), Qnil, Qnil); |
485 | 1446 |
1447 if (NILP (tem)) | |
398 | 1448 return Qnil; |
1449 | |
1450 switch (type) | |
1451 { | |
1452 case number: | |
1453 return make_number (atoi (XSTRING (tem)->data)); | |
1454 | |
1455 case boolean: | |
1456 tem = Fdowncase (tem); | |
1457 if (!strcmp (XSTRING (tem)->data, "on") | |
1458 || !strcmp (XSTRING (tem)->data, "true")) | |
1459 return Qt; | |
1460 else | |
1461 return Qnil; | |
1462 | |
1463 case string: | |
1464 return tem; | |
1465 | |
1466 default: | |
1467 abort (); | |
1468 } | |
389 | 1469 } |
1470 return Fcdr (tem); | |
1471 } | |
1472 | |
771 | 1473 /* Record in frame F the specified or default value according to ALIST |
389 | 1474 of the parameter named PARAM (a Lisp symbol). |
1475 If no value is specified for PARAM, look for an X default for XPROP | |
771 | 1476 on the frame named NAME. |
389 | 1477 If that is not found either, use the value DEFLT. */ |
1478 | |
1479 static Lisp_Object | |
771 | 1480 x_default_parameter (f, alist, propname, deflt, xprop, type) |
1481 struct frame *f; | |
389 | 1482 Lisp_Object alist; |
1483 char *propname; | |
1484 Lisp_Object deflt; | |
1485 char *xprop; | |
398 | 1486 enum resource_types type; |
389 | 1487 { |
1488 Lisp_Object propsym = intern (propname); | |
1489 Lisp_Object tem; | |
1490 | |
641 | 1491 tem = x_get_arg (alist, propsym, xprop, type); |
389 | 1492 if (EQ (tem, Qnil)) |
1493 tem = deflt; | |
771 | 1494 store_frame_param (f, propsym, tem); |
1495 x_set_frame_param (f, propsym, tem, Qnil); | |
389 | 1496 return tem; |
1497 } | |
1498 | |
1499 DEFUN ("x-geometry", Fx_geometry, Sx_geometry, 1, 1, 0, | |
1500 "Parse an X-style geometry string STRING.\n\ | |
1501 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).") | |
1502 (string) | |
1503 { | |
1504 int geometry, x, y; | |
1505 unsigned int width, height; | |
1506 Lisp_Object values[4]; | |
1507 | |
1508 CHECK_STRING (string, 0); | |
1509 | |
1510 geometry = XParseGeometry ((char *) XSTRING (string)->data, | |
1511 &x, &y, &width, &height); | |
1512 | |
1513 switch (geometry & 0xf) /* Mask out {X,Y}Negative */ | |
1514 { | |
1515 case (XValue | YValue): | |
1516 /* What's one pixel among friends? | |
1517 Perhaps fix this some day by returning symbol `extreme-top'... */ | |
1518 if (x == 0 && (geometry & XNegative)) | |
1519 x = -1; | |
1520 if (y == 0 && (geometry & YNegative)) | |
1521 y = -1; | |
1522 values[0] = Fcons (intern ("left"), make_number (x)); | |
1523 values[1] = Fcons (intern ("top"), make_number (y)); | |
1524 return Flist (2, values); | |
1525 break; | |
1526 | |
1527 case (WidthValue | HeightValue): | |
1528 values[0] = Fcons (intern ("width"), make_number (width)); | |
1529 values[1] = Fcons (intern ("height"), make_number (height)); | |
1530 return Flist (2, values); | |
1531 break; | |
1532 | |
1533 case (XValue | YValue | WidthValue | HeightValue): | |
1534 if (x == 0 && (geometry & XNegative)) | |
1535 x = -1; | |
1536 if (y == 0 && (geometry & YNegative)) | |
1537 y = -1; | |
1538 values[0] = Fcons (intern ("width"), make_number (width)); | |
1539 values[1] = Fcons (intern ("height"), make_number (height)); | |
1540 values[2] = Fcons (intern ("left"), make_number (x)); | |
1541 values[3] = Fcons (intern ("top"), make_number (y)); | |
1542 return Flist (4, values); | |
1543 break; | |
1544 | |
1545 case 0: | |
1546 return Qnil; | |
1547 | |
1548 default: | |
1549 error ("Must specify x and y value, and/or width and height"); | |
1550 } | |
1551 } | |
1552 | |
1553 #ifdef HAVE_X11 | |
1554 /* Calculate the desired size and position of this window, | |
1555 or set rubber-band prompting if none. */ | |
1556 | |
1557 #define DEFAULT_ROWS 40 | |
1558 #define DEFAULT_COLS 80 | |
1559 | |
1560 static | |
771 | 1561 x_figure_window_size (f, parms) |
1562 struct frame *f; | |
389 | 1563 Lisp_Object parms; |
1564 { | |
1565 register Lisp_Object tem0, tem1; | |
1566 int height, width, left, top; | |
1567 register int geometry; | |
1568 long window_prompting = 0; | |
1569 | |
1570 /* Default values if we fall through. | |
1571 Actually, if that happens we should get | |
1572 window manager prompting. */ | |
771 | 1573 f->width = DEFAULT_COLS; |
1574 f->height = DEFAULT_ROWS; | |
1575 f->display.x->top_pos = 1; | |
1576 f->display.x->left_pos = 1; | |
389 | 1577 |
641 | 1578 tem0 = x_get_arg (parms, intern ("height"), 0, 0); |
1579 tem1 = x_get_arg (parms, intern ("width"), 0, 0); | |
389 | 1580 if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil)) |
1581 { | |
1582 CHECK_NUMBER (tem0, 0); | |
1583 CHECK_NUMBER (tem1, 0); | |
771 | 1584 f->height = XINT (tem0); |
1585 f->width = XINT (tem1); | |
389 | 1586 window_prompting |= USSize; |
1587 } | |
1588 else if (! EQ (tem0, Qnil) || ! EQ (tem1, Qnil)) | |
1589 error ("Must specify *both* height and width"); | |
1590 | |
771 | 1591 f->display.x->pixel_width = (FONT_WIDTH (f->display.x->font) * f->width |
1592 + 2 * f->display.x->internal_border_width); | |
1593 f->display.x->pixel_height = (FONT_HEIGHT (f->display.x->font) * f->height | |
1594 + 2 * f->display.x->internal_border_width); | |
389 | 1595 |
641 | 1596 tem0 = x_get_arg (parms, intern ("top"), 0, 0); |
1597 tem1 = x_get_arg (parms, intern ("left"), 0, 0); | |
389 | 1598 if (! EQ (tem0, Qnil) && ! EQ (tem1, Qnil)) |
1599 { | |
1600 CHECK_NUMBER (tem0, 0); | |
1601 CHECK_NUMBER (tem1, 0); | |
771 | 1602 f->display.x->top_pos = XINT (tem0); |
1603 f->display.x->left_pos = XINT (tem1); | |
1604 x_calc_absolute_position (f); | |
389 | 1605 window_prompting |= USPosition; |
1606 } | |
1607 else if (! EQ (tem0, Qnil) || ! EQ (tem1, Qnil)) | |
1608 error ("Must specify *both* top and left corners"); | |
1609 | |
1610 switch (window_prompting) | |
1611 { | |
1612 case USSize | USPosition: | |
1613 return window_prompting; | |
1614 break; | |
1615 | |
1616 case USSize: /* Got the size, need the position. */ | |
1617 window_prompting |= PPosition; | |
1618 return window_prompting; | |
1619 break; | |
1620 | |
1621 case USPosition: /* Got the position, need the size. */ | |
1622 window_prompting |= PSize; | |
1623 return window_prompting; | |
1624 break; | |
1625 | |
1626 case 0: /* Got nothing, take both from geometry. */ | |
1627 window_prompting |= PPosition | PSize; | |
1628 return window_prompting; | |
1629 break; | |
1630 | |
1631 default: | |
1632 /* Somehow a bit got set in window_prompting that we didn't | |
1633 put there. */ | |
1634 abort (); | |
1635 } | |
1636 } | |
1637 | |
1638 static void | |
771 | 1639 x_window (f) |
1640 struct frame *f; | |
389 | 1641 { |
1642 XSetWindowAttributes attributes; | |
1643 unsigned long attribute_mask; | |
1644 XClassHint class_hints; | |
1645 | |
771 | 1646 attributes.background_pixel = f->display.x->background_pixel; |
1647 attributes.border_pixel = f->display.x->border_pixel; | |
389 | 1648 attributes.bit_gravity = StaticGravity; |
1649 attributes.backing_store = NotUseful; | |
1650 attributes.save_under = True; | |
1651 attributes.event_mask = STANDARD_EVENT_SET; | |
1652 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity | |
1653 #if 0 | |
1654 | CWBackingStore | CWSaveUnder | |
1655 #endif | |
1656 | CWEventMask); | |
1657 | |
1658 BLOCK_INPUT; | |
771 | 1659 f->display.x->window_desc |
389 | 1660 = XCreateWindow (x_current_display, ROOT_WINDOW, |
771 | 1661 f->display.x->left_pos, |
1662 f->display.x->top_pos, | |
1663 PIXEL_WIDTH (f), PIXEL_HEIGHT (f), | |
1664 f->display.x->border_width, | |
389 | 1665 CopyFromParent, /* depth */ |
1666 InputOutput, /* class */ | |
1667 screen_visual, /* set in Fx_open_connection */ | |
1668 attribute_mask, &attributes); | |
1669 | |
771 | 1670 class_hints.res_name = (char *) XSTRING (f->name)->data; |
389 | 1671 class_hints.res_class = EMACS_CLASS; |
771 | 1672 XSetClassHint (x_current_display, f->display.x->window_desc, &class_hints); |
1673 | |
1674 XDefineCursor (XDISPLAY f->display.x->window_desc, | |
1675 f->display.x->text_cursor); | |
389 | 1676 UNBLOCK_INPUT; |
1677 | |
771 | 1678 if (f->display.x->window_desc == 0) |
389 | 1679 error ("Unable to create window."); |
1680 } | |
1681 | |
1682 /* Handle the icon stuff for this window. Perhaps later we might | |
1683 want an x_set_icon_position which can be called interactively as | |
1684 well. */ | |
1685 | |
1686 static void | |
771 | 1687 x_icon (f, parms) |
1688 struct frame *f; | |
389 | 1689 Lisp_Object parms; |
1690 { | |
1691 register Lisp_Object tem0,tem1; | |
1692 XWMHints hints; | |
1693 | |
1694 /* Set the position of the icon. Note that twm groups all | |
1695 icons in an icon window. */ | |
641 | 1696 tem0 = x_get_arg (parms, intern ("icon-left"), 0, 0); |
1697 tem1 = x_get_arg (parms, intern ("icon-top"), 0, 0); | |
389 | 1698 if (!EQ (tem0, Qnil) && !EQ (tem1, Qnil)) |
1699 { | |
1700 CHECK_NUMBER (tem0, 0); | |
1701 CHECK_NUMBER (tem1, 0); | |
1702 hints.icon_x = XINT (tem0); | |
1703 hints.icon_x = XINT (tem0); | |
1704 } | |
1705 else if (!EQ (tem0, Qnil) || !EQ (tem1, Qnil)) | |
1706 error ("Both left and top icon corners of icon must be specified"); | |
1707 else | |
1708 { | |
771 | 1709 hints.icon_x = f->display.x->left_pos; |
1710 hints.icon_y = f->display.x->top_pos; | |
389 | 1711 } |
1712 | |
1713 /* Start up iconic or window? */ | |
641 | 1714 tem0 = x_get_arg (parms, intern ("iconic-startup"), 0, 0); |
389 | 1715 if (!EQ (tem0, Qnil)) |
1716 hints.initial_state = IconicState; | |
1717 else | |
1718 hints.initial_state = NormalState; /* the default, actually. */ | |
1719 hints.input = False; | |
1720 | |
1721 BLOCK_INPUT; | |
1722 hints.flags = StateHint | IconPositionHint | InputHint; | |
771 | 1723 XSetWMHints (x_current_display, f->display.x->window_desc, &hints); |
389 | 1724 UNBLOCK_INPUT; |
1725 } | |
1726 | |
1727 /* Make the GC's needed for this window, setting the | |
1728 background, border and mouse colors; also create the | |
1729 mouse cursor and the gray border tile. */ | |
1730 | |
1731 static void | |
771 | 1732 x_make_gc (f) |
1733 struct frame *f; | |
389 | 1734 { |
1735 XGCValues gc_values; | |
1736 GC temp_gc; | |
1737 XImage tileimage; | |
1738 static char cursor_bits[] = | |
1739 { | |
1740 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
1741 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
1742 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
1743 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
1744 }; | |
1745 | |
771 | 1746 /* Create the GC's of this frame. |
389 | 1747 Note that many default values are used. */ |
1748 | |
1749 /* Normal video */ | |
771 | 1750 gc_values.font = f->display.x->font->fid; |
1751 gc_values.foreground = f->display.x->foreground_pixel; | |
1752 gc_values.background = f->display.x->background_pixel; | |
389 | 1753 gc_values.line_width = 0; /* Means 1 using fast algorithm. */ |
771 | 1754 f->display.x->normal_gc = XCreateGC (x_current_display, |
1755 f->display.x->window_desc, | |
389 | 1756 GCLineWidth | GCFont |
1757 | GCForeground | GCBackground, | |
1758 &gc_values); | |
1759 | |
1760 /* Reverse video style. */ | |
771 | 1761 gc_values.foreground = f->display.x->background_pixel; |
1762 gc_values.background = f->display.x->foreground_pixel; | |
1763 f->display.x->reverse_gc = XCreateGC (x_current_display, | |
1764 f->display.x->window_desc, | |
389 | 1765 GCFont | GCForeground | GCBackground |
1766 | GCLineWidth, | |
1767 &gc_values); | |
1768 | |
1769 /* Cursor has cursor-color background, background-color foreground. */ | |
771 | 1770 gc_values.foreground = f->display.x->background_pixel; |
1771 gc_values.background = f->display.x->cursor_pixel; | |
389 | 1772 gc_values.fill_style = FillOpaqueStippled; |
1773 gc_values.stipple | |
1774 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW, | |
1775 cursor_bits, 16, 16); | |
771 | 1776 f->display.x->cursor_gc |
1777 = XCreateGC (x_current_display, f->display.x->window_desc, | |
389 | 1778 (GCFont | GCForeground | GCBackground |
1779 | GCFillStyle | GCStipple | GCLineWidth), | |
1780 &gc_values); | |
1781 | |
1782 /* Create the gray border tile used when the pointer is not in | |
771 | 1783 the frame. Since this depends on the frame's pixel values, |
1784 this must be done on a per-frame basis. */ | |
1785 f->display.x->border_tile = | |
389 | 1786 XCreatePixmap (x_current_display, ROOT_WINDOW, 16, 16, |
1787 DefaultDepth (x_current_display, | |
1788 XDefaultScreen (x_current_display))); | |
771 | 1789 gc_values.foreground = f->display.x->foreground_pixel; |
1790 gc_values.background = f->display.x->background_pixel; | |
389 | 1791 temp_gc = XCreateGC (x_current_display, |
771 | 1792 (Drawable) f->display.x->border_tile, |
389 | 1793 GCForeground | GCBackground, &gc_values); |
1794 | |
1795 /* These are things that should be determined by the server, in | |
1796 Fx_open_connection */ | |
1797 tileimage.height = 16; | |
1798 tileimage.width = 16; | |
1799 tileimage.xoffset = 0; | |
1800 tileimage.format = XYBitmap; | |
1801 tileimage.data = gray_bits; | |
1802 tileimage.byte_order = LSBFirst; | |
1803 tileimage.bitmap_unit = 8; | |
1804 tileimage.bitmap_bit_order = LSBFirst; | |
1805 tileimage.bitmap_pad = 8; | |
1806 tileimage.bytes_per_line = (16 + 7) >> 3; | |
1807 tileimage.depth = 1; | |
771 | 1808 XPutImage (x_current_display, f->display.x->border_tile, temp_gc, |
389 | 1809 &tileimage, 0, 0, 0, 0, 16, 16); |
1810 XFreeGC (x_current_display, temp_gc); | |
1811 } | |
1812 #endif /* HAVE_X11 */ | |
1813 | |
771 | 1814 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, |
389 | 1815 1, 1, 0, |
771 | 1816 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\ |
1817 Return an Emacs frame object representing the X window.\n\ | |
1818 ALIST is an alist of frame parameters.\n\ | |
1819 If the parameters specify that the frame should not have a minibuffer,\n\ | |
697
6dd85fc4fb2c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
689
diff
changeset
|
1820 and do not specify a specific minibuffer window to use,\n\ |
771 | 1821 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\ |
1822 be shared by the new frame.") | |
389 | 1823 (parms) |
1824 Lisp_Object parms; | |
1825 { | |
1826 #ifdef HAVE_X11 | |
771 | 1827 struct frame *f; |
1828 Lisp_Object frame, tem; | |
389 | 1829 Lisp_Object name; |
1830 int minibuffer_only = 0; | |
1831 long window_prompting = 0; | |
1832 int width, height; | |
1833 | |
1834 if (x_current_display == 0) | |
1835 error ("X windows are not in use or not initialized"); | |
1836 | |
641 | 1837 name = x_get_arg (parms, intern ("name"), "Title", string); |
485 | 1838 if (NILP (name)) |
398 | 1839 name = build_string (x_id_name); |
1840 if (XTYPE (name) != Lisp_String) | |
771 | 1841 error ("x-create-frame: name parameter must be a string"); |
398 | 1842 |
641 | 1843 tem = x_get_arg (parms, intern ("minibuffer"), 0, 0); |
389 | 1844 if (EQ (tem, intern ("none"))) |
771 | 1845 f = make_frame_without_minibuffer (Qnil); |
389 | 1846 else if (EQ (tem, intern ("only"))) |
1847 { | |
771 | 1848 f = make_minibuffer_frame (); |
389 | 1849 minibuffer_only = 1; |
1850 } | |
485 | 1851 else if (EQ (tem, Qnil) || EQ (tem, Qt)) |
771 | 1852 f = make_frame (1); |
485 | 1853 else |
771 | 1854 f = make_frame_without_minibuffer (tem); |
1855 | |
1856 /* Set the name; the functions to which we pass f expect the | |
389 | 1857 name to be set. */ |
771 | 1858 XSET (f->name, Lisp_String, name); |
1859 | |
1860 XSET (frame, Lisp_Frame, f); | |
1861 f->output_method = output_x_window; | |
1862 f->display.x = (struct x_display *) xmalloc (sizeof (struct x_display)); | |
1863 bzero (f->display.x, sizeof (struct x_display)); | |
1864 | |
1865 /* Note that the frame has no physical cursor right now. */ | |
1866 f->phys_cursor_x = -1; | |
485 | 1867 |
389 | 1868 /* Extract the window parameters from the supplied values |
1869 that are needed to determine window geometry. */ | |
771 | 1870 x_default_parameter (f, parms, "font", |
398 | 1871 build_string ("9x15"), "font", string); |
771 | 1872 x_default_parameter (f, parms, "background-color", |
398 | 1873 build_string ("white"), "background", string); |
771 | 1874 x_default_parameter (f, parms, "border-width", |
398 | 1875 make_number (2), "BorderWidth", number); |
727 | 1876 /* This defaults to 2 in order to match XTerms. */ |
771 | 1877 x_default_parameter (f, parms, "internal-border-width", |
727 | 1878 make_number (2), "InternalBorderWidth", number); |
389 | 1879 |
1880 /* Also do the stuff which must be set before the window exists. */ | |
771 | 1881 x_default_parameter (f, parms, "foreground-color", |
398 | 1882 build_string ("black"), "foreground", string); |
771 | 1883 x_default_parameter (f, parms, "mouse-color", |
398 | 1884 build_string ("black"), "mouse", string); |
771 | 1885 x_default_parameter (f, parms, "cursor-color", |
398 | 1886 build_string ("black"), "cursor", string); |
771 | 1887 x_default_parameter (f, parms, "border-color", |
398 | 1888 build_string ("black"), "border", string); |
389 | 1889 |
1890 /* Need to do icon type, auto-raise, auto-lower. */ | |
1891 | |
771 | 1892 f->display.x->parent_desc = ROOT_WINDOW; |
1893 window_prompting = x_figure_window_size (f, parms); | |
1894 | |
1895 x_window (f); | |
1896 x_icon (f, parms); | |
1897 x_make_gc (f); | |
1898 | |
1899 /* Dimensions, especially f->height, must be done via change_frame_size. | |
389 | 1900 Change will not be effected unless different from the current |
771 | 1901 f->height. */ |
1902 width = f->width; | |
1903 height = f->height; | |
1904 f->height = f->width = 0; | |
1905 change_frame_size (f, height, width, 1); | |
389 | 1906 BLOCK_INPUT; |
771 | 1907 x_wm_set_size_hint (f, window_prompting); |
389 | 1908 UNBLOCK_INPUT; |
1909 | |
641 | 1910 tem = x_get_arg (parms, intern ("unsplittable"), 0, 0); |
771 | 1911 f->no_split = minibuffer_only || EQ (tem, Qt); |
389 | 1912 |
1913 /* Now handle the rest of the parameters. */ | |
771 | 1914 x_default_parameter (f, parms, "horizontal-scroll-bar", |
398 | 1915 Qnil, "?HScrollBar", string); |
771 | 1916 x_default_parameter (f, parms, "vertical-scroll-bar", |
398 | 1917 Qnil, "?VScrollBar", string); |
389 | 1918 |
771 | 1919 /* Make the window appear on the frame and enable display. */ |
641 | 1920 if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), 0, 0), Qt)) |
771 | 1921 x_make_frame_visible (f); |
1922 | |
1923 return frame; | |
389 | 1924 #else /* X10 */ |
771 | 1925 struct frame *f; |
1926 Lisp_Object frame, tem; | |
389 | 1927 Lisp_Object name; |
1928 int pixelwidth, pixelheight; | |
1929 Cursor cursor; | |
1930 int height, width; | |
1931 Window parent; | |
1932 Pixmap temp; | |
1933 int minibuffer_only = 0; | |
1934 Lisp_Object vscroll, hscroll; | |
1935 | |
1936 if (x_current_display == 0) | |
1937 error ("X windows are not in use or not initialized"); | |
1938 | |
1939 name = Fassq (intern ("name"), parms); | |
1940 | |
641 | 1941 tem = x_get_arg (parms, intern ("minibuffer"), 0, 0); |
389 | 1942 if (EQ (tem, intern ("none"))) |
771 | 1943 f = make_frame_without_minibuffer (Qnil); |
389 | 1944 else if (EQ (tem, intern ("only"))) |
1945 { | |
771 | 1946 f = make_minibuffer_frame (); |
389 | 1947 minibuffer_only = 1; |
1948 } | |
1949 else if (! EQ (tem, Qnil)) | |
771 | 1950 f = make_frame_without_minibuffer (tem); |
389 | 1951 else |
771 | 1952 f = make_frame (1); |
389 | 1953 |
1954 parent = ROOT_WINDOW; | |
1955 | |
771 | 1956 XSET (frame, Lisp_Frame, f); |
1957 f->output_method = output_x_window; | |
1958 f->display.x = (struct x_display *) xmalloc (sizeof (struct x_display)); | |
1959 bzero (f->display.x, sizeof (struct x_display)); | |
389 | 1960 |
1961 /* Some temprorary default values for height and width. */ | |
1962 width = 80; | |
1963 height = 40; | |
771 | 1964 f->display.x->left_pos = -1; |
1965 f->display.x->top_pos = -1; | |
1966 | |
1967 /* Give the frame a default name (which may be overridden with PARMS). */ | |
389 | 1968 |
1969 strncpy (iconidentity, ICONTAG, MAXICID); | |
1970 if (gethostname (&iconidentity[sizeof (ICONTAG) - 1], | |
1971 (MAXICID - 1) - sizeof (ICONTAG))) | |
1972 iconidentity[sizeof (ICONTAG) - 2] = '\0'; | |
771 | 1973 f->name = build_string (iconidentity); |
389 | 1974 |
1975 /* Extract some window parameters from the supplied values. | |
1976 These are the parameters that affect window geometry. */ | |
1977 | |
641 | 1978 tem = x_get_arg (parms, intern ("font"), "BodyFont", string); |
389 | 1979 if (EQ (tem, Qnil)) |
1980 tem = build_string ("9x15"); | |
771 | 1981 x_set_font (f, tem); |
1982 x_default_parameter (f, parms, "border-color", | |
398 | 1983 build_string ("black"), "Border", string); |
771 | 1984 x_default_parameter (f, parms, "background-color", |
398 | 1985 build_string ("white"), "Background", string); |
771 | 1986 x_default_parameter (f, parms, "foreground-color", |
398 | 1987 build_string ("black"), "Foreground", string); |
771 | 1988 x_default_parameter (f, parms, "mouse-color", |
398 | 1989 build_string ("black"), "Mouse", string); |
771 | 1990 x_default_parameter (f, parms, "cursor-color", |
398 | 1991 build_string ("black"), "Cursor", string); |
771 | 1992 x_default_parameter (f, parms, "border-width", |
398 | 1993 make_number (2), "BorderWidth", number); |
771 | 1994 x_default_parameter (f, parms, "internal-border-width", |
398 | 1995 make_number (4), "InternalBorderWidth", number); |
771 | 1996 x_default_parameter (f, parms, "auto-raise", |
398 | 1997 Qnil, "AutoRaise", boolean); |
1998 | |
641 | 1999 hscroll = x_get_arg (parms, intern ("horizontal-scroll-bar"), 0, 0); |
2000 vscroll = x_get_arg (parms, intern ("vertical-scroll-bar"), 0, 0); | |
389 | 2001 |
771 | 2002 if (f->display.x->internal_border_width < 0) |
2003 f->display.x->internal_border_width = 0; | |
389 | 2004 |
641 | 2005 tem = x_get_arg (parms, intern ("window-id"), 0, 0); |
389 | 2006 if (!EQ (tem, Qnil)) |
2007 { | |
2008 WINDOWINFO_TYPE wininfo; | |
2009 int nchildren; | |
2010 Window *children, root; | |
2011 | |
2012 CHECK_STRING (tem, 0); | |
771 | 2013 f->display.x->window_desc = (Window) atoi (XSTRING (tem)->data); |
389 | 2014 |
2015 BLOCK_INPUT; | |
771 | 2016 XGetWindowInfo (f->display.x->window_desc, &wininfo); |
2017 XQueryTree (f->display.x->window_desc, &parent, &nchildren, &children); | |
389 | 2018 free (children); |
2019 UNBLOCK_INPUT; | |
2020 | |
771 | 2021 height = (wininfo.height - 2 * f->display.x->internal_border_width) |
2022 / FONT_HEIGHT (f->display.x->font); | |
2023 width = (wininfo.width - 2 * f->display.x->internal_border_width) | |
2024 / FONT_WIDTH (f->display.x->font); | |
2025 f->display.x->left_pos = wininfo.x; | |
2026 f->display.x->top_pos = wininfo.y; | |
2027 f->visible = wininfo.mapped != 0; | |
2028 f->display.x->border_width = wininfo.bdrwidth; | |
2029 f->display.x->parent_desc = parent; | |
389 | 2030 } |
2031 else | |
2032 { | |
641 | 2033 tem = x_get_arg (parms, intern ("parent-id"), 0, 0); |
389 | 2034 if (!EQ (tem, Qnil)) |
2035 { | |
2036 CHECK_STRING (tem, 0); | |
2037 parent = (Window) atoi (XSTRING (tem)->data); | |
2038 } | |
771 | 2039 f->display.x->parent_desc = parent; |
641 | 2040 tem = x_get_arg (parms, intern ("height"), 0, 0); |
389 | 2041 if (EQ (tem, Qnil)) |
2042 { | |
641 | 2043 tem = x_get_arg (parms, intern ("width"), 0, 0); |
389 | 2044 if (EQ (tem, Qnil)) |
2045 { | |
641 | 2046 tem = x_get_arg (parms, intern ("top"), 0, 0); |
389 | 2047 if (EQ (tem, Qnil)) |
641 | 2048 tem = x_get_arg (parms, intern ("left"), 0, 0); |
389 | 2049 } |
2050 } | |
2051 /* Now TEM is nil if no edge or size was specified. | |
2052 In that case, we must do rubber-banding. */ | |
2053 if (EQ (tem, Qnil)) | |
2054 { | |
641 | 2055 tem = x_get_arg (parms, intern ("geometry"), 0, 0); |
771 | 2056 x_rubber_band (f, |
2057 &f->display.x->left_pos, &f->display.x->top_pos, | |
389 | 2058 &width, &height, |
2059 (XTYPE (tem) == Lisp_String | |
2060 ? (char *) XSTRING (tem)->data : ""), | |
771 | 2061 XSTRING (f->name)->data, |
485 | 2062 !NILP (hscroll), !NILP (vscroll)); |
389 | 2063 } |
2064 else | |
2065 { | |
2066 /* Here if at least one edge or size was specified. | |
2067 Demand that they all were specified, and use them. */ | |
641 | 2068 tem = x_get_arg (parms, intern ("height"), 0, 0); |
389 | 2069 if (EQ (tem, Qnil)) |
2070 error ("Height not specified"); | |
2071 CHECK_NUMBER (tem, 0); | |
2072 height = XINT (tem); | |
2073 | |
641 | 2074 tem = x_get_arg (parms, intern ("width"), 0, 0); |
389 | 2075 if (EQ (tem, Qnil)) |
2076 error ("Width not specified"); | |
2077 CHECK_NUMBER (tem, 0); | |
2078 width = XINT (tem); | |
2079 | |
641 | 2080 tem = x_get_arg (parms, intern ("top"), 0, 0); |
389 | 2081 if (EQ (tem, Qnil)) |
2082 error ("Top position not specified"); | |
2083 CHECK_NUMBER (tem, 0); | |
771 | 2084 f->display.x->left_pos = XINT (tem); |
389 | 2085 |
641 | 2086 tem = x_get_arg (parms, intern ("left"), 0, 0); |
389 | 2087 if (EQ (tem, Qnil)) |
2088 error ("Left position not specified"); | |
2089 CHECK_NUMBER (tem, 0); | |
771 | 2090 f->display.x->top_pos = XINT (tem); |
389 | 2091 } |
2092 | |
771 | 2093 pixelwidth = (width * FONT_WIDTH (f->display.x->font) |
2094 + 2 * f->display.x->internal_border_width | |
485 | 2095 + (!NILP (vscroll) ? VSCROLL_WIDTH : 0)); |
771 | 2096 pixelheight = (height * FONT_HEIGHT (f->display.x->font) |
2097 + 2 * f->display.x->internal_border_width | |
485 | 2098 + (!NILP (hscroll) ? HSCROLL_HEIGHT : 0)); |
389 | 2099 |
2100 BLOCK_INPUT; | |
771 | 2101 f->display.x->window_desc |
389 | 2102 = XCreateWindow (parent, |
771 | 2103 f->display.x->left_pos, /* Absolute horizontal offset */ |
2104 f->display.x->top_pos, /* Absolute Vertical offset */ | |
389 | 2105 pixelwidth, pixelheight, |
771 | 2106 f->display.x->border_width, |
389 | 2107 BLACK_PIX_DEFAULT, WHITE_PIX_DEFAULT); |
2108 UNBLOCK_INPUT; | |
771 | 2109 if (f->display.x->window_desc == 0) |
389 | 2110 error ("Unable to create window."); |
2111 } | |
2112 | |
2113 /* Install the now determined height and width | |
2114 in the windows and in phys_lines and desired_lines. */ | |
2115 /* ??? jla version had 1 here instead of 0. */ | |
771 | 2116 change_frame_size (f, height, width, 1); |
2117 XSelectInput (f->display.x->window_desc, KeyPressed | ExposeWindow | |
389 | 2118 | ButtonPressed | ButtonReleased | ExposeRegion | ExposeCopy |
2119 | EnterWindow | LeaveWindow | UnmapWindow ); | |
771 | 2120 x_set_resize_hint (f); |
389 | 2121 |
2122 /* Tell the server the window's default name. */ | |
708 | 2123 #ifdef HAVE_X11 |
2124 { | |
2125 XTextProperty prop; | |
771 | 2126 prop.value = XSTRING (f->name)->data; |
708 | 2127 prop.encoding = XA_STRING; |
2128 prop.format = 8; | |
771 | 2129 prop.nitems = XSTRING (f->name)->size; |
2130 XSetWMName (XDISPLAY f->display.x->window_desc, &prop); | |
708 | 2131 } |
2132 #else | |
771 | 2133 XStoreName (XDISPLAY f->display.x->window_desc, XSTRING (f->name)->data); |
708 | 2134 #endif |
2135 | |
389 | 2136 /* Now override the defaults with all the rest of the specified |
2137 parms. */ | |
641 | 2138 tem = x_get_arg (parms, intern ("unsplittable"), 0, 0); |
771 | 2139 f->no_split = minibuffer_only || EQ (tem, Qt); |
389 | 2140 |
2141 /* Do not create an icon window if the caller says not to */ | |
641 | 2142 if (!EQ (x_get_arg (parms, intern ("suppress-icon"), 0, 0), Qt) |
771 | 2143 || f->display.x->parent_desc != ROOT_WINDOW) |
389 | 2144 { |
771 | 2145 x_text_icon (f, iconidentity); |
2146 x_default_parameter (f, parms, "icon-type", Qnil, | |
398 | 2147 "BitmapIcon", boolean); |
389 | 2148 } |
2149 | |
2150 /* Tell the X server the previously set values of the | |
2151 background, border and mouse colors; also create the mouse cursor. */ | |
2152 BLOCK_INPUT; | |
771 | 2153 temp = XMakeTile (f->display.x->background_pixel); |
2154 XChangeBackground (f->display.x->window_desc, temp); | |
389 | 2155 XFreePixmap (temp); |
2156 UNBLOCK_INPUT; | |
771 | 2157 x_set_border_pixel (f, f->display.x->border_pixel); |
2158 | |
2159 x_set_mouse_color (f, Qnil, Qnil); | |
389 | 2160 |
2161 /* Now override the defaults with all the rest of the specified parms. */ | |
2162 | |
771 | 2163 Fmodify_frame_parameters (frame, parms); |
389 | 2164 |
485 | 2165 if (!NILP (vscroll)) |
771 | 2166 install_vertical_scrollbar (f, pixelwidth, pixelheight); |
485 | 2167 if (!NILP (hscroll)) |
771 | 2168 install_horizontal_scrollbar (f, pixelwidth, pixelheight); |
2169 | |
2170 /* Make the window appear on the frame and enable display. */ | |
389 | 2171 |
641 | 2172 if (!EQ (x_get_arg (parms, intern ("suppress-initial-map"), 0, 0), Qt)) |
771 | 2173 x_make_window_visible (f); |
2174 FRAME_GARBAGED (f); | |
2175 | |
2176 return frame; | |
389 | 2177 #endif /* X10 */ |
2178 } | |
2179 | |
771 | 2180 DEFUN ("focus-frame", Ffocus_frame, Sfocus_frame, 1, 1, 0, |
2181 "Set the focus on FRAME.") | |
2182 (frame) | |
2183 Lisp_Object frame; | |
389 | 2184 { |
771 | 2185 CHECK_LIVE_FRAME (frame, 0); |
2186 | |
2187 if (FRAME_IS_X (XFRAME (frame))) | |
389 | 2188 { |
2189 BLOCK_INPUT; | |
771 | 2190 x_focus_on_frame (XFRAME (frame)); |
389 | 2191 UNBLOCK_INPUT; |
771 | 2192 return frame; |
389 | 2193 } |
2194 | |
2195 return Qnil; | |
2196 } | |
2197 | |
771 | 2198 DEFUN ("unfocus-frame", Funfocus_frame, Sunfocus_frame, 0, 0, 0, |
2199 "If a frame has been focused, release it.") | |
389 | 2200 () |
2201 { | |
771 | 2202 if (x_focus_frame) |
389 | 2203 { |
2204 BLOCK_INPUT; | |
771 | 2205 x_unfocus_frame (x_focus_frame); |
389 | 2206 UNBLOCK_INPUT; |
2207 } | |
2208 | |
2209 return Qnil; | |
2210 } | |
2211 | |
2212 #ifndef HAVE_X11 | |
2213 /* Computes an X-window size and position either from geometry GEO | |
2214 or with the mouse. | |
2215 | |
771 | 2216 F is a frame. It specifies an X window which is used to |
389 | 2217 determine which display to compute for. Its font, borders |
2218 and colors control how the rectangle will be displayed. | |
2219 | |
2220 X and Y are where to store the positions chosen. | |
2221 WIDTH and HEIGHT are where to store the sizes chosen. | |
2222 | |
2223 GEO is the geometry that may specify some of the info. | |
2224 STR is a prompt to display. | |
2225 HSCROLL and VSCROLL say whether we have horiz and vert scroll bars. */ | |
2226 | |
2227 int | |
771 | 2228 x_rubber_band (f, x, y, width, height, geo, str, hscroll, vscroll) |
2229 struct frame *f; | |
389 | 2230 int *x, *y, *width, *height; |
2231 char *geo; | |
2232 char *str; | |
2233 int hscroll, vscroll; | |
2234 { | |
2235 OpaqueFrame frame; | |
2236 Window tempwindow; | |
2237 WindowInfo wininfo; | |
2238 int border_color; | |
2239 int background_color; | |
2240 Lisp_Object tem; | |
2241 int mask; | |
2242 | |
2243 BLOCK_INPUT; | |
2244 | |
771 | 2245 background_color = f->display.x->background_pixel; |
2246 border_color = f->display.x->border_pixel; | |
2247 | |
2248 frame.bdrwidth = f->display.x->border_width; | |
389 | 2249 frame.border = XMakeTile (border_color); |
2250 frame.background = XMakeTile (background_color); | |
2251 tempwindow = XCreateTerm (str, "emacs", geo, default_window, &frame, 10, 5, | |
771 | 2252 (2 * f->display.x->internal_border_width |
389 | 2253 + (vscroll ? VSCROLL_WIDTH : 0)), |
771 | 2254 (2 * f->display.x->internal_border_width |
389 | 2255 + (hscroll ? HSCROLL_HEIGHT : 0)), |
771 | 2256 width, height, f->display.x->font, |
2257 FONT_WIDTH (f->display.x->font), | |
2258 FONT_HEIGHT (f->display.x->font)); | |
389 | 2259 XFreePixmap (frame.border); |
2260 XFreePixmap (frame.background); | |
2261 | |
2262 if (tempwindow != 0) | |
2263 { | |
2264 XQueryWindow (tempwindow, &wininfo); | |
2265 XDestroyWindow (tempwindow); | |
2266 *x = wininfo.x; | |
2267 *y = wininfo.y; | |
2268 } | |
2269 | |
2270 /* Coordinates we got are relative to the root window. | |
2271 Convert them to coordinates relative to desired parent window | |
2272 by scanning from there up to the root. */ | |
771 | 2273 tempwindow = f->display.x->parent_desc; |
389 | 2274 while (tempwindow != ROOT_WINDOW) |
2275 { | |
2276 int nchildren; | |
2277 Window *children; | |
2278 XQueryWindow (tempwindow, &wininfo); | |
2279 *x -= wininfo.x; | |
2280 *y -= wininfo.y; | |
2281 XQueryTree (tempwindow, &tempwindow, &nchildren, &children); | |
2282 free (children); | |
2283 } | |
2284 | |
2285 UNBLOCK_INPUT; | |
2286 return tempwindow != 0; | |
2287 } | |
2288 #endif /* not HAVE_X11 */ | |
2289 | |
771 | 2290 /* Set whether frame F has a horizontal scroll bar. |
389 | 2291 VAL is t or nil to specify it. */ |
2292 | |
2293 static void | |
771 | 2294 x_set_horizontal_scrollbar (f, val, oldval) |
2295 struct frame *f; | |
389 | 2296 Lisp_Object val, oldval; |
2297 { | |
485 | 2298 if (!NILP (val)) |
389 | 2299 { |
771 | 2300 if (f->display.x->window_desc != 0) |
389 | 2301 { |
2302 BLOCK_INPUT; | |
771 | 2303 f->display.x->h_scrollbar_height = HSCROLL_HEIGHT; |
2304 x_set_window_size (f, f->width, f->height); | |
2305 install_horizontal_scrollbar (f); | |
2306 SET_FRAME_GARBAGED (f); | |
389 | 2307 UNBLOCK_INPUT; |
2308 } | |
2309 } | |
2310 else | |
771 | 2311 if (f->display.x->h_scrollbar) |
389 | 2312 { |
2313 BLOCK_INPUT; | |
771 | 2314 f->display.x->h_scrollbar_height = 0; |
2315 XDestroyWindow (XDISPLAY f->display.x->h_scrollbar); | |
2316 f->display.x->h_scrollbar = 0; | |
2317 x_set_window_size (f, f->width, f->height); | |
2318 f->garbaged++; | |
2319 frame_garbaged++; | |
389 | 2320 BLOCK_INPUT; |
2321 } | |
2322 } | |
2323 | |
771 | 2324 /* Set whether frame F has a vertical scroll bar. |
389 | 2325 VAL is t or nil to specify it. */ |
2326 | |
2327 static void | |
771 | 2328 x_set_vertical_scrollbar (f, val, oldval) |
2329 struct frame *f; | |
389 | 2330 Lisp_Object val, oldval; |
2331 { | |
485 | 2332 if (!NILP (val)) |
389 | 2333 { |
771 | 2334 if (f->display.x->window_desc != 0) |
389 | 2335 { |
2336 BLOCK_INPUT; | |
771 | 2337 f->display.x->v_scrollbar_width = VSCROLL_WIDTH; |
2338 x_set_window_size (f, f->width, f->height); | |
2339 install_vertical_scrollbar (f); | |
2340 SET_FRAME_GARBAGED (f); | |
389 | 2341 UNBLOCK_INPUT; |
2342 } | |
2343 } | |
2344 else | |
771 | 2345 if (f->display.x->v_scrollbar != 0) |
389 | 2346 { |
2347 BLOCK_INPUT; | |
771 | 2348 f->display.x->v_scrollbar_width = 0; |
2349 XDestroyWindow (XDISPLAY f->display.x->v_scrollbar); | |
2350 f->display.x->v_scrollbar = 0; | |
2351 x_set_window_size (f, f->width, f->height); | |
2352 SET_FRAME_GARBAGED (f); | |
389 | 2353 UNBLOCK_INPUT; |
2354 } | |
2355 } | |
2356 | |
2357 /* Create the X windows for a vertical scroll bar | |
771 | 2358 for a frame X that already has an X window but no scroll bar. */ |
389 | 2359 |
2360 static void | |
771 | 2361 install_vertical_scrollbar (f) |
2362 struct frame *f; | |
389 | 2363 { |
771 | 2364 int ibw = f->display.x->internal_border_width; |
389 | 2365 Window parent; |
2366 XColor fore_color, back_color; | |
2367 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap; | |
2368 int pix_x, pix_y, width, height, border; | |
2369 | |
771 | 2370 height = f->display.x->pixel_height - ibw - 2; |
389 | 2371 width = VSCROLL_WIDTH - 2; |
771 | 2372 pix_x = f->display.x->pixel_width - ibw/2; |
389 | 2373 pix_y = ibw / 2; |
2374 border = 1; | |
2375 | |
2376 #ifdef HAVE_X11 | |
2377 up_arrow_pixmap = | |
771 | 2378 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, |
389 | 2379 up_arrow_bits, 16, 16, |
771 | 2380 f->display.x->foreground_pixel, |
2381 f->display.x->background_pixel, | |
389 | 2382 DefaultDepth (x_current_display, |
2383 XDefaultScreen (x_current_display))); | |
2384 | |
2385 down_arrow_pixmap = | |
771 | 2386 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, |
389 | 2387 down_arrow_bits, 16, 16, |
771 | 2388 f->display.x->foreground_pixel, |
2389 f->display.x->background_pixel, | |
389 | 2390 DefaultDepth (x_current_display, |
2391 XDefaultScreen (x_current_display))); | |
2392 | |
2393 slider_pixmap = | |
771 | 2394 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, |
389 | 2395 gray_bits, 16, 16, |
771 | 2396 f->display.x->foreground_pixel, |
2397 f->display.x->background_pixel, | |
389 | 2398 DefaultDepth (x_current_display, |
2399 XDefaultScreen (x_current_display))); | |
2400 | |
2401 /* These cursor shapes will be installed when the mouse enters | |
2402 the appropriate window. */ | |
2403 | |
2404 up_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_up_arrow); | |
2405 down_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_down_arrow); | |
2406 v_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_v_double_arrow); | |
2407 | |
771 | 2408 f->display.x->v_scrollbar = |
2409 XCreateSimpleWindow (x_current_display, f->display.x->window_desc, | |
389 | 2410 pix_x, pix_y, width, height, border, |
771 | 2411 f->display.x->foreground_pixel, |
2412 f->display.x->background_pixel); | |
389 | 2413 XFlush (x_current_display); |
771 | 2414 XDefineCursor (x_current_display, f->display.x->v_scrollbar, |
389 | 2415 v_double_arrow_cursor); |
2416 | |
2417 /* Create slider window */ | |
771 | 2418 f->display.x->v_slider = |
2419 XCreateSimpleWindow (x_current_display, f->display.x->v_scrollbar, | |
389 | 2420 0, VSCROLL_WIDTH - 2, |
2421 VSCROLL_WIDTH - 4, VSCROLL_WIDTH - 4, | |
771 | 2422 1, f->display.x->border_pixel, |
2423 f->display.x->foreground_pixel); | |
389 | 2424 XFlush (x_current_display); |
771 | 2425 XDefineCursor (x_current_display, f->display.x->v_slider, |
389 | 2426 v_double_arrow_cursor); |
771 | 2427 XSetWindowBackgroundPixmap (x_current_display, f->display.x->v_slider, |
389 | 2428 slider_pixmap); |
2429 | |
771 | 2430 f->display.x->v_thumbup = |
2431 XCreateSimpleWindow (x_current_display, f->display.x->v_scrollbar, | |
389 | 2432 0, 0, |
2433 VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, | |
771 | 2434 0, f->display.x->foreground_pixel, |
2435 f->display.x-> background_pixel); | |
389 | 2436 XFlush (x_current_display); |
771 | 2437 XDefineCursor (x_current_display, f->display.x->v_thumbup, |
389 | 2438 up_arrow_cursor); |
771 | 2439 XSetWindowBackgroundPixmap (x_current_display, f->display.x->v_thumbup, |
389 | 2440 up_arrow_pixmap); |
2441 | |
771 | 2442 f->display.x->v_thumbdown = |
2443 XCreateSimpleWindow (x_current_display, f->display.x->v_scrollbar, | |
389 | 2444 0, height - VSCROLL_WIDTH + 2, |
2445 VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, | |
771 | 2446 0, f->display.x->foreground_pixel, |
2447 f->display.x->background_pixel); | |
389 | 2448 XFlush (x_current_display); |
771 | 2449 XDefineCursor (x_current_display, f->display.x->v_thumbdown, |
389 | 2450 down_arrow_cursor); |
771 | 2451 XSetWindowBackgroundPixmap (x_current_display, f->display.x->v_thumbdown, |
389 | 2452 down_arrow_pixmap); |
2453 | |
771 | 2454 fore_color.pixel = f->display.x->mouse_pixel; |
2455 back_color.pixel = f->display.x->background_pixel; | |
389 | 2456 XQueryColor (x_current_display, |
2457 DefaultColormap (x_current_display, | |
2458 DefaultScreen (x_current_display)), | |
2459 &fore_color); | |
2460 XQueryColor (x_current_display, | |
2461 DefaultColormap (x_current_display, | |
2462 DefaultScreen (x_current_display)), | |
2463 &back_color); | |
2464 XRecolorCursor (x_current_display, up_arrow_cursor, | |
2465 &fore_color, &back_color); | |
2466 XRecolorCursor (x_current_display, down_arrow_cursor, | |
2467 &fore_color, &back_color); | |
2468 XRecolorCursor (x_current_display, v_double_arrow_cursor, | |
2469 &fore_color, &back_color); | |
2470 | |
2471 XFreePixmap (x_current_display, slider_pixmap); | |
2472 XFreePixmap (x_current_display, up_arrow_pixmap); | |
2473 XFreePixmap (x_current_display, down_arrow_pixmap); | |
2474 XFlush (x_current_display); | |
2475 | |
771 | 2476 XSelectInput (x_current_display, f->display.x->v_scrollbar, |
389 | 2477 ButtonPressMask | ButtonReleaseMask |
2478 | PointerMotionMask | PointerMotionHintMask | |
2479 | EnterWindowMask); | |
771 | 2480 XSelectInput (x_current_display, f->display.x->v_slider, |
389 | 2481 ButtonPressMask | ButtonReleaseMask); |
771 | 2482 XSelectInput (x_current_display, f->display.x->v_thumbdown, |
389 | 2483 ButtonPressMask | ButtonReleaseMask); |
771 | 2484 XSelectInput (x_current_display, f->display.x->v_thumbup, |
389 | 2485 ButtonPressMask | ButtonReleaseMask); |
2486 XFlush (x_current_display); | |
2487 | |
2488 /* This should be done at the same time as the main window. */ | |
771 | 2489 XMapWindow (x_current_display, f->display.x->v_scrollbar); |
2490 XMapSubwindows (x_current_display, f->display.x->v_scrollbar); | |
389 | 2491 XFlush (x_current_display); |
2492 #else /* not HAVE_X11 */ | |
2493 Bitmap b; | |
2494 Pixmap fore_tile, back_tile, bord_tile; | |
2495 static short up_arrow_bits[] = { | |
2496 0x0000, 0x0180, 0x03c0, 0x07e0, | |
2497 0x0ff0, 0x1ff8, 0x3ffc, 0x7ffe, | |
2498 0x0180, 0x0180, 0x0180, 0x0180, | |
2499 0x0180, 0x0180, 0x0180, 0xffff}; | |
2500 static short down_arrow_bits[] = { | |
2501 0xffff, 0x0180, 0x0180, 0x0180, | |
2502 0x0180, 0x0180, 0x0180, 0x0180, | |
2503 0x7ffe, 0x3ffc, 0x1ff8, 0x0ff0, | |
2504 0x07e0, 0x03c0, 0x0180, 0x0000}; | |
2505 | |
771 | 2506 fore_tile = XMakeTile (f->display.x->foreground_pixel); |
2507 back_tile = XMakeTile (f->display.x->background_pixel); | |
2508 bord_tile = XMakeTile (f->display.x->border_pixel); | |
389 | 2509 |
2510 b = XStoreBitmap (VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, up_arrow_bits); | |
2511 up_arrow_pixmap = XMakePixmap (b, | |
771 | 2512 f->display.x->foreground_pixel, |
2513 f->display.x->background_pixel); | |
389 | 2514 XFreeBitmap (b); |
2515 | |
2516 b = XStoreBitmap (VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, down_arrow_bits); | |
2517 down_arrow_pixmap = XMakePixmap (b, | |
771 | 2518 f->display.x->foreground_pixel, |
2519 f->display.x->background_pixel); | |
389 | 2520 XFreeBitmap (b); |
2521 | |
771 | 2522 ibw = f->display.x->internal_border_width; |
2523 | |
2524 f->display.x->v_scrollbar = XCreateWindow (f->display.x->window_desc, | |
389 | 2525 width - VSCROLL_WIDTH - ibw/2, |
2526 ibw/2, | |
2527 VSCROLL_WIDTH - 2, | |
2528 height - ibw - 2, | |
2529 1, bord_tile, back_tile); | |
2530 | |
771 | 2531 f->display.x->v_scrollbar_width = VSCROLL_WIDTH; |
2532 | |
2533 f->display.x->v_thumbup = XCreateWindow (f->display.x->v_scrollbar, | |
389 | 2534 0, 0, |
2535 VSCROLL_WIDTH - 2, | |
2536 VSCROLL_WIDTH - 2, | |
2537 0, 0, up_arrow_pixmap); | |
771 | 2538 XTileAbsolute (f->display.x->v_thumbup); |
2539 | |
2540 f->display.x->v_thumbdown = XCreateWindow (f->display.x->v_scrollbar, | |
389 | 2541 0, |
2542 height - ibw - VSCROLL_WIDTH, | |
2543 VSCROLL_WIDTH - 2, | |
2544 VSCROLL_WIDTH - 2, | |
2545 0, 0, down_arrow_pixmap); | |
771 | 2546 XTileAbsolute (f->display.x->v_thumbdown); |
2547 | |
2548 f->display.x->v_slider = XCreateWindow (f->display.x->v_scrollbar, | |
389 | 2549 0, VSCROLL_WIDTH - 2, |
2550 VSCROLL_WIDTH - 4, | |
2551 VSCROLL_WIDTH - 4, | |
2552 1, back_tile, fore_tile); | |
2553 | |
771 | 2554 XSelectInput (f->display.x->v_scrollbar, |
389 | 2555 (ButtonPressed | ButtonReleased | KeyPressed)); |
771 | 2556 XSelectInput (f->display.x->v_thumbup, |
389 | 2557 (ButtonPressed | ButtonReleased | KeyPressed)); |
2558 | |
771 | 2559 XSelectInput (f->display.x->v_thumbdown, |
389 | 2560 (ButtonPressed | ButtonReleased | KeyPressed)); |
2561 | |
771 | 2562 XMapWindow (f->display.x->v_thumbup); |
2563 XMapWindow (f->display.x->v_thumbdown); | |
2564 XMapWindow (f->display.x->v_slider); | |
2565 XMapWindow (f->display.x->v_scrollbar); | |
389 | 2566 |
2567 XFreePixmap (fore_tile); | |
2568 XFreePixmap (back_tile); | |
2569 XFreePixmap (up_arrow_pixmap); | |
2570 XFreePixmap (down_arrow_pixmap); | |
2571 #endif /* not HAVE_X11 */ | |
2572 } | |
2573 | |
2574 static void | |
771 | 2575 install_horizontal_scrollbar (f) |
2576 struct frame *f; | |
389 | 2577 { |
771 | 2578 int ibw = f->display.x->internal_border_width; |
389 | 2579 Window parent; |
2580 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap; | |
2581 int pix_x, pix_y; | |
2582 int width; | |
2583 | |
2584 pix_x = ibw; | |
771 | 2585 pix_y = PIXEL_HEIGHT (f) - HSCROLL_HEIGHT - ibw ; |
2586 width = PIXEL_WIDTH (f) - 2 * ibw; | |
2587 if (f->display.x->v_scrollbar_width) | |
2588 width -= (f->display.x->v_scrollbar_width + 1); | |
389 | 2589 |
2590 #ifdef HAVE_X11 | |
2591 left_arrow_pixmap = | |
771 | 2592 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, |
389 | 2593 left_arrow_bits, 16, 16, |
771 | 2594 f->display.x->foreground_pixel, |
2595 f->display.x->background_pixel, | |
389 | 2596 DefaultDepth (x_current_display, |
2597 XDefaultScreen (x_current_display))); | |
2598 | |
2599 right_arrow_pixmap = | |
771 | 2600 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, |
389 | 2601 right_arrow_bits, 16, 16, |
771 | 2602 f->display.x->foreground_pixel, |
2603 f->display.x->background_pixel, | |
389 | 2604 DefaultDepth (x_current_display, |
2605 XDefaultScreen (x_current_display))); | |
2606 | |
2607 slider_pixmap = | |
771 | 2608 XCreatePixmapFromBitmapData (x_current_display, f->display.x->window_desc, |
389 | 2609 gray_bits, 16, 16, |
771 | 2610 f->display.x->foreground_pixel, |
2611 f->display.x->background_pixel, | |
389 | 2612 DefaultDepth (x_current_display, |
2613 XDefaultScreen (x_current_display))); | |
2614 | |
2615 left_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_left_arrow); | |
2616 right_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_right_arrow); | |
2617 h_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_h_double_arrow); | |
2618 | |
771 | 2619 f->display.x->h_scrollbar = |
2620 XCreateSimpleWindow (x_current_display, f->display.x->window_desc, | |
389 | 2621 pix_x, pix_y, |
2622 width - ibw - 2, HSCROLL_HEIGHT - 2, 1, | |
771 | 2623 f->display.x->foreground_pixel, |
2624 f->display.x->background_pixel); | |
2625 XDefineCursor (x_current_display, f->display.x->h_scrollbar, | |
389 | 2626 h_double_arrow_cursor); |
2627 | |
771 | 2628 f->display.x->h_slider = |
2629 XCreateSimpleWindow (x_current_display, f->display.x->h_scrollbar, | |
389 | 2630 0, 0, |
2631 HSCROLL_HEIGHT - 4, HSCROLL_HEIGHT - 4, | |
771 | 2632 1, f->display.x->foreground_pixel, |
2633 f->display.x->background_pixel); | |
2634 XDefineCursor (x_current_display, f->display.x->h_slider, | |
389 | 2635 h_double_arrow_cursor); |
771 | 2636 XSetWindowBackgroundPixmap (x_current_display, f->display.x->h_slider, |
389 | 2637 slider_pixmap); |
2638 | |
771 | 2639 f->display.x->h_thumbleft = |
2640 XCreateSimpleWindow (x_current_display, f->display.x->h_scrollbar, | |
389 | 2641 0, 0, |
2642 HSCROLL_HEIGHT - 2, HSCROLL_HEIGHT - 2, | |
771 | 2643 0, f->display.x->foreground_pixel, |
2644 f->display.x->background_pixel); | |
2645 XDefineCursor (x_current_display, f->display.x->h_thumbleft, | |
389 | 2646 left_arrow_cursor); |
771 | 2647 XSetWindowBackgroundPixmap (x_current_display, f->display.x->h_thumbleft, |
389 | 2648 left_arrow_pixmap); |
2649 | |
771 | 2650 f->display.x->h_thumbright = |
2651 XCreateSimpleWindow (x_current_display, f->display.x->h_scrollbar, | |
389 | 2652 width - ibw - HSCROLL_HEIGHT, 0, |
2653 HSCROLL_HEIGHT - 2, HSCROLL_HEIGHT -2, | |
771 | 2654 0, f->display.x->foreground_pixel, |
2655 f->display.x->background_pixel); | |
2656 XDefineCursor (x_current_display, f->display.x->h_thumbright, | |
389 | 2657 right_arrow_cursor); |
771 | 2658 XSetWindowBackgroundPixmap (x_current_display, f->display.x->h_thumbright, |
389 | 2659 right_arrow_pixmap); |
2660 | |
2661 XFreePixmap (x_current_display, slider_pixmap); | |
2662 XFreePixmap (x_current_display, left_arrow_pixmap); | |
2663 XFreePixmap (x_current_display, right_arrow_pixmap); | |
2664 | |
771 | 2665 XSelectInput (x_current_display, f->display.x->h_scrollbar, |
389 | 2666 ButtonPressMask | ButtonReleaseMask |
2667 | PointerMotionMask | PointerMotionHintMask | |
2668 | EnterWindowMask); | |
771 | 2669 XSelectInput (x_current_display, f->display.x->h_slider, |
389 | 2670 ButtonPressMask | ButtonReleaseMask); |
771 | 2671 XSelectInput (x_current_display, f->display.x->h_thumbright, |
389 | 2672 ButtonPressMask | ButtonReleaseMask); |
771 | 2673 XSelectInput (x_current_display, f->display.x->h_thumbleft, |
389 | 2674 ButtonPressMask | ButtonReleaseMask); |
2675 | |
771 | 2676 XMapWindow (x_current_display, f->display.x->h_scrollbar); |
2677 XMapSubwindows (x_current_display, f->display.x->h_scrollbar); | |
389 | 2678 #else /* not HAVE_X11 */ |
2679 Bitmap b; | |
2680 Pixmap fore_tile, back_tile, bord_tile; | |
2681 #endif | |
2682 } | |
2683 | |
2684 #ifndef HAVE_X11 /* X10 */ | |
2685 #define XMoveResizeWindow XConfigureWindow | |
2686 #endif /* not HAVE_X11 */ | |
2687 | |
2688 /* Adjust the displayed position in the scroll bar for window W. */ | |
2689 | |
2690 void | |
771 | 2691 adjust_scrollbars (f) |
2692 struct frame *f; | |
389 | 2693 { |
2694 int pos; | |
2695 int first_char_in_window, char_beyond_window, chars_in_window; | |
2696 int chars_in_buffer, buffer_size; | |
771 | 2697 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); |
2698 | |
2699 if (! FRAME_IS_X (f)) | |
389 | 2700 return; |
2701 | |
771 | 2702 if (f->display.x->v_scrollbar != 0) |
389 | 2703 { |
2704 int h, height; | |
2705 struct buffer *b = XBUFFER (w->buffer); | |
2706 | |
2707 buffer_size = Z - BEG; | |
2708 chars_in_buffer = ZV - BEGV; | |
2709 first_char_in_window = marker_position (w->start); | |
2710 char_beyond_window = buffer_size + 1 - XFASTINT (w->window_end_pos); | |
2711 chars_in_window = char_beyond_window - first_char_in_window; | |
2712 | |
2713 /* Calculate height of scrollbar area */ | |
2714 | |
771 | 2715 height = f->height * FONT_HEIGHT (f->display.x->font) |
2716 + f->display.x->internal_border_width | |
2717 - 2 * (f->display.x->v_scrollbar_width); | |
389 | 2718 |
2719 /* Figure starting position for the scrollbar slider */ | |
2720 | |
2721 if (chars_in_buffer <= 0) | |
2722 pos = 0; | |
2723 else | |
2724 pos = ((first_char_in_window - BEGV - BEG) * height | |
2725 / chars_in_buffer); | |
2726 pos = max (0, pos); | |
2727 pos = min (pos, height - 2); | |
2728 | |
2729 /* Figure length of the slider */ | |
2730 | |
2731 if (chars_in_buffer <= 0) | |
2732 h = height; | |
2733 else | |
2734 h = (chars_in_window * height) / chars_in_buffer; | |
2735 h = min (h, height - pos); | |
2736 h = max (h, 1); | |
2737 | |
2738 /* Add thumbup offset to starting position of slider */ | |
2739 | |
771 | 2740 pos += (f->display.x->v_scrollbar_width - 2); |
389 | 2741 |
2742 XMoveResizeWindow (XDISPLAY | |
771 | 2743 f->display.x->v_slider, |
389 | 2744 0, pos, |
771 | 2745 f->display.x->v_scrollbar_width - 4, h); |
389 | 2746 } |
2747 | |
771 | 2748 if (f->display.x->h_scrollbar != 0) |
389 | 2749 { |
2750 int l, length; /* Length of the scrollbar area */ | |
2751 | |
771 | 2752 length = f->width * FONT_WIDTH (f->display.x->font) |
2753 + f->display.x->internal_border_width | |
2754 - 2 * (f->display.x->h_scrollbar_height); | |
389 | 2755 |
2756 /* Starting position for horizontal slider */ | |
2757 if (! w->hscroll) | |
2758 pos = 0; | |
2759 else | |
771 | 2760 pos = (w->hscroll * length) / (w->hscroll + f->width); |
389 | 2761 pos = max (0, pos); |
2762 pos = min (pos, length - 2); | |
2763 | |
2764 /* Length of slider */ | |
2765 l = length - pos; | |
2766 | |
2767 /* Add thumbup offset */ | |
771 | 2768 pos += (f->display.x->h_scrollbar_height - 2); |
389 | 2769 |
2770 XMoveResizeWindow (XDISPLAY | |
771 | 2771 f->display.x->h_slider, |
389 | 2772 pos, 0, |
771 | 2773 l, f->display.x->h_scrollbar_height - 4); |
389 | 2774 } |
2775 } | |
2776 | |
771 | 2777 /* Adjust the size of the scroll bars of frame F, |
2778 when the frame size has changed. */ | |
389 | 2779 |
2780 void | |
771 | 2781 x_resize_scrollbars (f) |
2782 struct frame *f; | |
389 | 2783 { |
771 | 2784 int ibw = f->display.x->internal_border_width; |
389 | 2785 int pixelwidth, pixelheight; |
2786 | |
771 | 2787 if (f == 0 |
2788 || f->display.x == 0 | |
2789 || (f->display.x->v_scrollbar == 0 | |
2790 && f->display.x->h_scrollbar == 0)) | |
389 | 2791 return; |
2792 | |
771 | 2793 /* Get the size of the frame. */ |
2794 pixelwidth = (f->width * FONT_WIDTH (f->display.x->font) | |
2795 + 2 * ibw + f->display.x->v_scrollbar_width); | |
2796 pixelheight = (f->height * FONT_HEIGHT (f->display.x->font) | |
2797 + 2 * ibw + f->display.x->h_scrollbar_height); | |
2798 | |
2799 if (f->display.x->v_scrollbar_width && f->display.x->v_scrollbar) | |
389 | 2800 { |
2801 BLOCK_INPUT; | |
2802 XMoveResizeWindow (XDISPLAY | |
771 | 2803 f->display.x->v_scrollbar, |
2804 pixelwidth - f->display.x->v_scrollbar_width - ibw/2, | |
389 | 2805 ibw/2, |
771 | 2806 f->display.x->v_scrollbar_width - 2, |
389 | 2807 pixelheight - ibw - 2); |
2808 XMoveWindow (XDISPLAY | |
771 | 2809 f->display.x->v_thumbdown, 0, |
2810 pixelheight - ibw - f->display.x->v_scrollbar_width); | |
389 | 2811 UNBLOCK_INPUT; |
2812 } | |
2813 | |
771 | 2814 if (f->display.x->h_scrollbar_height && f->display.x->h_scrollbar) |
389 | 2815 { |
771 | 2816 if (f->display.x->v_scrollbar_width) |
2817 pixelwidth -= f->display.x->v_scrollbar_width + 1; | |
389 | 2818 |
2819 BLOCK_INPUT; | |
2820 XMoveResizeWindow (XDISPLAY | |
771 | 2821 f->display.x->h_scrollbar, |
389 | 2822 ibw / 2, |
771 | 2823 pixelheight - f->display.x->h_scrollbar_height - ibw / 2, |
389 | 2824 pixelwidth - ibw - 2, |
771 | 2825 f->display.x->h_scrollbar_height - 2); |
389 | 2826 XMoveWindow (XDISPLAY |
771 | 2827 f->display.x->h_thumbright, |
2828 pixelwidth - ibw - f->display.x->h_scrollbar_height, 0); | |
389 | 2829 UNBLOCK_INPUT; |
2830 } | |
2831 } | |
2832 | |
771 | 2833 x_pixel_width (f) |
2834 register struct frame *f; | |
389 | 2835 { |
771 | 2836 return PIXEL_WIDTH (f); |
389 | 2837 } |
2838 | |
771 | 2839 x_pixel_height (f) |
2840 register struct frame *f; | |
389 | 2841 { |
771 | 2842 return PIXEL_HEIGHT (f); |
389 | 2843 } |
2844 | |
2845 DEFUN ("x-defined-color", Fx_defined_color, Sx_defined_color, 1, 1, 0, | |
2846 "Return t if the current X display supports the color named COLOR.") | |
2847 (color) | |
2848 Lisp_Object color; | |
2849 { | |
2850 Color foo; | |
2851 | |
2852 CHECK_STRING (color, 0); | |
2853 | |
2854 if (defined_color (XSTRING (color)->data, &foo)) | |
2855 return Qt; | |
2856 else | |
2857 return Qnil; | |
2858 } | |
2859 | |
2860 DEFUN ("x-color-display-p", Fx_color_display_p, Sx_color_display_p, 0, 0, 0, | |
2861 "Return t if the X display used currently supports color.") | |
2862 () | |
2863 { | |
2864 if (XINT (x_screen_planes) <= 2) | |
2865 return Qnil; | |
2866 | |
2867 switch (screen_visual->class) | |
2868 { | |
2869 case StaticColor: | |
2870 case PseudoColor: | |
2871 case TrueColor: | |
2872 case DirectColor: | |
2873 return Qt; | |
2874 | |
2875 default: | |
2876 return Qnil; | |
2877 } | |
2878 } | |
2879 | |
2880 DEFUN ("x-pixel-width", Fx_pixel_width, Sx_pixel_width, 1, 1, 0, | |
771 | 2881 "Return the width in pixels of FRAME.") |
2882 (frame) | |
2883 Lisp_Object frame; | |
389 | 2884 { |
771 | 2885 CHECK_LIVE_FRAME (frame, 0); |
2886 return make_number (XFRAME (frame)->display.x->pixel_width); | |
389 | 2887 } |
2888 | |
2889 DEFUN ("x-pixel-height", Fx_pixel_height, Sx_pixel_height, 1, 1, 0, | |
771 | 2890 "Return the height in pixels of FRAME.") |
2891 (frame) | |
2892 Lisp_Object frame; | |
389 | 2893 { |
771 | 2894 CHECK_LIVE_FRAME (frame, 0); |
2895 return make_number (XFRAME (frame)->display.x->pixel_height); | |
389 | 2896 } |
2897 | |
689
45401d45581d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
2898 #if 0 /* These no longer seem like the right way to do things. */ |
45401d45581d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
2899 |
771 | 2900 /* Draw a rectangle on the frame with left top corner including |
389 | 2901 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is |
2902 CHARS by LINES wide and long and is the color of the cursor. */ | |
2903 | |
2904 void | |
771 | 2905 x_rectangle (f, gc, left_char, top_char, chars, lines) |
2906 register struct frame *f; | |
389 | 2907 GC gc; |
2908 register int top_char, left_char, chars, lines; | |
2909 { | |
2910 int width; | |
2911 int height; | |
771 | 2912 int left = (left_char * FONT_WIDTH (f->display.x->font) |
2913 + f->display.x->internal_border_width); | |
2914 int top = (top_char * FONT_HEIGHT (f->display.x->font) | |
2915 + f->display.x->internal_border_width); | |
389 | 2916 |
2917 if (chars < 0) | |
771 | 2918 width = FONT_WIDTH (f->display.x->font) / 2; |
389 | 2919 else |
771 | 2920 width = FONT_WIDTH (f->display.x->font) * chars; |
389 | 2921 if (lines < 0) |
771 | 2922 height = FONT_HEIGHT (f->display.x->font) / 2; |
389 | 2923 else |
771 | 2924 height = FONT_HEIGHT (f->display.x->font) * lines; |
2925 | |
2926 XDrawRectangle (x_current_display, f->display.x->window_desc, | |
389 | 2927 gc, left, top, width, height); |
2928 } | |
2929 | |
2930 DEFUN ("x-draw-rectangle", Fx_draw_rectangle, Sx_draw_rectangle, 5, 5, 0, | |
771 | 2931 "Draw a rectangle on FRAME between coordinates specified by\n\ |
389 | 2932 numbers X0, Y0, X1, Y1 in the cursor pixel.") |
771 | 2933 (frame, X0, Y0, X1, Y1) |
2934 register Lisp_Object frame, X0, X1, Y0, Y1; | |
389 | 2935 { |
2936 register int x0, y0, x1, y1, top, left, n_chars, n_lines; | |
2937 | |
771 | 2938 CHECK_LIVE_FRAME (frame, 0); |
389 | 2939 CHECK_NUMBER (X0, 0); |
2940 CHECK_NUMBER (Y0, 1); | |
2941 CHECK_NUMBER (X1, 2); | |
2942 CHECK_NUMBER (Y1, 3); | |
2943 | |
2944 x0 = XINT (X0); | |
2945 x1 = XINT (X1); | |
2946 y0 = XINT (Y0); | |
2947 y1 = XINT (Y1); | |
2948 | |
2949 if (y1 > y0) | |
2950 { | |
2951 top = y0; | |
2952 n_lines = y1 - y0 + 1; | |
2953 } | |
2954 else | |
2955 { | |
2956 top = y1; | |
2957 n_lines = y0 - y1 + 1; | |
2958 } | |
2959 | |
2960 if (x1 > x0) | |
2961 { | |
2962 left = x0; | |
2963 n_chars = x1 - x0 + 1; | |
2964 } | |
2965 else | |
2966 { | |
2967 left = x1; | |
2968 n_chars = x0 - x1 + 1; | |
2969 } | |
2970 | |
2971 BLOCK_INPUT; | |
771 | 2972 x_rectangle (XFRAME (frame), XFRAME (frame)->display.x->cursor_gc, |
389 | 2973 left, top, n_chars, n_lines); |
2974 UNBLOCK_INPUT; | |
2975 | |
2976 return Qt; | |
2977 } | |
2978 | |
2979 DEFUN ("x-erase-rectangle", Fx_erase_rectangle, Sx_erase_rectangle, 5, 5, 0, | |
771 | 2980 "Draw a rectangle drawn on FRAME between coordinates\n\ |
389 | 2981 X0, Y0, X1, Y1 in the regular background-pixel.") |
771 | 2982 (frame, X0, Y0, X1, Y1) |
2983 register Lisp_Object frame, X0, Y0, X1, Y1; | |
389 | 2984 { |
2985 register int x0, y0, x1, y1, top, left, n_chars, n_lines; | |
2986 | |
771 | 2987 CHECK_FRAME (frame, 0); |
389 | 2988 CHECK_NUMBER (X0, 0); |
2989 CHECK_NUMBER (Y0, 1); | |
2990 CHECK_NUMBER (X1, 2); | |
2991 CHECK_NUMBER (Y1, 3); | |
2992 | |
2993 x0 = XINT (X0); | |
2994 x1 = XINT (X1); | |
2995 y0 = XINT (Y0); | |
2996 y1 = XINT (Y1); | |
2997 | |
2998 if (y1 > y0) | |
2999 { | |
3000 top = y0; | |
3001 n_lines = y1 - y0 + 1; | |
3002 } | |
3003 else | |
3004 { | |
3005 top = y1; | |
3006 n_lines = y0 - y1 + 1; | |
3007 } | |
3008 | |
3009 if (x1 > x0) | |
3010 { | |
3011 left = x0; | |
3012 n_chars = x1 - x0 + 1; | |
3013 } | |
3014 else | |
3015 { | |
3016 left = x1; | |
3017 n_chars = x0 - x1 + 1; | |
3018 } | |
3019 | |
3020 BLOCK_INPUT; | |
771 | 3021 x_rectangle (XFRAME (frame), XFRAME (frame)->display.x->reverse_gc, |
389 | 3022 left, top, n_chars, n_lines); |
3023 UNBLOCK_INPUT; | |
3024 | |
3025 return Qt; | |
3026 } | |
3027 | |
3028 /* Draw lines around the text region beginning at the character position | |
3029 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the | |
3030 pixel and line characteristics. */ | |
3031 | |
771 | 3032 #define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)]) |
389 | 3033 |
3034 static void | |
771 | 3035 outline_region (f, gc, top_x, top_y, bottom_x, bottom_y) |
3036 register struct frame *f; | |
389 | 3037 GC gc; |
3038 int top_x, top_y, bottom_x, bottom_y; | |
3039 { | |
771 | 3040 register int ibw = f->display.x->internal_border_width; |
3041 register int font_w = FONT_WIDTH (f->display.x->font); | |
3042 register int font_h = FONT_HEIGHT (f->display.x->font); | |
389 | 3043 int y = top_y; |
3044 int x = line_len (y); | |
3045 XPoint *pixel_points = (XPoint *) | |
3046 alloca (((bottom_y - top_y + 2) * 4) * sizeof (XPoint)); | |
3047 register XPoint *this_point = pixel_points; | |
3048 | |
3049 /* Do the horizontal top line/lines */ | |
3050 if (top_x == 0) | |
3051 { | |
3052 this_point->x = ibw; | |
3053 this_point->y = ibw + (font_h * top_y); | |
3054 this_point++; | |
3055 if (x == 0) | |
3056 this_point->x = ibw + (font_w / 2); /* Half-size for newline chars. */ | |
3057 else | |
3058 this_point->x = ibw + (font_w * x); | |
3059 this_point->y = (this_point - 1)->y; | |
3060 } | |
3061 else | |
3062 { | |
3063 this_point->x = ibw; | |
3064 this_point->y = ibw + (font_h * (top_y + 1)); | |
3065 this_point++; | |
3066 this_point->x = ibw + (font_w * top_x); | |
3067 this_point->y = (this_point - 1)->y; | |
3068 this_point++; | |
3069 this_point->x = (this_point - 1)->x; | |
3070 this_point->y = ibw + (font_h * top_y); | |
3071 this_point++; | |
3072 this_point->x = ibw + (font_w * x); | |
3073 this_point->y = (this_point - 1)->y; | |
3074 } | |
3075 | |
3076 /* Now do the right side. */ | |
3077 while (y < bottom_y) | |
3078 { /* Right vertical edge */ | |
3079 this_point++; | |
3080 this_point->x = (this_point - 1)->x; | |
3081 this_point->y = ibw + (font_h * (y + 1)); | |
3082 this_point++; | |
3083 | |
3084 y++; /* Horizontal connection to next line */ | |
3085 x = line_len (y); | |
3086 if (x == 0) | |
3087 this_point->x = ibw + (font_w / 2); | |
3088 else | |
3089 this_point->x = ibw + (font_w * x); | |
3090 | |
3091 this_point->y = (this_point - 1)->y; | |
3092 } | |
3093 | |
3094 /* Now do the bottom and connect to the top left point. */ | |
3095 this_point->x = ibw + (font_w * (bottom_x + 1)); | |
3096 | |
3097 this_point++; | |
3098 this_point->x = (this_point - 1)->x; | |
3099 this_point->y = ibw + (font_h * (bottom_y + 1)); | |
3100 this_point++; | |
3101 this_point->x = ibw; | |
3102 this_point->y = (this_point - 1)->y; | |
3103 this_point++; | |
3104 this_point->x = pixel_points->x; | |
3105 this_point->y = pixel_points->y; | |
3106 | |
771 | 3107 XDrawLines (x_current_display, f->display.x->window_desc, |
389 | 3108 gc, pixel_points, |
3109 (this_point - pixel_points + 1), CoordModeOrigin); | |
3110 } | |
3111 | |
3112 DEFUN ("x-contour-region", Fx_contour_region, Sx_contour_region, 1, 1, 0, | |
3113 "Highlight the region between point and the character under the mouse\n\ | |
771 | 3114 selected frame.") |
389 | 3115 (event) |
3116 register Lisp_Object event; | |
3117 { | |
3118 register int x0, y0, x1, y1; | |
771 | 3119 register struct frame *f = selected_frame; |
389 | 3120 register int p1, p2; |
3121 | |
3122 CHECK_CONS (event, 0); | |
3123 | |
3124 BLOCK_INPUT; | |
3125 x0 = XINT (Fcar (Fcar (event))); | |
3126 y0 = XINT (Fcar (Fcdr (Fcar (event)))); | |
3127 | |
3128 /* If the mouse is past the end of the line, don't that area. */ | |
3129 /* ReWrite this... */ | |
3130 | |
771 | 3131 x1 = f->cursor_x; |
3132 y1 = f->cursor_y; | |
389 | 3133 |
3134 if (y1 > y0) /* point below mouse */ | |
771 | 3135 outline_region (f, f->display.x->cursor_gc, |
389 | 3136 x0, y0, x1, y1); |
3137 else if (y1 < y0) /* point above mouse */ | |
771 | 3138 outline_region (f, f->display.x->cursor_gc, |
389 | 3139 x1, y1, x0, y0); |
3140 else /* same line: draw horizontal rectangle */ | |
3141 { | |
3142 if (x1 > x0) | |
771 | 3143 x_rectangle (f, f->display.x->cursor_gc, |
389 | 3144 x0, y0, (x1 - x0 + 1), 1); |
3145 else if (x1 < x0) | |
771 | 3146 x_rectangle (f, f->display.x->cursor_gc, |
389 | 3147 x1, y1, (x0 - x1 + 1), 1); |
3148 } | |
3149 | |
3150 XFlush (x_current_display); | |
3151 UNBLOCK_INPUT; | |
3152 | |
3153 return Qnil; | |
3154 } | |
3155 | |
3156 DEFUN ("x-uncontour-region", Fx_uncontour_region, Sx_uncontour_region, 1, 1, 0, | |
3157 "Erase any highlighting of the region between point and the character\n\ | |
771 | 3158 at X, Y on the selected frame.") |
389 | 3159 (event) |
3160 register Lisp_Object event; | |
3161 { | |
3162 register int x0, y0, x1, y1; | |
771 | 3163 register struct frame *f = selected_frame; |
389 | 3164 |
3165 BLOCK_INPUT; | |
3166 x0 = XINT (Fcar (Fcar (event))); | |
3167 y0 = XINT (Fcar (Fcdr (Fcar (event)))); | |
771 | 3168 x1 = f->cursor_x; |
3169 y1 = f->cursor_y; | |
389 | 3170 |
3171 if (y1 > y0) /* point below mouse */ | |
771 | 3172 outline_region (f, f->display.x->reverse_gc, |
389 | 3173 x0, y0, x1, y1); |
3174 else if (y1 < y0) /* point above mouse */ | |
771 | 3175 outline_region (f, f->display.x->reverse_gc, |
389 | 3176 x1, y1, x0, y0); |
3177 else /* same line: draw horizontal rectangle */ | |
3178 { | |
3179 if (x1 > x0) | |
771 | 3180 x_rectangle (f, f->display.x->reverse_gc, |
389 | 3181 x0, y0, (x1 - x0 + 1), 1); |
3182 else if (x1 < x0) | |
771 | 3183 x_rectangle (f, f->display.x->reverse_gc, |
389 | 3184 x1, y1, (x0 - x1 + 1), 1); |
3185 } | |
3186 UNBLOCK_INPUT; | |
3187 | |
3188 return Qnil; | |
3189 } | |
3190 | |
3191 #if 0 | |
3192 int contour_begin_x, contour_begin_y; | |
3193 int contour_end_x, contour_end_y; | |
3194 int contour_npoints; | |
3195 | |
3196 /* Clip the top part of the contour lines down (and including) line Y_POS. | |
3197 If X_POS is in the middle (rather than at the end) of the line, drop | |
3198 down a line at that character. */ | |
3199 | |
3200 static void | |
3201 clip_contour_top (y_pos, x_pos) | |
3202 { | |
3203 register XPoint *begin = contour_lines[y_pos].top_left; | |
3204 register XPoint *end; | |
3205 register int npoints; | |
771 | 3206 register struct display_line *line = selected_frame->phys_lines[y_pos + 1]; |
389 | 3207 |
3208 if (x_pos >= line->len - 1) /* Draw one, straight horizontal line. */ | |
3209 { | |
3210 end = contour_lines[y_pos].top_right; | |
3211 npoints = (end - begin + 1); | |
3212 XDrawLines (x_current_display, contour_window, | |
3213 contour_erase_gc, begin_erase, npoints, CoordModeOrigin); | |
3214 | |
3215 bcopy (end, begin + 1, contour_last_point - end + 1); | |
3216 contour_last_point -= (npoints - 2); | |
3217 XDrawLines (x_current_display, contour_window, | |
3218 contour_erase_gc, begin, 2, CoordModeOrigin); | |
3219 XFlush (x_current_display); | |
3220 | |
3221 /* Now, update contour_lines structure. */ | |
3222 } | |
3223 /* ______. */ | |
3224 else /* |________*/ | |
3225 { | |
3226 register XPoint *p = begin + 1; | |
3227 end = contour_lines[y_pos].bottom_right; | |
3228 npoints = (end - begin + 1); | |
3229 XDrawLines (x_current_display, contour_window, | |
3230 contour_erase_gc, begin_erase, npoints, CoordModeOrigin); | |
3231 | |
3232 p->y = begin->y; | |
3233 p->x = ibw + (font_w * (x_pos + 1)); | |
3234 p++; | |
3235 p->y = begin->y + font_h; | |
3236 p->x = (p - 1)->x; | |
3237 bcopy (end, begin + 3, contour_last_point - end + 1); | |
3238 contour_last_point -= (npoints - 5); | |
3239 XDrawLines (x_current_display, contour_window, | |
3240 contour_erase_gc, begin, 4, CoordModeOrigin); | |
3241 XFlush (x_current_display); | |
3242 | |
3243 /* Now, update contour_lines structure. */ | |
3244 } | |
3245 } | |
3246 | |
3247 /* Erase the top horzontal lines of the contour, and then extend | |
3248 the contour upwards. */ | |
3249 | |
3250 static void | |
3251 extend_contour_top (line) | |
3252 { | |
3253 } | |
3254 | |
3255 static void | |
3256 clip_contour_bottom (x_pos, y_pos) | |
3257 int x_pos, y_pos; | |
3258 { | |
3259 } | |
3260 | |
3261 static void | |
3262 extend_contour_bottom (x_pos, y_pos) | |
3263 { | |
3264 } | |
3265 | |
3266 DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e", | |
3267 "") | |
3268 (event) | |
3269 Lisp_Object event; | |
3270 { | |
771 | 3271 register struct frame *f = selected_frame; |
3272 register int point_x = f->cursor_x; | |
3273 register int point_y = f->cursor_y; | |
389 | 3274 register int mouse_below_point; |
3275 register Lisp_Object obj; | |
3276 register int x_contour_x, x_contour_y; | |
3277 | |
3278 x_contour_x = x_mouse_x; | |
3279 x_contour_y = x_mouse_y; | |
3280 if (x_contour_y > point_y || (x_contour_y == point_y | |
3281 && x_contour_x > point_x)) | |
3282 { | |
3283 mouse_below_point = 1; | |
771 | 3284 outline_region (f, f->display.x->cursor_gc, point_x, point_y, |
389 | 3285 x_contour_x, x_contour_y); |
3286 } | |
3287 else | |
3288 { | |
3289 mouse_below_point = 0; | |
771 | 3290 outline_region (f, f->display.x->cursor_gc, x_contour_x, x_contour_y, |
389 | 3291 point_x, point_y); |
3292 } | |
3293 | |
3294 while (1) | |
3295 { | |
3296 obj = read_char (-1); | |
3297 if (XTYPE (obj) != Lisp_Cons) | |
3298 break; | |
3299 | |
3300 if (mouse_below_point) | |
3301 { | |
3302 if (x_mouse_y <= point_y) /* Flipped. */ | |
3303 { | |
3304 mouse_below_point = 0; | |
3305 | |
771 | 3306 outline_region (f, f->display.x->reverse_gc, point_x, point_y, |
389 | 3307 x_contour_x, x_contour_y); |
771 | 3308 outline_region (f, f->display.x->cursor_gc, x_mouse_x, x_mouse_y, |
389 | 3309 point_x, point_y); |
3310 } | |
3311 else if (x_mouse_y < x_contour_y) /* Bottom clipped. */ | |
3312 { | |
3313 clip_contour_bottom (x_mouse_y); | |
3314 } | |
3315 else if (x_mouse_y > x_contour_y) /* Bottom extended. */ | |
3316 { | |
3317 extend_bottom_contour (x_mouse_y); | |
3318 } | |
3319 | |
3320 x_contour_x = x_mouse_x; | |
3321 x_contour_y = x_mouse_y; | |
3322 } | |
3323 else /* mouse above or same line as point */ | |
3324 { | |
3325 if (x_mouse_y >= point_y) /* Flipped. */ | |
3326 { | |
3327 mouse_below_point = 1; | |
3328 | |
771 | 3329 outline_region (f, f->display.x->reverse_gc, |
389 | 3330 x_contour_x, x_contour_y, point_x, point_y); |
771 | 3331 outline_region (f, f->display.x->cursor_gc, point_x, point_y, |
389 | 3332 x_mouse_x, x_mouse_y); |
3333 } | |
3334 else if (x_mouse_y > x_contour_y) /* Top clipped. */ | |
3335 { | |
3336 clip_contour_top (x_mouse_y); | |
3337 } | |
3338 else if (x_mouse_y < x_contour_y) /* Top extended. */ | |
3339 { | |
3340 extend_contour_top (x_mouse_y); | |
3341 } | |
3342 } | |
3343 } | |
3344 | |
3345 unread_command_char = obj; | |
3346 if (mouse_below_point) | |
3347 { | |
3348 contour_begin_x = point_x; | |
3349 contour_begin_y = point_y; | |
3350 contour_end_x = x_contour_x; | |
3351 contour_end_y = x_contour_y; | |
3352 } | |
3353 else | |
3354 { | |
3355 contour_begin_x = x_contour_x; | |
3356 contour_begin_y = x_contour_y; | |
3357 contour_end_x = point_x; | |
3358 contour_end_y = point_y; | |
3359 } | |
3360 } | |
3361 #endif | |
3362 | |
3363 DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e", | |
3364 "") | |
3365 (event) | |
3366 Lisp_Object event; | |
3367 { | |
3368 register Lisp_Object obj; | |
771 | 3369 struct frame *f = selected_frame; |
389 | 3370 register struct window *w = XWINDOW (selected_window); |
771 | 3371 register GC line_gc = f->display.x->cursor_gc; |
3372 register GC erase_gc = f->display.x->reverse_gc; | |
389 | 3373 #if 0 |
3374 char dash_list[] = {6, 4, 6, 4}; | |
3375 int dashes = 4; | |
3376 XGCValues gc_values; | |
3377 #endif | |
3378 register int previous_y; | |
771 | 3379 register int line = (x_mouse_y + 1) * FONT_HEIGHT (f->display.x->font) |
3380 + f->display.x->internal_border_width; | |
3381 register int left = f->display.x->internal_border_width | |
389 | 3382 + (w->left |
771 | 3383 * FONT_WIDTH (f->display.x->font)); |
389 | 3384 register int right = left + (w->width |
771 | 3385 * FONT_WIDTH (f->display.x->font)) |
3386 - f->display.x->internal_border_width; | |
389 | 3387 |
3388 #if 0 | |
3389 BLOCK_INPUT; | |
771 | 3390 gc_values.foreground = f->display.x->cursor_pixel; |
3391 gc_values.background = f->display.x->background_pixel; | |
389 | 3392 gc_values.line_width = 1; |
3393 gc_values.line_style = LineOnOffDash; | |
3394 gc_values.cap_style = CapRound; | |
3395 gc_values.join_style = JoinRound; | |
3396 | |
771 | 3397 line_gc = XCreateGC (x_current_display, f->display.x->window_desc, |
389 | 3398 GCLineStyle | GCJoinStyle | GCCapStyle |
3399 | GCLineWidth | GCForeground | GCBackground, | |
3400 &gc_values); | |
3401 XSetDashes (x_current_display, line_gc, 0, dash_list, dashes); | |
771 | 3402 gc_values.foreground = f->display.x->background_pixel; |
3403 gc_values.background = f->display.x->foreground_pixel; | |
3404 erase_gc = XCreateGC (x_current_display, f->display.x->window_desc, | |
389 | 3405 GCLineStyle | GCJoinStyle | GCCapStyle |
3406 | GCLineWidth | GCForeground | GCBackground, | |
3407 &gc_values); | |
3408 XSetDashes (x_current_display, erase_gc, 0, dash_list, dashes); | |
3409 #endif | |
3410 | |
3411 while (1) | |
3412 { | |
3413 BLOCK_INPUT; | |
3414 if (x_mouse_y >= XINT (w->top) | |
3415 && x_mouse_y < XINT (w->top) + XINT (w->height) - 1) | |
3416 { | |
3417 previous_y = x_mouse_y; | |
771 | 3418 line = (x_mouse_y + 1) * FONT_HEIGHT (f->display.x->font) |
3419 + f->display.x->internal_border_width; | |
3420 XDrawLine (x_current_display, f->display.x->window_desc, | |
389 | 3421 line_gc, left, line, right, line); |
3422 } | |
3423 XFlushQueue (); | |
3424 UNBLOCK_INPUT; | |
3425 | |
3426 do | |
3427 { | |
3428 obj = read_char (-1); | |
3429 if ((XTYPE (obj) != Lisp_Cons) | |
3430 || (! EQ (Fcar (Fcdr (Fcdr (obj))), | |
3431 intern ("vertical-scroll-bar"))) | |
3432 || x_mouse_grabbed) | |
3433 { | |
3434 BLOCK_INPUT; | |
771 | 3435 XDrawLine (x_current_display, f->display.x->window_desc, |
389 | 3436 erase_gc, left, line, right, line); |
3437 UNBLOCK_INPUT; | |
3438 unread_command_char = obj; | |
3439 #if 0 | |
3440 XFreeGC (x_current_display, line_gc); | |
3441 XFreeGC (x_current_display, erase_gc); | |
3442 #endif | |
3443 return Qnil; | |
3444 } | |
3445 } | |
3446 while (x_mouse_y == previous_y); | |
3447 | |
3448 BLOCK_INPUT; | |
771 | 3449 XDrawLine (x_current_display, f->display.x->window_desc, |
389 | 3450 erase_gc, left, line, right, line); |
3451 UNBLOCK_INPUT; | |
3452 } | |
3453 } | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
642
diff
changeset
|
3454 #endif |
389 | 3455 |
3456 /* Offset in buffer of character under the pointer, or 0. */ | |
3457 int mouse_buffer_offset; | |
3458 | |
3459 #if 0 | |
3460 /* These keep track of the rectangle following the pointer. */ | |
3461 int mouse_track_top, mouse_track_left, mouse_track_width; | |
3462 | |
3463 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0, | |
3464 "Track the pointer.") | |
3465 () | |
3466 { | |
3467 static Cursor current_pointer_shape; | |
771 | 3468 FRAME_PTR f = x_mouse_frame; |
389 | 3469 |
3470 BLOCK_INPUT; | |
771 | 3471 if (EQ (Vmouse_frame_part, Qtext_part) |
3472 && (current_pointer_shape != f->display.x->nontext_cursor)) | |
389 | 3473 { |
3474 unsigned char c; | |
3475 struct buffer *buf; | |
3476 | |
771 | 3477 current_pointer_shape = f->display.x->nontext_cursor; |
389 | 3478 XDefineCursor (x_current_display, |
771 | 3479 f->display.x->window_desc, |
389 | 3480 current_pointer_shape); |
3481 | |
3482 buf = XBUFFER (XWINDOW (Vmouse_window)->buffer); | |
3483 c = *(BUF_CHAR_ADDRESS (buf, mouse_buffer_offset)); | |
3484 } | |
771 | 3485 else if (EQ (Vmouse_frame_part, Qmodeline_part) |
3486 && (current_pointer_shape != f->display.x->modeline_cursor)) | |
389 | 3487 { |
771 | 3488 current_pointer_shape = f->display.x->modeline_cursor; |
389 | 3489 XDefineCursor (x_current_display, |
771 | 3490 f->display.x->window_desc, |
389 | 3491 current_pointer_shape); |
3492 } | |
3493 | |
3494 XFlushQueue (); | |
3495 UNBLOCK_INPUT; | |
3496 } | |
3497 #endif | |
3498 | |
3499 #if 0 | |
3500 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e", | |
3501 "Draw rectangle around character under mouse pointer, if there is one.") | |
3502 (event) | |
3503 Lisp_Object event; | |
3504 { | |
3505 struct window *w = XWINDOW (Vmouse_window); | |
771 | 3506 struct frame *f = XFRAME (WINDOW_FRAME (w)); |
389 | 3507 struct buffer *b = XBUFFER (w->buffer); |
3508 Lisp_Object obj; | |
3509 | |
3510 if (! EQ (Vmouse_window, selected_window)) | |
3511 return Qnil; | |
3512 | |
3513 if (EQ (event, Qnil)) | |
3514 { | |
3515 int x, y; | |
3516 | |
771 | 3517 x_read_mouse_position (selected_frame, &x, &y); |
389 | 3518 } |
3519 | |
3520 BLOCK_INPUT; | |
3521 mouse_track_width = 0; | |
3522 mouse_track_left = mouse_track_top = -1; | |
3523 | |
3524 do | |
3525 { | |
3526 if ((x_mouse_x != mouse_track_left | |
3527 && (x_mouse_x < mouse_track_left | |
3528 || x_mouse_x > (mouse_track_left + mouse_track_width))) | |
3529 || x_mouse_y != mouse_track_top) | |
3530 { | |
3531 int hp = 0; /* Horizontal position */ | |
771 | 3532 int len = FRAME_CURRENT_GLYPHS (f)->used[x_mouse_y]; |
3533 int p = FRAME_CURRENT_GLYPHS (f)->bufp[x_mouse_y]; | |
389 | 3534 int tab_width = XINT (b->tab_width); |
485 | 3535 int ctl_arrow_p = !NILP (b->ctl_arrow); |
389 | 3536 unsigned char c; |
3537 int mode_line_vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1; | |
3538 int in_mode_line = 0; | |
3539 | |
771 | 3540 if (! FRAME_CURRENT_GLYPHS (f)->enable[x_mouse_y]) |
389 | 3541 break; |
3542 | |
3543 /* Erase previous rectangle. */ | |
3544 if (mouse_track_width) | |
3545 { | |
771 | 3546 x_rectangle (f, f->display.x->reverse_gc, |
389 | 3547 mouse_track_left, mouse_track_top, |
3548 mouse_track_width, 1); | |
3549 | |
771 | 3550 if ((mouse_track_left == f->phys_cursor_x |
3551 || mouse_track_left == f->phys_cursor_x - 1) | |
3552 && mouse_track_top == f->phys_cursor_y) | |
389 | 3553 { |
771 | 3554 x_display_cursor (f, 1); |
389 | 3555 } |
3556 } | |
3557 | |
3558 mouse_track_left = x_mouse_x; | |
3559 mouse_track_top = x_mouse_y; | |
3560 mouse_track_width = 0; | |
3561 | |
3562 if (mouse_track_left > len) /* Past the end of line. */ | |
3563 goto draw_or_not; | |
3564 | |
3565 if (mouse_track_top == mode_line_vpos) | |
3566 { | |
3567 in_mode_line = 1; | |
3568 goto draw_or_not; | |
3569 } | |
3570 | |
3571 if (tab_width <= 0 || tab_width > 20) tab_width = 8; | |
3572 do | |
3573 { | |
3574 c = FETCH_CHAR (p); | |
771 | 3575 if (len == f->width && hp == len - 1 && c != '\n') |
389 | 3576 goto draw_or_not; |
3577 | |
3578 switch (c) | |
3579 { | |
3580 case '\t': | |
3581 mouse_track_width = tab_width - (hp % tab_width); | |
3582 p++; | |
3583 hp += mouse_track_width; | |
3584 if (hp > x_mouse_x) | |
3585 { | |
3586 mouse_track_left = hp - mouse_track_width; | |
3587 goto draw_or_not; | |
3588 } | |
3589 continue; | |
3590 | |
3591 case '\n': | |
3592 mouse_track_width = -1; | |
3593 goto draw_or_not; | |
3594 | |
3595 default: | |
3596 if (ctl_arrow_p && (c < 040 || c == 0177)) | |
3597 { | |
3598 if (p > ZV) | |
3599 goto draw_or_not; | |
3600 | |
3601 mouse_track_width = 2; | |
3602 p++; | |
3603 hp +=2; | |
3604 if (hp > x_mouse_x) | |
3605 { | |
3606 mouse_track_left = hp - mouse_track_width; | |
3607 goto draw_or_not; | |
3608 } | |
3609 } | |
3610 else | |
3611 { | |
3612 mouse_track_width = 1; | |
3613 p++; | |
3614 hp++; | |
3615 } | |
3616 continue; | |
3617 } | |
3618 } | |
3619 while (hp <= x_mouse_x); | |
3620 | |
3621 draw_or_not: | |
3622 if (mouse_track_width) /* Over text; use text pointer shape. */ | |
3623 { | |
3624 XDefineCursor (x_current_display, | |
771 | 3625 f->display.x->window_desc, |
3626 f->display.x->text_cursor); | |
3627 x_rectangle (f, f->display.x->cursor_gc, | |
389 | 3628 mouse_track_left, mouse_track_top, |
3629 mouse_track_width, 1); | |
3630 } | |
3631 else if (in_mode_line) | |
3632 XDefineCursor (x_current_display, | |
771 | 3633 f->display.x->window_desc, |
3634 f->display.x->modeline_cursor); | |
389 | 3635 else |
3636 XDefineCursor (x_current_display, | |
771 | 3637 f->display.x->window_desc, |
3638 f->display.x->nontext_cursor); | |
389 | 3639 } |
3640 | |
3641 XFlush (x_current_display); | |
3642 UNBLOCK_INPUT; | |
3643 | |
3644 obj = read_char (-1); | |
3645 BLOCK_INPUT; | |
3646 } | |
3647 while (XTYPE (obj) == Lisp_Cons /* Mouse event */ | |
3648 && EQ (Fcar (Fcdr (Fcdr (obj))), Qnil) /* Not scrollbar */ | |
3649 && EQ (Vmouse_depressed, Qnil) /* Only motion events */ | |
3650 && EQ (Vmouse_window, selected_window) /* In this window */ | |
771 | 3651 && x_mouse_frame); |
389 | 3652 |
3653 unread_command_char = obj; | |
3654 | |
3655 if (mouse_track_width) | |
3656 { | |
771 | 3657 x_rectangle (f, f->display.x->reverse_gc, |
389 | 3658 mouse_track_left, mouse_track_top, |
3659 mouse_track_width, 1); | |
3660 mouse_track_width = 0; | |
771 | 3661 if ((mouse_track_left == f->phys_cursor_x |
3662 || mouse_track_left - 1 == f->phys_cursor_x) | |
3663 && mouse_track_top == f->phys_cursor_y) | |
389 | 3664 { |
771 | 3665 x_display_cursor (f, 1); |
389 | 3666 } |
3667 } | |
3668 XDefineCursor (x_current_display, | |
771 | 3669 f->display.x->window_desc, |
3670 f->display.x->nontext_cursor); | |
389 | 3671 XFlush (x_current_display); |
3672 UNBLOCK_INPUT; | |
3673 | |
3674 return Qnil; | |
3675 } | |
3676 #endif | |
3677 | |
3678 #if 0 | |
3679 #include "glyphs.h" | |
3680 | |
3681 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT | |
771 | 3682 on the frame F at position X, Y. */ |
3683 | |
3684 x_draw_pixmap (f, x, y, image_data, width, height) | |
3685 struct frame *f; | |
389 | 3686 int x, y, width, height; |
3687 char *image_data; | |
3688 { | |
3689 Pixmap image; | |
3690 | |
3691 image = XCreateBitmapFromData (x_current_display, | |
771 | 3692 f->display.x->window_desc, image_data, |
389 | 3693 width, height); |
771 | 3694 XCopyPlane (x_current_display, image, f->display.x->window_desc, |
3695 f->display.x->normal_gc, 0, 0, width, height, x, y); | |
389 | 3696 } |
3697 #endif | |
3698 | |
3699 #if 0 | |
3700 | |
3701 #ifdef HAVE_X11 | |
3702 #define XMouseEvent XEvent | |
3703 #define WhichMouseButton xbutton.button | |
3704 #define MouseWindow xbutton.window | |
3705 #define MouseX xbutton.x | |
3706 #define MouseY xbutton.y | |
3707 #define MouseTime xbutton.time | |
3708 #define ButtonReleased ButtonRelease | |
3709 #define ButtonPressed ButtonPress | |
3710 #else | |
3711 #define XMouseEvent XButtonEvent | |
3712 #define WhichMouseButton detail | |
3713 #define MouseWindow window | |
3714 #define MouseX x | |
3715 #define MouseY y | |
3716 #define MouseTime time | |
3717 #endif /* X11 */ | |
3718 | |
3719 DEFUN ("x-mouse-events", Fx_mouse_events, Sx_mouse_events, 0, 0, 0, | |
3720 "Return number of pending mouse events from X window system.") | |
3721 () | |
3722 { | |
3723 return make_number (queue_event_count (&x_mouse_queue)); | |
3724 } | |
3725 | |
3726 /* Encode the mouse button events in the form expected by the | |
3727 mouse code in Lisp. For X11, this means moving the masks around. */ | |
3728 | |
3729 static int | |
3730 encode_mouse_button (mouse_event) | |
3731 XMouseEvent mouse_event; | |
3732 { | |
3733 register int event_code; | |
3734 register char key_mask; | |
3735 | |
3736 event_code = mouse_event.detail & 3; | |
3737 key_mask = (mouse_event.detail >> 8) & 0xf0; | |
3738 event_code |= key_mask >> 1; | |
3739 if (mouse_event.type == ButtonReleased) event_code |= 0x04; | |
3740 return event_code; | |
3741 } | |
3742 | |
3743 DEFUN ("x-get-mouse-event", Fx_get_mouse_event, Sx_get_mouse_event, | |
3744 0, 1, 0, | |
3745 "Get next mouse event out of mouse event buffer.\n\ | |
3746 Optional ARG non-nil means return nil immediately if no pending event;\n\ | |
3747 otherwise, wait for an event. Returns a four-part list:\n\ | |
771 | 3748 ((X-POS Y-POS) WINDOW FRAME-PART KEYSEQ TIMESTAMP).\n\ |
3749 Normally X-POS and Y-POS are the position of the click on the frame\n\ | |
389 | 3750 (measured in characters and lines), and WINDOW is the window clicked in.\n\ |
3751 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\ | |
771 | 3752 If FRAME-PART is non-nil, the event was on a scrollbar;\n\ |
389 | 3753 then Y-POS is really the total length of the scrollbar, while X-POS is\n\ |
3754 the relative position of the scrollbar's value within that total length,\n\ | |
3755 and a third element OFFSET appears in that list: the height of the thumb-up\n\ | |
3756 area at the top of the scroll bar.\n\ | |
771 | 3757 FRAME-PART is one of the following symbols:\n\ |
389 | 3758 `vertical-scrollbar', `vertical-thumbup', `vertical-thumbdown',\n\ |
3759 `horizontal-scrollbar', `horizontal-thumbleft', `horizontal-thumbright'.\n\ | |
3760 TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\ | |
3761 the mouse event.") | |
3762 (arg) | |
3763 Lisp_Object arg; | |
3764 { | |
3765 XMouseEvent xrep; | |
3766 register int com_letter; | |
3767 register Lisp_Object tempx; | |
3768 register Lisp_Object tempy; | |
3769 Lisp_Object part, pos, timestamp; | |
3770 int prefix; | |
771 | 3771 struct frame *f; |
389 | 3772 |
3773 int tem; | |
3774 | |
3775 while (1) | |
3776 { | |
3777 BLOCK_INPUT; | |
3778 tem = dequeue_event (&xrep, &x_mouse_queue); | |
3779 UNBLOCK_INPUT; | |
3780 | |
3781 if (tem) | |
3782 { | |
3783 switch (xrep.type) | |
3784 { | |
3785 case ButtonPressed: | |
3786 case ButtonReleased: | |
3787 | |
3788 com_letter = encode_mouse_button (xrep); | |
3789 mouse_timestamp = xrep.MouseTime; | |
3790 | |
771 | 3791 if ((f = x_window_to_frame (xrep.MouseWindow)) != 0) |
389 | 3792 { |
771 | 3793 Lisp_Object frame; |
389 | 3794 |
771 | 3795 if (f->display.x->icon_desc == xrep.MouseWindow) |
389 | 3796 { |
771 | 3797 x_make_frame_visible (f); |
389 | 3798 continue; |
3799 } | |
3800 | |
3801 XSET (tempx, Lisp_Int, | |
771 | 3802 min (f->width-1, max (0, (xrep.MouseX - f->display.x->internal_border_width)/FONT_WIDTH (f->display.x->font)))); |
389 | 3803 XSET (tempy, Lisp_Int, |
771 | 3804 min (f->height-1, max (0, (xrep.MouseY - f->display.x->internal_border_width)/FONT_HEIGHT (f->display.x->font)))); |
389 | 3805 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff)); |
771 | 3806 XSET (frame, Lisp_Frame, f); |
389 | 3807 |
3808 pos = Fcons (tempx, Fcons (tempy, Qnil)); | |
3809 Vmouse_window | |
771 | 3810 = Flocate_window_from_coordinates (frame, pos); |
389 | 3811 |
3812 Vmouse_event | |
3813 = Fcons (pos, | |
3814 Fcons (Vmouse_window, | |
3815 Fcons (Qnil, | |
3816 Fcons (Fchar_to_string (make_number (com_letter)), | |
3817 Fcons (timestamp, Qnil))))); | |
3818 return Vmouse_event; | |
3819 } | |
771 | 3820 else if ((f = x_window_to_scrollbar (xrep.MouseWindow, &part, &prefix)) != 0) |
389 | 3821 { |
3822 int pos, len; | |
3823 Lisp_Object keyseq; | |
3824 char *partname; | |
3825 | |
3826 keyseq = concat2 (Fchar_to_string (make_number (prefix)), | |
3827 Fchar_to_string (make_number (com_letter))); | |
3828 | |
771 | 3829 pos = xrep.MouseY - (f->display.x->v_scrollbar_width - 2); |
389 | 3830 XSET (tempx, Lisp_Int, pos); |
771 | 3831 len = ((FONT_HEIGHT (f->display.x->font) * f->height) |
3832 + f->display.x->internal_border_width | |
3833 - (2 * (f->display.x->v_scrollbar_width - 2))); | |
389 | 3834 XSET (tempy, Lisp_Int, len); |
3835 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff)); | |
771 | 3836 Vmouse_window = f->selected_window; |
389 | 3837 Vmouse_event |
3838 = Fcons (Fcons (tempx, Fcons (tempy, | |
771 | 3839 Fcons (make_number (f->display.x->v_scrollbar_width - 2), |
389 | 3840 Qnil))), |
3841 Fcons (Vmouse_window, | |
3842 Fcons (intern (part), | |
3843 Fcons (keyseq, Fcons (timestamp, | |
3844 Qnil))))); | |
3845 return Vmouse_event; | |
3846 } | |
3847 else | |
3848 continue; | |
3849 | |
3850 #ifdef HAVE_X11 | |
3851 case MotionNotify: | |
3852 | |
3853 com_letter = x11_encode_mouse_button (xrep); | |
771 | 3854 if ((f = x_window_to_frame (xrep.MouseWindow)) != 0) |
389 | 3855 { |
771 | 3856 Lisp_Object frame; |
389 | 3857 |
3858 XSET (tempx, Lisp_Int, | |
771 | 3859 min (f->width-1, |
3860 max (0, (xrep.MouseX - f->display.x->internal_border_width) | |
3861 / FONT_WIDTH (f->display.x->font)))); | |
389 | 3862 XSET (tempy, Lisp_Int, |
771 | 3863 min (f->height-1, |
3864 max (0, (xrep.MouseY - f->display.x->internal_border_width) | |
3865 / FONT_HEIGHT (f->display.x->font)))); | |
389 | 3866 |
771 | 3867 XSET (frame, Lisp_Frame, f); |
389 | 3868 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff)); |
3869 | |
3870 pos = Fcons (tempx, Fcons (tempy, Qnil)); | |
3871 Vmouse_window | |
771 | 3872 = Flocate_window_from_coordinates (frame, pos); |
389 | 3873 |
3874 Vmouse_event | |
3875 = Fcons (pos, | |
3876 Fcons (Vmouse_window, | |
3877 Fcons (Qnil, | |
3878 Fcons (Fchar_to_string (make_number (com_letter)), | |
3879 Fcons (timestamp, Qnil))))); | |
3880 return Vmouse_event; | |
3881 } | |
3882 | |
3883 break; | |
3884 #endif /* HAVE_X11 */ | |
3885 | |
3886 default: | |
771 | 3887 if (f = x_window_to_frame (xrep.MouseWindow)) |
3888 Vmouse_window = f->selected_window; | |
3889 else if (f = x_window_to_scrollbar (xrep.MouseWindow, &part, &prefix)) | |
3890 Vmouse_window = f->selected_window; | |
389 | 3891 return Vmouse_event = Qnil; |
3892 } | |
3893 } | |
3894 | |
485 | 3895 if (!NILP (arg)) |
389 | 3896 return Qnil; |
3897 | |
3898 /* Wait till we get another mouse event. */ | |
3899 wait_reading_process_input (0, 0, 2, 0); | |
3900 } | |
3901 } | |
3902 #endif | |
3903 | |
3904 | |
3905 #ifndef HAVE_X11 | |
3906 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer, Sx_store_cut_buffer, | |
3907 1, 1, "sStore text in cut buffer: ", | |
3908 "Store contents of STRING into the cut buffer of the X window system.") | |
3909 (string) | |
3910 register Lisp_Object string; | |
3911 { | |
3912 int mask; | |
3913 | |
3914 CHECK_STRING (string, 1); | |
771 | 3915 if (! FRAME_IS_X (selected_frame)) |
3916 error ("Selected frame does not understand X protocol."); | |
389 | 3917 |
3918 BLOCK_INPUT; | |
3919 XStoreBytes ((char *) XSTRING (string)->data, XSTRING (string)->size); | |
3920 UNBLOCK_INPUT; | |
3921 | |
3922 return Qnil; | |
3923 } | |
3924 | |
3925 DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer, Sx_get_cut_buffer, 0, 0, 0, | |
3926 "Return contents of cut buffer of the X window system, as a string.") | |
3927 () | |
3928 { | |
3929 int len; | |
3930 register Lisp_Object string; | |
3931 int mask; | |
3932 register char *d; | |
3933 | |
3934 BLOCK_INPUT; | |
3935 d = XFetchBytes (&len); | |
3936 string = make_string (d, len); | |
3937 XFree (d); | |
3938 UNBLOCK_INPUT; | |
3939 return string; | |
3940 } | |
3941 #endif /* X10 */ | |
3942 | |
3943 #ifdef HAVE_X11 | |
3944 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0, | |
3945 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\ | |
3946 KEYSYM is a string which conforms to the X keysym definitions found\n\ | |
3947 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\ | |
3948 list of strings specifying modifier keys such as Control_L, which must\n\ | |
3949 also be depressed for NEWSTRING to appear.") | |
3950 (x_keysym, modifiers, newstring) | |
3951 register Lisp_Object x_keysym; | |
3952 register Lisp_Object modifiers; | |
3953 register Lisp_Object newstring; | |
3954 { | |
3955 char *rawstring; | |
642 | 3956 register KeySym keysym; |
3957 KeySym modifier_list[16]; | |
389 | 3958 |
3959 CHECK_STRING (x_keysym, 1); | |
3960 CHECK_STRING (newstring, 3); | |
3961 | |
3962 keysym = XStringToKeysym ((char *) XSTRING (x_keysym)->data); | |
3963 if (keysym == NoSymbol) | |
3964 error ("Keysym does not exist"); | |
3965 | |
485 | 3966 if (NILP (modifiers)) |
389 | 3967 XRebindKeysym (x_current_display, keysym, modifier_list, 0, |
3968 XSTRING (newstring)->data, XSTRING (newstring)->size); | |
3969 else | |
3970 { | |
3971 register Lisp_Object rest, mod; | |
3972 register int i = 0; | |
3973 | |
485 | 3974 for (rest = modifiers; !NILP (rest); rest = Fcdr (rest)) |
389 | 3975 { |
3976 if (i == 16) | |
3977 error ("Can't have more than 16 modifiers"); | |
3978 | |
3979 mod = Fcar (rest); | |
3980 CHECK_STRING (mod, 3); | |
3981 modifier_list[i] = XStringToKeysym ((char *) XSTRING (mod)->data); | |
3982 if (modifier_list[i] == NoSymbol | |
3983 || !IsModifierKey (modifier_list[i])) | |
3984 error ("Element is not a modifier keysym"); | |
3985 i++; | |
3986 } | |
3987 | |
3988 XRebindKeysym (x_current_display, keysym, modifier_list, i, | |
3989 XSTRING (newstring)->data, XSTRING (newstring)->size); | |
3990 } | |
3991 | |
3992 return Qnil; | |
3993 } | |
3994 | |
3995 DEFUN ("x-rebind-keys", Fx_rebind_keys, Sx_rebind_keys, 2, 2, 0, | |
3996 "Rebind KEYCODE to list of strings STRINGS.\n\ | |
3997 STRINGS should be a list of 16 elements, one for each shift combination.\n\ | |
3998 nil as element means don't change.\n\ | |
3999 See the documentation of `x-rebind-key' for more information.") | |
4000 (keycode, strings) | |
4001 register Lisp_Object keycode; | |
4002 register Lisp_Object strings; | |
4003 { | |
4004 register Lisp_Object item; | |
4005 register unsigned char *rawstring; | |
4006 KeySym rawkey, modifier[1]; | |
4007 int strsize; | |
4008 register unsigned i; | |
4009 | |
4010 CHECK_NUMBER (keycode, 1); | |
4011 CHECK_CONS (strings, 2); | |
4012 rawkey = (KeySym) ((unsigned) (XINT (keycode))) & 255; | |
4013 for (i = 0; i <= 15; strings = Fcdr (strings), i++) | |
4014 { | |
4015 item = Fcar (strings); | |
485 | 4016 if (!NILP (item)) |
389 | 4017 { |
4018 CHECK_STRING (item, 2); | |
4019 strsize = XSTRING (item)->size; | |
4020 rawstring = (unsigned char *) xmalloc (strsize); | |
4021 bcopy (XSTRING (item)->data, rawstring, strsize); | |
4022 modifier[1] = 1 << i; | |
4023 XRebindKeysym (x_current_display, rawkey, modifier, 1, | |
4024 rawstring, strsize); | |
4025 } | |
4026 } | |
4027 return Qnil; | |
4028 } | |
4029 #else | |
4030 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0, | |
4031 "Rebind KEYCODE, with shift bits SHIFT-MASK, to new string NEWSTRING.\n\ | |
4032 KEYCODE and SHIFT-MASK should be numbers representing the X keyboard code\n\ | |
4033 and shift mask respectively. NEWSTRING is an arbitrary string of keystrokes.\n\ | |
4034 If SHIFT-MASK is nil, then KEYCODE's key will be bound to NEWSTRING for\n\ | |
4035 all shift combinations.\n\ | |
4036 Shift Lock 1 Shift 2\n\ | |
4037 Meta 4 Control 8\n\ | |
4038 \n\ | |
4039 For values of KEYCODE, see /usr/lib/Xkeymap.txt (remember that the codes\n\ | |
4040 in that file are in octal!)\n\ | |
4041 \n\ | |
4042 NOTE: due to an X bug, this function will not take effect unless one has\n\ | |
4043 a `~/.Xkeymap' file. (See the documentation for the `keycomp' program.)\n\ | |
4044 This problem will be fixed in X version 11.") | |
4045 | |
4046 (keycode, shift_mask, newstring) | |
4047 register Lisp_Object keycode; | |
4048 register Lisp_Object shift_mask; | |
4049 register Lisp_Object newstring; | |
4050 { | |
4051 char *rawstring; | |
4052 int keysym, rawshift; | |
4053 int i, strsize; | |
4054 | |
4055 CHECK_NUMBER (keycode, 1); | |
485 | 4056 if (!NILP (shift_mask)) |
389 | 4057 CHECK_NUMBER (shift_mask, 2); |
4058 CHECK_STRING (newstring, 3); | |
4059 strsize = XSTRING (newstring)->size; | |
4060 rawstring = (char *) xmalloc (strsize); | |
4061 bcopy (XSTRING (newstring)->data, rawstring, strsize); | |
4062 | |
4063 keysym = ((unsigned) (XINT (keycode))) & 255; | |
4064 | |
485 | 4065 if (NILP (shift_mask)) |
389 | 4066 { |
4067 for (i = 0; i <= 15; i++) | |
4068 XRebindCode (keysym, i<<11, rawstring, strsize); | |
4069 } | |
4070 else | |
4071 { | |
4072 rawshift = (((unsigned) (XINT (shift_mask))) & 15) << 11; | |
4073 XRebindCode (keysym, rawshift, rawstring, strsize); | |
4074 } | |
4075 return Qnil; | |
4076 } | |
4077 | |
4078 DEFUN ("x-rebind-keys", Fx_rebind_keys, Sx_rebind_keys, 2, 2, 0, | |
4079 "Rebind KEYCODE to list of strings STRINGS.\n\ | |
4080 STRINGS should be a list of 16 elements, one for each shift combination.\n\ | |
4081 nil as element means don't change.\n\ | |
4082 See the documentation of `x-rebind-key' for more information.") | |
4083 (keycode, strings) | |
4084 register Lisp_Object keycode; | |
4085 register Lisp_Object strings; | |
4086 { | |
4087 register Lisp_Object item; | |
4088 register char *rawstring; | |
4089 KeySym rawkey, modifier[1]; | |
4090 int strsize; | |
4091 register unsigned i; | |
4092 | |
4093 CHECK_NUMBER (keycode, 1); | |
4094 CHECK_CONS (strings, 2); | |
4095 rawkey = (KeySym) ((unsigned) (XINT (keycode))) & 255; | |
4096 for (i = 0; i <= 15; strings = Fcdr (strings), i++) | |
4097 { | |
4098 item = Fcar (strings); | |
485 | 4099 if (!NILP (item)) |
389 | 4100 { |
4101 CHECK_STRING (item, 2); | |
4102 strsize = XSTRING (item)->size; | |
4103 rawstring = (char *) xmalloc (strsize); | |
4104 bcopy (XSTRING (item)->data, rawstring, strsize); | |
4105 XRebindCode (rawkey, i << 11, rawstring, strsize); | |
4106 } | |
4107 } | |
4108 return Qnil; | |
4109 } | |
4110 #endif /* not HAVE_X11 */ | |
4111 | |
4112 #ifdef HAVE_X11 | |
4113 Visual * | |
4114 select_visual (screen, depth) | |
4115 Screen *screen; | |
4116 unsigned int *depth; | |
4117 { | |
4118 Visual *v; | |
4119 XVisualInfo *vinfo, vinfo_template; | |
4120 int n_visuals; | |
4121 | |
4122 v = DefaultVisualOfScreen (screen); | |
4123 vinfo_template.visualid = XVisualIDFromVisual (v); | |
4124 vinfo = XGetVisualInfo (x_current_display, VisualIDMask, &vinfo_template, | |
4125 &n_visuals); | |
4126 if (n_visuals != 1) | |
4127 fatal ("Can't get proper X visual info"); | |
4128 | |
4129 if ((1 << vinfo->depth) == vinfo->colormap_size) | |
4130 *depth = vinfo->depth; | |
4131 else | |
4132 { | |
4133 int i = 0; | |
4134 int n = vinfo->colormap_size - 1; | |
4135 while (n) | |
4136 { | |
4137 n = n >> 1; | |
4138 i++; | |
4139 } | |
4140 *depth = i; | |
4141 } | |
4142 | |
4143 XFree ((char *) vinfo); | |
4144 return v; | |
4145 } | |
4146 #endif /* HAVE_X11 */ | |
4147 | |
4148 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, | |
4149 1, 2, 0, "Open a connection to an X server.\n\ | |
4150 DISPLAY is the name of the display to connect to. Optional second\n\ | |
4151 arg XRM_STRING is a string of resources in xrdb format.") | |
4152 (display, xrm_string) | |
4153 Lisp_Object display, xrm_string; | |
4154 { | |
4155 unsigned int n_planes; | |
4156 register Screen *x_screen; | |
4157 unsigned char *xrm_option; | |
4158 | |
4159 CHECK_STRING (display, 0); | |
4160 if (x_current_display != 0) | |
4161 error ("X server connection is already initialized"); | |
4162 | |
4163 /* This is what opens the connection and sets x_current_display. | |
4164 This also initializes many symbols, such as those used for input. */ | |
4165 x_term_init (XSTRING (display)->data); | |
4166 | |
4167 #ifdef HAVE_X11 | |
4168 XFASTINT (Vwindow_system_version) = 11; | |
4169 | |
4170 if (!EQ (xrm_string, Qnil)) | |
4171 { | |
4172 CHECK_STRING (xrm_string, 1); | |
4173 xrm_option = (unsigned char *) XSTRING (xrm_string); | |
4174 } | |
4175 else | |
4176 xrm_option = (unsigned char *) 0; | |
4177 xrdb = x_load_resources (x_current_display, xrm_option, EMACS_CLASS); | |
4178 x_current_display->db = xrdb; | |
4179 | |
4180 x_screen = DefaultScreenOfDisplay (x_current_display); | |
4181 | |
4182 x_screen_count = make_number (ScreenCount (x_current_display)); | |
4183 Vx_vendor = build_string (ServerVendor (x_current_display)); | |
4184 x_release = make_number (VendorRelease (x_current_display)); | |
4185 | |
4186 x_screen_height = make_number (HeightOfScreen (x_screen)); | |
4187 x_screen_height_mm = make_number (HeightMMOfScreen (x_screen)); | |
4188 x_screen_width = make_number (WidthOfScreen (x_screen)); | |
4189 x_screen_width_mm = make_number (WidthMMOfScreen (x_screen)); | |
4190 | |
4191 switch (DoesBackingStore (x_screen)) | |
4192 { | |
4193 case Always: | |
4194 Vx_backing_store = intern ("Always"); | |
4195 break; | |
4196 | |
4197 case WhenMapped: | |
4198 Vx_backing_store = intern ("WhenMapped"); | |
4199 break; | |
4200 | |
4201 case NotUseful: | |
4202 Vx_backing_store = intern ("NotUseful"); | |
4203 break; | |
4204 | |
4205 default: | |
4206 error ("Strange value for BackingStore."); | |
4207 break; | |
4208 } | |
4209 | |
4210 if (DoesSaveUnders (x_screen) == True) | |
4211 x_save_under = Qt; | |
4212 else | |
4213 x_save_under = Qnil; | |
4214 | |
4215 screen_visual = select_visual (x_screen, &n_planes); | |
4216 x_screen_planes = make_number (n_planes); | |
4217 Vx_screen_visual = intern (x_visual_strings [screen_visual->class]); | |
4218 | |
4219 /* X Atoms used by emacs. */ | |
4220 BLOCK_INPUT; | |
4221 Xatom_emacs_selection = XInternAtom (x_current_display, "_EMACS_SELECTION_", | |
4222 False); | |
4223 Xatom_clipboard = XInternAtom (x_current_display, "CLIPBOARD", | |
4224 False); | |
4225 Xatom_clipboard_selection = XInternAtom (x_current_display, "_EMACS_CLIPBOARD_", | |
4226 False); | |
4227 Xatom_wm_change_state = XInternAtom (x_current_display, "WM_CHANGE_STATE", | |
4228 False); | |
4229 Xatom_incremental = XInternAtom (x_current_display, "INCR", | |
4230 False); | |
4231 Xatom_multiple = XInternAtom (x_current_display, "MULTIPLE", | |
4232 False); | |
4233 Xatom_targets = XInternAtom (x_current_display, "TARGETS", | |
4234 False); | |
4235 Xatom_timestamp = XInternAtom (x_current_display, "TIMESTAMP", | |
4236 False); | |
4237 Xatom_delete = XInternAtom (x_current_display, "DELETE", | |
4238 False); | |
4239 Xatom_insert_selection = XInternAtom (x_current_display, "INSERT_SELECTION", | |
4240 False); | |
4241 Xatom_pair = XInternAtom (x_current_display, "XA_ATOM_PAIR", | |
4242 False); | |
4243 Xatom_insert_property = XInternAtom (x_current_display, "INSERT_PROPERTY", | |
4244 False); | |
4245 Xatom_text = XInternAtom (x_current_display, "TEXT", | |
4246 False); | |
641 | 4247 Xatom_wm_protocols = XInternAtom (x_current_display, "WM_PROTOCOLS", |
4248 False); | |
4249 Xatom_wm_take_focus = XInternAtom (x_current_display, "WM_TAKE_FOCUS", | |
4250 False); | |
4251 Xatom_wm_save_yourself = XInternAtom (x_current_display, "WM_SAVE_YOURSELF", | |
4252 False); | |
4253 Xatom_wm_delete_window = XInternAtom (x_current_display, "WM_DELETE_WINDOW", | |
4254 False); | |
4255 Xatom_wm_change_state = XInternAtom (x_current_display, "WM_CHANGE_STATE", | |
4256 False); | |
4257 Xatom_wm_configure_denied = XInternAtom (x_current_display, | |
4258 "WM_CONFIGURE_DENIED", False); | |
4259 Xatom_wm_window_moved = XInternAtom (x_current_display, "WM_MOVED", | |
4260 False); | |
389 | 4261 UNBLOCK_INPUT; |
4262 #else /* not HAVE_X11 */ | |
4263 XFASTINT (Vwindow_system_version) = 10; | |
4264 #endif /* not HAVE_X11 */ | |
4265 return Qnil; | |
4266 } | |
4267 | |
4268 DEFUN ("x-close-current-connection", Fx_close_current_connection, | |
4269 Sx_close_current_connection, | |
4270 0, 0, 0, "Close the connection to the current X server.") | |
4271 () | |
4272 { | |
4273 #ifdef HAVE_X11 | |
4274 /* This is ONLY used when killing emacs; For switching displays | |
4275 we'll have to take care of setting CloseDownMode elsewhere. */ | |
4276 | |
4277 if (x_current_display) | |
4278 { | |
4279 BLOCK_INPUT; | |
4280 XSetCloseDownMode (x_current_display, DestroyAll); | |
4281 XCloseDisplay (x_current_display); | |
4282 } | |
4283 else | |
4284 fatal ("No current X display connection to close\n"); | |
4285 #endif | |
4286 return Qnil; | |
4287 } | |
4288 | |
4289 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, | |
4290 1, 1, 0, "If ON is non-nil, report X errors as soon as the erring request is made.\n\ | |
4291 If ON is nil, allow buffering of requests.\n\ | |
4292 Turning on synchronization prohibits the Xlib routines from buffering\n\ | |
4293 requests and seriously degrades performance, but makes debugging much\n\ | |
4294 easier.") | |
4295 (on) | |
4296 Lisp_Object on; | |
4297 { | |
4298 XSynchronize (x_current_display, !EQ (on, Qnil)); | |
4299 | |
4300 return Qnil; | |
4301 } | |
4302 | |
4303 | |
4304 syms_of_xfns () | |
4305 { | |
4306 init_x_parm_symbols (); | |
4307 | |
4308 /* This is zero if not using X windows. */ | |
4309 x_current_display = 0; | |
4310 | |
4311 Qundefined_color = intern ("undefined-color"); | |
4312 Fput (Qundefined_color, Qerror_conditions, | |
4313 Fcons (Qundefined_color, Fcons (Qerror, Qnil))); | |
4314 Fput (Qundefined_color, Qerror_message, | |
4315 build_string ("Undefined color")); | |
4316 | |
4317 DEFVAR_INT ("mouse-x-position", &x_mouse_x, | |
4318 "The X coordinate of the mouse position, in characters."); | |
4319 x_mouse_x = Qnil; | |
4320 | |
4321 DEFVAR_INT ("mouse-y-position", &x_mouse_y, | |
4322 "The Y coordinate of the mouse position, in characters."); | |
4323 x_mouse_y = Qnil; | |
4324 | |
4325 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset, | |
4326 "The buffer offset of the character under the pointer."); | |
4327 mouse_buffer_offset = Qnil; | |
4328 | |
4329 DEFVAR_INT ("x-pointer-shape", &Vx_pointer_shape, | |
4330 "The shape of the pointer when over text."); | |
4331 Vx_pointer_shape = Qnil; | |
4332 | |
4333 DEFVAR_INT ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape, | |
4334 "The shape of the pointer when not over text."); | |
4335 Vx_nontext_pointer_shape = Qnil; | |
4336 | |
4337 DEFVAR_INT ("x-mode-pointer-shape", &Vx_mode_pointer_shape, | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
642
diff
changeset
|
4338 "The shape of the pointer when over the mode line."); |
389 | 4339 Vx_mode_pointer_shape = Qnil; |
4340 | |
4341 DEFVAR_LISP ("x-bar-cursor", &Vbar_cursor, | |
4342 "*If non-nil, use a vertical bar cursor. Otherwise, use the traditional box."); | |
4343 Vbar_cursor = Qnil; | |
4344 | |
4345 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel, | |
4346 "A string indicating the foreground color of the cursor box."); | |
4347 Vx_cursor_fore_pixel = Qnil; | |
4348 | |
4349 DEFVAR_LISP ("mouse-grabbed", &Vmouse_depressed, | |
4350 "Non-nil if a mouse button is currently depressed."); | |
4351 Vmouse_depressed = Qnil; | |
4352 | |
4353 DEFVAR_INT ("x-screen-count", &x_screen_count, | |
4354 "The number of screens associated with the current display."); | |
4355 DEFVAR_INT ("x-release", &x_release, | |
4356 "The release number of the X server in use."); | |
4357 DEFVAR_LISP ("x-vendor", &Vx_vendor, | |
4358 "The vendor supporting the X server in use."); | |
4359 DEFVAR_INT ("x-screen-height", &x_screen_height, | |
4360 "The height of this X screen in pixels."); | |
4361 DEFVAR_INT ("x-screen-height-mm", &x_screen_height_mm, | |
4362 "The height of this X screen in millimeters."); | |
4363 DEFVAR_INT ("x-screen-width", &x_screen_width, | |
4364 "The width of this X screen in pixels."); | |
4365 DEFVAR_INT ("x-screen-width-mm", &x_screen_width_mm, | |
4366 "The width of this X screen in millimeters."); | |
4367 DEFVAR_LISP ("x-backing-store", &Vx_backing_store, | |
4368 "The backing store capability of this screen.\n\ | |
4369 Values can be the symbols Always, WhenMapped, or NotUseful."); | |
4370 DEFVAR_BOOL ("x-save-under", &x_save_under, | |
4371 "*Non-nil means this X screen supports the SaveUnder feature."); | |
4372 DEFVAR_INT ("x-screen-planes", &x_screen_planes, | |
4373 "The number of planes this monitor supports."); | |
4374 DEFVAR_LISP ("x-screen-visual", &Vx_screen_visual, | |
4375 "The default X visual for this X screen."); | |
4376 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, | |
4377 "t if no X window manager is in use."); | |
4378 | |
4379 #ifdef HAVE_X11 | |
4380 defsubr (&Sx_get_resource); | |
4381 defsubr (&Sx_pixel_width); | |
4382 defsubr (&Sx_pixel_height); | |
689
45401d45581d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
4383 #if 0 |
389 | 4384 defsubr (&Sx_draw_rectangle); |
4385 defsubr (&Sx_erase_rectangle); | |
4386 defsubr (&Sx_contour_region); | |
4387 defsubr (&Sx_uncontour_region); | |
689
45401d45581d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
687
diff
changeset
|
4388 #endif |
389 | 4389 defsubr (&Sx_color_display_p); |
4390 defsubr (&Sx_defined_color); | |
4391 #if 0 | |
4392 defsubr (&Sx_track_pointer); | |
4393 defsubr (&Sx_grab_pointer); | |
4394 defsubr (&Sx_ungrab_pointer); | |
436
6e0a136fca4f
*** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents:
398
diff
changeset
|
4395 #endif |
389 | 4396 #else |
4397 defsubr (&Sx_get_default); | |
4398 defsubr (&Sx_store_cut_buffer); | |
4399 defsubr (&Sx_get_cut_buffer); | |
4400 defsubr (&Sx_set_face); | |
4401 #endif | |
4402 defsubr (&Sx_geometry); | |
771 | 4403 defsubr (&Sx_create_frame); |
4404 defsubr (&Sfocus_frame); | |
4405 defsubr (&Sunfocus_frame); | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
642
diff
changeset
|
4406 #if 0 |
389 | 4407 defsubr (&Sx_horizontal_line); |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
642
diff
changeset
|
4408 #endif |
389 | 4409 defsubr (&Sx_rebind_key); |
4410 defsubr (&Sx_rebind_keys); | |
4411 defsubr (&Sx_open_connection); | |
4412 defsubr (&Sx_close_current_connection); | |
4413 defsubr (&Sx_synchronize); | |
4414 | |
4415 /* This was used in the old event interface which used a separate | |
4416 event queue.*/ | |
4417 #if 0 | |
4418 defsubr (&Sx_mouse_events); | |
4419 defsubr (&Sx_get_mouse_event); | |
4420 #endif | |
4421 } | |
4422 | |
4423 #endif /* HAVE_X_WINDOWS */ |