annotate src/xfns.c @ 26003:f6c190ef2f45

(shell-command, shell-command-on-region): use make-temp-file. (clone-buffer, clone-process, clone-buffer-hook): new functions.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 13 Oct 1999 00:48:17 +0000
parents 3daaee890b1e
children 6a349a18b1ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Functions for the X window system.
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2 Copyright (C) 1989, 92, 93, 94, 95, 96, 1997, 1998, 1999
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3 Free Software Foundation.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 This file is part of GNU Emacs.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 700
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 any later version.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 GNU General Public License for more details.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13867
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13867
diff changeset
20 Boston, MA 02111-1307, USA. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
22 /* Image support (XBM, XPM, PBM, JPEG, TIFF, GIF, PNG, GS). tooltips,
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
23 tool-bars, busy-cursor, file selection dialog added by Gerd
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
24 Moellmann <gerd@gnu.org>. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
25
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 /* Completely rewritten by Richard Stallman. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 /* Rewritten for X11 by Joseph Arceneaux */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
7899
facf6b0e97ff Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 7860
diff changeset
30 #include <signal.h>
facf6b0e97ff Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 7860
diff changeset
31 #include <config.h>
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
32 #include <stdio.h>
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
33 #include <math.h>
7899
facf6b0e97ff Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 7860
diff changeset
34
8091
f40cbe50c74f (XLIB_ILLEGAL_ACCESS): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 8090
diff changeset
35 /* This makes the fields of a Display accessible, in Xlib header files. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
36
8091
f40cbe50c74f (XLIB_ILLEGAL_ACCESS): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 8090
diff changeset
37 #define XLIB_ILLEGAL_ACCESS
f40cbe50c74f (XLIB_ILLEGAL_ACCESS): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 8090
diff changeset
38
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 #include "lisp.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 #include "xterm.h"
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
41 #include "frame.h"
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #include "window.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #include "buffer.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 #include "dispextern.h"
515
0005d4c90c97 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
45 #include "keyboard.h"
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2355
diff changeset
46 #include "blockinput.h"
24412
d11ac02f9d6a Use epaths.h istead of paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 24170
diff changeset
47 #include <epaths.h>
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
48 #include "charset.h"
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
49 #include "fontset.h"
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
50 #include "systime.h"
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
51 #include "termhooks.h"
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 #ifdef HAVE_X_WINDOWS
25451
786ab5197e4b Include <stdlib.h> if available, and declare abort only if not. Include
Andreas Schwab <schwab@suse.de>
parents: 25390
diff changeset
54
786ab5197e4b Include <stdlib.h> if available, and declare abort only if not. Include
Andreas Schwab <schwab@suse.de>
parents: 25390
diff changeset
55 #ifdef STDC_HEADERS
786ab5197e4b Include <stdlib.h> if available, and declare abort only if not. Include
Andreas Schwab <schwab@suse.de>
parents: 25390
diff changeset
56 #include <stdlib.h>
786ab5197e4b Include <stdlib.h> if available, and declare abort only if not. Include
Andreas Schwab <schwab@suse.de>
parents: 25390
diff changeset
57 #else
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 extern void abort ();
25451
786ab5197e4b Include <stdlib.h> if available, and declare abort only if not. Include
Andreas Schwab <schwab@suse.de>
parents: 25390
diff changeset
59 #endif
786ab5197e4b Include <stdlib.h> if available, and declare abort only if not. Include
Andreas Schwab <schwab@suse.de>
parents: 25390
diff changeset
60 #include <ctype.h>
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61
13781
fc1cf507c51b [X11R5_INHIBIT_I18N]: Undef HAVE_X_I18N if X11R5.
Karl Heuer <kwzh@gnu.org>
parents: 13751
diff changeset
62 /* On some systems, the character-composition stuff is broken in X11R5. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
63
13781
fc1cf507c51b [X11R5_INHIBIT_I18N]: Undef HAVE_X_I18N if X11R5.
Karl Heuer <kwzh@gnu.org>
parents: 13751
diff changeset
64 #if defined (HAVE_X11R5) && ! defined (HAVE_X11R6)
fc1cf507c51b [X11R5_INHIBIT_I18N]: Undef HAVE_X_I18N if X11R5.
Karl Heuer <kwzh@gnu.org>
parents: 13751
diff changeset
65 #ifdef X11R5_INHIBIT_I18N
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
66 #define X_I18N_INHIBITED
13781
fc1cf507c51b [X11R5_INHIBIT_I18N]: Undef HAVE_X_I18N if X11R5.
Karl Heuer <kwzh@gnu.org>
parents: 13751
diff changeset
67 #endif
fc1cf507c51b [X11R5_INHIBIT_I18N]: Undef HAVE_X_I18N if X11R5.
Karl Heuer <kwzh@gnu.org>
parents: 13751
diff changeset
68 #endif
fc1cf507c51b [X11R5_INHIBIT_I18N]: Undef HAVE_X_I18N if X11R5.
Karl Heuer <kwzh@gnu.org>
parents: 13751
diff changeset
69
2355
cec8c9490d8a * xfns.c [VMS]: Get the gray_bits from [.bitmaps]gray.xbm.
Jim Blandy <jimb@redhat.com>
parents: 2341
diff changeset
70 #ifndef VMS
3821
8f353c2491d0 * xfns.c: Always #include "bitmaps/gray.xbm"; the bitmaps seem to
Jim Blandy <jimb@redhat.com>
parents: 3692
diff changeset
71 #if 1 /* Used to be #ifdef EMACS_BITMAP_FILES, but this should always work. */
3512
2657b04dd324 [EMACS_BIT_MAPS]: Include gray.xbm from ./bitmaps.
Richard M. Stallman <rms@gnu.org>
parents: 3507
diff changeset
72 #include "bitmaps/gray.xbm"
2657b04dd324 [EMACS_BIT_MAPS]: Include gray.xbm from ./bitmaps.
Richard M. Stallman <rms@gnu.org>
parents: 3507
diff changeset
73 #else
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
74 #include <X11/bitmaps/gray>
3512
2657b04dd324 [EMACS_BIT_MAPS]: Include gray.xbm from ./bitmaps.
Richard M. Stallman <rms@gnu.org>
parents: 3507
diff changeset
75 #endif
2355
cec8c9490d8a * xfns.c [VMS]: Get the gray_bits from [.bitmaps]gray.xbm.
Jim Blandy <jimb@redhat.com>
parents: 2341
diff changeset
76 #else
cec8c9490d8a * xfns.c [VMS]: Get the gray_bits from [.bitmaps]gray.xbm.
Jim Blandy <jimb@redhat.com>
parents: 2341
diff changeset
77 #include "[.bitmaps]gray.xbm"
cec8c9490d8a * xfns.c [VMS]: Get the gray_bits from [.bitmaps]gray.xbm.
Jim Blandy <jimb@redhat.com>
parents: 2341
diff changeset
78 #endif
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
79
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
80 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
81 #include <X11/Shell.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
82
12616
ca170048a679 [USE_MOTIF]: Don't include X11/Xaw/Paned.h, X11/Xaw/Label.h.
Richard M. Stallman <rms@gnu.org>
parents: 12546
diff changeset
83 #ifndef USE_MOTIF
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
84 #include <X11/Xaw/Paned.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
85 #include <X11/Xaw/Label.h>
12616
ca170048a679 [USE_MOTIF]: Don't include X11/Xaw/Paned.h, X11/Xaw/Label.h.
Richard M. Stallman <rms@gnu.org>
parents: 12546
diff changeset
86 #endif /* USE_MOTIF */
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
87
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
88 #ifdef USG
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
89 #undef USG /* ####KLUDGE for Solaris 2.2 and up */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
90 #include <X11/Xos.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
91 #define USG
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
92 #else
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
93 #include <X11/Xos.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
94 #endif
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
95
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
96 #include "widget.h"
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
97
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
98 #include "../lwlib/lwlib.h"
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
99
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
100 #ifdef USE_MOTIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
101 #include <Xm/Xm.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
102 #include <Xm/DialogS.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
103 #include <Xm/FileSB.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
104 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
105
13508
b64345cf1ee9 (HACK_EDITRES): Don't define if NO_EDITRES is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13227
diff changeset
106 /* Do the EDITRES protocol if running X11R5
b64345cf1ee9 (HACK_EDITRES): Don't define if NO_EDITRES is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13227
diff changeset
107 Exception: HP-UX (at least version A.09.05) has X11R5 without EditRes */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
108
13508
b64345cf1ee9 (HACK_EDITRES): Don't define if NO_EDITRES is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13227
diff changeset
109 #if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES)
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
110 #define HACK_EDITRES
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
111 extern void _XEditResCheckMessages ();
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
112 #endif /* R5 + Athena */
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
113
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
114 /* Unique id counter for widgets created by the Lucid Widget Library. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
115
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
116 extern LWLIB_ID widget_id_tick;
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
117
15720
f1549b7501af (Fx_create_frame): Do xlwmenu hack only if USE_LUCID.
Karl Heuer <kwzh@gnu.org>
parents: 15706
diff changeset
118 #ifdef USE_LUCID
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
119 /* This is part of a kludge--see lwlib/xlwmenu.c. */
15706
bf891f379d9f (xlwmenu_default_font): Declare, but don't define.
Karl Heuer <kwzh@gnu.org>
parents: 15704
diff changeset
120 extern XFontStruct *xlwmenu_default_font;
15720
f1549b7501af (Fx_create_frame): Do xlwmenu hack only if USE_LUCID.
Karl Heuer <kwzh@gnu.org>
parents: 15706
diff changeset
121 #endif
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
122
5900
284c0d70a50a (x_set_menu_bar_lines) [USE_X_TOOLKIT]: Dont Call XtDestroyWidget but
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5899
diff changeset
123 extern void free_frame_menubar ();
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
124 extern double atof ();
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
125
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
126 #endif /* USE_X_TOOLKIT */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
127
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 #define min(a,b) ((a) < (b) ? (a) : (b))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 #define max(a,b) ((a) > (b) ? (a) : (b))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
131 #ifdef HAVE_X11R4
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
132 #define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
133 #else
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
134 #define MAXREQUEST(dpy) ((dpy)->max_request_size)
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
135 #endif
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
136
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
137 /* The gray bitmap `bitmaps/gray'. This is done because xterm.c uses
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
138 it, and including `bitmaps/gray' more than once is a problem when
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
139 config.h defines `static' as an empty replacement string. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
140
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
141 int gray_bitmap_width = gray_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
142 int gray_bitmap_height = gray_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
143 unsigned char *gray_bitmap_bits = gray_bits;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
144
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
145 /* The name we're using in resource queries. Most often "emacs". */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
146
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
147 Lisp_Object Vx_resource_name;
3170
647229114f47 * xfns.c: Make resource manager work correctly even when
Jim Blandy <jimb@redhat.com>
parents: 3141
diff changeset
148
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
149 /* The application class we're using in resource queries.
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
150 Normally "Emacs". */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
151
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
152 Lisp_Object Vx_resource_class;
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
153
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
154 /* Non-zero means we're allowed to display a busy cursor. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
155
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
156 int display_busy_cursor_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
157
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 /* The background and shape of the mouse pointer, and shape when not
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
159 over text or in the modeline. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
160
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
162 Lisp_Object Vx_busy_pointer_shape;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
163
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
164 /* The shape when over mouse-sensitive text. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
165
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
166 Lisp_Object Vx_sensitive_text_pointer_shape;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
168 /* Color of chars displayed in cursor box. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
169
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 Lisp_Object Vx_cursor_fore_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
172 /* Nonzero if using X. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
173
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
174 static int x_in_use;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
175
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
176 /* Non nil if no window manager is in use. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
177
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 Lisp_Object Vx_no_window_manager;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
180 /* Search path for bitmap files. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
181
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
182 Lisp_Object Vx_bitmap_file_path;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
183
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
184 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
185
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
186 Lisp_Object Vx_pixel_size_width_font_regexp;
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
187
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
188 /* Evaluate this expression to rebuild the section of syms_of_xfns
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
189 that initializes and staticpros the symbols declared below. Note
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
190 that Emacs 18 has a bug that keeps C-x C-e from being able to
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
191 evaluate this expression.
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
192
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
193 (progn
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
194 ;; Accumulate a list of the symbols we want to initialize from the
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
195 ;; declarations at the top of the file.
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
196 (goto-char (point-min))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
197 (search-forward "/\*&&& symbols declared here &&&*\/\n")
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
198 (let (symbol-list)
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
199 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
200 (setq symbol-list
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
201 (cons (buffer-substring (match-beginning 1) (match-end 1))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
202 symbol-list))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
203 (forward-line 1))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
204 (setq symbol-list (nreverse symbol-list))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
205 ;; Delete the section of syms_of_... where we initialize the symbols.
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
206 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
207 (let ((start (point)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
208 (while (looking-at "^ Q")
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
209 (forward-line 2))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
210 (kill-region start (point)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
211 ;; Write a new symbol initialization section.
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
212 (while symbol-list
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
213 (insert (format " %s = intern (\"" (car symbol-list)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
214 (let ((start (point)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
215 (insert (substring (car symbol-list) 1))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
216 (subst-char-in-region start (point) ?_ ?-))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
217 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
218 (setq symbol-list (cdr symbol-list)))))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
219
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
220 */
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
221
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
222 /*&&& symbols declared here &&&*/
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
223 Lisp_Object Qauto_raise;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
224 Lisp_Object Qauto_lower;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
225 Lisp_Object Qbar;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
226 Lisp_Object Qborder_color;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
227 Lisp_Object Qborder_width;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
228 Lisp_Object Qbox;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
229 Lisp_Object Qcursor_color;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
230 Lisp_Object Qcursor_type;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
231 Lisp_Object Qgeometry;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
232 Lisp_Object Qicon_left;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
233 Lisp_Object Qicon_top;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
234 Lisp_Object Qicon_type;
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
235 Lisp_Object Qicon_name;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
236 Lisp_Object Qinternal_border_width;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
237 Lisp_Object Qleft;
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
238 Lisp_Object Qright;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
239 Lisp_Object Qmouse_color;
1874
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
240 Lisp_Object Qnone;
23793
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
241 Lisp_Object Qouter_window_id;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
242 Lisp_Object Qparent_id;
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
243 Lisp_Object Qscroll_bar_width;
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
244 Lisp_Object Qsuppress_icon;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
245 extern Lisp_Object Qtop;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 Lisp_Object Qundefined_color;
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
247 Lisp_Object Qvertical_scroll_bars;
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
248 Lisp_Object Qvisibility;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
249 Lisp_Object Qwindow_id;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
250 Lisp_Object Qx_frame_parameter;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
251 Lisp_Object Qx_resource_name;
7251
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
252 Lisp_Object Quser_position;
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
253 Lisp_Object Quser_size;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
254 Lisp_Object Qdisplay;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
255 Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
256 Lisp_Object Qscreen_gamma;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
257
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
258 /* The below are defined in frame.c. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
259
1874
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
260 extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
14381
4d038c841cf4 (Qtitle): Declared.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
261 extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
262 extern Lisp_Object Qtool_bar_lines;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
263
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 extern Lisp_Object Vwindow_system_version;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265
18631
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
266 Lisp_Object Qface_set_after_frame_default;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
267
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
269 /* Error if we are not connected to X. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
270
5948
ef777779bd80 (check_x): Make it global.
Karl Heuer <kwzh@gnu.org>
parents: 5900
diff changeset
271 void
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
272 check_x ()
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
273 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
274 if (! x_in_use)
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
275 error ("X windows are not in use or not initialized");
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
276 }
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
277
13867
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
278 /* Nonzero if we can use mouse menus.
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
279 You should not call this unless HAVE_MENUS is defined. */
7791
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
280
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
281 int
13867
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
282 have_menus_p ()
7791
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
283 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
284 return x_in_use;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
285 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
286
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
287 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
288 and checking validity for X. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
289
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
290 FRAME_PTR
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
291 check_x_frame (frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
292 Lisp_Object frame;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
293 {
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
294 FRAME_PTR f;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
295
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
296 if (NILP (frame))
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
297 frame = selected_frame;
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
298 CHECK_LIVE_FRAME (frame, 0);
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
299 f = XFRAME (frame);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
300 if (! FRAME_X_P (f))
13867
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
301 error ("Non-X frame used");
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
302 return f;
7791
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
303 }
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
304
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
305 /* Let the user specify an X display with a frame.
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
306 nil stands for the selected frame--or, if that is not an X frame,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
307 the first X display on the list. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
308
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
309 static struct x_display_info *
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
310 check_x_display_info (frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
311 Lisp_Object frame;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
312 {
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
313 if (NILP (frame))
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
314 {
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
315 struct frame *sf = XFRAME (selected_frame);
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
316
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
317 if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
318 return FRAME_X_DISPLAY_INFO (sf);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
319 else if (x_display_list != 0)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
320 return x_display_list;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
321 else
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
322 error ("X windows are not in use or not initialized");
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
323 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
324 else if (STRINGP (frame))
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
325 return x_display_info_for_name (frame);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
326 else
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
327 {
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
328 FRAME_PTR f;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
329
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
330 CHECK_LIVE_FRAME (frame, 0);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
331 f = XFRAME (frame);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
332 if (! FRAME_X_P (f))
13867
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
333 error ("Non-X frame used");
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
334 return FRAME_X_DISPLAY_INFO (f);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
335 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
336 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
337
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
338
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
339 /* Return the Emacs frame-object corresponding to an X window.
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
340 It could be the frame's main window or an icon window. */
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
341
9948
982820033564 (x_window_to_frame, x_any_window_to_frame, x_top_window_to_frame): Use the new
Karl Heuer <kwzh@gnu.org>
parents: 9813
diff changeset
342 /* This function can be called during GC, so use GC_xxx type test macros. */
2964
a0ff2bc5dd05 (x_window_to_frame): Use XGCTYPE.
Richard M. Stallman <rms@gnu.org>
parents: 2936
diff changeset
343
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
344 struct frame *
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
345 x_window_to_frame (dpyinfo, wdesc)
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
346 struct x_display_info *dpyinfo;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 int wdesc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
349 Lisp_Object tail, frame;
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
350 struct frame *f;
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
351
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
352 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
353 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
354 frame = XCAR (tail);
9948
982820033564 (x_window_to_frame, x_any_window_to_frame, x_top_window_to_frame): Use the new
Karl Heuer <kwzh@gnu.org>
parents: 9813
diff changeset
355 if (!GC_FRAMEP (frame))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 continue;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
357 f = XFRAME (frame);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
358 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
359 continue;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
360 #ifdef USE_X_TOOLKIT
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
361 if ((f->output_data.x->edit_widget
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
362 && XtWindow (f->output_data.x->edit_widget) == wdesc)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
363 /* A tooltip frame? */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
364 || (!f->output_data.x->edit_widget
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
365 && FRAME_X_WINDOW (f) == wdesc)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
366 || f->output_data.x->icon_desc == wdesc)
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
367 return f;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
368 #else /* not USE_X_TOOLKIT */
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
369 if (FRAME_X_WINDOW (f) == wdesc
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
370 || f->output_data.x->icon_desc == wdesc)
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
371 return f;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
372 #endif /* not USE_X_TOOLKIT */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 return 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
377 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
378 /* Like x_window_to_frame but also compares the window with the widget's
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
379 windows. */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
380
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
381 struct frame *
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
382 x_any_window_to_frame (dpyinfo, wdesc)
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
383 struct x_display_info *dpyinfo;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
384 int wdesc;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
385 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
386 Lisp_Object tail, frame;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
387 struct frame *f;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
388 struct x_output *x;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
389
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
390 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
391 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
392 frame = XCAR (tail);
9948
982820033564 (x_window_to_frame, x_any_window_to_frame, x_top_window_to_frame): Use the new
Karl Heuer <kwzh@gnu.org>
parents: 9813
diff changeset
393 if (!GC_FRAMEP (frame))
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
394 continue;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
395 f = XFRAME (frame);
12672
63201a2c1247 Do renamings:
Karl Heuer <kwzh@gnu.org>
parents: 12667
diff changeset
396 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
397 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
398 x = f->output_data.x;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
399 /* This frame matches if the window is any of its widgets. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
400 if (x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
401 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
402 if (wdesc == XtWindow (x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
403 || wdesc == XtWindow (x->column_widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
404 || wdesc == XtWindow (x->edit_widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
405 return f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
406 /* Match if the window is this frame's menubar. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
407 if (lw_window_is_in_menubar (wdesc, x->menubar_widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
408 return f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
409 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
410 else if (FRAME_X_WINDOW (f) == wdesc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
411 /* A tooltip frame. */
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
412 return f;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
413 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
414 return 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
415 }
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
416
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
417 /* Likewise, but exclude the menu bar widget. */
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
418
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
419 struct frame *
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
420 x_non_menubar_window_to_frame (dpyinfo, wdesc)
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
421 struct x_display_info *dpyinfo;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
422 int wdesc;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
423 {
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
424 Lisp_Object tail, frame;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
425 struct frame *f;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
426 struct x_output *x;
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
427
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
428 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
429 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
430 frame = XCAR (tail);
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
431 if (!GC_FRAMEP (frame))
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
432 continue;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
433 f = XFRAME (frame);
12672
63201a2c1247 Do renamings:
Karl Heuer <kwzh@gnu.org>
parents: 12667
diff changeset
434 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
435 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
436 x = f->output_data.x;
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
437 /* This frame matches if the window is any of its widgets. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
438 if (x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
439 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
440 if (wdesc == XtWindow (x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
441 || wdesc == XtWindow (x->column_widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
442 || wdesc == XtWindow (x->edit_widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
443 return f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
444 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
445 else if (FRAME_X_WINDOW (f) == wdesc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
446 /* A tooltip frame. */
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
447 return f;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
448 }
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
449 return 0;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
450 }
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
451
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
452 /* Likewise, but consider only the menu bar widget. */
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
453
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
454 struct frame *
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
455 x_menubar_window_to_frame (dpyinfo, wdesc)
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
456 struct x_display_info *dpyinfo;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
457 int wdesc;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
458 {
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
459 Lisp_Object tail, frame;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
460 struct frame *f;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
461 struct x_output *x;
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
462
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
463 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
464 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
465 frame = XCAR (tail);
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
466 if (!GC_FRAMEP (frame))
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
467 continue;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
468 f = XFRAME (frame);
12672
63201a2c1247 Do renamings:
Karl Heuer <kwzh@gnu.org>
parents: 12667
diff changeset
469 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
470 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
471 x = f->output_data.x;
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
472 /* Match if the window is this frame's menubar. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
473 if (x->menubar_widget
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
474 && lw_window_is_in_menubar (wdesc, x->menubar_widget))
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
475 return f;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
476 }
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
477 return 0;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
478 }
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
479
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
480 /* Return the frame whose principal (outermost) window is WDESC.
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
481 If WDESC is some other (smaller) window, we return 0. */
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
482
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
483 struct frame *
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
484 x_top_window_to_frame (dpyinfo, wdesc)
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
485 struct x_display_info *dpyinfo;
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
486 int wdesc;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
487 {
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
488 Lisp_Object tail, frame;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
489 struct frame *f;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
490 struct x_output *x;
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
491
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
492 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
493 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
494 frame = XCAR (tail);
9948
982820033564 (x_window_to_frame, x_any_window_to_frame, x_top_window_to_frame): Use the new
Karl Heuer <kwzh@gnu.org>
parents: 9813
diff changeset
495 if (!GC_FRAMEP (frame))
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
496 continue;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
497 f = XFRAME (frame);
12672
63201a2c1247 Do renamings:
Karl Heuer <kwzh@gnu.org>
parents: 12667
diff changeset
498 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
499 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
500 x = f->output_data.x;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
501
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
502 if (x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
503 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
504 /* This frame matches if the window is its topmost widget. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
505 if (wdesc == XtWindow (x->widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
506 return f;
12019
63ee64941021 (x_top_window_to_frame): Don't match menu-bar widget.
Karl Heuer <kwzh@gnu.org>
parents: 12011
diff changeset
507 #if 0 /* I don't know why it did this,
63ee64941021 (x_top_window_to_frame): Don't match menu-bar widget.
Karl Heuer <kwzh@gnu.org>
parents: 12011
diff changeset
508 but it seems logically wrong,
63ee64941021 (x_top_window_to_frame): Don't match menu-bar widget.
Karl Heuer <kwzh@gnu.org>
parents: 12011
diff changeset
509 and it causes trouble for MapNotify events. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
510 /* Match if the window is this frame's menubar. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
511 if (x->menubar_widget
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
512 && wdesc == XtWindow (x->menubar_widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
513 return f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
514 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
515 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
516 else if (FRAME_X_WINDOW (f) == wdesc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
517 /* Tooltip frame. */
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
518 return f;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
519 }
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
520 return 0;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
521 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
522 #endif /* USE_X_TOOLKIT */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
523
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
525
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
526 /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
527 id, which is just an int that this section returns. Bitmaps are
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
528 reference counted so they can be shared among frames.
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
529
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
530 Bitmap indices are guaranteed to be > 0, so a negative number can
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
531 be used to indicate no bitmap.
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
532
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
533 If you use x_create_bitmap_from_data, then you must keep track of
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
534 the bitmaps yourself. That is, creating a bitmap from the same
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
535 data more than once will not be caught. */
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
536
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
537
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
538 /* Functions to access the contents of a bitmap, given an id. */
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
539
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
540 int
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
541 x_bitmap_height (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
542 FRAME_PTR f;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
543 int id;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
544 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
545 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].height;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
546 }
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
547
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
548 int
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
549 x_bitmap_width (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
550 FRAME_PTR f;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
551 int id;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
552 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
553 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].width;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
554 }
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
555
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
556 int
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
557 x_bitmap_pixmap (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
558 FRAME_PTR f;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
559 int id;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
560 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
561 return FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
562 }
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
564
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
565 /* Allocate a new bitmap record. Returns index of new record. */
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
566
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
567 static int
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
568 x_allocate_bitmap_record (f)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
569 FRAME_PTR f;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
570 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
571 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
572 int i;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
573
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
574 if (dpyinfo->bitmaps == NULL)
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
575 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
576 dpyinfo->bitmaps_size = 10;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
577 dpyinfo->bitmaps
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
578 = (struct x_bitmap_record *) xmalloc (dpyinfo->bitmaps_size * sizeof (struct x_bitmap_record));
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
579 dpyinfo->bitmaps_last = 1;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
580 return 1;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
581 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
582
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
583 if (dpyinfo->bitmaps_last < dpyinfo->bitmaps_size)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
584 return ++dpyinfo->bitmaps_last;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
585
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
586 for (i = 0; i < dpyinfo->bitmaps_size; ++i)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
587 if (dpyinfo->bitmaps[i].refcount == 0)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
588 return i + 1;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
589
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
590 dpyinfo->bitmaps_size *= 2;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
591 dpyinfo->bitmaps
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
592 = (struct x_bitmap_record *) xrealloc (dpyinfo->bitmaps,
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
593 dpyinfo->bitmaps_size * sizeof (struct x_bitmap_record));
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
594 return ++dpyinfo->bitmaps_last;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
595 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
596
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
597 /* Add one reference to the reference count of the bitmap with id ID. */
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
598
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
599 void
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
600 x_reference_bitmap (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
601 FRAME_PTR f;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
602 int id;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
603 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
604 ++FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].refcount;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
605 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
606
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
607 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS. */
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
608
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
609 int
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
610 x_create_bitmap_from_data (f, bits, width, height)
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
611 struct frame *f;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
612 char *bits;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
613 unsigned int width, height;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
614 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
615 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
616 Pixmap bitmap;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
617 int id;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
618
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
619 bitmap = XCreateBitmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
620 bits, width, height);
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
621
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
622 if (! bitmap)
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
623 return -1;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
624
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
625 id = x_allocate_bitmap_record (f);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
626 dpyinfo->bitmaps[id - 1].pixmap = bitmap;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
627 dpyinfo->bitmaps[id - 1].file = NULL;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
628 dpyinfo->bitmaps[id - 1].refcount = 1;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
629 dpyinfo->bitmaps[id - 1].depth = 1;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
630 dpyinfo->bitmaps[id - 1].height = height;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
631 dpyinfo->bitmaps[id - 1].width = width;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
632
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
633 return id;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
634 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
635
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
636 /* Create bitmap from file FILE for frame F. */
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
637
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
638 int
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
639 x_create_bitmap_from_file (f, file)
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
640 struct frame *f;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
641 Lisp_Object file;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
642 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
643 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
644 unsigned int width, height;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
645 Pixmap bitmap;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
646 int xhot, yhot, result, id;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
647 Lisp_Object found;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
648 int fd;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
649 char *filename;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
650
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
651 /* Look for an existing bitmap with the same name. */
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
652 for (id = 0; id < dpyinfo->bitmaps_last; ++id)
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
653 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
654 if (dpyinfo->bitmaps[id].refcount
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
655 && dpyinfo->bitmaps[id].file
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
656 && !strcmp (dpyinfo->bitmaps[id].file, (char *) XSTRING (file)->data))
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
657 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
658 ++dpyinfo->bitmaps[id].refcount;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
659 return id + 1;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
660 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
661 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
662
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
663 /* Search bitmap-file-path for the file, if appropriate. */
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
664 fd = openp (Vx_bitmap_file_path, file, "", &found, 0);
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
665 if (fd < 0)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
666 return -1;
23141
9676fa7e02bf (x_create_bitmap_from_file): Fail immediately if magic.
Karl Heuer <kwzh@gnu.org>
parents: 23043
diff changeset
667 /* XReadBitmapFile won't handle magic file names. */
9676fa7e02bf (x_create_bitmap_from_file): Fail immediately if magic.
Karl Heuer <kwzh@gnu.org>
parents: 23043
diff changeset
668 if (fd == 0)
9676fa7e02bf (x_create_bitmap_from_file): Fail immediately if magic.
Karl Heuer <kwzh@gnu.org>
parents: 23043
diff changeset
669 return -1;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
670 close (fd);
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
671
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
672 filename = (char *) XSTRING (found)->data;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
673
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
674 result = XReadBitmapFile (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
675 filename, &width, &height, &bitmap, &xhot, &yhot);
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
676 if (result != BitmapSuccess)
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
677 return -1;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
678
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
679 id = x_allocate_bitmap_record (f);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
680 dpyinfo->bitmaps[id - 1].pixmap = bitmap;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
681 dpyinfo->bitmaps[id - 1].refcount = 1;
20629
69d52f3bdb46 (x_create_bitmap_from_file): Use size_byte on strings.
Richard M. Stallman <rms@gnu.org>
parents: 19825
diff changeset
682 dpyinfo->bitmaps[id - 1].file
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
683 = (char *) xmalloc (STRING_BYTES (XSTRING (file)) + 1);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
684 dpyinfo->bitmaps[id - 1].depth = 1;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
685 dpyinfo->bitmaps[id - 1].height = height;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
686 dpyinfo->bitmaps[id - 1].width = width;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
687 strcpy (dpyinfo->bitmaps[id - 1].file, XSTRING (file)->data);
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
688
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
689 return id;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
690 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
691
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
692 /* Remove reference to bitmap with id number ID. */
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
693
21536
468585662fa8 (x_destroy_bitmap): Declare as void, not int.
Karl Heuer <kwzh@gnu.org>
parents: 21267
diff changeset
694 void
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
695 x_destroy_bitmap (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
696 FRAME_PTR f;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
697 int id;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
698 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
699 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
700
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
701 if (id > 0)
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
702 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
703 --dpyinfo->bitmaps[id - 1].refcount;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
704 if (dpyinfo->bitmaps[id - 1].refcount == 0)
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
705 {
12051
f193ce9efe24 (x_destroy_bitmap): Block and unblock input.
Karl Heuer <kwzh@gnu.org>
parents: 12046
diff changeset
706 BLOCK_INPUT;
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
707 XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].pixmap);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
708 if (dpyinfo->bitmaps[id - 1].file)
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
709 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
710 xfree (dpyinfo->bitmaps[id - 1].file);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
711 dpyinfo->bitmaps[id - 1].file = NULL;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
712 }
12051
f193ce9efe24 (x_destroy_bitmap): Block and unblock input.
Karl Heuer <kwzh@gnu.org>
parents: 12046
diff changeset
713 UNBLOCK_INPUT;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
714 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
715 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
716 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
717
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
718 /* Free all the bitmaps for the display specified by DPYINFO. */
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
719
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
720 static void
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
721 x_destroy_all_bitmaps (dpyinfo)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
722 struct x_display_info *dpyinfo;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
723 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
724 int i;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
725 for (i = 0; i < dpyinfo->bitmaps_last; i++)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
726 if (dpyinfo->bitmaps[i].refcount > 0)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
727 {
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
728 XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].pixmap);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
729 if (dpyinfo->bitmaps[i].file)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
730 xfree (dpyinfo->bitmaps[i].file);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
731 }
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
732 dpyinfo->bitmaps_last = 0;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
733 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
734
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
735 /* Connect the frame-parameter names for X frames
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 to the ways of passing the parameter values to the window system.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 The name of a parameter, as a Lisp symbol,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
739 has an `x-frame-parameter' property which is an integer in Lisp
14439
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
740 that is an index in this table. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
742 struct x_frame_parm_table
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 char *name;
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
745 void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
748 void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
749 void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
750 void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
751 void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
752 void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
753 void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
754 void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
755 void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
756 void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
757 void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
758 void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
759 Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
760 void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
761 void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
762 void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
763 void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
764 Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
765 void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
766 void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
767 void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
768 void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
769 void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
770 void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
771 void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
772 Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
773 void x_set_scroll_bar_background P_ ((struct frame *, Lisp_Object,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
774 Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
775 static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
776 Lisp_Object,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
777 Lisp_Object,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
778 char *, char *,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
779 int));
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
780 static void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
782 static struct x_frame_parm_table x_frame_parms[] =
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 {
1874
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
784 "auto-raise", x_set_autoraise,
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
785 "auto-lower", x_set_autolower,
14439
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
786 "background-color", x_set_background_color,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
787 "border-color", x_set_border_color,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
788 "border-width", x_set_border_width,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
789 "cursor-color", x_set_cursor_color,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
790 "cursor-type", x_set_cursor_type,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
791 "font", x_set_font,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
792 "foreground-color", x_set_foreground_color,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
793 "icon-name", x_set_icon_name,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
794 "icon-type", x_set_icon_type,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
795 "internal-border-width", x_set_internal_border_width,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
796 "menu-bar-lines", x_set_menu_bar_lines,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
797 "mouse-color", x_set_mouse_color,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
798 "name", x_explicitly_set_name,
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
799 "scroll-bar-width", x_set_scroll_bar_width,
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
800 "title", x_set_title,
14439
201ccc109ce7 (x_frame_parms): Alphabetize.
Richard M. Stallman <rms@gnu.org>
parents: 14381
diff changeset
801 "unsplittable", x_set_unsplittable,
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
802 "vertical-scroll-bars", x_set_vertical_scroll_bars,
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
803 "visibility", x_set_visibility,
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
804 "tool-bar-lines", x_set_tool_bar_lines,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
805 "scroll-bar-foreground", x_set_scroll_bar_foreground,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
806 "scroll-bar-background", x_set_scroll_bar_background,
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
807 "screen-gamma", x_set_screen_gamma
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
810 /* Attach the `x-frame-parameter' properties to
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 the Lisp symbol names of parameters relevant to X. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812
21846
486ac68ce051 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21779
diff changeset
813 void
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 init_x_parm_symbols ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 int i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
818 for (i = 0; i < sizeof (x_frame_parms) / sizeof (x_frame_parms[0]); i++)
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
819 Fput (intern (x_frame_parms[i].name), Qx_frame_parameter,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 make_number (i));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822
19095
2f58824bf3f6 (x_set_frame_parameters): Heading comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 19026
diff changeset
823 /* Change the parameters of frame F as specified by ALIST.
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
824 If a parameter is not specially recognized, do nothing;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
825 otherwise call the `x_set_...' function for that parameter. */
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
826
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
827 void
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
828 x_set_frame_parameters (f, alist)
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
829 FRAME_PTR f;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
830 Lisp_Object alist;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
831 {
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
832 Lisp_Object tail;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
833
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
834 /* If both of these parameters are present, it's more efficient to
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
835 set them both at once. So we wait until we've looked at the
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
836 entire list before we set them. */
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
837 int width, height;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
838
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
839 /* Same here. */
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
840 Lisp_Object left, top;
3203
1055aa1b7547 * xfns.c (x_set_frame_parameters): Use the first
Jim Blandy <jimb@redhat.com>
parents: 3173
diff changeset
841
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
842 /* Same with these. */
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
843 Lisp_Object icon_left, icon_top;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
844
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
845 /* Record in these vectors all the parms specified. */
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
846 Lisp_Object *parms;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
847 Lisp_Object *values;
25289
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
848 int i, p;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
849 int left_no_change = 0, top_no_change = 0;
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
850 int icon_left_no_change = 0, icon_top_no_change = 0;
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
851
24170
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
852 struct gcpro gcpro1, gcpro2;
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
853
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
854 i = 0;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
855 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
856 i++;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
857
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
858 parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
859 values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
860
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
861 /* Extract parm names and values into those vectors. */
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
862
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
863 i = 0;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
864 for (tail = alist; CONSP (tail); tail = Fcdr (tail))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
865 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
866 Lisp_Object elt;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
867
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
868 elt = Fcar (tail);
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
869 parms[i] = Fcar (elt);
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
870 values[i] = Fcdr (elt);
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
871 i++;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
872 }
24170
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
873 /* TAIL and ALIST are not used again below here. */
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
874 alist = tail = Qnil;
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
875
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
876 GCPRO2 (*parms, *values);
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
877 gcpro1.nvars = i;
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
878 gcpro2.nvars = i;
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
879
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
880 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
881 because their values appear in VALUES and strings are not valid. */
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
882 top = left = Qunbound;
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
883 icon_left = icon_top = Qunbound;
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
884
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
885 /* Provide default values for HEIGHT and WIDTH. */
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
886 if (FRAME_NEW_WIDTH (f))
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
887 width = FRAME_NEW_WIDTH (f);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
888 else
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
889 width = FRAME_WIDTH (f);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
890
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
891 if (FRAME_NEW_HEIGHT (f))
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
892 height = FRAME_NEW_HEIGHT (f);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
893 else
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
894 height = FRAME_HEIGHT (f);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
895
25289
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
896 /* Process foreground_color and background_color before anything else.
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
897 They are independent of other properties, but other properties (e.g.,
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
898 cursor_color) are dependent upon them. */
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
899 for (p = 0; p < i; p++)
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
900 {
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
901 Lisp_Object prop, val;
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
902
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
903 prop = parms[p];
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
904 val = values[p];
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
905 if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color))
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
906 {
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
907 register Lisp_Object param_index, old_value;
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
908
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
909 param_index = Fget (prop, Qx_frame_parameter);
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
910 old_value = get_frame_param (f, prop);
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
911 store_frame_param (f, prop, val);
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
912 if (NATNUMP (param_index)
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
913 && (XFASTINT (param_index)
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
914 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
915 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
916 }
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
917 }
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
918
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
919 /* Now process them in reverse of specified order. */
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
920 for (i--; i >= 0; i--)
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
921 {
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
922 Lisp_Object prop, val;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
923
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
924 prop = parms[i];
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
925 val = values[i];
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
926
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
927 if (EQ (prop, Qwidth) && NUMBERP (val))
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
928 width = XFASTINT (val);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
929 else if (EQ (prop, Qheight) && NUMBERP (val))
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
930 height = XFASTINT (val);
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
931 else if (EQ (prop, Qtop))
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
932 top = val;
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
933 else if (EQ (prop, Qleft))
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
934 left = val;
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
935 else if (EQ (prop, Qicon_top))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
936 icon_top = val;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
937 else if (EQ (prop, Qicon_left))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
938 icon_left = val;
25289
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
939 else if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color))
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
940 /* Processed above. */
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
941 continue;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
942 else
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
943 {
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
944 register Lisp_Object param_index, old_value;
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
945
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
946 param_index = Fget (prop, Qx_frame_parameter);
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
947 old_value = get_frame_param (f, prop);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
948 store_frame_param (f, prop, val);
9956
cc76b76a1ed1 (CHECK_NATNUM): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents: 9948
diff changeset
949 if (NATNUMP (param_index)
cc76b76a1ed1 (CHECK_NATNUM): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents: 9948
diff changeset
950 && (XFASTINT (param_index)
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
951 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
952 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
953 }
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
954 }
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
955
4617
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
956 /* Don't die if just one of these was set. */
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
957 if (EQ (left, Qunbound))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
958 {
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
959 left_no_change = 1;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
960 if (f->output_data.x->left_pos < 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
961 left = Fcons (Qplus, Fcons (make_number (f->output_data.x->left_pos), Qnil));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
962 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
963 XSETINT (left, f->output_data.x->left_pos);
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
964 }
4617
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
965 if (EQ (top, Qunbound))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
966 {
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
967 top_no_change = 1;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
968 if (f->output_data.x->top_pos < 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
969 top = Fcons (Qplus, Fcons (make_number (f->output_data.x->top_pos), Qnil));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
970 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
971 XSETINT (top, f->output_data.x->top_pos);
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
972 }
4617
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
973
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
974 /* If one of the icon positions was not set, preserve or default it. */
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
975 if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
976 {
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
977 icon_left_no_change = 1;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
978 icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
979 if (NILP (icon_left))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
980 XSETINT (icon_left, 0);
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
981 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
982 if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
983 {
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
984 icon_top_no_change = 1;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
985 icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
986 if (NILP (icon_top))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
987 XSETINT (icon_top, 0);
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
988 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
989
11932
f3fb1e5dfde1 (x_set_frame_parameters) Fix typo.
Karl Heuer <kwzh@gnu.org>
parents: 11917
diff changeset
990 /* Don't set these parameters unless they've been explicitly
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
991 specified. The window might be mapped or resized while we're in
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
992 this function, and we don't want to override that unless the lisp
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
993 code has asked for it.
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
994
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
995 Don't set these parameters unless they actually differ from the
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
996 window's current parameters; the window may not actually exist
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
997 yet. */
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
998 {
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
999 Lisp_Object frame;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1000
5107
2a019dd8ed51 (x_set_frame_parameters): Call check_frame_size
Richard M. Stallman <rms@gnu.org>
parents: 4771
diff changeset
1001 check_frame_size (f, &height, &width);
2a019dd8ed51 (x_set_frame_parameters): Call check_frame_size
Richard M. Stallman <rms@gnu.org>
parents: 4771
diff changeset
1002
9285
75f1c0d90b3d (x_set_frame_parameters, x_set_visibility, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9240
diff changeset
1003 XSETFRAME (frame, f);
4617
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
1004
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
1005 if (width != FRAME_WIDTH (f)
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
1006 || height != FRAME_HEIGHT (f)
14965
685888f786d3 (x_set_frame_parameters): Do call Fset_frame_size
Richard M. Stallman <rms@gnu.org>
parents: 14831
diff changeset
1007 || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
1008 Fset_frame_size (frame, make_number (width), make_number (height));
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1009
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1010 if ((!NILP (left) || !NILP (top))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1011 && ! (left_no_change && top_no_change)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1012 && ! (NUMBERP (left) && XINT (left) == f->output_data.x->left_pos
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1013 && NUMBERP (top) && XINT (top) == f->output_data.x->top_pos))
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1014 {
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1015 int leftpos = 0;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1016 int toppos = 0;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1017
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1018 /* Record the signs. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1019 f->output_data.x->size_hint_flags &= ~ (XNegative | YNegative);
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1020 if (EQ (left, Qminus))
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1021 f->output_data.x->size_hint_flags |= XNegative;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1022 else if (INTEGERP (left))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1023 {
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1024 leftpos = XINT (left);
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1025 if (leftpos < 0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1026 f->output_data.x->size_hint_flags |= XNegative;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1027 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1028 else if (CONSP (left) && EQ (XCAR (left), Qminus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1029 && CONSP (XCDR (left))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1030 && INTEGERP (XCAR (XCDR (left))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1031 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1032 leftpos = - XINT (XCAR (XCDR (left)));
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1033 f->output_data.x->size_hint_flags |= XNegative;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1034 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1035 else if (CONSP (left) && EQ (XCAR (left), Qplus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1036 && CONSP (XCDR (left))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1037 && INTEGERP (XCAR (XCDR (left))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1038 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1039 leftpos = XINT (XCAR (XCDR (left)));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1040 }
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1041
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1042 if (EQ (top, Qminus))
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1043 f->output_data.x->size_hint_flags |= YNegative;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1044 else if (INTEGERP (top))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1045 {
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1046 toppos = XINT (top);
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1047 if (toppos < 0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1048 f->output_data.x->size_hint_flags |= YNegative;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1049 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1050 else if (CONSP (top) && EQ (XCAR (top), Qminus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1051 && CONSP (XCDR (top))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1052 && INTEGERP (XCAR (XCDR (top))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1053 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1054 toppos = - XINT (XCAR (XCDR (top)));
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1055 f->output_data.x->size_hint_flags |= YNegative;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1056 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1057 else if (CONSP (top) && EQ (XCAR (top), Qplus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1058 && CONSP (XCDR (top))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1059 && INTEGERP (XCAR (XCDR (top))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1060 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1061 toppos = XINT (XCAR (XCDR (top)));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1062 }
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1063
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1064
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1065 /* Store the numeric value of the position. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1066 f->output_data.x->top_pos = toppos;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1067 f->output_data.x->left_pos = leftpos;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1068
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1069 f->output_data.x->win_gravity = NorthWestGravity;
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1070
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1071 /* Actually set that position, and convert to absolute. */
11989
0deb4505c0f0 (x_set_frame_parameters): Pass -1 to x_set_offset.
Karl Heuer <kwzh@gnu.org>
parents: 11986
diff changeset
1072 x_set_offset (f, leftpos, toppos, -1);
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1073 }
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
1074
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
1075 if ((!NILP (icon_left) || !NILP (icon_top))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
1076 && ! (icon_left_no_change && icon_top_no_change))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
1077 x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1078 }
24170
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
1079
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
1080 UNGCPRO;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1081 }
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1082
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1083 /* Store the screen positions of frame F into XPTR and YPTR.
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1084 These are the positions of the containing window manager window,
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1085 not Emacs's own window. */
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1086
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1087 void
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1088 x_real_positions (f, xptr, yptr)
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1089 FRAME_PTR f;
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1090 int *xptr, *yptr;
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1091 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1092 int win_x, win_y;
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1093 Window child;
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1094
7946
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1095 /* This is pretty gross, but seems to be the easiest way out of
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1096 the problem that arises when restarting window-managers. */
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1097
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1098 #ifdef USE_X_TOOLKIT
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1099 Window outer = (f->output_data.x->widget
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1100 ? XtWindow (f->output_data.x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1101 : FRAME_X_WINDOW (f));
7946
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1102 #else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1103 Window outer = f->output_data.x->window_desc;
7946
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1104 #endif
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1105 Window tmp_root_window;
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1106 Window *tmp_children;
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1107 int tmp_nchildren;
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1108
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1109 while (1)
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1110 {
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1111 int count = x_catch_errors (FRAME_X_DISPLAY (f));
17954
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1112 Window outer_window;
12111
832023e90d4d (x_real_positions): Uncatch and recatch X errors in the loop.
Karl Heuer <kwzh@gnu.org>
parents: 12094
diff changeset
1113
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1114 XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window,
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1115 &f->output_data.x->parent_desc,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1116 &tmp_children, &tmp_nchildren);
14563
6aa8b322b4d7 (x_real_positions): Cast arg of XFree.
Karl Heuer <kwzh@gnu.org>
parents: 14530
diff changeset
1117 XFree ((char *) tmp_children);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1118
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1119 win_x = win_y = 0;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1120
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1121 /* Find the position of the outside upper-left corner of
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1122 the inner window, with respect to the outer window. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1123 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window)
17954
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1124 outer_window = f->output_data.x->parent_desc;
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1125 else
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1126 outer_window = outer;
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1127
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1128 XTranslateCoordinates (FRAME_X_DISPLAY (f),
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1129
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1130 /* From-window, to-window. */
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1131 outer_window,
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1132 FRAME_X_DISPLAY_INFO (f)->root_window,
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1133
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1134 /* From-position, to-position. */
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1135 0, 0, &win_x, &win_y,
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1136
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1137 /* Child of win. */
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1138 &child);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1139
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1140 /* It is possible for the window returned by the XQueryNotify
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1141 to become invalid by the time we call XTranslateCoordinates.
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1142 That can happen when you restart some window managers.
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1143 If so, we get an error in XTranslateCoordinates.
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1144 Detect that and try the whole thing over. */
9703
85ac0e4030d4 (x_window): Pass new arg f to hack_wm_protocols.
Richard M. Stallman <rms@gnu.org>
parents: 9690
diff changeset
1145 if (! x_had_errors_p (FRAME_X_DISPLAY (f)))
15495
94467271b641 (x_real_positions): Don't call x_uncatch_errors twice.
Richard M. Stallman <rms@gnu.org>
parents: 15081
diff changeset
1146 {
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1147 x_uncatch_errors (FRAME_X_DISPLAY (f), count);
15495
94467271b641 (x_real_positions): Don't call x_uncatch_errors twice.
Richard M. Stallman <rms@gnu.org>
parents: 15081
diff changeset
1148 break;
94467271b641 (x_real_positions): Don't call x_uncatch_errors twice.
Richard M. Stallman <rms@gnu.org>
parents: 15081
diff changeset
1149 }
12111
832023e90d4d (x_real_positions): Uncatch and recatch X errors in the loop.
Karl Heuer <kwzh@gnu.org>
parents: 12094
diff changeset
1150
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1151 x_uncatch_errors (FRAME_X_DISPLAY (f), count);
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1152 }
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1153
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1154 *xptr = win_x;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1155 *yptr = win_y;
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1156 }
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1157
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1158 /* Insert a description of internally-recorded parameters of frame X
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1159 into the parameter alist *ALISTPTR that is to be given to the user.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1160 Only parameters that are specific to the X window system
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1161 and whose values are not correctly recorded in the frame's
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1162 param_alist need to be considered here. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1163
21536
468585662fa8 (x_destroy_bitmap): Declare as void, not int.
Karl Heuer <kwzh@gnu.org>
parents: 21267
diff changeset
1164 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1165 x_report_frame_params (f, alistptr)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1166 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1167 Lisp_Object *alistptr;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1168 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1169 char buf[16];
11986
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1170 Lisp_Object tem;
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1171
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1172 /* Represent negative positions (off the top or left screen edge)
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1173 in a way that Fmodify_frame_parameters will understand correctly. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1174 XSETINT (tem, f->output_data.x->left_pos);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1175 if (f->output_data.x->left_pos >= 0)
11986
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1176 store_in_alist (alistptr, Qleft, tem);
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1177 else
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1178 store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1179
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1180 XSETINT (tem, f->output_data.x->top_pos);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1181 if (f->output_data.x->top_pos >= 0)
11986
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1182 store_in_alist (alistptr, Qtop, tem);
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1183 else
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1184 store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1185
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1186 store_in_alist (alistptr, Qborder_width,
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1187 make_number (f->output_data.x->border_width));
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1188 store_in_alist (alistptr, Qinternal_border_width,
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1189 make_number (f->output_data.x->internal_border_width));
9182
516fdeee89d6 (x_report_frame_params): Fix format/arg mismatch.
Karl Heuer <kwzh@gnu.org>
parents: 9166
diff changeset
1190 sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1191 store_in_alist (alistptr, Qwindow_id,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1192 build_string (buf));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1193 #ifdef USE_X_TOOLKIT
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1194 /* Tooltip frame may not have this widget. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1195 if (f->output_data.x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1196 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1197 sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
23793
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
1198 store_in_alist (alistptr, Qouter_window_id,
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
1199 build_string (buf));
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
1200 store_in_alist (alistptr, Qicon_name, f->icon_name);
6522
eecaa7b19b6c (x_report_frame_params): Sample visibility.
Karl Heuer <kwzh@gnu.org>
parents: 6519
diff changeset
1201 FRAME_SAMPLE_VISIBILITY (f);
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1202 store_in_alist (alistptr, Qvisibility,
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1203 (FRAME_VISIBLE_P (f) ? Qt
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1204 : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
11483
089f81a81ba6 (x_report_frame_params): Report value of `display' parm.
Richard M. Stallman <rms@gnu.org>
parents: 11417
diff changeset
1205 store_in_alist (alistptr, Qdisplay,
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1206 XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element));
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
1207
18612
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1208 if (f->output_data.x->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window)
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1209 tem = Qnil;
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1210 else
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1211 XSETFASTINT (tem, f->output_data.x->parent_desc);
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1212 store_in_alist (alistptr, Qparent_id, tem);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1213 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1214
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1215
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1216
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1217 /* Gamma-correct COLOR on frame F. */
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1218
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1219 void
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1220 gamma_correct (f, color)
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1221 struct frame *f;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1222 XColor *color;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1223 {
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1224 if (f->gamma)
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1225 {
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1226 color->red = pow (color->red / 65535.0, f->gamma) * 65535.0 + 0.5;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1227 color->green = pow (color->green / 65535.0, f->gamma) * 65535.0 + 0.5;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1228 color->blue = pow (color->blue / 65535.0, f->gamma) * 65535.0 + 0.5;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1229 }
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1230 }
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1231
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1232
8675
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
1233 /* Decide if color named COLOR is valid for the display associated with
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
1234 the selected frame; if so, return the rgb values in COLOR_DEF.
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
1235 If ALLOC is nonzero, allocate a new colormap cell. */
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
1236
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1237 int
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1238 defined_color (f, color, color_def, alloc)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1239 FRAME_PTR f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1240 char *color;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1241 XColor *color_def;
8675
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
1242 int alloc;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1243 {
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1244 register int status;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1245 Colormap screen_colormap;
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1246 Display *display = FRAME_X_DISPLAY (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1247
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1248 BLOCK_INPUT;
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1249 screen_colormap = DefaultColormap (display, XDefaultScreen (display));
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1250
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1251 status = XParseColor (display, screen_colormap, color, color_def);
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1252 if (status && alloc)
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1253 {
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1254 /* Apply gamma correction. */
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1255 gamma_correct (f, color_def);
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1256
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1257 status = XAllocColor (display, screen_colormap, color_def);
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1258 if (!status)
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1259 {
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1260 /* If we got to this point, the colormap is full, so we're
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1261 going to try and get the next closest color.
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1262 The algorithm used is a least-squares matching, which is
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1263 what X uses for closest color matching with StaticColor visuals. */
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1264
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1265 XColor *cells;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1266 int no_cells;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1267 int nearest;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1268 long nearest_delta, trial_delta;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1269 int x;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1270
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1271 no_cells = XDisplayCells (display, XDefaultScreen (display));
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1272 cells = (XColor *) alloca (sizeof (XColor) * no_cells);
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1273
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1274 for (x = 0; x < no_cells; x++)
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1275 cells[x].pixel = x;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1276
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1277 XQueryColors (display, screen_colormap, cells, no_cells);
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1278 nearest = 0;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1279 /* I'm assuming CSE so I'm not going to condense this. */
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1280 nearest_delta = ((((color_def->red >> 8) - (cells[0].red >> 8))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1281 * ((color_def->red >> 8) - (cells[0].red >> 8)))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1282 +
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1283 (((color_def->green >> 8) - (cells[0].green >> 8))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1284 * ((color_def->green >> 8) - (cells[0].green >> 8)))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1285 +
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1286 (((color_def->blue >> 8) - (cells[0].blue >> 8))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1287 * ((color_def->blue >> 8) - (cells[0].blue >> 8))));
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1288 for (x = 1; x < no_cells; x++)
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1289 {
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1290 trial_delta = ((((color_def->red >> 8) - (cells[x].red >> 8))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1291 * ((color_def->red >> 8) - (cells[x].red >> 8)))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1292 +
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1293 (((color_def->green >> 8) - (cells[x].green >> 8))
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
1294 * ((color_def->green >> 8) - (cells[x].green >> 8)))
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1295 +
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1296 (((color_def->blue >> 8) - (cells[x].blue >> 8))
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1297 * ((color_def->blue >> 8) - (cells[x].blue >> 8))));
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1298 if (trial_delta < nearest_delta)
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1299 {
14615
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1300 XColor temp;
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1301 temp.red = cells[x].red;
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1302 temp.green = cells[x].green;
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1303 temp.blue = cells[x].blue;
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1304 status = XAllocColor (display, screen_colormap, &temp);
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1305 if (status)
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1306 {
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1307 nearest = x;
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1308 nearest_delta = trial_delta;
1bbe2716bcea (defined_color): When we find a "near" color in the map,
Karl Heuer <kwzh@gnu.org>
parents: 14595
diff changeset
1309 }
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1310 }
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1311 }
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1312 color_def->red = cells[nearest].red;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1313 color_def->green = cells[nearest].green;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1314 color_def->blue = cells[nearest].blue;
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1315 status = XAllocColor (display, screen_colormap, color_def);
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1316 }
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1317 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1318 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1319
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1320 if (status)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 return 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1322 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1323 return 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1324 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1325
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1326 /* Given a string ARG naming a color, compute a pixel value from it
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1327 suitable for screen F.
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1328 If F is not a color screen, return DEF (default) regardless of what
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329 ARG says. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 int
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1332 x_decode_color (f, arg, def)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1333 FRAME_PTR f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1334 Lisp_Object arg;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335 int def;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1336 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1337 XColor cdef;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1338
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1339 CHECK_STRING (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341 if (strcmp (XSTRING (arg)->data, "black") == 0)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1342 return BLACK_PIX_DEFAULT (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343 else if (strcmp (XSTRING (arg)->data, "white") == 0)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1344 return WHITE_PIX_DEFAULT (f);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1345
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1346 if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 return def;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348
11060
0a7048d331e6 (x_decode_color): Don't use cdef if defined_color failed.
Richard M. Stallman <rms@gnu.org>
parents: 11014
diff changeset
1349 /* defined_color is responsible for coping with failures
0a7048d331e6 (x_decode_color): Don't use cdef if defined_color failed.
Richard M. Stallman <rms@gnu.org>
parents: 11014
diff changeset
1350 by looking for a near-miss. */
0a7048d331e6 (x_decode_color): Don't use cdef if defined_color failed.
Richard M. Stallman <rms@gnu.org>
parents: 11014
diff changeset
1351 if (defined_color (f, XSTRING (arg)->data, &cdef, 1))
0a7048d331e6 (x_decode_color): Don't use cdef if defined_color failed.
Richard M. Stallman <rms@gnu.org>
parents: 11014
diff changeset
1352 return cdef.pixel;
0a7048d331e6 (x_decode_color): Don't use cdef if defined_color failed.
Richard M. Stallman <rms@gnu.org>
parents: 11014
diff changeset
1353
13083
16638ebb209f (Fx_create_frame): Set up buffer-predicate slot.
Richard M. Stallman <rms@gnu.org>
parents: 12832
diff changeset
1354 Fsignal (Qerror, Fcons (build_string ("undefined color"),
16638ebb209f (Fx_create_frame): Set up buffer-predicate slot.
Richard M. Stallman <rms@gnu.org>
parents: 12832
diff changeset
1355 Fcons (arg, Qnil)));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1358 /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1359 the previous value of that parameter, NEW_VALUE is the new value. */
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1360
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1361 static void
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1362 x_set_screen_gamma (f, new_value, old_value)
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1363 struct frame *f;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1364 Lisp_Object new_value, old_value;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1365 {
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1366 if (NILP (new_value))
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1367 f->gamma = 0;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1368 else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1369 /* The value 0.4545 is the normal viewing gamma. */
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1370 f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1371 else
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1372 Fsignal (Qerror, Fcons (build_string ("Illegal screen-gamma"),
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1373 Fcons (new_value, Qnil)));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1374
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1375 clear_face_cache (0);
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1376 }
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1377
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1378
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1379 /* Functions called only from `x_set_frame_param'
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1380 to set individual parameters.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1381
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1382 If FRAME_X_WINDOW (f) is 0,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1383 the frame is being created and its X-window does not exist yet.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1384 In that case, just record the parameter's new value
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1385 in the standard place; do not attempt to change the window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1386
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1387 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1388 x_set_foreground_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1389 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1391 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1392 unsigned long pixel
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1393 = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1394
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1395 unload_color (f, f->output_data.x->foreground_pixel);
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1396 f->output_data.x->foreground_pixel = pixel;
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1397
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1398 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1400 BLOCK_INPUT;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1401 XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1402 f->output_data.x->foreground_pixel);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1403 XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1404 f->output_data.x->foreground_pixel);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405 UNBLOCK_INPUT;
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1406 update_face_from_frame_parameter (f, Qforeground_color, arg);
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
1407 if (FRAME_VISIBLE_P (f))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1408 redraw_frame (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1412 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1413 x_set_background_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1414 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1417 unsigned long pixel
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1418 = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1419
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1420 unload_color (f, f->output_data.x->background_pixel);
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1421 f->output_data.x->background_pixel = pixel;
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1422
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1423 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1426 /* The main frame area. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1427 XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1428 f->output_data.x->background_pixel);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1429 XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1430 f->output_data.x->background_pixel);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1431 XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1432 f->output_data.x->background_pixel);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1433 XSetWindowBackground (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1434 f->output_data.x->background_pixel);
7599
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1435 {
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1436 Lisp_Object bar;
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1437 for (bar = FRAME_SCROLL_BARS (f); !NILP (bar);
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1438 bar = XSCROLL_BAR (bar)->next)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1439 XSetWindowBackground (FRAME_X_DISPLAY (f),
7599
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1440 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1441 f->output_data.x->background_pixel);
7599
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1442 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1443 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1445 update_face_from_frame_parameter (f, Qbackground_color, arg);
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1446
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
1447 if (FRAME_VISIBLE_P (f))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1448 redraw_frame (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1449 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1450 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1451
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1452 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1453 x_set_mouse_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1454 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1456 {
6759
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1457 Cursor cursor, nontext_cursor, mode_cursor, cross_cursor;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1458 Cursor busy_cursor;
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1459 int count;
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1460 unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1461 unsigned long mask_color = f->output_data.x->background_pixel;
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1462
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1463 /* Don't let pointers be invisible. */
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1464 if (mask_color == pixel
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1465 && mask_color == f->output_data.x->background_pixel)
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1466 pixel = f->output_data.x->foreground_pixel;
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1467
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1468 unload_color (f, f->output_data.x->mouse_pixel);
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1469 f->output_data.x->mouse_pixel = pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1470
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1471 BLOCK_INPUT;
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1472
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3512
diff changeset
1473 /* It's not okay to crash if the user selects a screwy cursor. */
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1474 count = x_catch_errors (FRAME_X_DISPLAY (f));
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1475
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1476 if (!EQ (Qnil, Vx_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1477 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1478 CHECK_NUMBER (Vx_pointer_shape, 0);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1479 cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XINT (Vx_pointer_shape));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1480 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1481 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1482 cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_xterm);
9703
85ac0e4030d4 (x_window): Pass new arg f to hack_wm_protocols.
Richard M. Stallman <rms@gnu.org>
parents: 9690
diff changeset
1483 x_check_errors (FRAME_X_DISPLAY (f), "bad text pointer cursor: %s");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1484
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1485 if (!EQ (Qnil, Vx_nontext_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1486 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1487 CHECK_NUMBER (Vx_nontext_pointer_shape, 0);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1488 nontext_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1489 XINT (Vx_nontext_pointer_shape));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1490 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1492 nontext_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_left_ptr);
9703
85ac0e4030d4 (x_window): Pass new arg f to hack_wm_protocols.
Richard M. Stallman <rms@gnu.org>
parents: 9690
diff changeset
1493 x_check_errors (FRAME_X_DISPLAY (f), "bad nontext pointer cursor: %s");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1494
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1495 if (!EQ (Qnil, Vx_busy_pointer_shape))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1496 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1497 CHECK_NUMBER (Vx_busy_pointer_shape, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1498 busy_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1499 XINT (Vx_busy_pointer_shape));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1500 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1501 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1502 busy_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_watch);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1503 x_check_errors (FRAME_X_DISPLAY (f), "bad busy pointer cursor: %s");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1504
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1505 x_check_errors (FRAME_X_DISPLAY (f), "bad nontext pointer cursor: %s");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1506 if (!EQ (Qnil, Vx_mode_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1507 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1508 CHECK_NUMBER (Vx_mode_pointer_shape, 0);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1509 mode_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1510 XINT (Vx_mode_pointer_shape));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1511 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1512 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1513 mode_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_xterm);
9703
85ac0e4030d4 (x_window): Pass new arg f to hack_wm_protocols.
Richard M. Stallman <rms@gnu.org>
parents: 9690
diff changeset
1514 x_check_errors (FRAME_X_DISPLAY (f), "bad modeline pointer cursor: %s");
6759
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1515
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1516 if (!EQ (Qnil, Vx_sensitive_text_pointer_shape))
6759
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1517 {
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1518 CHECK_NUMBER (Vx_sensitive_text_pointer_shape, 0);
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1519 cross_cursor
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1520 = XCreateFontCursor (FRAME_X_DISPLAY (f),
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1521 XINT (Vx_sensitive_text_pointer_shape));
6759
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1522 }
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1523 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1524 cross_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_crosshair);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1525
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1526 /* Check and report errors with the above calls. */
9703
85ac0e4030d4 (x_window): Pass new arg f to hack_wm_protocols.
Richard M. Stallman <rms@gnu.org>
parents: 9690
diff changeset
1527 x_check_errors (FRAME_X_DISPLAY (f), "can't set cursor shape: %s");
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1528 x_uncatch_errors (FRAME_X_DISPLAY (f), count);
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1529
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1530 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1531 XColor fore_color, back_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1532
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1533 fore_color.pixel = f->output_data.x->mouse_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1534 back_color.pixel = mask_color;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1535 XQueryColor (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1536 DefaultColormap (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1537 DefaultScreen (FRAME_X_DISPLAY (f))),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1538 &fore_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1539 XQueryColor (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1540 DefaultColormap (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1541 DefaultScreen (FRAME_X_DISPLAY (f))),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1543 XRecolorCursor (FRAME_X_DISPLAY (f), cursor,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1544 &fore_color, &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1545 XRecolorCursor (FRAME_X_DISPLAY (f), nontext_cursor,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1546 &fore_color, &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1547 XRecolorCursor (FRAME_X_DISPLAY (f), mode_cursor,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1548 &fore_color, &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1549 XRecolorCursor (FRAME_X_DISPLAY (f), cross_cursor,
6759
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1550 &fore_color, &back_color);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1551 XRecolorCursor (FRAME_X_DISPLAY (f), busy_cursor,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1552 &fore_color, &back_color);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1553 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1554
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1555 if (FRAME_X_WINDOW (f) != 0)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1556 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1557
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1558 if (cursor != f->output_data.x->text_cursor && f->output_data.x->text_cursor != 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1559 XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->text_cursor);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1560 f->output_data.x->text_cursor = cursor;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1561
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1562 if (nontext_cursor != f->output_data.x->nontext_cursor
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1563 && f->output_data.x->nontext_cursor != 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1564 XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->nontext_cursor);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1565 f->output_data.x->nontext_cursor = nontext_cursor;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1566
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1567 if (busy_cursor != f->output_data.x->busy_cursor
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1568 && f->output_data.x->busy_cursor != 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1569 XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->busy_cursor);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1570 f->output_data.x->busy_cursor = busy_cursor;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1571
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1572 if (mode_cursor != f->output_data.x->modeline_cursor
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1573 && f->output_data.x->modeline_cursor != 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1574 XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->modeline_cursor);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1575 f->output_data.x->modeline_cursor = mode_cursor;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1576
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1577 if (cross_cursor != f->output_data.x->cross_cursor
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1578 && f->output_data.x->cross_cursor != 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1579 XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->cross_cursor);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1580 f->output_data.x->cross_cursor = cross_cursor;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1581
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1582 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1583 UNBLOCK_INPUT;
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1584
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1585 update_face_from_frame_parameter (f, Qmouse_color, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1586 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1587
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1588 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1589 x_set_cursor_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1590 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1593 unsigned long fore_pixel, pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1594
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 if (!EQ (Vx_cursor_fore_pixel, Qnil))
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1596 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1597 WHITE_PIX_DEFAULT (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1599 fore_pixel = f->output_data.x->background_pixel;
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1600 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1601
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1602 /* Make sure that the cursor color differs from the background color. */
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1603 if (pixel == f->output_data.x->background_pixel)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1604 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1605 pixel = f->output_data.x->mouse_pixel;
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1606 if (pixel == fore_pixel)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1607 fore_pixel = f->output_data.x->background_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1608 }
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1609
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1610 unload_color (f, f->output_data.x->cursor_foreground_pixel);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1611 f->output_data.x->cursor_foreground_pixel = fore_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1612
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1613 unload_color (f, f->output_data.x->cursor_pixel);
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1614 f->output_data.x->cursor_pixel = pixel;
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1615
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1616 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618 BLOCK_INPUT;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1619 XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1620 f->output_data.x->cursor_pixel);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1621 XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1622 fore_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1623 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1624
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
1625 if (FRAME_VISIBLE_P (f))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1626 {
15999
0e148af7d4ec (x_set_cursor_color): Use x_update_cursor.
Richard M. Stallman <rms@gnu.org>
parents: 15942
diff changeset
1627 x_update_cursor (f, 0);
0e148af7d4ec (x_set_cursor_color): Use x_update_cursor.
Richard M. Stallman <rms@gnu.org>
parents: 15942
diff changeset
1628 x_update_cursor (f, 1);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1629 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1630 }
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1631
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1632 update_face_from_frame_parameter (f, Qcursor_color, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1633 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1634
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1635 /* Set the border-color of frame F to value described by ARG.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1636 ARG can be a string naming a color.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1637 The border-color is used for the border that is drawn by the X server.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1638 Note that this does not fully take effect if done before
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1639 F has an x-window; it must be redone when the window is created.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641 Note: this is done in two routines because of the way X10 works.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1642
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1643 Note: under X11, this is normally the province of the window manager,
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1644 and so emacs' border colors may be overridden. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1645
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1646 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1647 x_set_border_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1648 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1649 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1650 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1651 int pix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1652
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1653 CHECK_STRING (arg, 0);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1654 pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1655 x_set_border_pixel (f, pix);
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1656 update_face_from_frame_parameter (f, Qborder_color, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1657 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1658
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1659 /* Set the border-color of frame F to pixel value PIX.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1660 Note that this does not fully take effect if done before
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1661 F has an x-window. */
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1662
21536
468585662fa8 (x_destroy_bitmap): Declare as void, not int.
Karl Heuer <kwzh@gnu.org>
parents: 21267
diff changeset
1663 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1664 x_set_border_pixel (f, pix)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1665 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1666 int pix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1667 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1668 unload_color (f, f->output_data.x->border_pixel);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1669 f->output_data.x->border_pixel = pix;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1670
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1671 if (FRAME_X_WINDOW (f) != 0 && f->output_data.x->border_width > 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1672 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1673 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1674 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
11882
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
1675 (unsigned long)pix);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1676 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1677
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
1678 if (FRAME_VISIBLE_P (f))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1679 redraw_frame (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1680 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1682
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1683 void
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1684 x_set_cursor_type (f, arg, oldval)
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1685 FRAME_PTR f;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1686 Lisp_Object arg, oldval;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1687 {
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1688 if (EQ (arg, Qbar))
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1689 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1690 FRAME_DESIRED_CURSOR (f) = BAR_CURSOR;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1691 f->output_data.x->cursor_width = 2;
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1692 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1693 else if (CONSP (arg) && EQ (XCAR (arg), Qbar)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1694 && INTEGERP (XCDR (arg)))
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1695 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1696 FRAME_DESIRED_CURSOR (f) = BAR_CURSOR;
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1697 f->output_data.x->cursor_width = XINT (XCDR (arg));
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1698 }
3134
efdaaa695ad4 (x_set_cursor_type): If arg not recognized, use box cursor.
Richard M. Stallman <rms@gnu.org>
parents: 3108
diff changeset
1699 else
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1700 /* Treat anything unknown as "box cursor".
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1701 It was bad to signal an error; people have trouble fixing
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1702 .Xdefaults with Emacs, when it has something bad in it. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1703 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1704
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1705 /* Make sure the cursor gets redrawn. This is overkill, but how
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1706 often do people change cursor types? */
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1707 update_mode_lines++;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1708 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1709
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1710 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1711 x_set_icon_type (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1712 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1713 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1714 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1715 int result;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1716
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1717 if (STRINGP (arg))
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1718 {
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1719 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1720 return;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1721 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1722 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1723 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1724
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1725 BLOCK_INPUT;
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 436
diff changeset
1726 if (NILP (arg))
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1727 result = x_text_icon (f,
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
1728 (char *) XSTRING ((!NILP (f->icon_name)
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
1729 ? f->icon_name
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1730 : f->name))->data);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1731 else
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1732 result = x_bitmap_icon (f, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1733
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1734 if (result)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1735 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1736 UNBLOCK_INPUT;
9353
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1737 error ("No icon window available");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1738 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1739
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1740 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1741 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1742 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1743
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1744 /* Return non-nil if frame F wants a bitmap icon. */
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1745
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1746 Lisp_Object
9353
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1747 x_icon_type (f)
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1748 FRAME_PTR f;
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1749 {
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1750 Lisp_Object tem;
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1751
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1752 tem = assq_no_quit (Qicon_type, f->param_alist);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1753 if (CONSP (tem))
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1754 return XCDR (tem);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1755 else
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1756 return Qnil;
9353
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1757 }
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1758
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1759 void
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1760 x_set_icon_name (f, arg, oldval)
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1761 struct frame *f;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1762 Lisp_Object arg, oldval;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1763 {
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1764 int result;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1765
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1766 if (STRINGP (arg))
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1767 {
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1768 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1769 return;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1770 }
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1771 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1772 return;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1773
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
1774 f->icon_name = arg;
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1775
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1776 if (f->output_data.x->icon_bitmap != 0)
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1777 return;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1778
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1779 BLOCK_INPUT;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1780
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1781 result = x_text_icon (f,
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
1782 (char *) XSTRING ((!NILP (f->icon_name)
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
1783 ? f->icon_name
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1784 : !NILP (f->title)
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1785 ? f->title
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1786 : f->name))->data);
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1787
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1788 if (result)
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1789 {
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1790 UNBLOCK_INPUT;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1791 error ("No icon window available");
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1792 }
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1793
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1794 XFlush (FRAME_X_DISPLAY (f));
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1795 UNBLOCK_INPUT;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1796 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1797
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1798 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1799 x_set_font (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1800 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1801 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1802 {
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1803 Lisp_Object result;
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1804 Lisp_Object fontset_name;
18631
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
1805 Lisp_Object frame;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1806
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1807 CHECK_STRING (arg, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1808
21555
0927f341e390 (x_set_font): Give 2nd arg nil to Fquery_fontset.
Kenichi Handa <handa@m17n.org>
parents: 21549
diff changeset
1809 fontset_name = Fquery_fontset (arg, Qnil);
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1810
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1811 BLOCK_INPUT;
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1812 result = (STRINGP (fontset_name)
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1813 ? x_new_fontset (f, XSTRING (fontset_name)->data)
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1814 : x_new_font (f, XSTRING (arg)->data));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1815 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1816
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1817 if (EQ (result, Qnil))
13867
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
1818 error ("Font `%s' is not defined", XSTRING (arg)->data);
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1819 else if (EQ (result, Qt))
24589
316c00e8bc62 (x_set_font): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents: 24412
diff changeset
1820 error ("The characters of the given font have varying widths");
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1821 else if (STRINGP (result))
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1822 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1823 store_frame_param (f, Qfont, result);
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1824 recompute_basic_faces (f);
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1825 }
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1826 else
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1827 abort ();
18631
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
1828
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
1829 do_pending_window_change (0);
25153
fc8435c2ae0e (x_set_internal_border_width):
Richard M. Stallman <rms@gnu.org>
parents: 25082
diff changeset
1830
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1831 /* Don't call `face-set-after-frame-default' when faces haven't been
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1832 initialized yet. This is the case when called from
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1833 Fx_create_frame. In that case, the X widget or window doesn't
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1834 exist either, and we can end up in x_report_frame_params with a
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1835 null widget which gives a segfault. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1836 if (FRAME_FACE_CACHE (f))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1837 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1838 XSETFRAME (frame, f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1839 call1 (Qface_set_after_frame_default, frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1840 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1841 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1842
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1844 x_set_border_width (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1845 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1846 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1848 CHECK_NUMBER (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1850 if (XINT (arg) == f->output_data.x->border_width)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1851 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1853 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1854 error ("Cannot change the border width of a window");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1856 f->output_data.x->border_width = XINT (arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1857 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1858
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1859 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1860 x_set_internal_border_width (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1861 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1862 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1863 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1864 int old = f->output_data.x->internal_border_width;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1865
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1866 CHECK_NUMBER (arg, 0);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1867 f->output_data.x->internal_border_width = XINT (arg);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1868 if (f->output_data.x->internal_border_width < 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1869 f->output_data.x->internal_border_width = 0;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1870
16396
4e4cc27b2a2a (x_set_internal_border_width): Only change
Richard M. Stallman <rms@gnu.org>
parents: 16357
diff changeset
1871 #ifdef USE_X_TOOLKIT
16351
ac552926fc7e (x_set_internal_border_width, Fx_create_frame):
Richard M. Stallman <rms@gnu.org>
parents: 16305
diff changeset
1872 if (f->output_data.x->edit_widget)
21536
468585662fa8 (x_destroy_bitmap): Declare as void, not int.
Karl Heuer <kwzh@gnu.org>
parents: 21267
diff changeset
1873 widget_store_internal_border (f->output_data.x->edit_widget);
16396
4e4cc27b2a2a (x_set_internal_border_width): Only change
Richard M. Stallman <rms@gnu.org>
parents: 16357
diff changeset
1874 #endif
16351
ac552926fc7e (x_set_internal_border_width, Fx_create_frame):
Richard M. Stallman <rms@gnu.org>
parents: 16305
diff changeset
1875
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1876 if (f->output_data.x->internal_border_width == old)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1877 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
1879 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1880 {
5899
4e8f26a0f2b7 *** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5721
diff changeset
1881 x_set_window_size (f, 0, f->width, f->height);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1882 SET_FRAME_GARBAGED (f);
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
1883 do_pending_window_change (0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1884 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1885 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1886
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1887 void
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1888 x_set_visibility (f, value, oldval)
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1889 struct frame *f;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1890 Lisp_Object value, oldval;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1891 {
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1892 Lisp_Object frame;
9285
75f1c0d90b3d (x_set_frame_parameters, x_set_visibility, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9240
diff changeset
1893 XSETFRAME (frame, f);
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1894
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1895 if (NILP (value))
5899
4e8f26a0f2b7 *** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5721
diff changeset
1896 Fmake_frame_invisible (frame, Qt);
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
1897 else if (EQ (value, Qicon))
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
1898 Ficonify_frame (frame);
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
1899 else
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1900 Fmake_frame_visible (frame);
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1901 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1902
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1903 static void
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1904 x_set_menu_bar_lines_1 (window, n)
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1905 Lisp_Object window;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1906 int n;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1907 {
3477
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1908 struct window *w = XWINDOW (window);
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1909
9329
4e1048594e7f (x_set_menu_bar_lines_1): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9327
diff changeset
1910 XSETFASTINT (w->top, XFASTINT (w->top) + n);
4e1048594e7f (x_set_menu_bar_lines_1): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9327
diff changeset
1911 XSETFASTINT (w->height, XFASTINT (w->height) - n);
3477
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1912
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1913 /* Handle just the top child in a vertical split. */
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1914 if (!NILP (w->vchild))
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1915 x_set_menu_bar_lines_1 (w->vchild, n);
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1916
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1917 /* Adjust all children in a horizontal split. */
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1918 for (window = w->hchild; !NILP (window); window = w->next)
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1919 {
3477
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1920 w = XWINDOW (window);
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1921 x_set_menu_bar_lines_1 (window, n);
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1922 }
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1923 }
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1924
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1925 void
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1926 x_set_menu_bar_lines (f, value, oldval)
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1927 struct frame *f;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1928 Lisp_Object value, oldval;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1929 {
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1930 int nlines;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
1931 #ifndef USE_X_TOOLKIT
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1932 int olines = FRAME_MENU_BAR_LINES (f);
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
1933 #endif
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1934
2880
9a78169e44df * xfns.c (x_set_menu_bar_lines): Minibuffer-only frames can't have
Jim Blandy <jimb@redhat.com>
parents: 2842
diff changeset
1935 /* Right now, menu bars don't work properly in minibuf-only frames;
9a78169e44df * xfns.c (x_set_menu_bar_lines): Minibuffer-only frames can't have
Jim Blandy <jimb@redhat.com>
parents: 2842
diff changeset
1936 most of the commands try to apply themselves to the minibuffer
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1937 frame itself, and get an error because you can't switch buffers
2880
9a78169e44df * xfns.c (x_set_menu_bar_lines): Minibuffer-only frames can't have
Jim Blandy <jimb@redhat.com>
parents: 2842
diff changeset
1938 in or split the minibuffer window. */
2885
cb1709f302e9 (x_set_menu_bar_lines): Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents: 2880
diff changeset
1939 if (FRAME_MINIBUF_ONLY_P (f))
2880
9a78169e44df * xfns.c (x_set_menu_bar_lines): Minibuffer-only frames can't have
Jim Blandy <jimb@redhat.com>
parents: 2842
diff changeset
1940 return;
9a78169e44df * xfns.c (x_set_menu_bar_lines): Minibuffer-only frames can't have
Jim Blandy <jimb@redhat.com>
parents: 2842
diff changeset
1941
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
1942 if (INTEGERP (value))
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1943 nlines = XINT (value);
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1944 else
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1945 nlines = 0;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1946
17556
c0f8f4264f7a (x_set_menu_bar_lines): Increment windows_or_buffers_changed.
Richard M. Stallman <rms@gnu.org>
parents: 17106
diff changeset
1947 /* Make sure we redisplay all windows in this frame. */
c0f8f4264f7a (x_set_menu_bar_lines): Increment windows_or_buffers_changed.
Richard M. Stallman <rms@gnu.org>
parents: 17106
diff changeset
1948 windows_or_buffers_changed++;
c0f8f4264f7a (x_set_menu_bar_lines): Increment windows_or_buffers_changed.
Richard M. Stallman <rms@gnu.org>
parents: 17106
diff changeset
1949
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1950 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1951 FRAME_MENU_BAR_LINES (f) = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1952 if (nlines)
12832
0d750e41c4f2 (x_set_menu_bar_lines) [USE_X_TOOLKIT]: When turning
Richard M. Stallman <rms@gnu.org>
parents: 12773
diff changeset
1953 {
0d750e41c4f2 (x_set_menu_bar_lines) [USE_X_TOOLKIT]: When turning
Richard M. Stallman <rms@gnu.org>
parents: 12773
diff changeset
1954 FRAME_EXTERNAL_MENU_BAR (f) = 1;
13734
714433bead7f (x_set_menu_bar_lines) [USE_X_TOOLKIT]:
Richard M. Stallman <rms@gnu.org>
parents: 13508
diff changeset
1955 if (FRAME_X_P (f) && f->output_data.x->menubar_widget == 0)
12832
0d750e41c4f2 (x_set_menu_bar_lines) [USE_X_TOOLKIT]: When turning
Richard M. Stallman <rms@gnu.org>
parents: 12773
diff changeset
1956 /* Make sure next redisplay shows the menu bar. */
0d750e41c4f2 (x_set_menu_bar_lines) [USE_X_TOOLKIT]: When turning
Richard M. Stallman <rms@gnu.org>
parents: 12773
diff changeset
1957 XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
0d750e41c4f2 (x_set_menu_bar_lines) [USE_X_TOOLKIT]: When turning
Richard M. Stallman <rms@gnu.org>
parents: 12773
diff changeset
1958 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1959 else
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1960 {
5900
284c0d70a50a (x_set_menu_bar_lines) [USE_X_TOOLKIT]: Dont Call XtDestroyWidget but
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5899
diff changeset
1961 if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
284c0d70a50a (x_set_menu_bar_lines) [USE_X_TOOLKIT]: Dont Call XtDestroyWidget but
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5899
diff changeset
1962 free_frame_menubar (f);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1963 FRAME_EXTERNAL_MENU_BAR (f) = 0;
13734
714433bead7f (x_set_menu_bar_lines) [USE_X_TOOLKIT]:
Richard M. Stallman <rms@gnu.org>
parents: 13508
diff changeset
1964 if (FRAME_X_P (f))
714433bead7f (x_set_menu_bar_lines) [USE_X_TOOLKIT]:
Richard M. Stallman <rms@gnu.org>
parents: 13508
diff changeset
1965 f->output_data.x->menubar_widget = 0;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1966 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1967 #else /* not USE_X_TOOLKIT */
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1968 FRAME_MENU_BAR_LINES (f) = nlines;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1969 x_set_menu_bar_lines_1 (f->root_window, nlines - olines);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1970 #endif /* not USE_X_TOOLKIT */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1971 adjust_glyphs (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1972 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1973
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1974
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1975 /* Set the number of lines used for the tool bar of frame F to VALUE.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1976 VALUE not an integer, or < 0 means set the lines to zero. OLDVAL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1977 is the old number of tool bar lines. This function changes the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1978 height of all windows on frame F to match the new tool bar height.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1979 The frame's height doesn't change. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1980
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1981 void
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
1982 x_set_tool_bar_lines (f, value, oldval)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1983 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1984 Lisp_Object value, oldval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1985 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1986 int delta, nlines;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1987
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1988 /* Use VALUE only if an integer >= 0. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1989 if (INTEGERP (value) && XINT (value) >= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1990 nlines = XFASTINT (value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1991 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1992 nlines = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1993
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1994 /* Make sure we redisplay all windows in this frame. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1995 ++windows_or_buffers_changed;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1996
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
1997 delta = nlines - FRAME_TOOL_BAR_LINES (f);
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
1998 FRAME_TOOL_BAR_LINES (f) = nlines;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1999 x_set_menu_bar_lines_1 (FRAME_ROOT_WINDOW (f), delta);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2000 adjust_glyphs (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2001 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2002
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2003
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2004 /* Set the foreground color for scroll bars on frame F to VALUE.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2005 VALUE should be a string, a color name. If it isn't a string or
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2006 isn't a valid color name, do nothing. OLDVAL is the old value of
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2007 the frame parameter. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2008
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2009 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2010 x_set_scroll_bar_foreground (f, value, oldval)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2011 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2012 Lisp_Object value, oldval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2013 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2014 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2015
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2016 if (STRINGP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2017 pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2018 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2019 pixel = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2020
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2021 if (f->output_data.x->scroll_bar_foreground_pixel != -1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2022 unload_color (f, f->output_data.x->scroll_bar_foreground_pixel);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2023
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2024 f->output_data.x->scroll_bar_foreground_pixel = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2025 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2026 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2027 /* Remove all scroll bars because they have wrong colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2028 if (condemn_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2029 (*condemn_scroll_bars_hook) (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2030 if (judge_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2031 (*judge_scroll_bars_hook) (f);
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
2032
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
2033 update_face_from_frame_parameter (f, Qscroll_bar_foreground, value);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2034 redraw_frame (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2035 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2036 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2037
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2038
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2039 /* Set the background color for scroll bars on frame F to VALUE VALUE
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2040 should be a string, a color name. If it isn't a string or isn't a
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2041 valid color name, do nothing. OLDVAL is the old value of the frame
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2042 parameter. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2043
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2044 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2045 x_set_scroll_bar_background (f, value, oldval)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2046 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2047 Lisp_Object value, oldval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2048 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2049 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2050
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2051 if (STRINGP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2052 pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2053 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2054 pixel = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2055
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2056 if (f->output_data.x->scroll_bar_background_pixel != -1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2057 unload_color (f, f->output_data.x->scroll_bar_background_pixel);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2058
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2059 f->output_data.x->scroll_bar_background_pixel = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2060 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2061 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2062 /* Remove all scroll bars because they have wrong colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2063 if (condemn_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2064 (*condemn_scroll_bars_hook) (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2065 if (judge_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2066 (*judge_scroll_bars_hook) (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2067
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
2068 update_face_from_frame_parameter (f, Qscroll_bar_background, value);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2069 redraw_frame (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2070 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2071 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2072
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2073
4650
d81041bb1e3d comment fix
David J. MacKenzie <djm@gnu.org>
parents: 4629
diff changeset
2074 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2075 x_id_name.
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2076
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2077 If EXPLICIT is non-zero, that indicates that lisp code is setting the
4650
d81041bb1e3d comment fix
David J. MacKenzie <djm@gnu.org>
parents: 4629
diff changeset
2078 name; if NAME is a string, set F's name to NAME and set
d81041bb1e3d comment fix
David J. MacKenzie <djm@gnu.org>
parents: 4629
diff changeset
2079 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2080
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2081 If EXPLICIT is zero, that indicates that Emacs redisplay code is
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2082 suggesting a new name, which lisp code should override; if
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2083 F->explicit_name is set, ignore the new name; otherwise, set it. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2084
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2085 void
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2086 x_set_name (f, name, explicit)
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2087 struct frame *f;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2088 Lisp_Object name;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2089 int explicit;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2090 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2091 /* Make sure that requests from lisp code override requests from
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2092 Emacs redisplay code. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2093 if (explicit)
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2094 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2095 /* If we're switching from explicit to implicit, we had better
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2096 update the mode lines and thereby update the title. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2097 if (f->explicit_name && NILP (name))
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2098 update_mode_lines = 1;
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2099
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2100 f->explicit_name = ! NILP (name);
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2101 }
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2102 else if (f->explicit_name)
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2103 return;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2104
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2105 /* If NAME is nil, set the name to the x_id_name. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2106 if (NILP (name))
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
2107 {
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
2108 /* Check for no change needed in this very common case
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
2109 before we do any consing. */
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
2110 if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
2111 XSTRING (f->name)->data))
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
2112 return;
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
2113 name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
2114 }
833
14748faa4f17 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 817
diff changeset
2115 else
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2116 CHECK_STRING (name, 0);
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2117
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2118 /* Don't change the name if it's already NAME. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2119 if (! NILP (Fstring_equal (name, f->name)))
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 708
diff changeset
2120 return;
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 708
diff changeset
2121
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2122 f->name = name;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2123
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2124 /* For setting the frame title, the title parameter should override
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2125 the name parameter. */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2126 if (! NILP (f->title))
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2127 name = f->title;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2128
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2129 if (FRAME_X_WINDOW (f))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2130 {
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 700
diff changeset
2131 BLOCK_INPUT;
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2132 #ifdef HAVE_X11R4
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2133 {
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2134 XTextProperty text, icon;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2135 Lisp_Object icon_name;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2136
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2137 text.value = XSTRING (name)->data;
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2138 text.encoding = XA_STRING;
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2139 text.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2140 text.nitems = STRING_BYTES (XSTRING (name));
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2141
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
2142 icon_name = (!NILP (f->icon_name) ? f->icon_name : name);
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2143
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2144 icon.value = XSTRING (icon_name)->data;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2145 icon.encoding = XA_STRING;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2146 icon.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2147 icon.nitems = STRING_BYTES (XSTRING (icon_name));
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2148 #ifdef USE_X_TOOLKIT
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2149 XSetWMName (FRAME_X_DISPLAY (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2150 XtWindow (f->output_data.x->widget), &text);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2151 XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget),
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2152 &icon);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2153 #else /* not USE_X_TOOLKIT */
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2154 XSetWMName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text);
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2155 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2156 #endif /* not USE_X_TOOLKIT */
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2157 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2158 #else /* not HAVE_X11R4 */
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2159 XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2160 XSTRING (name)->data);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2161 XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
2162 XSTRING (name)->data);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2163 #endif /* not HAVE_X11R4 */
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 700
diff changeset
2164 UNBLOCK_INPUT;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2165 }
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2166 }
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2167
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2168 /* This function should be called when the user's lisp code has
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2169 specified a name for the frame; the name will override any set by the
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2170 redisplay code. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2171 void
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2172 x_explicitly_set_name (f, arg, oldval)
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2173 FRAME_PTR f;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2174 Lisp_Object arg, oldval;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2175 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2176 x_set_name (f, arg, 1);
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2177 }
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2178
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2179 /* This function should be called by Emacs redisplay code to set the
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2180 name; names set this way will never override names set by the user's
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2181 lisp code. */
1125
059624bf9bf0 Declare x_implicitly_set_name to be void.
Jim Blandy <jimb@redhat.com>
parents: 1096
diff changeset
2182 void
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2183 x_implicitly_set_name (f, arg, oldval)
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2184 FRAME_PTR f;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2185 Lisp_Object arg, oldval;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2186 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2187 x_set_name (f, arg, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2188 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2189
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2190 /* Change the title of frame F to NAME.
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2191 If NAME is nil, use the frame name as the title.
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2192
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2193 If EXPLICIT is non-zero, that indicates that lisp code is setting the
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2194 name; if NAME is a string, set F's name to NAME and set
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2195 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2196
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2197 If EXPLICIT is zero, that indicates that Emacs redisplay code is
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2198 suggesting a new name, which lisp code should override; if
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2199 F->explicit_name is set, ignore the new name; otherwise, set it. */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2200
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2201 void
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2202 x_set_title (f, name, old_name)
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2203 struct frame *f;
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2204 Lisp_Object name, old_name;
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2205 {
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2206 /* Don't change the title if it's already NAME. */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2207 if (EQ (name, f->title))
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2208 return;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2209
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2210 update_mode_lines = 1;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2211
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2212 f->title = name;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2213
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2214 if (NILP (name))
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2215 name = f->name;
16732
f52c4fd47f03 (x_set_title): Check data type of NAME.
Richard M. Stallman <rms@gnu.org>
parents: 16682
diff changeset
2216 else
f52c4fd47f03 (x_set_title): Check data type of NAME.
Richard M. Stallman <rms@gnu.org>
parents: 16682
diff changeset
2217 CHECK_STRING (name, 0);
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2218
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2219 if (FRAME_X_WINDOW (f))
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2220 {
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2221 BLOCK_INPUT;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2222 #ifdef HAVE_X11R4
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2223 {
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2224 XTextProperty text, icon;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2225 Lisp_Object icon_name;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2226
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2227 text.value = XSTRING (name)->data;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2228 text.encoding = XA_STRING;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2229 text.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2230 text.nitems = STRING_BYTES (XSTRING (name));
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2231
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2232 icon_name = (!NILP (f->icon_name) ? f->icon_name : name);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2233
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2234 icon.value = XSTRING (icon_name)->data;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2235 icon.encoding = XA_STRING;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2236 icon.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2237 icon.nitems = STRING_BYTES (XSTRING (icon_name));
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2238 #ifdef USE_X_TOOLKIT
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2239 XSetWMName (FRAME_X_DISPLAY (f),
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2240 XtWindow (f->output_data.x->widget), &text);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2241 XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget),
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2242 &icon);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2243 #else /* not USE_X_TOOLKIT */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2244 XSetWMName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2245 XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2246 #endif /* not USE_X_TOOLKIT */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2247 }
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2248 #else /* not HAVE_X11R4 */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2249 XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2250 XSTRING (name)->data);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2251 XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2252 XSTRING (name)->data);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2253 #endif /* not HAVE_X11R4 */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2254 UNBLOCK_INPUT;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2255 }
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2256 }
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2257
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2258 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2259 x_set_autoraise (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2260 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2261 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2262 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2263 f->auto_raise = !EQ (Qnil, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2264 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2265
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2266 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2267 x_set_autolower (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2268 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2269 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2270 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2271 f->auto_lower = !EQ (Qnil, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2272 }
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2273
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2274 void
9580
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2275 x_set_unsplittable (f, arg, oldval)
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2276 struct frame *f;
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2277 Lisp_Object arg, oldval;
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2278 {
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2279 f->no_split = !NILP (arg);
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2280 }
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2281
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2282 void
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
2283 x_set_vertical_scroll_bars (f, arg, oldval)
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2284 struct frame *f;
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2285 Lisp_Object arg, oldval;
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2286 {
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2287 if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2288 || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2289 || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f))
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2290 || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f)))
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2291 {
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2292 FRAME_VERTICAL_SCROLL_BAR_TYPE (f)
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2293 = (NILP (arg)
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2294 ? vertical_scroll_bar_none
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2295 : EQ (Qright, arg)
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2296 ? vertical_scroll_bar_right
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2297 : vertical_scroll_bar_left);
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2298
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2299 /* We set this parameter before creating the X window for the
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2300 frame, so we can get the geometry right from the start.
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2301 However, if the window hasn't been created yet, we shouldn't
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2302 call x_set_window_size. */
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2303 if (FRAME_X_WINDOW (f))
5899
4e8f26a0f2b7 *** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5721
diff changeset
2304 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
2305 do_pending_window_change (0);
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2306 }
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2307 }
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2308
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2309 void
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2310 x_set_scroll_bar_width (f, arg, oldval)
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2311 struct frame *f;
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2312 Lisp_Object arg, oldval;
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2313 {
18594
5ca5ff1c74eb (x_set_scroll_bar_width): By default, use enough
Richard M. Stallman <rms@gnu.org>
parents: 18114
diff changeset
2314 int wid = FONT_WIDTH (f->output_data.x->font);
5ca5ff1c74eb (x_set_scroll_bar_width): By default, use enough
Richard M. Stallman <rms@gnu.org>
parents: 18114
diff changeset
2315
9166
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2316 if (NILP (arg))
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2317 {
25511
9bc9d4d6c716 (x_set_scroll_bar_width): Change conditional compilation
Gerd Moellmann <gerd@gnu.org>
parents: 25464
diff changeset
2318 #ifdef USE_TOOLKIT_SCROLL_BARS
9bc9d4d6c716 (x_set_scroll_bar_width): Change conditional compilation
Gerd Moellmann <gerd@gnu.org>
parents: 25464
diff changeset
2319 /* A minimum width of 14 doesn't look good for toolkit scroll bars. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2320 int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2321 FRAME_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2322 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2323 #else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2324 /* Make the actual width at least 14 pixels and a multiple of a
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2325 character width. */
18594
5ca5ff1c74eb (x_set_scroll_bar_width): By default, use enough
Richard M. Stallman <rms@gnu.org>
parents: 18114
diff changeset
2326 FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2327
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2328 /* Use all of that space (aside from required margins) for the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2329 scroll bar. */
9166
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2330 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2331 #endif
18594
5ca5ff1c74eb (x_set_scroll_bar_width): By default, use enough
Richard M. Stallman <rms@gnu.org>
parents: 18114
diff changeset
2332
15891
dbc8c9c9d819 (x_set_scroll_bar_width): Call x_set_window_size when arg is nil.
Richard M. Stallman <rms@gnu.org>
parents: 15881
diff changeset
2333 if (FRAME_X_WINDOW (f))
dbc8c9c9d819 (x_set_scroll_bar_width): Call x_set_window_size when arg is nil.
Richard M. Stallman <rms@gnu.org>
parents: 15881
diff changeset
2334 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
2335 do_pending_window_change (0);
9166
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2336 }
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2337 else if (INTEGERP (arg) && XINT (arg) > 0
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2338 && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2339 {
17629
fa92ac645cf0 (x_set_scroll_bar_width): If arg is too small, round it up.
Richard M. Stallman <rms@gnu.org>
parents: 17609
diff changeset
2340 if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
fa92ac645cf0 (x_set_scroll_bar_width): If arg is too small, round it up.
Richard M. Stallman <rms@gnu.org>
parents: 17609
diff changeset
2341 XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
16682
fe4b95eb15ae (x_set_scroll_bar_width): Reject a width that's too small.
Richard M. Stallman <rms@gnu.org>
parents: 16515
diff changeset
2342
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2343 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2344 FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2345 if (FRAME_X_WINDOW (f))
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2346 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2347 }
16302
025b3dc7a6ba (Fx_create_frame): Default Qinternal_border_width to 1.
Richard M. Stallman <rms@gnu.org>
parents: 16254
diff changeset
2348
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
2349 change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2350 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2351 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2352 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2353
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2354
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2355
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2356 /* Subroutines of creating an X frame. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2357
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2358 /* Make sure that Vx_resource_name is set to a reasonable value.
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2359 Fix it up, or set it to `emacs' if it is too hopeless. */
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2360
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2361 static void
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2362 validate_x_resource_name ()
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2363 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2364 int len = 0;
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2365 /* Number of valid characters in the resource name. */
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2366 int good_count = 0;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2367 /* Number of invalid characters in the resource name. */
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2368 int bad_count = 0;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2369 Lisp_Object new;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2370 int i;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2371
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
2372 if (!STRINGP (Vx_resource_class))
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
2373 Vx_resource_class = build_string (EMACS_CLASS);
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
2374
7525
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2375 if (STRINGP (Vx_resource_name))
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2376 {
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2377 unsigned char *p = XSTRING (Vx_resource_name)->data;
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2378 int i;
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2379
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2380 len = STRING_BYTES (XSTRING (Vx_resource_name));
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2381
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2382 /* Only letters, digits, - and _ are valid in resource names.
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2383 Count the valid characters and count the invalid ones. */
7525
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2384 for (i = 0; i < len; i++)
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2385 {
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2386 int c = p[i];
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2387 if (! ((c >= 'a' && c <= 'z')
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2388 || (c >= 'A' && c <= 'Z')
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2389 || (c >= '0' && c <= '9')
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2390 || c == '-' || c == '_'))
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2391 bad_count++;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2392 else
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2393 good_count++;
7525
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2394 }
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2395 }
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2396 else
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2397 /* Not a string => completely invalid. */
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2398 bad_count = 5, good_count = 0;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2399
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2400 /* If name is valid already, return. */
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2401 if (bad_count == 0)
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2402 return;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2403
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2404 /* If name is entirely invalid, or nearly so, use `emacs'. */
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2405 if (good_count == 0
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2406 || (good_count == 1 && bad_count > 0))
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2407 {
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2408 Vx_resource_name = build_string ("emacs");
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2409 return;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2410 }
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2411
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2412 /* Name is partly valid. Copy it and replace the invalid characters
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2413 with underscores. */
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2414
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2415 Vx_resource_name = new = Fcopy_sequence (Vx_resource_name);
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2416
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2417 for (i = 0; i < len; i++)
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2418 {
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2419 int c = XSTRING (new)->data[i];
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2420 if (! ((c >= 'a' && c <= 'z')
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2421 || (c >= 'A' && c <= 'Z')
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2422 || (c >= '0' && c <= '9')
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2423 || c == '-' || c == '_'))
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2424 XSTRING (new)->data[i] = '_';
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2425 }
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2426 }
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2427
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2428
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2429 extern char *x_get_string_resource ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2430
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2431 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2432 "Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.\n\
8961
940ca63c26c8 (Fx_get_resource): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8942
diff changeset
2433 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the\n\
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2434 class, where INSTANCE is the name under which Emacs was invoked, or\n\
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2435 the name specified by the `-name' or `-rn' command-line arguments.\n\
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2436 \n\
1733
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2437 The optional arguments COMPONENT and SUBCLASS add to the key and the\n\
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2438 class, respectively. You must specify both of them or neither.\n\
8961
940ca63c26c8 (Fx_get_resource): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8942
diff changeset
2439 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'\n\
940ca63c26c8 (Fx_get_resource): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8942
diff changeset
2440 and the class is `Emacs.CLASS.SUBCLASS'.")
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2441 (attribute, class, component, subclass)
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2442 Lisp_Object attribute, class, component, subclass;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2443 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2444 register char *value;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2445 char *name_key;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2446 char *class_key;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2447
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
2448 check_x ();
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
2449
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2450 CHECK_STRING (attribute, 0);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2451 CHECK_STRING (class, 0);
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2452
1733
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2453 if (!NILP (component))
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2454 CHECK_STRING (component, 1);
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2455 if (!NILP (subclass))
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2456 CHECK_STRING (subclass, 2);
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2457 if (NILP (component) != NILP (subclass))
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2458 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2459
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2460 validate_x_resource_name ();
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2461
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2462 /* Allocate space for the components, the dots which separate them,
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2463 and the final '\0'. Make them big enough for the worst case. */
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2464 name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name))
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2465 + (STRINGP (component)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2466 ? STRING_BYTES (XSTRING (component)) : 0)
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2467 + STRING_BYTES (XSTRING (attribute))
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2468 + 3);
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2469
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2470 class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class))
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2471 + STRING_BYTES (XSTRING (class))
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2472 + (STRINGP (subclass)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2473 ? STRING_BYTES (XSTRING (subclass)) : 0)
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2474 + 3);
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2475
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2476 /* Start with emacs.FRAMENAME for the name (the specific one)
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2477 and with `Emacs' for the class key (the general one). */
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2478 strcpy (name_key, XSTRING (Vx_resource_name)->data);
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
2479 strcpy (class_key, XSTRING (Vx_resource_class)->data);
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2480
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2481 strcat (class_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2482 strcat (class_key, XSTRING (class)->data);
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2483
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2484 if (!NILP (component))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2485 {
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2486 strcat (class_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2487 strcat (class_key, XSTRING (subclass)->data);
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2488
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2489 strcat (name_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2490 strcat (name_key, XSTRING (component)->data);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2491 }
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2492
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2493 strcat (name_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2494 strcat (name_key, XSTRING (attribute)->data);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2495
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2496 value = x_get_string_resource (check_x_display_info (Qnil)->xrdb,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2497 name_key, class_key);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2498
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2499 if (value != (char *) 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2500 return build_string (value);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2501 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2502 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2503 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2504
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2505 /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2506
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2507 Lisp_Object
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2508 display_x_get_resource (dpyinfo, attribute, class, component, subclass)
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2509 struct x_display_info *dpyinfo;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2510 Lisp_Object attribute, class, component, subclass;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2511 {
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2512 register char *value;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2513 char *name_key;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2514 char *class_key;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2515
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2516 check_x ();
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2517
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2518 CHECK_STRING (attribute, 0);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2519 CHECK_STRING (class, 0);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2520
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2521 if (!NILP (component))
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2522 CHECK_STRING (component, 1);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2523 if (!NILP (subclass))
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2524 CHECK_STRING (subclass, 2);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2525 if (NILP (component) != NILP (subclass))
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2526 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2527
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2528 validate_x_resource_name ();
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2529
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2530 /* Allocate space for the components, the dots which separate them,
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2531 and the final '\0'. Make them big enough for the worst case. */
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2532 name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name))
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2533 + (STRINGP (component)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2534 ? STRING_BYTES (XSTRING (component)) : 0)
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2535 + STRING_BYTES (XSTRING (attribute))
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2536 + 3);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2537
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2538 class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class))
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2539 + STRING_BYTES (XSTRING (class))
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2540 + (STRINGP (subclass)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2541 ? STRING_BYTES (XSTRING (subclass)) : 0)
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2542 + 3);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2543
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2544 /* Start with emacs.FRAMENAME for the name (the specific one)
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2545 and with `Emacs' for the class key (the general one). */
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2546 strcpy (name_key, XSTRING (Vx_resource_name)->data);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2547 strcpy (class_key, XSTRING (Vx_resource_class)->data);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2548
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2549 strcat (class_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2550 strcat (class_key, XSTRING (class)->data);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2551
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2552 if (!NILP (component))
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2553 {
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2554 strcat (class_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2555 strcat (class_key, XSTRING (subclass)->data);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2556
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2557 strcat (name_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2558 strcat (name_key, XSTRING (component)->data);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2559 }
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2560
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2561 strcat (name_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2562 strcat (name_key, XSTRING (attribute)->data);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2563
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2564 value = x_get_string_resource (dpyinfo->xrdb, name_key, class_key);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2565
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2566 if (value != (char *) 0)
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2567 return build_string (value);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2568 else
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2569 return Qnil;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2570 }
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2571
3173
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2572 /* Used when C code wants a resource value. */
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2573
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2574 char *
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2575 x_get_resource_string (attribute, class)
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2576 char *attribute, *class;
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2577 {
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2578 char *name_key;
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2579 char *class_key;
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
2580 struct frame *sf = SELECTED_FRAME ();
3173
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2581
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2582 /* Allocate space for the components, the dots which separate them,
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2583 and the final '\0'. */
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2584 name_key = (char *) alloca (STRING_BYTES (XSTRING (Vinvocation_name))
3173
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2585 + strlen (attribute) + 2);
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2586 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2587 + strlen (class) + 2);
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2588
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2589 sprintf (name_key, "%s.%s",
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2590 XSTRING (Vinvocation_name)->data,
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2591 attribute);
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2592 sprintf (class_key, "%s.%s", EMACS_CLASS, class);
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2593
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
2594 return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2595 name_key, class_key);
3173
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2596 }
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2597
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2598 /* Types we might convert a resource string into. */
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2599 enum resource_types
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2600 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2601 RES_TYPE_NUMBER,
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2602 RES_TYPE_FLOAT,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2603 RES_TYPE_BOOLEAN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2604 RES_TYPE_STRING,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2605 RES_TYPE_SYMBOL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2606 };
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2607
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2608 /* Return the value of parameter PARAM.
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2609
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2610 First search ALIST, then Vdefault_frame_alist, then the X defaults
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2611 database, using ATTRIBUTE as the attribute name and CLASS as its class.
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2612
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2613 Convert the resource to the type specified by desired_type.
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2614
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2615 If no default is specified, return Qunbound. If you call
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2616 x_get_arg, make sure you deal with Qunbound in a reasonable way,
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
2617 and don't let it get stored in any Lisp-visible variables! */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2618
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2619 static Lisp_Object
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2620 x_get_arg (dpyinfo, alist, param, attribute, class, type)
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2621 struct x_display_info *dpyinfo;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 621
diff changeset
2622 Lisp_Object alist, param;
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2623 char *attribute;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2624 char *class;
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2625 enum resource_types type;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2626 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2627 register Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2628
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2629 tem = Fassq (param, alist);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2630 if (EQ (tem, Qnil))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2631 tem = Fassq (param, Vdefault_frame_alist);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2632 if (EQ (tem, Qnil))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2633 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2634
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2635 if (attribute)
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2636 {
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2637 tem = display_x_get_resource (dpyinfo,
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2638 build_string (attribute),
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2639 build_string (class),
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2640 Qnil, Qnil);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2641
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2642 if (NILP (tem))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2643 return Qunbound;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2644
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2645 switch (type)
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2646 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2647 case RES_TYPE_NUMBER:
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2648 return make_number (atoi (XSTRING (tem)->data));
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2649
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2650 case RES_TYPE_FLOAT:
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2651 return make_float (atof (XSTRING (tem)->data));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2652
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2653 case RES_TYPE_BOOLEAN:
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2654 tem = Fdowncase (tem);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2655 if (!strcmp (XSTRING (tem)->data, "on")
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2656 || !strcmp (XSTRING (tem)->data, "true"))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2657 return Qt;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2658 else
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2659 return Qnil;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2660
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2661 case RES_TYPE_STRING:
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2662 return tem;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2663
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2664 case RES_TYPE_SYMBOL:
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2665 /* As a special case, we map the values `true' and `on'
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2666 to Qt, and `false' and `off' to Qnil. */
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2667 {
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
2668 Lisp_Object lower;
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
2669 lower = Fdowncase (tem);
6523
d9d9ab5951dd (x_get_arg): Use downcased string in compare.
Karl Heuer <kwzh@gnu.org>
parents: 6522
diff changeset
2670 if (!strcmp (XSTRING (lower)->data, "on")
d9d9ab5951dd (x_get_arg): Use downcased string in compare.
Karl Heuer <kwzh@gnu.org>
parents: 6522
diff changeset
2671 || !strcmp (XSTRING (lower)->data, "true"))
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2672 return Qt;
6523
d9d9ab5951dd (x_get_arg): Use downcased string in compare.
Karl Heuer <kwzh@gnu.org>
parents: 6522
diff changeset
2673 else if (!strcmp (XSTRING (lower)->data, "off")
d9d9ab5951dd (x_get_arg): Use downcased string in compare.
Karl Heuer <kwzh@gnu.org>
parents: 6522
diff changeset
2674 || !strcmp (XSTRING (lower)->data, "false"))
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2675 return Qnil;
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2676 else
2686
a84b9a78ab08 (x_get_arg): Call Fintern, not intern.
Richard M. Stallman <rms@gnu.org>
parents: 2439
diff changeset
2677 return Fintern (tem, Qnil);
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2678 }
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2679
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2680 default:
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2681 abort ();
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2682 }
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2683 }
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2684 else
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2685 return Qunbound;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2686 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2687 return Fcdr (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2688 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2689
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2690 /* Like x_get_arg, but also record the value in f->param_alist. */
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2691
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2692 static Lisp_Object
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2693 x_get_and_record_arg (f, alist, param, attribute, class, type)
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2694 struct frame *f;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2695 Lisp_Object alist, param;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2696 char *attribute;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2697 char *class;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2698 enum resource_types type;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2699 {
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2700 Lisp_Object value;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2701
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2702 value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param,
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2703 attribute, class, type);
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2704 if (! NILP (value))
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2705 store_frame_param (f, param, value);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2706
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2707 return value;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2708 }
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2709
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2710 /* Record in frame F the specified or default value according to ALIST
19095
2f58824bf3f6 (x_set_frame_parameters): Heading comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 19026
diff changeset
2711 of the parameter named PROP (a Lisp symbol).
2f58824bf3f6 (x_set_frame_parameters): Heading comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 19026
diff changeset
2712 If no value is specified for PROP, look for an X default for XPROP
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2713 on the frame named NAME.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2714 If that is not found either, use the value DEFLT. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2715
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2716 static Lisp_Object
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2717 x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2718 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2719 Lisp_Object alist;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2720 Lisp_Object prop;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2721 Lisp_Object deflt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2722 char *xprop;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2723 char *xclass;
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2724 enum resource_types type;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2725 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2726 Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2728 tem = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, prop, xprop, xclass, type);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2729 if (EQ (tem, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2730 tem = deflt;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2731 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2732 return tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2733 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2734
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2735
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2736 /* Record in frame F the specified or default value according to ALIST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2737 of the parameter named PROP (a Lisp symbol). If no value is
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2738 specified for PROP, look for an X default for XPROP on the frame
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2739 named NAME. If that is not found either, use the value DEFLT. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2740
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2741 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2742 x_default_scroll_bar_color_parameter (f, alist, prop, xprop, xclass,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2743 foreground_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2744 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2745 Lisp_Object alist;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2746 Lisp_Object prop;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2747 char *xprop;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2748 char *xclass;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2749 int foreground_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2750 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2751 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2752 Lisp_Object tem;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2753
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2754 tem = x_get_arg (dpyinfo, alist, prop, xprop, xclass, RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2755 if (EQ (tem, Qunbound))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2756 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2757 #ifdef USE_TOOLKIT_SCROLL_BARS
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2758
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2759 /* See if an X resource for the scroll bar color has been
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2760 specified. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2761 tem = display_x_get_resource (dpyinfo,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2762 build_string (foreground_p
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2763 ? "foreground"
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2764 : "background"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2765 build_string (""),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2766 build_string ("verticalScrollBar"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2767 build_string (""));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2768 if (!STRINGP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2769 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2770 /* If nothing has been specified, scroll bars will use a
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2771 toolkit-dependent default. Because these defaults are
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2772 difficult to get at without actually creating a scroll
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2773 bar, use nil to indicate that no color has been
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2774 specified. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2775 tem = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2776 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2777
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2778 #else /* not USE_TOOLKIT_SCROLL_BARS */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2779
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2780 tem = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2781
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2782 #endif /* not USE_TOOLKIT_SCROLL_BARS */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2783 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2784
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2785 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2786 return tem;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2787 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2788
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2789
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2790
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
2791 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2792 "Parse an X-style geometry string STRING.\n\
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2793 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).\n\
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2794 The properties returned may include `top', `left', `height', and `width'.\n\
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2795 The value of `left' or `top' may be an integer,\n\
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2796 or a list (+ N) meaning N pixels relative to top/left corner,\n\
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2797 or a list (- N) meaning -N pixels relative to bottom/right corner.")
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2798 (string)
1528
924c8a609582 * xfns.c (x_decode_color, Fx_color_display_p): x_screen_planes is
Jim Blandy <jimb@redhat.com>
parents: 1438
diff changeset
2799 Lisp_Object string;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2800 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 int geometry, x, y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2802 unsigned int width, height;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2803 Lisp_Object result;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2804
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2805 CHECK_STRING (string, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807 geometry = XParseGeometry ((char *) XSTRING (string)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2808 &x, &y, &width, &height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2810 #if 0
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2811 if (!!(geometry & XValue) != !!(geometry & YValue))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2812 error ("Must specify both x and y position, or neither");
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2813 #endif
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2814
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2815 result = Qnil;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2816 if (geometry & XValue)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2817 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2818 Lisp_Object element;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2819
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2820 if (x >= 0 && (geometry & XNegative))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2821 element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2822 else if (x < 0 && ! (geometry & XNegative))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2823 element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2824 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2825 element = Fcons (Qleft, make_number (x));
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2826 result = Fcons (element, result);
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2827 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2828
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2829 if (geometry & YValue)
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2830 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2831 Lisp_Object element;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2832
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2833 if (y >= 0 && (geometry & YNegative))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2834 element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2835 else if (y < 0 && ! (geometry & YNegative))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2836 element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2837 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2838 element = Fcons (Qtop, make_number (y));
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2839 result = Fcons (element, result);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2840 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2841
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2842 if (geometry & WidthValue)
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2843 result = Fcons (Fcons (Qwidth, make_number (width)), result);
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2844 if (geometry & HeightValue)
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2845 result = Fcons (Fcons (Qheight, make_number (height)), result);
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2846
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2847 return result;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2848 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2849
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2850 /* Calculate the desired size and position of this window,
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2851 and return the flags saying which aspects were specified.
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
2852
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
2853 This function does not make the coordinates positive. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2854
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2855 #define DEFAULT_ROWS 40
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2856 #define DEFAULT_COLS 80
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2857
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2858 static int
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2859 x_figure_window_size (f, parms)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2860 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2861 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2862 {
7251
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2863 register Lisp_Object tem0, tem1, tem2;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2864 long window_prompting = 0;
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2865 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2866
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2867 /* Default values if we fall through.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2868 Actually, if that happens we should get
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2869 window manager prompting. */
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2870 SET_FRAME_WIDTH (f, DEFAULT_COLS);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2871 f->height = DEFAULT_ROWS;
3108
461470daafaa (x_figure_window_size): Make the default frame coords (0,0).
Richard M. Stallman <rms@gnu.org>
parents: 3080
diff changeset
2872 /* Window managers expect that if program-specified
461470daafaa (x_figure_window_size): Make the default frame coords (0,0).
Richard M. Stallman <rms@gnu.org>
parents: 3080
diff changeset
2873 positions are not (0,0), they're intentional, not defaults. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2874 f->output_data.x->top_pos = 0;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2875 f->output_data.x->left_pos = 0;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2876
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2877 tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2878 tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2879 tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER);
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2880 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2881 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2882 if (!EQ (tem0, Qunbound))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2883 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2884 CHECK_NUMBER (tem0, 0);
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2885 f->height = XINT (tem0);
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2886 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2887 if (!EQ (tem1, Qunbound))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2888 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2889 CHECK_NUMBER (tem1, 0);
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2890 SET_FRAME_WIDTH (f, XINT (tem1));
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2891 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2892 if (!NILP (tem2) && !EQ (tem2, Qunbound))
7251
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2893 window_prompting |= USSize;
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2894 else
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2895 window_prompting |= PSize;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2896 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2897
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2898 f->output_data.x->vertical_scroll_bar_extra
9240
60497ceed71a (x_figure_window_size): Use new formula for scroll bar width.
Karl Heuer <kwzh@gnu.org>
parents: 9231
diff changeset
2899 = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
60497ceed71a (x_figure_window_size): Use new formula for scroll bar width.
Karl Heuer <kwzh@gnu.org>
parents: 9231
diff changeset
2900 ? 0
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2901 : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2902 f->output_data.x->flags_areas_extra
25464
080a7a9d6f79 (x_figure_window_size): Use FRAME_FLAGS_AREA_COLS instead
Gerd Moellmann <gerd@gnu.org>
parents: 25451
diff changeset
2903 = FRAME_FLAGS_AREA_WIDTH (f);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2904 f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2905 f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2906
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2907 tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2908 tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2909 tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER);
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2910 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2911 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2912 if (EQ (tem0, Qminus))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2913 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2914 f->output_data.x->top_pos = 0;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2915 window_prompting |= YNegative;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2916 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2917 else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2918 && CONSP (XCDR (tem0))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2919 && INTEGERP (XCAR (XCDR (tem0))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2920 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2921 f->output_data.x->top_pos = - XINT (XCAR (XCDR (tem0)));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2922 window_prompting |= YNegative;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2923 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2924 else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2925 && CONSP (XCDR (tem0))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2926 && INTEGERP (XCAR (XCDR (tem0))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2927 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2928 f->output_data.x->top_pos = XINT (XCAR (XCDR (tem0)));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2929 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2930 else if (EQ (tem0, Qunbound))
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2931 f->output_data.x->top_pos = 0;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2932 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2933 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2934 CHECK_NUMBER (tem0, 0);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2935 f->output_data.x->top_pos = XINT (tem0);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2936 if (f->output_data.x->top_pos < 0)
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2937 window_prompting |= YNegative;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2938 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2939
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2940 if (EQ (tem1, Qminus))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2941 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2942 f->output_data.x->left_pos = 0;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2943 window_prompting |= XNegative;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2944 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2945 else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2946 && CONSP (XCDR (tem1))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2947 && INTEGERP (XCAR (XCDR (tem1))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2948 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2949 f->output_data.x->left_pos = - XINT (XCAR (XCDR (tem1)));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2950 window_prompting |= XNegative;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2951 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2952 else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2953 && CONSP (XCDR (tem1))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2954 && INTEGERP (XCAR (XCDR (tem1))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2955 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2956 f->output_data.x->left_pos = XINT (XCAR (XCDR (tem1)));
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2957 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2958 else if (EQ (tem1, Qunbound))
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2959 f->output_data.x->left_pos = 0;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2960 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2961 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2962 CHECK_NUMBER (tem1, 0);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2963 f->output_data.x->left_pos = XINT (tem1);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2964 if (f->output_data.x->left_pos < 0)
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2965 window_prompting |= XNegative;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2966 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2967
10264
92dcc001aa20 (x_figure_window_size): Treat missing user-position parm as nil.
Richard M. Stallman <rms@gnu.org>
parents: 10222
diff changeset
2968 if (!NILP (tem2) && ! EQ (tem2, Qunbound))
7251
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2969 window_prompting |= USPosition;
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2970 else
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2971 window_prompting |= PPosition;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2972 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2973
3293
03e4cad68481 (Fx_close_current_connection): Clear x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 3203
diff changeset
2974 return window_prompting;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2975 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2976
5229
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2977 #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2978
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2979 Status
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2980 XSetWMProtocols (dpy, w, protocols, count)
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2981 Display *dpy;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2982 Window w;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2983 Atom *protocols;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2984 int count;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2985 {
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2986 Atom prop;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2987 prop = XInternAtom (dpy, "WM_PROTOCOLS", False);
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2988 if (prop == None) return False;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2989 XChangeProperty (dpy, w, prop, XA_ATOM, 32, PropModeReplace,
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2990 (unsigned char *) protocols, count);
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2991 return True;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2992 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2993 #endif /* not HAVE_X11R4 && not HAVE_XSETWMPROTOCOLS */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2994
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2995 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2996
9528
db02bc274f20 (Fx_create_frame): Init the FRAME_X_SCREEN as soon as can be done.
Richard M. Stallman <rms@gnu.org>
parents: 9353
diff changeset
2997 /* If the WM_PROTOCOLS property does not already contain WM_TAKE_FOCUS,
db02bc274f20 (Fx_create_frame): Init the FRAME_X_SCREEN as soon as can be done.
Richard M. Stallman <rms@gnu.org>
parents: 9353
diff changeset
2998 WM_DELETE_WINDOW, and WM_SAVE_YOURSELF, then add them. (They may
8845
c4b7fda8f611 (hack_wm_protocols): Arrange to handle WM_SAVE_YOURSELF.
Richard M. Stallman <rms@gnu.org>
parents: 8782
diff changeset
2999 already be present because of the toolkit (Motif adds some of them,
c4b7fda8f611 (hack_wm_protocols): Arrange to handle WM_SAVE_YOURSELF.
Richard M. Stallman <rms@gnu.org>
parents: 8782
diff changeset
3000 for example, but Xt doesn't). */
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3001
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3002 static void
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3003 hack_wm_protocols (f, widget)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3004 FRAME_PTR f;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3005 Widget widget;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3006 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3007 Display *dpy = XtDisplay (widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3008 Window w = XtWindow (widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3009 int need_delete = 1;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3010 int need_focus = 1;
8845
c4b7fda8f611 (hack_wm_protocols): Arrange to handle WM_SAVE_YOURSELF.
Richard M. Stallman <rms@gnu.org>
parents: 8782
diff changeset
3011 int need_save = 1;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3012
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3013 BLOCK_INPUT;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3014 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3015 Atom type, *atoms = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3016 int format = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3017 unsigned long nitems = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3018 unsigned long bytes_after;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3019
11882
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3020 if ((XGetWindowProperty (dpy, w,
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3021 FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols,
11894
b20c45d49063 (hack_wm_protocols): Use cast instead of suffix.
Karl Heuer <kwzh@gnu.org>
parents: 11893
diff changeset
3022 (long)0, (long)100, False, XA_ATOM,
11882
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3023 &type, &format, &nitems, &bytes_after,
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3024 (unsigned char **) &atoms)
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3025 == Success)
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3026 && format == 32 && type == XA_ATOM)
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3027 while (nitems > 0)
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3028 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3029 nitems--;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3030 if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3031 need_delete = 0;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3032 else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3033 need_focus = 0;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3034 else if (atoms[nitems] == FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3035 need_save = 0;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3036 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3037 if (atoms) XFree ((char *) atoms);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3038 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3039 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3040 Atom props [10];
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3041 int count = 0;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3042 if (need_delete)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3043 props[count++] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3044 if (need_focus)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3045 props[count++] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_take_focus;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3046 if (need_save)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3047 props[count++] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3048 if (count)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3049 XChangeProperty (dpy, w, FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3050 XA_ATOM, 32, PropModeAppend,
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3051 (unsigned char *) props, count);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3052 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3053 UNBLOCK_INPUT;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3054 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3055 #endif
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3056
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3057 #ifdef USE_X_TOOLKIT
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3058
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3059 /* Create and set up the X widget for frame F. */
5229
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
3060
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3061 static void
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3062 x_window (f, window_prompting, minibuffer_only)
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3063 struct frame *f;
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3064 long window_prompting;
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3065 int minibuffer_only;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3066 {
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3067 XClassHint class_hints;
6059
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3068 XSetWindowAttributes attributes;
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3069 unsigned long attribute_mask;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3070
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3071 Widget shell_widget;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3072 Widget pane_widget;
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3073 Widget frame_widget;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3074 Arg al [25];
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3075 int ac;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3076
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3077 BLOCK_INPUT;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3078
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3079 /* Use the resource name as the top-level widget name
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3080 for looking up resources. Make a non-Lisp copy
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3081 for the window manager, so GC relocation won't bother it.
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3082
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3083 Elsewhere we specify the window name for the window manager. */
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3084
11496
db02849ee365 (x_window): Use (or reuse) frame's namebuf instead of a
Karl Heuer <kwzh@gnu.org>
parents: 11483
diff changeset
3085 {
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3086 char *str = (char *) XSTRING (Vx_resource_name)->data;
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3087 f->namebuf = (char *) xmalloc (strlen (str) + 1);
11496
db02849ee365 (x_window): Use (or reuse) frame's namebuf instead of a
Karl Heuer <kwzh@gnu.org>
parents: 11483
diff changeset
3088 strcpy (f->namebuf, str);
db02849ee365 (x_window): Use (or reuse) frame's namebuf instead of a
Karl Heuer <kwzh@gnu.org>
parents: 11483
diff changeset
3089 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3090
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3091 ac = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3092 XtSetArg (al[ac], XtNallowShellResize, 1); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3093 XtSetArg (al[ac], XtNinput, 1); ac++;
11707
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3094 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3095 XtSetArg (al[ac], XtNborderWidth, f->output_data.x->border_width); ac++;
11496
db02849ee365 (x_window): Use (or reuse) frame's namebuf instead of a
Karl Heuer <kwzh@gnu.org>
parents: 11483
diff changeset
3096 shell_widget = XtAppCreateShell (f->namebuf, EMACS_CLASS,
12019
63ee64941021 (x_top_window_to_frame): Don't match menu-bar widget.
Karl Heuer <kwzh@gnu.org>
parents: 12011
diff changeset
3097 applicationShellWidgetClass,
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
3098 FRAME_X_DISPLAY (f), al, ac);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3099
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3100 f->output_data.x->widget = shell_widget;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3101 /* maybe_set_screen_title_format (shell_widget); */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3102
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3103 pane_widget = lw_create_widget ("main", "pane", widget_id_tick++,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3104 (widget_value *) NULL,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3105 shell_widget, False,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3106 (lw_callback) NULL,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3107 (lw_callback) NULL,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3108 (lw_callback) NULL);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3109
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3110 f->output_data.x->column_widget = pane_widget;
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3111
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3112 /* mappedWhenManaged to false tells to the paned window to not map/unmap
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
3113 the emacs screen when changing menubar. This reduces flickering. */
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3114
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3115 ac = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3116 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3117 XtSetArg (al[ac], XtNshowGrip, 0); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3118 XtSetArg (al[ac], XtNallowResize, 1); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3119 XtSetArg (al[ac], XtNresizeToPreferred, 1); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3120 XtSetArg (al[ac], XtNemacsFrame, f); ac++;
11496
db02849ee365 (x_window): Use (or reuse) frame's namebuf instead of a
Karl Heuer <kwzh@gnu.org>
parents: 11483
diff changeset
3121 frame_widget = XtCreateWidget (f->namebuf,
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3122 emacsFrameClass,
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3123 pane_widget, al, ac);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3124
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3125 f->output_data.x->edit_widget = frame_widget;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3126
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3127 XtManageChild (frame_widget);
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3128
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3129 /* Do some needed geometry management. */
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3130 {
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3131 int len;
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3132 char *tem, shell_position[32];
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3133 Arg al[2];
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3134 int ac = 0;
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3135 int extra_borders = 0;
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3136 int menubar_size
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3137 = (f->output_data.x->menubar_widget
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3138 ? (f->output_data.x->menubar_widget->core.height
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3139 + f->output_data.x->menubar_widget->core.border_width)
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3140 : 0);
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3141
15942
ff30ec8aab54 (x_window): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15891
diff changeset
3142 #if 0 /* Experimentally, we now get the right results
ff30ec8aab54 (x_window): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15891
diff changeset
3143 for -geometry -0-0 without this. 24 Aug 96, rms. */
7969
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3144 if (FRAME_EXTERNAL_MENU_BAR (f))
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3145 {
9808
4c43c9dbe130 (x_window): Make ibw 0 by default.
Richard M. Stallman <rms@gnu.org>
parents: 9742
diff changeset
3146 Dimension ibw = 0;
7969
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3147 XtVaGetValues (pane_widget, XtNinternalBorderWidth, &ibw, NULL);
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3148 menubar_size += ibw;
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3149 }
15942
ff30ec8aab54 (x_window): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15891
diff changeset
3150 #endif
7969
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3151
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3152 f->output_data.x->menubar_height = menubar_size;
11897
cbd3724a9696 (x_window) [both versions]: Set menubar_height.
Karl Heuer <kwzh@gnu.org>
parents: 11894
diff changeset
3153
16305
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3154 #ifndef USE_LUCID
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3155 /* Motif seems to need this amount added to the sizes
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3156 specified for the shell widget. The Athena/Lucid widgets don't.
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3157 Both conclusions reached experimentally. -- rms. */
16305
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3158 XtVaGetValues (f->output_data.x->edit_widget, XtNinternalBorderWidth,
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3159 &extra_borders, NULL);
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3160 extra_borders *= 2;
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3161 #endif
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3162
11707
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3163 /* Convert our geometry parameters into a geometry string
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3164 and specify it.
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3165 Note that we do not specify here whether the position
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3166 is a user-specified or program-specified one.
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3167 We pass that information later, in x_wm_set_size_hints. */
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3168 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3169 int left = f->output_data.x->left_pos;
11707
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3170 int xneg = window_prompting & XNegative;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3171 int top = f->output_data.x->top_pos;
11707
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3172 int yneg = window_prompting & YNegative;
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3173 if (xneg)
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3174 left = -left;
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3175 if (yneg)
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3176 top = -top;
11893
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3177
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3178 if (window_prompting & USPosition)
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3179 sprintf (shell_position, "=%dx%d%c%d%c%d",
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3180 PIXEL_WIDTH (f) + extra_borders,
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3181 PIXEL_HEIGHT (f) + menubar_size + extra_borders,
11893
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3182 (xneg ? '-' : '+'), left,
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3183 (yneg ? '-' : '+'), top);
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3184 else
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3185 sprintf (shell_position, "=%dx%d",
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3186 PIXEL_WIDTH (f) + extra_borders,
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3187 PIXEL_HEIGHT (f) + menubar_size + extra_borders);
11707
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3188 }
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3189
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3190 len = strlen (shell_position) + 1;
17579
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3191 /* We don't free this because we don't know whether
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3192 it is safe to free it while the frame exists.
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3193 It isn't worth the trouble of arranging to free it
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3194 when the frame is deleted. */
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3195 tem = (char *) xmalloc (len);
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3196 strncpy (tem, shell_position, len);
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3197 XtSetArg (al[ac], XtNgeometry, tem); ac++;
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3198 XtSetValues (shell_widget, al, ac);
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3199 }
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3200
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3201 XtManageChild (pane_widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3202 XtRealizeWidget (shell_widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3203
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3204 FRAME_X_WINDOW (f) = XtWindow (frame_widget);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3205
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3206 validate_x_resource_name ();
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3207
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3208 class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
3209 class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3210 XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3211
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3212 #ifdef HAVE_X_I18N
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3213 #ifndef X_I18N_INHIBITED
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3214 {
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3215 XIM xim;
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3216 XIC xic = NULL;
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3217
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3218 xim = XOpenIM (FRAME_X_DISPLAY (f), NULL, NULL, NULL);
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3219
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3220 if (xim)
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3221 {
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3222 xic = XCreateIC (xim,
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3223 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3224 XNClientWindow, FRAME_X_WINDOW(f),
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3225 XNFocusWindow, FRAME_X_WINDOW(f),
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3226 NULL);
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3228 if (xic == 0)
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3229 {
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3230 XCloseIM (xim);
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3231 xim = NULL;
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3232 }
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3233 }
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3234 FRAME_XIM (f) = xim;
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3235 FRAME_XIC (f) = xic;
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3236 }
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3237 #else /* X_I18N_INHIBITED */
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3238 FRAME_XIM (f) = 0;
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3239 FRAME_XIC (f) = 0;
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3240 #endif /* X_I18N_INHIBITED */
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3241 #endif /* HAVE_X_I18N */
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3242
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3243 f->output_data.x->wm_hints.input = True;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3244 f->output_data.x->wm_hints.flags |= InputHint;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3245 XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3246 &f->output_data.x->wm_hints);
7172
f9eeb75c2b76 (x_window) [USE_X_TOOLKIT]: Call XSetWMHints.
Richard M. Stallman <rms@gnu.org>
parents: 7040
diff changeset
3247
9703
85ac0e4030d4 (x_window): Pass new arg f to hack_wm_protocols.
Richard M. Stallman <rms@gnu.org>
parents: 9690
diff changeset
3248 hack_wm_protocols (f, shell_widget);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3249
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3250 #ifdef HACK_EDITRES
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3251 XtAddEventHandler (shell_widget, 0, True, _XEditResCheckMessages, 0);
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3252 #endif
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3253
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3254 /* Do a stupid property change to force the server to generate a
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3255 PropertyNotify event so that the event_stream server timestamp will
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3256 be initialized to something relevant to the time we created the window.
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3257 */
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3258 XChangeProperty (XtDisplay (frame_widget), XtWindow (frame_widget),
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3259 FRAME_X_DISPLAY_INFO (f)->Xatom_wm_protocols,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3260 XA_ATOM, 32, PropModeAppend,
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3261 (unsigned char*) NULL, 0);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3262
6059
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3263 /* Make all the standard events reach the Emacs frame. */
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3264 attributes.event_mask = STANDARD_EVENT_SET;
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3265 attribute_mask = CWEventMask;
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3266 XChangeWindowAttributes (XtDisplay (shell_widget), XtWindow (shell_widget),
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3267 attribute_mask, &attributes);
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3268
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3269 XtMapWidget (frame_widget);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3270
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3271 /* x_set_name normally ignores requests to set the name if the
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3272 requested name is the same as the current name. This is the one
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3273 place where that assumption isn't correct; f->name is set, but
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3274 the X server hasn't been told. */
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3275 {
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3276 Lisp_Object name;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3277 int explicit = f->explicit_name;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3278
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3279 f->explicit_name = 0;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3280 name = f->name;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3281 f->name = Qnil;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3282 x_set_name (f, name, explicit);
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3283 }
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3284
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3285 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3286 f->output_data.x->text_cursor);
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3287
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3288 UNBLOCK_INPUT;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3289
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3290 /* This is a no-op, except under Motif. Make sure main areas are
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3291 set to something reasonable, in case we get an error later. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3292 lw_set_main_areas (pane_widget, 0, frame_widget);
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3293 }
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3294
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3295 #else /* not USE_X_TOOLKIT */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3296
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3297 /* Create and set up the X window for frame F. */
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3298
21846
486ac68ce051 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21779
diff changeset
3299 void
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3300 x_window (f)
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3301 struct frame *f;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3302
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3303 {
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3304 XClassHint class_hints;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3305 XSetWindowAttributes attributes;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3306 unsigned long attribute_mask;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3307
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3308 attributes.background_pixel = f->output_data.x->background_pixel;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3309 attributes.border_pixel = f->output_data.x->border_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3310 attributes.bit_gravity = StaticGravity;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3311 attributes.backing_store = NotUseful;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3312 attributes.save_under = True;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3313 attributes.event_mask = STANDARD_EVENT_SET;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3314 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3315 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3316 | CWBackingStore | CWSaveUnder
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3317 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3318 | CWEventMask);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3319
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3320 BLOCK_INPUT;
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
3321 FRAME_X_WINDOW (f)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3322 = XCreateWindow (FRAME_X_DISPLAY (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3323 f->output_data.x->parent_desc,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3324 f->output_data.x->left_pos,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3325 f->output_data.x->top_pos,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3326 PIXEL_WIDTH (f), PIXEL_HEIGHT (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3327 f->output_data.x->border_width,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3328 CopyFromParent, /* depth */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3329 InputOutput, /* class */
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3330 FRAME_X_DISPLAY_INFO (f)->visual,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3331 attribute_mask, &attributes);
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3332 #ifdef HAVE_X_I18N
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3333 #ifndef X_I18N_INHIBITED
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3334 {
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3335 XIM xim;
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3336 XIC xic = NULL;
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3337
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3338 xim = XOpenIM (FRAME_X_DISPLAY(f), NULL, NULL, NULL);
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3339
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3340 if (xim)
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3341 {
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3342 xic = XCreateIC (xim,
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3343 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3344 XNClientWindow, FRAME_X_WINDOW(f),
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3345 XNFocusWindow, FRAME_X_WINDOW(f),
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3346 NULL);
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3347
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3348 if (!xic)
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3349 {
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3350 XCloseIM (xim);
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3351 xim = NULL;
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3352 }
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3353 }
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3354
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3355 FRAME_XIM (f) = xim;
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3356 FRAME_XIC (f) = xic;
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3357 }
14831
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3358 #else /* X_I18N_INHIBITED */
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3359 FRAME_XIM (f) = 0;
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3360 FRAME_XIC (f) = 0;
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3361 #endif /* X_I18N_INHIBITED */
df37dc2b9bfb (X_I18N_INHIBITED): New macro--define this
Richard M. Stallman <rms@gnu.org>
parents: 14746
diff changeset
3362 #endif /* HAVE_X_I18N */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3363
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3364 validate_x_resource_name ();
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3365
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3366 class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
3367 class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3368 XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3369
11897
cbd3724a9696 (x_window) [both versions]: Set menubar_height.
Karl Heuer <kwzh@gnu.org>
parents: 11894
diff changeset
3370 /* The menubar is part of the ordinary display;
cbd3724a9696 (x_window) [both versions]: Set menubar_height.
Karl Heuer <kwzh@gnu.org>
parents: 11894
diff changeset
3371 it does not count in addition to the height of the window. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3372 f->output_data.x->menubar_height = 0;
11897
cbd3724a9696 (x_window) [both versions]: Set menubar_height.
Karl Heuer <kwzh@gnu.org>
parents: 11894
diff changeset
3373
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
3374 /* This indicates that we use the "Passive Input" input model.
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
3375 Unless we do this, we don't get the Focus{In,Out} events that we
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
3376 need to draw the cursor correctly. Accursed bureaucrats.
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3377 XWhipsAndChains (FRAME_X_DISPLAY (f), IronMaiden, &TheRack); */
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
3378
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3379 f->output_data.x->wm_hints.input = True;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3380 f->output_data.x->wm_hints.flags |= InputHint;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3381 XSetWMHints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3382 &f->output_data.x->wm_hints);
15081
ab8c81feacf9 (x_window) [! USE_X_TOOLKIT]: Initialize wm_hints.icon_pixmap.
Richard M. Stallman <rms@gnu.org>
parents: 15079
diff changeset
3383 f->output_data.x->wm_hints.icon_pixmap = None;
7860
26a1d7b2670b (x_window): Request "save yourself" commands.
Richard M. Stallman <rms@gnu.org>
parents: 7802
diff changeset
3384
26a1d7b2670b (x_window): Request "save yourself" commands.
Richard M. Stallman <rms@gnu.org>
parents: 7802
diff changeset
3385 /* Request "save yourself" and "delete window" commands from wm. */
26a1d7b2670b (x_window): Request "save yourself" commands.
Richard M. Stallman <rms@gnu.org>
parents: 7802
diff changeset
3386 {
26a1d7b2670b (x_window): Request "save yourself" commands.
Richard M. Stallman <rms@gnu.org>
parents: 7802
diff changeset
3387 Atom protocols[2];
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3388 protocols[0] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_delete_window;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3389 protocols[1] = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_save_yourself;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3390 XSetWMProtocols (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), protocols, 2);
7860
26a1d7b2670b (x_window): Request "save yourself" commands.
Richard M. Stallman <rms@gnu.org>
parents: 7802
diff changeset
3391 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3392
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3393 /* x_set_name normally ignores requests to set the name if the
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3394 requested name is the same as the current name. This is the one
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3395 place where that assumption isn't correct; f->name is set, but
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3396 the X server hasn't been told. */
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3397 {
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
3398 Lisp_Object name;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3399 int explicit = f->explicit_name;
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3400
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
3401 f->explicit_name = 0;
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
3402 name = f->name;
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3403 f->name = Qnil;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3404 x_set_name (f, name, explicit);
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3405 }
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3406
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3407 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3408 f->output_data.x->text_cursor);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3409
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3410 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3411
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
3412 if (FRAME_X_WINDOW (f) == 0)
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3413 error ("Unable to create window");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3414 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3415
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3416 #endif /* not USE_X_TOOLKIT */
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3417
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3418 /* Handle the icon stuff for this window. Perhaps later we might
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3419 want an x_set_icon_position which can be called interactively as
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3420 well. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3421
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3422 static void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3423 x_icon (f, parms)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3424 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3425 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3426 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3427 Lisp_Object icon_x, icon_y;
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
3428 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3429
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3430 /* Set the position of the icon. Note that twm groups all
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3431 icons in an icon window. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3432 icon_x = x_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3433 icon_y = x_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3434 if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3435 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3436 CHECK_NUMBER (icon_x, 0);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3437 CHECK_NUMBER (icon_y, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3438 }
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3439 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3440 error ("Both left and top icon corners of icon must be specified");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3441
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3442 BLOCK_INPUT;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3443
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
3444 if (! EQ (icon_x, Qunbound))
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
3445 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3446
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3447 /* Start up iconic or window? */
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
3448 x_wm_set_window_state
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3449 (f, (EQ (x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3450 Qicon)
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
3451 ? IconicState
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
3452 : NormalState));
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3453
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3454 x_text_icon (f, (char *) XSTRING ((!NILP (f->icon_name)
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3455 ? f->icon_name
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3456 : f->name))->data);
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
3457
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3458 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3459 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3460
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3461 /* Make the GC's needed for this window, setting the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3462 background, border and mouse colors; also create the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3463 mouse cursor and the gray border tile. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3464
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3465 static char cursor_bits[] =
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3466 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3467 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3468 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3469 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3471 };
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3472
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3473 static void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3474 x_make_gc (f)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3475 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3476 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3477 XGCValues gc_values;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3478
2341
1982e2983822 * xfns.c (x_make_gc): Don't forget to block X input around the
Jim Blandy <jimb@redhat.com>
parents: 2328
diff changeset
3479 BLOCK_INPUT;
1982e2983822 * xfns.c (x_make_gc): Don't forget to block X input around the
Jim Blandy <jimb@redhat.com>
parents: 2328
diff changeset
3480
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3481 /* Create the GC's of this frame.
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3482 Note that many default values are used. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3483
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3484 /* Normal video */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3485 gc_values.font = f->output_data.x->font->fid;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3486 gc_values.foreground = f->output_data.x->foreground_pixel;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3487 gc_values.background = f->output_data.x->background_pixel;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3488 gc_values.line_width = 0; /* Means 1 using fast algorithm. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3489 f->output_data.x->normal_gc = XCreateGC (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
3490 FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3491 GCLineWidth | GCFont
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3492 | GCForeground | GCBackground,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3493 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3494
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3495 /* Reverse video style. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3496 gc_values.foreground = f->output_data.x->background_pixel;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3497 gc_values.background = f->output_data.x->foreground_pixel;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3498 f->output_data.x->reverse_gc = XCreateGC (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
3499 FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3500 GCFont | GCForeground | GCBackground
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3501 | GCLineWidth,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3502 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3503
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3504 /* Cursor has cursor-color background, background-color foreground. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3505 gc_values.foreground = f->output_data.x->background_pixel;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3506 gc_values.background = f->output_data.x->cursor_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3507 gc_values.fill_style = FillOpaqueStippled;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3508 gc_values.stipple
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3509 = XCreateBitmapFromData (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3510 FRAME_X_DISPLAY_INFO (f)->root_window,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3511 cursor_bits, 16, 16);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3512 f->output_data.x->cursor_gc
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3513 = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3514 (GCFont | GCForeground | GCBackground
24905
2c79eecad64d (x_make_gc): Turn off GCStipple when setting up cursor_gc.
Richard M. Stallman <rms@gnu.org>
parents: 24677
diff changeset
3515 | GCFillStyle /* | GCStipple */ | GCLineWidth),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3516 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3517
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3518 /* Reliefs. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3519 f->output_data.x->white_relief.gc = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3520 f->output_data.x->black_relief.gc = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3521
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3522 /* Create the gray border tile used when the pointer is not in
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3523 the frame. Since this depends on the frame's pixel values,
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3524 this must be done on a per-frame basis. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3525 f->output_data.x->border_tile
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
3526 = (XCreatePixmapFromBitmapData
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3527 (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
3528 gray_bits, gray_width, gray_height,
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3529 f->output_data.x->foreground_pixel,
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3530 f->output_data.x->background_pixel,
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3531 DefaultDepth (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3532 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))));
2341
1982e2983822 * xfns.c (x_make_gc): Don't forget to block X input around the
Jim Blandy <jimb@redhat.com>
parents: 2328
diff changeset
3533
1982e2983822 * xfns.c (x_make_gc): Don't forget to block X input around the
Jim Blandy <jimb@redhat.com>
parents: 2328
diff changeset
3534 UNBLOCK_INPUT;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3535 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3536
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3537 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3538 1, 1, 0,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3539 "Make a new X window, which is called a \"frame\" in Emacs terms.\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3540 Returns an Emacs frame object.\n\
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3541 ALIST is an alist of frame parameters.\n\
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3542 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
3543 and do not specify a specific minibuffer window to use,\n\
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3544 then `default-minibuffer-frame' must be a frame whose minibuffer can\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3545 be shared by the new frame.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3546 \n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3547 This function is an internal primitive--use `make-frame' instead.")
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3548 (parms)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3549 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3550 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3551 struct frame *f;
6935
675e4ec5f14f (Fx_create_frame): Delete excess args to x_wm_set_size_hint.
Richard M. Stallman <rms@gnu.org>
parents: 6882
diff changeset
3552 Lisp_Object frame, tem;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3553 Lisp_Object name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3554 int minibuffer_only = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3555 long window_prompting = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3556 int width, height;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3557 int count = specpdl_ptr - specpdl;
15566
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3558 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3559 Lisp_Object display;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3560 struct x_display_info *dpyinfo = NULL;
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3561 Lisp_Object parent;
11774
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3562 struct kboard *kb;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3563
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
3564 check_x ();
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3565
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3566 /* Use this general default value to start with
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3567 until we know if this frame has a specified name. */
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3568 Vx_resource_name = Vinvocation_name;
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3569
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3570 display = x_get_arg (dpyinfo, parms, Qdisplay, 0, 0, RES_TYPE_STRING);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3571 if (EQ (display, Qunbound))
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3572 display = Qnil;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3573 dpyinfo = check_x_display_info (display);
11774
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3574 #ifdef MULTI_KBOARD
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3575 kb = dpyinfo->kboard;
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3576 #else
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3577 kb = &the_only_kboard;
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3578 #endif
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3579
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3580 name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
3581 if (!STRINGP (name)
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3582 && ! EQ (name, Qunbound)
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3583 && ! NILP (name))
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3584 error ("Invalid frame name--not a string or nil");
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
3585
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3586 if (STRINGP (name))
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3587 Vx_resource_name = name;
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3588
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3589 /* See if parent window is specified. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3590 parent = x_get_arg (dpyinfo, parms, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3591 if (EQ (parent, Qunbound))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3592 parent = Qnil;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3593 if (! NILP (parent))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3594 CHECK_NUMBER (parent, 0);
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3595
15566
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3596 /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3597 /* No need to protect DISPLAY because that's not used after passing
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3598 it to make_frame_without_minibuffer. */
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3599 frame = Qnil;
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3600 GCPRO4 (parms, parent, name, frame);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3601 tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3602 RES_TYPE_SYMBOL);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3603 if (EQ (tem, Qnone) || NILP (tem))
12011
854e396aabed (Fx_create_frame): Pass new arg to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11989
diff changeset
3604 f = make_frame_without_minibuffer (Qnil, kb, display);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3605 else if (EQ (tem, Qonly))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3606 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3607 f = make_minibuffer_frame ();
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3608 minibuffer_only = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3609 }
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
3610 else if (WINDOWP (tem))
12011
854e396aabed (Fx_create_frame): Pass new arg to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11989
diff changeset
3611 f = make_frame_without_minibuffer (tem, kb, display);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3612 else
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3613 f = make_frame (1);
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3614
15566
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3615 XSETFRAME (frame, f);
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3616
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
3617 /* Note that X Windows does support scroll bars. */
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
3618 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
3619
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3620 f->output_method = output_x_window;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3621 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3622 bzero (f->output_data.x, sizeof (struct x_output));
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3623 f->output_data.x->icon_bitmap = -1;
19026
db6728252ce2 (Fx_create_frame): Initialize fontset in output_data.
Richard M. Stallman <rms@gnu.org>
parents: 18947
diff changeset
3624 f->output_data.x->fontset = -1;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3625 f->output_data.x->scroll_bar_foreground_pixel = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3626 f->output_data.x->scroll_bar_background_pixel = -1;
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3627
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3628 f->icon_name
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3629 = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3630 RES_TYPE_STRING);
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3631 if (! STRINGP (f->icon_name))
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3632 f->icon_name = Qnil;
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
3633
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3634 FRAME_X_DISPLAY_INFO (f) = dpyinfo;
11014
634a98104921 (Fx_create_frame): set the frame's kboard member.
Karl Heuer <kwzh@gnu.org>
parents: 10920
diff changeset
3635 #ifdef MULTI_KBOARD
11774
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3636 FRAME_KBOARD (f) = kb;
11014
634a98104921 (Fx_create_frame): set the frame's kboard member.
Karl Heuer <kwzh@gnu.org>
parents: 10920
diff changeset
3637 #endif
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3638
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3639 /* Specify the parent under which to make this X window. */
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3640
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3641 if (!NILP (parent))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3642 {
18612
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
3643 f->output_data.x->parent_desc = (Window) XFASTINT (parent);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3644 f->output_data.x->explicit_parent = 1;
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3645 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3646 else
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3647 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3648 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3649 f->output_data.x->explicit_parent = 0;
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3650 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3651
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3652 /* Set the name; the functions to which we pass f expect the name to
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3653 be set. */
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3654 if (EQ (name, Qunbound) || NILP (name))
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3655 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3656 f->name = build_string (dpyinfo->x_id_name);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3657 f->explicit_name = 0;
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3658 }
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3659 else
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3660 {
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3661 f->name = name;
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3662 f->explicit_name = 1;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3663 /* use the frame's title when getting resources for this frame. */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3664 specbind (Qx_resource_name, name);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3665 }
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3666
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3667 /* Create fontsets from `global_fontset_alist' before handling fonts. */
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
3668 for (tem = Vglobal_fontset_alist; CONSP (tem); tem = XCDR (tem))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
3669 fs_register_fontset (f, XCAR (tem));
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3670
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3671 /* Extract the window parameters from the supplied values
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3672 that are needed to determine window geometry. */
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3673 {
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3674 Lisp_Object font;
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3675
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3676 font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
18947
386d68191907 (Fx_create_frame): Don't fail to initialize `font'.
Richard M. Stallman <rms@gnu.org>
parents: 18893
diff changeset
3677
4150
e2e92cd737bf * xfns.c (Fx_create_frame): Block input around call to
Jim Blandy <jimb@redhat.com>
parents: 4146
diff changeset
3678 BLOCK_INPUT;
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3679 /* First, try whatever font the caller has specified. */
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3680 if (STRINGP (font))
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3681 {
21555
0927f341e390 (x_set_font): Give 2nd arg nil to Fquery_fontset.
Kenichi Handa <handa@m17n.org>
parents: 21549
diff changeset
3682 tem = Fquery_fontset (font, Qnil);
17722
27df69e20b98 (Fx_create_frame): Delete code for handling the X
Kenichi Handa <handa@m17n.org>
parents: 17629
diff changeset
3683 if (STRINGP (tem))
27df69e20b98 (Fx_create_frame): Delete code for handling the X
Kenichi Handa <handa@m17n.org>
parents: 17629
diff changeset
3684 font = x_new_fontset (f, XSTRING (tem)->data);
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3685 else
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3686 font = x_new_font (f, XSTRING (font)->data);
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3687 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3688
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3689 /* Try out a font which we hope has bold and italic variations. */
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3690 if (!STRINGP (font))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3691 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3692 if (!STRINGP (font))
8270
1a0af0f4fb1d (Fx_create_frame): Use 140 as default font size.
Richard M. Stallman <rms@gnu.org>
parents: 8192
diff changeset
3693 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3694 if (! STRINGP (font))
8270
1a0af0f4fb1d (Fx_create_frame): Use 140 as default font size.
Richard M. Stallman <rms@gnu.org>
parents: 8192
diff changeset
3695 font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3696 if (! STRINGP (font))
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3697 /* This was formerly the first thing tried, but it finds too many fonts
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3698 and takes too long. */
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3699 font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3700 /* If those didn't work, look for something which will at least work. */
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3701 if (! STRINGP (font))
8270
1a0af0f4fb1d (Fx_create_frame): Use 140 as default font size.
Richard M. Stallman <rms@gnu.org>
parents: 8192
diff changeset
3702 font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
4150
e2e92cd737bf * xfns.c (Fx_create_frame): Block input around call to
Jim Blandy <jimb@redhat.com>
parents: 4146
diff changeset
3703 UNBLOCK_INPUT;
e2e92cd737bf * xfns.c (Fx_create_frame): Block input around call to
Jim Blandy <jimb@redhat.com>
parents: 4146
diff changeset
3704 if (! STRINGP (font))
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3705 font = build_string ("fixed");
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3706
17722
27df69e20b98 (Fx_create_frame): Delete code for handling the X
Kenichi Handa <handa@m17n.org>
parents: 17629
diff changeset
3707 x_default_parameter (f, parms, Qfont, font,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3708 "font", "Font", RES_TYPE_STRING);
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3709 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3710
15720
f1549b7501af (Fx_create_frame): Do xlwmenu hack only if USE_LUCID.
Karl Heuer <kwzh@gnu.org>
parents: 15706
diff changeset
3711 #ifdef USE_LUCID
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
3712 /* Prevent lwlib/xlwmenu.c from crashing because of a bug
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
3713 whereby it fails to get any font. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3714 xlwmenu_default_font = f->output_data.x->font;
9808
4c43c9dbe130 (x_window): Make ibw 0 by default.
Richard M. Stallman <rms@gnu.org>
parents: 9742
diff changeset
3715 #endif
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
3716
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3717 x_default_parameter (f, parms, Qborder_width, make_number (2),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3718 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3719
3923
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3720 /* This defaults to 2 in order to match xterm. We recognize either
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3721 internalBorderWidth or internalBorder (which is what xterm calls
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3722 it). */
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3723 if (NILP (Fassq (Qinternal_border_width, parms)))
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3724 {
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3725 Lisp_Object value;
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3726
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
3727 value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3728 "internalBorder", "internalBorder", RES_TYPE_NUMBER);
3923
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3729 if (! EQ (value, Qunbound))
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3730 parms = Fcons (Fcons (Qinternal_border_width, value),
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3731 parms);
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
3732 }
16302
025b3dc7a6ba (Fx_create_frame): Default Qinternal_border_width to 1.
Richard M. Stallman <rms@gnu.org>
parents: 16254
diff changeset
3733 x_default_parameter (f, parms, Qinternal_border_width, make_number (1),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3734 "internalBorderWidth", "internalBorderWidth",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3735 RES_TYPE_NUMBER);
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
3736 x_default_parameter (f, parms, Qvertical_scroll_bars, Qleft,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3737 "verticalScrollBars", "ScrollBars",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3738 RES_TYPE_SYMBOL);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3739
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3740 /* Also do the stuff which must be set before the window exists. */
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3741 x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3742 "foreground", "Foreground", RES_TYPE_STRING);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3743 x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3744 "background", "Background", RES_TYPE_STRING);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3745 x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3746 "pointerColor", "Foreground", RES_TYPE_STRING);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3747 x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3748 "cursorColor", "Foreground", RES_TYPE_STRING);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3749 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3750 "borderColor", "BorderColor", RES_TYPE_STRING);
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
3751 x_default_parameter (f, parms, Qscreen_gamma, Qnil,
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
3752 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3753
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3754 x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3755 "scrollBarForeground",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3756 "ScrollBarForeground", 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3757 x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_background,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3758 "scrollBarBackground",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3759 "ScrollBarBackground", 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3760
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3761 /* Init faces before x_default_parameter is called for scroll-bar
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3762 parameters because that function calls x_set_scroll_bar_width,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3763 which calls change_frame_size, which calls Fset_window_buffer,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3764 which runs hooks, which call Fvertical_motion. At the end, we
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3765 end up in init_iterator with a null face cache, which should not
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3766 happen. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3767 init_frame_faces (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3768
8758
fac1c4722677 (Fx_create_frame): Make 1 the default for menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 8675
diff changeset
3769 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3770 "menuBar", "MenuBar", RES_TYPE_NUMBER);
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
3771 x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3772 "toolBar", "ToolBar", RES_TYPE_NUMBER);
9166
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
3773 x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3774 "scrollBarWidth", "ScrollBarWidth",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3775 RES_TYPE_NUMBER);
13083
16638ebb209f (Fx_create_frame): Set up buffer-predicate slot.
Richard M. Stallman <rms@gnu.org>
parents: 12832
diff changeset
3776 x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3777 "bufferPredicate", "BufferPredicate",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3778 RES_TYPE_SYMBOL);
14381
4d038c841cf4 (Qtitle): Declared.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
3779 x_default_parameter (f, parms, Qtitle, Qnil,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3780 "title", "Title", RES_TYPE_STRING);
6882
3096a6f7fffb (Fx_list_fonts): Error if non-X frame used.
Richard M. Stallman <rms@gnu.org>
parents: 6790
diff changeset
3781
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3782 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3783 window_prompting = x_figure_window_size (f, parms);
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3784
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3785 if (window_prompting & XNegative)
6935
675e4ec5f14f (Fx_create_frame): Delete excess args to x_wm_set_size_hint.
Richard M. Stallman <rms@gnu.org>
parents: 6882
diff changeset
3786 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3787 if (window_prompting & YNegative)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3788 f->output_data.x->win_gravity = SouthEastGravity;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3789 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3790 f->output_data.x->win_gravity = NorthEastGravity;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3791 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3792 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3793 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3794 if (window_prompting & YNegative)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3795 f->output_data.x->win_gravity = SouthWestGravity;
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
3796 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3797 f->output_data.x->win_gravity = NorthWestGravity;
6935
675e4ec5f14f (Fx_create_frame): Delete excess args to x_wm_set_size_hint.
Richard M. Stallman <rms@gnu.org>
parents: 6882
diff changeset
3798 }
675e4ec5f14f (Fx_create_frame): Delete excess args to x_wm_set_size_hint.
Richard M. Stallman <rms@gnu.org>
parents: 6882
diff changeset
3799
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3800 f->output_data.x->size_hint_flags = window_prompting;
7263
b7025b4bf659 (Fx_create_frame): Set the size_hint_flags field.
Richard M. Stallman <rms@gnu.org>
parents: 7261
diff changeset
3801
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3802 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3803 f->no_split = minibuffer_only || EQ (tem, Qt);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3804
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
3805 /* Create the X widget or window. Add the tool-bar height to the
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3806 initial frame height so that the user gets a text display area of
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3807 the size he specified with -g or via .Xdefaults. Later changes
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
3808 of the tool-bar height don't change the frame size. This is done
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3809 so that users can create tall Emacs frames without having to
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
3810 guess how tall the tool-bar will get. */
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
3811 f->height += FRAME_TOOL_BAR_LINES (f);
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3812
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3813 #ifdef USE_X_TOOLKIT
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3814 x_window (f, window_prompting, minibuffer_only);
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3815 #else
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3816 x_window (f);
6604
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3817 #endif
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3818
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3819 x_icon (f, parms);
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3820 x_make_gc (f);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3821
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3822 /* Now consider the frame official. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3823 FRAME_X_DISPLAY_INFO (f)->reference_count++;
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3824 Vframe_list = Fcons (frame, Vframe_list);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3825
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3826 /* We need to do this after creating the X window, so that the
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3827 icon-creation functions can say whose icon they're describing. */
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3828 x_default_parameter (f, parms, Qicon_type, Qnil,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3829 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3830
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3831 x_default_parameter (f, parms, Qauto_raise, Qnil,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3832 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3833 x_default_parameter (f, parms, Qauto_lower, Qnil,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3834 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
3835 x_default_parameter (f, parms, Qcursor_type, Qbox,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3836 "cursorType", "CursorType", RES_TYPE_SYMBOL);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3837
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3838 /* Dimensions, especially f->height, must be done via change_frame_size.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3839 Change will not be effected unless different from the current
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3840 f->height. */
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3841 width = f->width;
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3842 height = f->height;
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
3843 f->height = 0;
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
3844 SET_FRAME_WIDTH (f, 0);
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
3845 change_frame_size (f, height, width, 1, 0, 0);
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
3846
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3847 /* Set up faces after all frame parameters are known. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3848 call1 (Qface_set_after_frame_default, frame);
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
3849
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3850 #ifdef USE_X_TOOLKIT
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3851 /* Create the menu bar. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3852 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3853 {
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3854 /* If this signals an error, we haven't set size hints for the
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3855 frame and we didn't make it visible. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3856 initialize_frame_menubar (f);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3857
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3858 /* This is a no-op, except under Motif where it arranges the
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3859 main window for the widgets on it. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3860 lw_set_main_areas (f->output_data.x->column_widget,
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3861 f->output_data.x->menubar_widget,
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3862 f->output_data.x->edit_widget);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3863 }
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3864 #endif /* USE_X_TOOLKIT */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3865
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3866 /* Tell the server what size and position, etc, we want, and how
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3867 badly we want them. This should be done after we have the menu
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3868 bar so that its size can be taken into account. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3869 BLOCK_INPUT;
7209
ca5e04c9795c (Fx_create_frame): Pass 0 as 3rd arg to x_wm_set_size_hint.
Richard M. Stallman <rms@gnu.org>
parents: 7172
diff changeset
3870 x_wm_set_size_hint (f, window_prompting, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3871 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3872
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3873 /* Make the window appear on the frame and enable display, unless
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3874 the caller says not to. However, with explicit parent, Emacs
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3875 cannot control visibility, so don't try. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3876 if (! f->output_data.x->explicit_parent)
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3877 {
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3878 Lisp_Object visibility;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3879
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3880 visibility = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3881 RES_TYPE_SYMBOL);
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3882 if (EQ (visibility, Qunbound))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3883 visibility = Qt;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3884
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3885 if (EQ (visibility, Qicon))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3886 x_iconify_frame (f);
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3887 else if (! NILP (visibility))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3888 x_make_frame_visible (f);
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3889 else
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3890 /* Must have been Qnil. */
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3891 ;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3892 }
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3893
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3894 UNGCPRO;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3895 return unbind_to (count, frame);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3896 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3897
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3898 /* FRAME is used only to get a handle on the X display. We don't pass the
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3899 display info directly because we're called from frame.c, which doesn't
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3900 know about that structure. */
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
3901
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
3902 Lisp_Object
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3903 x_get_focus_frame (frame)
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3904 struct frame *frame;
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
3905 {
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3906 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (frame);
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
3907 Lisp_Object xfocus;
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3908 if (! dpyinfo->x_focus_frame)
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
3909 return Qnil;
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
3910
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
3911 XSETFRAME (xfocus, dpyinfo->x_focus_frame);
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
3912 return xfocus;
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
3913 }
3048
96ff8e5744b2 * xfns.c (select_visual): Include the screen number in the
Jim Blandy <jimb@redhat.com>
parents: 3015
diff changeset
3914
96ff8e5744b2 * xfns.c (select_visual): Include the screen number in the
Jim Blandy <jimb@redhat.com>
parents: 3015
diff changeset
3915
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3916 DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0,
11417
a5b136d16356 (Fx_color_defined_p): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 11353
diff changeset
3917 "Return non-nil if color COLOR is supported on frame FRAME.\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3918 If FRAME is omitted or nil, use the selected frame.")
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3919 (color, frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3920 Lisp_Object color, frame;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3921 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3922 XColor foo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3923 FRAME_PTR f = check_x_frame (frame);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3924
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3925 CHECK_STRING (color, 1);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3926
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3927 if (defined_color (f, XSTRING (color)->data, &foo, 0))
8675
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
3928 return Qt;
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
3929 else
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
3930 return Qnil;
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
3931 }
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
3932
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3933 DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3934 "Return a description of the color named COLOR on frame FRAME.\n\
8675
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
3935 The value is a list of integer RGB values--(RED GREEN BLUE).\n\
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3936 These values appear to range from 0 to 65280 or 65535, depending\n\
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3937 on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3938 If FRAME is omitted or nil, use the selected frame.")
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3939 (color, frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3940 Lisp_Object color, frame;
8675
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
3941 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3942 XColor foo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3943 FRAME_PTR f = check_x_frame (frame);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3944
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3945 CHECK_STRING (color, 1);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3946
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3947 if (defined_color (f, XSTRING (color)->data, &foo, 0))
8655
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3948 {
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3949 Lisp_Object rgb[3];
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3950
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3951 rgb[0] = make_number (foo.red);
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3952 rgb[1] = make_number (foo.green);
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3953 rgb[2] = make_number (foo.blue);
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3954 return Flist (3, rgb);
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
3955 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3956 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3957 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3958 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3959
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3960 DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3961 "Return t if the X display supports color.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3962 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3963 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3964 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3965 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3966 Lisp_Object display;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3967 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3968 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3969
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3970 if (dpyinfo->n_planes <= 2)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3971 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3972
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3973 switch (dpyinfo->visual->class)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3974 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3975 case StaticColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3976 case PseudoColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3977 case TrueColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3978 case DirectColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3979 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3980
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3981 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3982 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3983 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3984 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3985
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
3986 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3987 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3988 "Return t if the X display supports shades of gray.\n\
12347
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
3989 Note that color displays do support shades of gray.\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3990 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3991 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3992 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3993 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3994 Lisp_Object display;
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
3995 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3996 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3997
12347
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
3998 if (dpyinfo->n_planes <= 1)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3999 return Qnil;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4000
12347
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4001 switch (dpyinfo->visual->class)
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4002 {
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4003 case StaticColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4004 case PseudoColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4005 case TrueColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4006 case DirectColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4007 case StaticGray:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4008 case GrayScale:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4009 return Qt;
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4010
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4011 default:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4012 return Qnil;
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4013 }
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
4014 }
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
4015
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4016 DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4017 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4018 "Returns the width in pixels of the X display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4019 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4020 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4021 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4022 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4023 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4024 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4025 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4026
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4027 return make_number (dpyinfo->width);
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4028 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4029
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4030 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4031 Sx_display_pixel_height, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4032 "Returns the height in pixels of the X display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4033 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4034 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4035 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4036 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4037 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4038 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4039 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4040
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4041 return make_number (dpyinfo->height);
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4042 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4043
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4044 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4045 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4046 "Returns the number of bitplanes of the X display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4047 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4048 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4049 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4050 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4051 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4052 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4053 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4054
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4055 return make_number (dpyinfo->n_planes);
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4056 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4057
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4058 DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4059 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4060 "Returns the number of color cells of the X display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4061 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4062 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4063 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4064 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4065 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4066 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4067 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4068
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4069 return make_number (DisplayCells (dpyinfo->display,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4070 XScreenNumberOfScreen (dpyinfo->screen)));
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4071 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4072
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4073 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4074 Sx_server_max_request_size,
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4075 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4076 "Returns the maximum request size of the X server of display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4077 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4078 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4079 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4080 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4081 Lisp_Object display;
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4082 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4083 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4084
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4085 return make_number (MAXREQUEST (dpyinfo->display));
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4086 }
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4087
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4088 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4089 "Returns the vendor ID string of the X server of display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4090 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4091 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4092 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4093 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4094 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4095 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4096 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4097 char *vendor = ServerVendor (dpyinfo->display);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4098
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4099 if (! vendor) vendor = "";
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4100 return build_string (vendor);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4101 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4102
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4103 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4104 "Returns the version numbers of the X server of display DISPLAY.\n\
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4105 The value is a list of three integers: the major and minor\n\
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4106 version numbers of the X Protocol in use, and the vendor-specific release\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4107 number. See also the function `x-server-vendor'.\n\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4108 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4109 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4110 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4111 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4112 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4113 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4114 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4115 Display *dpy = dpyinfo->display;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4116
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4117 return Fcons (make_number (ProtocolVersion (dpy)),
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4118 Fcons (make_number (ProtocolRevision (dpy)),
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4119 Fcons (make_number (VendorRelease (dpy)), Qnil)));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4120 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4121
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4122 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4123 "Returns the number of screens on the X server of display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4124 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4125 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4126 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4127 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4128 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4129 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4130 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4131
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4132 return make_number (ScreenCount (dpyinfo->display));
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4133 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4134
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4135 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4136 "Returns the height in millimeters of the X display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4137 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4138 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4139 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4140 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4141 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4142 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4143 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4144
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4145 return make_number (HeightMMOfScreen (dpyinfo->screen));
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4146 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4147
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4148 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4149 "Returns the width in millimeters of the X display DISPLAY.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4150 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4151 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4152 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4153 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4154 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4155 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4156 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4157
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4158 return make_number (WidthMMOfScreen (dpyinfo->screen));
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4159 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4160
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4161 DEFUN ("x-display-backing-store", Fx_display_backing_store,
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4162 Sx_display_backing_store, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4163 "Returns an indication of whether X display DISPLAY does backing store.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4164 The value may be `always', `when-mapped', or `not-useful'.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4165 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4166 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4167 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4168 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4169 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4170 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4171 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4172
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4173 switch (DoesBackingStore (dpyinfo->screen))
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4174 {
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4175 case Always:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4176 return intern ("always");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4177
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4178 case WhenMapped:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4179 return intern ("when-mapped");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4180
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4181 case NotUseful:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4182 return intern ("not-useful");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4183
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4184 default:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4185 error ("Strange value for BackingStore parameter of screen");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4186 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4187 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4188
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4189 DEFUN ("x-display-visual-class", Fx_display_visual_class,
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4190 Sx_display_visual_class, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4191 "Returns the visual class of the X display DISPLAY.\n\
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4192 The value is one of the symbols `static-gray', `gray-scale',\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4193 `static-color', `pseudo-color', `true-color', or `direct-color'.\n\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4194 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4195 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4196 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4197 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4198 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4199 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4200 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4201
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4202 switch (dpyinfo->visual->class)
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4203 {
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4204 case StaticGray: return (intern ("static-gray"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4205 case GrayScale: return (intern ("gray-scale"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4206 case StaticColor: return (intern ("static-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4207 case PseudoColor: return (intern ("pseudo-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4208 case TrueColor: return (intern ("true-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4209 case DirectColor: return (intern ("direct-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4210 default:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4211 error ("Display has an unknown visual class");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4212 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4213 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4214
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4215 DEFUN ("x-display-save-under", Fx_display_save_under,
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4216 Sx_display_save_under, 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4217 "Returns t if the X display DISPLAY supports the save-under feature.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4218 The optional argument DISPLAY specifies which display to ask about.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4219 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4220 If omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4221 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4222 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4223 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4224 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4225
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4226 if (DoesSaveUnders (dpyinfo->screen) == True)
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4227 return Qt;
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4228 else
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4229 return Qnil;
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4230 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4231
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4232 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4233 x_pixel_width (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4234 register struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4235 {
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4236 return PIXEL_WIDTH (f);
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4237 }
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4238
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4239 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4240 x_pixel_height (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4241 register struct frame *f;
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4242 {
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4243 return PIXEL_HEIGHT (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4244 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4245
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4246 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4247 x_char_width (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4248 register struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4249 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4250 return FONT_WIDTH (f->output_data.x->font);
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4251 }
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4252
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4253 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4254 x_char_height (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4255 register struct frame *f;
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4256 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4257 return f->output_data.x->line_height;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4258 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4259
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4260 int
19825
cdfaf8ce5208 (x_screen_planes): Fix type of argument.
Richard M. Stallman <rms@gnu.org>
parents: 19095
diff changeset
4261 x_screen_planes (f)
cdfaf8ce5208 (x_screen_planes): Fix type of argument.
Richard M. Stallman <rms@gnu.org>
parents: 19095
diff changeset
4262 register struct frame *f;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4263 {
19825
cdfaf8ce5208 (x_screen_planes): Fix type of argument.
Richard M. Stallman <rms@gnu.org>
parents: 19095
diff changeset
4264 return FRAME_X_DISPLAY_INFO (f)->n_planes;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4265 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4266
689
45401d45581d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 687
diff changeset
4267 #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
4268
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4269 /* Draw a rectangle on the frame with left top corner including
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4270 the character specified by LEFT_CHAR and TOP_CHAR. The rectangle is
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4271 CHARS by LINES wide and long and is the color of the cursor. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4272
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4273 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4274 x_rectangle (f, gc, left_char, top_char, chars, lines)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4275 register struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4276 GC gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4277 register int top_char, left_char, chars, lines;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4278 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4279 int width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4280 int height;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4281 int left = (left_char * FONT_WIDTH (f->output_data.x->font)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4282 + f->output_data.x->internal_border_width);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4283 int top = (top_char * f->output_data.x->line_height
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4284 + f->output_data.x->internal_border_width);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4285
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4286 if (chars < 0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4287 width = FONT_WIDTH (f->output_data.x->font) / 2;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4288 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4289 width = FONT_WIDTH (f->output_data.x->font) * chars;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4290 if (lines < 0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4291 height = f->output_data.x->line_height / 2;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4292 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4293 height = f->output_data.x->line_height * lines;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4294
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4295 XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4296 gc, left, top, width, height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4297 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4298
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4299 DEFUN ("x-draw-rectangle", Fx_draw_rectangle, Sx_draw_rectangle, 5, 5, 0,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4300 "Draw a rectangle on FRAME between coordinates specified by\n\
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4301 numbers X0, Y0, X1, Y1 in the cursor pixel.")
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4302 (frame, X0, Y0, X1, Y1)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4303 register Lisp_Object frame, X0, X1, Y0, Y1;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4304 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4305 register int x0, y0, x1, y1, top, left, n_chars, n_lines;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4306
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4307 CHECK_LIVE_FRAME (frame, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4308 CHECK_NUMBER (X0, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4309 CHECK_NUMBER (Y0, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4310 CHECK_NUMBER (X1, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4311 CHECK_NUMBER (Y1, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4312
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4313 x0 = XINT (X0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4314 x1 = XINT (X1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4315 y0 = XINT (Y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4316 y1 = XINT (Y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4317
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4318 if (y1 > y0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4319 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4320 top = y0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4321 n_lines = y1 - y0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4322 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4323 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4324 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4325 top = y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4326 n_lines = y0 - y1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4327 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4328
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4329 if (x1 > x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4330 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4331 left = x0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4332 n_chars = x1 - x0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4333 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4334 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4335 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4336 left = x1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4337 n_chars = x0 - x1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4338 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4339
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4340 BLOCK_INPUT;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4341 x_rectangle (XFRAME (frame), XFRAME (frame)->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4342 left, top, n_chars, n_lines);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4343 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4344
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4345 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4346 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4347
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4348 DEFUN ("x-erase-rectangle", Fx_erase_rectangle, Sx_erase_rectangle, 5, 5, 0,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4349 "Draw a rectangle drawn on FRAME between coordinates\n\
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4350 X0, Y0, X1, Y1 in the regular background-pixel.")
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4351 (frame, X0, Y0, X1, Y1)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4352 register Lisp_Object frame, X0, Y0, X1, Y1;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4353 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4354 register int x0, y0, x1, y1, top, left, n_chars, n_lines;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4355
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4356 CHECK_LIVE_FRAME (frame, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4357 CHECK_NUMBER (X0, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4358 CHECK_NUMBER (Y0, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4359 CHECK_NUMBER (X1, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4360 CHECK_NUMBER (Y1, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4361
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4362 x0 = XINT (X0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4363 x1 = XINT (X1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4364 y0 = XINT (Y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4365 y1 = XINT (Y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4366
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4367 if (y1 > y0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4368 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4369 top = y0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4370 n_lines = y1 - y0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4371 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4372 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4373 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4374 top = y1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4375 n_lines = y0 - y1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4376 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4377
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4378 if (x1 > x0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4379 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4380 left = x0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4381 n_chars = x1 - x0 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4382 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4383 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4384 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4385 left = x1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4386 n_chars = x0 - x1 + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4387 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4388
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4389 BLOCK_INPUT;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4390 x_rectangle (XFRAME (frame), XFRAME (frame)->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4391 left, top, n_chars, n_lines);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4392 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4393
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4394 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4395 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4396
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4397 /* Draw lines around the text region beginning at the character position
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4398 TOP_X, TOP_Y and ending at BOTTOM_X and BOTTOM_Y. GC specifies the
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4399 pixel and line characteristics. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4400
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4401 #define line_len(line) (FRAME_CURRENT_GLYPHS (f)->used[(line)])
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4402
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4403 static void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4404 outline_region (f, gc, top_x, top_y, bottom_x, bottom_y)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4405 register struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4406 GC gc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4407 int top_x, top_y, bottom_x, bottom_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4408 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4409 register int ibw = f->output_data.x->internal_border_width;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4410 register int font_w = FONT_WIDTH (f->output_data.x->font);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4411 register int font_h = f->output_data.x->line_height;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4412 int y = top_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4413 int x = line_len (y);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
4414 XPoint *pixel_points
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
4415 = (XPoint *) alloca (((bottom_y - top_y + 2) * 4) * sizeof (XPoint));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4416 register XPoint *this_point = pixel_points;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4417
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4418 /* Do the horizontal top line/lines */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4419 if (top_x == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4420 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4421 this_point->x = ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4422 this_point->y = ibw + (font_h * top_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4423 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4424 if (x == 0)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4425 this_point->x = ibw + (font_w / 2); /* Half-size for newline chars. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4426 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4427 this_point->x = ibw + (font_w * x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4428 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4429 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4430 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4431 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4432 this_point->x = ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4433 this_point->y = ibw + (font_h * (top_y + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4434 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4435 this_point->x = ibw + (font_w * top_x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4436 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4437 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4438 this_point->x = (this_point - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4439 this_point->y = ibw + (font_h * top_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4440 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4441 this_point->x = ibw + (font_w * x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4442 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4443 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4444
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4445 /* Now do the right side. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4446 while (y < bottom_y)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4447 { /* Right vertical edge */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4448 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4449 this_point->x = (this_point - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4450 this_point->y = ibw + (font_h * (y + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4451 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4452
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4453 y++; /* Horizontal connection to next line */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4454 x = line_len (y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4455 if (x == 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4456 this_point->x = ibw + (font_w / 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4457 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4458 this_point->x = ibw + (font_w * x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4459
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4460 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4461 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4462
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4463 /* Now do the bottom and connect to the top left point. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4464 this_point->x = ibw + (font_w * (bottom_x + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4465
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4466 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4467 this_point->x = (this_point - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4468 this_point->y = ibw + (font_h * (bottom_y + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4469 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4470 this_point->x = ibw;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4471 this_point->y = (this_point - 1)->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4472 this_point++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4473 this_point->x = pixel_points->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4474 this_point->y = pixel_points->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4475
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4476 XDrawLines (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4477 gc, pixel_points,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4478 (this_point - pixel_points + 1), CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4479 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4480
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4481 DEFUN ("x-contour-region", Fx_contour_region, Sx_contour_region, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4482 "Highlight the region between point and the character under the mouse\n\
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4483 selected frame.")
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4484 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4485 register Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4486 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4487 register int x0, y0, x1, y1;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4488 register struct frame *f = selected_frame;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4489 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4490 register int p1, p2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4491
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4492 CHECK_CONS (event, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4493
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4494 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4495 x0 = XINT (Fcar (Fcar (event)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4496 y0 = XINT (Fcar (Fcdr (Fcar (event))));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4497
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4498 /* If the mouse is past the end of the line, don't that area. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4499 /* ReWrite this... */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4500
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4501 /* Where the cursor is. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4502 x1 = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4503 y1 = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4504
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4505 if (y1 > y0) /* point below mouse */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4506 outline_region (f, f->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4507 x0, y0, x1, y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4508 else if (y1 < y0) /* point above mouse */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4509 outline_region (f, f->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4510 x1, y1, x0, y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4511 else /* same line: draw horizontal rectangle */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4512 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4513 if (x1 > x0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4514 x_rectangle (f, f->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4515 x0, y0, (x1 - x0 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4516 else if (x1 < x0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4517 x_rectangle (f, f->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4518 x1, y1, (x0 - x1 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4519 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4520
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4521 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4522 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4523
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4524 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4525 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4526
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4527 DEFUN ("x-uncontour-region", Fx_uncontour_region, Sx_uncontour_region, 1, 1, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4528 "Erase any highlighting of the region between point and the character\n\
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4529 at X, Y on the selected frame.")
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4530 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4531 register Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4532 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4533 register int x0, y0, x1, y1;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4534 register struct frame *f = selected_frame;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4535 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4536
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4537 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4538 x0 = XINT (Fcar (Fcar (event)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4539 y0 = XINT (Fcar (Fcdr (Fcar (event))));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4540 x1 = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4541 y1 = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4542
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4543 if (y1 > y0) /* point below mouse */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4544 outline_region (f, f->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4545 x0, y0, x1, y1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4546 else if (y1 < y0) /* point above mouse */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4547 outline_region (f, f->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4548 x1, y1, x0, y0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4549 else /* same line: draw horizontal rectangle */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4550 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4551 if (x1 > x0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4552 x_rectangle (f, f->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4553 x0, y0, (x1 - x0 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4554 else if (x1 < x0)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4555 x_rectangle (f, f->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4556 x1, y1, (x0 - x1 + 1), 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4557 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4558 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4559
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4560 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4561 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4562
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4563 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4564 int contour_begin_x, contour_begin_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4565 int contour_end_x, contour_end_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4566 int contour_npoints;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4567
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4568 /* Clip the top part of the contour lines down (and including) line Y_POS.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4569 If X_POS is in the middle (rather than at the end) of the line, drop
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4570 down a line at that character. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4571
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4572 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4573 clip_contour_top (y_pos, x_pos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4574 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4575 register XPoint *begin = contour_lines[y_pos].top_left;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4576 register XPoint *end;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4577 register int npoints;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4578 register struct display_line *line = selected_frame->phys_lines[y_pos + 1];
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4579
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4580 if (x_pos >= line->len - 1) /* Draw one, straight horizontal line. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4581 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4582 end = contour_lines[y_pos].top_right;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4583 npoints = (end - begin + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4584 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4585 contour_erase_gc, begin_erase, npoints, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4586
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4587 bcopy (end, begin + 1, contour_last_point - end + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4588 contour_last_point -= (npoints - 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4589 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4590 contour_erase_gc, begin, 2, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4591 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4592
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4593 /* Now, update contour_lines structure. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4594 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4595 /* ______. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4596 else /* |________*/
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4597 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4598 register XPoint *p = begin + 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4599 end = contour_lines[y_pos].bottom_right;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4600 npoints = (end - begin + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4601 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4602 contour_erase_gc, begin_erase, npoints, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4603
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4604 p->y = begin->y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4605 p->x = ibw + (font_w * (x_pos + 1));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4606 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4607 p->y = begin->y + font_h;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4608 p->x = (p - 1)->x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4609 bcopy (end, begin + 3, contour_last_point - end + 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4610 contour_last_point -= (npoints - 5);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4611 XDrawLines (x_current_display, contour_window,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4612 contour_erase_gc, begin, 4, CoordModeOrigin);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4613 XFlush (x_current_display);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4614
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4615 /* Now, update contour_lines structure. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4616 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4617 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4618
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3512
diff changeset
4619 /* Erase the top horizontal lines of the contour, and then extend
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4620 the contour upwards. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4621
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4622 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4623 extend_contour_top (line)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4624 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4625 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4626
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4627 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4628 clip_contour_bottom (x_pos, y_pos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4629 int x_pos, y_pos;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4630 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4631 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4632
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4633 static void
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4634 extend_contour_bottom (x_pos, y_pos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4635 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4636 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4637
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4638 DEFUN ("x-select-region", Fx_select_region, Sx_select_region, 1, 1, "e",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4639 "")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4640 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4641 Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4642 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4643 register struct frame *f = selected_frame;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4644 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4645 register int point_x = WINDOW_TO_FRAME_PIXEL_X (w, w->cursor.x);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4646 register int point_y = WINDOW_TO_FRAME_PIXEL_Y (w, w->cursor.y);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4647 register int mouse_below_point;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4648 register Lisp_Object obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4649 register int x_contour_x, x_contour_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4650
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4651 x_contour_x = x_mouse_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4652 x_contour_y = x_mouse_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4653 if (x_contour_y > point_y || (x_contour_y == point_y
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4654 && x_contour_x > point_x))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4655 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4656 mouse_below_point = 1;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4657 outline_region (f, f->output_data.x->cursor_gc, point_x, point_y,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4658 x_contour_x, x_contour_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4659 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4660 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4661 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4662 mouse_below_point = 0;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4663 outline_region (f, f->output_data.x->cursor_gc, x_contour_x, x_contour_y,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4664 point_x, point_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4665 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4666
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4667 while (1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4668 {
1096
d79192bacdce (Fx_track_pointer): Pass new args to read_char.
Richard M. Stallman <rms@gnu.org>
parents: 1050
diff changeset
4669 obj = read_char (-1, 0, 0, Qnil, 0);
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
4670 if (!CONSP (obj))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4671 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4672
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4673 if (mouse_below_point)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4674 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4675 if (x_mouse_y <= point_y) /* Flipped. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4676 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4677 mouse_below_point = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4678
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4679 outline_region (f, f->output_data.x->reverse_gc, point_x, point_y,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4680 x_contour_x, x_contour_y);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4681 outline_region (f, f->output_data.x->cursor_gc, x_mouse_x, x_mouse_y,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4682 point_x, point_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4683 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4684 else if (x_mouse_y < x_contour_y) /* Bottom clipped. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4685 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4686 clip_contour_bottom (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4687 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4688 else if (x_mouse_y > x_contour_y) /* Bottom extended. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4689 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4690 extend_bottom_contour (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4691 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4692
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4693 x_contour_x = x_mouse_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4694 x_contour_y = x_mouse_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4695 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4696 else /* mouse above or same line as point */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4697 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4698 if (x_mouse_y >= point_y) /* Flipped. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4699 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4700 mouse_below_point = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4701
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4702 outline_region (f, f->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4703 x_contour_x, x_contour_y, point_x, point_y);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4704 outline_region (f, f->output_data.x->cursor_gc, point_x, point_y,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4705 x_mouse_x, x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4706 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4707 else if (x_mouse_y > x_contour_y) /* Top clipped. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4708 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4709 clip_contour_top (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4710 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4711 else if (x_mouse_y < x_contour_y) /* Top extended. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4712 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4713 extend_contour_top (x_mouse_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4714 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4715 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4716 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4717
1601
a371ec79bc31 * xfns.c (unread_command_char): Change name in extern declaration
Jim Blandy <jimb@redhat.com>
parents: 1528
diff changeset
4718 unread_command_event = obj;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4719 if (mouse_below_point)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4720 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4721 contour_begin_x = point_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4722 contour_begin_y = point_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4723 contour_end_x = x_contour_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4724 contour_end_y = x_contour_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4725 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4726 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4727 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4728 contour_begin_x = x_contour_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4729 contour_begin_y = x_contour_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4730 contour_end_x = point_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4731 contour_end_y = point_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4732 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4733 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4734 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4735
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4736 DEFUN ("x-horizontal-line", Fx_horizontal_line, Sx_horizontal_line, 1, 1, "e",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4737 "")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4738 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4739 Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4740 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4741 register Lisp_Object obj;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4742 struct frame *f = selected_frame;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4743 register struct window *w = XWINDOW (selected_window);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4744 register GC line_gc = f->output_data.x->cursor_gc;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4745 register GC erase_gc = f->output_data.x->reverse_gc;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4746 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4747 char dash_list[] = {6, 4, 6, 4};
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4748 int dashes = 4;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4749 XGCValues gc_values;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4750 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4751 register int previous_y;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4752 register int line = (x_mouse_y + 1) * f->output_data.x->line_height
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4753 + f->output_data.x->internal_border_width;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4754 register int left = f->output_data.x->internal_border_width
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
4755 + (WINDOW_LEFT_MARGIN (w)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4756 * FONT_WIDTH (f->output_data.x->font));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4757 register int right = left + (w->width
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4758 * FONT_WIDTH (f->output_data.x->font))
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4759 - f->output_data.x->internal_border_width;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4760
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4761 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4762 BLOCK_INPUT;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4763 gc_values.foreground = f->output_data.x->cursor_pixel;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4764 gc_values.background = f->output_data.x->background_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4765 gc_values.line_width = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4766 gc_values.line_style = LineOnOffDash;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4767 gc_values.cap_style = CapRound;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4768 gc_values.join_style = JoinRound;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4769
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4770 line_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4771 GCLineStyle | GCJoinStyle | GCCapStyle
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4772 | GCLineWidth | GCForeground | GCBackground,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4773 &gc_values);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4774 XSetDashes (FRAME_X_DISPLAY (f), line_gc, 0, dash_list, dashes);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4775 gc_values.foreground = f->output_data.x->background_pixel;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4776 gc_values.background = f->output_data.x->foreground_pixel;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4777 erase_gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4778 GCLineStyle | GCJoinStyle | GCCapStyle
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4779 | GCLineWidth | GCForeground | GCBackground,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4780 &gc_values);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4781 XSetDashes (FRAME_X_DISPLAY (f), erase_gc, 0, dash_list, dashes);
12051
f193ce9efe24 (x_destroy_bitmap): Block and unblock input.
Karl Heuer <kwzh@gnu.org>
parents: 12046
diff changeset
4782 UNBLOCK_INPUT;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4783 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4784
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4785 while (1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4786 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4787 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4788 if (x_mouse_y >= XINT (w->top)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4789 && x_mouse_y < XINT (w->top) + XINT (w->height) - 1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4790 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4791 previous_y = x_mouse_y;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4792 line = (x_mouse_y + 1) * f->output_data.x->line_height
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4793 + f->output_data.x->internal_border_width;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4794 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4795 line_gc, left, line, right, line);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4796 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4797 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4798 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4799
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4800 do
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4801 {
1096
d79192bacdce (Fx_track_pointer): Pass new args to read_char.
Richard M. Stallman <rms@gnu.org>
parents: 1050
diff changeset
4802 obj = read_char (-1, 0, 0, Qnil, 0);
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
4803 if (!CONSP (obj)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4804 || (! EQ (Fcar (Fcdr (Fcdr (obj))),
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
4805 Qvertical_scroll_bar))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4806 || x_mouse_grabbed)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4807 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4808 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4809 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4810 erase_gc, left, line, right, line);
1601
a371ec79bc31 * xfns.c (unread_command_char): Change name in extern declaration
Jim Blandy <jimb@redhat.com>
parents: 1528
diff changeset
4811 unread_command_event = obj;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4812 #if 0
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4813 XFreeGC (FRAME_X_DISPLAY (f), line_gc);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4814 XFreeGC (FRAME_X_DISPLAY (f), erase_gc);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4815 #endif
12051
f193ce9efe24 (x_destroy_bitmap): Block and unblock input.
Karl Heuer <kwzh@gnu.org>
parents: 12046
diff changeset
4816 UNBLOCK_INPUT;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4817 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4818 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4819 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4820 while (x_mouse_y == previous_y);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4821
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4822 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4823 XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4824 erase_gc, left, line, right, line);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4825 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4826 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4827 }
687
e2b747dd6a6e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 642
diff changeset
4828 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4829
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4830 #if 0
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4831 /* These keep track of the rectangle following the pointer. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4832 int mouse_track_top, mouse_track_left, mouse_track_width;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4833
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4834 /* Offset in buffer of character under the pointer, or 0. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4835 int mouse_buffer_offset;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4836
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4837 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 0, 0, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4838 "Track the pointer.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4839 ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4840 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4841 static Cursor current_pointer_shape;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4842 FRAME_PTR f = x_mouse_frame;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4843
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4844 BLOCK_INPUT;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4845 if (EQ (Vmouse_frame_part, Qtext_part)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4846 && (current_pointer_shape != f->output_data.x->nontext_cursor))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4847 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4848 unsigned char c;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4849 struct buffer *buf;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4850
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4851 current_pointer_shape = f->output_data.x->nontext_cursor;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4852 XDefineCursor (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
4853 FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4854 current_pointer_shape);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4855
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4856 buf = XBUFFER (XWINDOW (Vmouse_window)->buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4857 c = *(BUF_CHAR_ADDRESS (buf, mouse_buffer_offset));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4858 }
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4859 else if (EQ (Vmouse_frame_part, Qmodeline_part)
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4860 && (current_pointer_shape != f->output_data.x->modeline_cursor))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4861 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4862 current_pointer_shape = f->output_data.x->modeline_cursor;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4863 XDefineCursor (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
4864 FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4865 current_pointer_shape);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4866 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4867
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4868 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4869 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4870 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4871 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4872
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4873 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4874 DEFUN ("x-track-pointer", Fx_track_pointer, Sx_track_pointer, 1, 1, "e",
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4875 "Draw rectangle around character under mouse pointer, if there is one.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4876 (event)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4877 Lisp_Object event;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4878 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4879 struct window *w = XWINDOW (Vmouse_window);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4880 struct frame *f = XFRAME (WINDOW_FRAME (w));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4881 struct buffer *b = XBUFFER (w->buffer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4882 Lisp_Object obj;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4883
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4884 if (! EQ (Vmouse_window, selected_window))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4885 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4886
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4887 if (EQ (event, Qnil))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4888 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4889 int x, y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4890
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4891 x_read_mouse_position (selected_frame, &x, &y);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4892 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4893
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4894 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4895 mouse_track_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4896 mouse_track_left = mouse_track_top = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4897
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4898 do
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4899 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4900 if ((x_mouse_x != mouse_track_left
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4901 && (x_mouse_x < mouse_track_left
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4902 || x_mouse_x > (mouse_track_left + mouse_track_width)))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4903 || x_mouse_y != mouse_track_top)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4904 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4905 int hp = 0; /* Horizontal position */
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4906 int len = FRAME_CURRENT_GLYPHS (f)->used[x_mouse_y];
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4907 int p = FRAME_CURRENT_GLYPHS (f)->bufp[x_mouse_y];
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4908 int tab_width = XINT (b->tab_width);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 436
diff changeset
4909 int ctl_arrow_p = !NILP (b->ctl_arrow);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4910 unsigned char c;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4911 int mode_line_vpos = XFASTINT (w->height) + XFASTINT (w->top) - 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4912 int in_mode_line = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4913
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4914 if (! FRAME_CURRENT_GLYPHS (f)->enable[x_mouse_y])
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4915 break;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4916
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4917 /* Erase previous rectangle. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4918 if (mouse_track_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4919 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4920 x_rectangle (f, f->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4921 mouse_track_left, mouse_track_top,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4922 mouse_track_width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4923
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4924 if ((mouse_track_left == f->phys_cursor_x
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4925 || mouse_track_left == f->phys_cursor_x - 1)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4926 && mouse_track_top == f->phys_cursor_y)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4927 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4928 x_display_cursor (f, 1);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4929 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4930 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4931
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4932 mouse_track_left = x_mouse_x;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4933 mouse_track_top = x_mouse_y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4934 mouse_track_width = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4935
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4936 if (mouse_track_left > len) /* Past the end of line. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4937 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4938
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4939 if (mouse_track_top == mode_line_vpos)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4940 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4941 in_mode_line = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4942 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4943 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4944
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4945 if (tab_width <= 0 || tab_width > 20) tab_width = 8;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4946 do
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4947 {
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
4948 c = FETCH_BYTE (p);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4949 if (len == f->width && hp == len - 1 && c != '\n')
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4950 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4951
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4952 switch (c)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4953 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4954 case '\t':
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4955 mouse_track_width = tab_width - (hp % tab_width);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4956 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4957 hp += mouse_track_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4958 if (hp > x_mouse_x)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4959 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4960 mouse_track_left = hp - mouse_track_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4961 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4962 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4963 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4964
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4965 case '\n':
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4966 mouse_track_width = -1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4967 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4968
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4969 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4970 if (ctl_arrow_p && (c < 040 || c == 0177))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4971 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4972 if (p > ZV)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4973 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4974
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4975 mouse_track_width = 2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4976 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4977 hp +=2;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4978 if (hp > x_mouse_x)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4979 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4980 mouse_track_left = hp - mouse_track_width;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4981 goto draw_or_not;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4982 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4983 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4984 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4985 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4986 mouse_track_width = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4987 p++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4988 hp++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4989 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4990 continue;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4991 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4992 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4993 while (hp <= x_mouse_x);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4994
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4995 draw_or_not:
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4996 if (mouse_track_width) /* Over text; use text pointer shape. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4997 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4998 XDefineCursor (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
4999 FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
5000 f->output_data.x->text_cursor);
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
5001 x_rectangle (f, f->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5002 mouse_track_left, mouse_track_top,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5003 mouse_track_width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5004 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5005 else if (in_mode_line)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5006 XDefineCursor (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5007 FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
5008 f->output_data.x->modeline_cursor);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5009 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5010 XDefineCursor (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5011 FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
5012 f->output_data.x->nontext_cursor);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5013 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5014
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5015 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5016 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5017
1096
d79192bacdce (Fx_track_pointer): Pass new args to read_char.
Richard M. Stallman <rms@gnu.org>
parents: 1050
diff changeset
5018 obj = read_char (-1, 0, 0, Qnil, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5019 BLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5020 }
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
5021 while (CONSP (obj) /* Mouse event */
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
5022 && EQ (Fcar (Fcdr (Fcdr (obj))), Qnil) /* Not scroll bar */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5023 && EQ (Vmouse_depressed, Qnil) /* Only motion events */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5024 && EQ (Vmouse_window, selected_window) /* In this window */
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5025 && x_mouse_frame);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5026
1601
a371ec79bc31 * xfns.c (unread_command_char): Change name in extern declaration
Jim Blandy <jimb@redhat.com>
parents: 1528
diff changeset
5027 unread_command_event = obj;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5028
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5029 if (mouse_track_width)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5030 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
5031 x_rectangle (f, f->output_data.x->reverse_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5032 mouse_track_left, mouse_track_top,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5033 mouse_track_width, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5034 mouse_track_width = 0;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5035 if ((mouse_track_left == f->phys_cursor_x
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5036 || mouse_track_left - 1 == f->phys_cursor_x)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5037 && mouse_track_top == f->phys_cursor_y)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5038 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5039 x_display_cursor (f, 1);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5040 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5041 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5042 XDefineCursor (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5043 FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
5044 f->output_data.x->nontext_cursor);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5045 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5046 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5047
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5048 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5049 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5050 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5051
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5052 #if 0
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5053 #include "glyphs.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5054
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5055 /* Draw a pixmap specified by IMAGE_DATA of dimensions WIDTH and HEIGHT
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5056 on the frame F at position X, Y. */
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5057
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5058 x_draw_pixmap (f, x, y, image_data, width, height)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
5059 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5060 int x, y, width, height;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5061 char *image_data;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5062 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5063 Pixmap image;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5064
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5065 image = XCreateBitmapFromData (FRAME_X_DISPLAY (f),
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5066 FRAME_X_WINDOW (f), image_data,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5067 width, height);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5068 XCopyPlane (FRAME_X_DISPLAY (f), image, FRAME_X_WINDOW (f),
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
5069 f->output_data.x->normal_gc, 0, 0, width, height, x, y);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5070 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5071 #endif
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5072
4309
c79a44360ed9 (Fx_rebind_key, Fx_rebind_keys): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 4279
diff changeset
5073 #if 0 /* I'm told these functions are superfluous
c79a44360ed9 (Fx_rebind_key, Fx_rebind_keys): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 4279
diff changeset
5074 given the ability to bind function keys. */
c79a44360ed9 (Fx_rebind_key, Fx_rebind_keys): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 4279
diff changeset
5075
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5076 #ifdef HAVE_X11
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5077 DEFUN ("x-rebind-key", Fx_rebind_key, Sx_rebind_key, 3, 3, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5078 "Rebind X keysym KEYSYM, with MODIFIERS, to generate NEWSTRING.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5079 KEYSYM is a string which conforms to the X keysym definitions found\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5080 in X11/keysymdef.h, sans the initial XK_. MODIFIERS is nil or a\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5081 list of strings specifying modifier keys such as Control_L, which must\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5082 also be depressed for NEWSTRING to appear.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5083 (x_keysym, modifiers, newstring)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5084 register Lisp_Object x_keysym;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5085 register Lisp_Object modifiers;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5086 register Lisp_Object newstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5087 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5088 char *rawstring;
642
b0ddc138b0b5 *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 641
diff changeset
5089 register KeySym keysym;
b0ddc138b0b5 *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 641
diff changeset
5090 KeySym modifier_list[16];
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5091
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
5092 check_x ();
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5093 CHECK_STRING (x_keysym, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5094 CHECK_STRING (newstring, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5095
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5096 keysym = XStringToKeysym ((char *) XSTRING (x_keysym)->data);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5097 if (keysym == NoSymbol)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5098 error ("Keysym does not exist");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5099
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 436
diff changeset
5100 if (NILP (modifiers))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5101 XRebindKeysym (x_current_display, keysym, modifier_list, 0,
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
5102 XSTRING (newstring)->data,
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
5103 STRING_BYTES (XSTRING (newstring)));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5104 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5105 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5106 register Lisp_Object rest, mod;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5107 register int i = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5108
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 436
diff changeset
5109 for (rest = modifiers; !NILP (rest); rest = Fcdr (rest))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5110 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5111 if (i == 16)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5112 error ("Can't have more than 16 modifiers");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5113
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5114 mod = Fcar (rest);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5115 CHECK_STRING (mod, 3);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5116 modifier_list[i] = XStringToKeysym ((char *) XSTRING (mod)->data);
3692
589aaa4a815b * xfns.c [! HAVE_X11R5] (Fx_rebind_key): Recognize that
Jim Blandy <jimb@redhat.com>
parents: 3679
diff changeset
5117 #ifndef HAVE_X11R5
589aaa4a815b * xfns.c [! HAVE_X11R5] (Fx_rebind_key): Recognize that
Jim Blandy <jimb@redhat.com>
parents: 3679
diff changeset
5118 if (modifier_list[i] == NoSymbol
589aaa4a815b * xfns.c [! HAVE_X11R5] (Fx_rebind_key): Recognize that
Jim Blandy <jimb@redhat.com>
parents: 3679
diff changeset
5119 || !(IsModifierKey (modifier_list[i])
589aaa4a815b * xfns.c [! HAVE_X11R5] (Fx_rebind_key): Recognize that
Jim Blandy <jimb@redhat.com>
parents: 3679
diff changeset
5120 || ((unsigned)(modifier_list[i]) == XK_Mode_switch)
589aaa4a815b * xfns.c [! HAVE_X11R5] (Fx_rebind_key): Recognize that
Jim Blandy <jimb@redhat.com>
parents: 3679
diff changeset
5121 || ((unsigned)(modifier_list[i]) == XK_Num_Lock)))
589aaa4a815b * xfns.c [! HAVE_X11R5] (Fx_rebind_key): Recognize that
Jim Blandy <jimb@redhat.com>
parents: 3679
diff changeset
5122 #else
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5123 if (modifier_list[i] == NoSymbol
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5124 || !IsModifierKey (modifier_list[i]))
3692
589aaa4a815b * xfns.c [! HAVE_X11R5] (Fx_rebind_key): Recognize that
Jim Blandy <jimb@redhat.com>
parents: 3679
diff changeset
5125 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5126 error ("Element is not a modifier keysym");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5127 i++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5128 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5129
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5130 XRebindKeysym (x_current_display, keysym, modifier_list, i,
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
5131 XSTRING (newstring)->data,
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
5132 STRING_BYTES (XSTRING (newstring)));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5133 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5134
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5135 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5136 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5137
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5138 DEFUN ("x-rebind-keys", Fx_rebind_keys, Sx_rebind_keys, 2, 2, 0,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5139 "Rebind KEYCODE to list of strings STRINGS.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5140 STRINGS should be a list of 16 elements, one for each shift combination.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5141 nil as element means don't change.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5142 See the documentation of `x-rebind-key' for more information.")
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5143 (keycode, strings)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5144 register Lisp_Object keycode;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5145 register Lisp_Object strings;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5146 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5147 register Lisp_Object item;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5148 register unsigned char *rawstring;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5149 KeySym rawkey, modifier[1];
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5150 int strsize;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5151 register unsigned i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5152
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
5153 check_x ();
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5154 CHECK_NUMBER (keycode, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5155 CHECK_CONS (strings, 2);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5156 rawkey = (KeySym) ((unsigned) (XINT (keycode))) & 255;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5157 for (i = 0; i <= 15; strings = Fcdr (strings), i++)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5158 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5159 item = Fcar (strings);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 436
diff changeset
5160 if (!NILP (item))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5161 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5162 CHECK_STRING (item, 2);
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
5163 strsize = STRING_BYTES (XSTRING (item));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5164 rawstring = (unsigned char *) xmalloc (strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5165 bcopy (XSTRING (item)->data, rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5166 modifier[1] = 1 << i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5167 XRebindKeysym (x_current_display, rawkey, modifier, 1,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5168 rawstring, strsize);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5169 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5170 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5171 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5172 }
3141
ffe66ae9bfb3 (Fx_rebind_key, Fx_rebind_keys): X10 definitions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 3134
diff changeset
5173 #endif /* HAVE_X11 */
4309
c79a44360ed9 (Fx_rebind_key, Fx_rebind_keys): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 4279
diff changeset
5174 #endif /* 0 */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5175
4606
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5176 #ifndef HAVE_XSCREENNUMBEROFSCREEN
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5177 int
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5178 XScreenNumberOfScreen (scr)
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5179 register Screen *scr;
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5180 {
4771
d6ddaf79ea6a (XScreenNumberOfScreen): Move assignments out of declaration for (dpy,
Brian Fox <bfox@gnu.org>
parents: 4696
diff changeset
5181 register Display *dpy;
d6ddaf79ea6a (XScreenNumberOfScreen): Move assignments out of declaration for (dpy,
Brian Fox <bfox@gnu.org>
parents: 4696
diff changeset
5182 register Screen *dpyscr;
4606
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5183 register int i;
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5184
4771
d6ddaf79ea6a (XScreenNumberOfScreen): Move assignments out of declaration for (dpy,
Brian Fox <bfox@gnu.org>
parents: 4696
diff changeset
5185 dpy = scr->display;
d6ddaf79ea6a (XScreenNumberOfScreen): Move assignments out of declaration for (dpy,
Brian Fox <bfox@gnu.org>
parents: 4696
diff changeset
5186 dpyscr = dpy->screens;
d6ddaf79ea6a (XScreenNumberOfScreen): Move assignments out of declaration for (dpy,
Brian Fox <bfox@gnu.org>
parents: 4696
diff changeset
5187
4606
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5188 for (i = 0; i < dpy->nscreens; i++, dpyscr++)
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5189 if (scr == dpyscr)
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5190 return i;
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5191
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5192 return -1;
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5193 }
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5194 #endif /* not HAVE_XSCREENNUMBEROFSCREEN */
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
5195
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5196 Visual *
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5197 select_visual (dpy, screen, depth)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5198 Display *dpy;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5199 Screen *screen;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5200 unsigned int *depth;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5201 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5202 Visual *v;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5203 XVisualInfo *vinfo, vinfo_template;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5204 int n_visuals;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5205
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5206 v = DefaultVisualOfScreen (screen);
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5207
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5208 #ifdef HAVE_X11R4
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5209 vinfo_template.visualid = XVisualIDFromVisual (v);
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5210 #else
2341
1982e2983822 * xfns.c (x_make_gc): Don't forget to block X input around the
Jim Blandy <jimb@redhat.com>
parents: 2328
diff changeset
5211 vinfo_template.visualid = v->visualid;
1050
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5212 #endif
133bad38bde1 * xfns.c (x_icon): Don't call x_wm_set_icon_positions if the user
Jim Blandy <jimb@redhat.com>
parents: 1018
diff changeset
5213
3048
96ff8e5744b2 * xfns.c (select_visual): Include the screen number in the
Jim Blandy <jimb@redhat.com>
parents: 3015
diff changeset
5214 vinfo_template.screen = XScreenNumberOfScreen (screen);
96ff8e5744b2 * xfns.c (select_visual): Include the screen number in the
Jim Blandy <jimb@redhat.com>
parents: 3015
diff changeset
5215
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5216 vinfo = XGetVisualInfo (dpy,
3048
96ff8e5744b2 * xfns.c (select_visual): Include the screen number in the
Jim Blandy <jimb@redhat.com>
parents: 3015
diff changeset
5217 VisualIDMask | VisualScreenMask, &vinfo_template,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5218 &n_visuals);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5219 if (n_visuals != 1)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5220 fatal ("Can't get proper X visual info");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5221
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5222 if ((1 << vinfo->depth) == vinfo->colormap_size)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5223 *depth = vinfo->depth;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5224 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5225 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5226 int i = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5227 int n = vinfo->colormap_size - 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5228 while (n)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5229 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5230 n = n >> 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5231 i++;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5232 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5233 *depth = i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5234 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5235
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5236 XFree ((char *) vinfo);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5237 return v;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5238 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5239
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5240 /* Return the X display structure for the display named NAME.
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5241 Open a new connection if necessary. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5242
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5243 struct x_display_info *
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5244 x_display_info_for_name (name)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5245 Lisp_Object name;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5246 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5247 Lisp_Object names;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5248 struct x_display_info *dpyinfo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5249
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5250 CHECK_STRING (name, 0);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5251
12381
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
5252 if (! EQ (Vwindow_system, intern ("x")))
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
5253 error ("Not using X Windows");
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
5254
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5255 for (dpyinfo = x_display_list, names = x_display_name_list;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5256 dpyinfo;
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
5257 dpyinfo = dpyinfo->next, names = XCDR (names))
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5258 {
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5259 Lisp_Object tem;
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
5260 tem = Fstring_equal (XCAR (XCAR (names)), name);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5261 if (!NILP (tem))
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5262 return dpyinfo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5263 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5264
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
5265 /* Use this general default value to start with. */
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
5266 Vx_resource_name = Vinvocation_name;
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
5267
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5268 validate_x_resource_name ();
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5269
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5270 dpyinfo = x_term_init (name, (unsigned char *)0,
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
5271 (char *) XSTRING (Vx_resource_name)->data);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5272
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5273 if (dpyinfo == 0)
12046
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
5274 error ("Cannot connect to X server %s", XSTRING (name)->data);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5275
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5276 x_in_use = 1;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5277 XSETFASTINT (Vwindow_system_version, 11);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5278
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5279 return dpyinfo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5280 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5281
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5282 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5283 1, 3, 0, "Open a connection to an X server.\n\
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5284 DISPLAY is the name of the display to connect to.\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5285 Optional second arg XRM-STRING is a string of resources in xrdb format.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5286 If the optional third arg MUST-SUCCEED is non-nil,\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5287 terminate Emacs if we can't open the connection.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5288 (display, xrm_string, must_succeed)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5289 Lisp_Object display, xrm_string, must_succeed;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5290 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5291 unsigned char *xrm_option;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5292 struct x_display_info *dpyinfo;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5293
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5294 CHECK_STRING (display, 0);
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5295 if (! NILP (xrm_string))
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5296 CHECK_STRING (xrm_string, 1);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5297
12381
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
5298 if (! EQ (Vwindow_system, intern ("x")))
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
5299 error ("Not using X Windows");
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
5300
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5301 if (! NILP (xrm_string))
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5302 xrm_option = (unsigned char *) XSTRING (xrm_string)->data;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5303 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5304 xrm_option = (unsigned char *) 0;
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5305
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5306 validate_x_resource_name ();
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
5307
7802
d687e885fa6a (Fx_open_connection): Set up Vx_resource_name and xrm_option
Richard M. Stallman <rms@gnu.org>
parents: 7797
diff changeset
5308 /* This is what opens the connection and sets x_current_display.
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5309 This also initializes many symbols, such as those used for input. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5310 dpyinfo = x_term_init (display, xrm_option,
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
5311 (char *) XSTRING (Vx_resource_name)->data);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5312
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5313 if (dpyinfo == 0)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5314 {
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5315 if (!NILP (must_succeed))
12046
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
5316 fatal ("Cannot connect to X server %s.\n\
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
5317 Check the DISPLAY environment variable or use `-d'.\n\
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
5318 Also use the `xhost' program to verify that it is set to permit\n\
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
5319 connections from your machine.\n",
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5320 XSTRING (display)->data);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5321 else
12046
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
5322 error ("Cannot connect to X server %s", XSTRING (display)->data);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5323 }
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5324
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5325 x_in_use = 1;
7802
d687e885fa6a (Fx_open_connection): Set up Vx_resource_name and xrm_option
Richard M. Stallman <rms@gnu.org>
parents: 7797
diff changeset
5326
9327
b3398cf56fba (Fx_open_connection): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9285
diff changeset
5327 XSETFASTINT (Vwindow_system_version, 11);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5328 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5329 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5330
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5331 DEFUN ("x-close-connection", Fx_close_connection,
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5332 Sx_close_connection, 1, 1, 0,
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5333 "Close the connection to DISPLAY's X server.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5334 For DISPLAY, specify either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5335 If DISPLAY is nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5336 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5337 Lisp_Object display;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5338 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5339 struct x_display_info *dpyinfo = check_x_display_info (display);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5340 int i;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5341
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5342 if (dpyinfo->reference_count > 0)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5343 error ("Display still has frames on it");
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5344
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5345 BLOCK_INPUT;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5346 /* Free the fonts in the font table. */
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5347 for (i = 0; i < dpyinfo->n_fonts; i++)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5348 if (dpyinfo->font_table[i].name)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5349 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5350 xfree (dpyinfo->font_table[i].name);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5351 /* Don't free the full_name string;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5352 it is always shared with something else. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5353 XFreeFont (dpyinfo->display, dpyinfo->font_table[i].font);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5354 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5355
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5356 x_destroy_all_bitmaps (dpyinfo);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5357 XSetCloseDownMode (dpyinfo->display, DestroyAll);
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
5358
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
5359 #ifdef USE_X_TOOLKIT
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
5360 XtCloseDisplay (dpyinfo->display);
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
5361 #else
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5362 XCloseDisplay (dpyinfo->display);
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
5363 #endif
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5364
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5365 x_delete_display (dpyinfo);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5366 UNBLOCK_INPUT;
8782
51241477cfc5 Delete X11 conditionals.
Richard M. Stallman <rms@gnu.org>
parents: 8780
diff changeset
5367
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5368 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5369 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5370
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5371 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5372 "Return the list of display names that Emacs has connections to.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5373 ()
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5374 {
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5375 Lisp_Object tail, result;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5376
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5377 result = Qnil;
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
5378 for (tail = x_display_name_list; ! NILP (tail); tail = XCDR (tail))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
5379 result = Fcons (XCAR (XCAR (tail)), result);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5380
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5381 return result;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5382 }
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5383
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5384 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5385 "If ON is non-nil, report X errors as soon as the erring request is made.\n\
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5386 If ON is nil, allow buffering of requests.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5387 Turning on synchronization prohibits the Xlib routines from buffering\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5388 requests and seriously degrades performance, but makes debugging much\n\
10080
2e1987a4de30 (Fx_synchronize): Fix doc string syntax.
Richard M. Stallman <rms@gnu.org>
parents: 9956
diff changeset
5389 easier.\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5390 The optional second argument DISPLAY specifies which display to act on.\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5391 DISPLAY should be either a frame or a display name (a string).\n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5392 If DISPLAY is omitted or nil, that stands for the selected frame's display.")
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5393 (on, display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5394 Lisp_Object display, on;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5395 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
5396 struct x_display_info *dpyinfo = check_x_display_info (display);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5397
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5398 XSynchronize (dpyinfo->display, !EQ (on, Qnil));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5399
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5400 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5401 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5402
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5403 /* Wait for responses to all X commands issued so far for frame F. */
5536
f900f7bba4c2 (x_sync): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5429
diff changeset
5404
f900f7bba4c2 (x_sync): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5429
diff changeset
5405 void
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5406 x_sync (f)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5407 FRAME_PTR f;
5536
f900f7bba4c2 (x_sync): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5429
diff changeset
5408 {
5558
42ec75481b8b (x_sync): Block input.
Richard M. Stallman <rms@gnu.org>
parents: 5536
diff changeset
5409 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
5410 XSync (FRAME_X_DISPLAY (f), False);
5558
42ec75481b8b (x_sync): Block input.
Richard M. Stallman <rms@gnu.org>
parents: 5536
diff changeset
5411 UNBLOCK_INPUT;
5536
f900f7bba4c2 (x_sync): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5429
diff changeset
5412 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5413
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5414
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5415 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5416 Image types
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5417 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5418
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5419 /* Value is the number of elements of vector VECTOR. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5420
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5421 #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5422
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5423 /* List of supported image types. Use define_image_type to add new
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5424 types. Use lookup_image_type to find a type for a given symbol. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5425
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5426 static struct image_type *image_types;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5427
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5428 /* A list of symbols, one for each supported image type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5429
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5430 Lisp_Object Vimage_types;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5431
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5432 /* The symbol `image' which is the car of the lists used to represent
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5433 images in Lisp. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5434
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5435 extern Lisp_Object Qimage;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5436
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5437 /* The symbol `xbm' which is used as the type symbol for XBM images. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5438
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5439 Lisp_Object Qxbm;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5440
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5441 /* Keywords. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5442
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
5443 Lisp_Object QCtype, QCdata, QCascent, QCmargin, QCrelief;
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
5444 extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5445 Lisp_Object QCalgorithm, QCcolor_symbols, QCheuristic_mask;
25620
1c991744ce13 (QCindex): New.
Gerd Moellmann <gerd@gnu.org>
parents: 25593
diff changeset
5446 Lisp_Object QCindex;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5447
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5448 /* Other symbols. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5449
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5450 Lisp_Object Qlaplace;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5451
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5452 /* Time in seconds after which images should be removed from the cache
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5453 if not displayed. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5454
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
5455 Lisp_Object Vimage_cache_eviction_delay;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5456
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5457 /* Function prototypes. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5458
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5459 static void define_image_type P_ ((struct image_type *type));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5460 static struct image_type *lookup_image_type P_ ((Lisp_Object symbol));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5461 static void image_error P_ ((char *format, Lisp_Object, Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5462 static void x_laplace P_ ((struct frame *, struct image *));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5463 static int x_build_heuristic_mask P_ ((struct frame *, Lisp_Object,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5464 struct image *, Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5465
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5466
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5467 /* Define a new image type from TYPE. This adds a copy of TYPE to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5468 image_types and adds the symbol *TYPE->type to Vimage_types. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5469
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5470 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5471 define_image_type (type)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5472 struct image_type *type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5473 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5474 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5475 The initialized data segment is read-only. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5476 struct image_type *p = (struct image_type *) xmalloc (sizeof *p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5477 bcopy (type, p, sizeof *p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5478 p->next = image_types;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5479 image_types = p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5480 Vimage_types = Fcons (*p->type, Vimage_types);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5481 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5482
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5483
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5484 /* Look up image type SYMBOL, and return a pointer to its image_type
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5485 structure. Value is null if SYMBOL is not a known image type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5486
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5487 static INLINE struct image_type *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5488 lookup_image_type (symbol)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5489 Lisp_Object symbol;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5490 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5491 struct image_type *type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5492
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5493 for (type = image_types; type; type = type->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5494 if (EQ (symbol, *type->type))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5495 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5496
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5497 return type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5498 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5499
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5500
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5501 /* Value is non-zero if OBJECT is a valid Lisp image specification. A
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5502 valid image specification is a list whose car is the symbol
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5503 `image', and whose rest is a property list. The property list must
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5504 contain a value for key `:type'. That value must be the name of a
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5505 supported image type. The rest of the property list depends on the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5506 image type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5507
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5508 int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5509 valid_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5510 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5511 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5512 int valid_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5513
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5514 if (CONSP (object) && EQ (XCAR (object), Qimage))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5515 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5516 Lisp_Object symbol = Fplist_get (XCDR (object), QCtype);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5517 struct image_type *type = lookup_image_type (symbol);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5518
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5519 if (type)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5520 valid_p = type->valid_p (object);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5521 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5522
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5523 return valid_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5524 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5525
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5526
25800
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
5527 /* Log error message with format string FORMAT and argument ARG.
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
5528 Signaling an error, e.g. when an image cannot be loaded, is not a
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
5529 good idea because this would interrupt redisplay, and the error
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
5530 message display would lead to another redisplay. This function
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
5531 therefore simply displays a message. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5532
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5533 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5534 image_error (format, arg1, arg2)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5535 char *format;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5536 Lisp_Object arg1, arg2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5537 {
25800
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
5538 add_to_log (format, arg1, arg2);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5539 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5540
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5541
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5542
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5543 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5544 Image specifications
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5545 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5546
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5547 enum image_value_type
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5548 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5549 IMAGE_DONT_CHECK_VALUE_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5550 IMAGE_STRING_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5551 IMAGE_SYMBOL_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5552 IMAGE_POSITIVE_INTEGER_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5553 IMAGE_NON_NEGATIVE_INTEGER_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5554 IMAGE_INTEGER_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5555 IMAGE_FUNCTION_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5556 IMAGE_NUMBER_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5557 IMAGE_BOOL_VALUE
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5558 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5559
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5560 /* Structure used when parsing image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5561
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5562 struct image_keyword
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5563 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5564 /* Name of keyword. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5565 char *name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5566
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5567 /* The type of value allowed. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5568 enum image_value_type type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5569
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5570 /* Non-zero means key must be present. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5571 int mandatory_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5572
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5573 /* Used to recognize duplicate keywords in a property list. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5574 int count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5575
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5576 /* The value that was found. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5577 Lisp_Object value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5578 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5579
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5580
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5581 static int parse_image_spec P_ ((Lisp_Object spec,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5582 struct image_keyword *keywords,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5583 int nkeywords, Lisp_Object type,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5584 int allow_other_keys_p));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5585 static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5586
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5587
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5588 /* Parse image spec SPEC according to KEYWORDS. A valid image spec
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5589 has the format (image KEYWORD VALUE ...). One of the keyword/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5590 value pairs must be `:type TYPE'. KEYWORDS is a vector of
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5591 image_keywords structures of size NKEYWORDS describing other
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5592 allowed keyword/value pairs. ALLOW_OTHER_KEYS_P non-zero means
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5593 allow KEYWORD/VALUE pairs other than those described by KEYWORDS
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5594 without checking them. Value is non-zero if SPEC is valid. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5595
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5596 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5597 parse_image_spec (spec, keywords, nkeywords, type, allow_other_keys_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5598 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5599 struct image_keyword *keywords;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5600 int nkeywords;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5601 Lisp_Object type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5602 int allow_other_keys_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5603 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5604 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5605 Lisp_Object plist;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5606
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5607 if (!CONSP (spec) || !EQ (XCAR (spec), Qimage))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5608 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5609
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5610 plist = XCDR (spec);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5611 while (CONSP (plist))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5612 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5613 Lisp_Object key, value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5614
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5615 /* First element of a pair must be a symbol. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5616 key = XCAR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5617 plist = XCDR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5618 if (!SYMBOLP (key))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5619 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5620
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5621 /* There must follow a value. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5622 if (!CONSP (plist))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5623 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5624 value = XCAR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5625 plist = XCDR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5626
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5627 /* Find key in KEYWORDS. Error if not found. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5628 for (i = 0; i < nkeywords; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5629 if (strcmp (keywords[i].name, XSYMBOL (key)->name->data) == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5630 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5631
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5632 if (i == nkeywords)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5633 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5634 if (!allow_other_keys_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5635 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5636 continue;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5637 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5638
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5639 /* Record that we recognized the keyword. If a keywords
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5640 was found more than once, it's an error. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5641 keywords[i].value = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5642 ++keywords[i].count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5643
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5644 if (keywords[i].count > 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5645 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5646
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5647 /* Check type of value against allowed type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5648 switch (keywords[i].type)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5649 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5650 case IMAGE_STRING_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5651 if (!STRINGP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5652 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5653 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5654
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5655 case IMAGE_SYMBOL_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5656 if (!SYMBOLP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5657 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5658 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5659
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5660 case IMAGE_POSITIVE_INTEGER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5661 if (!INTEGERP (value) || XINT (value) <= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5662 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5663 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5664
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5665 case IMAGE_NON_NEGATIVE_INTEGER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5666 if (!INTEGERP (value) || XINT (value) < 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5667 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5668 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5669
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5670 case IMAGE_DONT_CHECK_VALUE_TYPE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5671 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5672
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5673 case IMAGE_FUNCTION_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5674 value = indirect_function (value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5675 if (SUBRP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5676 || COMPILEDP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5677 || (CONSP (value) && EQ (XCAR (value), Qlambda)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5678 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5679 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5680
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5681 case IMAGE_NUMBER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5682 if (!INTEGERP (value) && !FLOATP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5683 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5684 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5685
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5686 case IMAGE_INTEGER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5687 if (!INTEGERP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5688 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5689 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5690
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5691 case IMAGE_BOOL_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5692 if (!NILP (value) && !EQ (value, Qt))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5693 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5694 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5695
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5696 default:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5697 abort ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5698 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5699 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5700
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5701 if (EQ (key, QCtype) && !EQ (type, value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5702 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5703 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5704
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5705 /* Check that all mandatory fields are present. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5706 for (i = 0; i < nkeywords; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5707 if (keywords[i].mandatory_p && keywords[i].count == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5708 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5709
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5710 return NILP (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5711 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5712
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5713
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5714 /* Return the value of KEY in image specification SPEC. Value is nil
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5715 if KEY is not present in SPEC. if FOUND is not null, set *FOUND
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5716 to 1 if KEY was found in SPEC, set it to 0 otherwise. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5717
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5718 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5719 image_spec_value (spec, key, found)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5720 Lisp_Object spec, key;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5721 int *found;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5722 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5723 Lisp_Object tail;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5724
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5725 xassert (valid_image_p (spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5726
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5727 for (tail = XCDR (spec);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5728 CONSP (tail) && CONSP (XCDR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5729 tail = XCDR (XCDR (tail)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5730 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5731 if (EQ (XCAR (tail), key))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5732 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5733 if (found)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5734 *found = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5735 return XCAR (XCDR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5736 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5737 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5738
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5739 if (found)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5740 *found = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5741 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5742 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5743
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5744
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5745
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5746
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5747 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5748 Image type independent image structures
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5749 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5750
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5751 static struct image *make_image P_ ((Lisp_Object spec, unsigned hash));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5752 static void free_image P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5753
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5754
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5755 /* Allocate and return a new image structure for image specification
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5756 SPEC. SPEC has a hash value of HASH. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5757
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5758 static struct image *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5759 make_image (spec, hash)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5760 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5761 unsigned hash;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5762 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5763 struct image *img = (struct image *) xmalloc (sizeof *img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5764
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5765 xassert (valid_image_p (spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5766 bzero (img, sizeof *img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5767 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5768 xassert (img->type != NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5769 img->spec = spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5770 img->data.lisp_val = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5771 img->ascent = DEFAULT_IMAGE_ASCENT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5772 img->hash = hash;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5773 return img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5774 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5775
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5776
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5777 /* Free image IMG which was used on frame F, including its resources. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5778
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5779 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5780 free_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5781 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5782 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5783 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5784 if (img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5785 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5786 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5787
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5788 /* Remove IMG from the hash table of its cache. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5789 if (img->prev)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5790 img->prev->next = img->next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5791 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5792 c->buckets[img->hash % IMAGE_CACHE_BUCKETS_SIZE] = img->next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5793
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5794 if (img->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5795 img->next->prev = img->prev;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5796
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5797 c->images[img->id] = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5798
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5799 /* Free resources, then free IMG. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5800 img->type->free (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5801 xfree (img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5802 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5803 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5804
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5805
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5806 /* Prepare image IMG for display on frame F. Must be called before
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5807 drawing an image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5808
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5809 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5810 prepare_image_for_display (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5811 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5812 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5813 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5814 EMACS_TIME t;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5815
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5816 /* We're about to display IMG, so set its timestamp to `now'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5817 EMACS_GET_TIME (t);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5818 img->timestamp = EMACS_SECS (t);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5819
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5820 /* If IMG doesn't have a pixmap yet, load it now, using the image
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5821 type dependent loader function. */
25955
3daaee890b1e (prepare_image_for_display): Don't try to load image if
Gerd Moellmann <gerd@gnu.org>
parents: 25817
diff changeset
5822 if (img->pixmap == 0 && !img->load_failed_p)
3daaee890b1e (prepare_image_for_display): Don't try to load image if
Gerd Moellmann <gerd@gnu.org>
parents: 25817
diff changeset
5823 img->load_failed_p = img->type->load (f, img) == 0;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5824 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5825
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5826
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5827
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5828 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5829 Helper functions for X image types
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5830 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5831
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5832 static void x_clear_image P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5833 static unsigned long x_alloc_image_color P_ ((struct frame *f,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5834 struct image *img,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5835 Lisp_Object color_name,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5836 unsigned long dflt));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5837
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5838 /* Free X resources of image IMG which is used on frame F. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5839
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5840 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5841 x_clear_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5842 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5843 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5844 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5845 if (img->pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5846 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5847 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5848 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5849 img->pixmap = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5850 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5851 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5852
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5853 if (img->ncolors)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5854 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5855 int class = FRAME_X_DISPLAY_INFO (f)->visual->class;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5856
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5857 /* If display has an immutable color map, freeing colors is not
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5858 necessary and some servers don't allow it. So don't do it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5859 if (class != StaticColor
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5860 && class != StaticGray
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5861 && class != TrueColor)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5862 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5863 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5864 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5865 cmap = DefaultColormapOfScreen (FRAME_X_DISPLAY_INFO (f)->screen);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5866 XFreeColors (FRAME_X_DISPLAY (f), cmap, img->colors,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5867 img->ncolors, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5868 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5869 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5870
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5871 xfree (img->colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5872 img->colors = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5873 img->ncolors = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5874 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5875 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5876
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5877
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5878 /* Allocate color COLOR_NAME for image IMG on frame F. If color
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5879 cannot be allocated, use DFLT. Add a newly allocated color to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5880 IMG->colors, so that it can be freed again. Value is the pixel
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5881 color. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5882
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5883 static unsigned long
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5884 x_alloc_image_color (f, img, color_name, dflt)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5885 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5886 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5887 Lisp_Object color_name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5888 unsigned long dflt;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5889 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5890 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5891 unsigned long result;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5892
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5893 xassert (STRINGP (color_name));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5894
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5895 if (defined_color (f, XSTRING (color_name)->data, &color, 1))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5896 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5897 /* This isn't called frequently so we get away with simply
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5898 reallocating the color vector to the needed size, here. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5899 ++img->ncolors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5900 img->colors =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5901 (unsigned long *) xrealloc (img->colors,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5902 img->ncolors * sizeof *img->colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5903 img->colors[img->ncolors - 1] = color.pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5904 result = color.pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5905 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5906 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5907 result = dflt;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5908
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5909 return result;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5910 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5911
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5912
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5913
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5914 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5915 Image Cache
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5916 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5917
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5918 static void cache_image P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5919
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5920
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5921 /* Return a new, initialized image cache that is allocated from the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5922 heap. Call free_image_cache to free an image cache. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5923
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5924 struct image_cache *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5925 make_image_cache ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5926 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5927 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5928 int size;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5929
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5930 bzero (c, sizeof *c);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5931 c->size = 50;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5932 c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5933 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5934 c->buckets = (struct image **) xmalloc (size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5935 bzero (c->buckets, size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5936 return c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5937 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5938
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5939
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5940 /* Free image cache of frame F. Be aware that X frames share images
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5941 caches. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5942
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5943 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5944 free_image_cache (f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5945 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5946 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5947 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5948 if (c)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5949 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5950 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5951
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5952 /* Cache should not be referenced by any frame when freed. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5953 xassert (c->refcount == 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5954
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5955 for (i = 0; i < c->used; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5956 free_image (f, c->images[i]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5957 xfree (c->images);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5958 xfree (c);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5959 xfree (c->buckets);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5960 FRAME_X_IMAGE_CACHE (f) = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5961 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5962 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5963
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5964
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5965 /* Clear image cache of frame F. FORCE_P non-zero means free all
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5966 images. FORCE_P zero means clear only images that haven't been
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5967 displayed for some time. Should be called from time to time to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5968 reduce the number of loaded images. If image-eviction-seconds is
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5969 non-nil, this frees images in the cache which weren't displayed for
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5970 at least that many seconds. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5971
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5972 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5973 clear_image_cache (f, force_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5974 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5975 int force_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5976 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5977 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5978
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
5979 if (c && INTEGERP (Vimage_cache_eviction_delay))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5980 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5981 EMACS_TIME t;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5982 unsigned long old;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5983 int i, any_freed_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5984
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5985 EMACS_GET_TIME (t);
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
5986 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5987
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5988 for (i = 0; i < c->used; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5989 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5990 struct image *img = c->images[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5991 if (img != NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5992 && (force_p
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5993 || (img->timestamp > old)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5994 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5995 free_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5996 any_freed_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5997 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5998 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5999
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6000 /* We may be clearing the image cache because, for example,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6001 Emacs was iconified for a longer period of time. In that
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6002 case, current matrices may still contain references to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6003 images freed above. So, clear these matrices. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6004 if (any_freed_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6005 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6006 clear_current_matrices (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6007 ++windows_or_buffers_changed;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6008 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6009 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6010 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6011
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6012
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6013 DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6014 0, 1, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6015 "Clear the image cache of FRAME.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6016 FRAME nil or omitted means use the selected frame.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6017 FRAME t means clear the image caches of all frames.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6018 (frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6019 Lisp_Object frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6020 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6021 if (EQ (frame, Qt))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6022 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6023 Lisp_Object tail;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6024
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6025 FOR_EACH_FRAME (tail, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6026 if (FRAME_X_P (XFRAME (frame)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6027 clear_image_cache (XFRAME (frame), 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6028 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6029 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6030 clear_image_cache (check_x_frame (frame), 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6031
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6032 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6033 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6034
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6035
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6036 /* Return the id of image with Lisp specification SPEC on frame F.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6037 SPEC must be a valid Lisp image specification (see valid_image_p). */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6038
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6039 int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6040 lookup_image (f, spec)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6041 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6042 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6043 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6044 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6045 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6046 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6047 unsigned hash;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6048 struct gcpro gcpro1;
25817
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
6049 EMACS_TIME now;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6050
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6051 /* F must be a window-system frame, and SPEC must be a valid image
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6052 specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6053 xassert (FRAME_WINDOW_P (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6054 xassert (valid_image_p (spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6055
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6056 GCPRO1 (spec);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6057
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6058 /* Look up SPEC in the hash table of the image cache. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6059 hash = sxhash (spec, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6060 i = hash % IMAGE_CACHE_BUCKETS_SIZE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6061
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6062 for (img = c->buckets[i]; img; img = img->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6063 if (img->hash == hash && !NILP (Fequal (img->spec, spec)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6064 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6065
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6066 /* If not found, create a new image and cache it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6067 if (img == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6068 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6069 img = make_image (spec, hash);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6070 cache_image (f, img);
25955
3daaee890b1e (prepare_image_for_display): Don't try to load image if
Gerd Moellmann <gerd@gnu.org>
parents: 25817
diff changeset
6071 img->load_failed_p = img->type->load (f, img) == 0;
3daaee890b1e (prepare_image_for_display): Don't try to load image if
Gerd Moellmann <gerd@gnu.org>
parents: 25817
diff changeset
6072 xassert (!interrupt_input_blocked);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6073
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6074 /* If we can't load the image, and we don't have a width and
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6075 height, use some arbitrary width and height so that we can
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6076 draw a rectangle for it. */
25955
3daaee890b1e (prepare_image_for_display): Don't try to load image if
Gerd Moellmann <gerd@gnu.org>
parents: 25817
diff changeset
6077 if (img->load_failed_p)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6078 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6079 Lisp_Object value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6080
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6081 value = image_spec_value (spec, QCwidth, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6082 img->width = (INTEGERP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6083 ? XFASTINT (value) : DEFAULT_IMAGE_WIDTH);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6084 value = image_spec_value (spec, QCheight, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6085 img->height = (INTEGERP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6086 ? XFASTINT (value) : DEFAULT_IMAGE_HEIGHT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6087 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6088 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6089 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6090 /* Handle image type independent image attributes
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6091 `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6092 Lisp_Object ascent, margin, relief, algorithm, heuristic_mask;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6093 Lisp_Object file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6094
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6095 ascent = image_spec_value (spec, QCascent, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6096 if (INTEGERP (ascent))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6097 img->ascent = XFASTINT (ascent);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6098
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6099 margin = image_spec_value (spec, QCmargin, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6100 if (INTEGERP (margin) && XINT (margin) >= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6101 img->margin = XFASTINT (margin);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6102
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6103 relief = image_spec_value (spec, QCrelief, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6104 if (INTEGERP (relief))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6105 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6106 img->relief = XINT (relief);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6107 img->margin += abs (img->relief);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6108 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6109
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6110 /* Should we apply a Laplace edge-detection algorithm? */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6111 algorithm = image_spec_value (spec, QCalgorithm, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6112 if (img->pixmap && EQ (algorithm, Qlaplace))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6113 x_laplace (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6114
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6115 /* Should we built a mask heuristically? */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6116 heuristic_mask = image_spec_value (spec, QCheuristic_mask, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6117 if (img->pixmap && !img->mask && !NILP (heuristic_mask))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6118 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6119 file = image_spec_value (spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6120 x_build_heuristic_mask (f, file, img, heuristic_mask);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6121 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6122 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6123 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6124
25817
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
6125 /* We're using IMG, so set its timestamp to `now'. */
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
6126 EMACS_GET_TIME (now);
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
6127 img->timestamp = EMACS_SECS (now);
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
6128
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6129 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6130
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6131 /* Value is the image id. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6132 return img->id;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6133 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6134
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6135
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6136 /* Cache image IMG in the image cache of frame F. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6137
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6138 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6139 cache_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6140 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6141 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6142 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6143 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6144 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6145
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6146 /* Find a free slot in c->images. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6147 for (i = 0; i < c->used; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6148 if (c->images[i] == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6149 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6150
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6151 /* If no free slot found, maybe enlarge c->images. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6152 if (i == c->used && c->used == c->size)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6153 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6154 c->size *= 2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6155 c->images = (struct image **) xrealloc (c->images,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6156 c->size * sizeof *c->images);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6157 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6158
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6159 /* Add IMG to c->images, and assign IMG an id. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6160 c->images[i] = img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6161 img->id = i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6162 if (i == c->used)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6163 ++c->used;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6164
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6165 /* Add IMG to the cache's hash table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6166 i = img->hash % IMAGE_CACHE_BUCKETS_SIZE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6167 img->next = c->buckets[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6168 if (img->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6169 img->next->prev = img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6170 img->prev = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6171 c->buckets[i] = img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6172 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6173
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6174
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6175 /* Call FN on every image in the image cache of frame F. Used to mark
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6176 Lisp Objects in the image cache. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6177
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6178 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6179 forall_images_in_image_cache (f, fn)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6180 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6181 void (*fn) P_ ((struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6182 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6183 if (FRAME_LIVE_P (f) && FRAME_X_P (f))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6184 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6185 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6186 if (c)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6187 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6188 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6189 for (i = 0; i < c->used; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6190 if (c->images[i])
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6191 fn (c->images[i]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6192 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6193 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6194 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6195
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6196
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6197
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6198 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6199 X support code
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6200 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6201
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6202 static int x_create_x_image_and_pixmap P_ ((struct frame *, Lisp_Object,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6203 int, int, int, XImage **,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6204 Pixmap *));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6205 static void x_destroy_x_image P_ ((XImage *));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6206 static void x_put_x_image P_ ((struct frame *, XImage *, Pixmap, int, int));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6207
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6208
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6209 /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6210 frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6211 Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6212 via xmalloc. Print error messages via image_error if an error
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6213 occurs. FILE is the name of an image file being processed, for
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6214 error messages. Value is non-zero if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6215
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6216 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6217 x_create_x_image_and_pixmap (f, file, width, height, depth, ximg, pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6218 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6219 Lisp_Object file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6220 int width, height, depth;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6221 XImage **ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6222 Pixmap *pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6223 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6224 Display *display = FRAME_X_DISPLAY (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6225 Screen *screen = FRAME_X_SCREEN (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6226 Window window = FRAME_X_WINDOW (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6227
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6228 xassert (interrupt_input_blocked);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6229
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6230 if (depth <= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6231 depth = DefaultDepthOfScreen (screen);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6232 *ximg = XCreateImage (display, DefaultVisualOfScreen (screen),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6233 depth, ZPixmap, 0, NULL, width, height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6234 depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6235 if (*ximg == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6236 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6237 image_error ("Unable to allocate X image for %s", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6238 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6239 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6240
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6241 /* Allocate image raster. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6242 (*ximg)->data = (char *) xmalloc ((*ximg)->bytes_per_line * height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6243
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6244 /* Allocate a pixmap of the same size. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6245 *pixmap = XCreatePixmap (display, window, width, height, depth);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6246 if (*pixmap == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6247 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6248 x_destroy_x_image (*ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6249 *ximg = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6250 image_error ("Unable to create pixmap for `%s'", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6251 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6252 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6253
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6254 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6255 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6256
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6257
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6258 /* Destroy XImage XIMG. Free XIMG->data. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6259
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6260 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6261 x_destroy_x_image (ximg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6262 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6263 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6264 xassert (interrupt_input_blocked);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6265 if (ximg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6266 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6267 xfree (ximg->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6268 ximg->data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6269 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6270 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6271 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6272
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6273
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6274 /* Put XImage XIMG into pixmap PIXMAP on frame F. WIDTH and HEIGHT
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6275 are width and height of both the image and pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6276
25691
815efc48a80b (x_put_x_image): Make type consistent with declaration.
Dave Love <fx@gnu.org>
parents: 25679
diff changeset
6277 static void
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6278 x_put_x_image (f, ximg, pixmap, width, height)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6279 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6280 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6281 Pixmap pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6282 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6283 GC gc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6284
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6285 xassert (interrupt_input_blocked);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6286 gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6287 XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6288 XFreeGC (FRAME_X_DISPLAY (f), gc);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6289 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6290
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6291
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6292
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6293 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6294 Searching files
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6295 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6296
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6297 static Lisp_Object x_find_image_file P_ ((Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6298
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6299 /* Find image file FILE. Look in data-directory, then
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6300 x-bitmap-file-path. Value is the full name of the file found, or
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6301 nil if not found. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6302
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6303 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6304 x_find_image_file (file)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6305 Lisp_Object file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6306 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6307 Lisp_Object file_found, search_path;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6308 struct gcpro gcpro1, gcpro2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6309 int fd;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6310
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6311 file_found = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6312 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6313 GCPRO2 (file_found, search_path);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6314
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6315 /* Try to find FILE in data-directory, then x-bitmap-file-path. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6316 fd = openp (search_path, file, "", &file_found, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6317
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6318 if (fd < 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6319 file_found = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6320 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6321 close (fd);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6322
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6323 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6324 return file_found;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6325 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6326
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6327
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6328
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6329 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6330 XBM images
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6331 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6332
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6333 static int xbm_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6334 static int xbm_load_image_from_file P_ ((struct frame *f, struct image *img,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6335 Lisp_Object file));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6336 static int xbm_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6337 static int xbm_read_bitmap_file_data P_ ((char *, int *, int *,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6338 unsigned char **));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6339
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6340
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6341 /* Indices of image specification fields in xbm_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6342
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6343 enum xbm_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6344 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6345 XBM_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6346 XBM_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6347 XBM_WIDTH,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6348 XBM_HEIGHT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6349 XBM_DATA,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6350 XBM_FOREGROUND,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6351 XBM_BACKGROUND,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6352 XBM_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6353 XBM_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6354 XBM_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6355 XBM_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6356 XBM_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6357 XBM_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6358 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6359
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6360 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6361 of valid XBM image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6362
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6363 static struct image_keyword xbm_format[XBM_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6364 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6365 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6366 {":file", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6367 {":width", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6368 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6369 {":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6370 {":foreground", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6371 {":background", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6372 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6373 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6374 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6375 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6376 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6377 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6378
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6379 /* Structure describing the image type XBM. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6380
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6381 static struct image_type xbm_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6382 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6383 &Qxbm,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6384 xbm_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6385 xbm_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6386 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6387 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6388 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6389
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6390 /* Tokens returned from xbm_scan. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6391
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6392 enum xbm_token
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6393 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6394 XBM_TK_IDENT = 256,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6395 XBM_TK_NUMBER
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6396 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6397
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6398
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6399 /* Return non-zero if OBJECT is a valid XBM-type image specification.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6400 A valid specification is a list starting with the symbol `image'
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6401 The rest of the list is a property list which must contain an
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6402 entry `:type xbm..
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6403
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6404 If the specification specifies a file to load, it must contain
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6405 an entry `:file FILENAME' where FILENAME is a string.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6406
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6407 If the specification is for a bitmap loaded from memory it must
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6408 contain `:width WIDTH', `:height HEIGHT', and `:data DATA', where
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6409 WIDTH and HEIGHT are integers > 0. DATA may be:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6410
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6411 1. a string large enough to hold the bitmap data, i.e. it must
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6412 have a size >= (WIDTH + 7) / 8 * HEIGHT
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6413
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6414 2. a bool-vector of size >= WIDTH * HEIGHT
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6415
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6416 3. a vector of strings or bool-vectors, one for each line of the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6417 bitmap.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6418
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6419 Both the file and data forms may contain the additional entries
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6420 `:background COLOR' and `:foreground COLOR'. If not present,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6421 foreground and background of the frame on which the image is
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6422 displayed, is used. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6423
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6424 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6425 xbm_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6426 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6427 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6428 struct image_keyword kw[XBM_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6429
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6430 bcopy (xbm_format, kw, sizeof kw);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6431 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm, 0))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6432 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6433
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6434 xassert (EQ (kw[XBM_TYPE].value, Qxbm));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6435
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6436 if (kw[XBM_FILE].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6437 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6438 if (kw[XBM_WIDTH].count || kw[XBM_HEIGHT].count || kw[XBM_DATA].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6439 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6440 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6441 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6442 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6443 Lisp_Object data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6444 int width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6445
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6446 /* Entries for `:width', `:height' and `:data' must be present. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6447 if (!kw[XBM_WIDTH].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6448 || !kw[XBM_HEIGHT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6449 || !kw[XBM_DATA].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6450 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6451
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6452 data = kw[XBM_DATA].value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6453 width = XFASTINT (kw[XBM_WIDTH].value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6454 height = XFASTINT (kw[XBM_HEIGHT].value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6455
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6456 /* Check type of data, and width and height against contents of
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6457 data. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6458 if (VECTORP (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6459 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6460 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6461
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6462 /* Number of elements of the vector must be >= height. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6463 if (XVECTOR (data)->size < height)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6464 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6465
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6466 /* Each string or bool-vector in data must be large enough
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6467 for one line of the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6468 for (i = 0; i < height; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6469 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6470 Lisp_Object elt = XVECTOR (data)->contents[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6471
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6472 if (STRINGP (elt))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6473 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6474 if (XSTRING (elt)->size
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6475 < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6476 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6477 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6478 else if (BOOL_VECTOR_P (elt))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6479 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6480 if (XBOOL_VECTOR (elt)->size < width)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6481 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6482 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6483 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6484 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6485 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6486 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6487 else if (STRINGP (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6488 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6489 if (XSTRING (data)->size
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6490 < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6491 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6492 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6493 else if (BOOL_VECTOR_P (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6494 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6495 if (XBOOL_VECTOR (data)->size < width * height)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6496 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6497 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6498 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6499 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6500 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6501
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6502 /* Baseline must be a value between 0 and 100 (a percentage). */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6503 if (kw[XBM_ASCENT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6504 && XFASTINT (kw[XBM_ASCENT].value) > 100)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6505 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6506
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6507 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6508 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6509
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6510
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6511 /* Scan a bitmap file. FP is the stream to read from. Value is
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6512 either an enumerator from enum xbm_token, or a character for a
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6513 single-character token, or 0 at end of file. If scanning an
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6514 identifier, store the lexeme of the identifier in SVAL. If
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6515 scanning a number, store its value in *IVAL. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6516
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6517 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6518 xbm_scan (fp, sval, ival)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6519 FILE *fp;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6520 char *sval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6521 int *ival;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6522 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6523 int c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6524
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6525 /* Skip white space. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6526 while ((c = fgetc (fp)) != EOF && isspace (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6527 ;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6528
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6529 if (c == EOF)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6530 c = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6531 else if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6532 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6533 int value = 0, digit;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6534
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6535 if (c == '0')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6536 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6537 c = fgetc (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6538 if (c == 'x' || c == 'X')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6539 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6540 while ((c = fgetc (fp)) != EOF)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6541 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6542 if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6543 digit = c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6544 else if (c >= 'a' && c <= 'f')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6545 digit = c - 'a' + 10;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6546 else if (c >= 'A' && c <= 'F')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6547 digit = c - 'A' + 10;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6548 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6549 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6550 value = 16 * value + digit;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6551 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6552 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6553 else if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6554 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6555 value = c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6556 while ((c = fgetc (fp)) != EOF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6557 && isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6558 value = 8 * value + c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6559 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6560 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6561 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6562 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6563 value = c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6564 while ((c = fgetc (fp)) != EOF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6565 && isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6566 value = 10 * value + c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6567 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6568
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6569 if (c != EOF)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6570 ungetc (c, fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6571 *ival = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6572 c = XBM_TK_NUMBER;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6573 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6574 else if (isalpha (c) || c == '_')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6575 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6576 *sval++ = c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6577 while ((c = fgetc (fp)) != EOF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6578 && (isalnum (c) || c == '_'))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6579 *sval++ = c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6580 *sval = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6581 if (c != EOF)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6582 ungetc (c, fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6583 c = XBM_TK_IDENT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6584 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6585
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6586 return c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6587 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6588
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6589
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6590 /* Replacement for XReadBitmapFileData which isn't available under old
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6591 X versions. FILE is the name of the bitmap file to read. Set
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6592 *WIDTH and *HEIGHT to the width and height of the image. Return in
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6593 *DATA the bitmap data allocated with xmalloc. Value is non-zero if
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6594 successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6595
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6596 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6597 xbm_read_bitmap_file_data (file, width, height, data)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6598 char *file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6599 int *width, *height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6600 unsigned char **data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6601 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6602 FILE *fp;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6603 char buffer[BUFSIZ];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6604 int padding_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6605 int v10 = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6606 int bytes_per_line, i, nbytes;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6607 unsigned char *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6608 int value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6609 int LA1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6610
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6611 #define match() \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6612 LA1 = xbm_scan (fp, buffer, &value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6613
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6614 #define expect(TOKEN) \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6615 if (LA1 != (TOKEN)) \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6616 goto failure; \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6617 else \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6618 match ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6619
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6620 #define expect_ident(IDENT) \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6621 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6622 match (); \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6623 else \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6624 goto failure
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6625
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6626 fp = fopen (file, "r");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6627 if (fp == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6628 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6629
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6630 *width = *height = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6631 *data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6632 LA1 = xbm_scan (fp, buffer, &value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6633
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6634 /* Parse defines for width, height and hot-spots. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6635 while (LA1 == '#')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6636 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6637 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6638 expect_ident ("define");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6639 expect (XBM_TK_IDENT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6640
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6641 if (LA1 == XBM_TK_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6642 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6643 char *p = strrchr (buffer, '_');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6644 p = p ? p + 1 : buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6645 if (strcmp (p, "width") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6646 *width = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6647 else if (strcmp (p, "height") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6648 *height = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6649 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6650 expect (XBM_TK_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6651 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6652
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6653 if (*width < 0 || *height < 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6654 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6655
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6656 /* Parse bits. Must start with `static'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6657 expect_ident ("static");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6658 if (LA1 == XBM_TK_IDENT)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6659 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6660 if (strcmp (buffer, "unsigned") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6661 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6662 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6663 expect_ident ("char");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6664 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6665 else if (strcmp (buffer, "short") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6666 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6667 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6668 v10 = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6669 if (*width % 16 && *width % 16 < 9)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6670 padding_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6671 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6672 else if (strcmp (buffer, "char") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6673 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6674 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6675 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6676 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6677 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6678 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6679
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6680 expect (XBM_TK_IDENT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6681 expect ('[');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6682 expect (']');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6683 expect ('=');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6684 expect ('{');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6685
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6686 bytes_per_line = (*width + 7) / 8 + padding_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6687 nbytes = bytes_per_line * *height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6688 p = *data = (char *) xmalloc (nbytes);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6689
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6690 if (v10)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6691 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6692
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6693 for (i = 0; i < nbytes; i += 2)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6694 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6695 int val = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6696 expect (XBM_TK_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6697
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6698 *p++ = val;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6699 if (!padding_p || ((i + 2) % bytes_per_line))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6700 *p++ = value >> 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6701
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6702 if (LA1 == ',' || LA1 == '}')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6703 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6704 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6705 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6706 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6707 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6708 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6709 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6710 for (i = 0; i < nbytes; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6711 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6712 int val = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6713 expect (XBM_TK_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6714
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6715 *p++ = val;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6716
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6717 if (LA1 == ',' || LA1 == '}')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6718 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6719 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6720 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6721 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6722 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6723
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6724 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6725 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6726
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6727 failure:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6728
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6729 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6730 if (*data)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6731 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6732 xfree (*data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6733 *data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6734 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6735 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6736
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6737 #undef match
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6738 #undef expect
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6739 #undef expect_ident
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6740 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6741
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6742
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6743 /* Load XBM image IMG which will be displayed on frame F from file
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6744 SPECIFIED_FILE. Value is non-zero if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6745
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6746 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6747 xbm_load_image_from_file (f, img, specified_file)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6748 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6749 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6750 Lisp_Object specified_file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6751 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6752 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6753 unsigned char *data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6754 int success_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6755 Lisp_Object file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6756 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6757
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6758 xassert (STRINGP (specified_file));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6759 file = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6760 GCPRO1 (file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6761
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6762 file = x_find_image_file (specified_file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6763 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6764 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6765 image_error ("Cannot find image file %s", specified_file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6766 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6767 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6768 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6769
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6770 rc = xbm_read_bitmap_file_data (XSTRING (file)->data, &img->width,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6771 &img->height, &data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6772 if (rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6773 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6774 int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6775 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6776 unsigned long background = FRAME_BACKGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6777 Lisp_Object value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6778
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6779 xassert (img->width > 0 && img->height > 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6780
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6781 /* Get foreground and background colors, maybe allocate colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6782 value = image_spec_value (img->spec, QCforeground, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6783 if (!NILP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6784 foreground = x_alloc_image_color (f, img, value, foreground);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6785
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6786 value = image_spec_value (img->spec, QCbackground, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6787 if (!NILP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6788 background = x_alloc_image_color (f, img, value, background);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6789
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6790 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6791 img->pixmap
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6792 = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6793 FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6794 data,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6795 img->width, img->height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6796 foreground, background,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6797 depth);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6798 xfree (data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6799
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6800 if (img->pixmap == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6801 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6802 x_clear_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6803 image_error ("Unable to create X pixmap for `%s'", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6804 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6805 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6806 success_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6807
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6808 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6809 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6810 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6811 image_error ("Error loading XBM image %s", img->spec, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6812
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6813 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6814 return success_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6815 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6816
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6817
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6818 /* Fill image IMG which is used on frame F with pixmap data. Value is
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6819 non-zero if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6820
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6821 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6822 xbm_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6823 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6824 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6825 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6826 int success_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6827 Lisp_Object file_name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6828
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6829 xassert (xbm_image_p (img->spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6830
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6831 /* If IMG->spec specifies a file name, create a non-file spec from it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6832 file_name = image_spec_value (img->spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6833 if (STRINGP (file_name))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6834 success_p = xbm_load_image_from_file (f, img, file_name);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6835 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6836 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6837 struct image_keyword fmt[XBM_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6838 Lisp_Object data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6839 int depth;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6840 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6841 unsigned long background = FRAME_BACKGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6842 char *bits;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6843 int parsed_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6844
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6845 /* Parse the list specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6846 bcopy (xbm_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6847 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6848 xassert (parsed_p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6849
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6850 /* Get specified width, and height. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6851 img->width = XFASTINT (fmt[XBM_WIDTH].value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6852 img->height = XFASTINT (fmt[XBM_HEIGHT].value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6853 xassert (img->width > 0 && img->height > 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6854
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6855 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6856
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6857 if (fmt[XBM_ASCENT].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6858 img->ascent = XFASTINT (fmt[XBM_ASCENT].value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6859
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6860 /* Get foreground and background colors, maybe allocate colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6861 if (fmt[XBM_FOREGROUND].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6862 foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6863 foreground);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6864 if (fmt[XBM_BACKGROUND].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6865 background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6866 background);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6867
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6868 /* Set bits to the bitmap image data. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6869 data = fmt[XBM_DATA].value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6870 if (VECTORP (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6871 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6872 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6873 char *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6874 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6875
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6876 p = bits = (char *) alloca (nbytes * img->height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6877 for (i = 0; i < img->height; ++i, p += nbytes)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6878 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6879 Lisp_Object line = XVECTOR (data)->contents[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6880 if (STRINGP (line))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6881 bcopy (XSTRING (line)->data, p, nbytes);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6882 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6883 bcopy (XBOOL_VECTOR (line)->data, p, nbytes);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6884 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6885 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6886 else if (STRINGP (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6887 bits = XSTRING (data)->data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6888 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6889 bits = XBOOL_VECTOR (data)->data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6890
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6891 /* Create the pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6892 depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6893 img->pixmap
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6894 = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6895 FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6896 bits,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6897 img->width, img->height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6898 foreground, background,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6899 depth);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6900 if (img->pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6901 success_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6902 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6903 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6904 image_error ("Unable to create pixmap for XBM image", Qnil, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6905 x_clear_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6906 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6907
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6908 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6909 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6910
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6911 return success_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6912 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6913
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6914
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6915
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6916 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6917 XPM images
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6918 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6919
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6920 #if HAVE_XPM
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6921
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6922 static int xpm_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6923 static int xpm_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6924 static int xpm_valid_color_symbols_p P_ ((Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6925
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6926 #include "X11/xpm.h"
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6927
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6928 /* The symbol `xpm' identifying XPM-format images. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6929
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6930 Lisp_Object Qxpm;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6931
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6932 /* Indices of image specification fields in xpm_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6933
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6934 enum xpm_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6935 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6936 XPM_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6937 XPM_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6938 XPM_DATA,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6939 XPM_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6940 XPM_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6941 XPM_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6942 XPM_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6943 XPM_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6944 XPM_COLOR_SYMBOLS,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6945 XPM_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6946 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6947
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6948 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6949 of valid XPM image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6950
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6951 static struct image_keyword xpm_format[XPM_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6952 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6953 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6954 {":file", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6955 {":data", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6956 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6957 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6958 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6959 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6960 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6961 {":color-symbols", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6962 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6963
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6964 /* Structure describing the image type XBM. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6965
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6966 static struct image_type xpm_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6967 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6968 &Qxpm,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6969 xpm_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6970 xpm_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6971 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6972 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6973 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6974
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6975
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6976 /* Value is non-zero if COLOR_SYMBOLS is a valid color symbols list
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6977 for XPM images. Such a list must consist of conses whose car and
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6978 cdr are strings. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6979
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6980 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6981 xpm_valid_color_symbols_p (color_symbols)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6982 Lisp_Object color_symbols;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6983 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6984 while (CONSP (color_symbols))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6985 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6986 Lisp_Object sym = XCAR (color_symbols);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6987 if (!CONSP (sym)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6988 || !STRINGP (XCAR (sym))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6989 || !STRINGP (XCDR (sym)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6990 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6991 color_symbols = XCDR (color_symbols);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6992 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6993
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6994 return NILP (color_symbols);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6995 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6996
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6997
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6998 /* Value is non-zero if OBJECT is a valid XPM image specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6999
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7000 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7001 xpm_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7002 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7003 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7004 struct image_keyword fmt[XPM_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7005 bcopy (xpm_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7006 return (parse_image_spec (object, fmt, XPM_LAST, Qxpm, 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7007 /* Either `:file' or `:data' must be present. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7008 && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7009 /* Either no `:color-symbols' or it's a list of conses
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7010 whose car and cdr are strings. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7011 && (fmt[XPM_COLOR_SYMBOLS].count == 0
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7012 || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7013 && (fmt[XPM_ASCENT].count == 0
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7014 || XFASTINT (fmt[XPM_ASCENT].value) < 100));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7015 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7016
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7017
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7018 /* Load image IMG which will be displayed on frame F. Value is
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7019 non-zero if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7020
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7021 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7022 xpm_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7023 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7024 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7025 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7026 int rc, i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7027 XpmAttributes attrs;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7028 Lisp_Object specified_file, color_symbols;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7029
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7030 /* Configure the XPM lib. Use the visual of frame F. Allocate
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7031 close colors. Return colors allocated. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7032 bzero (&attrs, sizeof attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7033 attrs.visual = FRAME_X_DISPLAY_INFO (f)->visual;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7034 attrs.valuemask |= XpmVisual;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7035 attrs.valuemask |= XpmReturnAllocPixels;
25200
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
7036 #ifdef XpmAllocCloseColors
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7037 attrs.alloc_close_colors = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7038 attrs.valuemask |= XpmAllocCloseColors;
25200
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
7039 #else
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
7040 attrs.closeness = 600;
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
7041 attrs.valuemask |= XpmCloseness;
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
7042 #endif
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7043
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7044 /* If image specification contains symbolic color definitions, add
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7045 these to `attrs'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7046 color_symbols = image_spec_value (img->spec, QCcolor_symbols, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7047 if (CONSP (color_symbols))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7048 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7049 Lisp_Object tail;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7050 XpmColorSymbol *xpm_syms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7051 int i, size;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7052
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7053 attrs.valuemask |= XpmColorSymbols;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7054
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7055 /* Count number of symbols. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7056 attrs.numsymbols = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7057 for (tail = color_symbols; CONSP (tail); tail = XCDR (tail))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7058 ++attrs.numsymbols;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7059
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7060 /* Allocate an XpmColorSymbol array. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7061 size = attrs.numsymbols * sizeof *xpm_syms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7062 xpm_syms = (XpmColorSymbol *) alloca (size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7063 bzero (xpm_syms, size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7064 attrs.colorsymbols = xpm_syms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7065
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7066 /* Fill the color symbol array. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7067 for (tail = color_symbols, i = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7068 CONSP (tail);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7069 ++i, tail = XCDR (tail))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7070 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7071 Lisp_Object name = XCAR (XCAR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7072 Lisp_Object color = XCDR (XCAR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7073 xpm_syms[i].name = (char *) alloca (XSTRING (name)->size + 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7074 strcpy (xpm_syms[i].name, XSTRING (name)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7075 xpm_syms[i].value = (char *) alloca (XSTRING (color)->size + 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7076 strcpy (xpm_syms[i].value, XSTRING (color)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7077 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7078 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7079
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7080 /* Create a pixmap for the image, either from a file, or from a
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7081 string buffer containing data in the same format as an XPM file. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7082 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7083 specified_file = image_spec_value (img->spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7084 if (STRINGP (specified_file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7085 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7086 Lisp_Object file = x_find_image_file (specified_file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7087 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7088 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7089 image_error ("Cannot find image file %s", specified_file, Qnil);
25955
3daaee890b1e (prepare_image_for_display): Don't try to load image if
Gerd Moellmann <gerd@gnu.org>
parents: 25817
diff changeset
7090 UNBLOCK_INPUT;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7091 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7092 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7093
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7094 rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7095 XSTRING (file)->data, &img->pixmap, &img->mask,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7096 &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7097 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7098 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7099 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7100 Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7101 rc = XpmCreatePixmapFromBuffer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7102 XSTRING (buffer)->data,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7103 &img->pixmap, &img->mask,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7104 &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7105 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7106 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7107
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7108 if (rc == XpmSuccess)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7109 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7110 /* Remember allocated colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7111 img->ncolors = attrs.nalloc_pixels;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7112 img->colors = (unsigned long *) xmalloc (img->ncolors
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7113 * sizeof *img->colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7114 for (i = 0; i < attrs.nalloc_pixels; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7115 img->colors[i] = attrs.alloc_pixels[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7116
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7117 img->width = attrs.width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7118 img->height = attrs.height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7119 xassert (img->width > 0 && img->height > 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7120
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7121 /* The call to XpmFreeAttributes below frees attrs.alloc_pixels. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7122 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7123 XpmFreeAttributes (&attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7124 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7125 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7126 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7127 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7128 switch (rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7129 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7130 case XpmOpenFailed:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7131 image_error ("Error opening XPM file (%s)", img->spec, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7132 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7133
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7134 case XpmFileInvalid:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7135 image_error ("Invalid XPM file (%s)", img->spec, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7136 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7137
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7138 case XpmNoMemory:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7139 image_error ("Out of memory (%s)", img->spec, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7140 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7141
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7142 case XpmColorFailed:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7143 image_error ("Color allocation error (%s)", img->spec, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7144 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7145
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7146 default:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7147 image_error ("Unknown error (%s)", img->spec, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7148 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7149 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7150 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7151
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7152 return rc == XpmSuccess;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7153 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7154
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7155 #endif /* HAVE_XPM != 0 */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7156
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7157
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7158 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7159 Color table
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7160 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7161
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7162 /* An entry in the color table mapping an RGB color to a pixel color. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7163
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7164 struct ct_color
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7165 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7166 int r, g, b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7167 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7168
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7169 /* Next in color table collision list. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7170 struct ct_color *next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7171 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7172
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7173 /* The bucket vector size to use. Must be prime. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7174
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7175 #define CT_SIZE 101
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7176
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7177 /* Value is a hash of the RGB color given by R, G, and B. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7178
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7179 #define CT_HASH_RGB(R, G, B) (((R) << 16) ^ ((G) << 8) ^ (B))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7180
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7181 /* The color hash table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7182
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7183 struct ct_color **ct_table;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7184
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7185 /* Number of entries in the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7186
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7187 int ct_colors_allocated;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7188
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7189 /* Function prototypes. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7190
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7191 static void init_color_table P_ ((void));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7192 static void free_color_table P_ ((void));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7193 static unsigned long *colors_in_color_table P_ ((int *n));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7194 static unsigned long lookup_rgb_color P_ ((struct frame *f, int r, int g, int b));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7195 static unsigned long lookup_pixel_color P_ ((struct frame *f, unsigned long p));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7196
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7197
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7198 /* Initialize the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7199
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7200 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7201 init_color_table ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7202 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7203 int size = CT_SIZE * sizeof (*ct_table);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7204 ct_table = (struct ct_color **) xmalloc (size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7205 bzero (ct_table, size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7206 ct_colors_allocated = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7207 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7208
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7209
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7210 /* Free memory associated with the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7211
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7212 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7213 free_color_table ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7214 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7215 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7216 struct ct_color *p, *next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7217
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7218 for (i = 0; i < CT_SIZE; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7219 for (p = ct_table[i]; p; p = next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7220 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7221 next = p->next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7222 xfree (p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7223 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7224
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7225 xfree (ct_table);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7226 ct_table = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7227 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7228
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7229
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7230 /* Value is a pixel color for RGB color R, G, B on frame F. If an
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7231 entry for that color already is in the color table, return the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7232 pixel color of that entry. Otherwise, allocate a new color for R,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7233 G, B, and make an entry in the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7234
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7235 static unsigned long
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7236 lookup_rgb_color (f, r, g, b)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7237 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7238 int r, g, b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7239 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7240 unsigned hash = CT_HASH_RGB (r, g, b);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7241 int i = hash % CT_SIZE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7242 struct ct_color *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7243
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7244 for (p = ct_table[i]; p; p = p->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7245 if (p->r == r && p->g == g && p->b == b)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7246 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7247
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7248 if (p == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7249 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7250 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7251 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7252 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7253
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7254 color.red = r;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7255 color.green = g;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7256 color.blue = b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7257
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7258 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7259 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
7260 rc = x_alloc_nearest_color (f, cmap, &color);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7261 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7262
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7263 if (rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7264 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7265 ++ct_colors_allocated;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7266
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7267 p = (struct ct_color *) xmalloc (sizeof *p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7268 p->r = r;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7269 p->g = g;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7270 p->b = b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7271 p->pixel = color.pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7272 p->next = ct_table[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7273 ct_table[i] = p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7274 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7275 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7276 return FRAME_FOREGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7277 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7278
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7279 return p->pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7280 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7281
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7282
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7283 /* Look up pixel color PIXEL which is used on frame F in the color
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7284 table. If not already present, allocate it. Value is PIXEL. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7285
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7286 static unsigned long
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7287 lookup_pixel_color (f, pixel)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7288 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7289 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7290 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7291 int i = pixel % CT_SIZE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7292 struct ct_color *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7293
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7294 for (p = ct_table[i]; p; p = p->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7295 if (p->pixel == pixel)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7296 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7297
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7298 if (p == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7299 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7300 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7301 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7302 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7303
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7304 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7305
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7306 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7307 color.pixel = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7308 XQueryColor (FRAME_X_DISPLAY (f), cmap, &color);
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
7309 rc = x_alloc_nearest_color (f, cmap, &color);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7310 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7311
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7312 if (rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7313 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7314 ++ct_colors_allocated;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7315
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7316 p = (struct ct_color *) xmalloc (sizeof *p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7317 p->r = color.red;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7318 p->g = color.green;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7319 p->b = color.blue;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7320 p->pixel = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7321 p->next = ct_table[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7322 ct_table[i] = p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7323 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7324 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7325 return FRAME_FOREGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7326 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7327
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7328 return p->pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7329 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7330
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7331
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7332 /* Value is a vector of all pixel colors contained in the color table,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7333 allocated via xmalloc. Set *N to the number of colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7334
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7335 static unsigned long *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7336 colors_in_color_table (n)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7337 int *n;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7338 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7339 int i, j;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7340 struct ct_color *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7341 unsigned long *colors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7342
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7343 if (ct_colors_allocated == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7344 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7345 *n = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7346 colors = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7347 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7348 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7349 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7350 colors = (unsigned long *) xmalloc (ct_colors_allocated
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7351 * sizeof *colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7352 *n = ct_colors_allocated;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7353
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7354 for (i = j = 0; i < CT_SIZE; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7355 for (p = ct_table[i]; p; p = p->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7356 colors[j++] = p->pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7357 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7358
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7359 return colors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7360 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7361
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7362
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7363
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7364 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7365 Algorithms
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7366 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7367
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7368 static void x_laplace_write_row P_ ((struct frame *, long *,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7369 int, XImage *, int));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7370 static void x_laplace_read_row P_ ((struct frame *, Colormap,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7371 XColor *, int, XImage *, int));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7372
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7373
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7374 /* Fill COLORS with RGB colors from row Y of image XIMG. F is the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7375 frame we operate on, CMAP is the color-map in effect, and WIDTH is
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7376 the width of one row in the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7377
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7378 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7379 x_laplace_read_row (f, cmap, colors, width, ximg, y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7380 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7381 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7382 XColor *colors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7383 int width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7384 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7385 int y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7386 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7387 int x;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7388
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7389 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7390 colors[x].pixel = XGetPixel (ximg, x, y);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7391
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7392 XQueryColors (FRAME_X_DISPLAY (f), cmap, colors, width);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7393 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7394
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7395
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7396 /* Write row Y of image XIMG. PIXELS is an array of WIDTH longs
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7397 containing the pixel colors to write. F is the frame we are
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7398 working on. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7399
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7400 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7401 x_laplace_write_row (f, pixels, width, ximg, y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7402 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7403 long *pixels;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7404 int width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7405 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7406 int y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7407 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7408 int x;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7409
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7410 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7411 XPutPixel (ximg, x, y, pixels[x]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7412 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7413
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7414
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7415 /* Transform image IMG which is used on frame F with a Laplace
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7416 edge-detection algorithm. The result is an image that can be used
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7417 to draw disabled buttons, for example. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7418
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7419 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7420 x_laplace (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7421 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7422 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7423 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7424 Colormap cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7425 XImage *ximg, *oimg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7426 XColor *in[3];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7427 long *out;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7428 Pixmap pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7429 int x, y, i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7430 long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7431 int in_y, out_y, rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7432 int mv2 = 45000;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7433
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7434 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7435
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7436 /* Get the X image IMG->pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7437 ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7438 0, 0, img->width, img->height, ~0, ZPixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7439
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7440 /* Allocate 3 input rows, and one output row of colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7441 for (i = 0; i < 3; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7442 in[i] = (XColor *) alloca (img->width * sizeof (XColor));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7443 out = (long *) alloca (img->width * sizeof (long));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7444
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7445 /* Create an X image for output. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7446 rc = x_create_x_image_and_pixmap (f, Qnil, img->width, img->height, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7447 &oimg, &pixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7448
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7449 /* Fill first two rows. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7450 x_laplace_read_row (f, cmap, in[0], img->width, ximg, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7451 x_laplace_read_row (f, cmap, in[1], img->width, ximg, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7452 in_y = 2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7453
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7454 /* Write first row, all zeros. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7455 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7456 pixel = lookup_rgb_color (f, 0, 0, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7457 for (x = 0; x < img->width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7458 out[x] = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7459 x_laplace_write_row (f, out, img->width, oimg, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7460 out_y = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7461
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7462 for (y = 2; y < img->height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7463 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7464 int rowa = y % 3;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7465 int rowb = (y + 2) % 3;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7466
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7467 x_laplace_read_row (f, cmap, in[rowa], img->width, ximg, in_y++);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7468
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7469 for (x = 0; x < img->width - 2; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7470 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7471 int r = in[rowa][x].red + mv2 - in[rowb][x + 2].red;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7472 int g = in[rowa][x].green + mv2 - in[rowb][x + 2].green;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7473 int b = in[rowa][x].blue + mv2 - in[rowb][x + 2].blue;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7474
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7475 out[x + 1] = lookup_rgb_color (f, r & 0xffff, g & 0xffff,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7476 b & 0xffff);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7477 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7478
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7479 x_laplace_write_row (f, out, img->width, oimg, out_y++);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7480 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7481
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7482 /* Write last line, all zeros. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7483 for (x = 0; x < img->width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7484 out[x] = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7485 x_laplace_write_row (f, out, img->width, oimg, out_y);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7486
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7487 /* Free the input image, and free resources of IMG. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7488 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7489 x_clear_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7490
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7491 /* Put the output image into pixmap, and destroy it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7492 x_put_x_image (f, oimg, pixmap, img->width, img->height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7493 x_destroy_x_image (oimg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7494
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7495 /* Remember new pixmap and colors in IMG. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7496 img->pixmap = pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7497 img->colors = colors_in_color_table (&img->ncolors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7498 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7499
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7500 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7501 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7502
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7503
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7504 /* Build a mask for image IMG which is used on frame F. FILE is the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7505 name of an image file, for error messages. HOW determines how to
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7506 determine the background color of IMG. If it is a list '(R G B)',
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7507 with R, G, and B being integers >= 0, take that as the color of the
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7508 background. Otherwise, determine the background color of IMG
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7509 heuristically. Value is non-zero if successful. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7510
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7511 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7512 x_build_heuristic_mask (f, file, img, how)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7513 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7514 Lisp_Object file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7515 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7516 Lisp_Object how;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7517 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7518 Display *dpy = FRAME_X_DISPLAY (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7519 XImage *ximg, *mask_img;
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7520 int x, y, rc, look_at_corners_p;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7521 unsigned long bg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7522
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7523 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7524
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7525 /* Create an image and pixmap serving as mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7526 rc = x_create_x_image_and_pixmap (f, file, img->width, img->height, 1,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7527 &mask_img, &img->mask);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7528 if (!rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7529 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7530 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7531 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7532 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7533
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7534 /* Get the X image of IMG->pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7535 ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7536 ~0, ZPixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7537
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7538 /* Determine the background color of ximg. If HOW is `(R G B)'
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7539 take that as color. Otherwise, try to determine the color
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7540 heuristically. */
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7541 look_at_corners_p = 1;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7542
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7543 if (CONSP (how))
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7544 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7545 int rgb[3], i = 0;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7546
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7547 while (i < 3
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7548 && CONSP (how)
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7549 && NATNUMP (XCAR (how)))
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7550 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7551 rgb[i] = XFASTINT (XCAR (how)) & 0xffff;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7552 how = XCDR (how);
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7553 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7554
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7555 if (i == 3 && NILP (how))
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7556 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7557 char color_name[30];
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7558 XColor exact, color;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7559 Colormap cmap;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7560
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7561 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7562
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7563 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7564 if (XLookupColor (dpy, cmap, color_name, &exact, &color))
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7565 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7566 bg = color.pixel;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7567 look_at_corners_p = 0;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7568 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7569 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7570 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7571
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7572 if (look_at_corners_p)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7573 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7574 unsigned long corners[4];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7575 int i, best_count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7576
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7577 /* Get the colors at the corners of ximg. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7578 corners[0] = XGetPixel (ximg, 0, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7579 corners[1] = XGetPixel (ximg, img->width - 1, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7580 corners[2] = XGetPixel (ximg, img->width - 1, img->height - 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7581 corners[3] = XGetPixel (ximg, 0, img->height - 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7582
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7583 /* Choose the most frequently found color as background. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7584 for (i = best_count = 0; i < 4; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7585 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7586 int j, n;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7587
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7588 for (j = n = 0; j < 4; ++j)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7589 if (corners[i] == corners[j])
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7590 ++n;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7591
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7592 if (n > best_count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7593 bg = corners[i], best_count = n;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7594 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7595 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7596
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7597 /* Set all bits in mask_img to 1 whose color in ximg is different
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7598 from the background color bg. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7599 for (y = 0; y < img->height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7600 for (x = 0; x < img->width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7601 XPutPixel (mask_img, x, y, XGetPixel (ximg, x, y) != bg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7602
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7603 /* Put mask_img into img->mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7604 x_put_x_image (f, mask_img, img->mask, img->width, img->height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7605 x_destroy_x_image (mask_img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7606 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7607
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7608 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7609 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7610 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7611
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7612
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7613
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7614 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7615 PBM (mono, gray, color)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7616 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7617
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7618 static int pbm_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7619 static int pbm_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7620 static int pbm_scan_number P_ ((FILE *fp));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7621
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7622 /* The symbol `pbm' identifying images of this type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7623
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7624 Lisp_Object Qpbm;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7625
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7626 /* Indices of image specification fields in gs_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7627
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7628 enum pbm_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7629 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7630 PBM_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7631 PBM_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7632 PBM_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7633 PBM_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7634 PBM_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7635 PBM_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7636 PBM_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7637 PBM_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7638 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7639
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7640 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7641 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7642
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7643 static struct image_keyword pbm_format[PBM_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7644 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7645 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7646 {":file", IMAGE_STRING_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7647 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7648 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7649 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7650 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7651 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7652 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7653
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7654 /* Structure describing the image type `pbm'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7655
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7656 static struct image_type pbm_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7657 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7658 &Qpbm,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7659 pbm_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7660 pbm_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7661 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7662 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7663 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7664
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7665
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7666 /* Return non-zero if OBJECT is a valid PBM image specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7667
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7668 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7669 pbm_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7670 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7671 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7672 struct image_keyword fmt[PBM_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7673
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7674 bcopy (pbm_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7675
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7676 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm, 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7677 || (fmt[PBM_ASCENT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7678 && XFASTINT (fmt[PBM_ASCENT].value) > 100))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7679 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7680 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7681 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7682
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7683
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7684 /* Scan a decimal number from PBM input file FP and return it. Value
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7685 is -1 at end of file or if an error occurs. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7686
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7687 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7688 pbm_scan_number (fp)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7689 FILE *fp;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7690 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7691 int c, val = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7692
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7693 while (!feof (fp))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7694 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7695 /* Skip white-space. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7696 while ((c = fgetc (fp)) != EOF && isspace (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7697 ;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7698
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7699 if (c == '#')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7700 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7701 /* Skip comment to end of line. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7702 while ((c = fgetc (fp)) != EOF && c != '\n')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7703 ;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7704 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7705 else if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7706 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7707 /* Read decimal number. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7708 val = c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7709 while ((c = fgetc (fp)) != EOF && isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7710 val = 10 * val + c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7711 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7712 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7713 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7714 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7715 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7716
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7717 return val;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7718 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7719
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7720
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7721 /* Load PBM image IMG for use on frame F. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7722
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7723 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7724 pbm_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7725 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7726 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7727 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7728 FILE *fp;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7729 char magic[2];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7730 int raw_p, x, y;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
7731 int width, height, max_color_idx = 0;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7732 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7733 Lisp_Object file, specified_file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7734 enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7735 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7736
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7737 specified_file = image_spec_value (img->spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7738 file = x_find_image_file (specified_file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7739 GCPRO1 (file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7740 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7741 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7742 image_error ("Cannot find image file %s", specified_file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7743 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7744 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7745 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7746
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7747 fp = fopen (XSTRING (file)->data, "r");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7748 if (fp == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7749 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7750 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7751 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7752 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7753
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7754 /* Read first two characters. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7755 if (fread (magic, sizeof *magic, 2, fp) != 2)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7756 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7757 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7758 image_error ("Not a PBM image file: %s", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7759 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7760 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7761 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7762
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7763 if (*magic != 'P')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7764 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7765 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7766 image_error ("Not a PBM image file: %s", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7767 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7768 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7769 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7770
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7771 switch (magic[1])
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7772 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7773 case '1':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7774 raw_p = 0, type = PBM_MONO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7775 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7776
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7777 case '2':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7778 raw_p = 0, type = PBM_GRAY;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7779 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7780
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7781 case '3':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7782 raw_p = 0, type = PBM_COLOR;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7783 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7784
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7785 case '4':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7786 raw_p = 1, type = PBM_MONO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7787 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7788
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7789 case '5':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7790 raw_p = 1, type = PBM_GRAY;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7791 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7792
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7793 case '6':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7794 raw_p = 1, type = PBM_COLOR;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7795 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7796
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7797 default:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7798 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7799 image_error ("Not a PBM image file: %s", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7800 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7801 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7802 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7803
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7804 /* Read width, height, maximum color-component. Characters
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7805 starting with `#' up to the end of a line are ignored. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7806 width = pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7807 height = pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7808
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7809 if (type != PBM_MONO)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7810 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7811 max_color_idx = pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7812 if (raw_p && max_color_idx > 255)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7813 max_color_idx = 255;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7814 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7815
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7816 if (width < 0 || height < 0
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7817 || (type != PBM_MONO && max_color_idx < 0))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7818 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7819 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7820 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7821 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7822 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7823
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7824 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7825 if (!x_create_x_image_and_pixmap (f, file, width, height, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7826 &ximg, &img->pixmap))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7827 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7828 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7829 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7830 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7831 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7832 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7833
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7834 /* Initialize the color hash table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7835 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7836
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7837 if (type == PBM_MONO)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7838 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7839 int c = 0, g;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7840
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7841 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7842 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7843 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7844 if (raw_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7845 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7846 if ((x & 7) == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7847 c = fgetc (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7848 g = c & 0x80;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7849 c <<= 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7850 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7851 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7852 g = pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7853
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7854 XPutPixel (ximg, x, y, (g
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7855 ? FRAME_FOREGROUND_PIXEL (f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7856 : FRAME_BACKGROUND_PIXEL (f)));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7857 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7858 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7859 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7860 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7861 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7862 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7863 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7864 int r, g, b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7865
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7866 if (type == PBM_GRAY)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7867 r = g = b = raw_p ? fgetc (fp) : pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7868 else if (raw_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7869 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7870 r = fgetc (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7871 g = fgetc (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7872 b = fgetc (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7873 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7874 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7875 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7876 r = pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7877 g = pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7878 b = pbm_scan_number (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7879 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7880
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7881 if (r < 0 || g < 0 || b < 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7882 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7883 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7884 xfree (ximg->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7885 ximg->data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7886 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7887 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7888 image_error ("Invalid pixel value in file `%s'",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7889 file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7890 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7891 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7892 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7893
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7894 /* RGB values are now in the range 0..max_color_idx.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7895 Scale this to the range 0..0xffff supported by X. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7896 r = (double) r * 65535 / max_color_idx;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7897 g = (double) g * 65535 / max_color_idx;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7898 b = (double) b * 65535 / max_color_idx;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7899 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7900 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7901 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7902
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7903 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7904
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7905 /* Store in IMG->colors the colors allocated for the image, and
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7906 free the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7907 img->colors = colors_in_color_table (&img->ncolors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7908 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7909
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7910 /* Put the image into a pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7911 x_put_x_image (f, ximg, img->pixmap, width, height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7912 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7913 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7914
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7915 img->width = width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7916 img->height = height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7917
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7918 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7919 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7920 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7921
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7922
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7923
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7924 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7925 PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7926 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7927
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7928 #if HAVE_PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7929
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7930 #include <png.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7931
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7932 /* Function prototypes. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7933
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7934 static int png_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7935 static int png_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7936
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7937 /* The symbol `png' identifying images of this type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7938
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7939 Lisp_Object Qpng;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7940
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7941 /* Indices of image specification fields in png_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7942
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7943 enum png_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7944 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7945 PNG_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7946 PNG_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7947 PNG_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7948 PNG_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7949 PNG_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7950 PNG_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7951 PNG_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7952 PNG_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7953 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7954
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7955 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7956 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7957
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7958 static struct image_keyword png_format[PNG_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7959 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7960 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7961 {":file", IMAGE_STRING_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7962 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7963 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7964 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7965 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7966 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7967 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7968
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7969 /* Structure describing the image type `gif'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7970
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7971 static struct image_type png_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7972 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7973 &Qpng,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7974 png_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7975 png_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7976 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7977 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7978 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7979
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7980
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7981 /* Return non-zero if OBJECT is a valid PNG image specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7982
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7983 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7984 png_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7985 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7986 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7987 struct image_keyword fmt[PNG_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7988 bcopy (png_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7989
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7990 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng, 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7991 || (fmt[PNG_ASCENT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7992 && XFASTINT (fmt[PNG_ASCENT].value) > 100))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7993 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7994 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7995 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7996
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7997
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7998 /* Error and warning handlers installed when the PNG library
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7999 is initialized. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8000
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8001 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8002 my_png_error (png_ptr, msg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8003 png_struct *png_ptr;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8004 char *msg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8005 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8006 xassert (png_ptr != NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8007 image_error ("PNG error: %s", build_string (msg), Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8008 longjmp (png_ptr->jmpbuf, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8009 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8010
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8011
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8012 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8013 my_png_warning (png_ptr, msg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8014 png_struct *png_ptr;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8015 char *msg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8016 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8017 xassert (png_ptr != NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8018 image_error ("PNG warning: %s", build_string (msg), Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8019 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8020
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8021
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8022 /* Load PNG image IMG for use on frame F. Value is non-zero if
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8023 successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8024
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8025 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8026 png_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8027 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8028 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8029 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8030 Lisp_Object file, specified_file;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
8031 int x, y, i;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8032 XImage *ximg, *mask_img = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8033 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8034 png_struct *png_ptr = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8035 png_info *info_ptr = NULL, *end_info = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8036 FILE *fp;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8037 png_byte sig[8];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8038 png_byte *pixels = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8039 png_byte **rows = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8040 png_uint_32 width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8041 int bit_depth, color_type, interlace_type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8042 png_byte channels;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8043 png_uint_32 row_bytes;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8044 int transparent_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8045 char *gamma_str;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8046 double screen_gamma, image_gamma;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8047 int intent;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8048
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8049 /* Find out what file to load. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8050 specified_file = image_spec_value (img->spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8051 file = x_find_image_file (specified_file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8052 GCPRO1 (file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8053 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8054 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8055 image_error ("Cannot find image file %s", specified_file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8056 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8057 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8058 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8059
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8060 /* Open the image file. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8061 fp = fopen (XSTRING (file)->data, "rb");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8062 if (!fp)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8063 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8064 image_error ("Cannot open image file %s", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8065 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8066 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8067 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8068 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8069
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8070 /* Check PNG signature. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8071 if (fread (sig, 1, sizeof sig, fp) != sizeof sig
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8072 || !png_check_sig (sig, sizeof sig))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8073 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8074 image_error ("Not a PNG file: %s", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8075 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8076 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8077 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8078 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8079
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8080 /* Initialize read and info structs for PNG lib. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8081 png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8082 my_png_error, my_png_warning);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8083 if (!png_ptr)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8084 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8085 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8086 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8087 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8088 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8089
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8090 info_ptr = png_create_info_struct (png_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8091 if (!info_ptr)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8092 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8093 png_destroy_read_struct (&png_ptr, NULL, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8094 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8095 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8096 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8097 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8098
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8099 end_info = png_create_info_struct (png_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8100 if (!end_info)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8101 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8102 png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8103 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8104 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8105 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8106 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8107
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8108 /* Set error jump-back. We come back here when the PNG library
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8109 detects an error. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8110 if (setjmp (png_ptr->jmpbuf))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8111 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8112 error:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8113 if (png_ptr)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8114 png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8115 xfree (pixels);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8116 xfree (rows);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8117 if (fp)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8118 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8119 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8120 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8121 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8122
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8123 /* Read image info. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8124 png_init_io (png_ptr, fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8125 png_set_sig_bytes (png_ptr, sizeof sig);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8126 png_read_info (png_ptr, info_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8127 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8128 &interlace_type, NULL, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8129
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8130 /* If image contains simply transparency data, we prefer to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8131 construct a clipping mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8132 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8133 transparent_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8134 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8135 transparent_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8136
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8137 /* This function is easier to write if we only have to handle
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8138 one data format: RGB or RGBA with 8 bits per channel. Let's
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8139 transform other formats into that format. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8140
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8141 /* Strip more than 8 bits per channel. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8142 if (bit_depth == 16)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8143 png_set_strip_16 (png_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8144
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8145 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8146 if available. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8147 png_set_expand (png_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8148
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8149 /* Convert grayscale images to RGB. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8150 if (color_type == PNG_COLOR_TYPE_GRAY
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8151 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8152 png_set_gray_to_rgb (png_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8153
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8154 /* The value 2.2 is a guess for PC monitors from PNG example.c. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8155 gamma_str = getenv ("SCREEN_GAMMA");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8156 screen_gamma = gamma_str ? atof (gamma_str) : 2.2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8157
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8158 /* Tell the PNG lib to handle gamma correction for us. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8159
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8160 if (png_get_sRGB (png_ptr, info_ptr, &intent))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8161 /* There is a special chunk in the image specifying the gamma. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8162 png_set_sRGB (png_ptr, info_ptr, intent);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8163 else if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8164 /* Image contains gamma information. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8165 png_set_gamma (png_ptr, screen_gamma, image_gamma);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8166 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8167 /* Use a default of 0.5 for the image gamma. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8168 png_set_gamma (png_ptr, screen_gamma, 0.5);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8169
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8170 /* Handle alpha channel by combining the image with a background
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8171 color. Do this only if a real alpha channel is supplied. For
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8172 simple transparency, we prefer a clipping mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8173 if (!transparent_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8174 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8175 png_color_16 *image_background;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8176
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8177 if (png_get_bKGD (png_ptr, info_ptr, &image_background))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8178 /* Image contains a background color with which to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8179 combine the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8180 png_set_background (png_ptr, image_background,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8181 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8182 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8183 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8184 /* Image does not contain a background color with which
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8185 to combine the image data via an alpha channel. Use
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8186 the frame's background instead. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8187 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8188 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8189 png_color_16 frame_background;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8190
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8191 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8192 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8193 color.pixel = FRAME_BACKGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8194 XQueryColor (FRAME_X_DISPLAY (f), cmap, &color);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8195 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8196
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8197 bzero (&frame_background, sizeof frame_background);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8198 frame_background.red = color.red;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8199 frame_background.green = color.green;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8200 frame_background.blue = color.blue;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8201
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8202 png_set_background (png_ptr, &frame_background,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8203 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8204 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8205 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8206
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8207 /* Update info structure. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8208 png_read_update_info (png_ptr, info_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8209
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8210 /* Get number of channels. Valid values are 1 for grayscale images
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8211 and images with a palette, 2 for grayscale images with transparency
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8212 information (alpha channel), 3 for RGB images, and 4 for RGB
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8213 images with alpha channel, i.e. RGBA. If conversions above were
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8214 sufficient we should only have 3 or 4 channels here. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8215 channels = png_get_channels (png_ptr, info_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8216 xassert (channels == 3 || channels == 4);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8217
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8218 /* Number of bytes needed for one row of the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8219 row_bytes = png_get_rowbytes (png_ptr, info_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8220
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8221 /* Allocate memory for the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8222 pixels = (png_byte *) xmalloc (row_bytes * height * sizeof *pixels);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8223 rows = (png_byte **) xmalloc (height * sizeof *rows);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8224 for (i = 0; i < height; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8225 rows[i] = pixels + i * row_bytes;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8226
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8227 /* Read the entire image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8228 png_read_image (png_ptr, rows);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8229 png_read_end (png_ptr, info_ptr);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8230 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8231 fp = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8232
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8233 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8234
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8235 /* Create the X image and pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8236 if (!x_create_x_image_and_pixmap (f, file, width, height, 0, &ximg,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8237 &img->pixmap))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8238 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8239 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8240 goto error;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8241 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8242
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8243 /* Create an image and pixmap serving as mask if the PNG image
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8244 contains an alpha channel. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8245 if (channels == 4
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8246 && !transparent_p
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8247 && !x_create_x_image_and_pixmap (f, file, width, height, 1,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8248 &mask_img, &img->mask))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8249 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8250 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8251 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8252 img->pixmap = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8253 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8254 goto error;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8255 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8256
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8257 /* Fill the X image and mask from PNG data. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8258 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8259
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8260 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8261 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8262 png_byte *p = rows[y];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8263
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8264 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8265 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8266 unsigned r, g, b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8267
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8268 r = *p++ << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8269 g = *p++ << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8270 b = *p++ << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8271 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8272
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8273 /* An alpha channel, aka mask channel, associates variable
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8274 transparency with an image. Where other image formats
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8275 support binary transparency---fully transparent or fully
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8276 opaque---PNG allows up to 254 levels of partial transparency.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8277 The PNG library implements partial transparency by combining
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8278 the image with a specified background color.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8279
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8280 I'm not sure how to handle this here nicely: because the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8281 background on which the image is displayed may change, for
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8282 real alpha channel support, it would be necessary to create
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8283 a new image for each possible background.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8284
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8285 What I'm doing now is that a mask is created if we have
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8286 boolean transparency information. Otherwise I'm using
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8287 the frame's background color to combine the image with. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8288
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8289 if (channels == 4)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8290 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8291 if (mask_img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8292 XPutPixel (mask_img, x, y, *p > 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8293 ++p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8294 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8295 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8296 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8297
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8298 /* Remember colors allocated for this image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8299 img->colors = colors_in_color_table (&img->ncolors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8300 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8301
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8302 /* Clean up. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8303 png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8304 xfree (rows);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8305 xfree (pixels);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8306
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8307 img->width = width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8308 img->height = height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8309
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8310 /* Put the image into the pixmap, then free the X image and its buffer. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8311 x_put_x_image (f, ximg, img->pixmap, width, height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8312 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8313
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8314 /* Same for the mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8315 if (mask_img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8316 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8317 x_put_x_image (f, mask_img, img->mask, img->width, img->height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8318 x_destroy_x_image (mask_img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8319 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8320
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8321 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8322 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8323 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8324 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8325
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8326 #endif /* HAVE_PNG != 0 */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8327
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8328
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8329
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8330 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8331 JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8332 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8333
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8334 #if HAVE_JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8335
25390
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8336 /* Work around a warning about HAVE_STDLIB_H being redefined in
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8337 jconfig.h. */
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8338 #ifdef HAVE_STDLIB_H
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8339 #define HAVE_STDLIB_H_1
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8340 #undef HAVE_STDLIB_H
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8341 #endif /* HAVE_STLIB_H */
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8342
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8343 #include <jpeglib.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8344 #include <jerror.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8345 #include <setjmp.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8346
25390
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8347 #ifdef HAVE_STLIB_H_1
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8348 #define HAVE_STDLIB_H 1
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8349 #endif
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
8350
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8351 static int jpeg_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8352 static int jpeg_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8353
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8354 /* The symbol `jpeg' identifying images of this type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8355
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8356 Lisp_Object Qjpeg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8357
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8358 /* Indices of image specification fields in gs_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8359
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8360 enum jpeg_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8361 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8362 JPEG_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8363 JPEG_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8364 JPEG_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8365 JPEG_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8366 JPEG_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8367 JPEG_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8368 JPEG_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8369 JPEG_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8370 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8371
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8372 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8373 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8374
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8375 static struct image_keyword jpeg_format[JPEG_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8376 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8377 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8378 {":file", IMAGE_STRING_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8379 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8380 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8381 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8382 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8383 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8384 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8385
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8386 /* Structure describing the image type `jpeg'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8387
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8388 static struct image_type jpeg_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8389 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8390 &Qjpeg,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8391 jpeg_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8392 jpeg_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8393 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8394 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8395 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8396
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8397
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8398 /* Return non-zero if OBJECT is a valid JPEG image specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8399
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8400 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8401 jpeg_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8402 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8403 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8404 struct image_keyword fmt[JPEG_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8405
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8406 bcopy (jpeg_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8407
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8408 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg, 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8409 || (fmt[JPEG_ASCENT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8410 && XFASTINT (fmt[JPEG_ASCENT].value) > 100))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8411 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8412 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8413 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8414
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8415 struct my_jpeg_error_mgr
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8416 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8417 struct jpeg_error_mgr pub;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8418 jmp_buf setjmp_buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8419 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8420
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8421 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8422 my_error_exit (cinfo)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8423 j_common_ptr cinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8424 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8425 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8426 longjmp (mgr->setjmp_buffer, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8427 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8428
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8429 /* Load image IMG for use on frame F. Patterned after example.c
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8430 from the JPEG lib. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8431
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8432 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8433 jpeg_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8434 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8435 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8436 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8437 struct jpeg_decompress_struct cinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8438 struct my_jpeg_error_mgr mgr;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8439 Lisp_Object file, specified_file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8440 FILE *fp;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8441 JSAMPARRAY buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8442 int row_stride, x, y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8443 XImage *ximg = NULL;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
8444 int rc;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8445 unsigned long *colors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8446 int width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8447 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8448
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8449 /* Open the JPEG file. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8450 specified_file = image_spec_value (img->spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8451 file = x_find_image_file (specified_file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8452 GCPRO1 (file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8453 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8454 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8455 image_error ("Cannot find image file %s", specified_file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8456 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8457 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8458 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8459
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8460 fp = fopen (XSTRING (file)->data, "r");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8461 if (fp == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8462 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8463 image_error ("Cannot open `%s'", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8464 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8465 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8466 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8467
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8468 /* Customize libjpeg's error handling to call my_error_exit
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8469 when an error is detected. This function will perform
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8470 a longjmp. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8471 mgr.pub.error_exit = my_error_exit;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8472 cinfo.err = jpeg_std_error (&mgr.pub);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8473
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8474 if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8475 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8476 if (rc == 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8477 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8478 /* Called from my_error_exit. Display a JPEG error. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8479 char buffer[JMSG_LENGTH_MAX];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8480 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8481 image_error ("Error reading JPEG file `%s': %s", file,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8482 build_string (buffer));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8483 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8484
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8485 /* Close the input file and destroy the JPEG object. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8486 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8487 jpeg_destroy_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8488
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8489 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8490
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8491 /* If we already have an XImage, free that. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8492 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8493
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8494 /* Free pixmap and colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8495 x_clear_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8496
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8497 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8498 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8499 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8500 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8501
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8502 /* Create the JPEG decompression object. Let it read from fp.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8503 Read the JPEG image header. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8504 jpeg_create_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8505 jpeg_stdio_src (&cinfo, fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8506 jpeg_read_header (&cinfo, TRUE);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8507
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8508 /* Customize decompression so that color quantization will be used.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8509 Start decompression. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8510 cinfo.quantize_colors = TRUE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8511 jpeg_start_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8512 width = img->width = cinfo.output_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8513 height = img->height = cinfo.output_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8514
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8515 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8516
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8517 /* Create X image and pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8518 if (!x_create_x_image_and_pixmap (f, file, width, height, 0, &ximg,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8519 &img->pixmap))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8520 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8521 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8522 longjmp (mgr.setjmp_buffer, 2);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8523 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8524
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8525 /* Allocate colors. When color quantization is used,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8526 cinfo.actual_number_of_colors has been set with the number of
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8527 colors generated, and cinfo.colormap is a two-dimensional array
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8528 of color indices in the range 0..cinfo.actual_number_of_colors.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8529 No more than 255 colors will be generated. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8530 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8531 int i, ir, ig, ib;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8532
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8533 if (cinfo.out_color_components > 2)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8534 ir = 0, ig = 1, ib = 2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8535 else if (cinfo.out_color_components > 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8536 ir = 0, ig = 1, ib = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8537 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8538 ir = 0, ig = 0, ib = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8539
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8540 /* Use the color table mechanism because it handles colors that
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8541 cannot be allocated nicely. Such colors will be replaced with
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8542 a default color, and we don't have to care about which colors
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8543 can be freed safely, and which can't. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8544 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8545 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8546 * sizeof *colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8547
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8548 for (i = 0; i < cinfo.actual_number_of_colors; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8549 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8550 /* Multiply RGB values with 255 because X expects RGB values
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8551 in the range 0..0xffff. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8552 int r = cinfo.colormap[ir][i] << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8553 int g = cinfo.colormap[ig][i] << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8554 int b = cinfo.colormap[ib][i] << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8555 colors[i] = lookup_rgb_color (f, r, g, b);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8556 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8557
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8558 /* Remember those colors actually allocated. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8559 img->colors = colors_in_color_table (&img->ncolors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8560 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8561 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8562
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8563 /* Read pixels. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8564 row_stride = width * cinfo.output_components;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8565 buffer = cinfo.mem->alloc_sarray ((j_common_ptr) &cinfo, JPOOL_IMAGE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8566 row_stride, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8567 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8568 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8569 jpeg_read_scanlines (&cinfo, buffer, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8570 for (x = 0; x < cinfo.output_width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8571 XPutPixel (ximg, x, y, colors[buffer[0][x]]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8572 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8573
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8574 /* Clean up. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8575 jpeg_finish_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8576 jpeg_destroy_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8577 fclose (fp);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8578
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8579 /* Put the image into the pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8580 x_put_x_image (f, ximg, img->pixmap, width, height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8581 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8582 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8583 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8584 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8585 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8586
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8587 #endif /* HAVE_JPEG */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8588
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8589
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8590
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8591 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8592 TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8593 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8594
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8595 #if HAVE_TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8596
25335
2de1796b006b remove tiff34 prefix from include.
Gerd Moellmann <gerd@gnu.org>
parents: 25320
diff changeset
8597 #include <tiffio.h>
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8598
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8599 static int tiff_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8600 static int tiff_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8601
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8602 /* The symbol `tiff' identifying images of this type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8603
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8604 Lisp_Object Qtiff;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8605
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8606 /* Indices of image specification fields in tiff_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8607
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8608 enum tiff_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8609 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8610 TIFF_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8611 TIFF_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8612 TIFF_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8613 TIFF_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8614 TIFF_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8615 TIFF_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8616 TIFF_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8617 TIFF_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8618 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8619
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8620 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8621 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8622
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8623 static struct image_keyword tiff_format[TIFF_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8624 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8625 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8626 {":file", IMAGE_STRING_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8627 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8628 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8629 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8630 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8631 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8632 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8633
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8634 /* Structure describing the image type `tiff'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8635
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8636 static struct image_type tiff_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8637 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8638 &Qtiff,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8639 tiff_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8640 tiff_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8641 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8642 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8643 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8644
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8645
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8646 /* Return non-zero if OBJECT is a valid TIFF image specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8647
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8648 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8649 tiff_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8650 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8651 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8652 struct image_keyword fmt[TIFF_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8653 bcopy (tiff_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8654
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8655 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff, 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8656 || (fmt[TIFF_ASCENT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8657 && XFASTINT (fmt[TIFF_ASCENT].value) > 100))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8658 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8659 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8660 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8661
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8662
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8663 /* Load TIFF image IMG for use on frame F. Value is non-zero if
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8664 successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8665
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8666 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8667 tiff_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8668 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8669 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8670 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8671 Lisp_Object file, specified_file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8672 TIFF *tiff;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8673 int width, height, x, y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8674 uint32 *buf;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8675 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8676 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8677 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8678
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8679 specified_file = image_spec_value (img->spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8680 file = x_find_image_file (specified_file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8681 GCPRO1 (file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8682 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8683 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8684 image_error ("Cannot find image file %s", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8685 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8686 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8687 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8688
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8689 /* Try to open the image file. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8690 tiff = TIFFOpen (XSTRING (file)->data, "r");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8691 if (tiff == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8692 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8693 image_error ("Cannot open `%s'", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8694 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8695 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8696 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8697
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8698 /* Get width and height of the image, and allocate a raster buffer
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8699 of width x height 32-bit values. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8700 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8701 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8702 buf = (uint32 *) xmalloc (width * height * sizeof *buf);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8703
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8704 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8705 TIFFClose (tiff);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8706 if (!rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8707 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8708 image_error ("Error reading `%s'", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8709 xfree (buf);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8710 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8711 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8712 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8713
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8714 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8715
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8716 /* Create the X image and pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8717 if (!x_create_x_image_and_pixmap (f, file, width, height, 0, &ximg,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8718 &img->pixmap))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8719 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8720 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8721 xfree (buf);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8722 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8723 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8724 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8725
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8726 /* Initialize the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8727 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8728
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8729 /* Process the pixel raster. Origin is in the lower-left corner. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8730 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8731 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8732 uint32 *row = buf + y * width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8733
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8734 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8735 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8736 uint32 abgr = row[x];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8737 int r = TIFFGetR (abgr) << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8738 int g = TIFFGetG (abgr) << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8739 int b = TIFFGetB (abgr) << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8740 XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8741 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8742 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8743
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8744 /* Remember the colors allocated for the image. Free the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8745 img->colors = colors_in_color_table (&img->ncolors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8746 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8747
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8748 /* Put the image into the pixmap, then free the X image and its buffer. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8749 x_put_x_image (f, ximg, img->pixmap, width, height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8750 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8751 xfree (buf);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8752 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8753
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8754 img->width = width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8755 img->height = height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8756
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8757 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8758 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8759 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8760
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8761 #endif /* HAVE_TIFF != 0 */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8762
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8763
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8764
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8765 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8766 GIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8767 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8768
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8769 #if HAVE_GIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8770
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8771 #include <gif_lib.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8772
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8773 static int gif_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8774 static int gif_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8775
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8776 /* The symbol `gif' identifying images of this type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8777
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8778 Lisp_Object Qgif;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8779
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8780 /* Indices of image specification fields in gif_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8781
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8782 enum gif_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8783 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8784 GIF_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8785 GIF_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8786 GIF_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8787 GIF_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8788 GIF_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8789 GIF_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8790 GIF_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8791 GIF_IMAGE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8792 GIF_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8793 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8794
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8795 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8796 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8797
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8798 static struct image_keyword gif_format[GIF_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8799 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8800 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8801 {":file", IMAGE_STRING_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8802 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8803 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8804 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8805 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8806 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8807 {":image", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8808 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8809
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8810 /* Structure describing the image type `gif'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8811
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8812 static struct image_type gif_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8813 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8814 &Qgif,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8815 gif_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8816 gif_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8817 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8818 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8819 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8820
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8821
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8822 /* Return non-zero if OBJECT is a valid GIF image specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8823
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8824 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8825 gif_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8826 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8827 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8828 struct image_keyword fmt[GIF_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8829 bcopy (gif_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8830
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8831 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif, 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8832 || (fmt[GIF_ASCENT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8833 && XFASTINT (fmt[GIF_ASCENT].value) > 100))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8834 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8835 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8836 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8837
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8838
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8839 /* Load GIF image IMG for use on frame F. Value is non-zero if
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8840 successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8841
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8842 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8843 gif_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8844 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8845 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8846 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8847 Lisp_Object file, specified_file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8848 int rc, width, height, x, y, i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8849 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8850 ColorMapObject *gif_color_map;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8851 unsigned long pixel_colors[256];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8852 GifFileType *gif;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8853 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8854 Lisp_Object image;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8855 int ino, image_left, image_top, image_width, image_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8856
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8857 specified_file = image_spec_value (img->spec, QCfile, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8858 file = x_find_image_file (specified_file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8859 GCPRO1 (file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8860 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8861 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8862 image_error ("Cannot find image file %s", specified_file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8863 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8864 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8865 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8866
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8867 /* Open the GIF file. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8868 gif = DGifOpenFileName (XSTRING (file)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8869 if (gif == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8870 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8871 image_error ("Cannot open `%s'", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8872 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8873 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8874 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8875
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8876 /* Read entire contents. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8877 rc = DGifSlurp (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8878 if (rc == GIF_ERROR)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8879 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8880 image_error ("Error reading `%s'", file, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8881 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8882 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8883 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8884 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8885
25620
1c991744ce13 (QCindex): New.
Gerd Moellmann <gerd@gnu.org>
parents: 25593
diff changeset
8886 image = image_spec_value (img->spec, QCindex, NULL);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8887 ino = INTEGERP (image) ? XFASTINT (image) : 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8888 if (ino >= gif->ImageCount)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8889 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8890 image_error ("Invalid image number `%s'", image, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8891 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8892 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8893 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8894 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8895
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8896 width = img->width = gif->SWidth;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8897 height = img->height = gif->SHeight;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8898
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8899 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8900
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8901 /* Create the X image and pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8902 if (!x_create_x_image_and_pixmap (f, file, width, height, 0, &ximg,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8903 &img->pixmap))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8904 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8905 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8906 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8907 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8908 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8909 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8910
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8911 /* Allocate colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8912 gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8913 if (!gif_color_map)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8914 gif_color_map = gif->SColorMap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8915 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8916 bzero (pixel_colors, sizeof pixel_colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8917
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8918 for (i = 0; i < gif_color_map->ColorCount; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8919 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8920 int r = gif_color_map->Colors[i].Red << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8921 int g = gif_color_map->Colors[i].Green << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8922 int b = gif_color_map->Colors[i].Blue << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8923 pixel_colors[i] = lookup_rgb_color (f, r, g, b);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8924 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8925
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8926 img->colors = colors_in_color_table (&img->ncolors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8927 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8928
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8929 /* Clear the part of the screen image that are not covered by
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8930 the image from the GIF file. Full animated GIF support
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8931 requires more than can be done here (see the gif89 spec,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8932 disposal methods). Let's simply assume that the part
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8933 not covered by a sub-image is in the frame's background color. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8934 image_top = gif->SavedImages[ino].ImageDesc.Top;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8935 image_left = gif->SavedImages[ino].ImageDesc.Left;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8936 image_width = gif->SavedImages[ino].ImageDesc.Width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8937 image_height = gif->SavedImages[ino].ImageDesc.Height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8938
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8939 for (y = 0; y < image_top; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8940 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8941 XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8942
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8943 for (y = image_top + image_height; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8944 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8945 XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8946
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8947 for (y = image_top; y < image_top + image_height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8948 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8949 for (x = 0; x < image_left; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8950 XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8951 for (x = image_left + image_width; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8952 XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8953 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8954
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8955 /* Read the GIF image into the X image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8956 if (gif->SavedImages[ino].ImageDesc.Interlace)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8957 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8958 static int interlace_start[] = {0, 4, 2, 1};
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8959 static int interlace_increment[] = {8, 8, 4, 2};
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8960 int pass, inc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8961
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8962 for (pass = 0; pass < 4; ++pass)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8963 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8964 inc = interlace_increment[pass];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8965 for (y = interlace_start[pass]; y < image_height; y += inc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8966 for (x = 0; x < image_width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8967 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8968 unsigned i = gif->SavedImages[ino].RasterBits[y * image_width + x];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8969 XPutPixel (ximg, x + image_left, y + image_top,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8970 pixel_colors[i]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8971 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8972 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8973 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8974 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8975 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8976 for (y = 0; y < image_height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8977 for (x = 0; x < image_width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8978 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8979 unsigned i = gif->SavedImages[ino].RasterBits[y * image_width + x];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8980 XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8981 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8982 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8983
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8984 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8985
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8986 /* Put the image into the pixmap, then free the X image and its buffer. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8987 x_put_x_image (f, ximg, img->pixmap, width, height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8988 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8989 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8990
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8991 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8992 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8993 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8995 #endif /* HAVE_GIF != 0 */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8996
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8997
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8998
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8999 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9000 Ghostscript
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9001 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9002
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9003 static int gs_image_p P_ ((Lisp_Object object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9004 static int gs_load P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9005 static void gs_clear_image P_ ((struct frame *f, struct image *img));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9006
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
9007 /* The symbol `postscript' identifying images of this type. */
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
9008
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
9009 Lisp_Object Qpostscript;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9010
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9011 /* Keyword symbols. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9012
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9013 Lisp_Object QCloader, QCbounding_box, QCpt_width, QCpt_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9014
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9015 /* Indices of image specification fields in gs_format, below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9016
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9017 enum gs_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9018 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9019 GS_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9020 GS_PT_WIDTH,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9021 GS_PT_HEIGHT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9022 GS_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9023 GS_LOADER,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9024 GS_BOUNDING_BOX,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9025 GS_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9026 GS_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9027 GS_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9028 GS_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9029 GS_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9030 GS_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9031 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9032
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9033 /* Vector of image_keyword structures describing the format
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9034 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9035
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9036 static struct image_keyword gs_format[GS_LAST] =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9037 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9038 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9039 {":pt-width", IMAGE_POSITIVE_INTEGER_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9040 {":pt-height", IMAGE_POSITIVE_INTEGER_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9041 {":file", IMAGE_STRING_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9042 {":loader", IMAGE_FUNCTION_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9043 {":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9044 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9045 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9046 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9047 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9048 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9049 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9050
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9051 /* Structure describing the image type `ghostscript'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9052
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9053 static struct image_type gs_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9054 {
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
9055 &Qpostscript,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9056 gs_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9057 gs_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9058 gs_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9059 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9060 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9061
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9062
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9063 /* Free X resources of Ghostscript image IMG which is used on frame F. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9064
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9065 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9066 gs_clear_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9067 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9068 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9069 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9070 /* IMG->data.ptr_val may contain a recorded colormap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9071 xfree (img->data.ptr_val);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9072 x_clear_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9073 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9074
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9075
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9076 /* Return non-zero if OBJECT is a valid Ghostscript image
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9077 specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9078
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9079 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9080 gs_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9081 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9082 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9083 struct image_keyword fmt[GS_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9084 Lisp_Object tem;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9085 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9086
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9087 bcopy (gs_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9088
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
9089 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript, 1)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9090 || (fmt[GS_ASCENT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9091 && XFASTINT (fmt[GS_ASCENT].value) > 100))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9092 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9093
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9094 /* Bounding box must be a list or vector containing 4 integers. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9095 tem = fmt[GS_BOUNDING_BOX].value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9096 if (CONSP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9097 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9098 for (i = 0; i < 4; ++i, tem = XCDR (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9099 if (!CONSP (tem) || !INTEGERP (XCAR (tem)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9100 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9101 if (!NILP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9102 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9103 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9104 else if (VECTORP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9105 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9106 if (XVECTOR (tem)->size != 4)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9107 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9108 for (i = 0; i < 4; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9109 if (!INTEGERP (XVECTOR (tem)->contents[i]))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9110 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9111 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9112 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9113 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9114
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9115 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9116 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9117
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9118
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9119 /* Load Ghostscript image IMG for use on frame F. Value is non-zero
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9120 if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9121
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9122 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9123 gs_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9124 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9125 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9126 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9127 char buffer[100];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9128 Lisp_Object window_and_pixmap_id = Qnil, loader, pt_height, pt_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9129 struct gcpro gcpro1, gcpro2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9130 Lisp_Object frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9131 double in_width, in_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9132 Lisp_Object pixel_colors = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9133
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9134 /* Compute pixel size of pixmap needed from the given size in the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9135 image specification. Sizes in the specification are in pt. 1 pt
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9136 = 1/72 in, xdpi and ydpi are stored in the frame's X display
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9137 info. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9138 pt_width = image_spec_value (img->spec, QCpt_width, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9139 in_width = XFASTINT (pt_width) / 72.0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9140 img->width = in_width * FRAME_X_DISPLAY_INFO (f)->resx;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9141 pt_height = image_spec_value (img->spec, QCpt_height, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9142 in_height = XFASTINT (pt_height) / 72.0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9143 img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9144
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9145 /* Create the pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9146 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9147 xassert (img->pixmap == 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9148 img->pixmap = XCreatePixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9149 img->width, img->height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9150 DefaultDepthOfScreen (FRAME_X_SCREEN (f)));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9151 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9152
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9153 if (!img->pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9154 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9155 image_error ("Unable to create pixmap for `%s'",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9156 image_spec_value (img->spec, QCfile, NULL), Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9157 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9158 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9159
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9160 /* Call the loader to fill the pixmap. It returns a process object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9161 if successful. We do not record_unwind_protect here because
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9162 other places in redisplay like calling window scroll functions
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9163 don't either. Let the Lisp loader use `unwind-protect' instead. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9164 GCPRO2 (window_and_pixmap_id, pixel_colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9165
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9166 sprintf (buffer, "%lu %lu",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9167 (unsigned long) FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9168 (unsigned long) img->pixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9169 window_and_pixmap_id = build_string (buffer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9170
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9171 sprintf (buffer, "%lu %lu",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9172 FRAME_FOREGROUND_PIXEL (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9173 FRAME_BACKGROUND_PIXEL (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9174 pixel_colors = build_string (buffer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9175
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9176 XSETFRAME (frame, f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9177 loader = image_spec_value (img->spec, QCloader, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9178 if (NILP (loader))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9179 loader = intern ("gs-load-image");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9180
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9181 img->data.lisp_val = call6 (loader, frame, img->spec,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9182 make_number (img->width),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9183 make_number (img->height),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9184 window_and_pixmap_id,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9185 pixel_colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9186 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9187 return PROCESSP (img->data.lisp_val);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9188 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9189
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9190
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9191 /* Kill the Ghostscript process that was started to fill PIXMAP on
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9192 frame F. Called from XTread_socket when receiving an event
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9193 telling Emacs that Ghostscript has finished drawing. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9194
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9195 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9196 x_kill_gs_process (pixmap, f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9197 Pixmap pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9198 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9199 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9200 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9201 int class, i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9202 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9203
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9204 /* Find the image containing PIXMAP. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9205 for (i = 0; i < c->used; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9206 if (c->images[i]->pixmap == pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9207 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9208
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9209 /* Kill the GS process. We should have found PIXMAP in the image
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9210 cache and its image should contain a process object. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9211 xassert (i < c->used);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9212 img = c->images[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9213 xassert (PROCESSP (img->data.lisp_val));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9214 Fkill_process (img->data.lisp_val, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9215 img->data.lisp_val = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9216
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9217 /* On displays with a mutable colormap, figure out the colors
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9218 allocated for the image by looking at the pixels of an XImage for
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9219 img->pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9220 class = FRAME_X_DISPLAY_INFO (f)->visual->class;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9221 if (class != StaticColor && class != StaticGray && class != TrueColor)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9222 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9223 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9224
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9225 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9226
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9227 /* Try to get an XImage for img->pixmep. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9228 ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9229 0, 0, img->width, img->height, ~0, ZPixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9230 if (ximg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9231 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9232 int x, y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9233
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9234 /* Initialize the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9235 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9236
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9237 /* For each pixel of the image, look its color up in the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9238 color table. After having done so, the color table will
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9239 contain an entry for each color used by the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9240 for (y = 0; y < img->height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9241 for (x = 0; x < img->width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9242 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9243 unsigned long pixel = XGetPixel (ximg, x, y);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9244 lookup_pixel_color (f, pixel);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9245 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9246
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9247 /* Record colors in the image. Free color table and XImage. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9248 img->colors = colors_in_color_table (&img->ncolors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9249 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9250 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9251
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9252 #if 0 /* This doesn't seem to be the case. If we free the colors
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9253 here, we get a BadAccess later in x_clear_image when
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9254 freeing the colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9255 /* We have allocated colors once, but Ghostscript has also
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9256 allocated colors on behalf of us. So, to get the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9257 reference counts right, free them once. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9258 if (img->ncolors)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9259 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9260 Colormap cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9261 XFreeColors (FRAME_X_DISPLAY (f), cmap,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9262 img->colors, img->ncolors, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9263 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9264 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9265 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9266 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9267 image_error ("Cannot get X image of `%s'; colors will not be freed",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9268 image_spec_value (img->spec, QCfile, NULL), Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9269
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9270 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9271 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9272 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9273
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9274
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9275
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9276 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9277 Window properties
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9278 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9279
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9280 DEFUN ("x-change-window-property", Fx_change_window_property,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9281 Sx_change_window_property, 2, 3, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9282 "Change window property PROP to VALUE on the X window of FRAME.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9283 PROP and VALUE must be strings. FRAME nil or omitted means use the\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9284 selected frame. Value is VALUE.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9285 (prop, value, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9286 Lisp_Object frame, prop, value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9287 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9288 struct frame *f = check_x_frame (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9289 Atom prop_atom;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9290
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9291 CHECK_STRING (prop, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9292 CHECK_STRING (value, 2);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9293
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9294 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9295 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9296 XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9297 prop_atom, XA_STRING, 8, PropModeReplace,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9298 XSTRING (value)->data, XSTRING (value)->size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9299
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9300 /* Make sure the property is set when we return. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9301 XFlush (FRAME_X_DISPLAY (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9302 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9303
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9304 return value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9305 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9306
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9307
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9308 DEFUN ("x-delete-window-property", Fx_delete_window_property,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9309 Sx_delete_window_property, 1, 2, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9310 "Remove window property PROP from X window of FRAME.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9311 FRAME nil or omitted means use the selected frame. Value is PROP.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9312 (prop, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9313 Lisp_Object prop, frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9314 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9315 struct frame *f = check_x_frame (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9316 Atom prop_atom;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9317
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9318 CHECK_STRING (prop, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9319 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9320 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9321 XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9322
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9323 /* Make sure the property is removed when we return. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9324 XFlush (FRAME_X_DISPLAY (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9325 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9326
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9327 return prop;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9328 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9329
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9330
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9331 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9332 1, 2, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9333 "Value is the value of window property PROP on FRAME.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9334 If FRAME is nil or omitted, use the selected frame. Value is nil\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9335 if FRAME hasn't a property with name PROP or if PROP has no string\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9336 value.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9337 (prop, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9338 Lisp_Object prop, frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9339 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9340 struct frame *f = check_x_frame (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9341 Atom prop_atom;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9342 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9343 Lisp_Object prop_value = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9344 char *tmp_data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9345 Atom actual_type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9346 int actual_format;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9347 unsigned long actual_size, bytes_remaining;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9348
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9349 CHECK_STRING (prop, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9350 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9351 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9352 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9353 prop_atom, 0, 0, False, XA_STRING,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9354 &actual_type, &actual_format, &actual_size,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9355 &bytes_remaining, (unsigned char **) &tmp_data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9356 if (rc == Success)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9357 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9358 int size = bytes_remaining;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9359
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9360 XFree (tmp_data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9361 tmp_data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9362
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9363 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9364 prop_atom, 0, bytes_remaining,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9365 False, XA_STRING,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9366 &actual_type, &actual_format,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9367 &actual_size, &bytes_remaining,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9368 (unsigned char **) &tmp_data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9369 if (rc == Success)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9370 prop_value = make_string (tmp_data, size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9371
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9372 XFree (tmp_data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9373 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9374
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9375 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9376 return prop_value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9377 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9378
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9379
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9380
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9381 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9382 Busy cursor
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9383 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9384
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9385 /* The implementation partly follows a patch from
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9386 F.Pierresteguy@frcl.bull.fr dated 1994. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9387
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9388 /* Setting inhibit_busy_cursor to 2 inhibits busy-cursor display until
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9389 the next X event is read and we enter XTread_socket again. Setting
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9390 it to 1 inhibits busy-cursor display for direct commands. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9391
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9392 int inhibit_busy_cursor;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9393
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9394 /* Incremented with each call to x-display-busy-cursor.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9395 Decremented in x-undisplay-busy-cursor. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9396
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9397 static int busy_count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9398
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9399
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9400 DEFUN ("x-show-busy-cursor", Fx_show_busy_cursor,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9401 Sx_show_busy_cursor, 0, 0, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9402 "Show a busy cursor, if not already shown.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9403 Each call to this function must be matched by a call to\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9404 x-undisplay-busy-cursor to make the busy pointer disappear again.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9405 ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9406 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9407 ++busy_count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9408 if (busy_count == 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9409 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9410 Lisp_Object rest, frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9411
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9412 FOR_EACH_FRAME (rest, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9413 if (FRAME_X_P (XFRAME (frame)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9414 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9415 struct frame *f = XFRAME (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9416
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9417 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9418 f->output_data.x->busy_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9419
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9420 if (!f->output_data.x->busy_window)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9421 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9422 unsigned long mask = CWCursor;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9423 XSetWindowAttributes attrs;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9424
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9425 attrs.cursor = f->output_data.x->busy_cursor;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9426 f->output_data.x->busy_window
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9427 = XCreateWindow (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9428 FRAME_OUTER_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9429 0, 0, 32000, 32000, 0, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9430 InputOnly, CopyFromParent,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9431 mask, &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9432 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9433
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9434 XMapRaised (FRAME_X_DISPLAY (f), f->output_data.x->busy_window);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9435 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9436 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9437 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9438
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9439 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9440 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9441
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9442
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9443 DEFUN ("x-hide-busy-cursor", Fx_hide_busy_cursor,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9444 Sx_hide_busy_cursor, 0, 1, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9445 "Hide a busy-cursor.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9446 A busy-cursor will actually be undisplayed when a matching\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9447 `x-undisplay-busy-cursor' is called for each `x-display-busy-cursor'\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9448 issued. FORCE non-nil means undisplay the busy-cursor forcibly,\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9449 not counting calls.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9450 (force)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9451 Lisp_Object force;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9452 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9453 Lisp_Object rest, frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9454
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9455 if (busy_count == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9456 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9457
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9458 if (!NILP (force) && busy_count != 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9459 busy_count = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9460
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9461 --busy_count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9462 if (busy_count != 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9463 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9464
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9465 FOR_EACH_FRAME (rest, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9466 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9467 struct frame *f = XFRAME (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9468
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9469 if (FRAME_X_P (f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9470 /* Watch out for newly created frames. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9471 && f->output_data.x->busy_window)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9472 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9473
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9474 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9475 XUnmapWindow (FRAME_X_DISPLAY (f), f->output_data.x->busy_window);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9476 /* Sync here because XTread_socket looks at the busy_p flag
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9477 that is reset to zero below. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9478 XSync (FRAME_X_DISPLAY (f), False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9479 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9480 f->output_data.x->busy_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9481 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9482 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9483
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9484 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9485 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9486
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9487
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9488
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9489 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9490 Tool tips
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9491 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9492
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9493 static Lisp_Object x_create_tip_frame P_ ((struct x_display_info *,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9494 Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9495
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9496 /* The frame of a currently visible tooltip, or null. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9497
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9498 struct frame *tip_frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9499
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9500 /* If non-nil, a timer started that hides the last tooltip when it
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9501 fires. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9502
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9503 Lisp_Object tip_timer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9504 Window tip_window;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9505
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9506 /* Create a frame for a tooltip on the display described by DPYINFO.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9507 PARMS is a list of frame parameters. Value is the frame. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9508
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9509 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9510 x_create_tip_frame (dpyinfo, parms)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9511 struct x_display_info *dpyinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9512 Lisp_Object parms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9513 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9514 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9515 Lisp_Object frame, tem;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9516 Lisp_Object name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9517 long window_prompting = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9518 int width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9519 int count = specpdl_ptr - specpdl;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
9520 struct gcpro gcpro1, gcpro2, gcpro3;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9521 struct kboard *kb;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9522
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9523 check_x ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9524
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9525 /* Use this general default value to start with until we know if
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9526 this frame has a specified name. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9527 Vx_resource_name = Vinvocation_name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9528
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9529 #ifdef MULTI_KBOARD
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9530 kb = dpyinfo->kboard;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9531 #else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9532 kb = &the_only_kboard;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9533 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9534
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9535 /* Get the name of the frame to use for resource lookup. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9536 name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9537 if (!STRINGP (name)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9538 && !EQ (name, Qunbound)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9539 && !NILP (name))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9540 error ("Invalid frame name--not a string or nil");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9541 Vx_resource_name = name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9542
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9543 frame = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9544 GCPRO3 (parms, name, frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9545 tip_frame = f = make_frame (1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9546 XSETFRAME (frame, f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9547 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9548
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9549 f->output_method = output_x_window;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9550 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9551 bzero (f->output_data.x, sizeof (struct x_output));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9552 f->output_data.x->icon_bitmap = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9553 f->output_data.x->fontset = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9554 f->icon_name = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9555 FRAME_X_DISPLAY_INFO (f) = dpyinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9556 #ifdef MULTI_KBOARD
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9557 FRAME_KBOARD (f) = kb;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9558 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9559 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9560 f->output_data.x->explicit_parent = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9561
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9562 /* Set the name; the functions to which we pass f expect the name to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9563 be set. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9564 if (EQ (name, Qunbound) || NILP (name))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9565 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9566 f->name = build_string (dpyinfo->x_id_name);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9567 f->explicit_name = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9568 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9569 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9570 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9571 f->name = name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9572 f->explicit_name = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9573 /* use the frame's title when getting resources for this frame. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9574 specbind (Qx_resource_name, name);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9575 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9576
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9577 /* Create fontsets from `global_fontset_alist' before handling fonts. */
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
9578 for (tem = Vglobal_fontset_alist; CONSP (tem); tem = XCDR (tem))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
9579 fs_register_fontset (f, XCAR (tem));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9580
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9581 /* Extract the window parameters from the supplied values
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9582 that are needed to determine window geometry. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9583 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9584 Lisp_Object font;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9585
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9586 font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9587
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9588 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9589 /* First, try whatever font the caller has specified. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9590 if (STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9591 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9592 tem = Fquery_fontset (font, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9593 if (STRINGP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9594 font = x_new_fontset (f, XSTRING (tem)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9595 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9596 font = x_new_font (f, XSTRING (font)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9597 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9598
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9599 /* Try out a font which we hope has bold and italic variations. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9600 if (!STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9601 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9602 if (!STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9603 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9604 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9605 font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9606 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9607 /* This was formerly the first thing tried, but it finds too many fonts
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9608 and takes too long. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9609 font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9610 /* If those didn't work, look for something which will at least work. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9611 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9612 font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9613 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9614 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9615 font = build_string ("fixed");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9616
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9617 x_default_parameter (f, parms, Qfont, font,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9618 "font", "Font", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9619 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9620
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9621 x_default_parameter (f, parms, Qborder_width, make_number (2),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9622 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9623
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9624 /* This defaults to 2 in order to match xterm. We recognize either
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9625 internalBorderWidth or internalBorder (which is what xterm calls
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9626 it). */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9627 if (NILP (Fassq (Qinternal_border_width, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9628 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9629 Lisp_Object value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9630
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9631 value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9632 "internalBorder", "internalBorder", RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9633 if (! EQ (value, Qunbound))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9634 parms = Fcons (Fcons (Qinternal_border_width, value),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9635 parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9636 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9637
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9638 x_default_parameter (f, parms, Qinternal_border_width, make_number (1),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9639 "internalBorderWidth", "internalBorderWidth",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9640 RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9641
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9642 /* Also do the stuff which must be set before the window exists. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9643 x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9644 "foreground", "Foreground", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9645 x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9646 "background", "Background", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9647 x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9648 "pointerColor", "Foreground", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9649 x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9650 "cursorColor", "Foreground", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9651 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9652 "borderColor", "BorderColor", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9653
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9654 /* Init faces before x_default_parameter is called for scroll-bar
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9655 parameters because that function calls x_set_scroll_bar_width,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9656 which calls change_frame_size, which calls Fset_window_buffer,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9657 which runs hooks, which call Fvertical_motion. At the end, we
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9658 end up in init_iterator with a null face cache, which should not
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9659 happen. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9660 init_frame_faces (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9661
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9662 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9663 window_prompting = x_figure_window_size (f, parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9664
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9665 if (window_prompting & XNegative)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9666 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9667 if (window_prompting & YNegative)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9668 f->output_data.x->win_gravity = SouthEastGravity;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9669 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9670 f->output_data.x->win_gravity = NorthEastGravity;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9671 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9672 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9673 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9674 if (window_prompting & YNegative)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9675 f->output_data.x->win_gravity = SouthWestGravity;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9676 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9677 f->output_data.x->win_gravity = NorthWestGravity;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9678 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9679
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9680 f->output_data.x->size_hint_flags = window_prompting;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9681 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9682 XSetWindowAttributes attrs;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9683 unsigned long mask;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9684
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9685 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9686 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9687 /* Window managers looks at the override-redirect flag to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9688 determine whether or net to give windows a decoration (Xlib
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9689 3.2.8). */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9690 attrs.override_redirect = True;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9691 attrs.save_under = True;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9692 attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9693 /* Arrange for getting MapNotify and UnmapNotify events. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9694 attrs.event_mask = StructureNotifyMask;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9695 tip_window
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9696 = FRAME_X_WINDOW (f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9697 = XCreateWindow (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9698 FRAME_X_DISPLAY_INFO (f)->root_window,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9699 /* x, y, width, height */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9700 0, 0, 1, 1,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9701 /* Border. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9702 1,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9703 CopyFromParent, InputOutput, CopyFromParent,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9704 mask, &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9705 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9706 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9707
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9708 x_make_gc (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9709
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9710 x_default_parameter (f, parms, Qauto_raise, Qnil,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9711 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9712 x_default_parameter (f, parms, Qauto_lower, Qnil,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9713 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9714 x_default_parameter (f, parms, Qcursor_type, Qbox,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9715 "cursorType", "CursorType", RES_TYPE_SYMBOL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9716
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9717 /* Dimensions, especially f->height, must be done via change_frame_size.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9718 Change will not be effected unless different from the current
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9719 f->height. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9720 width = f->width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9721 height = f->height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9722 f->height = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9723 SET_FRAME_WIDTH (f, 0);
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
9724 change_frame_size (f, height, width, 1, 0, 0);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9725
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9726 f->no_split = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9727
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9728 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9729
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9730 /* It is now ok to make the frame official even if we get an error
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9731 below. And the frame needs to be on Vframe_list or making it
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9732 visible won't work. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9733 Vframe_list = Fcons (frame, Vframe_list);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9734
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9735 /* Now that the frame is official, it counts as a reference to
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9736 its display. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9737 FRAME_X_DISPLAY_INFO (f)->reference_count++;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9738
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9739 return unbind_to (count, frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9740 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9741
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9742
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9743 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 4, 0,
25550
05f27fc24f81 (Fx_show_tip): Improve documentation.
Gerd Moellmann <gerd@gnu.org>
parents: 25544
diff changeset
9744 "Show STRING in a \"tooltip\" window on frame FRAME.\n\
05f27fc24f81 (Fx_show_tip): Improve documentation.
Gerd Moellmann <gerd@gnu.org>
parents: 25544
diff changeset
9745 A tooltip window is a small X window displaying STRING at\n\
05f27fc24f81 (Fx_show_tip): Improve documentation.
Gerd Moellmann <gerd@gnu.org>
parents: 25544
diff changeset
9746 the current mouse position.\n\
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9747 FRAME nil or omitted means use the selected frame.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9748 PARMS is an optional list of frame parameters which can be\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9749 used to change the tooltip's appearance.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9750 Automatically hide the tooltip after TIMEOUT seconds.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9751 TIMEOUT nil means use the default timeout of 5 seconds.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9752 (string, frame, parms, timeout)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9753 Lisp_Object string, frame, parms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9754 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9755 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9756 struct window *w;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9757 Window root, child;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9758 Lisp_Object buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9759 struct buffer *old_buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9760 struct text_pos pos;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9761 int i, width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9762 int root_x, root_y, win_x, win_y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9763 unsigned pmask;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9764 struct gcpro gcpro1, gcpro2, gcpro3;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9765 int old_windows_or_buffers_changed = windows_or_buffers_changed;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9766 int count = specpdl_ptr - specpdl;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9767
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9768 specbind (Qinhibit_redisplay, Qt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9769
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9770 GCPRO3 (string, parms, frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9771
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9772 CHECK_STRING (string, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9773 f = check_x_frame (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9774 if (NILP (timeout))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9775 timeout = make_number (5);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9776 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9777 CHECK_NATNUM (timeout, 2);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9778
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9779 /* Hide a previous tip, if any. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9780 Fx_hide_tip ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9781
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9782 /* Add default values to frame parameters. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9783 if (NILP (Fassq (Qname, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9784 parms = Fcons (Fcons (Qname, build_string ("tooltip")), parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9785 if (NILP (Fassq (Qinternal_border_width, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9786 parms = Fcons (Fcons (Qinternal_border_width, make_number (3)), parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9787 if (NILP (Fassq (Qborder_width, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9788 parms = Fcons (Fcons (Qborder_width, make_number (1)), parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9789 if (NILP (Fassq (Qborder_color, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9790 parms = Fcons (Fcons (Qborder_color, build_string ("lightyellow")), parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9791 if (NILP (Fassq (Qbackground_color, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9792 parms = Fcons (Fcons (Qbackground_color, build_string ("lightyellow")),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9793 parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9794
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9795 /* Create a frame for the tooltip, and record it in the global
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9796 variable tip_frame. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9797 frame = x_create_tip_frame (FRAME_X_DISPLAY_INFO (f), parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9798 tip_frame = f = XFRAME (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9799
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9800 /* Set up the frame's root window. Currently we use a size of 80
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9801 columns x 40 lines. If someone wants to show a larger tip, he
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9802 will loose. I don't think this is a realistic case. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9803 w = XWINDOW (FRAME_ROOT_WINDOW (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9804 w->left = w->top = make_number (0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9805 w->width = 80;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9806 w->height = 40;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9807 adjust_glyphs (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9808 w->pseudo_window_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9809
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9810 /* Display the tooltip text in a temporary buffer. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9811 buffer = Fget_buffer_create (build_string (" *tip*"));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9812 Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9813 old_buffer = current_buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9814 set_buffer_internal_1 (XBUFFER (buffer));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9815 Ferase_buffer ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9816 Finsert (make_number (1), &string);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9817 clear_glyph_matrix (w->desired_matrix);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9818 clear_glyph_matrix (w->current_matrix);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9819 SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9820 try_window (FRAME_ROOT_WINDOW (f), pos);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9821
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9822 /* Compute width and height of the tooltip. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9823 width = height = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9824 for (i = 0; i < w->desired_matrix->nrows; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9825 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9826 struct glyph_row *row = &w->desired_matrix->rows[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9827 struct glyph *last;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9828 int row_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9829
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9830 /* Stop at the first empty row at the end. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9831 if (!row->enabled_p || !row->displays_text_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9832 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9833
25082
ba6bf065b287 (x_create_tip_frame): Don't set bitmapIcon resource.
Gerd Moellmann <gerd@gnu.org>
parents: 25075
diff changeset
9834 /* Let the row go over the full width of the frame. */
ba6bf065b287 (x_create_tip_frame): Don't set bitmapIcon resource.
Gerd Moellmann <gerd@gnu.org>
parents: 25075
diff changeset
9835 row->full_width_p = 1;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9836
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9837 /* There's a glyph at the end of rows that is use to place
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9838 the cursor there. Don't include the width of this glyph. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9839 if (row->used[TEXT_AREA])
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9840 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9841 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9842 row_width = row->pixel_width - last->pixel_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9843 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9844 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9845 row_width = row->pixel_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9846
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9847 height += row->height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9848 width = max (width, row_width);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9849 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9850
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9851 /* Add the frame's internal border to the width and height the X
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9852 window should have. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9853 height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9854 width += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9855
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9856 /* Move the tooltip window where the mouse pointer is. Resize and
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9857 show it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9858 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9859 XQueryPointer (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9860 &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9861 XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9862 root_x + 5, root_y - height - 5, width, height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9863 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9864 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9865
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9866 /* Draw into the window. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9867 w->must_be_updated_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9868 update_single_window (w, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9869
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9870 /* Restore original current buffer. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9871 set_buffer_internal_1 (old_buffer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9872 windows_or_buffers_changed = old_windows_or_buffers_changed;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9873
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9874 /* Let the tip disappear after timeout seconds. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9875 tip_timer = call3 (intern ("run-at-time"), timeout, Qnil,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9876 intern ("x-hide-tip"));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9877
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9878 return unbind_to (count, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9879 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9880
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9881
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9882 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
25550
05f27fc24f81 (Fx_show_tip): Improve documentation.
Gerd Moellmann <gerd@gnu.org>
parents: 25544
diff changeset
9883 "Hide the current tooltip window, if there is any.\n\
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9884 Value is t is tooltip was open, nil otherwise.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9885 ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9886 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9887 int count = specpdl_ptr - specpdl;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9888 int deleted_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9889
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9890 specbind (Qinhibit_redisplay, Qt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9891
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9892 if (!NILP (tip_timer))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9893 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9894 call1 (intern ("cancel-timer"), tip_timer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9895 tip_timer = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9896 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9897
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9898 if (tip_frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9899 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9900 Lisp_Object frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9901
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9902 XSETFRAME (frame, tip_frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9903 Fdelete_frame (frame, Qt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9904 tip_frame = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9905 deleted_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9906 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9907
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9908 return unbind_to (count, deleted_p ? Qt : Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9909 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9910
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9911
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9912
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9913 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9914 File selection dialog
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9915 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9916
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9917 #ifdef USE_MOTIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9918
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9919 /* Callback for "OK" and "Cancel" on file selection dialog. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9920
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9921 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9922 file_dialog_cb (widget, client_data, call_data)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9923 Widget widget;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9924 XtPointer call_data, client_data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9925 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9926 int *result = (int *) client_data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9927 XmAnyCallbackStruct *cb = (XmAnyCallbackStruct *) call_data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9928 *result = cb->reason;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9929 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9930
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9931
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9932 DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9933 "Read file name, prompting with PROMPT in directory DIR.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9934 Use a file selection dialog.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9935 Select DEFAULT-FILENAME in the dialog's file selection box, if\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9936 specified. Don't let the user enter a file name in the file\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9937 selection dialog's entry field, if MUSTMATCH is non-nil.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9938 (prompt, dir, default_filename, mustmatch)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9939 Lisp_Object prompt, dir, default_filename, mustmatch;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9940 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9941 int result;
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
9942 struct frame *f = SELECTED_FRAME ();
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9943 Lisp_Object file = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9944 Widget dialog, text, list, help;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9945 Arg al[10];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9946 int ac = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9947 extern XtAppContext Xt_app_con;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9948 char *title;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9949 XmString dir_xmstring, pattern_xmstring;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9950 int popup_activated_flag;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9951 int count = specpdl_ptr - specpdl;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9952 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9953
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9954 GCPRO5 (prompt, dir, default_filename, mustmatch, file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9955 CHECK_STRING (prompt, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9956 CHECK_STRING (dir, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9957
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9958 /* Prevent redisplay. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9959 specbind (Qinhibit_redisplay, Qt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9960
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9961 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9962
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9963 /* Create the dialog with PROMPT as title, using DIR as initial
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9964 directory and using "*" as pattern. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9965 dir = Fexpand_file_name (dir, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9966 dir_xmstring = XmStringCreateLocalized (XSTRING (dir)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9967 pattern_xmstring = XmStringCreateLocalized ("*");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9968
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9969 XtSetArg (al[ac], XmNtitle, XSTRING (prompt)->data); ++ac;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9970 XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9971 XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9972 XtSetArg (al[ac], XmNresizePolicy, XmRESIZE_GROW); ++ac;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9973 XtSetArg (al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ++ac;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9974 dialog = XmCreateFileSelectionDialog (f->output_data.x->widget,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9975 "fsb", al, ac);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9976 XmStringFree (dir_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9977 XmStringFree (pattern_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9978
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9979 /* Add callbacks for OK and Cancel. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9980 XtAddCallback (dialog, XmNokCallback, file_dialog_cb,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9981 (XtPointer) &result);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9982 XtAddCallback (dialog, XmNcancelCallback, file_dialog_cb,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9983 (XtPointer) &result);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9984
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9985 /* Disable the help button since we can't display help. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9986 help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9987 XtSetSensitive (help, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9988
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9989 /* Mark OK button as default. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9990 XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9991 XmNshowAsDefault, True, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9992
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9993 /* If MUSTMATCH is non-nil, disable the file entry field of the
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9994 dialog, so that the user must select a file from the files list
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9995 box. We can't remove it because we wouldn't have a way to get at
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9996 the result file name, then. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9997 text = XmFileSelectionBoxGetChild (dialog, XmDIALOG_TEXT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9998 if (!NILP (mustmatch))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9999 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10000 Widget label;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10001 label = XmFileSelectionBoxGetChild (dialog, XmDIALOG_SELECTION_LABEL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10002 XtSetSensitive (text, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10003 XtSetSensitive (label, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10004 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10005
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10006 /* Manage the dialog, so that list boxes get filled. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10007 XtManageChild (dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10008
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10009 /* Select DEFAULT_FILENAME in the files list box. DEFAULT_FILENAME
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10010 must include the path for this to work. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10011 list = XmFileSelectionBoxGetChild (dialog, XmDIALOG_LIST);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10012 if (STRINGP (default_filename))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10013 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10014 XmString default_xmstring;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10015 int item_pos;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10016
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10017 default_xmstring
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10018 = XmStringCreateLocalized (XSTRING (default_filename)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10019
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10020 if (!XmListItemExists (list, default_xmstring))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10021 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10022 /* Add a new item if DEFAULT_FILENAME is not in the list. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10023 XmListAddItem (list, default_xmstring, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10024 item_pos = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10025 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10026 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10027 item_pos = XmListItemPos (list, default_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10028 XmStringFree (default_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10029
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10030 /* Select the item and scroll it into view. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10031 XmListSelectPos (list, item_pos, True);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10032 XmListSetPos (list, item_pos);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10033 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10034
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10035 /* Process all events until the user presses Cancel or OK. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10036 for (result = 0; result == 0;)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10037 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10038 XEvent event;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10039 Widget widget, parent;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10040
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10041 XtAppNextEvent (Xt_app_con, &event);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10042
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10043 /* See if the receiver of the event is one of the widgets of
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10044 the file selection dialog. If so, dispatch it. If not,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10045 discard it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10046 widget = XtWindowToWidget (event.xany.display, event.xany.window);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10047 parent = widget;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10048 while (parent && parent != dialog)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10049 parent = XtParent (parent);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10050
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10051 if (parent == dialog
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10052 || (event.type == Expose
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10053 && !process_expose_from_menu (event)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10054 XtDispatchEvent (&event);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10055 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10056
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10057 /* Get the result. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10058 if (result == XmCR_OK)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10059 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10060 XmString text;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10061 String data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10062
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10063 XtVaGetValues (dialog, XmNtextString, &text, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10064 XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10065 XmStringFree (text);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10066 file = build_string (data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10067 XtFree (data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10068 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10069 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10070 file = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10071
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10072 /* Clean up. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10073 XtUnmanageChild (dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10074 XtDestroyWidget (dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10075 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10076 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10077
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10078 /* Make "Cancel" equivalent to C-g. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10079 if (NILP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10080 Fsignal (Qquit, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10081
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10082 return unbind_to (count, file);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10083 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10084
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10085 #endif /* USE_MOTIF */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10086
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10087
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10088 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10089 Tests
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10090 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10091
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10092 #if GLYPH_DEBUG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10093
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10094 DEFUN ("imagep", Fimagep, Simagep, 1, 1, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10095 "Value is non-nil if SPEC is a valid image specification.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10096 (spec)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10097 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10098 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10099 return valid_image_p (spec) ? Qt : Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10100 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10101
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10102
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10103 DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 1, 0, "")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10104 (spec)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10105 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10106 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10107 int id = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10108
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10109 if (valid_image_p (spec))
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
10110 id = lookup_image (SELECTED_FRAME (), spec);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10111
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10112 debug_print (spec);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10113 return make_number (id);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10114 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10115
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10116 #endif /* GLYPH_DEBUG != 0 */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10117
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10118
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10119
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10120 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10121 Initialization
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10122 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10123
21846
486ac68ce051 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21779
diff changeset
10124 void
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10125 syms_of_xfns ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10126 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10127 /* This is zero if not using X windows. */
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
10128 x_in_use = 0;
9014
7b805f79f3b4 (Fx_list_fonts): Use a cache stored in FRAME_X_SCREEN.
Richard M. Stallman <rms@gnu.org>
parents: 8961
diff changeset
10129
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10130 /* The section below is built by the lisp expression at the top of the file,
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10131 just above where these variables are declared. */
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10132 /*&&& init symbols here &&&*/
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10133 Qauto_raise = intern ("auto-raise");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10134 staticpro (&Qauto_raise);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10135 Qauto_lower = intern ("auto-lower");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10136 staticpro (&Qauto_lower);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10137 Qbar = intern ("bar");
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10138 staticpro (&Qbar);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10139 Qborder_color = intern ("border-color");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10140 staticpro (&Qborder_color);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10141 Qborder_width = intern ("border-width");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10142 staticpro (&Qborder_width);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10143 Qbox = intern ("box");
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10144 staticpro (&Qbox);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10145 Qcursor_color = intern ("cursor-color");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10146 staticpro (&Qcursor_color);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10147 Qcursor_type = intern ("cursor-type");
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10148 staticpro (&Qcursor_type);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10149 Qgeometry = intern ("geometry");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10150 staticpro (&Qgeometry);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10151 Qicon_left = intern ("icon-left");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10152 staticpro (&Qicon_left);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10153 Qicon_top = intern ("icon-top");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10154 staticpro (&Qicon_top);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10155 Qicon_type = intern ("icon-type");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10156 staticpro (&Qicon_type);
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
10157 Qicon_name = intern ("icon-name");
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
10158 staticpro (&Qicon_name);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10159 Qinternal_border_width = intern ("internal-border-width");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10160 staticpro (&Qinternal_border_width);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10161 Qleft = intern ("left");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10162 staticpro (&Qleft);
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
10163 Qright = intern ("right");
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
10164 staticpro (&Qright);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10165 Qmouse_color = intern ("mouse-color");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10166 staticpro (&Qmouse_color);
1874
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
10167 Qnone = intern ("none");
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
10168 staticpro (&Qnone);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10169 Qparent_id = intern ("parent-id");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10170 staticpro (&Qparent_id);
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
10171 Qscroll_bar_width = intern ("scroll-bar-width");
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
10172 staticpro (&Qscroll_bar_width);
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
10173 Qsuppress_icon = intern ("suppress-icon");
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
10174 staticpro (&Qsuppress_icon);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10175 Qundefined_color = intern ("undefined-color");
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10176 staticpro (&Qundefined_color);
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
10177 Qvertical_scroll_bars = intern ("vertical-scroll-bars");
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
10178 staticpro (&Qvertical_scroll_bars);
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
10179 Qvisibility = intern ("visibility");
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
10180 staticpro (&Qvisibility);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10181 Qwindow_id = intern ("window-id");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10182 staticpro (&Qwindow_id);
23793
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
10183 Qouter_window_id = intern ("outer-window-id");
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
10184 staticpro (&Qouter_window_id);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10185 Qx_frame_parameter = intern ("x-frame-parameter");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10186 staticpro (&Qx_frame_parameter);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
10187 Qx_resource_name = intern ("x-resource-name");
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
10188 staticpro (&Qx_resource_name);
7251
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
10189 Quser_position = intern ("user-position");
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
10190 staticpro (&Quser_position);
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
10191 Quser_size = intern ("user-size");
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
10192 staticpro (&Quser_size);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
10193 Qdisplay = intern ("display");
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
10194 staticpro (&Qdisplay);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10195 Qscroll_bar_foreground = intern ("scroll-bar-foreground");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10196 staticpro (&Qscroll_bar_foreground);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10197 Qscroll_bar_background = intern ("scroll-bar-background");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10198 staticpro (&Qscroll_bar_background);
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
10199 Qscreen_gamma = intern ("screen-gamma");
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
10200 staticpro (&Qscreen_gamma);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10201 /* This is the end of symbol initialization. */
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10202
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10203 Qlaplace = intern ("laplace");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10204 staticpro (&Qlaplace);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10205
18631
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
10206 Qface_set_after_frame_default = intern ("face-set-after-frame-default");
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
10207 staticpro (&Qface_set_after_frame_default);
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
10208
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10209 Fput (Qundefined_color, Qerror_conditions,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10210 Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10211 Fput (Qundefined_color, Qerror_message,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10212 build_string ("Undefined color"));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10213
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10214 init_x_parm_symbols ();
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10215
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
10216 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
10217 "List of directories to search for bitmap files for X.");
12036
035d4ee6cc80 (syms_of_xfns): Allow PATH_BITMAPS to be a colon-separated list.
Karl Heuer <kwzh@gnu.org>
parents: 12019
diff changeset
10218 Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
10219
4328
3d43e65a593d (syms_of_xfns): Use DEFVAR_LISP, not DEFVAR_INT, for Vx_pointer_shape.
Roland McGrath <roland@gnu.org>
parents: 4309
diff changeset
10220 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10221 "The shape of the pointer when over text.\n\
2936
f9956cdb0d1d (syms_of_xfns): Don't make Lisp vars
Richard M. Stallman <rms@gnu.org>
parents: 2885
diff changeset
10222 Changing the value does not affect existing frames\n\
f9956cdb0d1d (syms_of_xfns): Don't make Lisp vars
Richard M. Stallman <rms@gnu.org>
parents: 2885
diff changeset
10223 unless you set the mouse color.");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10224 Vx_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10225
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10226 DEFVAR_LISP ("x-resource-name", &Vx_resource_name,
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10227 "The name Emacs uses to look up X resources.\n\
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10228 `x-get-resource' uses this as the first component of the instance name\n\
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10229 when requesting resource values.\n\
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10230 Emacs initially sets `x-resource-name' to the name under which Emacs\n\
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10231 was invoked, or to the value specified with the `-name' or `-rn'\n\
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10232 switches, if present.\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10233 \n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10234 It may be useful to bind this variable locally around a call\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10235 to `x-get-resource'. See also the variable `x-resource-class'.");
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10236 Vx_resource_name = Qnil;
3170
647229114f47 * xfns.c: Make resource manager work correctly even when
Jim Blandy <jimb@redhat.com>
parents: 3141
diff changeset
10237
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10238 DEFVAR_LISP ("x-resource-class", &Vx_resource_class,
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10239 "The class Emacs uses to look up X resources.\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10240 `x-get-resource' uses this as the first component of the instance class\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10241 when requesting resource values.\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10242 Emacs initially sets `x-resource-class' to \"Emacs\".\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10243 \n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10244 Setting this variable permanently is not a reasonable thing to do,\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10245 but binding this variable locally around a call to `x-get-resource'\n\
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10246 is a reasonable practice. See also the variable `x-resource-name'.");
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10247 Vx_resource_class = build_string (EMACS_CLASS);
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10248
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10249 #if 0 /* This doesn't really do anything. */
16396
4e4cc27b2a2a (x_set_internal_border_width): Only change
Richard M. Stallman <rms@gnu.org>
parents: 16357
diff changeset
10250 DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10251 "The shape of the pointer when not over text.\n\
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10252 This variable takes effect when you create a new frame\n\
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10253 or when you set the mouse color.");
2936
f9956cdb0d1d (syms_of_xfns): Don't make Lisp vars
Richard M. Stallman <rms@gnu.org>
parents: 2885
diff changeset
10254 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10255 Vx_nontext_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10256
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10257 DEFVAR_LISP ("x-busy-pointer-shape", &Vx_busy_pointer_shape,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10258 "The shape of the pointer when Emacs is busy.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10259 This variable takes effect when you create a new frame\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10260 or when you set the mouse color.");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10261 Vx_busy_pointer_shape = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10262
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10263 DEFVAR_BOOL ("display-busy-cursor", &display_busy_cursor_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10264 "Non-zero means Emacs displays a busy cursor on window systems.");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10265 display_busy_cursor_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10266
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10267 #if 0 /* This doesn't really do anything. */
16396
4e4cc27b2a2a (x_set_internal_border_width): Only change
Richard M. Stallman <rms@gnu.org>
parents: 16357
diff changeset
10268 DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10269 "The shape of the pointer when over the mode line.\n\
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10270 This variable takes effect when you create a new frame\n\
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10271 or when you set the mouse color.");
2936
f9956cdb0d1d (syms_of_xfns): Don't make Lisp vars
Richard M. Stallman <rms@gnu.org>
parents: 2885
diff changeset
10272 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10273 Vx_mode_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10274
16396
4e4cc27b2a2a (x_set_internal_border_width): Only change
Richard M. Stallman <rms@gnu.org>
parents: 16357
diff changeset
10275 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10276 &Vx_sensitive_text_pointer_shape,
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10277 "The shape of the pointer when over mouse-sensitive text.\n\
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10278 This variable takes effect when you create a new frame\n\
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10279 or when you set the mouse color.");
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10280 Vx_sensitive_text_pointer_shape = Qnil;
6759
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
10281
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10282 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10283 "A string indicating the foreground color of the cursor box.");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10284 Vx_cursor_fore_pixel = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10285
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10286 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
12209
5537ed125771 (syms_of_xfns): Initialize Vx_no_window_manager. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12190
diff changeset
10287 "Non-nil if no X window manager is in use.\n\
5537ed125771 (syms_of_xfns): Initialize Vx_no_window_manager. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12190
diff changeset
10288 Emacs doesn't try to figure this out; this is always nil\n\
5537ed125771 (syms_of_xfns): Initialize Vx_no_window_manager. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12190
diff changeset
10289 unless you set it to something else.");
5537ed125771 (syms_of_xfns): Initialize Vx_no_window_manager. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12190
diff changeset
10290 /* We don't have any way to find this out, so set it to nil
5537ed125771 (syms_of_xfns): Initialize Vx_no_window_manager. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12190
diff changeset
10291 and maybe the user would like to set it to t. */
5537ed125771 (syms_of_xfns): Initialize Vx_no_window_manager. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 12190
diff changeset
10292 Vx_no_window_manager = Qnil;
8170
d92a24366b22 (x_toolkit): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8103
diff changeset
10293
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10294 DEFVAR_LISP ("x-pixel-size-width-font-regexp",
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10295 &Vx_pixel_size_width_font_regexp,
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10296 "Regexp matching a font name whose width is the same as `PIXEL_SIZE'.\n\
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10297 \n\
17106
5075619fac7a (syms_of_xfns): Documentation of
Kenichi Handa <handa@m17n.org>
parents: 17048
diff changeset
10298 Since Emacs gets width of a font matching with this regexp from\n\
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10299 PIXEL_SIZE field of the name, font finding mechanism gets faster for\n\
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10300 such a font. This is especially effective for such large fonts as\n\
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10301 Chinese, Japanese, and Korean.");
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10302 Vx_pixel_size_width_font_regexp = Qnil;
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10303
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
10304 DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10305 "Time after which cached images are removed from the cache.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10306 When an image has not been displayed this many seconds, remove it\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10307 from the image cache. Value must be an integer or nil with nil\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10308 meaning don't clear the cache.");
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
10309 Vimage_cache_eviction_delay = make_number (30 * 60);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10310
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10311 DEFVAR_LISP ("image-types", &Vimage_types,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10312 "List of supported image types.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10313 Each element of the list is a symbol for a supported image type.");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10314 Vimage_types = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10315
8170
d92a24366b22 (x_toolkit): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8103
diff changeset
10316 #ifdef USE_X_TOOLKIT
8192
091cd6243cae (syms_of_xfns): Provide x-toolkit in toolkit version.
Richard M. Stallman <rms@gnu.org>
parents: 8170
diff changeset
10317 Fprovide (intern ("x-toolkit"));
8170
d92a24366b22 (x_toolkit): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8103
diff changeset
10318 #endif
12094
a9fda5417acf (syms_of_xfns): Provide motif in Motif version.
Karl Heuer <kwzh@gnu.org>
parents: 12080
diff changeset
10319 #ifdef USE_MOTIF
a9fda5417acf (syms_of_xfns): Provide motif in Motif version.
Karl Heuer <kwzh@gnu.org>
parents: 12080
diff changeset
10320 Fprovide (intern ("motif"));
a9fda5417acf (syms_of_xfns): Provide motif in Motif version.
Karl Heuer <kwzh@gnu.org>
parents: 12080
diff changeset
10321 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10322
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10323 defsubr (&Sx_get_resource);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10324
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10325 /* X window properties. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10326 defsubr (&Sx_change_window_property);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10327 defsubr (&Sx_delete_window_property);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10328 defsubr (&Sx_window_property);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10329
689
45401d45581d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 687
diff changeset
10330 #if 0
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10331 defsubr (&Sx_draw_rectangle);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10332 defsubr (&Sx_erase_rectangle);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10333 defsubr (&Sx_contour_region);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10334 defsubr (&Sx_uncontour_region);
689
45401d45581d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 687
diff changeset
10335 #endif
2277
773e47f29c5a (Fx_display_color_p): Renamed from Fx_color_display_p.
Richard M. Stallman <rms@gnu.org>
parents: 2276
diff changeset
10336 defsubr (&Sx_display_color_p);
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
10337 defsubr (&Sx_display_grayscale_p);
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
10338 defsubr (&Sx_color_defined_p);
8675
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
10339 defsubr (&Sx_color_values);
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
10340 defsubr (&Sx_server_max_request_size);
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10341 defsubr (&Sx_server_vendor);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10342 defsubr (&Sx_server_version);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10343 defsubr (&Sx_display_pixel_width);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10344 defsubr (&Sx_display_pixel_height);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10345 defsubr (&Sx_display_mm_width);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10346 defsubr (&Sx_display_mm_height);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10347 defsubr (&Sx_display_screens);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10348 defsubr (&Sx_display_planes);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10349 defsubr (&Sx_display_color_cells);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10350 defsubr (&Sx_display_visual_class);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10351 defsubr (&Sx_display_backing_store);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10352 defsubr (&Sx_display_save_under);
4309
c79a44360ed9 (Fx_rebind_key, Fx_rebind_keys): Functions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 4279
diff changeset
10353 #if 0
3141
ffe66ae9bfb3 (Fx_rebind_key, Fx_rebind_keys): X10 definitions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 3134
diff changeset
10354 defsubr (&Sx_rebind_key);
ffe66ae9bfb3 (Fx_rebind_key, Fx_rebind_keys): X10 definitions deleted.
Richard M. Stallman <rms@gnu.org>
parents: 3134
diff changeset
10355 defsubr (&Sx_rebind_keys);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10356 defsubr (&Sx_track_pointer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10357 defsubr (&Sx_grab_pointer);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10358 defsubr (&Sx_ungrab_pointer);
436
6e0a136fca4f *** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents: 398
diff changeset
10359 #endif
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
10360 defsubr (&Sx_parse_geometry);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
10361 defsubr (&Sx_create_frame);
687
e2b747dd6a6e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 642
diff changeset
10362 #if 0
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10363 defsubr (&Sx_horizontal_line);
687
e2b747dd6a6e *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 642
diff changeset
10364 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10365 defsubr (&Sx_open_connection);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
10366 defsubr (&Sx_close_connection);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
10367 defsubr (&Sx_display_list);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10368 defsubr (&Sx_synchronize);
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10369
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10370 /* Setting callback functions for fontset handler. */
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10371 get_font_info_func = x_get_font_info;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10372
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10373 #if 0 /* This function pointer doesn't seem to be used anywhere.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10374 And the pointer assigned has the wrong type, anyway. */
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10375 list_fonts_func = x_list_fonts;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10376 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10377
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10378 load_font_func = x_load_font;
21549
3b63301ea296 (syms_of_xfns): Initialize find_ccl_program_func.
Kenichi Handa <handa@m17n.org>
parents: 21536
diff changeset
10379 find_ccl_program_func = x_find_ccl_program;
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10380 query_font_func = x_query_font;
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10381 set_frame_fontset_func = x_set_font;
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10382 check_window_system_func = check_x;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10383
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10384 /* Images. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10385 Qxbm = intern ("xbm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10386 staticpro (&Qxbm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10387 QCtype = intern (":type");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10388 staticpro (&QCtype);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10389 QCalgorithm = intern (":algorithm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10390 staticpro (&QCalgorithm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10391 QCheuristic_mask = intern (":heuristic-mask");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10392 staticpro (&QCheuristic_mask);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10393 QCcolor_symbols = intern (":color-symbols");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10394 staticpro (&QCcolor_symbols);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10395 QCdata = intern (":data");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10396 staticpro (&QCdata);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10397 QCascent = intern (":ascent");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10398 staticpro (&QCascent);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10399 QCmargin = intern (":margin");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10400 staticpro (&QCmargin);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10401 QCrelief = intern (":relief");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10402 staticpro (&QCrelief);
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
10403 Qpostscript = intern ("postscript");
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
10404 staticpro (&Qpostscript);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10405 QCloader = intern (":loader");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10406 staticpro (&QCloader);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10407 QCbounding_box = intern (":bounding-box");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10408 staticpro (&QCbounding_box);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10409 QCpt_width = intern (":pt-width");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10410 staticpro (&QCpt_width);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10411 QCpt_height = intern (":pt-height");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10412 staticpro (&QCpt_height);
25620
1c991744ce13 (QCindex): New.
Gerd Moellmann <gerd@gnu.org>
parents: 25593
diff changeset
10413 QCindex = intern (":index");
1c991744ce13 (QCindex): New.
Gerd Moellmann <gerd@gnu.org>
parents: 25593
diff changeset
10414 staticpro (&QCindex);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10415 Qpbm = intern ("pbm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10416 staticpro (&Qpbm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10417
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10418 #if HAVE_XPM
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10419 Qxpm = intern ("xpm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10420 staticpro (&Qxpm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10421 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10422
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10423 #if HAVE_JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10424 Qjpeg = intern ("jpeg");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10425 staticpro (&Qjpeg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10426 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10427
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10428 #if HAVE_TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10429 Qtiff = intern ("tiff");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10430 staticpro (&Qtiff);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10431 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10432
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10433 #if HAVE_GIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10434 Qgif = intern ("gif");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10435 staticpro (&Qgif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10436 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10437
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10438 #if HAVE_PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10439 Qpng = intern ("png");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10440 staticpro (&Qpng);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10441 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10442
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10443 defsubr (&Sclear_image_cache);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10444
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10445 #if GLYPH_DEBUG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10446 defsubr (&Simagep);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10447 defsubr (&Slookup_image);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10448 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10449
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10450 /* Busy-cursor. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10451 defsubr (&Sx_show_busy_cursor);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10452 defsubr (&Sx_hide_busy_cursor);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10453 busy_count = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10454 inhibit_busy_cursor = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10455
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10456 defsubr (&Sx_show_tip);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10457 defsubr (&Sx_hide_tip);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10458 staticpro (&tip_timer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10459 tip_timer = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10460
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10461 #ifdef USE_MOTIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10462 defsubr (&Sx_file_dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10463 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10464 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10465
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10466
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10467 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10468 init_xfns ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10469 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10470 image_types = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10471 Vimage_types = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10472
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10473 define_image_type (&xbm_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10474 define_image_type (&gs_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10475 define_image_type (&pbm_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10476
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10477 #if HAVE_XPM
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10478 define_image_type (&xpm_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10479 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10480
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10481 #if HAVE_JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10482 define_image_type (&jpeg_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10483 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10484
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10485 #if HAVE_TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10486 define_image_type (&tiff_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10487 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10488
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10489 #if HAVE_GIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10490 define_image_type (&gif_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10491 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10492
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10493 #if HAVE_PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10494 define_image_type (&png_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10495 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10496 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10497
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10498 #endif /* HAVE_X_WINDOWS */