annotate src/xfns.c @ 29213:b332ebdca302

Delete obsolete URL comment.
author Dave Love <fx@gnu.org>
date Thu, 25 May 2000 18:39:31 +0000
parents ee61d41ad789
children 3d157c3d1f51
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
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26032
diff changeset
22 #include <config.h>
7899
facf6b0e97ff Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 7860
diff changeset
23 #include <signal.h>
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
24 #include <stdio.h>
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
25 #include <math.h>
7899
facf6b0e97ff Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 7860
diff changeset
26
8091
f40cbe50c74f (XLIB_ILLEGAL_ACCESS): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 8090
diff changeset
27 /* 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
28
8091
f40cbe50c74f (XLIB_ILLEGAL_ACCESS): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 8090
diff changeset
29 #define XLIB_ILLEGAL_ACCESS
f40cbe50c74f (XLIB_ILLEGAL_ACCESS): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 8090
diff changeset
30
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #include "lisp.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #include "xterm.h"
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
33 #include "frame.h"
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 #include "window.h"
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #include "buffer.h"
26876
578acd06aa3b Include intervals.h.
Kenichi Handa <handa@m17n.org>
parents: 26808
diff changeset
36 #include "intervals.h"
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 #include "dispextern.h"
515
0005d4c90c97 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
38 #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
39 #include "blockinput.h"
24412
d11ac02f9d6a Use epaths.h istead of paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 24170
diff changeset
40 #include <epaths.h>
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
41 #include "charset.h"
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
42 #include "fontset.h"
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
43 #include "systime.h"
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
44 #include "termhooks.h"
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
45 #include "atimer.h"
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 #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
48
786ab5197e4b Include <stdlib.h> if available, and declare abort only if not. Include
Andreas Schwab <schwab@suse.de>
parents: 25390
diff changeset
49 #include <ctype.h>
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
50 #include <sys/types.h>
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
51 #include <sys/stat.h>
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
2355
cec8c9490d8a * xfns.c [VMS]: Get the gray_bits from [.bitmaps]gray.xbm.
Jim Blandy <jimb@redhat.com>
parents: 2341
diff changeset
53 #ifndef VMS
3821
8f353c2491d0 * xfns.c: Always #include "bitmaps/gray.xbm"; the bitmaps seem to
Jim Blandy <jimb@redhat.com>
parents: 3692
diff changeset
54 #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
55 #include "bitmaps/gray.xbm"
2657b04dd324 [EMACS_BIT_MAPS]: Include gray.xbm from ./bitmaps.
Richard M. Stallman <rms@gnu.org>
parents: 3507
diff changeset
56 #else
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
57 #include <X11/bitmaps/gray>
3512
2657b04dd324 [EMACS_BIT_MAPS]: Include gray.xbm from ./bitmaps.
Richard M. Stallman <rms@gnu.org>
parents: 3507
diff changeset
58 #endif
2355
cec8c9490d8a * xfns.c [VMS]: Get the gray_bits from [.bitmaps]gray.xbm.
Jim Blandy <jimb@redhat.com>
parents: 2341
diff changeset
59 #else
cec8c9490d8a * xfns.c [VMS]: Get the gray_bits from [.bitmaps]gray.xbm.
Jim Blandy <jimb@redhat.com>
parents: 2341
diff changeset
60 #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
61 #endif
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
62
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
63 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
64 #include <X11/Shell.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
65
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
66 #ifndef USE_MOTIF
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
67 #include <X11/Xaw/Paned.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
68 #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
69 #endif /* USE_MOTIF */
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
70
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
71 #ifdef USG
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
72 #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
73 #include <X11/Xos.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
74 #define USG
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
75 #else
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
76 #include <X11/Xos.h>
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
77 #endif
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
78
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
79 #include "widget.h"
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
80
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
81 #include "../lwlib/lwlib.h"
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
82
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
83 #ifdef USE_MOTIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
84 #include <Xm/Xm.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
85 #include <Xm/DialogS.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
86 #include <Xm/FileSB.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
87 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
88
13508
b64345cf1ee9 (HACK_EDITRES): Don't define if NO_EDITRES is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13227
diff changeset
89 /* 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
90 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
91
13508
b64345cf1ee9 (HACK_EDITRES): Don't define if NO_EDITRES is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13227
diff changeset
92 #if (XtSpecificationRelease >= 5) && !defined(NO_EDITRES)
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
93 #define HACK_EDITRES
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
94 extern void _XEditResCheckMessages ();
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
95 #endif /* R5 + Athena */
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
96
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
97 /* 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
98
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
99 extern LWLIB_ID widget_id_tick;
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
100
15720
f1549b7501af (Fx_create_frame): Do xlwmenu hack only if USE_LUCID.
Karl Heuer <kwzh@gnu.org>
parents: 15706
diff changeset
101 #ifdef USE_LUCID
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
102 /* 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
103 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
104 #endif
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
105
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
106 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
107 extern double atof ();
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
108
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
109 #endif /* USE_X_TOOLKIT */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
110
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 #define min(a,b) ((a) < (b) ? (a) : (b))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 #define max(a,b) ((a) > (b) ? (a) : (b))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
114 #ifdef HAVE_X11R4
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
115 #define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
116 #else
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
117 #define MAXREQUEST(dpy) ((dpy)->max_request_size)
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
118 #endif
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
119
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
120 /* 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
121 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
122 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
123
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
124 int gray_bitmap_width = gray_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
125 int gray_bitmap_height = gray_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
126 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
127
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
128 /* 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
129
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
130 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
131
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
132 /* 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
133 Normally "Emacs". */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
134
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
135 Lisp_Object Vx_resource_class;
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
136
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
137 /* 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
138
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
139 int display_busy_cursor_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
140
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 /* 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
142 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
143
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 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
145 Lisp_Object Vx_busy_pointer_shape;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
146
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
147 /* 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
148
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
149 Lisp_Object Vx_sensitive_text_pointer_shape;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
151 /* 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
152
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 Lisp_Object Vx_cursor_fore_pixel;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
155 /* Nonzero if using X. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
156
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
157 static int x_in_use;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
158
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
159 /* 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
160
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 Lisp_Object Vx_no_window_manager;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
163 /* Search path for bitmap files. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
164
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
165 Lisp_Object Vx_bitmap_file_path;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
166
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
167 /* 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
168
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
169 Lisp_Object Vx_pixel_size_width_font_regexp;
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
170
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
171 /* 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
172 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
173 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
174 evaluate this expression.
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
175
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
176 (progn
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
177 ;; 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
178 ;; 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
179 (goto-char (point-min))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
180 (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
181 (let (symbol-list)
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
182 (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
183 (setq symbol-list
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
184 (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
185 symbol-list))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
186 (forward-line 1))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
187 (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
188 ;; 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
189 (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
190 (let ((start (point)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
191 (while (looking-at "^ Q")
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
192 (forward-line 2))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
193 (kill-region start (point)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
194 ;; 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
195 (while symbol-list
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
196 (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
197 (let ((start (point)))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
198 (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
199 (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
200 (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
201 (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
202
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
203 */
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
204
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
205 /*&&& symbols declared here &&&*/
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
206 Lisp_Object Qauto_raise;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
207 Lisp_Object Qauto_lower;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
208 Lisp_Object Qbar;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
209 Lisp_Object Qborder_color;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
210 Lisp_Object Qborder_width;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
211 Lisp_Object Qbox;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
212 Lisp_Object Qcursor_color;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
213 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
214 Lisp_Object Qgeometry;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
215 Lisp_Object Qicon_left;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
216 Lisp_Object Qicon_top;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
217 Lisp_Object Qicon_type;
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
218 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
219 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
220 Lisp_Object Qleft;
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
221 Lisp_Object Qright;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
222 Lisp_Object Qmouse_color;
1874
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
223 Lisp_Object Qnone;
23793
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
224 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
225 Lisp_Object Qparent_id;
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
226 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
227 Lisp_Object Qsuppress_icon;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
228 extern Lisp_Object Qtop;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 Lisp_Object Qundefined_color;
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
230 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
231 Lisp_Object Qvisibility;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
232 Lisp_Object Qwindow_id;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
233 Lisp_Object Qx_frame_parameter;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
234 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
235 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
236 Lisp_Object Quser_size;
26571
bc95d8e47cb9 Don't duplicate Qdisplay definition done elsewhere.
Dave Love <fx@gnu.org>
parents: 26526
diff changeset
237 extern Lisp_Object Qdisplay;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
238 Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
239 Lisp_Object Qscreen_gamma, Qline_spacing, Qcenter;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
240
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
241 /* 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
242
1874
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
243 extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
14381
4d038c841cf4 (Qtitle): Declared.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
244 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
245 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
246
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 extern Lisp_Object Vwindow_system_version;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248
18631
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
249 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
250
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
252 /* 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
253
5948
ef777779bd80 (check_x): Make it global.
Karl Heuer <kwzh@gnu.org>
parents: 5900
diff changeset
254 void
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
255 check_x ()
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
256 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
257 if (! x_in_use)
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
258 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
259 }
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
260
13867
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
261 /* 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
262 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
263
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
264 int
13867
19a05b5a597d (check_x_display_info, check_x_frame, x_set_font)
Richard M. Stallman <rms@gnu.org>
parents: 13781
diff changeset
265 have_menus_p ()
7791
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
266 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
267 return x_in_use;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
268 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
269
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
270 /* 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
271 and checking validity for X. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
272
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
273 FRAME_PTR
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
274 check_x_frame (frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
275 Lisp_Object frame;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
276 {
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
277 FRAME_PTR f;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
278
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
279 if (NILP (frame))
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
280 frame = selected_frame;
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
281 CHECK_LIVE_FRAME (frame, 0);
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
282 f = XFRAME (frame);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
283 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
284 error ("Non-X frame used");
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
285 return f;
7791
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
286 }
2b4e4a76468b (using_x_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7683
diff changeset
287
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
288 /* 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
289 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
290 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
291
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
292 static struct x_display_info *
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
293 check_x_display_info (frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
294 Lisp_Object frame;
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))
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
297 {
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
298 struct frame *sf = XFRAME (selected_frame);
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
299
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
300 if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
301 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
302 else if (x_display_list != 0)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
303 return x_display_list;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
304 else
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
305 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
306 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
307 else if (STRINGP (frame))
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
308 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
309 else
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
310 {
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
311 FRAME_PTR f;
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 CHECK_LIVE_FRAME (frame, 0);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
314 f = XFRAME (frame);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
315 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
316 error ("Non-X frame used");
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
317 return FRAME_X_DISPLAY_INFO (f);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
318 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
319 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
320
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
321
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
322 /* Return the Emacs frame-object corresponding to an X window.
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
323 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
324
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
325 /* 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
326
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
327 struct frame *
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
328 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
329 struct x_display_info *dpyinfo;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 int wdesc;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
332 Lisp_Object tail, frame;
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
333 struct frame *f;
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
334
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
335 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
336 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
337 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
338 if (!GC_FRAMEP (frame))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 continue;
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
340 f = XFRAME (frame);
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
341 if (!FRAME_X_P (f) || 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
342 continue;
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
343 if (f->output_data.x->busy_window == wdesc)
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
344 return f;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
345 #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
346 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
347 && 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
348 /* A tooltip frame? */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
349 || (!f->output_data.x->edit_widget
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
350 && 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
351 || f->output_data.x->icon_desc == wdesc)
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
352 return f;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
353 #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
354 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
355 || f->output_data.x->icon_desc == wdesc)
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
356 return f;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
357 #endif /* not USE_X_TOOLKIT */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 return 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
362 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
363 /* 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
364 windows. */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
365
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
366 struct frame *
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
367 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
368 struct x_display_info *dpyinfo;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
369 int wdesc;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
370 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
371 Lisp_Object tail, frame;
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
372 struct frame *f, *found;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
373 struct x_output *x;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
374
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
375 found = NULL;
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
376 for (tail = Vframe_list; GC_CONSP (tail) && !found; tail = XCDR (tail))
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
377 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
378 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
379 if (!GC_FRAMEP (frame))
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
380 continue;
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
381
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
382 f = XFRAME (frame);
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
383 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
384 {
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
385 /* This frame matches if the window is any of its widgets. */
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
386 x = f->output_data.x;
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
387 if (x->busy_window == wdesc)
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
388 found = f;
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
389 else if (x->widget)
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
390 {
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
391 if (wdesc == XtWindow (x->widget)
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
392 || wdesc == XtWindow (x->column_widget)
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
393 || wdesc == XtWindow (x->edit_widget))
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
394 found = f;
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
395 /* Match if the window is this frame's menubar. */
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
396 else if (lw_window_is_in_menubar (wdesc, x->menubar_widget))
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
397 found = f;
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
398 }
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
399 else if (FRAME_X_WINDOW (f) == wdesc)
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
400 /* A tooltip frame. */
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
401 found = f;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
402 }
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
403 }
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
404
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
405 return found;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
406 }
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
407
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
408 /* 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
409
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
410 struct frame *
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
411 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
412 struct x_display_info *dpyinfo;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
413 int wdesc;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
414 {
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
415 Lisp_Object tail, frame;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
416 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
417 struct x_output *x;
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
418
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
419 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
420 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
421 frame = XCAR (tail);
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
422 if (!GC_FRAMEP (frame))
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
423 continue;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
424 f = XFRAME (frame);
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
425 if (!FRAME_X_P (f) || 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
426 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
427 x = f->output_data.x;
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
428 /* This frame matches if the window is any of its widgets. */
27798
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
429 if (x->busy_window == wdesc)
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
430 return f;
d00730392332 (x_window_to_frame, x_any_window_to_frame)
Gerd Moellmann <gerd@gnu.org>
parents: 27659
diff changeset
431 else if (x->widget)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
432 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
433 if (wdesc == XtWindow (x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
434 || wdesc == XtWindow (x->column_widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
435 || wdesc == XtWindow (x->edit_widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
436 return f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
437 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
438 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
439 /* A tooltip frame. */
11611
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
440 return f;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
441 }
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
442 return 0;
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
443 }
bf53e9945a3c (x_non_menubar_window_to_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 11537
diff changeset
444
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
445 /* 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
446
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
447 struct frame *
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
448 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
449 struct x_display_info *dpyinfo;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
450 int wdesc;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
451 {
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
452 Lisp_Object tail, frame;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
453 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
454 struct x_output *x;
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
455
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
456 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
457 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
458 frame = XCAR (tail);
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
459 if (!GC_FRAMEP (frame))
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
460 continue;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
461 f = XFRAME (frame);
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
462 if (!FRAME_X_P (f) || 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
463 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
464 x = f->output_data.x;
12656
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
465 /* 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
466 if (x->menubar_widget
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
467 && 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
468 return f;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
469 }
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
470 return 0;
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
471 }
5beb1d2be5c1 (x_menubar_window_to_frame): New function.
Richard M. Stallman <rms@gnu.org>
parents: 12616
diff changeset
472
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
473 /* 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
474 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
475
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
476 struct frame *
11197
1bdc265aab86 (x_window_to_frame): New arg DPYINFO. All callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11060
diff changeset
477 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
478 struct x_display_info *dpyinfo;
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
479 int wdesc;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
480 {
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
481 Lisp_Object tail, frame;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
482 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
483 struct x_output *x;
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
484
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
485 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
486 {
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
487 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
488 if (!GC_FRAMEP (frame))
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
489 continue;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
490 f = XFRAME (frame);
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
491 if (!FRAME_X_P (f) || 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
492 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
493 x = f->output_data.x;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
494
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
495 if (x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
496 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
497 /* 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
498 if (wdesc == XtWindow (x->widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
499 return f;
12019
63ee64941021 (x_top_window_to_frame): Don't match menu-bar widget.
Karl Heuer <kwzh@gnu.org>
parents: 12011
diff changeset
500 #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
501 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
502 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
503 /* 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
504 if (x->menubar_widget
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
505 && wdesc == XtWindow (x->menubar_widget))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
506 return f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
507 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
508 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
509 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
510 /* Tooltip frame. */
7040
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
511 return f;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
512 }
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
513 return 0;
cd4dd38925f9 (x_window): Test FRAME_EXTERNAL_MENU_BAR
Richard M. Stallman <rms@gnu.org>
parents: 6940
diff changeset
514 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
515 #endif /* USE_X_TOOLKIT */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
516
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
518
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
519 /* 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
520 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
521 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
522
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
523 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
524 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
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 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
527 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
528 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
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
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
531 /* 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
532
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
533 int
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
534 x_bitmap_height (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
535 FRAME_PTR f;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
536 int id;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
537 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
538 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
539 }
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
540
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
541 int
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
542 x_bitmap_width (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
543 FRAME_PTR f;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
544 int id;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
545 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
546 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
547 }
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
548
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
549 int
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
550 x_bitmap_pixmap (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
551 FRAME_PTR f;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
552 int id;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
553 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
554 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
555 }
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
556
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
557
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
558 /* 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
559
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
560 static int
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
561 x_allocate_bitmap_record (f)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
562 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
563 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
564 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
565 int i;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
566
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
567 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
568 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
569 dpyinfo->bitmaps_size = 10;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
570 dpyinfo->bitmaps
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
571 = (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
572 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
573 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
574 }
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 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
577 return ++dpyinfo->bitmaps_last;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
578
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
579 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
580 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
581 return i + 1;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
582
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
583 dpyinfo->bitmaps_size *= 2;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
584 dpyinfo->bitmaps
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
585 = (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
586 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
587 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
588 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
589
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
590 /* 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
591
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
592 void
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
593 x_reference_bitmap (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
594 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
595 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
596 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
597 ++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
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
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
600 /* 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
601
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
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
603 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
604 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
605 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
606 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
607 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
608 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
609 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
610 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
611
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
612 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
613 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
614
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
615 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
616 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
617
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
618 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
619 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
620 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
621 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
622 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
623 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
624 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
625
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
626 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
627 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
628
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
629 /* 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
630
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
631 int
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
632 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
633 struct frame *f;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
634 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
635 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
636 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
637 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
638 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
639 int xhot, yhot, result, id;
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
640 Lisp_Object found;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
641 int fd;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
642 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
643
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
644 /* 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
645 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
646 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
647 if (dpyinfo->bitmaps[id].refcount
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
648 && dpyinfo->bitmaps[id].file
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
649 && !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
650 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
651 ++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
652 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
653 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
654 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
655
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
656 /* Search bitmap-file-path for the file, if appropriate. */
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
657 fd = openp (Vx_bitmap_file_path, file, "", &found, 0);
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
658 if (fd < 0)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
659 return -1;
23141
9676fa7e02bf (x_create_bitmap_from_file): Fail immediately if magic.
Karl Heuer <kwzh@gnu.org>
parents: 23043
diff changeset
660 /* 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
661 if (fd == 0)
9676fa7e02bf (x_create_bitmap_from_file): Fail immediately if magic.
Karl Heuer <kwzh@gnu.org>
parents: 23043
diff changeset
662 return -1;
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26032
diff changeset
663 emacs_close (fd);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
664
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
665 filename = (char *) XSTRING (found)->data;
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
666
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
667 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
668 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
669 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
670 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
671
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
672 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
673 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
674 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
675 dpyinfo->bitmaps[id - 1].file
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
676 = (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
677 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
678 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
679 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
680 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
681
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
682 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
683 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
684
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
685 /* 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
686
21536
468585662fa8 (x_destroy_bitmap): Declare as void, not int.
Karl Heuer <kwzh@gnu.org>
parents: 21267
diff changeset
687 void
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
688 x_destroy_bitmap (f, id)
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
689 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
690 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
691 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
692 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
693
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
694 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
695 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
696 --dpyinfo->bitmaps[id - 1].refcount;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
697 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
698 {
12051
f193ce9efe24 (x_destroy_bitmap): Block and unblock input.
Karl Heuer <kwzh@gnu.org>
parents: 12046
diff changeset
699 BLOCK_INPUT;
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
700 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
701 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
702 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
703 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
704 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
705 }
12051
f193ce9efe24 (x_destroy_bitmap): Block and unblock input.
Karl Heuer <kwzh@gnu.org>
parents: 12046
diff changeset
706 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
707 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
708 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
709 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
710
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
711 /* 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
712
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
713 static void
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
714 x_destroy_all_bitmaps (dpyinfo)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
715 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
716 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
717 int i;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
718 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
719 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
720 {
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
721 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
722 if (dpyinfo->bitmaps[i].file)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
723 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
724 }
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
725 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
726 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
727
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
728 /* Connect the frame-parameter names for X frames
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729 to the ways of passing the parameter values to the window system.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 The name of a parameter, as a Lisp symbol,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
732 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
733 that is an index in this table. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
735 struct x_frame_parm_table
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 char *name;
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
738 void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740
27157
3dafddaefc2c (x_create_im): New function to set IM and IC of a frame.
Gerd Moellmann <gerd@gnu.org>
parents: 27153
diff changeset
741 static void x_create_im P_ ((struct frame *));
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
742 void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
28690
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
743 static void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
744 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
745 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
746 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
747 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
748 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
749 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
750 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
751 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
752 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
753 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
754 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_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
756 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
757 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
758 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
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_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
761 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
762 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
763 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
764 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
765 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
766 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
767 Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
768 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
769 Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
770 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
771 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 char *, char *,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
774 int));
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
775 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
776
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
777 static struct x_frame_parm_table x_frame_parms[] =
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 {
28690
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
779 "auto-raise", x_set_autoraise,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
780 "auto-lower", x_set_autolower,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
781 "background-color", x_set_background_color,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
782 "border-color", x_set_border_color,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
783 "border-width", x_set_border_width,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
784 "cursor-color", x_set_cursor_color,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
785 "cursor-type", x_set_cursor_type,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
786 "font", x_set_font,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
787 "foreground-color", x_set_foreground_color,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
788 "icon-name", x_set_icon_name,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
789 "icon-type", x_set_icon_type,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
790 "internal-border-width", x_set_internal_border_width,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
791 "menu-bar-lines", x_set_menu_bar_lines,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
792 "mouse-color", x_set_mouse_color,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
793 "name", x_explicitly_set_name,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
794 "scroll-bar-width", x_set_scroll_bar_width,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
795 "title", x_set_title,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
796 "unsplittable", x_set_unsplittable,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
797 "vertical-scroll-bars", x_set_vertical_scroll_bars,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
798 "visibility", x_set_visibility,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
799 "tool-bar-lines", x_set_tool_bar_lines,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
800 "scroll-bar-foreground", x_set_scroll_bar_foreground,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
801 "scroll-bar-background", x_set_scroll_bar_background,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
802 "screen-gamma", x_set_screen_gamma,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
803 "line-spacing", x_set_line_spacing
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804 };
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
806 /* Attach the `x-frame-parameter' properties to
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807 the Lisp symbol names of parameters relevant to X. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808
21846
486ac68ce051 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21779
diff changeset
809 void
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 init_x_parm_symbols ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 int i;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
814 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
815 Fput (intern (x_frame_parms[i].name), Qx_frame_parameter,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 make_number (i));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818
19095
2f58824bf3f6 (x_set_frame_parameters): Heading comment fixed.
Kenichi Handa <handa@m17n.org>
parents: 19026
diff changeset
819 /* 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
820 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
821 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
822
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
823 void
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
824 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
825 FRAME_PTR f;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
826 Lisp_Object alist;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
827 {
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
828 Lisp_Object tail;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
829
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
830 /* 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
831 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
832 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
833 int width, height;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
834
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
835 /* Same here. */
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
836 Lisp_Object left, top;
3203
1055aa1b7547 * xfns.c (x_set_frame_parameters): Use the first
Jim Blandy <jimb@redhat.com>
parents: 3173
diff changeset
837
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
838 /* Same with these. */
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
839 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
840
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
841 /* 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
842 Lisp_Object *parms;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
843 Lisp_Object *values;
25289
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
844 int i, p;
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
845 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
846 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
847
24170
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
848 struct gcpro gcpro1, gcpro2;
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
849
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
850 i = 0;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
851 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
852 i++;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
853
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
854 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
855 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
856
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
857 /* 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
858
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
859 i = 0;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
860 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
861 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
862 Lisp_Object elt;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
863
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
864 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
865 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
866 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
867 i++;
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
868 }
24170
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
869 /* 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
870 alist = tail = Qnil;
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
871
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
872 GCPRO2 (*parms, *values);
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
873 gcpro1.nvars = i;
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
874 gcpro2.nvars = i;
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 /* 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
877 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
878 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
879 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
880
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
881 /* 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
882 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
883 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
884 else
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
885 width = FRAME_WIDTH (f);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
886
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
887 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
888 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
889 else
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
890 height = FRAME_HEIGHT (f);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
891
25289
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
892 /* 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
893 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
894 cursor_color) are dependent upon them. */
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
895 for (p = 0; p < i; p++)
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
896 {
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
897 Lisp_Object prop, val;
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
898
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
899 prop = parms[p];
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
900 val = values[p];
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
901 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
902 {
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
903 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
904
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
905 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
906 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
907 store_frame_param (f, prop, val);
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
908 if (NATNUMP (param_index)
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
909 && (XFASTINT (param_index)
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
910 < 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
911 (*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
912 }
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
913 }
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
914
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
915 /* 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
916 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
917 {
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
918 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
919
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
920 prop = parms[i];
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
921 val = values[i];
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
922
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
923 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
924 width = XFASTINT (val);
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
925 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
926 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
927 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
928 top = val;
3447
ed2a17aac4cd (x_set_frame_parameters): Process all parms in reverse order.
Richard M. Stallman <rms@gnu.org>
parents: 3446
diff changeset
929 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
930 left = val;
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
931 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
932 icon_top = val;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
933 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
934 icon_left = val;
25289
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
935 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
936 /* Processed above. */
64b742df49ca (x_set_frame_parameters): Set foreground and
Geoff Voelker <voelker@cs.washington.edu>
parents: 25200
diff changeset
937 continue;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
938 else
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
939 {
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
940 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
941
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
942 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
943 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
944 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
945 if (NATNUMP (param_index)
cc76b76a1ed1 (CHECK_NATNUM): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents: 9948
diff changeset
946 && (XFASTINT (param_index)
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
947 < 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
948 (*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
949 }
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
950 }
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
951
4617
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
952 /* 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
953 if (EQ (left, Qunbound))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
954 {
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
955 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
956 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
957 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
958 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
959 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
960 }
4617
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
961 if (EQ (top, Qunbound))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
962 {
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
963 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
964 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
965 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
966 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
967 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
968 }
4617
807ba8bcc309 (x_set_frame_parameters): Don't die if just one of
Richard M. Stallman <rms@gnu.org>
parents: 4606
diff changeset
969
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
970 /* 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
971 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
972 {
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
973 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
974 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
975 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
976 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
977 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
978 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
979 {
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
980 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
981 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
982 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
983 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
984 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
985
11932
f3fb1e5dfde1 (x_set_frame_parameters) Fix typo.
Karl Heuer <kwzh@gnu.org>
parents: 11917
diff changeset
986 /* 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
987 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
988 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
989 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
990
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
991 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
992 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
993 yet. */
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
994 {
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
995 Lisp_Object frame;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
996
5107
2a019dd8ed51 (x_set_frame_parameters): Call check_frame_size
Richard M. Stallman <rms@gnu.org>
parents: 4771
diff changeset
997 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
998
9285
75f1c0d90b3d (x_set_frame_parameters, x_set_visibility, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9240
diff changeset
999 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
1000
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
1001 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
1002 || 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
1003 || 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
1004 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
1005
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1006 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
1007 && ! (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
1008 && ! (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
1009 && 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
1010 {
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1011 int leftpos = 0;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1012 int toppos = 0;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1013
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1014 /* 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
1015 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
1016 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
1017 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
1018 else if (INTEGERP (left))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1019 {
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1020 leftpos = XINT (left);
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1021 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
1022 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
1023 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1024 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
1025 && CONSP (XCDR (left))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1026 && INTEGERP (XCAR (XCDR (left))))
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 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
1029 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
1030 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1031 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
1032 && CONSP (XCDR (left))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1033 && INTEGERP (XCAR (XCDR (left))))
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 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
1036 }
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1037
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1038 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
1039 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
1040 else if (INTEGERP (top))
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 toppos = XINT (top);
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1043 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
1044 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
1045 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1046 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
1047 && CONSP (XCDR (top))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1048 && INTEGERP (XCAR (XCDR (top))))
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 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
1051 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
1052 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1053 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
1054 && CONSP (XCDR (top))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1055 && INTEGERP (XCAR (XCDR (top))))
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 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
1058 }
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
1059
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1060
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1061 /* 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
1062 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
1063 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
1064
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1065 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
1066
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
1067 /* 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
1068 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
1069 }
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
1070
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
1071 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
1072 && ! (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
1073 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
1074 }
24170
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
1075
3689490f7f65 (x_set_frame_parameters): gcpro as needed.
Richard M. Stallman <rms@gnu.org>
parents: 23793
diff changeset
1076 UNGCPRO;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1077 }
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1078
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1079 /* 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
1080 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
1081 not Emacs's own window. */
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1082
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1083 void
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1084 x_real_positions (f, xptr, yptr)
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1085 FRAME_PTR f;
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1086 int *xptr, *yptr;
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1087 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1088 int win_x, win_y;
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1089 Window child;
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1090
7946
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1091 /* 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
1092 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
1093
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1094 #ifdef USE_X_TOOLKIT
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1095 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
1096 ? XtWindow (f->output_data.x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1097 : 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
1098 #else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1099 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
1100 #endif
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1101 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
1102 Window *tmp_children;
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1103 int tmp_nchildren;
4dbba88e2717 (x_real_positions): Make sure we know the parent window.
Richard M. Stallman <rms@gnu.org>
parents: 7899
diff changeset
1104
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1105 while (1)
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1106 {
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1107 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
1108 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
1109
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1110 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
1111 &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
1112 &tmp_children, &tmp_nchildren);
14563
6aa8b322b4d7 (x_real_positions): Cast arg of XFree.
Karl Heuer <kwzh@gnu.org>
parents: 14530
diff changeset
1113 XFree ((char *) tmp_children);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1114
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1115 win_x = win_y = 0;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1116
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1117 /* 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
1118 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
1119 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
1120 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
1121 else
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1122 outer_window = outer;
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1123
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1124 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
1125
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1126 /* From-window, to-window. */
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1127 outer_window,
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1128 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
1129
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1130 /* From-position, to-position. */
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1131 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
1132
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1133 /* Child of win. */
7c919d7f8217 (x_real_positions): Directly compare the frame's window
Richard M. Stallman <rms@gnu.org>
parents: 17836
diff changeset
1134 &child);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1135
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1136 /* 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
1137 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
1138 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
1139 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
1140 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
1141 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
1142 {
17609
8c878d76d6a4 (x_real_positions, x_set_mouse_color, Fx_list_fonts):
Richard M. Stallman <rms@gnu.org>
parents: 17579
diff changeset
1143 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
1144 break;
94467271b641 (x_real_positions): Don't call x_uncatch_errors twice.
Richard M. Stallman <rms@gnu.org>
parents: 15081
diff changeset
1145 }
12111
832023e90d4d (x_real_positions): Uncatch and recatch X errors in the loop.
Karl Heuer <kwzh@gnu.org>
parents: 12094
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);
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1148 }
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
1149
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1150 *xptr = win_x;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1151 *yptr = win_y;
7408
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1152 }
65c133b66371 (x_real_positions): New function.
Richard M. Stallman <rms@gnu.org>
parents: 7308
diff changeset
1153
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1154 /* Insert a description of internally-recorded parameters of frame X
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1155 into the parameter alist *ALISTPTR that is to be given to the user.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1156 Only parameters that are specific to the X window system
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1157 and whose values are not correctly recorded in the frame's
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1158 param_alist need to be considered here. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1159
21536
468585662fa8 (x_destroy_bitmap): Declare as void, not int.
Karl Heuer <kwzh@gnu.org>
parents: 21267
diff changeset
1160 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1161 x_report_frame_params (f, alistptr)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1162 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1163 Lisp_Object *alistptr;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1164 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1165 char buf[16];
11986
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1166 Lisp_Object tem;
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1167
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1168 /* 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
1169 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
1170 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
1171 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
1172 store_in_alist (alistptr, Qleft, tem);
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1173 else
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1174 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
1175
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1176 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
1177 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
1178 store_in_alist (alistptr, Qtop, tem);
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1179 else
bfdf35b8c34b (x_report_frame_params): Report top and left
Karl Heuer <kwzh@gnu.org>
parents: 11962
diff changeset
1180 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
1181
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1182 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
1183 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
1184 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
1185 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
1186 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
1187 store_in_alist (alistptr, Qwindow_id,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1188 build_string (buf));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1189 #ifdef USE_X_TOOLKIT
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1190 /* 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
1191 if (f->output_data.x->widget)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1192 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1193 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
1194 store_in_alist (alistptr, Qouter_window_id,
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
1195 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
1196 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
1197 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
1198 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
1199 (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
1200 : 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
1201 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
1202 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
1203
18612
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1204 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
1205 tem = Qnil;
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1206 else
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
1207 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
1208 store_in_alist (alistptr, Qparent_id, tem);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1209 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1210
10920
bb3f9aaf0e46 (defined_color): If colormap is full, find closest match.
Richard M. Stallman <rms@gnu.org>
parents: 10742
diff changeset
1211
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1212
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1213 /* 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
1214
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1215 void
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1216 gamma_correct (f, color)
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1217 struct frame *f;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1218 XColor *color;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1219 {
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1220 if (f->gamma)
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1221 {
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1222 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
1223 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
1224 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
1225 }
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1226 }
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1227
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1228
28096
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1229 /* Decide if color named COLOR_NAME is valid for use on frame F. If
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1230 so, return the RGB values in COLOR. If ALLOC_P is non-zero,
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1231 allocate the color. Value is zero if COLOR_NAME is invalid, or
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1232 no color could be allocated. */
8675
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
1233
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1234 int
28096
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1235 x_defined_color (f, color_name, color, alloc_p)
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1236 struct frame *f;
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1237 char *color_name;
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1238 XColor *color;
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1239 int alloc_p;
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1240 {
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1241 int success_p;
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1242 Display *dpy = FRAME_X_DISPLAY (f);
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1243 Colormap cmap = FRAME_X_COLORMAP (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1244
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1245 BLOCK_INPUT;
28096
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1246 success_p = XParseColor (dpy, cmap, color_name, color);
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1247 if (success_p && alloc_p)
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1248 success_p = x_alloc_nearest_color (f, cmap, color);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1249 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1250
28096
244f283b3d03 (x_defined_color): Rewritten to use x_allocate_nearest_color.
Gerd Moellmann <gerd@gnu.org>
parents: 28050
diff changeset
1251 return success_p;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1252 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1253
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1254
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1255 /* Return the pixel color value for color COLOR_NAME on frame F. If F
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1256 is a monochrome frame, return MONO_COLOR regardless of what ARG says.
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1257 Signal an error if color can't be allocated. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1258
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1259 int
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1260 x_decode_color (f, color_name, mono_color)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1261 FRAME_PTR f;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1262 Lisp_Object color_name;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1263 int mono_color;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1264 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1265 XColor cdef;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1266
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1267 CHECK_STRING (color_name, 0);
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1268
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1269 #if 0 /* Don't do this. It's wrong when we're not using the default
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1270 colormap, it makes freeing difficult, and it's probably not
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1271 an important optimization. */
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1272 if (strcmp (XSTRING (color_name)->data, "black") == 0)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1273 return BLACK_PIX_DEFAULT (f);
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1274 else if (strcmp (XSTRING (color_name)->data, "white") == 0)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1275 return WHITE_PIX_DEFAULT (f);
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1276 #endif
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1277
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1278 /* Return MONO_COLOR for monochrome frames. */
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1279 if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1280 return mono_color;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1281
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
1282 /* x_defined_color is responsible for coping with failures
11060
0a7048d331e6 (x_decode_color): Don't use cdef if defined_color failed.
Richard M. Stallman <rms@gnu.org>
parents: 11014
diff changeset
1283 by looking for a near-miss. */
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1284 if (x_defined_color (f, XSTRING (color_name)->data, &cdef, 1))
11060
0a7048d331e6 (x_decode_color): Don't use cdef if defined_color failed.
Richard M. Stallman <rms@gnu.org>
parents: 11014
diff changeset
1285 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
1286
13083
16638ebb209f (Fx_create_frame): Set up buffer-predicate slot.
Richard M. Stallman <rms@gnu.org>
parents: 12832
diff changeset
1287 Fsignal (Qerror, Fcons (build_string ("undefined color"),
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1288 Fcons (color_name, Qnil)));
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1289 }
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1290
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1291
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1292
28690
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1293 /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1294 the previous value of that parameter, NEW_VALUE is the new value. */
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1295
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1296 static void
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1297 x_set_line_spacing (f, new_value, old_value)
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1298 struct frame *f;
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1299 Lisp_Object new_value, old_value;
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1300 {
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1301 if (NILP (new_value))
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1302 f->extra_line_spacing = 0;
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1303 else if (NATNUMP (new_value))
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1304 f->extra_line_spacing = XFASTINT (new_value);
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1305 else
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1306 Fsignal (Qerror, Fcons (build_string ("Illegal line-spacing"),
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1307 Fcons (new_value, Qnil)));
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1308 if (FRAME_VISIBLE_P (f))
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1309 redraw_frame (f);
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1310 }
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1311
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
1312
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1313 /* 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
1314 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
1315
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1316 static void
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1317 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
1318 struct frame *f;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1319 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
1320 {
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1321 if (NILP (new_value))
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1322 f->gamma = 0;
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1323 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
1324 /* 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
1325 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
1326 else
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1327 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
1328 Fcons (new_value, Qnil)));
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1329
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1330 clear_face_cache (0);
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1331 }
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1332
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
1333
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1334 /* Functions called only from `x_set_frame_param'
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335 to set individual parameters.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1336
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
1337 If FRAME_X_WINDOW (f) is 0,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1338 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
1339 In that case, just record the parameter's new value
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340 in the standard place; do not attempt to change the window. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1343 x_set_foreground_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1344 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1347 unsigned long pixel
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1348 = 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
1349
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1350 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
1351 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
1352
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
1353 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1354 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 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
1356 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
1357 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
1358 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
1359 f->output_data.x->foreground_pixel);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360 UNBLOCK_INPUT;
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1361 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
1362 if (FRAME_VISIBLE_P (f))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1363 redraw_frame (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1365 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1366
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1367 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1368 x_set_background_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1369 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1370 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1372 unsigned long pixel
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1373 = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1374
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1375 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
1376 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
1377
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
1378 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1379 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1380 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1381 /* 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
1382 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
1383 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
1384 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
1385 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
1386 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
1387 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
1388 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
1389 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
1390 {
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1391 Lisp_Object bar;
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1392 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
1393 bar = XSCROLL_BAR (bar)->next)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1394 XSetWindowBackground (FRAME_X_DISPLAY (f),
7599
880fcef68f73 (x_set_background_color): Set scroll bar backgrounds.
Karl Heuer <kwzh@gnu.org>
parents: 7525
diff changeset
1395 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
1396 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
1397 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1400 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
1401
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
1402 if (FRAME_VISIBLE_P (f))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1403 redraw_frame (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1408 x_set_mouse_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1409 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 {
6759
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1412 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
1413 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
1414 int count;
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1415 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
1416 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
1417
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1418 /* 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
1419 if (mask_color == pixel
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1420 && 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
1421 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
1422
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1423 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
1424 f->output_data.x->mouse_pixel = pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 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
1427
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3512
diff changeset
1428 /* 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
1429 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
1430
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431 if (!EQ (Qnil, Vx_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433 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
1434 cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XINT (Vx_pointer_shape));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1435 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1436 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1437 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
1438 x_check_errors (FRAME_X_DISPLAY (f), "bad text pointer cursor: %s");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1439
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1440 if (!EQ (Qnil, Vx_nontext_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1442 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
1443 nontext_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444 XINT (Vx_nontext_pointer_shape));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1445 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1447 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
1448 x_check_errors (FRAME_X_DISPLAY (f), "bad nontext pointer cursor: %s");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1449
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1450 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
1451 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1452 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
1453 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
1454 XINT (Vx_busy_pointer_shape));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1455 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1456 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1457 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
1458 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
1459
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1460 x_check_errors (FRAME_X_DISPLAY (f), "bad nontext pointer cursor: %s");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1461 if (!EQ (Qnil, Vx_mode_pointer_shape))
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1462 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1463 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
1464 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
1465 XINT (Vx_mode_pointer_shape));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1466 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1467 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1468 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
1469 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
1470
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1471 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
1472 {
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1473 CHECK_NUMBER (Vx_sensitive_text_pointer_shape, 0);
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1474 cross_cursor
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1475 = XCreateFontCursor (FRAME_X_DISPLAY (f),
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
1476 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
1477 }
e0938c42218c (syms_of_xfns): Define Vx_cross_pointer_shape.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6610
diff changeset
1478 else
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1479 cross_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_crosshair);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1480
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
1481 /* 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
1482 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
1483 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
1484
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1485 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1486 XColor fore_color, back_color;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1487
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1488 fore_color.pixel = f->output_data.x->mouse_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1489 back_color.pixel = mask_color;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1490 XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491 &fore_color);
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
1492 XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1493 &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1494 XRecolorCursor (FRAME_X_DISPLAY (f), cursor,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1495 &fore_color, &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1496 XRecolorCursor (FRAME_X_DISPLAY (f), nontext_cursor,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1497 &fore_color, &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1498 XRecolorCursor (FRAME_X_DISPLAY (f), mode_cursor,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1499 &fore_color, &back_color);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1500 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
1501 &fore_color, &back_color);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1502 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
1503 &fore_color, &back_color);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1504 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1505
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
1506 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
1507 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1508
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1509 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
1510 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
1511 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
1512
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1513 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
1514 && 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
1515 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
1516 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
1517
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1518 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
1519 && 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
1520 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
1521 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
1522
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1523 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
1524 && 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
1525 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
1526 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
1527
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1528 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
1529 && 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
1530 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
1531 f->output_data.x->cross_cursor = cross_cursor;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1532
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1533 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1534 UNBLOCK_INPUT;
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1535
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1536 update_face_from_frame_parameter (f, Qmouse_color, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1537 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1538
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1539 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1540 x_set_cursor_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1541 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1543 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1544 unsigned long fore_pixel, pixel;
28355
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1545 int fore_pixel_allocated_p = 0, pixel_allocated_p = 0;
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1546
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1547 if (!NILP (Vx_cursor_fore_pixel))
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1548 {
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1549 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1550 WHITE_PIX_DEFAULT (f));
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1551 fore_pixel_allocated_p = 1;
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1552 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1553 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1554 fore_pixel = f->output_data.x->background_pixel;
28355
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1555
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1556 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
28355
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1557 pixel_allocated_p = 1;
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1558
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1559 /* 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
1560 if (pixel == f->output_data.x->background_pixel)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1561 {
28355
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1562 if (pixel_allocated_p)
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1563 {
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1564 x_free_colors (f, &pixel, 1);
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1565 pixel_allocated_p = 0;
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1566 }
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1567
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1568 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
1569 if (pixel == fore_pixel)
28355
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1570 {
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1571 if (fore_pixel_allocated_p)
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1572 {
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1573 x_free_colors (f, &fore_pixel, 1);
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1574 fore_pixel_allocated_p = 0;
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1575 }
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1576 fore_pixel = f->output_data.x->background_pixel;
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1577 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1578 }
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1579
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1580 unload_color (f, f->output_data.x->cursor_foreground_pixel);
28355
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1581 if (!fore_pixel_allocated_p)
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1582 fore_pixel = x_copy_color (f, 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
1583 f->output_data.x->cursor_foreground_pixel = fore_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1584
25075
9f5d679349e9 (x_set_mouse_color): Always unload the old color.
Karl Heuer <kwzh@gnu.org>
parents: 24994
diff changeset
1585 unload_color (f, f->output_data.x->cursor_pixel);
28355
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1586 if (!pixel_allocated_p)
11d7a6fdad5f (x_set_cursor_color): Get color reference counts right.
Gerd Moellmann <gerd@gnu.org>
parents: 28347
diff changeset
1587 pixel = x_copy_color (f, pixel);
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1588 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
1589
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
1590 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 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
1593 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
1594 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
1595 XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1596 fore_pixel);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1597 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
1599 if (FRAME_VISIBLE_P (f))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1600 {
15999
0e148af7d4ec (x_set_cursor_color): Use x_update_cursor.
Richard M. Stallman <rms@gnu.org>
parents: 15942
diff changeset
1601 x_update_cursor (f, 0);
0e148af7d4ec (x_set_cursor_color): Use x_update_cursor.
Richard M. Stallman <rms@gnu.org>
parents: 15942
diff changeset
1602 x_update_cursor (f, 1);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1604 }
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1605
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1606 update_face_from_frame_parameter (f, Qcursor_color, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1607 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1608
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1609 /* Set the border-color of frame F to value described by ARG.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1610 ARG can be a string naming a color.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1611 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
1612 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
1613 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
1614
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1615 Note: this is done in two routines because of the way X10 works.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1616
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 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
1618 and so emacs' border colors may be overridden. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1620 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1621 x_set_border_color (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1622 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1623 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1624 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1625 int pix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1626
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1627 CHECK_STRING (arg, 0);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1628 pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1629 x_set_border_pixel (f, pix);
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
1630 update_face_from_frame_parameter (f, Qborder_color, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1631 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1632
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1633 /* Set the border-color of frame F to pixel value PIX.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1634 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
1635 F has an x-window. */
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1636
21536
468585662fa8 (x_destroy_bitmap): Declare as void, not int.
Karl Heuer <kwzh@gnu.org>
parents: 21267
diff changeset
1637 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1638 x_set_border_pixel (f, pix)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1639 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640 int pix;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641 {
21779
6aaa0268fe91 (x_set_foreground_color, x_set_background_color)
Richard M. Stallman <rms@gnu.org>
parents: 21555
diff changeset
1642 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
1643 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
1644
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1645 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
1646 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1647 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1648 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
1649 (unsigned long)pix);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1650 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1651
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
1652 if (FRAME_VISIBLE_P (f))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1653 redraw_frame (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1654 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1655 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1656
28347
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1657
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1658 /* Value is the internal representation of the specified cursor type
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1659 ARG. If type is BAR_CURSOR, return in *WIDTH the specified width
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1660 of the bar cursor. */
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1661
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1662 enum text_cursor_kinds
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1663 x_specified_cursor_type (arg, width)
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1664 Lisp_Object arg;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1665 int *width;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1666 {
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1667 enum text_cursor_kinds type;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1668
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1669 if (EQ (arg, Qbar))
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1670 {
28347
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1671 type = BAR_CURSOR;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1672 *width = 2;
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1673 }
28050
79a67f9da183 (x_set_cursor_type): If ARG is nil, give frame no cursor.
Gerd Moellmann <gerd@gnu.org>
parents: 28044
diff changeset
1674 else if (CONSP (arg)
79a67f9da183 (x_set_cursor_type): If ARG is nil, give frame no cursor.
Gerd Moellmann <gerd@gnu.org>
parents: 28044
diff changeset
1675 && EQ (XCAR (arg), Qbar)
79a67f9da183 (x_set_cursor_type): If ARG is nil, give frame no cursor.
Gerd Moellmann <gerd@gnu.org>
parents: 28044
diff changeset
1676 && INTEGERP (XCDR (arg))
79a67f9da183 (x_set_cursor_type): If ARG is nil, give frame no cursor.
Gerd Moellmann <gerd@gnu.org>
parents: 28044
diff changeset
1677 && XINT (XCDR (arg)) >= 0)
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1678 {
28347
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1679 type = BAR_CURSOR;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1680 *width = XINT (XCDR (arg));
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1681 }
28050
79a67f9da183 (x_set_cursor_type): If ARG is nil, give frame no cursor.
Gerd Moellmann <gerd@gnu.org>
parents: 28044
diff changeset
1682 else if (NILP (arg))
28347
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1683 type = NO_CURSOR;
3134
efdaaa695ad4 (x_set_cursor_type): If arg not recognized, use box cursor.
Richard M. Stallman <rms@gnu.org>
parents: 3108
diff changeset
1684 else
10742
e4d6f6f1fc17 (x_set_cursor_type): Set cursor_width field.
Richard M. Stallman <rms@gnu.org>
parents: 10717
diff changeset
1685 /* 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
1686 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
1687 .Xdefaults with Emacs, when it has something bad in it. */
28347
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1688 type = FILLED_BOX_CURSOR;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1689
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1690 return type;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1691 }
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1692
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1693 void
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1694 x_set_cursor_type (f, arg, oldval)
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1695 FRAME_PTR f;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1696 Lisp_Object arg, oldval;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1697 {
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1698 int width;
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1699
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1700 FRAME_DESIRED_CURSOR (f) = x_specified_cursor_type (arg, &width);
ce7dddf6dfb7 (x_specified_cursor_type): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28229
diff changeset
1701 f->output_data.x->cursor_width = width;
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1702
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1703 /* 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
1704 often do people change cursor types? */
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1705 update_mode_lines++;
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1706 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1707
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
1708 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1709 x_set_icon_type (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1710 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1711 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1712 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1713 int result;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1714
9543
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1715 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
1716 {
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 (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
1718 return;
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1719 }
3cf8aa53c4cf (x_set_icon_type): If icon-type is a string, then use
Richard M. Stallman <rms@gnu.org>
parents: 9528
diff changeset
1720 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1721 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1722
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1723 BLOCK_INPUT;
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 436
diff changeset
1724 if (NILP (arg))
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1725 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
1726 (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
1727 ? f->icon_name
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1728 : f->name))->data);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1729 else
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1730 result = x_bitmap_icon (f, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1731
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1732 if (result)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1733 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
1734 UNBLOCK_INPUT;
9353
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1735 error ("No icon window available");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1736 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1737
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
1738 XFlush (FRAME_X_DISPLAY (f));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1739 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1740 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1741
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1742 /* Return non-nil if frame F wants a bitmap icon. */
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1743
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1744 Lisp_Object
9353
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1745 x_icon_type (f)
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1746 FRAME_PTR f;
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1747 {
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1748 Lisp_Object tem;
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 tem = assq_no_quit (Qicon_type, f->param_alist);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1751 if (CONSP (tem))
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
1752 return XCDR (tem);
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1753 else
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
1754 return Qnil;
9353
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1755 }
30659ed71a1b (x_set_icon_type): Remove period from error message.
Richard M. Stallman <rms@gnu.org>
parents: 9329
diff changeset
1756
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1757 void
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1758 x_set_icon_name (f, arg, oldval)
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1759 struct frame *f;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1760 Lisp_Object arg, oldval;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1761 {
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1762 int result;
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 if (STRINGP (arg))
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 (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1767 return;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1768 }
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1769 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1770 return;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1771
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
1772 f->icon_name = arg;
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1773
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1774 if (f->output_data.x->icon_bitmap != 0)
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1775 return;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1776
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1777 BLOCK_INPUT;
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 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
1780 (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
1781 ? f->icon_name
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1782 : !NILP (f->title)
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1783 ? f->title
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1784 : f->name))->data);
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1785
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1786 if (result)
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 UNBLOCK_INPUT;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1789 error ("No icon window available");
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1790 }
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1791
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1792 XFlush (FRAME_X_DISPLAY (f));
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1793 UNBLOCK_INPUT;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
1794 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1795
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1796 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1797 x_set_font (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1798 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1799 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1800 {
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1801 Lisp_Object result;
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1802 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
1803 Lisp_Object frame;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1804
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1805 CHECK_STRING (arg, 1);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1806
21555
0927f341e390 (x_set_font): Give 2nd arg nil to Fquery_fontset.
Kenichi Handa <handa@m17n.org>
parents: 21549
diff changeset
1807 fontset_name = Fquery_fontset (arg, Qnil);
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1808
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1809 BLOCK_INPUT;
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1810 result = (STRINGP (fontset_name)
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1811 ? x_new_fontset (f, XSTRING (fontset_name)->data)
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
1812 : x_new_font (f, XSTRING (arg)->data));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1813 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1814
3075
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1815 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
1816 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
1817 else if (EQ (result, Qt))
24589
316c00e8bc62 (x_set_font): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents: 24412
diff changeset
1818 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
1819 else if (STRINGP (result))
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1820 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1821 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
1822 recompute_basic_faces (f);
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1823 }
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1824 else
878381e48b0d * xfns.c: Clear out the old face stuff.
Jim Blandy <jimb@redhat.com>
parents: 3048
diff changeset
1825 abort ();
18631
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
1826
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
1827 do_pending_window_change (0);
25153
fc8435c2ae0e (x_set_internal_border_width):
Richard M. Stallman <rms@gnu.org>
parents: 25082
diff changeset
1828
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1829 /* 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
1830 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
1831 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
1832 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
1833 null widget which gives a segfault. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1834 if (FRAME_FACE_CACHE (f))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1835 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1836 XSETFRAME (frame, f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1837 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
1838 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1839 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1840
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1841 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1842 x_set_border_width (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1843 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1844 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1845 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1846 CHECK_NUMBER (arg, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1848 if (XINT (arg) == f->output_data.x->border_width)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1850
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
1851 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852 error ("Cannot change the border width of a window");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1853
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1854 f->output_data.x->border_width = XINT (arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1856
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1857 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1858 x_set_internal_border_width (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1859 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1860 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1861 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1862 int old = f->output_data.x->internal_border_width;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1863
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1864 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
1865 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
1866 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
1867 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
1868
16396
4e4cc27b2a2a (x_set_internal_border_width): Only change
Richard M. Stallman <rms@gnu.org>
parents: 16357
diff changeset
1869 #ifdef USE_X_TOOLKIT
16351
ac552926fc7e (x_set_internal_border_width, Fx_create_frame):
Richard M. Stallman <rms@gnu.org>
parents: 16305
diff changeset
1870 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
1871 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
1872 #endif
16351
ac552926fc7e (x_set_internal_border_width, Fx_create_frame):
Richard M. Stallman <rms@gnu.org>
parents: 16305
diff changeset
1873
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
1874 if (f->output_data.x->internal_border_width == old)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1875 return;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1876
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
1877 if (FRAME_X_WINDOW (f) != 0)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878 {
5899
4e8f26a0f2b7 *** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5721
diff changeset
1879 x_set_window_size (f, 0, f->width, f->height);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
1880 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
1881 do_pending_window_change (0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1882 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1883 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1884
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1885 void
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1886 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
1887 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
1888 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
1889 {
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 frame;
9285
75f1c0d90b3d (x_set_frame_parameters, x_set_visibility, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9240
diff changeset
1891 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
1892
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1893 if (NILP (value))
5899
4e8f26a0f2b7 *** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5721
diff changeset
1894 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
1895 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
1896 Ficonify_frame (frame);
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
1897 else
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1898 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
1899 }
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
1900
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1901 static void
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1902 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
1903 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
1904 int n;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1905 {
3477
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1906 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
1907
9329
4e1048594e7f (x_set_menu_bar_lines_1): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9327
diff changeset
1908 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
1909 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
1910
28010
5e3c139838a6 (x_set_menu_bar_lines_1): Adjust window's orig_top and
Gerd Moellmann <gerd@gnu.org>
parents: 28001
diff changeset
1911 if (INTEGERP (w->orig_top))
5e3c139838a6 (x_set_menu_bar_lines_1): Adjust window's orig_top and
Gerd Moellmann <gerd@gnu.org>
parents: 28001
diff changeset
1912 XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);
5e3c139838a6 (x_set_menu_bar_lines_1): Adjust window's orig_top and
Gerd Moellmann <gerd@gnu.org>
parents: 28001
diff changeset
1913 if (INTEGERP (w->orig_height))
5e3c139838a6 (x_set_menu_bar_lines_1): Adjust window's orig_top and
Gerd Moellmann <gerd@gnu.org>
parents: 28001
diff changeset
1914 XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);
5e3c139838a6 (x_set_menu_bar_lines_1): Adjust window's orig_top and
Gerd Moellmann <gerd@gnu.org>
parents: 28001
diff changeset
1915
3477
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1916 /* 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
1917 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
1918 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
1919
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1920 /* 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
1921 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
1922 {
3477
c079a2d6cf0e (x_set_menu_bar_lines_1): Adjust just the uppermost child
Richard M. Stallman <rms@gnu.org>
parents: 3447
diff changeset
1923 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
1924 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
1925 }
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1926 }
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1927
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1928 void
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1929 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
1930 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
1931 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
1932 {
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1933 int nlines;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
1934 #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
1935 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
1936 #endif
2136
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1937
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 /* 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
1939 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
1940 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
1941 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
1942 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
1943 return;
9a78169e44df * xfns.c (x_set_menu_bar_lines): Minibuffer-only frames can't have
Jim Blandy <jimb@redhat.com>
parents: 2842
diff changeset
1944
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
1945 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
1946 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
1947 else
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1948 nlines = 0;
17ab6ed0f98b (x_frame_parms): Add elts for visibility and menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 2067
diff changeset
1949
17556
c0f8f4264f7a (x_set_menu_bar_lines): Increment windows_or_buffers_changed.
Richard M. Stallman <rms@gnu.org>
parents: 17106
diff changeset
1950 /* 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
1951 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
1952
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1953 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1954 FRAME_MENU_BAR_LINES (f) = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1955 if (nlines)
12832
0d750e41c4f2 (x_set_menu_bar_lines) [USE_X_TOOLKIT]: When turning
Richard M. Stallman <rms@gnu.org>
parents: 12773
diff changeset
1956 {
0d750e41c4f2 (x_set_menu_bar_lines) [USE_X_TOOLKIT]: When turning
Richard M. Stallman <rms@gnu.org>
parents: 12773
diff changeset
1957 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
1958 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
1959 /* 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
1960 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
1961 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1962 else
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1963 {
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
1964 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
1965 free_frame_menubar (f);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1966 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
1967 if (FRAME_X_P (f))
714433bead7f (x_set_menu_bar_lines) [USE_X_TOOLKIT]:
Richard M. Stallman <rms@gnu.org>
parents: 13508
diff changeset
1968 f->output_data.x->menubar_widget = 0;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1969 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
1970 #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
1971 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
1972 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
1973 #endif /* not USE_X_TOOLKIT */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1974 adjust_glyphs (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1975 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1976
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1977
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1978 /* 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
1979 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
1980 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
1981 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
1982 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
1983
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1984 void
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
1985 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
1986 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1987 Lisp_Object value, oldval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1988 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1989 int delta, nlines;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1990
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1991 /* 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
1992 if (INTEGERP (value) && XINT (value) >= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1993 nlines = XFASTINT (value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1994 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1995 nlines = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1996
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1997 /* 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
1998 ++windows_or_buffers_changed;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
1999
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
2000 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
2001 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
2002 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
2003 adjust_glyphs (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2004 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2005
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2006
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2007 /* 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
2008 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
2009 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
2010 the frame parameter. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2011
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2012 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2013 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
2014 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2015 Lisp_Object value, oldval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2016 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2017 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2018
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2019 if (STRINGP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2020 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
2021 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2022 pixel = -1;
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 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
2025 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
2026
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2027 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
2028 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
2029 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2030 /* 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
2031 if (condemn_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2032 (*condemn_scroll_bars_hook) (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2033 if (judge_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2034 (*judge_scroll_bars_hook) (f);
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
2035
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
2036 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
2037 redraw_frame (f);
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 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2040
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2041
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2042 /* 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
2043 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
2044 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
2045 parameter. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2046
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2047 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2048 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
2049 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2050 Lisp_Object value, oldval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2051 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2052 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2053
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2054 if (STRINGP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2055 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
2056 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2057 pixel = -1;
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 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
2060 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
2061
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2062 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
2063 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
2064 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2065 /* 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
2066 if (condemn_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2067 (*condemn_scroll_bars_hook) (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2068 if (judge_scroll_bars_hook)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2069 (*judge_scroll_bars_hook) (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2070
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
2071 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
2072 redraw_frame (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2073 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2074 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2075
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2076
4650
d81041bb1e3d comment fix
David J. MacKenzie <djm@gnu.org>
parents: 4629
diff changeset
2077 /* 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
2078 x_id_name.
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2079
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2080 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
2081 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
2082 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
2083
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2084 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
2085 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
2086 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
2087
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2088 void
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2089 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
2090 struct frame *f;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2091 Lisp_Object name;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2092 int explicit;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2093 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2094 /* 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
2095 Emacs redisplay code. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2096 if (explicit)
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2097 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2098 /* 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
2099 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
2100 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
2101 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
2102
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2103 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
2104 }
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2105 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
2106 return;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2107
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2108 /* 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
2109 if (NILP (name))
8090
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
2110 {
bb03e344f07e (x_set_frame_parameters): Call x_set_offset directly.
Richard M. Stallman <rms@gnu.org>
parents: 7989
diff changeset
2111 /* 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
2112 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
2113 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
2114 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
2115 return;
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
2116 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
2117 }
833
14748faa4f17 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 817
diff changeset
2118 else
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2119 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
2120
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2121 /* 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
2122 if (! NILP (Fstring_equal (name, f->name)))
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 708
diff changeset
2123 return;
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 708
diff changeset
2124
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2125 f->name = name;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2126
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2127 /* 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
2128 the name parameter. */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2129 if (! NILP (f->title))
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2130 name = f->title;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2131
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 if (FRAME_X_WINDOW (f))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2133 {
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 700
diff changeset
2134 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
2135 #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
2136 {
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2137 XTextProperty text, icon;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2138 Lisp_Object icon_name;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2139
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
2140 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
2141 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
2142 text.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2143 text.nitems = STRING_BYTES (XSTRING (name));
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2144
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
2145 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
2146
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2147 icon.value = XSTRING (icon_name)->data;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2148 icon.encoding = XA_STRING;
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
2149 icon.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2150 icon.nitems = STRING_BYTES (XSTRING (icon_name));
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2151 #ifdef USE_X_TOOLKIT
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2152 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
2153 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
2154 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
2155 &icon);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2156 #else /* not USE_X_TOOLKIT */
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2157 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
2158 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
2159 #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
2160 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2161 #else /* not HAVE_X11R4 */
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2162 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
2163 XSTRING (name)->data);
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2164 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
2165 XSTRING (name)->data);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2166 #endif /* not HAVE_X11R4 */
708
030fb4635335 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 700
diff changeset
2167 UNBLOCK_INPUT;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2168 }
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2169 }
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2170
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2171 /* 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
2172 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
2173 redisplay code. */
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2174 void
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2175 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
2176 FRAME_PTR f;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2177 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
2178 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2179 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
2180 }
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2181
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2182 /* 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
2183 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
2184 lisp code. */
1125
059624bf9bf0 Declare x_implicitly_set_name to be void.
Jim Blandy <jimb@redhat.com>
parents: 1096
diff changeset
2185 void
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2186 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
2187 FRAME_PTR f;
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2188 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
2189 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2190 x_set_name (f, arg, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2191 }
14482
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 /* 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
2194 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
2195
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2196 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
2197 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
2198 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
2199
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2200 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
2201 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
2202 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
2203
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2204 void
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2205 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
2206 struct frame *f;
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2207 Lisp_Object name, old_name;
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2208 {
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2209 /* 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
2210 if (EQ (name, f->title))
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2211 return;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2212
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2213 update_mode_lines = 1;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2214
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2215 f->title = name;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2216
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2217 if (NILP (name))
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2218 name = f->name;
16732
f52c4fd47f03 (x_set_title): Check data type of NAME.
Richard M. Stallman <rms@gnu.org>
parents: 16682
diff changeset
2219 else
f52c4fd47f03 (x_set_title): Check data type of NAME.
Richard M. Stallman <rms@gnu.org>
parents: 16682
diff changeset
2220 CHECK_STRING (name, 0);
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2221
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2222 if (FRAME_X_WINDOW (f))
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 BLOCK_INPUT;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2225 #ifdef HAVE_X11R4
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 XTextProperty text, icon;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2228 Lisp_Object icon_name;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2229
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2230 text.value = XSTRING (name)->data;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2231 text.encoding = XA_STRING;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2232 text.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2233 text.nitems = STRING_BYTES (XSTRING (name));
14482
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2234
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2235 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
2236
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2237 icon.value = XSTRING (icon_name)->data;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2238 icon.encoding = XA_STRING;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2239 icon.format = 8;
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2240 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
2241 #ifdef USE_X_TOOLKIT
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2242 XSetWMName (FRAME_X_DISPLAY (f),
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2243 XtWindow (f->output_data.x->widget), &text);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2244 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
2245 &icon);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2246 #else /* not USE_X_TOOLKIT */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2247 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
2248 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
2249 #endif /* not USE_X_TOOLKIT */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2250 }
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2251 #else /* not HAVE_X11R4 */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2252 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
2253 XSTRING (name)->data);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2254 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
2255 XSTRING (name)->data);
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2256 #endif /* not HAVE_X11R4 */
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2257 UNBLOCK_INPUT;
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2258 }
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2259 }
479987ba2c8d (x_frame_parms): Add "title" element.
Richard M. Stallman <rms@gnu.org>
parents: 14439
diff changeset
2260
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2261 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2262 x_set_autoraise (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2263 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2264 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2265 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2266 f->auto_raise = !EQ (Qnil, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2267 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2268
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2269 void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2270 x_set_autolower (f, arg, oldval)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2271 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2272 Lisp_Object arg, oldval;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2273 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2274 f->auto_lower = !EQ (Qnil, arg);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2275 }
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2276
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2277 void
9580
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2278 x_set_unsplittable (f, arg, oldval)
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2279 struct frame *f;
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2280 Lisp_Object arg, oldval;
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 f->no_split = !NILP (arg);
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2283 }
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2284
bcc9342cf633 (x_set_unsplittable): New function.
Karl Heuer <kwzh@gnu.org>
parents: 9563
diff changeset
2285 void
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
2286 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
2287 struct frame *f;
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2288 Lisp_Object arg, oldval;
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2289 {
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2290 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
2291 || (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
2292 || (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
2293 || (!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
2294 {
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2295 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
2296 = (NILP (arg)
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2297 ? vertical_scroll_bar_none
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2298 : EQ (Qright, arg)
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2299 ? vertical_scroll_bar_right
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2300 : 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
2301
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2302 /* 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
2303 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
2304 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
2305 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
2306 if (FRAME_X_WINDOW (f))
5899
4e8f26a0f2b7 *** empty log message ***
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5721
diff changeset
2307 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
2308 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
2309 }
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
2310 }
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2311
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2312 void
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2313 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
2314 struct frame *f;
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2315 Lisp_Object arg, oldval;
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2316 {
18594
5ca5ff1c74eb (x_set_scroll_bar_width): By default, use enough
Richard M. Stallman <rms@gnu.org>
parents: 18114
diff changeset
2317 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
2318
9166
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2319 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
2320 {
25511
9bc9d4d6c716 (x_set_scroll_bar_width): Change conditional compilation
Gerd Moellmann <gerd@gnu.org>
parents: 25464
diff changeset
2321 #ifdef USE_TOOLKIT_SCROLL_BARS
9bc9d4d6c716 (x_set_scroll_bar_width): Change conditional compilation
Gerd Moellmann <gerd@gnu.org>
parents: 25464
diff changeset
2322 /* 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
2323 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
2324 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
2325 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
2326 #else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2327 /* 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
2328 character width. */
18594
5ca5ff1c74eb (x_set_scroll_bar_width): By default, use enough
Richard M. Stallman <rms@gnu.org>
parents: 18114
diff changeset
2329 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
2330
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2331 /* 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
2332 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
2333 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
2334 #endif
18594
5ca5ff1c74eb (x_set_scroll_bar_width): By default, use enough
Richard M. Stallman <rms@gnu.org>
parents: 18114
diff changeset
2335
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
2336 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
2337 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
2338 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
2339 }
44b44e900cf1 (x_set_scroll_bar_width): Nil now means 2 columns' worth of pixels.
Karl Heuer <kwzh@gnu.org>
parents: 9103
diff changeset
2340 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
2341 && 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
2342 {
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
2343 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
2344 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
2345
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2346 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
2347 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
2348 if (FRAME_X_WINDOW (f))
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
2349 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
2350 }
16302
025b3dc7a6ba (Fx_create_frame): Default Qinternal_border_width to 1.
Richard M. Stallman <rms@gnu.org>
parents: 16254
diff changeset
2351
25363
bf0488244270 Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents: 25335
diff changeset
2352 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
2353 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
2354 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
2355 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2356
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2357
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2358
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2359 /* Subroutines of creating an X frame. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2360
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2361 /* 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
2362 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
2363
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2364 static void
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2365 validate_x_resource_name ()
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2366 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2367 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
2368 /* 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
2369 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
2370 /* 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
2371 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
2372 Lisp_Object new;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2373 int i;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2374
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
2375 if (!STRINGP (Vx_resource_class))
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
2376 Vx_resource_class = build_string (EMACS_CLASS);
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
2377
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
2378 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
2379 {
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2380 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
2381 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
2382
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2383 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
2384
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2385 /* 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
2386 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
2387 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
2388 {
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 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
2390 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
2391 || (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
2392 || (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
2393 || c == '-' || c == '_'))
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2394 bad_count++;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2395 else
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2396 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
2397 }
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2398 }
5b784d881c0f (validate_x_resource_name): Don't let Vx_resource_name have invalid characters.
Richard M. Stallman <rms@gnu.org>
parents: 7408
diff changeset
2399 else
11353
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2400 /* 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
2401 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
2402
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2403 /* 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
2404 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
2405 return;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2406
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2407 /* 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
2408 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
2409 || (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
2410 {
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2411 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
2412 return;
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2413 }
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 /* 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
2416 with underscores. */
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2417
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2418 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
2419
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2420 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
2421 {
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2422 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
2423 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
2424 || (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
2425 || (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
2426 || c == '-' || c == '_'))
9e3da029f921 (x_window): Copy the frame name to non-Lisp string.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
2427 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
2428 }
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2429 }
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2430
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2431
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2432 extern char *x_get_string_resource ();
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2433
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2434 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
2435 "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
2436 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
2437 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
2438 the name specified by the `-name' or `-rn' command-line arguments.\n\
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2439 \n\
1733
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2440 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
2441 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
2442 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
2443 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
2444 (attribute, class, component, subclass)
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2445 Lisp_Object attribute, class, component, subclass;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2446 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2447 register char *value;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2448 char *name_key;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2449 char *class_key;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2450
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
2451 check_x ();
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
2452
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2453 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
2454 CHECK_STRING (class, 0);
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2455
1733
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2456 if (!NILP (component))
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2457 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
2458 if (!NILP (subclass))
2d41a3d7b9a6 (Fx_get_resource): Use EMACS_CLASS to make class_key
Richard M. Stallman <rms@gnu.org>
parents: 1719
diff changeset
2459 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
2460 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
2461 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
2462
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
2463 validate_x_resource_name ();
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2464
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2465 /* 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
2466 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
2467 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
2468 + (STRINGP (component)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2469 ? STRING_BYTES (XSTRING (component)) : 0)
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2470 + STRING_BYTES (XSTRING (attribute))
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2471 + 3);
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2472
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2473 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
2474 + STRING_BYTES (XSTRING (class))
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2475 + (STRINGP (subclass)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2476 ? 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
2477 + 3);
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2478
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2479 /* 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
2480 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
2481 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
2482 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
2483
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2484 strcat (class_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2485 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
2486
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2487 if (!NILP (component))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2488 {
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2489 strcat (class_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2490 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
2491
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2492 strcat (name_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2493 strcat (name_key, XSTRING (component)->data);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2494 }
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2495
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2496 strcat (name_key, ".");
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
2497 strcat (name_key, XSTRING (attribute)->data);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2498
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
2499 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
2500 name_key, class_key);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2501
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2502 if (value != (char *) 0)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2503 return build_string (value);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2504 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2505 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2506 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2507
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2508 /* 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
2509
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2510 Lisp_Object
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2511 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
2512 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
2513 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
2514 {
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2515 register char *value;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2516 char *name_key;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2517 char *class_key;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2518
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2519 CHECK_STRING (attribute, 0);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2520 CHECK_STRING (class, 0);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2521
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2522 if (!NILP (component))
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2523 CHECK_STRING (component, 1);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2524 if (!NILP (subclass))
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2525 CHECK_STRING (subclass, 2);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2526 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
2527 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
2528
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2529 validate_x_resource_name ();
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2530
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2531 /* 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
2532 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
2533 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
2534 + (STRINGP (component)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2535 ? STRING_BYTES (XSTRING (component)) : 0)
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2536 + 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
2537 + 3);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2538
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2539 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
2540 + 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
2541 + (STRINGP (subclass)
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2542 ? 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
2543 + 3);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2544
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2545 /* 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
2546 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
2547 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
2548 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
2549
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2550 strcat (class_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2551 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
2552
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2553 if (!NILP (component))
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2554 {
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2555 strcat (class_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2556 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
2557
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2558 strcat (name_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2559 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
2560 }
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2561
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2562 strcat (name_key, ".");
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2563 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
2564
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2565 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
2566
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2567 if (value != (char *) 0)
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2568 return build_string (value);
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2569 else
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2570 return Qnil;
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2571 }
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2572
3173
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2573 /* 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
2574
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2575 char *
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2576 x_get_resource_string (attribute, class)
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2577 char *attribute, *class;
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2578 {
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2579 char *name_key;
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2580 char *class_key;
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
2581 struct frame *sf = SELECTED_FRAME ();
3173
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2582
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2583 /* 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
2584 and the final '\0'. */
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 20629
diff changeset
2585 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
2586 + strlen (attribute) + 2);
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2587 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
2588 + strlen (class) + 2);
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2589
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2590 sprintf (name_key, "%s.%s",
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2591 XSTRING (Vinvocation_name)->data,
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2592 attribute);
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2593 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
2594
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
2595 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
2596 name_key, class_key);
3173
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2597 }
c3c1b1ceab05 (x_get_resource_string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3170
diff changeset
2598
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2599 /* Types we might convert a resource string into. */
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2600 enum resource_types
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2601 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2602 RES_TYPE_NUMBER,
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2603 RES_TYPE_FLOAT,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2604 RES_TYPE_BOOLEAN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2605 RES_TYPE_STRING,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2606 RES_TYPE_SYMBOL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2607 };
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2608
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2609 /* Return the value of parameter PARAM.
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2610
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2611 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
2612 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
2613
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2614 Convert the resource to the type specified by desired_type.
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2615
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2616 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
2617 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
2618 and don't let it get stored in any Lisp-visible variables! */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2619
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2620 static Lisp_Object
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2621 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
2622 struct x_display_info *dpyinfo;
641
78a0b78aa6de *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 621
diff changeset
2623 Lisp_Object alist, param;
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2624 char *attribute;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2625 char *class;
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2626 enum resource_types type;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2627 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2628 register Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2629
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2630 tem = Fassq (param, alist);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2631 if (EQ (tem, Qnil))
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2632 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
2633 if (EQ (tem, Qnil))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2634 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2635
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2636 if (attribute)
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2637 {
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2638 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
2639 build_string (attribute),
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2640 build_string (class),
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2641 Qnil, Qnil);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2642
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2643 if (NILP (tem))
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2644 return Qunbound;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2645
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2646 switch (type)
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2647 {
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2648 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
2649 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
2650
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2651 case RES_TYPE_FLOAT:
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
2652 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
2653
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2654 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
2655 tem = Fdowncase (tem);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2656 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
2657 || !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
2658 return Qt;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2659 else
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2660 return Qnil;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2661
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2662 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
2663 return tem;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2664
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2665 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
2666 /* 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
2667 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
2668 {
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
2669 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
2670 lower = Fdowncase (tem);
6523
d9d9ab5951dd (x_get_arg): Use downcased string in compare.
Karl Heuer <kwzh@gnu.org>
parents: 6522
diff changeset
2671 if (!strcmp (XSTRING (lower)->data, "on")
d9d9ab5951dd (x_get_arg): Use downcased string in compare.
Karl Heuer <kwzh@gnu.org>
parents: 6522
diff changeset
2672 || !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
2673 return Qt;
6523
d9d9ab5951dd (x_get_arg): Use downcased string in compare.
Karl Heuer <kwzh@gnu.org>
parents: 6522
diff changeset
2674 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
2675 || !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
2676 return Qnil;
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
2677 else
2686
a84b9a78ab08 (x_get_arg): Call Fintern, not intern.
Richard M. Stallman <rms@gnu.org>
parents: 2439
diff changeset
2678 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
2679 }
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
2680
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2681 default:
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2682 abort ();
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2683 }
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2684 }
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2685 else
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2686 return Qunbound;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2687 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2688 return Fcdr (tem);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2689 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2690
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2691 /* 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
2692
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2693 static Lisp_Object
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2694 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
2695 struct frame *f;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2696 Lisp_Object alist, param;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2697 char *attribute;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2698 char *class;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2699 enum resource_types type;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2700 {
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2701 Lisp_Object value;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2702
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2703 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
2704 attribute, class, type);
16156
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2705 if (! NILP (value))
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2706 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
2707
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2708 return value;
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2709 }
d435199e529d (x_set_frame_parameters): Make height and width ints.
Richard M. Stallman <rms@gnu.org>
parents: 16041
diff changeset
2710
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2711 /* 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
2712 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
2713 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
2714 on the frame named NAME.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2715 If that is not found either, use the value DEFLT. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2716
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2717 static Lisp_Object
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2718 x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2719 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2720 Lisp_Object alist;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2721 Lisp_Object prop;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2722 Lisp_Object deflt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2723 char *xprop;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
2724 char *xclass;
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
2725 enum resource_types type;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2726 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727 Lisp_Object tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2728
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
2729 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
2730 if (EQ (tem, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2731 tem = deflt;
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2732 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2733 return tem;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2734 }
24994
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2737 /* 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
2738 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
2739 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
2740 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
2741
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2742 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2743 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
2744 foreground_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2745 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2746 Lisp_Object alist;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2747 Lisp_Object prop;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2748 char *xprop;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2749 char *xclass;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2750 int foreground_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2751 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2752 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
2753 Lisp_Object tem;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2754
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2755 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
2756 if (EQ (tem, Qunbound))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2757 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2758 #ifdef USE_TOOLKIT_SCROLL_BARS
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2759
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2760 /* 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
2761 specified. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2762 tem = display_x_get_resource (dpyinfo,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2763 build_string (foreground_p
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2764 ? "foreground"
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2765 : "background"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2766 build_string (""),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2767 build_string ("verticalScrollBar"),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2768 build_string (""));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2769 if (!STRINGP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2770 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2771 /* 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
2772 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
2773 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
2774 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
2775 specified. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2776 tem = Qnil;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2779 #else /* not USE_TOOLKIT_SCROLL_BARS */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2780
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2781 tem = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2782
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2783 #endif /* not USE_TOOLKIT_SCROLL_BARS */
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2786 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
2787 return tem;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2790
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2791
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
2792 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
2793 "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
2794 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
2795 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
2796 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
2797 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
2798 or a list (- N) meaning -N pixels relative to bottom/right corner.")
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2799 (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
2800 Lisp_Object string;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2802 int geometry, x, y;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2803 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
2804 Lisp_Object result;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2805
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806 CHECK_STRING (string, 0);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2808 geometry = XParseGeometry ((char *) XSTRING (string)->data,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809 &x, &y, &width, &height);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2810
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2811 #if 0
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2812 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
2813 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
2814 #endif
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2815
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2816 result = Qnil;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2817 if (geometry & XValue)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2818 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2819 Lisp_Object element;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2820
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2821 if (x >= 0 && (geometry & XNegative))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2822 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
2823 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
2824 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
2825 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2826 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
2827 result = Fcons (element, result);
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
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2830 if (geometry & YValue)
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2831 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2832 Lisp_Object element;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2833
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2834 if (y >= 0 && (geometry & YNegative))
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2835 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
2836 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
2837 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
2838 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2839 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
2840 result = Fcons (element, result);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2841 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2842
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2843 if (geometry & WidthValue)
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2844 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
2845 if (geometry & HeightValue)
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2846 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
2847
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2848 return result;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2849 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2850
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2851 /* 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
2852 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
2853
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
2854 This function does not make the coordinates positive. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2855
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2856 #define DEFAULT_ROWS 40
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2857 #define DEFAULT_COLS 80
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2858
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
2859 static int
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2860 x_figure_window_size (f, parms)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2861 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2862 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2863 {
7251
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2864 register Lisp_Object tem0, tem1, tem2;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2865 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
2866 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2867
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2868 /* Default values if we fall through.
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2869 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
2870 window manager prompting. */
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
2871 SET_FRAME_WIDTH (f, DEFAULT_COLS);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
2872 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
2873 /* 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
2874 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
2875 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
2876 f->output_data.x->left_pos = 0;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2877
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2878 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
2879 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
2880 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
2881 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2882 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2883 if (!EQ (tem0, Qunbound))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2884 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2885 CHECK_NUMBER (tem0, 0);
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2886 f->height = XINT (tem0);
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2887 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2888 if (!EQ (tem1, Qunbound))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2889 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2890 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
2891 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
2892 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2893 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
2894 window_prompting |= USSize;
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2895 else
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2896 window_prompting |= PSize;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2897 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2898
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2899 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
2900 = (!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
2901 ? 0
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2902 : (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
2903 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
2904 = 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
2905 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
2906 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
2907
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
2908 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
2909 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
2910 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
2911 if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2912 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2913 if (EQ (tem0, Qminus))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2914 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2915 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
2916 window_prompting |= YNegative;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2917 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2918 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
2919 && CONSP (XCDR (tem0))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2920 && INTEGERP (XCAR (XCDR (tem0))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2921 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2922 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
2923 window_prompting |= YNegative;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2924 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2925 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
2926 && CONSP (XCDR (tem0))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2927 && INTEGERP (XCAR (XCDR (tem0))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2928 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2929 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
2930 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2931 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
2932 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
2933 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2934 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2935 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
2936 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
2937 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
2938 window_prompting |= YNegative;
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
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2941 if (EQ (tem1, Qminus))
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2942 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
2943 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
2944 window_prompting |= XNegative;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2945 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2946 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
2947 && CONSP (XCDR (tem1))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2948 && INTEGERP (XCAR (XCDR (tem1))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2949 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2950 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
2951 window_prompting |= XNegative;
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2952 }
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2953 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
2954 && CONSP (XCDR (tem1))
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2955 && INTEGERP (XCAR (XCDR (tem1))))
9022
10fa443c671a (Fx_create_frame): Rename menuBarLines resource to menuBar.
Richard M. Stallman <rms@gnu.org>
parents: 9014
diff changeset
2956 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
2957 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
2958 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2959 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
2960 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
2961 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2962 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2963 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
2964 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
2965 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
2966 window_prompting |= XNegative;
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2967 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2968
10264
92dcc001aa20 (x_figure_window_size): Treat missing user-position parm as nil.
Richard M. Stallman <rms@gnu.org>
parents: 10222
diff changeset
2969 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
2970 window_prompting |= USPosition;
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2971 else
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
2972 window_prompting |= PPosition;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2973 }
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
2974
3293
03e4cad68481 (Fx_close_current_connection): Clear x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 3203
diff changeset
2975 return window_prompting;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2976 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2977
5229
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2978 #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2979
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2980 Status
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2981 XSetWMProtocols (dpy, w, protocols, count)
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2982 Display *dpy;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2983 Window w;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2984 Atom *protocols;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2985 int count;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2986 {
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2987 Atom prop;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2988 prop = XInternAtom (dpy, "WM_PROTOCOLS", False);
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2989 if (prop == None) return False;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2990 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
2991 (unsigned char *) protocols, count);
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2992 return True;
110539a25499 (Fx_list_fonts): Handle BROKEN_XLISTFONTSWITHINFO.
Richard M. Stallman <rms@gnu.org>
parents: 5193
diff changeset
2993 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2994 #endif /* not HAVE_X11R4 && not HAVE_XSETWMPROTOCOLS */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2995
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2996 #ifdef USE_X_TOOLKIT
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
2997
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
2998 /* 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
2999 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
3000 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
3001 for example, but Xt doesn't). */
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3002
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3003 static void
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3004 hack_wm_protocols (f, widget)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3005 FRAME_PTR f;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3006 Widget widget;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3007 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3008 Display *dpy = XtDisplay (widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3009 Window w = XtWindow (widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3010 int need_delete = 1;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3011 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
3012 int need_save = 1;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3013
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3014 BLOCK_INPUT;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3015 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3016 Atom type, *atoms = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3017 int format = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3018 unsigned long nitems = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3019 unsigned long bytes_after;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3020
11882
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3021 if ((XGetWindowProperty (dpy, w,
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3022 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
3023 (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
3024 &type, &format, &nitems, &bytes_after,
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3025 (unsigned char **) &atoms)
8b3575269610 (hack_wm_protocols): Cast args of XGetWindowProperty.
Karl Heuer <kwzh@gnu.org>
parents: 11774
diff changeset
3026 == Success)
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3027 && format == 32 && type == XA_ATOM)
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3028 while (nitems > 0)
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3029 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3030 nitems--;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3031 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
3032 need_delete = 0;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3033 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
3034 need_focus = 0;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3035 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
3036 need_save = 0;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3037 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3038 if (atoms) XFree ((char *) atoms);
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 {
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3041 Atom props [10];
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3042 int count = 0;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3043 if (need_delete)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3044 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
3045 if (need_focus)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3046 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
3047 if (need_save)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3048 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
3049 if (count)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3050 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
3051 XA_ATOM, 32, PropModeAppend,
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3052 (unsigned char *) props, count);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3053 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3054 UNBLOCK_INPUT;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3055 }
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3056 #endif
27157
3dafddaefc2c (x_create_im): New function to set IM and IC of a frame.
Gerd Moellmann <gerd@gnu.org>
parents: 27153
diff changeset
3057
3dafddaefc2c (x_create_im): New function to set IM and IC of a frame.
Gerd Moellmann <gerd@gnu.org>
parents: 27153
diff changeset
3058
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3059
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3060 /* Support routines for XIC (X Input Context). */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3061
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3062 #ifdef HAVE_X_I18N
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3063
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3064 static XFontSet xic_create_xfontset P_ ((struct frame *, char *));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3065 static XIMStyle best_xim_style P_ ((XIMStyles *, XIMStyles *));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3066
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3067
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3068 /* Supported XIM styles, ordered by preferenc. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3069
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3070 static XIMStyle supported_xim_styles[] =
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3071 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3072 XIMPreeditPosition | XIMStatusArea,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3073 XIMPreeditPosition | XIMStatusNothing,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3074 XIMPreeditPosition | XIMStatusNone,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3075 XIMPreeditNothing | XIMStatusArea,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3076 XIMPreeditNothing | XIMStatusNothing,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3077 XIMPreeditNothing | XIMStatusNone,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3078 XIMPreeditNone | XIMStatusArea,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3079 XIMPreeditNone | XIMStatusNothing,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3080 XIMPreeditNone | XIMStatusNone,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3081 0,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3082 };
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3083
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3084
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3085 /* Create an X fontset on frame F with base font name
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3086 BASE_FONTNAME.. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3087
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3088 static XFontSet
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3089 xic_create_xfontset (f, base_fontname)
27157
3dafddaefc2c (x_create_im): New function to set IM and IC of a frame.
Gerd Moellmann <gerd@gnu.org>
parents: 27153
diff changeset
3090 struct frame *f;
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3091 char *base_fontname;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3092 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3093 XFontSet xfs;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3094 char **missing_list;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3095 int missing_count;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3096 char *def_string;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3097
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3098 xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3099 base_fontname, &missing_list,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3100 &missing_count, &def_string);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3101 if (missing_list)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3102 XFreeStringList (missing_list);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3103
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3104 /* No need to free def_string. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3105 return xfs;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3106 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3107
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3108
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3109 /* Value is the best input style, given user preferences USER (already
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3110 checked to be supported by Emacs), and styles supported by the
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3111 input method XIM. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3112
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3113 static XIMStyle
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3114 best_xim_style (user, xim)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3115 XIMStyles *user;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3116 XIMStyles *xim;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3117 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3118 int i, j;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3119
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3120 for (i = 0; i < user->count_styles; ++i)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3121 for (j = 0; j < xim->count_styles; ++j)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3122 if (user->supported_styles[i] == xim->supported_styles[j])
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3123 return user->supported_styles[i];
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3124
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3125 /* Return the default style. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3126 return XIMPreeditNothing | XIMStatusNothing;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3127 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3128
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3129 /* Create XIC for frame F. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3130
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3131 void
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3132 create_frame_xic (f)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3133 struct frame *f;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3134 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3135 XIM xim;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3136 XIC xic = NULL;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3137 XFontSet xfs = NULL;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3138 static XIMStyle xic_style;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3139
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3140 if (FRAME_XIC (f))
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3141 return;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3142
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3143 xim = FRAME_X_XIM (f);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3144 if (xim)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3145 {
27659
4137c807296b (create_frame_xic): Fix initialization of automatic aggregates for pcc.
Dave Love <fx@gnu.org>
parents: 27502
diff changeset
3146 XRectangle s_area;
4137c807296b (create_frame_xic): Fix initialization of automatic aggregates for pcc.
Dave Love <fx@gnu.org>
parents: 27502
diff changeset
3147 XPoint spot;
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3148 XVaNestedList preedit_attr;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3149 XVaNestedList status_attr;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3150 char *base_fontname;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3151 int fontset;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3152
27659
4137c807296b (create_frame_xic): Fix initialization of automatic aggregates for pcc.
Dave Love <fx@gnu.org>
parents: 27502
diff changeset
3153 s_area.x = 0; s_area.y = 0; s_area.width = 1; s_area.height = 1;
4137c807296b (create_frame_xic): Fix initialization of automatic aggregates for pcc.
Dave Love <fx@gnu.org>
parents: 27502
diff changeset
3154 spot.x = 0; spot.y = 1;
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3155 /* Create X fontset. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3156 fontset = FRAME_FONTSET (f);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3157 if (fontset < 0)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3158 base_fontname = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3159 else
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3160 {
28229
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3161 /* Determine the base fontname from the ASCII font name of
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3162 FONTSET. */
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3163 char *ascii_font = (char *) XSTRING (fontset_ascii (fontset))->data;
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3164 char *p = ascii_font;
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3165 int i;
28229
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3166
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3167 for (i = 0; *p; p++)
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3168 if (*p == '-') i++;
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3169 if (i != 14)
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3170 /* As the font name doesn't conform to XLFD, we can't
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3171 modify it to get a suitable base fontname for the
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3172 frame. */
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3173 base_fontname = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3174 else
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3175 {
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3176 int len = strlen (ascii_font) + 1;
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3177 char *p1;
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3178
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3179 for (i = 0, p = ascii_font; i < 8; p++)
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3180 {
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3181 if (*p == '-')
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3182 {
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3183 i++;
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3184 if (i == 3)
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3185 p1 = p + 1;
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3186 }
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3187 }
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3188 base_fontname = (char *) alloca (len);
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3189 bzero (base_fontname, len);
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3190 strcpy (base_fontname, "-*-*-");
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3191 bcopy (p1, base_fontname + 5, p - p1);
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3192 strcat (base_fontname, "*-*-*-*-*-*-*");
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
3193 }
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3194 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3195 xfs = xic_create_xfontset (f, base_fontname);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3196
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3197 /* Determine XIC style. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3198 if (xic_style == 0)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3199 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3200 XIMStyles supported_list;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3201 supported_list.count_styles = (sizeof supported_xim_styles
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3202 / sizeof supported_xim_styles[0]);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3203 supported_list.supported_styles = supported_xim_styles;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3204 xic_style = best_xim_style (&supported_list,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3205 FRAME_X_XIM_STYLES (f));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3206 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3207
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3208 preedit_attr = XVaCreateNestedList (0,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3209 XNFontSet, xfs,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3210 XNForeground,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3211 FRAME_FOREGROUND_PIXEL (f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3212 XNBackground,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3213 FRAME_BACKGROUND_PIXEL (f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3214 (xic_style & XIMPreeditPosition
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3215 ? XNSpotLocation
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3216 : NULL),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3217 &spot,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3218 NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3219 status_attr = XVaCreateNestedList (0,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3220 XNArea,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3221 &s_area,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3222 XNFontSet,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3223 xfs,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3224 XNForeground,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3225 FRAME_FOREGROUND_PIXEL (f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3226 XNBackground,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3227 FRAME_BACKGROUND_PIXEL (f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3228 NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3229
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3230 xic = XCreateIC (xim,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3231 XNInputStyle, xic_style,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3232 XNClientWindow, FRAME_X_WINDOW(f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3233 XNFocusWindow, FRAME_X_WINDOW(f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3234 XNStatusAttributes, status_attr,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3235 XNPreeditAttributes, preedit_attr,
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3236 NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3237 XFree (preedit_attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3238 XFree (status_attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3239 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3240
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3241 FRAME_XIC (f) = xic;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3242 FRAME_XIC_STYLE (f) = xic_style;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3243 FRAME_XIC_FONTSET (f) = xfs;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3244 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3245
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3246
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3247 /* Destroy XIC and free XIC fontset of frame F, if any. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3248
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3249 void
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3250 free_frame_xic (f)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3251 struct frame *f;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3252 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3253 if (FRAME_XIC (f) == NULL)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3254 return;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3255
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3256 XDestroyIC (FRAME_XIC (f));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3257 if (FRAME_XIC_FONTSET (f))
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3258 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3259
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3260 FRAME_XIC (f) = NULL;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3261 FRAME_XIC_FONTSET (f) = NULL;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3262 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3263
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3264
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3265 /* Place preedit area for XIC of window W's frame to specified
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3266 pixel position X/Y. X and Y are relative to window W. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3267
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3268 void
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3269 xic_set_preeditarea (w, x, y)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3270 struct window *w;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3271 int x, y;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3272 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3273 struct frame *f = XFRAME (w->frame);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3274 XVaNestedList attr;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3275 XPoint spot;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3276
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3277 spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3278 spot.y = WINDOW_TO_FRAME_PIXEL_Y (w, y) + FONT_BASE (FRAME_FONT (f));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3279 attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3280 XSetICValues (FRAME_XIC (f), XNPreeditAttributes, attr, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3281 XFree (attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3282 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3283
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3284
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3285 /* Place status area for XIC in bottom right corner of frame F.. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3286
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3287 void
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3288 xic_set_statusarea (f)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3289 struct frame *f;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3290 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3291 XIC xic = FRAME_XIC (f);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3292 XVaNestedList attr;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3293 XRectangle area;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3294 XRectangle *needed;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3295
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3296 /* Negotiate geometry of status area. If input method has existing
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3297 status area, use its current size. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3298 area.x = area.y = area.width = area.height = 0;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3299 attr = XVaCreateNestedList (0, XNAreaNeeded, &area, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3300 XSetICValues (xic, XNStatusAttributes, attr, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3301 XFree (attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3302
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3303 attr = XVaCreateNestedList (0, XNAreaNeeded, &needed, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3304 XGetICValues (xic, XNStatusAttributes, attr, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3305 XFree (attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3306
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3307 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3308 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3309 attr = XVaCreateNestedList (0, XNArea, &needed, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3310 XGetICValues (xic, XNStatusAttributes, attr, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3311 XFree (attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3312 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3313
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3314 area.width = needed->width;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3315 area.height = needed->height;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3316 area.x = PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3317 area.y = (PIXEL_HEIGHT (f) - area.height
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3318 - FRAME_MENUBAR_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3319 XFree (needed);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3320
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3321 attr = XVaCreateNestedList (0, XNArea, &area, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3322 XSetICValues(xic, XNStatusAttributes, attr, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3323 XFree (attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3324 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3325
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3326
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3327 /* Set X fontset for XIC of frame F, using base font name
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3328 BASE_FONTNAME. Called when a new Emacs fontset is chosen. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3329
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3330 void
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3331 xic_set_xfontset (f, base_fontname)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3332 struct frame *f;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3333 char *base_fontname;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3334 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3335 XVaNestedList attr;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3336 XFontSet xfs;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3337
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3338 xfs = xic_create_xfontset (f, base_fontname);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3339
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3340 attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3341 if (FRAME_XIC_STYLE (f) & XIMPreeditPosition)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3342 XSetICValues (FRAME_XIC (f), XNPreeditAttributes, attr, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3343 if (FRAME_XIC_STYLE (f) & XIMStatusArea)
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3344 XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3345 XFree (attr);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3346
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3347 if (FRAME_XIC_FONTSET (f))
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3348 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3349 FRAME_XIC_FONTSET (f) = xfs;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3350 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3351
27157
3dafddaefc2c (x_create_im): New function to set IM and IC of a frame.
Gerd Moellmann <gerd@gnu.org>
parents: 27153
diff changeset
3352 #endif /* HAVE_X_I18N */
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3353
27157
3dafddaefc2c (x_create_im): New function to set IM and IC of a frame.
Gerd Moellmann <gerd@gnu.org>
parents: 27153
diff changeset
3354
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3355
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3356 #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
3357
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3358 /* 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
3359
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3360 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
3361 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
3362 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
3363 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
3364 int minibuffer_only;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3365 {
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3366 XClassHint class_hints;
6059
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3367 XSetWindowAttributes attributes;
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3368 unsigned long attribute_mask;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3369 Widget shell_widget;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3370 Widget pane_widget;
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3371 Widget frame_widget;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3372 Arg al [25];
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3373 int ac;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3374
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3375 BLOCK_INPUT;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3376
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3377 /* 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
3378 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
3379 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
3380
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3381 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
3382
11496
db02849ee365 (x_window): Use (or reuse) frame's namebuf instead of a
Karl Heuer <kwzh@gnu.org>
parents: 11483
diff changeset
3383 {
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3384 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
3385 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
3386 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
3387 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3388
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3389 ac = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3390 XtSetArg (al[ac], XtNallowShellResize, 1); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3391 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
3392 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
3393 XtSetArg (al[ac], XtNborderWidth, f->output_data.x->border_width); ac++;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3394 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3395 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3396 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
11496
db02849ee365 (x_window): Use (or reuse) frame's namebuf instead of a
Karl Heuer <kwzh@gnu.org>
parents: 11483
diff changeset
3397 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
3398 applicationShellWidgetClass,
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
3399 FRAME_X_DISPLAY (f), al, ac);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3400
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3401 f->output_data.x->widget = shell_widget;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3402 /* maybe_set_screen_title_format (shell_widget); */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3403
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3404 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
3405 (widget_value *) NULL,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3406 shell_widget, False,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3407 (lw_callback) NULL,
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3408 (lw_callback) NULL,
27343
43230463dfcf (x_window): Call lw_create_widget with new parameter
Gerd Moellmann <gerd@gnu.org>
parents: 27157
diff changeset
3409 (lw_callback) NULL,
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3410 (lw_callback) NULL);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3411
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3412 ac = 0;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3413 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3414 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3415 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3416 XtSetValues (pane_widget, al, ac);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3417 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
3418
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3419 /* 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
3420 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
3421
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3422 ac = 0;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3423 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3424 XtSetArg (al[ac], XtNshowGrip, 0); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3425 XtSetArg (al[ac], XtNallowResize, 1); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3426 XtSetArg (al[ac], XtNresizeToPreferred, 1); ac++;
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3427 XtSetArg (al[ac], XtNemacsFrame, f); ac++;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3428 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3429 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3430 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3431 frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget,
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3432 al, ac);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3433
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3434 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
3435
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3436 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
3437
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3438 /* 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
3439 {
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3440 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
3441 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
3442 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
3443 int ac = 0;
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3444 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
3445 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
3446 = (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
3447 ? (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
3448 + 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
3449 : 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
3450
15942
ff30ec8aab54 (x_window): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15891
diff changeset
3451 #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
3452 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
3453 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
3454 {
9808
4c43c9dbe130 (x_window): Make ibw 0 by default.
Richard M. Stallman <rms@gnu.org>
parents: 9742
diff changeset
3455 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
3456 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
3457 menubar_size += ibw;
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3458 }
15942
ff30ec8aab54 (x_window): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15891
diff changeset
3459 #endif
7969
7f15f77cb644 (x_window): Take account of pane widget internal border width.
Richard M. Stallman <rms@gnu.org>
parents: 7946
diff changeset
3460
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3461 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
3462
16305
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3463 #ifndef USE_LUCID
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3464 /* 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
3465 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
3466 Both conclusions reached experimentally. -- rms. */
16305
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3467 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
3468 &extra_borders, NULL);
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3469 extra_borders *= 2;
00e57c8adaba (x_window): With Motif, double extra_borders.
Richard M. Stallman <rms@gnu.org>
parents: 16302
diff changeset
3470 #endif
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3471
11707
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3472 /* 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
3473 and specify it.
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3474 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
3475 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
3476 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
3477 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3478 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
3479 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
3480 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
3481 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
3482 if (xneg)
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3483 left = -left;
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3484 if (yneg)
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3485 top = -top;
11893
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3486
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3487 if (window_prompting & USPosition)
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3488 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
3489 PIXEL_WIDTH (f) + extra_borders,
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3490 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
3491 (xneg ? '-' : '+'), left,
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3492 (yneg ? '-' : '+'), top);
1f70ffad3d6d [USE_X_TOOLKIT] (x_window): Pass position to toolkit
Karl Heuer <kwzh@gnu.org>
parents: 11882
diff changeset
3493 else
12190
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3494 sprintf (shell_position, "=%dx%d",
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3495 PIXEL_WIDTH (f) + extra_borders,
e0abe30899a9 [USE_X_TOOLKIT] (x_window): If using Motif,
Karl Heuer <kwzh@gnu.org>
parents: 12111
diff changeset
3496 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
3497 }
b0cb8129be58 [USE_X_TOOLKIT] (x_window): Always pass position in geometry.
Richard M. Stallman <rms@gnu.org>
parents: 11611
diff changeset
3498
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
3499 len = strlen (shell_position) + 1;
17579
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3500 /* We don't free this because we don't know whether
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3501 it is safe to free it while the frame exists.
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3502 It isn't worth the trouble of arranging to free it
8dd146dbe737 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17556
diff changeset
3503 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
3504 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
3505 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
3506 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
3507 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
3508 }
bb11213734d6 (x_window) [USE_X_TOOLKIT]: New args window_prompting and minibuffer_only.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6523
diff changeset
3509
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3510 XtManageChild (pane_widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3511 XtRealizeWidget (shell_widget);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3512
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3513 FRAME_X_WINDOW (f) = XtWindow (frame_widget);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3514
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3515 validate_x_resource_name ();
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3516
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3517 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
3518 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
3519 XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3520
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3521 #ifdef HAVE_X_I18N
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3522 FRAME_XIC (f) = NULL;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3523 create_frame_xic (f);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3524 #endif
13227
d8af44485b3c (x_window, both versions): Add HAVE_X_I18N support.
Richard M. Stallman <rms@gnu.org>
parents: 13083
diff changeset
3525
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3526 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
3527 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
3528 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
3529 &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
3530
9703
85ac0e4030d4 (x_window): Pass new arg f to hack_wm_protocols.
Richard M. Stallman <rms@gnu.org>
parents: 9690
diff changeset
3531 hack_wm_protocols (f, shell_widget);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3532
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3533 #ifdef HACK_EDITRES
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3534 XtAddEventHandler (shell_widget, 0, True, _XEditResCheckMessages, 0);
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3535 #endif
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3536
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3537 /* 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
3538 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
3539 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
3540 */
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3541 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
3542 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
3543 XA_ATOM, 32, PropModeAppend,
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3544 (unsigned char*) NULL, 0);
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3545
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3546 /* Make all the standard events reach the Emacs frame. */
6059
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3547 attributes.event_mask = STANDARD_EVENT_SET;
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3548
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3549 #ifdef HAVE_X_I18N
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3550 if (FRAME_XIC (f))
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3551 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3552 /* XIM server might require some X events. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3553 unsigned long fevent = NoEventMask;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3554 XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3555 attributes.event_mask |= fevent;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3556 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3557 #endif /* HAVE_X_I18N */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3558
6059
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3559 attribute_mask = CWEventMask;
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3560 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
3561 attribute_mask, &attributes);
0021cbdc591b (x_window): Call XChangeWindowAttributes with the standard
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6011
diff changeset
3562
9231
eeb35369e536 (HACK_EDITRES): Declare if using X11R5.
Paul Reilly <pmr@pajato.com>
parents: 9182
diff changeset
3563 XtMapWidget (frame_widget);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3564
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3565 /* 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
3566 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
3567 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
3568 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
3569 {
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3570 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
3571 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
3572
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3573 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
3574 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
3575 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
3576 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
3577 }
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3578
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3579 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
3580 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
3581
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3582 UNBLOCK_INPUT;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3583
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
3584 /* 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
3585 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
3586 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
3587 }
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3588
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3589 #else /* not USE_X_TOOLKIT */
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3590
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3591 /* 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
3592
21846
486ac68ce051 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21779
diff changeset
3593 void
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3594 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
3595 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
3596
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3597 {
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3598 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
3599 XSetWindowAttributes attributes;
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3600 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
3601
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3602 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
3603 attributes.border_pixel = f->output_data.x->border_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3604 attributes.bit_gravity = StaticGravity;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3605 attributes.backing_store = NotUseful;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3606 attributes.save_under = True;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3607 attributes.event_mask = STANDARD_EVENT_SET;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3608 attributes.colormap = FRAME_X_COLORMAP (f);
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3609 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3610 | CWColormap);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3611
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3612 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
3613 FRAME_X_WINDOW (f)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3614 = 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
3615 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
3616 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
3617 f->output_data.x->top_pos,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3618 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
3619 f->output_data.x->border_width,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3620 CopyFromParent, /* depth */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3621 InputOutput, /* class */
28144
71ebba3566ec (X_I18N_INHIBITED): Don't define.
Gerd Moellmann <gerd@gnu.org>
parents: 28096
diff changeset
3622 FRAME_X_VISUAL (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3623 attribute_mask, &attributes);
27502
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3624
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3625 #ifdef HAVE_X_I18N
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3626 create_frame_xic (f);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3627 if (FRAME_XIC (f))
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3628 {
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3629 /* XIM server might require some X events. */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3630 unsigned long fevent = NoEventMask;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3631 XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3632 attributes.event_mask |= fevent;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3633 attribute_mask = CWEventMask;
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3634 XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3635 attribute_mask, &attributes);
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3636 }
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3637 #endif /* HAVE_X_I18N */
52e8cb1333f2 (xic_set_preeditarea): Take window parameter and
Gerd Moellmann <gerd@gnu.org>
parents: 27343
diff changeset
3638
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3639 validate_x_resource_name ();
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3640
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3641 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
3642 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
3643 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
3644
11897
cbd3724a9696 (x_window) [both versions]: Set menubar_height.
Karl Heuer <kwzh@gnu.org>
parents: 11894
diff changeset
3645 /* 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
3646 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
3647 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
3648
1719
48f539ac6921 * frame.h (struct frame): New fields `can_have_scrollbars' and
Jim Blandy <jimb@redhat.com>
parents: 1657
diff changeset
3649 /* 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
3650 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
3651 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
3652 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
3653
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3654 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
3655 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
3656 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
3657 &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
3658 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
3659
26a1d7b2670b (x_window): Request "save yourself" commands.
Richard M. Stallman <rms@gnu.org>
parents: 7802
diff changeset
3660 /* 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
3661 {
26a1d7b2670b (x_window): Request "save yourself" commands.
Richard M. Stallman <rms@gnu.org>
parents: 7802
diff changeset
3662 Atom protocols[2];
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3663 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
3664 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
3665 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
3666 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3667
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3668 /* 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
3669 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
3670 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
3671 the X server hasn't been told. */
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3672 {
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
3673 Lisp_Object name;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3674 int explicit = f->explicit_name;
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3675
6519
22c56514eeb3 (x_set_frame_parameters, x_get_arg, x_window, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 6506
diff changeset
3676 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
3677 name = f->name;
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3678 f->name = Qnil;
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3679 x_set_name (f, name, explicit);
817
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3680 }
1dd126823b36 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 771
diff changeset
3681
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3682 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
3683 f->output_data.x->text_cursor);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3684
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3685 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3686
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
3687 if (FRAME_X_WINDOW (f) == 0)
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3688 error ("Unable to create window");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3689 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3690
6790
ee8090b47ea6 (x_figure_window_size): Don't call x_calc_absolute_position.
Richard M. Stallman <rms@gnu.org>
parents: 6783
diff changeset
3691 #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
3692
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3693 /* Handle the icon stuff for this window. Perhaps later we might
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3694 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
3695 well. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3696
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3697 static void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3698 x_icon (f, parms)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3699 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3700 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3701 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3702 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
3703 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3704
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3705 /* 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
3706 icons in an icon window. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3707 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
3708 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
3709 if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3710 {
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3711 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
3712 CHECK_NUMBER (icon_y, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3713 }
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3714 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3715 error ("Both left and top icon corners of icon must be specified");
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3716
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3717 BLOCK_INPUT;
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3718
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
3719 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
3720 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
3721
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3722 /* 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
3723 x_wm_set_window_state
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3724 (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
3725 Qicon)
2294
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
3726 ? IconicState
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
3727 : NormalState));
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3728
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3729 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
3730 ? 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
3731 : f->name))->data);
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
3732
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3733 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3734 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3735
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3736 /* Make the GC's needed for this window, setting the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3737 background, border and mouse colors; also create the
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3738 mouse cursor and the gray border tile. */
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3739
1018
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3740 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
3741 {
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3742 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
3743 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
3744 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
3745 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
3746 };
5fd29acd3db7 * xfns.c (x_set_name): Take new argument EXPLICIT, instead of
Jim Blandy <jimb@redhat.com>
parents: 974
diff changeset
3747
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3748 static void
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3749 x_make_gc (f)
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3750 struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3751 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3752 XGCValues gc_values;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3753
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
3754 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
3755
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3756 /* Create the GC's of this frame.
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3757 Note that many default values are used. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3758
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3759 /* 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
3760 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
3761 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
3762 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
3763 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
3764 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
3765 FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3766 GCLineWidth | GCFont
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3767 | GCForeground | GCBackground,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3768 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3769
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3770 /* 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
3771 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
3772 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
3773 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
3774 FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3775 GCFont | GCForeground | GCBackground
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3776 | GCLineWidth,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3777 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3778
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3779 /* 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
3780 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
3781 gc_values.background = f->output_data.x->cursor_pixel;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3782 gc_values.fill_style = FillOpaqueStippled;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3783 gc_values.stipple
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3784 = XCreateBitmapFromData (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3785 FRAME_X_DISPLAY_INFO (f)->root_window,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3786 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
3787 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
3788 = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3789 (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
3790 | GCFillStyle /* | GCStipple */ | GCLineWidth),
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3791 &gc_values);
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3792
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3793 /* Reliefs. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3794 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
3795 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
3796
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3797 /* 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
3798 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
3799 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
3800 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
3801 = (XCreatePixmapFromBitmapData
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3802 (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
3803 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
3804 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
3805 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
3806 DefaultDepth (FRAME_X_DISPLAY (f),
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3807 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
3808
1982e2983822 * xfns.c (x_make_gc): Don't forget to block X input around the
Jim Blandy <jimb@redhat.com>
parents: 2328
diff changeset
3809 UNBLOCK_INPUT;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3810 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3811
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3812 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3813 1, 1, 0,
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3814 "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
3815 Returns an Emacs frame object.\n\
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3816 ALIST is an alist of frame parameters.\n\
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3817 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
3818 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
3819 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
3820 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
3821 \n\
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3822 This function is an internal primitive--use `make-frame' instead.")
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3823 (parms)
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3824 Lisp_Object parms;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3825 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3826 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
3827 Lisp_Object frame, tem;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3828 Lisp_Object name;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3829 int minibuffer_only = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3830 long window_prompting = 0;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3831 int width, height;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3832 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
3833 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
3834 Lisp_Object display;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3835 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
3836 Lisp_Object parent;
11774
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3837 struct kboard *kb;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3838
2999
33c820044087 (check_x): New function.
Richard M. Stallman <rms@gnu.org>
parents: 2964
diff changeset
3839 check_x ();
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3840
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3841 /* 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
3842 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
3843 Vx_resource_name = Vinvocation_name;
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3844
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3845 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
3846 if (EQ (display, Qunbound))
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3847 display = Qnil;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3848 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
3849 #ifdef MULTI_KBOARD
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3850 kb = dpyinfo->kboard;
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3851 #else
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3852 kb = &the_only_kboard;
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3853 #endif
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
3854
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3855 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
3856 if (!STRINGP (name)
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3857 && ! EQ (name, Qunbound)
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3858 && ! NILP (name))
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3859 error ("Invalid frame name--not a string or nil");
398
a60eafebd43f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 389
diff changeset
3860
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3861 if (STRINGP (name))
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3862 Vx_resource_name = name;
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
3863
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3864 /* 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
3865 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
3866 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
3867 parent = Qnil;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3868 if (! NILP (parent))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3869 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
3870
15566
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3871 /* 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
3872 /* 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
3873 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
3874 frame = Qnil;
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3875 GCPRO4 (parms, parent, name, frame);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3876 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
3877 RES_TYPE_SYMBOL);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
3878 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
3879 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
3880 else if (EQ (tem, Qonly))
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3881 {
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3882 f = make_minibuffer_frame ();
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3883 minibuffer_only = 1;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3884 }
9103
948e8acb6990 (x_set_frame_parameters, x_set_menu_bar_lines, Fx_create_frame,
Karl Heuer <kwzh@gnu.org>
parents: 9022
diff changeset
3885 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
3886 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
3887 else
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3888 f = make_frame (1);
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3889
15566
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3890 XSETFRAME (frame, f);
3d03a3fb8757 (Fx_create_frame): Gcpro parms, parent, and name.
Richard M. Stallman <rms@gnu.org>
parents: 15495
diff changeset
3891
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
3892 /* 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
3893 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
3894
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3895 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
3896 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
3897 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
3898 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
3899 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
3900 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
3901 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
3902
12276
2e376a4397bc (x_report_frame_params, x_set_icon_type, x_set_icon_name)
Richard M. Stallman <rms@gnu.org>
parents: 12209
diff changeset
3903 f->icon_name
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3904 = 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
3905 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
3906 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
3907 f->icon_name = Qnil;
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
3908
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3909 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
3910 #ifdef MULTI_KBOARD
11774
0b5cb5170084 (Fx_create_frame): Pass kb to make_frame_without_minibuffer.
Karl Heuer <kwzh@gnu.org>
parents: 11772
diff changeset
3911 FRAME_KBOARD (f) = kb;
11014
634a98104921 (Fx_create_frame): set the frame's kboard member.
Karl Heuer <kwzh@gnu.org>
parents: 10920
diff changeset
3912 #endif
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3913
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3914 /* These colors will be set anyway later, but it's important
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3915 to get the color reference counts right, so initialize them! */
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3916 {
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3917 Lisp_Object black;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3918 struct gcpro gcpro1;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3919
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3920 black = build_string ("black");
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3921 GCPRO1 (black);
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3922 f->output_data.x->foreground_pixel
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3923 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3924 f->output_data.x->background_pixel
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3925 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3926 f->output_data.x->cursor_pixel
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3927 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3928 f->output_data.x->cursor_foreground_pixel
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3929 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3930 f->output_data.x->border_pixel
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3931 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3932 f->output_data.x->mouse_pixel
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3933 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3934 UNGCPRO;
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3935 }
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
3936
10222
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3937 /* 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
3938
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3939 if (!NILP (parent))
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3940 {
18612
88efccff8970 Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18594
diff changeset
3941 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
3942 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
3943 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3944 else
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3945 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
3946 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
3947 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
3948 }
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
3949
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3950 /* 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
3951 be set. */
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3952 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
3953 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
3954 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
3955 f->explicit_name = 0;
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3956 }
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3957 else
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3958 {
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3959 f->name = name;
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
3960 f->explicit_name = 1;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
3961 /* 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
3962 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
3963 }
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3964
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3965 /* Extract the window parameters from the supplied values
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3966 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
3967 {
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3968 Lisp_Object font;
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
3969
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3970 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
3971
4150
e2e92cd737bf * xfns.c (Fx_create_frame): Block input around call to
Jim Blandy <jimb@redhat.com>
parents: 4146
diff changeset
3972 BLOCK_INPUT;
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3973 /* 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
3974 if (STRINGP (font))
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3975 {
21555
0927f341e390 (x_set_font): Give 2nd arg nil to Fquery_fontset.
Kenichi Handa <handa@m17n.org>
parents: 21549
diff changeset
3976 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
3977 if (STRINGP (tem))
27df69e20b98 (Fx_create_frame): Delete code for handling the X
Kenichi Handa <handa@m17n.org>
parents: 17629
diff changeset
3978 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
3979 else
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3980 font = x_new_font (f, XSTRING (font)->data);
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
3981 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3982
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3983 /* 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
3984 if (!STRINGP (font))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
3985 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
3986 if (!STRINGP (font))
8270
1a0af0f4fb1d (Fx_create_frame): Use 140 as default font size.
Richard M. Stallman <rms@gnu.org>
parents: 8192
diff changeset
3987 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
3988 if (! STRINGP (font))
8270
1a0af0f4fb1d (Fx_create_frame): Use 140 as default font size.
Richard M. Stallman <rms@gnu.org>
parents: 8192
diff changeset
3989 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
3990 if (! STRINGP (font))
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3991 /* 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
3992 and takes too long. */
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3993 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
3994 /* 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
3995 if (! STRINGP (font))
8270
1a0af0f4fb1d (Fx_create_frame): Use 140 as default font size.
Richard M. Stallman <rms@gnu.org>
parents: 8192
diff changeset
3996 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
3997 UNBLOCK_INPUT;
e2e92cd737bf * xfns.c (Fx_create_frame): Block input around call to
Jim Blandy <jimb@redhat.com>
parents: 4146
diff changeset
3998 if (! STRINGP (font))
4259
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
3999 font = build_string ("fixed");
085095792d99 (Fx_create_frame): Don't look for default font
Richard M. Stallman <rms@gnu.org>
parents: 4195
diff changeset
4000
17722
27df69e20b98 (Fx_create_frame): Delete code for handling the X
Kenichi Handa <handa@m17n.org>
parents: 17629
diff changeset
4001 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
4002 "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
4003 }
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
4004
15720
f1549b7501af (Fx_create_frame): Do xlwmenu hack only if USE_LUCID.
Karl Heuer <kwzh@gnu.org>
parents: 15706
diff changeset
4005 #ifdef USE_LUCID
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
4006 /* 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
4007 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
4008 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
4009 #endif
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
4010
1786
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
4011 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
4012 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4013
3923
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
4014 /* 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
4015 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
4016 it). */
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
4017 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
4018 {
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
4019 Lisp_Object value;
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
4020
17779
094e5efd262d (Fx_create_frame): Get X resources from the display
Richard M. Stallman <rms@gnu.org>
parents: 17722
diff changeset
4021 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
4022 "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
4023 if (! EQ (value, Qunbound))
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
4024 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
4025 parms);
cb16ebff1c44 * xfns.c (Fx_create_frame): Check for internalBorder resource, as
Jim Blandy <jimb@redhat.com>
parents: 3888
diff changeset
4026 }
16302
025b3dc7a6ba (Fx_create_frame): Default Qinternal_border_width to 1.
Richard M. Stallman <rms@gnu.org>
parents: 16254
diff changeset
4027 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
4028 "internalBorderWidth", "internalBorderWidth",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4029 RES_TYPE_NUMBER);
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
4030 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
4031 "verticalScrollBars", "ScrollBars",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4032 RES_TYPE_SYMBOL);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4033
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4034 /* 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
4035 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
4036 "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
4037 x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
26808
d8a6c42deb4e Indentation fixes.
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
4038 "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
4039 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
4040 "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
4041 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
4042 "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
4043 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
4044 "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
4045 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
4046 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
28690
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
4047 x_default_parameter (f, parms, Qline_spacing, Qnil,
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
4048 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4049
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4050 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
4051 "scrollBarForeground",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4052 "ScrollBarForeground", 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4053 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
4054 "scrollBarBackground",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4055 "ScrollBarBackground", 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4056
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4057 /* 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
4058 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
4059 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
4060 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
4061 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
4062 happen. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4063 init_frame_faces (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4064
8758
fac1c4722677 (Fx_create_frame): Make 1 the default for menu-bar-lines.
Richard M. Stallman <rms@gnu.org>
parents: 8675
diff changeset
4065 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
4066 "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
4067 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
4068 "toolBar", "ToolBar", RES_TYPE_NUMBER);
13083
16638ebb209f (Fx_create_frame): Set up buffer-predicate slot.
Richard M. Stallman <rms@gnu.org>
parents: 12832
diff changeset
4069 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
4070 "bufferPredicate", "BufferPredicate",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4071 RES_TYPE_SYMBOL);
14381
4d038c841cf4 (Qtitle): Declared.
Richard M. Stallman <rms@gnu.org>
parents: 14186
diff changeset
4072 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
4073 "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
4074
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4075 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
4076 window_prompting = x_figure_window_size (f, parms);
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4077
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
4078 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
4079 {
7261
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
4080 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
4081 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
4082 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4083 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
4084 }
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
4085 else
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
4086 {
a752899939f7 (x_figure_window_size): Handle `-' for top or left.
Richard M. Stallman <rms@gnu.org>
parents: 7251
diff changeset
4087 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
4088 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
4089 else
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4090 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
4091 }
675e4ec5f14f (Fx_create_frame): Delete excess args to x_wm_set_size_hint.
Richard M. Stallman <rms@gnu.org>
parents: 6882
diff changeset
4092
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4093 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
4094
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4095 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
4096 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
4097
25544
693ca9ba497a Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents: 25528
diff changeset
4098 /* 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
4099 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
4100 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
4101 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
4102 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
4103 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
4104 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
4105
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
4106 #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
4107 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
4108 #else
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4109 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
4110 #endif
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4111
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4112 x_icon (f, parms);
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4113 x_make_gc (f);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4114
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4115 /* Now consider the frame official. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4116 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
4117 Vframe_list = Fcons (frame, Vframe_list);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4118
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
4119 /* 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
4120 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
4121 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
4122 "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
4123
5179baee010b * xfns.c (Fx_create_frame): After mapping the frame, call
Jim Blandy <jimb@redhat.com>
parents: 1733
diff changeset
4124 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
4125 "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
4126 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
4127 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
4128 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
4129 "cursorType", "CursorType", RES_TYPE_SYMBOL);
26978
06f887a1c834 (Fx_create_frame): Move x_default_parameter calls that
Gerd Moellmann <gerd@gnu.org>
parents: 26954
diff changeset
4130 x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
06f887a1c834 (Fx_create_frame): Move x_default_parameter calls that
Gerd Moellmann <gerd@gnu.org>
parents: 26954
diff changeset
4131 "scrollBarWidth", "ScrollBarWidth",
06f887a1c834 (Fx_create_frame): Move x_default_parameter calls that
Gerd Moellmann <gerd@gnu.org>
parents: 26954
diff changeset
4132 RES_TYPE_NUMBER);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
4133
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4134 /* Dimensions, especially f->height, must be done via change_frame_size.
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4135 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
4136 f->height. */
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4137 width = f->width;
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4138 height = f->height;
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
4139 f->height = 0;
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
4140 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
4141 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
4142
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4143 /* 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
4144 call1 (Qface_set_after_frame_default, frame);
25593
9aecfcf3cb43 (x_set_foreground_color): Call
Gerd Moellmann <gerd@gnu.org>
parents: 25550
diff changeset
4145
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4146 #ifdef USE_X_TOOLKIT
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4147 /* Create the menu bar. */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4148 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
4149 {
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4150 /* 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
4151 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
4152 initialize_frame_menubar (f);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4153
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4154 /* 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
4155 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
4156 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
4157 f->output_data.x->menubar_widget,
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4158 f->output_data.x->edit_widget);
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4159 }
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4160 #endif /* USE_X_TOOLKIT */
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4161
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4162 /* 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
4163 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
4164 bar so that its size can be taken into account. */
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4165 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
4166 x_wm_set_size_hint (f, window_prompting, 0);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4167 UNBLOCK_INPUT;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4168
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4169 /* 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
4170 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
4171 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
4172 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
4173 {
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
4174 Lisp_Object visibility;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
4175
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4176 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
4177 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
4178 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
4179 visibility = Qt;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
4180
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
4181 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
4182 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
4183 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
4184 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
4185 else
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
4186 /* 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
4187 ;
617bee0c64f6 (x_set_frame_parameters): Handle icon-left, icon-top parms.
Richard M. Stallman <rms@gnu.org>
parents: 10080
diff changeset
4188 }
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
4189
25320
107c9221181c (x_window) [USE_X_TOOLKIT]: Remove test for
Gerd Moellmann <gerd@gnu.org>
parents: 25289
diff changeset
4190 UNGCPRO;
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
4191 return unbind_to (count, frame);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4192 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4193
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
4194 /* 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
4195 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
4196 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
4197
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
4198 Lisp_Object
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
4199 x_get_focus_frame (frame)
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
4200 struct frame *frame;
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
4201 {
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
4202 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
4203 Lisp_Object xfocus;
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
4204 if (! dpyinfo->x_focus_frame)
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
4205 return Qnil;
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
4206
11537
9d4df3cf95b3 (x_get_focus_frame): New arg FRAME. Callers changed.
Karl Heuer <kwzh@gnu.org>
parents: 11496
diff changeset
4207 XSETFRAME (xfocus, dpyinfo->x_focus_frame);
6485
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
4208 return xfocus;
b0825eef18b1 (x_get_focus_frame): New function.
Karl Heuer <kwzh@gnu.org>
parents: 6480
diff changeset
4209 }
3048
96ff8e5744b2 * xfns.c (select_visual): Include the screen number in the
Jim Blandy <jimb@redhat.com>
parents: 3015
diff changeset
4210
28044
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4211
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4212 /* In certain situations, when the window manager follows a
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4213 click-to-focus policy, there seems to be no way around calling
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4214 XSetInputFocus to give another frame the input focus .
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4215
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4216 In an ideal world, XSetInputFocus should generally be avoided so
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4217 that applications don't interfere with the window manager's focus
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4218 policy. But I think it's okay to use when it's clearly done
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4219 following a user-command. */
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4220
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4221 DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4222 "Set the input focus to FRAME.\n\
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4223 FRAME nil means use the selected frame.")
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4224 (frame)
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4225 Lisp_Object frame;
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4226 {
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4227 struct frame *f = check_x_frame (frame);
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4228 Display *dpy = FRAME_X_DISPLAY (f);
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4229 int count;
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4230
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4231 BLOCK_INPUT;
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4232 count = x_catch_errors (dpy);
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4233 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4234 RevertToParent, CurrentTime);
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4235 x_uncatch_errors (dpy, count);
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4236 UNBLOCK_INPUT;
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4237
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4238 return Qnil;
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4239 }
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4240
3048
96ff8e5744b2 * xfns.c (select_visual): Include the screen number in the
Jim Blandy <jimb@redhat.com>
parents: 3015
diff changeset
4241
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4242 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4243 "Internal function called by `color-defined-p', which see.")
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4244 (color, frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4245 Lisp_Object color, frame;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4246 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4247 XColor foo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4248 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
4249
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4250 CHECK_STRING (color, 1);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4251
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4252 if (x_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
4253 return Qt;
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
4254 else
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
4255 return Qnil;
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
4256 }
1fe413b0a916 (defined_color): New arg ALLOC--optionally don't allocate the color.
Richard M. Stallman <rms@gnu.org>
parents: 8655
diff changeset
4257
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4258 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4259 "Internal function called by `color-values', which see.")
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4260 (color, frame)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4261 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
4262 {
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4263 XColor foo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4264 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
4265
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4266 CHECK_STRING (color, 1);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4267
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4268 if (x_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
4269 {
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
4270 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
4271
4c69fcaaa037 (Fx_color_defined_p): Return list of RGB values, not just t.
Richard M. Stallman <rms@gnu.org>
parents: 8405
diff changeset
4272 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
4273 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
4274 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
4275 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
4276 }
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4277 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4278 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4279 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4280
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4281 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
4282 "Internal function called by `display-color-p', which see.")
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4283 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4284 Lisp_Object display;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4285 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4286 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
4287
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4288 if (dpyinfo->n_planes <= 2)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4289 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4290
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4291 switch (dpyinfo->visual->class)
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4292 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4293 case StaticColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4294 case PseudoColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4295 case TrueColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4296 case DirectColor:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4297 return Qt;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4298
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4299 default:
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4300 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4301 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4302 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4303
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
4304 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
4305 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4306 "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
4307 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
4308 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
4309 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
4310 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
4311 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4312 Lisp_Object display;
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
4313 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4314 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
4315
12347
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4316 if (dpyinfo->n_planes <= 1)
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4317 return Qnil;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4318
12347
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4319 switch (dpyinfo->visual->class)
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4320 {
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4321 case StaticColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4322 case PseudoColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4323 case TrueColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4324 case DirectColor:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4325 case StaticGray:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4326 case GrayScale:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4327 return Qt;
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4328
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4329 default:
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4330 return Qnil;
0731c1ec96ad (Fx_display_grayscale_p): Return t or nil.
Richard M. Stallman <rms@gnu.org>
parents: 12316
diff changeset
4331 }
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
4332 }
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
4333
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4334 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
4335 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4336 "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
4337 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
4338 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
4339 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
4340 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4341 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4342 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4343 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
4344
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4345 return make_number (dpyinfo->width);
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4346 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4347
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4348 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
4349 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
4350 "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
4351 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
4352 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
4353 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
4354 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4355 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4356 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4357 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
4358
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4359 return make_number (dpyinfo->height);
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4360 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4361
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4362 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
4363 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4364 "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
4365 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
4366 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
4367 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
4368 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4369 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4370 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4371 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
4372
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4373 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
4374 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4375
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4376 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
4377 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4378 "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
4379 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
4380 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
4381 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
4382 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4383 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4384 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4385 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
4386
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4387 return make_number (DisplayCells (dpyinfo->display,
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4388 XScreenNumberOfScreen (dpyinfo->screen)));
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4389 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4390
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4391 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4392 Sx_server_max_request_size,
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4393 0, 1, 0,
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4394 "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
4395 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
4396 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
4397 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
4398 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4399 Lisp_Object display;
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4400 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4401 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
4402
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4403 return make_number (MAXREQUEST (dpyinfo->display));
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4404 }
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
4405
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4406 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
4407 "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
4408 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
4409 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
4410 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
4411 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4412 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4413 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4414 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
4415 char *vendor = ServerVendor (dpyinfo->display);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4416
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4417 if (! vendor) vendor = "";
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4418 return build_string (vendor);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4419 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4420
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4421 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
4422 "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
4423 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
4424 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
4425 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
4426 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
4427 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
4428 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
4429 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4430 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4431 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4432 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
4433 Display *dpy = dpyinfo->display;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4434
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4435 return Fcons (make_number (ProtocolVersion (dpy)),
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4436 Fcons (make_number (ProtocolRevision (dpy)),
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4437 Fcons (make_number (VendorRelease (dpy)), Qnil)));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4438 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4439
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4440 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
4441 "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
4442 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
4443 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
4444 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
4445 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4446 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4447 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4448 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
4449
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4450 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
4451 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4452
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4453 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
4454 "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
4455 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
4456 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
4457 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
4458 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4459 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4460 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4461 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
4462
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4463 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
4464 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4465
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4466 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
4467 "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
4468 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
4469 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
4470 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
4471 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4472 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4473 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4474 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
4475
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4476 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
4477 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4478
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4479 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
4480 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
4481 "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
4482 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
4483 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
4484 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
4485 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
4486 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4487 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4488 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4489 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
4490
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4491 switch (DoesBackingStore (dpyinfo->screen))
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4492 {
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4493 case Always:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4494 return intern ("always");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4495
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4496 case WhenMapped:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4497 return intern ("when-mapped");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4498
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4499 case NotUseful:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4500 return intern ("not-useful");
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4501
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4502 default:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4503 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
4504 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4505 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4506
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4507 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
4508 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
4509 "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
4510 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
4511 `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
4512 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
4513 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
4514 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
4515 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4516 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4517 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4518 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
4519
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4520 switch (dpyinfo->visual->class)
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4521 {
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4522 case StaticGray: return (intern ("static-gray"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4523 case GrayScale: return (intern ("gray-scale"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4524 case StaticColor: return (intern ("static-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4525 case PseudoColor: return (intern ("pseudo-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4526 case TrueColor: return (intern ("true-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4527 case DirectColor: return (intern ("direct-color"));
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4528 default:
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4529 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
4530 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4531 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4532
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4533 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
4534 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
4535 "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
4536 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
4537 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
4538 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
4539 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4540 Lisp_Object display;
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4541 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4542 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
4543
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4544 if (DoesSaveUnders (dpyinfo->screen) == True)
2276
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4545 return Qt;
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4546 else
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4547 return Qnil;
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4548 }
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
4549
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4550 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4551 x_pixel_width (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4552 register struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4553 {
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4554 return PIXEL_WIDTH (f);
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4555 }
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4556
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4557 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4558 x_pixel_height (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4559 register struct frame *f;
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4560 {
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4561 return PIXEL_HEIGHT (f);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4562 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4563
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4564 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4565 x_char_width (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4566 register struct frame *f;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4567 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4568 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
4569 }
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4570
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4571 int
2067
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4572 x_char_height (f)
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4573 register struct frame *f;
0a353ddd4bf4 (Fx_pixel_width, Fx_pixel_height): Fns deleted.
Richard M. Stallman <rms@gnu.org>
parents: 1994
diff changeset
4574 {
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12656
diff changeset
4575 return f->output_data.x->line_height;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4576 }
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4577
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4578 int
19825
cdfaf8ce5208 (x_screen_planes): Fix type of argument.
Richard M. Stallman <rms@gnu.org>
parents: 19095
diff changeset
4579 x_screen_planes (f)
cdfaf8ce5208 (x_screen_planes): Fix type of argument.
Richard M. Stallman <rms@gnu.org>
parents: 19095
diff changeset
4580 register struct frame *f;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4581 {
19825
cdfaf8ce5208 (x_screen_planes): Fix type of argument.
Richard M. Stallman <rms@gnu.org>
parents: 19095
diff changeset
4582 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
4583 }
28044
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
4584
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4585
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4586
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4587 /************************************************************************
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4588 X Displays
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4589 ************************************************************************/
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4590
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4591
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4592 /* Mapping visual names to visuals. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4593
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4594 static struct visual_class
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4595 {
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4596 char *name;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4597 int class;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4598 }
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4599 visual_classes[] =
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4600 {
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4601 {"StaticGray", StaticGray},
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4602 {"GrayScale", GrayScale},
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4603 {"StaticColor", StaticColor},
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4604 {"PseudoColor", PseudoColor},
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4605 {"TrueColor", TrueColor},
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4606 {"DirectColor", DirectColor},
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4607 NULL
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4608 };
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4609
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4610
4606
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
4611 #ifndef HAVE_XSCREENNUMBEROFSCREEN
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4612
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4613 /* Value is the screen number of screen SCR. This is a substitute for
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4614 the X function with the same name when that doesn't exist. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4615
4606
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
4616 int
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
4617 XScreenNumberOfScreen (scr)
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
4618 register Screen *scr;
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
4619 {
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4620 Display *dpy = scr->display;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4621 int i;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4622
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4623 for (i = 0; i < dpy->nscreens; ++i)
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4624 if (scr == dpy->screens[i])
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4625 break;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4626
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4627 return i;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4628 }
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4629
4606
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
4630 #endif /* not HAVE_XSCREENNUMBEROFSCREEN */
0866f021a2cc (XScreenNumberOfScreen): New function.
Richard M. Stallman <rms@gnu.org>
parents: 4571
diff changeset
4631
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4632
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4633 /* Select the visual that should be used on display DPYINFO. Set
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4634 members of DPYINFO appropriately. Called from x_term_init. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4635
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4636 void
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4637 select_visual (dpyinfo)
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4638 struct x_display_info *dpyinfo;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4639 {
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4640 Display *dpy = dpyinfo->display;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4641 Screen *screen = dpyinfo->screen;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4642 Lisp_Object value;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4643
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4644 /* See if a visual is specified. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4645 value = display_x_get_resource (dpyinfo,
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4646 build_string ("visualClass"),
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4647 build_string ("VisualClass"),
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4648 Qnil, Qnil);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4649 if (STRINGP (value))
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4650 {
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4651 /* VALUE should be of the form CLASS-DEPTH, where CLASS is one
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4652 of `PseudoColor', `TrueColor' etc. and DEPTH is the color
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4653 depth, a decimal number. NAME is compared with case ignored. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4654 char *s = (char *) alloca (STRING_BYTES (XSTRING (value)) + 1);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4655 char *dash;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4656 int i, class = -1;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4657 XVisualInfo vinfo;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4658
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4659 strcpy (s, XSTRING (value)->data);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4660 dash = index (s, '-');
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4661 if (dash)
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4662 {
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4663 dpyinfo->n_planes = atoi (dash + 1);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4664 *dash = '\0';
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4665 }
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4666 else
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4667 /* We won't find a matching visual with depth 0, so that
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4668 an error will be printed below. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4669 dpyinfo->n_planes = 0;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4670
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4671 /* Determine the visual class. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4672 for (i = 0; visual_classes[i].name; ++i)
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4673 if (xstricmp (s, visual_classes[i].name) == 0)
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4674 {
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4675 class = visual_classes[i].class;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4676 break;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4677 }
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4678
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4679 /* Look up a matching visual for the specified class. */
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4680 if (class == -1
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4681 || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen),
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4682 dpyinfo->n_planes, class, &vinfo))
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4683 fatal ("Invalid visual specification `%s'", XSTRING (value)->data);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4684
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4685 dpyinfo->visual = vinfo.visual;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4686 }
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4687 else
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4688 {
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4689 int n_visuals;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4690 XVisualInfo *vinfo, vinfo_template;
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4691
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4692 dpyinfo->visual = 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
4693
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
4694 #ifdef HAVE_X11R4
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4695 vinfo_template.visualid = XVisualIDFromVisual (dpyinfo->visual);
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
4696 #else
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4697 vinfo_template.visualid = dpyinfo->visual->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
4698 #endif
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4699 vinfo_template.screen = XScreenNumberOfScreen (screen);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4700 vinfo = XGetVisualInfo (dpy, VisualIDMask | VisualScreenMask,
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4701 &vinfo_template, &n_visuals);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4702 if (n_visuals != 1)
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4703 fatal ("Can't get proper X visual info");
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4704
28199
56a776500341 * xfns.c (select_visual): Don't set dpyinfo->n_planes to the
Gerd Moellmann <gerd@gnu.org>
parents: 28144
diff changeset
4705 dpyinfo->n_planes = vinfo->depth;
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4706 XFree ((char *) vinfo);
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4707 }
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4708 }
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4709
389
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 /* 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
4712 Open a new connection if necessary. */
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4713
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4714 struct x_display_info *
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4715 x_display_info_for_name (name)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4716 Lisp_Object name;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4717 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4718 Lisp_Object names;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4719 struct x_display_info *dpyinfo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4720
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4721 CHECK_STRING (name, 0);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4722
12381
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
4723 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
4724 error ("Not using X Windows");
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
4725
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4726 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
4727 dpyinfo;
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
4728 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
4729 {
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4730 Lisp_Object tem;
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
4731 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
4732 if (!NILP (tem))
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4733 return dpyinfo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4734 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4735
11917
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
4736 /* 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
4737 Vx_resource_name = Vinvocation_name;
2314b62ca4ab (Fx_get_resource): Major rewrite to make it clearer.
Karl Heuer <kwzh@gnu.org>
parents: 11900
diff changeset
4738
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4739 validate_x_resource_name ();
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4740
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4741 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
4742 (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
4743
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4744 if (dpyinfo == 0)
12046
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
4745 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
4746
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4747 x_in_use = 1;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4748 XSETFASTINT (Vwindow_system_version, 11);
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4749
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4750 return dpyinfo;
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4751 }
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4752
27993
3a34e2d1bf3c (select_visual): Rewritten. Recognize user-specified
Gerd Moellmann <gerd@gnu.org>
parents: 27987
diff changeset
4753
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4754 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
4755 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
4756 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
4757 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
4758 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
4759 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
4760 (display, xrm_string, must_succeed)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4761 Lisp_Object display, xrm_string, must_succeed;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4762 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4763 unsigned char *xrm_option;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4764 struct x_display_info *dpyinfo;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4765
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4766 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
4767 if (! NILP (xrm_string))
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
4768 CHECK_STRING (xrm_string, 1);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4769
12381
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
4770 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
4771 error ("Not using X Windows");
67cb86bbdb55 (Fx_open_connection, x_display_info_for_name):
Richard M. Stallman <rms@gnu.org>
parents: 12347
diff changeset
4772
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
4773 if (! NILP (xrm_string))
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
4774 xrm_option = (unsigned char *) XSTRING (xrm_string)->data;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4775 else
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4776 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
4777
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
4778 validate_x_resource_name ();
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
4779
7802
d687e885fa6a (Fx_open_connection): Set up Vx_resource_name and xrm_option
Richard M. Stallman <rms@gnu.org>
parents: 7797
diff changeset
4780 /* 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
4781 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
4782 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
4783 (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
4784
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4785 if (dpyinfo == 0)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4786 {
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4787 if (!NILP (must_succeed))
12046
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
4788 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
4789 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
4790 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
4791 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
4792 XSTRING (display)->data);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4793 else
12046
d23f2c9990b2 (x_display_info_for_name): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 12036
diff changeset
4794 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
4795 }
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4796
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4797 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
4798
9327
b3398cf56fba (Fx_open_connection): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents: 9285
diff changeset
4799 XSETFASTINT (Vwindow_system_version, 11);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4800 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4801 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4802
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4803 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
4804 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
4805 "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
4806 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
4807 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
4808 (display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4809 Lisp_Object display;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4810 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4811 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
4812 int i;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4813
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4814 if (dpyinfo->reference_count > 0)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4815 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
4816
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4817 BLOCK_INPUT;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4818 /* 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
4819 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
4820 if (dpyinfo->font_table[i].name)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4821 {
28229
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
4822 if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)
5a0af67169a7 (Fx_create_frame): Don't cal fs_register_fontset.
Kenichi Handa <handa@m17n.org>
parents: 28199
diff changeset
4823 xfree (dpyinfo->font_table[i].full_name);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4824 xfree (dpyinfo->font_table[i].name);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4825 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
4826 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4827
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4828 x_destroy_all_bitmaps (dpyinfo);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4829 XSetCloseDownMode (dpyinfo->display, DestroyAll);
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
4830
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
4831 #ifdef USE_X_TOOLKIT
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
4832 XtCloseDisplay (dpyinfo->display);
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
4833 #else
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4834 XCloseDisplay (dpyinfo->display);
9742
fe7653791d28 (Fx_create_frame): Set xlwmenu_default_font.
Richard M. Stallman <rms@gnu.org>
parents: 9703
diff changeset
4835 #endif
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4836
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4837 x_delete_display (dpyinfo);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4838 UNBLOCK_INPUT;
8782
51241477cfc5 Delete X11 conditionals.
Richard M. Stallman <rms@gnu.org>
parents: 8780
diff changeset
4839
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4840 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4841 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4842
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4843 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
4844 "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
4845 ()
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4846 {
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4847 Lisp_Object tail, result;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4848
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4849 result = Qnil;
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25628
diff changeset
4850 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
4851 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
4852
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4853 return result;
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4854 }
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4855
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4856 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
4857 "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
4858 If ON is nil, allow buffering of requests.\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4859 Turning on synchronization prohibits the Xlib routines from buffering\n\
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4860 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
4861 easier.\n\
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4862 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
4863 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
4864 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
4865 (on, display)
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4866 Lisp_Object display, on;
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4867 {
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
4868 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
4869
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4870 XSynchronize (dpyinfo->display, !EQ (on, Qnil));
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4871
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4872 return Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4873 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4874
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4875 /* 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
4876
f900f7bba4c2 (x_sync): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5429
diff changeset
4877 void
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4878 x_sync (f)
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4879 FRAME_PTR f;
5536
f900f7bba4c2 (x_sync): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5429
diff changeset
4880 {
5558
42ec75481b8b (x_sync): Block input.
Richard M. Stallman <rms@gnu.org>
parents: 5536
diff changeset
4881 BLOCK_INPUT;
9653
cfc5e15e0baf (x_sync): Take frame ptr as arg.
Richard M. Stallman <rms@gnu.org>
parents: 9580
diff changeset
4882 XSync (FRAME_X_DISPLAY (f), False);
5558
42ec75481b8b (x_sync): Block input.
Richard M. Stallman <rms@gnu.org>
parents: 5536
diff changeset
4883 UNBLOCK_INPUT;
5536
f900f7bba4c2 (x_sync): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5429
diff changeset
4884 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4885
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4886
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4887 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4888 Image types
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4889 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4890
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4891 /* 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
4892
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4893 #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
4894
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4895 /* 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
4896 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
4897
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4898 static struct image_type *image_types;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4899
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4900 /* 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
4901 images in Lisp. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4902
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4903 extern Lisp_Object Qimage;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4904
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4905 /* 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
4906
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4907 Lisp_Object Qxbm;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4908
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4909 /* Keywords. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4910
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
4911 extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile;
28001
fed7f17af8c1 (QCdata): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 27993
diff changeset
4912 extern Lisp_Object QCdata;
fed7f17af8c1 (QCdata): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 27993
diff changeset
4913 Lisp_Object QCtype, QCascent, QCmargin, QCrelief;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4914 Lisp_Object QCalgorithm, QCcolor_symbols, QCheuristic_mask;
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
4915 Lisp_Object QCindex;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4916
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4917 /* Other symbols. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4918
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4919 Lisp_Object Qlaplace;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4920
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4921 /* 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
4922 if not displayed. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4923
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
4924 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
4925
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4926 /* Function prototypes. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4927
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4928 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
4929 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
4930 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
4931 static void x_laplace P_ ((struct frame *, struct image *));
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
4932 static int x_build_heuristic_mask P_ ((struct frame *, struct image *,
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
4933 Lisp_Object));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4934
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4935
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4936 /* 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
4937 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
4938
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4939 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4940 define_image_type (type)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4941 struct image_type *type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4942 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4943 /* 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
4944 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
4945 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
4946 bcopy (type, p, sizeof *p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4947 p->next = image_types;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4948 image_types = p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4949 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
4950 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4951
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4952
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4953 /* 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
4954 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
4955
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4956 static INLINE struct image_type *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4957 lookup_image_type (symbol)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4958 Lisp_Object symbol;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4959 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4960 struct image_type *type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4961
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4962 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
4963 if (EQ (symbol, *type->type))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4964 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4965
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4966 return type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4967 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4968
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4969
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4970 /* 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
4971 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
4972 `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
4973 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
4974 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
4975 image type. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4976
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4977 int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4978 valid_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4979 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4980 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4981 int valid_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4982
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4983 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
4984 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4985 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
4986 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
4987
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4988 if (type)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4989 valid_p = type->valid_p (object);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4990 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4991
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4992 return valid_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4993 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
4995
25800
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
4996 /* 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
4997 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
4998 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
4999 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
5000 therefore simply displays a message. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5001
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5002 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5003 image_error (format, arg1, arg2)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5004 char *format;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5005 Lisp_Object arg1, arg2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5006 {
25800
609695887d08 (image_error): Use add_to_log.
Gerd Moellmann <gerd@gnu.org>
parents: 25715
diff changeset
5007 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
5008 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5009
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5010
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5011
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5012 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5013 Image specifications
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5014 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5015
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5016 enum image_value_type
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5017 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5018 IMAGE_DONT_CHECK_VALUE_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5019 IMAGE_STRING_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5020 IMAGE_SYMBOL_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5021 IMAGE_POSITIVE_INTEGER_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5022 IMAGE_NON_NEGATIVE_INTEGER_VALUE,
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5023 IMAGE_ASCENT_VALUE,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5024 IMAGE_INTEGER_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5025 IMAGE_FUNCTION_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5026 IMAGE_NUMBER_VALUE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5027 IMAGE_BOOL_VALUE
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5028 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5029
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5030 /* Structure used when parsing image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5031
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5032 struct image_keyword
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5033 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5034 /* Name of keyword. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5035 char *name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5036
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5037 /* The type of value allowed. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5038 enum image_value_type type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5039
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5040 /* 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
5041 int mandatory_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5042
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5043 /* 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
5044 int count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5045
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5046 /* The value that was found. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5047 Lisp_Object value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5048 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5049
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5050
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
5051 static int parse_image_spec P_ ((Lisp_Object, struct image_keyword *,
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
5052 int, Lisp_Object));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5053 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
5054
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5055
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5056 /* 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
5057 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
5058 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
5059 image_keywords structures of size NKEYWORDS describing other
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
5060 allowed keyword/value pairs. Value is non-zero if SPEC is valid. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5061
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5062 static int
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
5063 parse_image_spec (spec, keywords, nkeywords, type)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5064 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5065 struct image_keyword *keywords;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5066 int nkeywords;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5067 Lisp_Object type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5068 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5069 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5070 Lisp_Object plist;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5071
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5072 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
5073 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5074
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5075 plist = XCDR (spec);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5076 while (CONSP (plist))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5077 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5078 Lisp_Object key, value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5079
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5080 /* 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
5081 key = XCAR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5082 plist = XCDR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5083 if (!SYMBOLP (key))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5084 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5085
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5086 /* There must follow a value. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5087 if (!CONSP (plist))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5088 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5089 value = XCAR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5090 plist = XCDR (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5091
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5092 /* 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
5093 for (i = 0; i < nkeywords; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5094 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
5095 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5096
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5097 if (i == nkeywords)
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
5098 continue;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5099
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5100 /* 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
5101 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
5102 keywords[i].value = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5103 ++keywords[i].count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5104
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5105 if (keywords[i].count > 1)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5106 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5107
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5108 /* 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
5109 switch (keywords[i].type)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5110 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5111 case IMAGE_STRING_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5112 if (!STRINGP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5113 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5114 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5115
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5116 case IMAGE_SYMBOL_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5117 if (!SYMBOLP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5118 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5119 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5120
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5121 case IMAGE_POSITIVE_INTEGER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5122 if (!INTEGERP (value) || XINT (value) <= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5123 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5124 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5125
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5126 case IMAGE_ASCENT_VALUE:
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5127 if (SYMBOLP (value) && EQ (value, Qcenter))
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5128 break;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5129 else if (INTEGERP (value)
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5130 && XINT (value) >= 0
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5131 && XINT (value) <= 100)
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5132 break;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5133 return 0;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5134
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5135 case IMAGE_NON_NEGATIVE_INTEGER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5136 if (!INTEGERP (value) || XINT (value) < 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5137 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5138 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5139
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5140 case IMAGE_DONT_CHECK_VALUE_TYPE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5141 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5142
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5143 case IMAGE_FUNCTION_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5144 value = indirect_function (value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5145 if (SUBRP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5146 || COMPILEDP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5147 || (CONSP (value) && EQ (XCAR (value), Qlambda)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5148 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5149 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5150
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5151 case IMAGE_NUMBER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5152 if (!INTEGERP (value) && !FLOATP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5153 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5154 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5155
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5156 case IMAGE_INTEGER_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5157 if (!INTEGERP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5158 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5159 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5160
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5161 case IMAGE_BOOL_VALUE:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5162 if (!NILP (value) && !EQ (value, Qt))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5163 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5164 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5165
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5166 default:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5167 abort ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5168 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5169 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5170
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5171 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
5172 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5173 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5174
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5175 /* 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
5176 for (i = 0; i < nkeywords; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5177 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
5178 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5179
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5180 return NILP (plist);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5181 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5182
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5183
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5184 /* 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
5185 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
5186 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
5187
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5188 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5189 image_spec_value (spec, key, found)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5190 Lisp_Object spec, key;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5191 int *found;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5192 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5193 Lisp_Object tail;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5194
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5195 xassert (valid_image_p (spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5196
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5197 for (tail = XCDR (spec);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5198 CONSP (tail) && CONSP (XCDR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5199 tail = XCDR (XCDR (tail)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5200 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5201 if (EQ (XCAR (tail), key))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5202 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5203 if (found)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5204 *found = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5205 return XCAR (XCDR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5206 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5207 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5208
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5209 if (found)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5210 *found = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5211 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5212 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5213
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5214
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5215
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5216
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5217 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5218 Image type independent image structures
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5219 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5220
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5221 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
5222 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
5223
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5224
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5225 /* 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
5226 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
5227
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5228 static struct image *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5229 make_image (spec, hash)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5230 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5231 unsigned hash;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5232 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5233 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
5234
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5235 xassert (valid_image_p (spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5236 bzero (img, sizeof *img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5237 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
5238 xassert (img->type != NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5239 img->spec = spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5240 img->data.lisp_val = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5241 img->ascent = DEFAULT_IMAGE_ASCENT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5242 img->hash = hash;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5243 return img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5244 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5245
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5246
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5247 /* 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
5248
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5249 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5250 free_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5251 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5252 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5253 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5254 if (img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5255 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5256 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
5257
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5258 /* 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
5259 if (img->prev)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5260 img->prev->next = img->next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5261 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5262 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
5263
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5264 if (img->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5265 img->next->prev = img->prev;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5266
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5267 c->images[img->id] = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5268
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5269 /* Free resources, then free IMG. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5270 img->type->free (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5271 xfree (img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5272 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5273 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5274
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5275
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5276 /* 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
5277 drawing an image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5278
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5279 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5280 prepare_image_for_display (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5281 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5282 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5283 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5284 EMACS_TIME t;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5285
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5286 /* 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
5287 EMACS_GET_TIME (t);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5288 img->timestamp = EMACS_SECS (t);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5289
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5290 /* 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
5291 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
5292 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
5293 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
5294 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5295
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5296
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5297 /* Value is the number of pixels for the ascent of image IMG when
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5298 drawn in face FACE. */
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5299
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5300 int
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5301 image_ascent (img, face)
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5302 struct image *img;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5303 struct face *face;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5304 {
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5305 int height = img->height + img->margin;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5306 int ascent;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5307
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5308 if (img->ascent == CENTERED_IMAGE_ASCENT)
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5309 {
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5310 if (face->font)
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5311 ascent = height / 2 - (face->font->descent - face->font->ascent) / 2;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5312 else
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5313 ascent = height / 2;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5314 }
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5315 else
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5316 ascent = height * img->ascent / 100.0;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5317
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5318 return ascent;
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5319 }
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5320
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5321
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5322
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5323 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5324 Helper functions for X image types
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5325 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5326
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5327 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
5328 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
5329 struct image *img,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5330 Lisp_Object color_name,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5331 unsigned long dflt));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5332
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5333 /* 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
5334
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5335 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5336 x_clear_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5337 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5338 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5339 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5340 if (img->pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5341 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5342 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5343 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
5344 img->pixmap = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5345 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5346 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5347
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5348 if (img->ncolors)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5349 {
27963
0e2c6e5cca6e (x_clear_image, x_kill_gs_process): Use x_free_colors.
Gerd Moellmann <gerd@gnu.org>
parents: 27915
diff changeset
5350 BLOCK_INPUT;
0e2c6e5cca6e (x_clear_image, x_kill_gs_process): Use x_free_colors.
Gerd Moellmann <gerd@gnu.org>
parents: 27915
diff changeset
5351 x_free_colors (f, img->colors, img->ncolors);
0e2c6e5cca6e (x_clear_image, x_kill_gs_process): Use x_free_colors.
Gerd Moellmann <gerd@gnu.org>
parents: 27915
diff changeset
5352 UNBLOCK_INPUT;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5353
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5354 xfree (img->colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5355 img->colors = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5356 img->ncolors = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5357 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5358 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5359
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5360
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5361 /* 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
5362 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
5363 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
5364 color. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5365
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5366 static unsigned long
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5367 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
5368 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5369 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5370 Lisp_Object color_name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5371 unsigned long dflt;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5372 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5373 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5374 unsigned long result;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5375
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5376 xassert (STRINGP (color_name));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5377
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
5378 if (x_defined_color (f, XSTRING (color_name)->data, &color, 1))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5379 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5380 /* 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
5381 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
5382 ++img->ncolors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5383 img->colors =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5384 (unsigned long *) xrealloc (img->colors,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5385 img->ncolors * sizeof *img->colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5386 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
5387 result = color.pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5388 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5389 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5390 result = dflt;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5391
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5392 return result;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5393 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5394
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5395
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5396
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5397 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5398 Image Cache
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5399 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5400
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5401 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
5402
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5403
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5404 /* 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
5405 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
5406
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5407 struct image_cache *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5408 make_image_cache ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5409 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5410 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
5411 int size;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5412
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5413 bzero (c, sizeof *c);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5414 c->size = 50;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5415 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
5416 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
5417 c->buckets = (struct image **) xmalloc (size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5418 bzero (c->buckets, size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5419 return c;
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
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 /* 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
5424 caches. */
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 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5427 free_image_cache (f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5428 struct frame *f;
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 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
5431 if (c)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5432 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5433 int i;
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 /* 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
5436 xassert (c->refcount == 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5437
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5438 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
5439 free_image (f, c->images[i]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5440 xfree (c->images);
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
5441 xfree (c->buckets);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5442 xfree (c);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5443 FRAME_X_IMAGE_CACHE (f) = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5444 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5445 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5446
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 /* 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
5449 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
5450 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
5451 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
5452 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
5453 at least that many seconds. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5454
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5455 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5456 clear_image_cache (f, force_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5457 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5458 int force_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5459 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5460 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
5461
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
5462 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
5463 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5464 EMACS_TIME t;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5465 unsigned long old;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5466 int i, any_freed_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5467
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5468 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
5469 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
5470
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5471 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
5472 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5473 struct image *img = c->images[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5474 if (img != NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5475 && (force_p
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5476 || (img->timestamp > old)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5477 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5478 free_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5479 any_freed_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5480 }
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 /* 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
5484 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
5485 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
5486 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
5487 if (any_freed_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5488 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5489 clear_current_matrices (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5490 ++windows_or_buffers_changed;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5491 }
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 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5494
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5495
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5496 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
5497 0, 1, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5498 "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
5499 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
5500 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
5501 (frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5502 Lisp_Object frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5503 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5504 if (EQ (frame, Qt))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5505 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5506 Lisp_Object tail;
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 FOR_EACH_FRAME (tail, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5509 if (FRAME_X_P (XFRAME (frame)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5510 clear_image_cache (XFRAME (frame), 1);
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 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5513 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
5514
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5515 return Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5516 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5517
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 /* 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
5520 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
5521
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5522 int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5523 lookup_image (f, spec)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5524 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5525 Lisp_Object spec;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5526 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5527 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
5528 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5529 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5530 unsigned hash;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5531 struct gcpro gcpro1;
25817
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
5532 EMACS_TIME now;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5533
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5534 /* 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
5535 specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5536 xassert (FRAME_WINDOW_P (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5537 xassert (valid_image_p (spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5538
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5539 GCPRO1 (spec);
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 /* 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
5542 hash = sxhash (spec, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5543 i = hash % IMAGE_CACHE_BUCKETS_SIZE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5544
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5545 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
5546 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
5547 break;
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 /* 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
5550 if (img == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5551 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5552 img = make_image (spec, hash);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5553 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
5554 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
5555 xassert (!interrupt_input_blocked);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5556
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5557 /* 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
5558 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
5559 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
5560 if (img->load_failed_p)
24994
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 Lisp_Object value;
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 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
5565 img->width = (INTEGERP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5566 ? XFASTINT (value) : DEFAULT_IMAGE_WIDTH);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5567 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
5568 img->height = (INTEGERP (value)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5569 ? XFASTINT (value) : DEFAULT_IMAGE_HEIGHT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5570 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5571 else
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 /* Handle image type independent image attributes
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5574 `:ascent ASCENT', `:margin MARGIN', `:relief RELIEF'. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5575 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
5576 Lisp_Object file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5577
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5578 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
5579 if (INTEGERP (ascent))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5580 img->ascent = XFASTINT (ascent);
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5581 else if (EQ (ascent, Qcenter))
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5582 img->ascent = CENTERED_IMAGE_ASCENT;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5583
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5584 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
5585 if (INTEGERP (margin) && XINT (margin) >= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5586 img->margin = XFASTINT (margin);
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 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
5589 if (INTEGERP (relief))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5590 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5591 img->relief = XINT (relief);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5592 img->margin += abs (img->relief);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5593 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5594
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5595 /* 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
5596 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
5597 if (img->pixmap && EQ (algorithm, Qlaplace))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5598 x_laplace (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5599
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5600 /* Should we built a mask heuristically? */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5601 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
5602 if (img->pixmap && !img->mask && !NILP (heuristic_mask))
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
5603 x_build_heuristic_mask (f, img, heuristic_mask);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5604 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5605 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5606
25817
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
5607 /* 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
5608 EMACS_GET_TIME (now);
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
5609 img->timestamp = EMACS_SECS (now);
190a99688b53 (lookup_image): Set image's timestamp because it's
Gerd Moellmann <gerd@gnu.org>
parents: 25800
diff changeset
5610
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5611 UNGCPRO;
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 /* Value is the image id. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5614 return img->id;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5615 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5616
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5617
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5618 /* 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
5619
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5620 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5621 cache_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5622 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5623 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5624 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5625 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
5626 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5627
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5628 /* 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
5629 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
5630 if (c->images[i] == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5631 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5632
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5633 /* 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
5634 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
5635 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5636 c->size *= 2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5637 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
5638 c->size * sizeof *c->images);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5639 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5640
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5641 /* 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
5642 c->images[i] = img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5643 img->id = i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5644 if (i == c->used)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5645 ++c->used;
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 /* 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
5648 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
5649 img->next = c->buckets[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5650 if (img->next)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5651 img->next->prev = img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5652 img->prev = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5653 c->buckets[i] = img;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5656
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5657 /* 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
5658 Lisp Objects in the image cache. */
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 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5661 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
5662 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5663 void (*fn) P_ ((struct image *img));
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 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
5666 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5667 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
5668 if (c)
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 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5671 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
5672 if (c->images[i])
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5673 fn (c->images[i]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5674 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5675 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5676 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5677
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5678
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5679
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 X support code
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5682 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5683
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
5684 static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int,
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
5685 XImage **, Pixmap *));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5686 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
5687 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
5688
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5689
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5690 /* 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
5691 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
5692 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
5693 via xmalloc. Print error messages via image_error if an error
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
5694 occurs. 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
5695
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5696 static int
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
5697 x_create_x_image_and_pixmap (f, width, height, depth, ximg, pixmap)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5698 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5699 int width, height, depth;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5700 XImage **ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5701 Pixmap *pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5702 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5703 Display *display = FRAME_X_DISPLAY (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5704 Screen *screen = FRAME_X_SCREEN (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5705 Window window = FRAME_X_WINDOW (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5706
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5707 xassert (interrupt_input_blocked);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5708
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5709 if (depth <= 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5710 depth = DefaultDepthOfScreen (screen);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5711 *ximg = XCreateImage (display, DefaultVisualOfScreen (screen),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5712 depth, ZPixmap, 0, NULL, width, height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5713 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
5714 if (*ximg == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5715 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
5716 image_error ("Unable to allocate X image", Qnil, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5717 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5718 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5719
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5720 /* Allocate image raster. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5721 (*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
5722
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5723 /* 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
5724 *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
5725 if (*pixmap == 0)
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 x_destroy_x_image (*ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5728 *ximg = NULL;
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
5729 image_error ("Unable to create X pixmap", Qnil, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5730 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5731 }
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 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5734 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5735
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 /* Destroy XImage XIMG. Free XIMG->data. */
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 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5740 x_destroy_x_image (ximg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5741 XImage *ximg;
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 xassert (interrupt_input_blocked);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5744 if (ximg)
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 xfree (ximg->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5747 ximg->data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5748 XDestroyImage (ximg);
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5752
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5753 /* 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
5754 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
5755
25691
815efc48a80b (x_put_x_image): Make type consistent with declaration.
Dave Love <fx@gnu.org>
parents: 25679
diff changeset
5756 static void
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5757 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
5758 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5759 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5760 Pixmap pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5761 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5762 GC gc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5763
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5764 xassert (interrupt_input_blocked);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5765 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
5766 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
5767 XFreeGC (FRAME_X_DISPLAY (f), gc);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5768 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5769
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5770
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5771
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5772 /***********************************************************************
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5773 File Handling
24994
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 static Lisp_Object x_find_image_file P_ ((Lisp_Object));
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5777 static char *slurp_file P_ ((char *, int *));
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5778
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5779
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5780 /* 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
5781 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
5782 nil if not found. */
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 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5785 x_find_image_file (file)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5786 Lisp_Object file;
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 Lisp_Object file_found, search_path;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5789 struct gcpro gcpro1, gcpro2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5790 int fd;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5791
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5792 file_found = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5793 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
5794 GCPRO2 (file_found, search_path);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5795
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5796 /* 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
5797 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
5798
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5799 if (fd < 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5800 file_found = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5801 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5802 close (fd);
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 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5805 return file_found;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5806 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5807
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5808
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5809 /* Read FILE into memory. Value is a pointer to a buffer allocated
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5810 with xmalloc holding FILE's contents. Value is null if an error
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5811 occured. *SIZE is set to the size of the file. */
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5812
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5813 static char *
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5814 slurp_file (file, size)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5815 char *file;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5816 int *size;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5817 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5818 FILE *fp = NULL;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5819 char *buf = NULL;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5820 struct stat st;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5821
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5822 if (stat (file, &st) == 0
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5823 && (fp = fopen (file, "r")) != NULL
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5824 && (buf = (char *) xmalloc (st.st_size),
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5825 fread (buf, 1, st.st_size, fp) == st.st_size))
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5826 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5827 *size = st.st_size;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5828 fclose (fp);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5829 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5830 else
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5831 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5832 if (fp)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5833 fclose (fp);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5834 if (buf)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5835 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5836 xfree (buf);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5837 buf = NULL;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5838 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5839 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5840
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5841 return buf;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5842 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5843
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5844
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5845
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 XBM images
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5848 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5849
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5850 static int xbm_scan P_ ((char **, char *, char *, int *));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5851 static int xbm_load P_ ((struct frame *f, struct image *img));
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5852 static int xbm_load_image P_ ((struct frame *f, struct image *img,
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5853 char *, char *));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5854 static int xbm_image_p P_ ((Lisp_Object object));
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5855 static int xbm_read_bitmap_data P_ ((char *, char *, int *, int *,
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5856 unsigned char **));
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5857 static int xbm_file_p P_ ((Lisp_Object));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5858
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5859
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5860 /* 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
5861
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5862 enum xbm_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5863 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5864 XBM_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5865 XBM_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5866 XBM_WIDTH,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5867 XBM_HEIGHT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5868 XBM_DATA,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5869 XBM_FOREGROUND,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5870 XBM_BACKGROUND,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5871 XBM_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5872 XBM_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5873 XBM_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5874 XBM_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5875 XBM_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5876 XBM_LAST
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5879 /* 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
5880 of valid XBM image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5881
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5882 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
5883 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5884 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5885 {":file", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5886 {":width", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5887 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5888 {":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
5889 {":foreground", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5890 {":background", IMAGE_STRING_VALUE, 0},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
5891 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5892 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5893 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5894 {":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
5895 {":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
5896 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5897
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5898 /* Structure describing the image type XBM. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5899
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5900 static struct image_type xbm_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5901 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5902 &Qxbm,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5903 xbm_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5904 xbm_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5905 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5906 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5907 };
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 /* Tokens returned from xbm_scan. */
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 enum xbm_token
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 XBM_TK_IDENT = 256,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5914 XBM_TK_NUMBER
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5915 };
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 /* 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
5919 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
5920 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
5921 entry `:type xbm..
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5922
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5923 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
5924 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
5925
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5926 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
5927 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
5928 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
5929
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5930 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
5931 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
5932
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5933 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
5934
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5935 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
5936 bitmap.
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5937
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5938 4. A string containing an in-memory XBM file. WIDTH and HEIGHT
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5939 may not be specified in this case because they are defined in the
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5940 XBM file.
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5941
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5942 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
5943 `: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
5944 foreground and background of the frame on which the image is
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
5945 displayed is used. */
24994
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 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5948 xbm_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5949 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5950 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5951 struct image_keyword kw[XBM_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5952
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5953 bcopy (xbm_format, kw, sizeof kw);
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
5954 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5955 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5956
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5957 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
5958
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5959 if (kw[XBM_FILE].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5960 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5961 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
5962 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5963 }
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5964 else if (kw[XBM_DATA].count && xbm_file_p (kw[XBM_DATA].value))
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5965 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5966 /* In-memory XBM file. */
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5967 if (kw[XBM_WIDTH].count || kw[XBM_HEIGHT].count || kw[XBM_FILE].count)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5968 return 0;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
5969 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5970 else
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 Lisp_Object data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5973 int width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5974
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5975 /* 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
5976 if (!kw[XBM_WIDTH].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5977 || !kw[XBM_HEIGHT].count
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5978 || !kw[XBM_DATA].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5979 return 0;
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 data = kw[XBM_DATA].value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5982 width = XFASTINT (kw[XBM_WIDTH].value);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5983 height = XFASTINT (kw[XBM_HEIGHT].value);
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 /* 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
5986 data. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5987 if (VECTORP (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5988 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5989 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5990
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5991 /* 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
5992 if (XVECTOR (data)->size < height)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5993 return 0;
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 /* 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
5996 for one line of the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
5997 for (i = 0; i < height; ++i)
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 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
6000
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6001 if (STRINGP (elt))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6002 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6003 if (XSTRING (elt)->size
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6004 < (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
6005 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6006 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6007 else if (BOOL_VECTOR_P (elt))
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 if (XBOOL_VECTOR (elt)->size < width)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6010 return 0;
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 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6013 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6014 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6015 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6016 else if (STRINGP (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6017 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6018 if (XSTRING (data)->size
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6019 < (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
6020 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6021 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6022 else if (BOOL_VECTOR_P (data))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6023 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6024 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
6025 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6026 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6027 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6028 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6029 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6030
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6031 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6032 }
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 /* 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
6036 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
6037 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
6038 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
6039 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
6040
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6041 static int
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6042 xbm_scan (s, end, sval, ival)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6043 char **s, *end;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6044 char *sval;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6045 int *ival;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6046 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6047 int c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6048
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6049 /* Skip white space. */
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6050 while (*s < end && (c = *(*s)++, isspace (c)))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6051 ;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6052
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6053 if (*s >= end)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6054 c = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6055 else if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6056 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6057 int value = 0, digit;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6058
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6059 if (c == '0' && *s < end)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6060 {
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6061 c = *(*s)++;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6062 if (c == 'x' || c == 'X')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6063 {
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6064 while (*s < end)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6065 {
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6066 c = *(*s)++;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6067 if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6068 digit = c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6069 else if (c >= 'a' && c <= 'f')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6070 digit = c - 'a' + 10;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6071 else if (c >= 'A' && c <= 'F')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6072 digit = c - 'A' + 10;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6073 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6074 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6075 value = 16 * value + digit;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6076 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6077 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6078 else if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6079 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6080 value = c - '0';
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6081 while (*s < end
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6082 && (c = *(*s)++, isdigit (c)))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6083 value = 8 * value + c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6084 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6085 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6086 else
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 value = c - '0';
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6089 while (*s < end
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6090 && (c = *(*s)++, isdigit (c)))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6091 value = 10 * value + c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6092 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6093
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6094 if (*s < end)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6095 *s = *s - 1;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6096 *ival = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6097 c = XBM_TK_NUMBER;
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 else if (isalpha (c) || c == '_')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6100 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6101 *sval++ = c;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6102 while (*s < end
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6103 && (c = *(*s)++, (isalnum (c) || c == '_')))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6104 *sval++ = c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6105 *sval = 0;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6106 if (*s < end)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6107 *s = *s - 1;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6108 c = XBM_TK_IDENT;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6111 return c;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6112 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6113
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 /* Replacement for XReadBitmapFileData which isn't available under old
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6116 X versions. CONTENTS is a pointer to a buffer to parse; END is the
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6117 buffer's end. Set *WIDTH and *HEIGHT to the width and height of
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6118 the image. Return in *DATA the bitmap data allocated with xmalloc.
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6119 Value is non-zero if successful. DATA null means just test if
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6120 CONTENTS looks like an im-memory XBM file. */
24994
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 static int
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6123 xbm_read_bitmap_data (contents, end, width, height, data)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6124 char *contents, *end;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6125 int *width, *height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6126 unsigned char **data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6127 {
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6128 char *s = contents;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6129 char buffer[BUFSIZ];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6130 int padding_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6131 int v10 = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6132 int bytes_per_line, i, nbytes;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6133 unsigned char *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6134 int value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6135 int LA1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6136
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6137 #define match() \
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6138 LA1 = xbm_scan (&s, end, buffer, &value)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6139
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6140 #define expect(TOKEN) \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6141 if (LA1 != (TOKEN)) \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6142 goto failure; \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6143 else \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6144 match ()
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 #define expect_ident(IDENT) \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6147 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
6148 match (); \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6149 else \
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6150 goto failure
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6151
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6152 *width = *height = -1;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6153 if (data)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6154 *data = NULL;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6155 LA1 = xbm_scan (&s, end, buffer, &value);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6156
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6157 /* 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
6158 while (LA1 == '#')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6159 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6160 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6161 expect_ident ("define");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6162 expect (XBM_TK_IDENT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6163
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6164 if (LA1 == XBM_TK_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6165 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6166 char *p = strrchr (buffer, '_');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6167 p = p ? p + 1 : buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6168 if (strcmp (p, "width") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6169 *width = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6170 else if (strcmp (p, "height") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6171 *height = value;
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 expect (XBM_TK_NUMBER);
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6176 if (*width < 0 || *height < 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6177 goto failure;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6178 else if (data == NULL)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6179 goto success;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6180
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6181 /* Parse bits. Must start with `static'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6182 expect_ident ("static");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6183 if (LA1 == XBM_TK_IDENT)
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 if (strcmp (buffer, "unsigned") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6186 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6187 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6188 expect_ident ("char");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6189 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6190 else if (strcmp (buffer, "short") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6191 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6192 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6193 v10 = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6194 if (*width % 16 && *width % 16 < 9)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6195 padding_p = 1;
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 else if (strcmp (buffer, "char") == 0)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6198 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6199 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6200 goto failure;
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 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6203 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6204
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6205 expect (XBM_TK_IDENT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6206 expect ('[');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6207 expect (']');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6208 expect ('=');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6209 expect ('{');
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6210
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6211 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
6212 nbytes = bytes_per_line * *height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6213 p = *data = (char *) xmalloc (nbytes);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6214
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6215 if (v10)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6216 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6217 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
6218 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6219 int val = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6220 expect (XBM_TK_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6221
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6222 *p++ = val;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6223 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
6224 *p++ = value >> 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6225
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6226 if (LA1 == ',' || LA1 == '}')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6227 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6228 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6229 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6230 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6231 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6232 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6233 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6234 for (i = 0; i < nbytes; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6235 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6236 int val = value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6237 expect (XBM_TK_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6238
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6239 *p++ = val;
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 if (LA1 == ',' || LA1 == '}')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6242 match ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6243 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6244 goto failure;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6245 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6246 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6247
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6248 success:
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6249 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6250
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6251 failure:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6252
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6253 if (data && *data)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6254 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6255 xfree (*data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6256 *data = NULL;
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 return 0;
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 #undef match
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6261 #undef expect
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6262 #undef expect_ident
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6265
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6266 /* Load XBM image IMG which will be displayed on frame F from buffer
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6267 CONTENTS. END is the end of the buffer. Value is non-zero if
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6268 successful. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6269
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6270 static int
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6271 xbm_load_image (f, img, contents, end)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6272 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6273 struct image *img;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6274 char *contents, *end;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6275 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6276 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6277 unsigned char *data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6278 int success_p = 0;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6279
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6280 rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6281 if (rc)
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 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
6284 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
6285 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
6286 Lisp_Object value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6287
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6288 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
6289
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6290 /* 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
6291 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
6292 if (!NILP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6293 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
6294
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6295 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
6296 if (!NILP (value))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6297 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
6298
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6299 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6300 img->pixmap
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6301 = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6302 FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6303 data,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6304 img->width, img->height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6305 foreground, background,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6306 depth);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6307 xfree (data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6308
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6309 if (img->pixmap == 0)
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 x_clear_image (f, img);
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6312 image_error ("Unable to create X pixmap for `%s'", img->spec, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6313 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6314 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6315 success_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6316
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6317 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6318 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6319 else
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
6320 image_error ("Error loading XBM image `%s'", img->spec, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6321
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6322 return success_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6323 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6324
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6325
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6326 /* Value is non-zero if DATA looks like an in-memory XBM file. */
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6327
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6328 static int
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6329 xbm_file_p (data)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6330 Lisp_Object data;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6331 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6332 int w, h;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6333 return (STRINGP (data)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6334 && xbm_read_bitmap_data (XSTRING (data)->data,
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6335 (XSTRING (data)->data
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6336 + STRING_BYTES (XSTRING (data))),
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6337 &w, &h, NULL));
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6338 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6339
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6340
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6341 /* 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
6342 non-zero if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6343
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6344 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6345 xbm_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6346 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6347 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6348 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6349 int success_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6350 Lisp_Object file_name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6351
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6352 xassert (xbm_image_p (img->spec));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6353
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6354 /* 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
6355 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
6356 if (STRINGP (file_name))
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6357 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6358 Lisp_Object file;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6359 char *contents;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6360 int size;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6361 struct gcpro gcpro1;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6362
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6363 file = x_find_image_file (file_name);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6364 GCPRO1 (file);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6365 if (!STRINGP (file))
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6366 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6367 image_error ("Cannot find image file `%s'", file_name, Qnil);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6368 UNGCPRO;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6369 return 0;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6370 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6371
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6372 contents = slurp_file (XSTRING (file)->data, &size);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6373 if (contents == NULL)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6374 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6375 image_error ("Error loading XBM image `%s'", img->spec, Qnil);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6376 UNGCPRO;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6377 return 0;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6378 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6379
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6380 success_p = xbm_load_image (f, img, contents, contents + size);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6381 UNGCPRO;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6382 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6383 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6384 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6385 struct image_keyword fmt[XBM_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6386 Lisp_Object data;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6387 unsigned char *bitmap_data;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6388 int depth;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6389 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
6390 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
6391 char *bits;
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6392 int parsed_p, height, width;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6393 int in_memory_file_p = 0;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6394
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6395 /* See if data looks like an in-memory XBM file. */
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6396 data = image_spec_value (img->spec, QCdata, NULL);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6397 in_memory_file_p = xbm_file_p (data);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6398
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6399 /* Parse the image specification. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6400 bcopy (xbm_format, fmt, sizeof fmt);
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
6401 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6402 xassert (parsed_p);
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 /* Get specified width, and height. */
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6405 if (!in_memory_file_p)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6406 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6407 img->width = XFASTINT (fmt[XBM_WIDTH].value);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6408 img->height = XFASTINT (fmt[XBM_HEIGHT].value);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6409 xassert (img->width > 0 && img->height > 0);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6410 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6411
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6412 BLOCK_INPUT;
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 /* 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
6415 if (fmt[XBM_FOREGROUND].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6416 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
6417 foreground);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6418 if (fmt[XBM_BACKGROUND].count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6419 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
6420 background);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6421
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6422 if (in_memory_file_p)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6423 success_p = xbm_load_image (f, img, XSTRING (data)->data,
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6424 (XSTRING (data)->data
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6425 + STRING_BYTES (XSTRING (data))));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6426 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6427 {
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6428 if (VECTORP (data))
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6429 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6430 int i;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6431 char *p;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6432 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6433
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6434 p = bits = (char *) alloca (nbytes * img->height);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6435 for (i = 0; i < img->height; ++i, p += nbytes)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6436 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6437 Lisp_Object line = XVECTOR (data)->contents[i];
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6438 if (STRINGP (line))
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6439 bcopy (XSTRING (line)->data, p, nbytes);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6440 else
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6441 bcopy (XBOOL_VECTOR (line)->data, p, nbytes);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6442 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6443 }
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6444 else if (STRINGP (data))
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6445 bits = XSTRING (data)->data;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6446 else
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6447 bits = XBOOL_VECTOR (data)->data;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6448
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6449 /* Create the pixmap. */
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6450 depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6451 img->pixmap
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6452 = XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6453 FRAME_X_WINDOW (f),
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6454 bits,
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6455 img->width, img->height,
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6456 foreground, background,
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6457 depth);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6458 if (img->pixmap)
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6459 success_p = 1;
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6460 else
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6461 {
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6462 image_error ("Unable to create pixmap for XBM image `%s'",
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6463 img->spec, Qnil);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6464 x_clear_image (f, img);
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
6465 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6466 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6467
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6468 UNBLOCK_INPUT;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6471 return success_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6472 }
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6475
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6476 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6477 XPM images
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6478 ***********************************************************************/
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 HAVE_XPM
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6481
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6482 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
6483 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
6484 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
6485
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6486 #include "X11/xpm.h"
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6487
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6488 /* 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
6489
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6490 Lisp_Object Qxpm;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6491
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6492 /* 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
6493
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6494 enum xpm_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6495 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6496 XPM_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6497 XPM_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6498 XPM_DATA,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6499 XPM_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6500 XPM_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6501 XPM_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6502 XPM_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6503 XPM_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6504 XPM_COLOR_SYMBOLS,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6505 XPM_LAST
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6508 /* 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
6509 of valid XPM image specifications. */
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 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
6512 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6513 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6514 {":file", IMAGE_STRING_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6515 {":data", IMAGE_STRING_VALUE, 0},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
6516 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6517 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6518 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6519 {":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
6520 {":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
6521 {":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
6522 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6523
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6524 /* Structure describing the image type XBM. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6525
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6526 static struct image_type xpm_type =
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 &Qxpm,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6529 xpm_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6530 xpm_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6531 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6532 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6533 };
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6536 /* 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
6537 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
6538 cdr are strings. */
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 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6541 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
6542 Lisp_Object color_symbols;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6543 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6544 while (CONSP (color_symbols))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6545 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6546 Lisp_Object sym = XCAR (color_symbols);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6547 if (!CONSP (sym)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6548 || !STRINGP (XCAR (sym))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6549 || !STRINGP (XCDR (sym)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6550 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6551 color_symbols = XCDR (color_symbols);
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6554 return NILP (color_symbols);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6555 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6556
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6557
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6558 /* 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
6559
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6560 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6561 xpm_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6562 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6563 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6564 struct image_keyword fmt[XPM_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6565 bcopy (xpm_format, fmt, sizeof fmt);
26401
9457656ded8b (QCuser_data): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 26304
diff changeset
6566 return (parse_image_spec (object, fmt, XPM_LAST, Qxpm)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6567 /* 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
6568 && 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
6569 /* 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
6570 whose car and cdr are strings. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6571 && (fmt[XPM_COLOR_SYMBOLS].count == 0
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
6572 || xpm_valid_color_symbols_p (fmt[XPM_COLOR_SYMBOLS].value)));
24994
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
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 /* 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
6577 non-zero if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6578
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6579 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6580 xpm_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6581 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6582 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6583 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6584 int rc, i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6585 XpmAttributes attrs;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6586 Lisp_Object specified_file, color_symbols;
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 /* 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
6589 close colors. Return colors allocated. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6590 bzero (&attrs, sizeof attrs);
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
6591 attrs.visual = FRAME_X_VISUAL (f);
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
6592 attrs.colormap = FRAME_X_COLORMAP (f);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6593 attrs.valuemask |= XpmVisual;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
6594 attrs.valuemask |= XpmColormap;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6595 attrs.valuemask |= XpmReturnAllocPixels;
25200
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
6596 #ifdef XpmAllocCloseColors
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6597 attrs.alloc_close_colors = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6598 attrs.valuemask |= XpmAllocCloseColors;
25200
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
6599 #else
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
6600 attrs.closeness = 600;
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
6601 attrs.valuemask |= XpmCloseness;
8ab4da818dc0 (xpm_load) [!XpmAllocCloseColors]:
Richard M. Stallman <rms@gnu.org>
parents: 25153
diff changeset
6602 #endif
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6603
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6604 /* 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
6605 these to `attrs'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6606 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
6607 if (CONSP (color_symbols))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6608 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6609 Lisp_Object tail;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6610 XpmColorSymbol *xpm_syms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6611 int i, size;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6612
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6613 attrs.valuemask |= XpmColorSymbols;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6614
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6615 /* Count number of symbols. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6616 attrs.numsymbols = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6617 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
6618 ++attrs.numsymbols;
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 /* Allocate an XpmColorSymbol array. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6621 size = attrs.numsymbols * sizeof *xpm_syms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6622 xpm_syms = (XpmColorSymbol *) alloca (size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6623 bzero (xpm_syms, size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6624 attrs.colorsymbols = xpm_syms;
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 /* Fill the color symbol array. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6627 for (tail = color_symbols, i = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6628 CONSP (tail);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6629 ++i, tail = XCDR (tail))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6630 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6631 Lisp_Object name = XCAR (XCAR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6632 Lisp_Object color = XCDR (XCAR (tail));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6633 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
6634 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
6635 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
6636 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
6637 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6638 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6639
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6640 /* 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
6641 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
6642 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6643 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
6644 if (STRINGP (specified_file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6645 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6646 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
6647 if (!STRINGP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6648 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
6649 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
6650 UNBLOCK_INPUT;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6651 return 0;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6654 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
6655 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
6656 &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6657 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6658 else
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 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
6661 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
6662 XSTRING (buffer)->data,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6663 &img->pixmap, &img->mask,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6664 &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6665 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6666 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6667
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6668 if (rc == XpmSuccess)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6669 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6670 /* Remember allocated colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6671 img->ncolors = attrs.nalloc_pixels;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6672 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
6673 * sizeof *img->colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6674 for (i = 0; i < attrs.nalloc_pixels; ++i)
28597
6bbcb7e674b1 (xpm_load) [DEBUG_X_COLORS]: Register colors.
Gerd Moellmann <gerd@gnu.org>
parents: 28464
diff changeset
6675 {
6bbcb7e674b1 (xpm_load) [DEBUG_X_COLORS]: Register colors.
Gerd Moellmann <gerd@gnu.org>
parents: 28464
diff changeset
6676 img->colors[i] = attrs.alloc_pixels[i];
6bbcb7e674b1 (xpm_load) [DEBUG_X_COLORS]: Register colors.
Gerd Moellmann <gerd@gnu.org>
parents: 28464
diff changeset
6677 #ifdef DEBUG_X_COLORS
6bbcb7e674b1 (xpm_load) [DEBUG_X_COLORS]: Register colors.
Gerd Moellmann <gerd@gnu.org>
parents: 28464
diff changeset
6678 register_color (img->colors[i]);
6bbcb7e674b1 (xpm_load) [DEBUG_X_COLORS]: Register colors.
Gerd Moellmann <gerd@gnu.org>
parents: 28464
diff changeset
6679 #endif
6bbcb7e674b1 (xpm_load) [DEBUG_X_COLORS]: Register colors.
Gerd Moellmann <gerd@gnu.org>
parents: 28464
diff changeset
6680 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6681
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6682 img->width = attrs.width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6683 img->height = attrs.height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6684 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
6685
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6686 /* 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
6687 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6688 XpmFreeAttributes (&attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6689 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6690 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6691 else
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 switch (rc)
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 case XpmOpenFailed:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6696 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
6697 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6698
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6699 case XpmFileInvalid:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6700 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
6701 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6702
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6703 case XpmNoMemory:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6704 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
6705 break;
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 case XpmColorFailed:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6708 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
6709 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6710
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6711 default:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6712 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
6713 break;
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 }
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 return rc == XpmSuccess;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6718 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6719
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6720 #endif /* HAVE_XPM != 0 */
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 Color table
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6725 ***********************************************************************/
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 /* 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
6728
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6729 struct ct_color
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6730 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6731 int r, g, b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6732 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6733
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6734 /* Next in color table collision list. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6735 struct ct_color *next;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6738 /* 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
6739
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6740 #define CT_SIZE 101
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 /* 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
6743
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6744 #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
6745
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6746 /* The color hash table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6747
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6748 struct ct_color **ct_table;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6749
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6750 /* 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
6751
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6752 int ct_colors_allocated;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6753
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6754 /* Function prototypes. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6755
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6756 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
6757 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
6758 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
6759 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
6760 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
6761
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6762
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6763 /* Initialize the color table. */
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 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6766 init_color_table ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6767 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6768 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
6769 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
6770 bzero (ct_table, size);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6771 ct_colors_allocated = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6772 }
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6775 /* 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
6776
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6777 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6778 free_color_table ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6779 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6780 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6781 struct ct_color *p, *next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6782
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6783 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
6784 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
6785 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6786 next = p->next;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6787 xfree (p);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6788 }
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 xfree (ct_table);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6791 ct_table = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6792 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6793
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6794
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6795 /* 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
6796 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
6797 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
6798 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
6799
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6800 static unsigned long
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6801 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
6802 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6803 int r, g, b;
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 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
6806 int i = hash % CT_SIZE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6807 struct ct_color *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6808
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6809 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
6810 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
6811 break;
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 if (p == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6814 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6815 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6816 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6817 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6818
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6819 color.red = r;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6820 color.green = g;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6821 color.blue = b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6822
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6823 BLOCK_INPUT;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
6824 cmap = FRAME_X_COLORMAP (f);
25528
b5dd1bafd001 Include math.h. Add extern declaration for atof in case
Gerd Moellmann <gerd@gnu.org>
parents: 25511
diff changeset
6825 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
6826 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6827
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6828 if (rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6829 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6830 ++ct_colors_allocated;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6831
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6832 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
6833 p->r = r;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6834 p->g = g;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6835 p->b = b;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6836 p->pixel = color.pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6837 p->next = ct_table[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6838 ct_table[i] = p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6839 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6840 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6841 return FRAME_FOREGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6842 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6843
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6844 return p->pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6845 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6846
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6847
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6848 /* 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
6849 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
6850
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6851 static unsigned long
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6852 lookup_pixel_color (f, pixel)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6853 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6854 unsigned long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6855 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6856 int i = pixel % CT_SIZE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6857 struct ct_color *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6858
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6859 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
6860 if (p->pixel == pixel)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6861 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6862
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6863 if (p == NULL)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6864 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6865 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6866 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6867 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6868
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6869 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6870
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
6871 cmap = FRAME_X_COLORMAP (f);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6872 color.pixel = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6873 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
6874 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
6875 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6876
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6877 if (rc)
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 ++ct_colors_allocated;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6880
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6881 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
6882 p->r = color.red;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6883 p->g = color.green;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6884 p->b = color.blue;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6885 p->pixel = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6886 p->next = ct_table[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6887 ct_table[i] = p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6888 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6889 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6890 return FRAME_FOREGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6891 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6892
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6893 return p->pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6894 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6895
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6896
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6897 /* 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
6898 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
6899
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6900 static unsigned long *
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6901 colors_in_color_table (n)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6902 int *n;
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 int i, j;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6905 struct ct_color *p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6906 unsigned long *colors;
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 if (ct_colors_allocated == 0)
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 *n = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6911 colors = NULL;
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 else
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 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
6916 * sizeof *colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6917 *n = ct_colors_allocated;
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 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
6920 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
6921 colors[j++] = p->pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6922 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6923
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6924 return colors;
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
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
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 Algorithms
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6933 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
6934 int, XImage *, int));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6935 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
6936 XColor *, int, XImage *, int));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6937
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6938
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6939 /* 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
6940 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
6941 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
6942
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6943 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6944 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
6945 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6946 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6947 XColor *colors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6948 int width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6949 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6950 int y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6951 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6952 int x;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6953
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6954 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6955 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
6956
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6957 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
6958 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6959
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6960
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6961 /* 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
6962 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
6963 working on. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6964
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6965 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6966 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
6967 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6968 long *pixels;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6969 int width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6970 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6971 int y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6972 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6973 int x;
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 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6976 XPutPixel (ximg, x, y, pixels[x]);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6977 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6978
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 /* 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
6981 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
6982 to draw disabled buttons, for example. */
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 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6985 x_laplace (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6986 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6987 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6988 {
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
6989 Colormap cmap = FRAME_X_COLORMAP (f);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6990 XImage *ximg, *oimg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6991 XColor *in[3];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6992 long *out;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6993 Pixmap pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6994 int x, y, i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6995 long pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6996 int in_y, out_y, rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6997 int mv2 = 45000;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6998
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
6999 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7000
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7001 /* Get the X image IMG->pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7002 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
7003 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
7004
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7005 /* 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
7006 for (i = 0; i < 3; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7007 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
7008 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
7009
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7010 /* Create an X image for output. */
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7011 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 0,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7012 &oimg, &pixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7013
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7014 /* Fill first two rows. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7015 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
7016 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
7017 in_y = 2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7018
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7019 /* Write first row, all zeros. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7020 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7021 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
7022 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
7023 out[x] = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7024 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
7025 out_y = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7026
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7027 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
7028 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7029 int rowa = y % 3;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7030 int rowb = (y + 2) % 3;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7031
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7032 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
7033
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7034 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
7035 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7036 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
7037 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
7038 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
7039
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7040 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
7041 b & 0xffff);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7042 }
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 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
7045 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7046
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7047 /* Write last line, all zeros. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7048 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
7049 out[x] = pixel;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7050 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
7051
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7052 /* 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
7053 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7054 x_clear_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7055
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7056 /* 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
7057 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
7058 x_destroy_x_image (oimg);
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 /* 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
7061 img->pixmap = pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7062 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
7063 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7064
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7065 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7066 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7067
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7068
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7069 /* 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
7070 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
7071 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
7072 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
7073 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
7074 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
7075
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7076 static int
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7077 x_build_heuristic_mask (f, img, how)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7078 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7079 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7080 Lisp_Object how;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7081 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7082 Display *dpy = FRAME_X_DISPLAY (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7083 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
7084 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
7085 unsigned long bg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7086
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7087 BLOCK_INPUT;
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 /* Create an image and pixmap serving as mask. */
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7090 rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7091 &mask_img, &img->mask);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7092 if (!rc)
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 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7095 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7096 }
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 /* 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
7099 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
7100 ~0, ZPixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7101
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7102 /* 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
7103 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
7104 heuristically. */
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7105 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
7106
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7107 if (CONSP (how))
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7108 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7109 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
7110
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7111 while (i < 3
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7112 && CONSP (how)
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7113 && NATNUMP (XCAR (how)))
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7114 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7115 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
7116 how = XCDR (how);
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7117 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7118
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7119 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
7120 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7121 char color_name[30];
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7122 XColor exact, color;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7123 Colormap cmap;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7124
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7125 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
7126
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
7127 cmap = FRAME_X_COLORMAP (f);
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7128 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
7129 {
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7130 bg = color.pixel;
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7131 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
7132 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7133 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7134 }
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7135
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
7136 if (look_at_corners_p)
24994
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 unsigned long corners[4];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7139 int i, best_count;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7140
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7141 /* 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
7142 corners[0] = XGetPixel (ximg, 0, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7143 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
7144 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
7145 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
7146
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7147 /* 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
7148 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
7149 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7150 int j, n;
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 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
7153 if (corners[i] == corners[j])
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7154 ++n;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7155
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7156 if (n > best_count)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7157 bg = corners[i], best_count = n;
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 }
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 /* 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
7162 from the background color bg. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7163 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
7164 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
7165 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
7166
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7167 /* Put mask_img into img->mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7168 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
7169 x_destroy_x_image (mask_img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7170 XDestroyImage (ximg);
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 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7173 return 1;
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
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
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 PBM (mono, gray, color)
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7182 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
7183 static int pbm_load P_ ((struct frame *f, struct image *img));
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7184 static int pbm_scan_number P_ ((unsigned char **, unsigned char *));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7185
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7186 /* 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
7187
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7188 Lisp_Object Qpbm;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7189
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7190 /* 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
7191
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7192 enum pbm_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7193 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7194 PBM_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7195 PBM_FILE,
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7196 PBM_DATA,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7197 PBM_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7198 PBM_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7199 PBM_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7200 PBM_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7201 PBM_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7202 PBM_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7203 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7204
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7205 /* 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
7206 of valid user-defined image specifications. */
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 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
7209 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7210 {":type", IMAGE_SYMBOL_VALUE, 1},
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7211 {":file", IMAGE_STRING_VALUE, 0},
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7212 {":data", IMAGE_STRING_VALUE, 0},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
7213 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7214 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7215 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7216 {":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
7217 {":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
7218 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7219
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7220 /* Structure describing the image type `pbm'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7221
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7222 static struct image_type pbm_type =
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 &Qpbm,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7225 pbm_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7226 pbm_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7227 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7228 NULL
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7231
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7232 /* 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
7233
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7234 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7235 pbm_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7236 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7237 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7238 struct image_keyword fmt[PBM_LAST];
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 bcopy (pbm_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7241
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
7242 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7243 return 0;
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7244
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7245 /* Must specify either :data or :file. */
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7246 return fmt[PBM_DATA].count + fmt[PBM_FILE].count == 1;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7247 }
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7248
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7249
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7250 /* Scan a decimal number from *S and return it. Advance *S while
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7251 reading the number. END is the end of the string. Value is -1 at
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7252 end of input. */
24994
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 static int
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7255 pbm_scan_number (s, end)
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7256 unsigned char **s, *end;
24994
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 int c, val = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7259
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7260 while (*s < end)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7261 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7262 /* Skip white-space. */
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7263 while (*s < end && (c = *(*s)++, isspace (c)))
24994
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7266 if (c == '#')
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7267 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7268 /* Skip comment to end of line. */
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7269 while (*s < end && (c = *(*s)++, c != '\n'))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7270 ;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7271 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7272 else if (isdigit (c))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7273 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7274 /* Read decimal number. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7275 val = c - '0';
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7276 while (*s < end && (c = *(*s)++, isdigit (c)))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7277 val = 10 * val + c - '0';
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7278 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7279 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7280 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7281 break;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7284 return val;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7287
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7288 /* 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
7289
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7290 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7291 pbm_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7292 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7293 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7294 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7295 int raw_p, x, y;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
7296 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
7297 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7298 Lisp_Object file, specified_file;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7299 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
7300 struct gcpro gcpro1;
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7301 unsigned char *contents = NULL;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7302 unsigned char *end, *p;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7303 int size;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7304
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7305 specified_file = image_spec_value (img->spec, QCfile, NULL);
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7306 file = Qnil;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7307 GCPRO1 (file);
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7308
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7309 if (STRINGP (specified_file))
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7310 {
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7311 file = x_find_image_file (specified_file);
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7312 if (!STRINGP (file))
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7313 {
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7314 image_error ("Cannot find image file `%s'", specified_file, Qnil);
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7315 UNGCPRO;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7316 return 0;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7317 }
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7318
28747
6f90293e6ccb (slurp_file): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28690
diff changeset
7319 contents = slurp_file (XSTRING (file)->data, &size);
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7320 if (contents == NULL)
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7321 {
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7322 image_error ("Error reading `%s'", file, Qnil);
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7323 UNGCPRO;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7324 return 0;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7325 }
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7326
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7327 p = contents;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7328 end = contents + size;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7329 }
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7330 else
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7331 {
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7332 Lisp_Object data;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7333 data = image_spec_value (img->spec, QCdata, NULL);
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7334 p = XSTRING (data)->data;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7335 end = p + STRING_BYTES (XSTRING (data));
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7336 }
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7337
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7338 /* Check magic number. */
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7339 if (end - p < 2 || *p++ != 'P')
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7340 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7341 image_error ("Not a PBM image: `%s'", img->spec, Qnil);
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7342 error:
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7343 xfree (contents);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7344 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7345 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7346 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7347
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7348 switch (*p++)
24994
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 case '1':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7351 raw_p = 0, type = PBM_MONO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7352 break;
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 case '2':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7355 raw_p = 0, type = PBM_GRAY;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7356 break;
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 case '3':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7359 raw_p = 0, type = PBM_COLOR;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7360 break;
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 case '4':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7363 raw_p = 1, type = PBM_MONO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7364 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7365
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7366 case '5':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7367 raw_p = 1, type = PBM_GRAY;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7368 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7369
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7370 case '6':
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7371 raw_p = 1, type = PBM_COLOR;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7372 break;
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 default:
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7375 image_error ("Not a PBM image: `%s'", img->spec, Qnil);
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7376 goto error;
24994
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7379 /* 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
7380 starting with `#' up to the end of a line are ignored. */
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7381 width = pbm_scan_number (&p, end);
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7382 height = pbm_scan_number (&p, end);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7383
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7384 if (type != PBM_MONO)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7385 {
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7386 max_color_idx = pbm_scan_number (&p, end);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7387 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
7388 max_color_idx = 255;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7389 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7390
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7391 if (width < 0
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7392 || height < 0
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7393 || (type != PBM_MONO && max_color_idx < 0))
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7394 goto error;
24994
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 BLOCK_INPUT;
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7397 if (!x_create_x_image_and_pixmap (f, width, height, 0,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7398 &ximg, &img->pixmap))
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 UNBLOCK_INPUT;
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7401 goto error;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7402 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7403
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7404 /* Initialize the color hash table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7405 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7406
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7407 if (type == PBM_MONO)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7408 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7409 int c = 0, g;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7410
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7411 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7412 for (x = 0; x < width; ++x)
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 if (raw_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7415 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7416 if ((x & 7) == 0)
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7417 c = *p++;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7418 g = c & 0x80;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7419 c <<= 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7420 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7421 else
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7422 g = pbm_scan_number (&p, end);
24994
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 XPutPixel (ximg, x, y, (g
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7425 ? FRAME_FOREGROUND_PIXEL (f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7426 : FRAME_BACKGROUND_PIXEL (f)));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7427 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7428 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7429 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7430 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7431 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7432 for (x = 0; x < width; ++x)
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 int r, g, b;
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 if (type == PBM_GRAY)
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7437 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7438 else if (raw_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7439 {
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7440 r = *p++;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7441 g = *p++;
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7442 b = *p++;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7443 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7444 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7445 {
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7446 r = pbm_scan_number (&p, end);
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7447 g = pbm_scan_number (&p, end);
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7448 b = pbm_scan_number (&p, end);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7449 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7450
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7451 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
7452 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7453 xfree (ximg->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7454 ximg->data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7455 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7456 UNBLOCK_INPUT;
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7457 image_error ("Invalid pixel value in image `%s'",
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7458 img->spec, Qnil);
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7459 goto error;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7460 }
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 /* 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
7463 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
7464 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
7465 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
7466 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
7467 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
7468 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7469 }
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 /* 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
7472 free the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7473 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
7474 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7475
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7476 /* Put the image into a pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7477 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
7478 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7479 UNBLOCK_INPUT;
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 img->width = width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7482 img->height = height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7483
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7484 UNGCPRO;
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7485 xfree (contents);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7486 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7487 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7488
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7489
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 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7492 PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7493 ***********************************************************************/
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 #if HAVE_PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7496
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7497 #include <png.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7498
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7499 /* Function prototypes. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7500
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7501 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
7502 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
7503
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7504 /* 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
7505
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7506 Lisp_Object Qpng;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7507
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7508 /* 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
7509
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7510 enum png_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7511 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7512 PNG_TYPE,
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7513 PNG_DATA,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7514 PNG_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7515 PNG_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7516 PNG_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7517 PNG_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7518 PNG_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7519 PNG_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7520 PNG_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7521 };
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 /* 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
7524 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7525
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7526 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
7527 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7528 {":type", IMAGE_SYMBOL_VALUE, 1},
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7529 {":data", IMAGE_STRING_VALUE, 0},
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7530 {":file", IMAGE_STRING_VALUE, 0},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
7531 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7532 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7533 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7534 {":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
7535 {":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
7536 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7537
26032
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
7538 /* Structure describing the image type `png'. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7539
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7540 static struct image_type png_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7541 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7542 &Qpng,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7543 png_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7544 png_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7545 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7546 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7547 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7548
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7549
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7550 /* 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
7551
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7552 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7553 png_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7554 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7555 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7556 struct image_keyword fmt[PNG_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7557 bcopy (png_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7558
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
7559 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7560 return 0;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7561
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7562 /* Must specify either the :data or :file keyword. */
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
7563 return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7564 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7565
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7566
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7567 /* 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
7568 is initialized. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7569
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7570 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7571 my_png_error (png_ptr, msg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7572 png_struct *png_ptr;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7573 char *msg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7574 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7575 xassert (png_ptr != NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7576 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
7577 longjmp (png_ptr->jmpbuf, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7578 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7579
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7580
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7581 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7582 my_png_warning (png_ptr, msg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7583 png_struct *png_ptr;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7584 char *msg;
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 xassert (png_ptr != NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7587 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
7588 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7589
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7590 /* Memory source for PNG decoding. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7591
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7592 struct png_memory_storage
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7593 {
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7594 unsigned char *bytes; /* The data */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7595 size_t len; /* How big is it? */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7596 int index; /* Where are we? */
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7597 };
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7598
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7599
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7600 /* Function set as reader function when reading PNG image from memory.
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7601 PNG_PTR is a pointer to the PNG control structure. Copy LENGTH
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7602 bytes from the input to DATA. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7603
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7604 static void
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7605 png_read_from_memory (png_ptr, data, length)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7606 png_structp png_ptr;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7607 png_bytep data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7608 png_size_t length;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7609 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7610 struct png_memory_storage *tbr
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7611 = (struct png_memory_storage *) png_get_io_ptr (png_ptr);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7612
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7613 if (length > tbr->len - tbr->index)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7614 png_error (png_ptr, "Read error");
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7615
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7616 bcopy (tbr->bytes + tbr->index, data, length);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7617 tbr->index = tbr->index + length;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7618 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7619
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7620 /* 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
7621 successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7622
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7623 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7624 png_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7625 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7626 struct image *img;
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 Lisp_Object file, specified_file;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7629 Lisp_Object specified_data;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
7630 int x, y, i;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7631 XImage *ximg, *mask_img = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7632 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7633 png_struct *png_ptr = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7634 png_info *info_ptr = NULL, *end_info = NULL;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7635 FILE *fp = NULL;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7636 png_byte sig[8];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7637 png_byte *pixels = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7638 png_byte **rows = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7639 png_uint_32 width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7640 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
7641 png_byte channels;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7642 png_uint_32 row_bytes;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7643 int transparent_p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7644 char *gamma_str;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7645 double screen_gamma, image_gamma;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7646 int intent;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7647 struct png_memory_storage tbr; /* Data to be read */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7648
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7649 /* Find out what file to load. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7650 specified_file = image_spec_value (img->spec, QCfile, NULL);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7651 specified_data = image_spec_value (img->spec, QCdata, NULL);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7652 file = Qnil;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7653 GCPRO1 (file);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7654
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7655 if (NILP (specified_data))
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7656 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7657 file = x_find_image_file (specified_file);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7658 if (!STRINGP (file))
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7659 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7660 image_error ("Cannot find image file `%s'", specified_file, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7661 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7662 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7663 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7664
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7665 /* Open the image file. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7666 fp = fopen (XSTRING (file)->data, "rb");
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7667 if (!fp)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7668 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7669 image_error ("Cannot open image file `%s'", file, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7670 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7671 fclose (fp);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7672 return 0;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7673 }
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7674
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7675 /* Check PNG signature. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7676 if (fread (sig, 1, sizeof sig, fp) != sizeof sig
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7677 || !png_check_sig (sig, sizeof sig))
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7678 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7679 image_error ("Not a PNG file: `%s'", file, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7680 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7681 fclose (fp);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7682 return 0;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7683 }
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7684 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7685 else
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7686 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7687 /* Read from memory. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7688 tbr.bytes = XSTRING (specified_data)->data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7689 tbr.len = STRING_BYTES (XSTRING (specified_data));
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7690 tbr.index = 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7691
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7692 /* Check PNG signature. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7693 if (tbr.len < sizeof sig
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7694 || !png_check_sig (tbr.bytes, sizeof sig))
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7695 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7696 image_error ("Not a PNG image: `%s'", img->spec, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7697 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7698 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7699 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7700
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7701 /* Need to skip past the signature. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7702 tbr.bytes += sizeof (sig);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7703 }
24994
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 /* 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
7706 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
7707 my_png_error, my_png_warning);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7708 if (!png_ptr)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7709 {
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7710 if (fp) fclose (fp);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7711 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7712 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7713 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7714
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7715 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
7716 if (!info_ptr)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7717 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7718 png_destroy_read_struct (&png_ptr, NULL, NULL);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7719 if (fp) fclose (fp);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7720 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7721 return 0;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7724 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
7725 if (!end_info)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7726 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7727 png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7728 if (fp) fclose (fp);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7729 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7730 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7731 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7732
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7733 /* 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
7734 detects an error. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7735 if (setjmp (png_ptr->jmpbuf))
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 error:
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7738 if (png_ptr)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7739 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
7740 xfree (pixels);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7741 xfree (rows);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7742 if (fp) fclose (fp);
24994
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 /* Read image info. */
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7748 if (!NILP (specified_data))
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7749 png_set_read_fn (png_ptr, (void *) &tbr, png_read_from_memory);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7750 else
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7751 png_init_io (png_ptr, fp);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
7752
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7753 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
7754 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
7755 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
7756 &interlace_type, NULL, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7757
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7758 /* 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
7759 construct a clipping mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7760 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
7761 transparent_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7762 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7763 transparent_p = 0;
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 /* 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
7766 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
7767 transform other formats into that format. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7768
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7769 /* 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
7770 if (bit_depth == 16)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7771 png_set_strip_16 (png_ptr);
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 /* 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
7774 if available. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7775 png_set_expand (png_ptr);
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 /* Convert grayscale images to RGB. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7778 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
7779 || 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
7780 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
7781
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7782 /* 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
7783 gamma_str = getenv ("SCREEN_GAMMA");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7784 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
7785
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7786 /* 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
7787
26293
65861669b393 (png_load) [PNG_READ_sRGB_SUPPORTED]: Put code using
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
7788 #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7789 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
7790 /* 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
7791 png_set_sRGB (png_ptr, info_ptr, intent);
26293
65861669b393 (png_load) [PNG_READ_sRGB_SUPPORTED]: Put code using
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
7792 else
65861669b393 (png_load) [PNG_READ_sRGB_SUPPORTED]: Put code using
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
7793 #endif
65861669b393 (png_load) [PNG_READ_sRGB_SUPPORTED]: Put code using
Gerd Moellmann <gerd@gnu.org>
parents: 26088
diff changeset
7794 if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7795 /* Image contains gamma information. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7796 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
7797 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7798 /* 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
7799 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
7800
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7801 /* 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
7802 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
7803 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
7804 if (!transparent_p)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7805 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7806 png_color_16 *image_background;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7807
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7808 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
7809 /* 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
7810 combine the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7811 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
7812 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
7813 else
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 /* 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
7816 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
7817 the frame's background instead. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7818 XColor color;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7819 Colormap cmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7820 png_color_16 frame_background;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7821
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7822 BLOCK_INPUT;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
7823 cmap = FRAME_X_COLORMAP (f);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7824 color.pixel = FRAME_BACKGROUND_PIXEL (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7825 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
7826 UNBLOCK_INPUT;
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 bzero (&frame_background, sizeof frame_background);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7829 frame_background.red = color.red;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7830 frame_background.green = color.green;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7831 frame_background.blue = color.blue;
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 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
7834 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
7835 }
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7838 /* Update info structure. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7839 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
7840
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7841 /* 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
7842 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
7843 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
7844 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
7845 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
7846 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
7847 xassert (channels == 3 || channels == 4);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7848
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7849 /* 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
7850 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
7851
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7852 /* Allocate memory for the image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7853 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
7854 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
7855 for (i = 0; i < height; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7856 rows[i] = pixels + i * row_bytes;
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 /* Read the entire image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7859 png_read_image (png_ptr, rows);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7860 png_read_end (png_ptr, info_ptr);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7861 if (fp)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7862 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7863 fclose (fp);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7864 fp = NULL;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
7865 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7866
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7867 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7868
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7869 /* Create the X image and pixmap. */
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7870 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7871 &img->pixmap))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7872 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7873 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7874 goto error;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7877 /* 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
7878 contains an alpha channel. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7879 if (channels == 4
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7880 && !transparent_p
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
7881 && !x_create_x_image_and_pixmap (f, width, height, 1,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7882 &mask_img, &img->mask))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7883 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7884 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7885 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
7886 img->pixmap = 0;
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 goto error;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7889 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7890
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7891 /* 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
7892 init_color_table ();
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 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7895 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7896 png_byte *p = rows[y];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7897
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7898 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7899 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7900 unsigned r, g, b;
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 r = *p++ << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7903 g = *p++ << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7904 b = *p++ << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7905 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
7906
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7907 /* 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
7908 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
7909 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
7910 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
7911 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
7912 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
7913
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7914 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
7915 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
7916 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
7917 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
7918
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7919 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
7920 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
7921 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
7922
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7923 if (channels == 4)
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 if (mask_img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7926 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
7927 ++p;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7928 }
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 }
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 /* Remember colors allocated for this image. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7933 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
7934 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7935
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7936 /* Clean up. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7937 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
7938 xfree (rows);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7939 xfree (pixels);
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 img->width = width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7942 img->height = height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7943
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7944 /* 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
7945 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
7946 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7947
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7948 /* Same for the mask. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7949 if (mask_img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7950 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7951 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
7952 x_destroy_x_image (mask_img);
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 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7956 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7957 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7958 }
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 #endif /* HAVE_PNG != 0 */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7961
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7962
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7963
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7964 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7965 JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7966 ***********************************************************************/
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 #if HAVE_JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7969
25390
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
7970 /* 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
7971 jconfig.h. */
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
7972 #ifdef HAVE_STDLIB_H
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
7973 #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
7974 #undef HAVE_STDLIB_H
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
7975 #endif /* HAVE_STLIB_H */
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
7976
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7977 #include <jpeglib.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7978 #include <jerror.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7979 #include <setjmp.h>
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7980
25390
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
7981 #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
7982 #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
7983 #endif
4404ab9c802b [HAVE_JPEG]: Work around a warning about HAVE_STDLIB_H
Gerd Moellmann <gerd@gnu.org>
parents: 25363
diff changeset
7984
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7985 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
7986 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
7987
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7988 /* 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
7989
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7990 Lisp_Object Qjpeg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7991
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7992 /* 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
7993
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7994 enum jpeg_keyword_index
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 JPEG_TYPE,
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
7997 JPEG_DATA,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7998 JPEG_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
7999 JPEG_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8000 JPEG_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8001 JPEG_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8002 JPEG_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8003 JPEG_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8004 JPEG_LAST
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8007 /* 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
8008 of valid user-defined image specifications. */
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 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
8011 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8012 {":type", IMAGE_SYMBOL_VALUE, 1},
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8013 {":data", IMAGE_STRING_VALUE, 0},
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8014 {":file", IMAGE_STRING_VALUE, 0},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
8015 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8016 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8017 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8018 {":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
8019 {":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
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 /* Structure describing the image type `jpeg'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8023
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8024 static struct image_type jpeg_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8025 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8026 &Qjpeg,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8027 jpeg_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8028 jpeg_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8029 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8030 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8031 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8032
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8033
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8034 /* 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
8035
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8036 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8037 jpeg_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8038 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8039 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8040 struct image_keyword fmt[JPEG_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8041
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8042 bcopy (jpeg_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8043
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
8044 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8045 return 0;
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8046
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
8047 /* Must specify either the :data or :file keyword. */
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
8048 return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1;
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8049 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8050
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8051
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8052 struct my_jpeg_error_mgr
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8053 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8054 struct jpeg_error_mgr pub;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8055 jmp_buf setjmp_buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8056 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8057
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8058
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8059 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8060 my_error_exit (cinfo)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8061 j_common_ptr cinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8062 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8063 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
8064 longjmp (mgr->setjmp_buffer, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8065 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8066
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8067
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8068 /* Init source method for JPEG data source manager. Called by
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8069 jpeg_read_header() before any data is actually read. See
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8070 libjpeg.doc from the JPEG lib distribution. */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8071
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8072 static void
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8073 our_init_source (cinfo)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8074 j_decompress_ptr cinfo;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8075 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8076 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8077
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8078
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8079 /* Fill input buffer method for JPEG data source manager. Called
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8080 whenever more data is needed. We read the whole image in one step,
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8081 so this only adds a fake end of input marker at the end. */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8082
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8083 static boolean
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8084 our_fill_input_buffer (cinfo)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8085 j_decompress_ptr cinfo;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8086 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8087 /* Insert a fake EOI marker. */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8088 struct jpeg_source_mgr *src = cinfo->src;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8089 static JOCTET buffer[2];
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8090
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8091 buffer[0] = (JOCTET) 0xFF;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8092 buffer[1] = (JOCTET) JPEG_EOI;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8093
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8094 src->next_input_byte = buffer;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8095 src->bytes_in_buffer = 2;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8096 return TRUE;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8097 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8098
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8099
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8100 /* Method to skip over NUM_BYTES bytes in the image data. CINFO->src
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8101 is the JPEG data source manager. */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8102
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8103 static void
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8104 our_skip_input_data (cinfo, num_bytes)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8105 j_decompress_ptr cinfo;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8106 long num_bytes;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8107 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8108 struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8109
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8110 if (src)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8111 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8112 if (num_bytes > src->bytes_in_buffer)
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8113 ERREXIT (cinfo, JERR_INPUT_EOF);
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8114
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8115 src->bytes_in_buffer -= num_bytes;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8116 src->next_input_byte += num_bytes;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8117 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8118 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8119
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8120
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8121 /* Method to terminate data source. Called by
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8122 jpeg_finish_decompress() after all data has been processed. */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8123
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8124 static void
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8125 our_term_source (cinfo)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8126 j_decompress_ptr cinfo;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8127 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8128 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8129
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8130
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8131 /* Set up the JPEG lib for reading an image from DATA which contains
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8132 LEN bytes. CINFO is the decompression info structure created for
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8133 reading the image. */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8134
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8135 static void
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8136 jpeg_memory_src (cinfo, data, len)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8137 j_decompress_ptr cinfo;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8138 JOCTET *data;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8139 unsigned int len;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8140 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8141 struct jpeg_source_mgr *src;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8142
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8143 if (cinfo->src == NULL)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8144 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8145 /* First time for this JPEG object? */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8146 cinfo->src = (struct jpeg_source_mgr *)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8147 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8148 sizeof (struct jpeg_source_mgr));
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8149 src = (struct jpeg_source_mgr *) cinfo->src;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8150 src->next_input_byte = data;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8151 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8152
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8153 src = (struct jpeg_source_mgr *) cinfo->src;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8154 src->init_source = our_init_source;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8155 src->fill_input_buffer = our_fill_input_buffer;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8156 src->skip_input_data = our_skip_input_data;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8157 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8158 src->term_source = our_term_source;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8159 src->bytes_in_buffer = len;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8160 src->next_input_byte = data;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8161 }
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8162
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8163
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8164 /* 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
8165 from the JPEG lib. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8166
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8167 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8168 jpeg_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8169 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8170 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8171 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8172 struct jpeg_decompress_struct cinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8173 struct my_jpeg_error_mgr mgr;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8174 Lisp_Object file, specified_file;
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8175 Lisp_Object specified_data;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8176 FILE *fp = NULL;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8177 JSAMPARRAY buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8178 int row_stride, x, y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8179 XImage *ximg = NULL;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
8180 int rc;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8181 unsigned long *colors;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8182 int width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8183 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8184
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8185 /* Open the JPEG file. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8186 specified_file = image_spec_value (img->spec, QCfile, NULL);
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8187 specified_data = image_spec_value (img->spec, QCdata, NULL);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8188 file = Qnil;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8189 GCPRO1 (file);
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8190
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8191 if (NILP (specified_data))
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8192 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8193 file = x_find_image_file (specified_file);
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8194 if (!STRINGP (file))
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8195 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8196 image_error ("Cannot find image file `%s'", specified_file, Qnil);
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8197 UNGCPRO;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8198 return 0;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8199 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8200
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8201 fp = fopen (XSTRING (file)->data, "r");
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8202 if (fp == NULL)
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8203 {
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8204 image_error ("Cannot open `%s'", file, Qnil);
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8205 UNGCPRO;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8206 return 0;
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8207 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8208 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8209
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8210 /* Customize libjpeg's error handling to call my_error_exit when an
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8211 error is detected. This function will perform a longjmp. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8212 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
8213 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
8214
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8215 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
8216 {
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8217 if (rc == 1)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8218 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8219 /* Called from my_error_exit. Display a JPEG error. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8220 char buffer[JMSG_LENGTH_MAX];
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8221 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer);
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8222 image_error ("Error reading JPEG image `%s': %s", img->spec,
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8223 build_string (buffer));
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8224 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8225
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8226 /* Close the input file and destroy the JPEG object. */
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8227 if (fp)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8228 fclose (fp);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8229 jpeg_destroy_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8230
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8231 BLOCK_INPUT;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8232
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8233 /* If we already have an XImage, free that. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8234 x_destroy_x_image (ximg);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8235
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8236 /* Free pixmap and colors. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8237 x_clear_image (f, img);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8238
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8239 UNBLOCK_INPUT;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8240 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8241 return 0;
24994
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8244 /* Create the JPEG decompression object. Let it read from fp.
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8245 Read the JPEG image header. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8246 jpeg_create_decompress (&cinfo);
27053
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8247
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8248 if (NILP (specified_data))
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8249 jpeg_stdio_src (&cinfo, fp);
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8250 else
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8251 jpeg_memory_src (&cinfo, XSTRING (specified_data)->data,
3995eec4287f (enum jpeg_keyword_index): Add JPEG_DATA.
Gerd Moellmann <gerd@gnu.org>
parents: 26980
diff changeset
8252 STRING_BYTES (XSTRING (specified_data)));
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8253
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8254 jpeg_read_header (&cinfo, TRUE);
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 /* Customize decompression so that color quantization will be used.
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8257 Start decompression. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8258 cinfo.quantize_colors = TRUE;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8259 jpeg_start_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8260 width = img->width = cinfo.output_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8261 height = img->height = cinfo.output_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8262
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8263 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8264
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8265 /* Create X image and pixmap. */
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8266 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8267 {
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8268 UNBLOCK_INPUT;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8269 longjmp (mgr.setjmp_buffer, 2);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8270 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8271
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8272 /* Allocate colors. When color quantization is used,
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8273 cinfo.actual_number_of_colors has been set with the number of
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8274 colors generated, and cinfo.colormap is a two-dimensional array
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8275 of color indices in the range 0..cinfo.actual_number_of_colors.
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8276 No more than 255 colors will be generated. */
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8277 {
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8278 int i, ir, ig, ib;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8279
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8280 if (cinfo.out_color_components > 2)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8281 ir = 0, ig = 1, ib = 2;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8282 else if (cinfo.out_color_components > 1)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8283 ir = 0, ig = 1, ib = 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8284 else
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8285 ir = 0, ig = 0, ib = 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8286
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8287 /* Use the color table mechanism because it handles colors that
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8288 cannot be allocated nicely. Such colors will be replaced with
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8289 a default color, and we don't have to care about which colors
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8290 can be freed safely, and which can't. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8291 init_color_table ();
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8292 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8293 * sizeof *colors);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8294
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8295 for (i = 0; i < cinfo.actual_number_of_colors; ++i)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8296 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8297 /* Multiply RGB values with 255 because X expects RGB values
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8298 in the range 0..0xffff. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8299 int r = cinfo.colormap[ir][i] << 8;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8300 int g = cinfo.colormap[ig][i] << 8;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8301 int b = cinfo.colormap[ib][i] << 8;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8302 colors[i] = lookup_rgb_color (f, r, g, b);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8303 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8304
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8305 /* Remember those colors actually allocated. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8306 img->colors = colors_in_color_table (&img->ncolors);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8307 free_color_table ();
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8308 }
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 /* Read pixels. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8311 row_stride = width * cinfo.output_components;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8312 buffer = cinfo.mem->alloc_sarray ((j_common_ptr) &cinfo, JPOOL_IMAGE,
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8313 row_stride, 1);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8314 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8315 {
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8316 jpeg_read_scanlines (&cinfo, buffer, 1);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8317 for (x = 0; x < cinfo.output_width; ++x)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8318 XPutPixel (ximg, x, y, colors[buffer[0][x]]);
24994
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 /* Clean up. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8322 jpeg_finish_decompress (&cinfo);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8323 jpeg_destroy_decompress (&cinfo);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8324 if (fp)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8325 fclose (fp);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8326
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8327 /* Put the image into the pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8328 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
8329 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8330 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8331 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8332 return 1;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8335 #endif /* HAVE_JPEG */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8336
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8337
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8338
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8339 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8340 TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8341 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8342
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8343 #if HAVE_TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8344
25335
2de1796b006b remove tiff34 prefix from include.
Gerd Moellmann <gerd@gnu.org>
parents: 25320
diff changeset
8345 #include <tiffio.h>
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8346
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8347 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
8348 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
8349
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8350 /* 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
8351
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8352 Lisp_Object Qtiff;
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 /* 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
8355
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8356 enum tiff_keyword_index
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 TIFF_TYPE,
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8359 TIFF_DATA,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8360 TIFF_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8361 TIFF_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8362 TIFF_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8363 TIFF_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8364 TIFF_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8365 TIFF_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8366 TIFF_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8367 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8368
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8369 /* 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
8370 of valid user-defined image specifications. */
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 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
8373 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8374 {":type", IMAGE_SYMBOL_VALUE, 1},
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8375 {":data", IMAGE_STRING_VALUE, 0},
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8376 {":file", IMAGE_STRING_VALUE, 0},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
8377 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8378 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8379 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8380 {":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
8381 {":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
8382 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8383
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8384 /* Structure describing the image type `tiff'. */
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 static struct image_type tiff_type =
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 &Qtiff,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8389 tiff_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8390 tiff_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8391 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8392 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8393 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8394
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 /* 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
8397
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8398 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8399 tiff_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8400 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8401 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8402 struct image_keyword fmt[TIFF_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8403 bcopy (tiff_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8404
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
8405 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8406 return 0;
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8407
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
8408 /* Must specify either the :data or :file keyword. */
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
8409 return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8410 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8411
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8412
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8413 /* Reading from a memory buffer for TIFF images Based on the PNG
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8414 memory source, but we have to provide a lot of extra functions.
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8415 Blah.
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8416
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8417 We really only need to implement read and seek, but I am not
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8418 convinced that the TIFF library is smart enough not to destroy
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8419 itself if we only hand it the function pointers we need to
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8420 override. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8421
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8422 typedef struct
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8423 {
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8424 unsigned char *bytes;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8425 size_t len;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8426 int index;
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8427 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8428 tiff_memory_source;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8429
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8430
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8431 static size_t
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8432 tiff_read_from_memory (data, buf, size)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8433 thandle_t data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8434 tdata_t buf;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8435 tsize_t size;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8436 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8437 tiff_memory_source *src = (tiff_memory_source *) data;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8438
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8439 if (size > src->len - src->index)
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8440 return (size_t) -1;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8441 bcopy (src->bytes + src->index, buf, size);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8442 src->index += size;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8443 return size;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8444 }
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8445
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8446
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8447 static size_t
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8448 tiff_write_from_memory (data, buf, size)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8449 thandle_t data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8450 tdata_t buf;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8451 tsize_t size;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8452 {
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8453 return (size_t) -1;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8454 }
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8455
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8456
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8457 static toff_t
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8458 tiff_seek_in_memory (data, off, whence)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8459 thandle_t data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8460 toff_t off;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8461 int whence;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8462 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8463 tiff_memory_source *src = (tiff_memory_source *) data;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8464 int idx;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8465
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8466 switch (whence)
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8467 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8468 case SEEK_SET: /* Go from beginning of source. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8469 idx = off;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8470 break;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8471
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8472 case SEEK_END: /* Go from end of source. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8473 idx = src->len + off;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8474 break;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8475
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8476 case SEEK_CUR: /* Go from current position. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8477 idx = src->index + off;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8478 break;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8479
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8480 default: /* Invalid `whence'. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8481 return -1;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8482 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8483
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8484 if (idx > src->len || idx < 0)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8485 return -1;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8486
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8487 src->index = idx;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8488 return src->index;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8489 }
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8490
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8491
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8492 static int
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8493 tiff_close_memory (data)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8494 thandle_t data;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8495 {
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8496 /* NOOP */
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8497 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8498 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8499
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8500
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8501 static int
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8502 tiff_mmap_memory (data, pbase, psize)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8503 thandle_t data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8504 tdata_t *pbase;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8505 toff_t *psize;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8506 {
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8507 /* It is already _IN_ memory. */
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8508 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8509 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8510
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8511
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8512 static void
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8513 tiff_unmap_memory (data, base, size)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8514 thandle_t data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8515 tdata_t base;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8516 toff_t size;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8517 {
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8518 /* We don't need to do this. */
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8519 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8520
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8521
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8522 static toff_t
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8523 tiff_size_of_memory (data)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8524 thandle_t data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8525 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8526 return ((tiff_memory_source *) data)->len;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8527 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8528
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8529
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8530 /* 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
8531 successful. */
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 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8534 tiff_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8535 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8536 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8537 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8538 Lisp_Object file, specified_file;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8539 Lisp_Object specified_data;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8540 TIFF *tiff;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8541 int width, height, x, y;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8542 uint32 *buf;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8543 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8544 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8545 struct gcpro gcpro1;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8546 tiff_memory_source memsrc;
24994
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 specified_file = image_spec_value (img->spec, QCfile, NULL);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8549 specified_data = image_spec_value (img->spec, QCdata, NULL);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8550 file = Qnil;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8551 GCPRO1 (file);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8552
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8553 if (NILP (specified_data))
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8554 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8555 /* Read from a file */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8556 file = x_find_image_file (specified_file);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8557 if (!STRINGP (file))
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8558 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8559 image_error ("Cannot find image file `%s'", file, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8560 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8561 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8562 }
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8563
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8564 /* Try to open the image file. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8565 tiff = TIFFOpen (XSTRING (file)->data, "r");
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8566 if (tiff == NULL)
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8567 {
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8568 image_error ("Cannot open `%s'", file, Qnil);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8569 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8570 return 0;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8571 }
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8572 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8573 else
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8574 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8575 /* Memory source! */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8576 memsrc.bytes = XSTRING (specified_data)->data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8577 memsrc.len = STRING_BYTES (XSTRING (specified_data));
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8578 memsrc.index = 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8579
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8580 tiff = TIFFClientOpen ("memory_source", "r", &memsrc,
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8581 (TIFFReadWriteProc) tiff_read_from_memory,
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8582 (TIFFReadWriteProc) tiff_write_from_memory,
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8583 tiff_seek_in_memory,
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8584 tiff_close_memory,
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8585 tiff_size_of_memory,
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8586 tiff_mmap_memory,
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8587 tiff_unmap_memory);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8588
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8589 if (!tiff)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8590 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8591 image_error ("Cannot open memory source for `%s'", img->spec, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8592 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8593 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8594 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8595 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8596
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8597 /* 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
8598 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
8599 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8600 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8601 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
8602
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8603 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
8604 TIFFClose (tiff);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8605 if (!rc)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8606 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8607 image_error ("Error reading TIFF image `%s'", img->spec, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8608 xfree (buf);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8609 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8610 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8611 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8612
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8613 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8614
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8615 /* Create the X image and pixmap. */
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8616 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8617 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8618 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8619 xfree (buf);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8620 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8621 return 0;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8624 /* Initialize the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8625 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8626
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8627 /* 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
8628 for (y = 0; y < height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8629 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8630 uint32 *row = buf + y * width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8631
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8632 for (x = 0; x < width; ++x)
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 uint32 abgr = row[x];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8635 int r = TIFFGetR (abgr) << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8636 int g = TIFFGetG (abgr) << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8637 int b = TIFFGetB (abgr) << 8;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8638 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
8639 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8640 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8641
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8642 /* 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
8643 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
8644 free_color_table ();
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 /* 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
8647 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
8648 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8649 xfree (buf);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8650 UNBLOCK_INPUT;
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 img->width = width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8653 img->height = height;
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 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8656 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8657 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8658
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8659 #endif /* HAVE_TIFF != 0 */
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 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8664 GIF
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8667 #if HAVE_GIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8668
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8669 #include <gif_lib.h>
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 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
8672 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
8673
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8674 /* 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
8675
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8676 Lisp_Object Qgif;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8677
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8678 /* 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
8679
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8680 enum gif_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8681 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8682 GIF_TYPE,
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8683 GIF_DATA,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8684 GIF_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8685 GIF_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8686 GIF_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8687 GIF_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8688 GIF_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8689 GIF_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8690 GIF_IMAGE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8691 GIF_LAST
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8694 /* 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
8695 of valid user-defined image specifications. */
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 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
8698 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8699 {":type", IMAGE_SYMBOL_VALUE, 1},
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8700 {":data", IMAGE_STRING_VALUE, 0},
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8701 {":file", IMAGE_STRING_VALUE, 0},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
8702 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8703 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8704 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8705 {":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
8706 {":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
8707 {":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
8708 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8709
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8710 /* Structure describing the image type `gif'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8711
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8712 static struct image_type gif_type =
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 &Qgif,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8715 gif_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8716 gif_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8717 x_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8718 NULL
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
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8721
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8722 /* 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
8723
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8724 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8725 gif_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8726 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8727 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8728 struct image_keyword fmt[GIF_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8729 bcopy (gif_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8730
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
8731 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8732 return 0;
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8733
27069
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
8734 /* Must specify either the :data or :file keyword. */
b2934c683b5e (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27066
diff changeset
8735 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8736 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8737
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8738
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8739 /* Reading a GIF image from memory
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8740 Based on the PNG memory stuff to a certain extent. */
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8741
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8742 typedef struct
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8743 {
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8744 unsigned char *bytes;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8745 size_t len;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8746 int index;
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8747 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8748 gif_memory_source;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8749
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
8750
27153
31b7a2a8ea20 (current_gif_memory_src): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 27071
diff changeset
8751 /* Make the current memory source available to gif_read_from_memory.
31b7a2a8ea20 (current_gif_memory_src): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 27071
diff changeset
8752 It's done this way because not all versions of libungif support
31b7a2a8ea20 (current_gif_memory_src): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 27071
diff changeset
8753 a UserData field in the GifFileType structure. */
31b7a2a8ea20 (current_gif_memory_src): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 27071
diff changeset
8754 static gif_memory_source *current_gif_memory_src;
31b7a2a8ea20 (current_gif_memory_src): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 27071
diff changeset
8755
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8756 static int
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8757 gif_read_from_memory (file, buf, len)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8758 GifFileType *file;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8759 GifByteType *buf;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8760 int len;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8761 {
27153
31b7a2a8ea20 (current_gif_memory_src): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 27071
diff changeset
8762 gif_memory_source *src = current_gif_memory_src;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8763
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8764 if (len > src->len - src->index)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8765 return -1;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8766
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8767 bcopy (src->bytes + src->index, buf, len);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8768 src->index += len;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8769 return len;
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8770 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8771
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8772
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8773 /* 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
8774 successful. */
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 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8777 gif_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8778 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8779 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8780 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8781 Lisp_Object file, specified_file;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8782 Lisp_Object specified_data;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8783 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
8784 XImage *ximg;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8785 ColorMapObject *gif_color_map;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8786 unsigned long pixel_colors[256];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8787 GifFileType *gif;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8788 struct gcpro gcpro1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8789 Lisp_Object image;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8790 int ino, image_left, image_top, image_width, image_height;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8791 gif_memory_source memsrc;
27066
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8792 unsigned char *raster;
24994
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 specified_file = image_spec_value (img->spec, QCfile, NULL);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8795 specified_data = image_spec_value (img->spec, QCdata, NULL);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8796 file = Qnil;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8797 GCPRO1 (file);
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8798
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8799 if (NILP (specified_data))
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8800 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8801 file = x_find_image_file (specified_file);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8802 if (!STRINGP (file))
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8803 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8804 image_error ("Cannot find image file `%s'", specified_file, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8805 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8806 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8807 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8808
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8809 /* Open the GIF file. */
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8810 gif = DGifOpenFileName (XSTRING (file)->data);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8811 if (gif == NULL)
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8812 {
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8813 image_error ("Cannot open `%s'", file, Qnil);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8814 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8815 return 0;
27058
209b24ba8ddf Changes to xfns.c to support reading images from a memory buffer instead of forcing them to be on disk. GIF/JPEG/PNG/TIFF currently support this.
William M. Perry <wmperry@aventail.com>
parents: 27053
diff changeset
8816 }
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8817 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8818 else
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8819 {
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8820 /* Read from memory! */
27153
31b7a2a8ea20 (current_gif_memory_src): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 27071
diff changeset
8821 current_gif_memory_src = &memsrc;
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8822 memsrc.bytes = XSTRING (specified_data)->data;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8823 memsrc.len = STRING_BYTES (XSTRING (specified_data));
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8824 memsrc.index = 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8825
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8826 gif = DGifOpen(&memsrc, gif_read_from_memory);
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8827 if (!gif)
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8828 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8829 image_error ("Cannot open memory source `%s'", img->spec, Qnil);
27060
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8830 UNGCPRO;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8831 return 0;
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8832 }
4960164efd1c New image functions adapted to Emacs conventions.
Gerd Moellmann <gerd@gnu.org>
parents: 27058
diff changeset
8833 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8834
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8835 /* Read entire contents. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8836 rc = DGifSlurp (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8837 if (rc == GIF_ERROR)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8838 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8839 image_error ("Error reading `%s'", img->spec, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8840 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8841 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8842 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8843 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8844
25620
1c991744ce13 (QCindex): New.
Gerd Moellmann <gerd@gnu.org>
parents: 25593
diff changeset
8845 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
8846 ino = INTEGERP (image) ? XFASTINT (image) : 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8847 if (ino >= gif->ImageCount)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8848 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8849 image_error ("Invalid image number `%s' in image `%s'",
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8850 image, img->spec);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8851 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8852 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8853 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8854 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8855
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8856 width = img->width = gif->SWidth;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8857 height = img->height = gif->SHeight;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8858
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8859 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8860
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8861 /* Create the X image and pixmap. */
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
8862 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8863 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8864 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8865 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8866 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8867 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8868 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8869
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8870 /* Allocate colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8871 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
8872 if (!gif_color_map)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8873 gif_color_map = gif->SColorMap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8874 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8875 bzero (pixel_colors, sizeof pixel_colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8876
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8877 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
8878 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8879 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
8880 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
8881 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
8882 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
8883 }
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 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
8886 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8887
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8888 /* 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
8889 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
8890 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
8891 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
8892 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
8893 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
8894 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
8895 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
8896 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
8897
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8898 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
8899 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8900 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
8901
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8902 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
8903 for (x = 0; x < width; ++x)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8904 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
8905
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8906 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
8907 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8908 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
8909 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
8910 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
8911 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
8912 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8913
27066
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8914 /* Read the GIF image into the X image. We use a local variable
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8915 `raster' here because RasterBits below is a char *, and invites
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8916 problems with bytes >= 0x80. */
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8917 raster = (unsigned char *) gif->SavedImages[ino].RasterBits;
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8918
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8919 if (gif->SavedImages[ino].ImageDesc.Interlace)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8920 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8921 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
8922 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
8923 int pass, inc;
26032
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8924 int row = interlace_start[0];
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8925
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8926 pass = 0;
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8927
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8928 for (y = 0; y < image_height; y++)
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8929 {
26032
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8930 if (row >= image_height)
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8931 {
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8932 row = interlace_start[++pass];
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8933 while (row >= image_height)
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8934 row = interlace_start[++pass];
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8935 }
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8936
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8937 for (x = 0; x < image_width; x++)
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8938 {
27066
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8939 int i = raster[(y * image_width) + x];
26032
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8940 XPutPixel (ximg, x + image_left, row + image_top,
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8941 pixel_colors[i]);
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8942 }
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8943
6a349a18b1ad (gif_load): Fix handling of interlaced GIFs.
Gerd Moellmann <gerd@gnu.org>
parents: 25955
diff changeset
8944 row += interlace_increment[pass];
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8945 }
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 else
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 (y = 0; y < image_height; ++y)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8950 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
8951 {
27066
30697e7cb5a2 (gif_load): Avoid sign extension and thus out of bounds
Gerd Moellmann <gerd@gnu.org>
parents: 27060
diff changeset
8952 int i = raster[y * image_width + x];
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8953 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
8954 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8955 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8956
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8957 DGifCloseFile (gif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8958
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8959 /* 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
8960 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
8961 x_destroy_x_image (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8962 UNBLOCK_INPUT;
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 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8965 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8966 }
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 #endif /* HAVE_GIF != 0 */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8969
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8970
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 Ghostscript
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8974 ***********************************************************************/
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 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
8977 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
8978 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
8979
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
8980 /* 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
8981
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
8982 Lisp_Object Qpostscript;
24994
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 /* Keyword symbols. */
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 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
8987
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8988 /* 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
8989
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8990 enum gs_keyword_index
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8991 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8992 GS_TYPE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8993 GS_PT_WIDTH,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8994 GS_PT_HEIGHT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8995 GS_FILE,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8996 GS_LOADER,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8997 GS_BOUNDING_BOX,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8998 GS_ASCENT,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
8999 GS_MARGIN,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9000 GS_RELIEF,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9001 GS_ALGORITHM,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9002 GS_HEURISTIC_MASK,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9003 GS_LAST
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9004 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9005
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9006 /* 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
9007 of valid user-defined image specifications. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9008
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9009 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
9010 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9011 {":type", IMAGE_SYMBOL_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9012 {":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
9013 {":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
9014 {":file", IMAGE_STRING_VALUE, 1},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9015 {":loader", IMAGE_FUNCTION_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9016 {":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE, 1},
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
9017 {":ascent", IMAGE_ASCENT_VALUE, 0},
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9018 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9019 {":relief", IMAGE_INTEGER_VALUE, 0},
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9020 {":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
9021 {":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
9022 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9023
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9024 /* Structure describing the image type `ghostscript'. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9025
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9026 static struct image_type gs_type =
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9027 {
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
9028 &Qpostscript,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9029 gs_image_p,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9030 gs_load,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9031 gs_clear_image,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9032 NULL
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9033 };
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9034
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 /* 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
9037
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9038 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9039 gs_clear_image (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9040 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9041 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9042 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9043 /* 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
9044 xfree (img->data.ptr_val);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9045 x_clear_image (f, img);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9046 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9047
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9048
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9049 /* 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
9050 specification. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9051
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9052 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9053 gs_image_p (object)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9054 Lisp_Object object;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9055 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9056 struct image_keyword fmt[GS_LAST];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9057 Lisp_Object tem;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9058 int i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9059
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9060 bcopy (gs_format, fmt, sizeof fmt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9061
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
9062 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9063 return 0;
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 /* 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
9066 tem = fmt[GS_BOUNDING_BOX].value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9067 if (CONSP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9068 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9069 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
9070 if (!CONSP (tem) || !INTEGERP (XCAR (tem)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9071 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9072 if (!NILP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9073 return 0;
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 else if (VECTORP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9076 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9077 if (XVECTOR (tem)->size != 4)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9078 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9079 for (i = 0; i < 4; ++i)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9080 if (!INTEGERP (XVECTOR (tem)->contents[i]))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9081 return 0;
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 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9084 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9085
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9086 return 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9087 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9088
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9089
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9090 /* 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
9091 if successful. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9092
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9093 static int
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9094 gs_load (f, img)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9095 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9096 struct image *img;
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 char buffer[100];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9099 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
9100 struct gcpro gcpro1, gcpro2;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9101 Lisp_Object frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9102 double in_width, in_height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9103 Lisp_Object pixel_colors = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9104
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9105 /* 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
9106 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
9107 = 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
9108 info. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9109 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
9110 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
9111 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
9112 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
9113 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
9114 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
9115
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9116 /* Create the pixmap. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9117 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9118 xassert (img->pixmap == 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9119 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
9120 img->width, img->height,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9121 DefaultDepthOfScreen (FRAME_X_SCREEN (f)));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9122 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9123
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9124 if (!img->pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9125 {
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
9126 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9127 return 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9128 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9129
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9130 /* 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
9131 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
9132 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
9133 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
9134 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
9135
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9136 sprintf (buffer, "%lu %lu",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9137 (unsigned long) FRAME_X_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9138 (unsigned long) img->pixmap);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9139 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
9140
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9141 sprintf (buffer, "%lu %lu",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9142 FRAME_FOREGROUND_PIXEL (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9143 FRAME_BACKGROUND_PIXEL (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9144 pixel_colors = build_string (buffer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9145
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9146 XSETFRAME (frame, f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9147 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
9148 if (NILP (loader))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9149 loader = intern ("gs-load-image");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9150
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9151 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
9152 make_number (img->width),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9153 make_number (img->height),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9154 window_and_pixmap_id,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9155 pixel_colors);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9156 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9157 return PROCESSP (img->data.lisp_val);
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9161 /* 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
9162 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
9163 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
9164
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9165 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9166 x_kill_gs_process (pixmap, f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9167 Pixmap pixmap;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9168 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9169 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9170 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
9171 int class, i;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9172 struct image *img;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9173
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9174 /* Find the image containing PIXMAP. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9175 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
9176 if (c->images[i]->pixmap == pixmap)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9177 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9178
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9179 /* 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
9180 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
9181 xassert (i < c->used);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9182 img = c->images[i];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9183 xassert (PROCESSP (img->data.lisp_val));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9184 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
9185 img->data.lisp_val = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9186
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9187 /* 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
9188 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
9189 img->pixmap. */
28144
71ebba3566ec (X_I18N_INHIBITED): Don't define.
Gerd Moellmann <gerd@gnu.org>
parents: 28096
diff changeset
9190 class = FRAME_X_VISUAL (f)->class;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9191 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
9192 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9193 XImage *ximg;
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 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9196
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9197 /* 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
9198 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
9199 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
9200 if (ximg)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9201 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9202 int x, y;
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 /* Initialize the color table. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9205 init_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9206
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9207 /* 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
9208 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
9209 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
9210 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
9211 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
9212 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9213 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
9214 lookup_pixel_color (f, pixel);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9215 }
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 /* 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
9218 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
9219 free_color_table ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9220 XDestroyImage (ximg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9221
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9222 #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
9223 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
9224 freeing the colors. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9225 /* 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
9226 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
9227 reference counts right, free them once. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9228 if (img->ncolors)
27963
0e2c6e5cca6e (x_clear_image, x_kill_gs_process): Use x_free_colors.
Gerd Moellmann <gerd@gnu.org>
parents: 27915
diff changeset
9229 x_free_colors (f, img->colors, img->ncolors);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9230 #endif
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 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9233 image_error ("Cannot get X image of `%s'; colors will not be freed",
27071
d647366b1464 (x_create_x_image_and_pixmap): Remove parameter file.
Gerd Moellmann <gerd@gnu.org>
parents: 27069
diff changeset
9234 img->spec, Qnil);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9235
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9236 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9237 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9238 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9239
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9240
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9241
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 Window properties
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9244 ***********************************************************************/
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 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
9247 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
9248 "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
9249 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
9250 selected frame. Value is VALUE.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9251 (prop, value, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9252 Lisp_Object frame, prop, value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9253 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9254 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
9255 Atom prop_atom;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9256
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9257 CHECK_STRING (prop, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9258 CHECK_STRING (value, 2);
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 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9261 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
9262 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
9263 prop_atom, XA_STRING, 8, PropModeReplace,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9264 XSTRING (value)->data, XSTRING (value)->size);
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 /* 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
9267 XFlush (FRAME_X_DISPLAY (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9268 UNBLOCK_INPUT;
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 return value;
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 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
9275 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
9276 "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
9277 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
9278 (prop, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9279 Lisp_Object prop, frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9280 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9281 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
9282 Atom prop_atom;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9283
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9284 CHECK_STRING (prop, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9285 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9286 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
9287 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
9288
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9289 /* 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
9290 XFlush (FRAME_X_DISPLAY (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9291 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9292
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9293 return prop;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9294 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9295
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9296
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9297 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
9298 1, 2, 0,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9299 "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
9300 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
9301 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
9302 value.")
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9303 (prop, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9304 Lisp_Object prop, frame;
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 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
9307 Atom prop_atom;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9308 int rc;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9309 Lisp_Object prop_value = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9310 char *tmp_data = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9311 Atom actual_type;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9312 int actual_format;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9313 unsigned long actual_size, bytes_remaining;
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 CHECK_STRING (prop, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9316 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9317 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
9318 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
9319 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
9320 &actual_type, &actual_format, &actual_size,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9321 &bytes_remaining, (unsigned char **) &tmp_data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9322 if (rc == Success)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9323 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9324 int size = bytes_remaining;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9325
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9326 XFree (tmp_data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9327 tmp_data = NULL;
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 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
9330 prop_atom, 0, bytes_remaining,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9331 False, XA_STRING,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9332 &actual_type, &actual_format,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9333 &actual_size, &bytes_remaining,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9334 (unsigned char **) &tmp_data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9335 if (rc == Success)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9336 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
9337
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9338 XFree (tmp_data);
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9341 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9342 return prop_value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9343 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9344
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9345
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9346
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9347 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9348 Busy cursor
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9349 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9350
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9351 /* If non-null, an asynchronous timer that, when it expires, displays
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9352 a busy cursor on all frames. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9353
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9354 static struct atimer *busy_cursor_atimer;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9355
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9356 /* Non-zero means a busy cursor is currently shown. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9357
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9358 static int busy_cursor_shown_p;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9359
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9360 /* Number of seconds to wait before displaying a busy cursor. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9361
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9362 static Lisp_Object Vbusy_cursor_delay;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9363
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9364 /* Default number of seconds to wait before displaying a busy
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9365 cursor. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9366
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9367 #define DEFAULT_BUSY_CURSOR_DELAY 1
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9368
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9369 /* Function prototypes. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9370
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9371 static void show_busy_cursor P_ ((struct atimer *));
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9372 static void hide_busy_cursor P_ ((void));
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9373
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9374
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9375 /* Cancel a currently active busy-cursor timer, and start a new one. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9376
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9377 void
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9378 start_busy_cursor ()
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9379 {
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9380 EMACS_TIME delay;
27915
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9381 int secs, usecs = 0;
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9382
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9383 cancel_busy_cursor ();
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9384
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9385 if (INTEGERP (Vbusy_cursor_delay)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9386 && XINT (Vbusy_cursor_delay) > 0)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9387 secs = XFASTINT (Vbusy_cursor_delay);
27915
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9388 else if (FLOATP (Vbusy_cursor_delay)
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9389 && XFLOAT_DATA (Vbusy_cursor_delay) > 0)
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9390 {
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9391 Lisp_Object tem;
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9392 tem = Ftruncate (Vbusy_cursor_delay, Qnil);
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9393 secs = XFASTINT (tem);
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9394 usecs = (XFLOAT_DATA (Vbusy_cursor_delay) - secs) * 1000000;
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9395 }
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9396 else
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9397 secs = DEFAULT_BUSY_CURSOR_DELAY;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9398
27915
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
9399 EMACS_SET_SECS_USECS (delay, secs, usecs);
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9400 busy_cursor_atimer = start_atimer (ATIMER_RELATIVE, delay,
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9401 show_busy_cursor, NULL);
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9402 }
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9403
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9404
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9405 /* Cancel the busy cursor timer if active, hide a busy cursor if
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9406 shown. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9407
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9408 void
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9409 cancel_busy_cursor ()
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9410 {
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9411 if (busy_cursor_atimer)
27902
27af8b008c69 (cancel_busy_cursor): Set busy_cursor_atimer to null
Gerd Moellmann <gerd@gnu.org>
parents: 27864
diff changeset
9412 {
27af8b008c69 (cancel_busy_cursor): Set busy_cursor_atimer to null
Gerd Moellmann <gerd@gnu.org>
parents: 27864
diff changeset
9413 cancel_atimer (busy_cursor_atimer);
27af8b008c69 (cancel_busy_cursor): Set busy_cursor_atimer to null
Gerd Moellmann <gerd@gnu.org>
parents: 27864
diff changeset
9414 busy_cursor_atimer = NULL;
27af8b008c69 (cancel_busy_cursor): Set busy_cursor_atimer to null
Gerd Moellmann <gerd@gnu.org>
parents: 27864
diff changeset
9415 }
27af8b008c69 (cancel_busy_cursor): Set busy_cursor_atimer to null
Gerd Moellmann <gerd@gnu.org>
parents: 27864
diff changeset
9416
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9417 if (busy_cursor_shown_p)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9418 hide_busy_cursor ();
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9419 }
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9420
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9421
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9422 /* Timer function of busy_cursor_atimer. TIMER is equal to
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9423 busy_cursor_atimer.
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9424
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9425 Display a busy cursor on all frames by mapping the frames'
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9426 busy_window. Set the busy_p flag in the frames' output_data.x
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9427 structure to indicate that a busy cursor is shown on the
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9428 frames. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9429
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9430 static void
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9431 show_busy_cursor (timer)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9432 struct atimer *timer;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9433 {
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9434 /* The timer implementation will cancel this timer automatically
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9435 after this function has run. Set busy_cursor_atimer to null
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9436 so that we know the timer doesn't have to be canceled. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9437 busy_cursor_atimer = NULL;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9438
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9439 if (!busy_cursor_shown_p)
24994
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 Lisp_Object rest, frame;
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9442
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9443 BLOCK_INPUT;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9444
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9445 FOR_EACH_FRAME (rest, frame)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9446 if (FRAME_X_P (XFRAME (frame)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9447 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9448 struct frame *f = XFRAME (frame);
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9449
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9450 f->output_data.x->busy_p = 1;
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9451
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9452 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
9453 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9454 unsigned long mask = CWCursor;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9455 XSetWindowAttributes attrs;
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9456
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9457 attrs.cursor = f->output_data.x->busy_cursor;
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9458
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9459 f->output_data.x->busy_window
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9460 = XCreateWindow (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9461 FRAME_OUTER_WINDOW (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9462 0, 0, 32000, 32000, 0, 0,
26474
027b7c42a65b (Fx_show_busy_cursor): Doc-fix.
Gerd Moellmann <gerd@gnu.org>
parents: 26401
diff changeset
9463 InputOnly,
027b7c42a65b (Fx_show_busy_cursor): Doc-fix.
Gerd Moellmann <gerd@gnu.org>
parents: 26401
diff changeset
9464 CopyFromParent,
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9465 mask, &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9466 }
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9467
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9468 XMapRaised (FRAME_X_DISPLAY (f), f->output_data.x->busy_window);
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9469 XFlush (FRAME_X_DISPLAY (f));
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9470 }
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9471
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9472 busy_cursor_shown_p = 1;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9473 UNBLOCK_INPUT;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9474 }
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9475 }
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9476
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9477
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9478 /* Hide the busy cursor on all frames, if it is currently shown. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9479
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9480 static void
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9481 hide_busy_cursor ()
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9482 {
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9483 if (busy_cursor_shown_p)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9484 {
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9485 Lisp_Object rest, frame;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9486
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9487 BLOCK_INPUT;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9488 FOR_EACH_FRAME (rest, frame)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9489 {
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9490 struct frame *f = XFRAME (frame);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9491
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9492 if (FRAME_X_P (f)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9493 /* Watch out for newly created frames. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9494 && f->output_data.x->busy_window)
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9495 {
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9496 XUnmapWindow (FRAME_X_DISPLAY (f), f->output_data.x->busy_window);
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9497 /* Sync here because XTread_socket looks at the busy_p flag
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9498 that is reset to zero below. */
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9499 XSync (FRAME_X_DISPLAY (f), False);
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9500 f->output_data.x->busy_p = 0;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9501 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9502 }
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9503
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9504 busy_cursor_shown_p = 0;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9505 UNBLOCK_INPUT;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
9506 }
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9507 }
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9510
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9511 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9512 Tool tips
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9515 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
9516 Lisp_Object));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9517
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9518 /* 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
9519
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9520 struct frame *tip_frame;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9521
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9522 /* 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
9523 fires. */
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 Lisp_Object tip_timer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9526 Window tip_window;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9527
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9528 /* 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
9529 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
9530
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9531 static Lisp_Object
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9532 x_create_tip_frame (dpyinfo, parms)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9533 struct x_display_info *dpyinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9534 Lisp_Object parms;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9535 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9536 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9537 Lisp_Object frame, tem;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9538 Lisp_Object name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9539 long window_prompting = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9540 int width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9541 int count = specpdl_ptr - specpdl;
25715
feaedc03dbc8 (x_set_background_color): Remove unused variable(s).
Gerd Moellmann <gerd@gnu.org>
parents: 25691
diff changeset
9542 struct gcpro gcpro1, gcpro2, gcpro3;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9543 struct kboard *kb;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9544
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9545 check_x ();
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9546
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9547 /* 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
9548 this frame has a specified name. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9549 Vx_resource_name = Vinvocation_name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9550
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9551 #ifdef MULTI_KBOARD
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9552 kb = dpyinfo->kboard;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9553 #else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9554 kb = &the_only_kboard;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9555 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9556
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9557 /* 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
9558 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
9559 if (!STRINGP (name)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9560 && !EQ (name, Qunbound)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9561 && !NILP (name))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9562 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
9563 Vx_resource_name = name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9564
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9565 frame = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9566 GCPRO3 (parms, name, frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9567 tip_frame = f = make_frame (1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9568 XSETFRAME (frame, f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9569 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
9570
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9571 f->output_method = output_x_window;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9572 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
9573 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
9574 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
9575 f->output_data.x->fontset = -1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9576 f->icon_name = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9577 FRAME_X_DISPLAY_INFO (f) = dpyinfo;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9578 #ifdef MULTI_KBOARD
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9579 FRAME_KBOARD (f) = kb;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9580 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9581 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
9582 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
9583
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9584 /* 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
9585 be set. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9586 if (EQ (name, Qunbound) || NILP (name))
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 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
9589 f->explicit_name = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9590 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9591 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9592 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9593 f->name = name;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9594 f->explicit_name = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9595 /* 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
9596 specbind (Qx_resource_name, name);
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 /* 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
9600 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
9601 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9602 Lisp_Object font;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9603
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9604 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
9605
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9606 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9607 /* 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
9608 if (STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9609 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9610 tem = Fquery_fontset (font, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9611 if (STRINGP (tem))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9612 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
9613 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9614 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
9615 }
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 /* 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
9618 if (!STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9619 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
9620 if (!STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9621 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
9622 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9623 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
9624 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9625 /* 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
9626 and takes too long. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9627 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
9628 /* 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
9629 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9630 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
9631 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9632 if (! STRINGP (font))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9633 font = build_string ("fixed");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9634
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9635 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
9636 "font", "Font", RES_TYPE_STRING);
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9639 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
9640 "borderWidth", "BorderWidth", 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 /* 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
9643 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
9644 it). */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9645 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
9646 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9647 Lisp_Object value;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9648
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9649 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
9650 "internalBorder", "internalBorder", RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9651 if (! EQ (value, Qunbound))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9652 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
9653 parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9654 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9655
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9656 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
9657 "internalBorderWidth", "internalBorderWidth",
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9658 RES_TYPE_NUMBER);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9659
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9660 /* 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
9661 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
9662 "foreground", "Foreground", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9663 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
9664 "background", "Background", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9665 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
9666 "pointerColor", "Foreground", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9667 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
9668 "cursorColor", "Foreground", RES_TYPE_STRING);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9669 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
9670 "borderColor", "BorderColor", RES_TYPE_STRING);
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 /* 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
9673 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
9674 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
9675 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
9676 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
9677 happen. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9678 init_frame_faces (f);
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->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
9681 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
9682
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9683 if (window_prompting & XNegative)
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 if (window_prompting & YNegative)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9686 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
9687 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9688 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
9689 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9690 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9691 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9692 if (window_prompting & YNegative)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9693 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
9694 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9695 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
9696 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9697
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9698 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
9699 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9700 XSetWindowAttributes attrs;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9701 unsigned long mask;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9702
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9703 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9704 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;
27987
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
9705 /* Window managers look at the override-redirect flag to determine
ce9edc646960 (x_defined_color, x_set_mouse_color, lookup_rgb_color)
Gerd Moellmann <gerd@gnu.org>
parents: 27963
diff changeset
9706 whether or net to give windows a decoration (Xlib spec, chapter
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9707 3.2.8). */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9708 attrs.override_redirect = True;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9709 attrs.save_under = True;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9710 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
9711 /* 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
9712 attrs.event_mask = StructureNotifyMask;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9713 tip_window
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9714 = FRAME_X_WINDOW (f)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9715 = XCreateWindow (FRAME_X_DISPLAY (f),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9716 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
9717 /* x, y, width, height */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9718 0, 0, 1, 1,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9719 /* Border. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9720 1,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9721 CopyFromParent, InputOutput, CopyFromParent,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9722 mask, &attrs);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9723 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9724 }
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 x_make_gc (f);
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 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
9729 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9730 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
9731 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9732 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
9733 "cursorType", "CursorType", RES_TYPE_SYMBOL);
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 /* 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
9736 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
9737 f->height. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9738 width = f->width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9739 height = f->height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9740 f->height = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9741 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
9742 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
9743
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9744 f->no_split = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9745
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9746 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9747
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9748 /* 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
9749 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
9750 visible won't work. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9751 Vframe_list = Fcons (frame, Vframe_list);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9752
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9753 /* 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
9754 its display. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9755 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
9756
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9757 return unbind_to (count, frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9758 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9759
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9760
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9761 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
9762 "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
9763 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
9764 the current mouse position.\n\
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9765 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
9766 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
9767 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
9768 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
9769 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
9770 (string, frame, parms, timeout)
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26032
diff changeset
9771 Lisp_Object string, frame, parms, timeout;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9772 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9773 struct frame *f;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9774 struct window *w;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9775 Window root, child;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9776 Lisp_Object buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9777 struct buffer *old_buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9778 struct text_pos pos;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9779 int i, width, height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9780 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
9781 unsigned pmask;
26980
f0d5e95ccce9 (Fx_show_tip): Gcpro `timeout' too.
Dave Love <fx@gnu.org>
parents: 26978
diff changeset
9782 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9783 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
9784 int count = specpdl_ptr - specpdl;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9785
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9786 specbind (Qinhibit_redisplay, Qt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9787
26980
f0d5e95ccce9 (Fx_show_tip): Gcpro `timeout' too.
Dave Love <fx@gnu.org>
parents: 26978
diff changeset
9788 GCPRO4 (string, parms, frame, timeout);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9789
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9790 CHECK_STRING (string, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9791 f = check_x_frame (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9792 if (NILP (timeout))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9793 timeout = make_number (5);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9794 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9795 CHECK_NATNUM (timeout, 2);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9796
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9797 /* Hide a previous tip, if any. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9798 Fx_hide_tip ();
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 /* Add default values to frame parameters. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9801 if (NILP (Fassq (Qname, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9802 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
9803 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
9804 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
9805 if (NILP (Fassq (Qborder_width, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9806 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
9807 if (NILP (Fassq (Qborder_color, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9808 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
9809 if (NILP (Fassq (Qbackground_color, parms)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9810 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
9811 parms);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9812
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9813 /* 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
9814 variable tip_frame. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9815 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
9816 tip_frame = f = XFRAME (frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9817
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9818 /* 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
9819 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
9820 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
9821 w = XWINDOW (FRAME_ROOT_WINDOW (f));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9822 w->left = w->top = make_number (0);
28464
cad4cc0508a0 Fix Lisp_Object/int type confusion revealed by making Lisp_Object a union type:
Ken Raeburn <raeburn@raeburn.org>
parents: 28410
diff changeset
9823 w->width = make_number (80);
cad4cc0508a0 Fix Lisp_Object/int type confusion revealed by making Lisp_Object a union type:
Ken Raeburn <raeburn@raeburn.org>
parents: 28410
diff changeset
9824 w->height = make_number (40);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9825 adjust_glyphs (f);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9826 w->pseudo_window_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9827
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9828 /* 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
9829 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
9830 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
9831 old_buffer = current_buffer;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9832 set_buffer_internal_1 (XBUFFER (buffer));
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9833 Ferase_buffer ();
28464
cad4cc0508a0 Fix Lisp_Object/int type confusion revealed by making Lisp_Object a union type:
Ken Raeburn <raeburn@raeburn.org>
parents: 28410
diff changeset
9834 Finsert (1, &string);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9835 clear_glyph_matrix (w->desired_matrix);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9836 clear_glyph_matrix (w->current_matrix);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9837 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
9838 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
9839
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9840 /* 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
9841 width = height = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9842 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
9843 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9844 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
9845 struct glyph *last;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9846 int row_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9847
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9848 /* 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
9849 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
9850 break;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9851
25082
ba6bf065b287 (x_create_tip_frame): Don't set bitmapIcon resource.
Gerd Moellmann <gerd@gnu.org>
parents: 25075
diff changeset
9852 /* 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
9853 row->full_width_p = 1;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9854
28410
2812a333e746 (free_image_cache): Free the cache structure itself
Gerd Moellmann <gerd@gnu.org>
parents: 28355
diff changeset
9855 /* There's a glyph at the end of rows that is used to place
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9856 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
9857 if (row->used[TEXT_AREA])
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9858 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9859 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
9860 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
9861 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9862 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9863 row_width = row->pixel_width;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9864
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9865 height += row->height;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9866 width = max (width, row_width);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9867 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9868
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9869 /* 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
9870 window should have. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9871 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
9872 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
9873
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9874 /* 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
9875 show it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9876 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9877 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
9878 &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
9879 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
9880 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
9881 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
9882 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9883
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9884 /* Draw into the window. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9885 w->must_be_updated_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9886 update_single_window (w, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9887
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9888 /* Restore original current buffer. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9889 set_buffer_internal_1 (old_buffer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9890 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
9891
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9892 /* 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
9893 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
9894 intern ("x-hide-tip"));
26954
e388d69f4269 (Fx_show_tip): Add missing UNGCPRO.
Dave Love <fx@gnu.org>
parents: 26876
diff changeset
9895
e388d69f4269 (Fx_show_tip): Add missing UNGCPRO.
Dave Love <fx@gnu.org>
parents: 26876
diff changeset
9896 UNGCPRO;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9897 return unbind_to (count, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9898 }
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9901 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
9902 "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
9903 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
9904 ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9905 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9906 int count = specpdl_ptr - specpdl;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9907 int deleted_p = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9908
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9909 specbind (Qinhibit_redisplay, Qt);
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 if (!NILP (tip_timer))
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 call1 (intern ("cancel-timer"), tip_timer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9914 tip_timer = Qnil;
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 if (tip_frame)
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 Lisp_Object frame;
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 XSETFRAME (frame, tip_frame);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9922 Fdelete_frame (frame, Qt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9923 tip_frame = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9924 deleted_p = 1;
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9927 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
9928 }
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 /***********************************************************************
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9933 File selection dialog
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9934 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9935
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9936 #ifdef USE_MOTIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9937
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9938 /* 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
9939
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9940 static void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9941 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
9942 Widget widget;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9943 XtPointer call_data, client_data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9944 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9945 int *result = (int *) client_data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9946 XmAnyCallbackStruct *cb = (XmAnyCallbackStruct *) call_data;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9947 *result = cb->reason;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9948 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9949
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9950
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9951 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
9952 "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
9953 Use a file selection dialog.\n\
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9954 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
9955 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
9956 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
9957 (prompt, dir, default_filename, mustmatch)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9958 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
9959 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9960 int result;
25679
8b09c5927f1c (QCfile): Moved to xdisp.c.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
9961 struct frame *f = SELECTED_FRAME ();
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9962 Lisp_Object file = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9963 Widget dialog, text, list, help;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9964 Arg al[10];
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9965 int ac = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9966 extern XtAppContext Xt_app_con;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9967 char *title;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9968 XmString dir_xmstring, pattern_xmstring;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9969 int popup_activated_flag;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9970 int count = specpdl_ptr - specpdl;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9971 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
9972
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9973 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
9974 CHECK_STRING (prompt, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9975 CHECK_STRING (dir, 1);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9976
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9977 /* Prevent redisplay. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9978 specbind (Qinhibit_redisplay, Qt);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9979
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9980 BLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9981
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9982 /* 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
9983 directory and using "*" as pattern. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9984 dir = Fexpand_file_name (dir, Qnil);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9985 dir_xmstring = XmStringCreateLocalized (XSTRING (dir)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9986 pattern_xmstring = XmStringCreateLocalized ("*");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9987
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9988 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
9989 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
9990 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
9991 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
9992 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
9993 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
9994 "fsb", al, ac);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9995 XmStringFree (dir_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9996 XmStringFree (pattern_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9997
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9998 /* Add callbacks for OK and Cancel. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
9999 XtAddCallback (dialog, XmNokCallback, file_dialog_cb,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10000 (XtPointer) &result);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10001 XtAddCallback (dialog, XmNcancelCallback, file_dialog_cb,
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10002 (XtPointer) &result);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10003
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10004 /* 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
10005 help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10006 XtSetSensitive (help, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10007
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10008 /* Mark OK button as default. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10009 XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10010 XmNshowAsDefault, True, NULL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10011
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10012 /* 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
10013 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
10014 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
10015 the result file name, then. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10016 text = XmFileSelectionBoxGetChild (dialog, XmDIALOG_TEXT);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10017 if (!NILP (mustmatch))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10018 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10019 Widget label;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10020 label = XmFileSelectionBoxGetChild (dialog, XmDIALOG_SELECTION_LABEL);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10021 XtSetSensitive (text, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10022 XtSetSensitive (label, False);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10023 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10024
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10025 /* 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
10026 XtManageChild (dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10027
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10028 /* 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
10029 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
10030 list = XmFileSelectionBoxGetChild (dialog, XmDIALOG_LIST);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10031 if (STRINGP (default_filename))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10032 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10033 XmString default_xmstring;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10034 int item_pos;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10035
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10036 default_xmstring
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10037 = XmStringCreateLocalized (XSTRING (default_filename)->data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10038
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10039 if (!XmListItemExists (list, default_xmstring))
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 /* 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
10042 XmListAddItem (list, default_xmstring, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10043 item_pos = 0;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10044 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10045 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10046 item_pos = XmListItemPos (list, default_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10047 XmStringFree (default_xmstring);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10048
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10049 /* 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
10050 XmListSelectPos (list, item_pos, True);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10051 XmListSetPos (list, item_pos);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10052 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10053
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10054 /* 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
10055 for (result = 0; result == 0;)
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 XEvent event;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10058 Widget widget, parent;
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 XtAppNextEvent (Xt_app_con, &event);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10061
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10062 /* 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
10063 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
10064 discard it. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10065 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
10066 parent = widget;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10067 while (parent && parent != dialog)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10068 parent = XtParent (parent);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10069
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10070 if (parent == dialog
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10071 || (event.type == Expose
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10072 && !process_expose_from_menu (event)))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10073 XtDispatchEvent (&event);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10074 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10075
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10076 /* Get the result. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10077 if (result == XmCR_OK)
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10078 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10079 XmString text;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10080 String data;
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 XtVaGetValues (dialog, XmNtextString, &text, 0);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10083 XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10084 XmStringFree (text);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10085 file = build_string (data);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10086 XtFree (data);
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 else
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10089 file = Qnil;
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 /* Clean up. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10092 XtUnmanageChild (dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10093 XtDestroyWidget (dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10094 UNBLOCK_INPUT;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10095 UNGCPRO;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10096
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10097 /* Make "Cancel" equivalent to C-g. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10098 if (NILP (file))
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10099 Fsignal (Qquit, 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 return unbind_to (count, file);
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
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10104 #endif /* USE_MOTIF */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10105
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
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 Initialization
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10110 ***********************************************************************/
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10111
21846
486ac68ce051 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21779
diff changeset
10112 void
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10113 syms_of_xfns ()
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10114 {
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10115 /* 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
10116 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
10117
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10118 /* 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
10119 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
10120 /*&&& init symbols here &&&*/
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10121 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
10122 staticpro (&Qauto_raise);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10123 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
10124 staticpro (&Qauto_lower);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10125 Qbar = intern ("bar");
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10126 staticpro (&Qbar);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10127 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
10128 staticpro (&Qborder_color);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10129 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
10130 staticpro (&Qborder_width);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10131 Qbox = intern ("box");
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10132 staticpro (&Qbox);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10133 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
10134 staticpro (&Qcursor_color);
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10135 Qcursor_type = intern ("cursor-type");
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1786
diff changeset
10136 staticpro (&Qcursor_type);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10137 Qgeometry = intern ("geometry");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10138 staticpro (&Qgeometry);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10139 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
10140 staticpro (&Qicon_left);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10141 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
10142 staticpro (&Qicon_top);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10143 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
10144 staticpro (&Qicon_type);
12073
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
10145 Qicon_name = intern ("icon-name");
1b0018c43060 (Qicon_name): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 12051
diff changeset
10146 staticpro (&Qicon_name);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10147 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
10148 staticpro (&Qinternal_border_width);
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10149 Qleft = intern ("left");
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10150 staticpro (&Qleft);
16254
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
10151 Qright = intern ("right");
3e8b16badf3d (Fx_create_frame): Default Qvertical_scroll_bars to `left'.
Richard M. Stallman <rms@gnu.org>
parents: 16156
diff changeset
10152 staticpro (&Qright);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10153 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
10154 staticpro (&Qmouse_color);
1874
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
10155 Qnone = intern ("none");
19cf50641d6c * frame.c (Fframe_parameters): Report the `minibuffer' parameter of
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
10156 staticpro (&Qnone);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10157 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
10158 staticpro (&Qparent_id);
8942
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
10159 Qscroll_bar_width = intern ("scroll-bar-width");
a43f3b56ed47 (x_set_scroll_bar_width): New function.
Karl Heuer <kwzh@gnu.org>
parents: 8845
diff changeset
10160 staticpro (&Qscroll_bar_width);
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
10161 Qsuppress_icon = intern ("suppress-icon");
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
10162 staticpro (&Qsuppress_icon);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10163 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
10164 staticpro (&Qundefined_color);
1994
73ce9dd21093 Use the term `scroll bar', instead of `scrollbar'.
Jim Blandy <jimb@redhat.com>
parents: 1932
diff changeset
10165 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
10166 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
10167 Qvisibility = intern ("visibility");
9bce20507666 Use the `visiblity' parameter to determine the initial state of
Jim Blandy <jimb@redhat.com>
parents: 2283
diff changeset
10168 staticpro (&Qvisibility);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10169 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
10170 staticpro (&Qwindow_id);
23793
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
10171 Qouter_window_id = intern ("outer-window-id");
3f48dda0547a (Qouter_window_id): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 23411
diff changeset
10172 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
10173 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
10174 staticpro (&Qx_frame_parameter);
5671
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
10175 Qx_resource_name = intern ("x-resource-name");
5c597b8fbabe Find lwlib.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5558
diff changeset
10176 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
10177 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
10178 staticpro (&Quser_position);
02cc4eee5928 (x_figure_window_size): Set USPosition only if user-position
Richard M. Stallman <rms@gnu.org>
parents: 7209
diff changeset
10179 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
10180 staticpro (&Quser_size);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10181 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
10182 staticpro (&Qscroll_bar_foreground);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10183 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
10184 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
10185 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
10186 staticpro (&Qscreen_gamma);
28690
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
10187 Qline_spacing = intern ("line-spacing");
01a3287bb747 (x_set_line_spacing): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 28597
diff changeset
10188 staticpro (&Qline_spacing);
28787
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
10189 Qcenter = intern ("center");
90e5b2abbd10 (Qcenter): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 28747
diff changeset
10190 staticpro (&Qcenter);
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10191 /* 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
10192
26876
578acd06aa3b Include intervals.h.
Kenichi Handa <handa@m17n.org>
parents: 26808
diff changeset
10193 /* Text property `display' should be nonsticky by default. */
578acd06aa3b Include intervals.h.
Kenichi Handa <handa@m17n.org>
parents: 26808
diff changeset
10194 Vtext_property_default_nonsticky
578acd06aa3b Include intervals.h.
Kenichi Handa <handa@m17n.org>
parents: 26808
diff changeset
10195 = Fcons (Fcons (Qdisplay, Qt), Vtext_property_default_nonsticky);
578acd06aa3b Include intervals.h.
Kenichi Handa <handa@m17n.org>
parents: 26808
diff changeset
10196
578acd06aa3b Include intervals.h.
Kenichi Handa <handa@m17n.org>
parents: 26808
diff changeset
10197
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10198 Qlaplace = intern ("laplace");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10199 staticpro (&Qlaplace);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10200
18631
62bcc6aff013 (x_set_font): Funcall Qface_set_after_frame_default.
Richard M. Stallman <rms@gnu.org>
parents: 18612
diff changeset
10201 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
10202 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
10203
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10204 Fput (Qundefined_color, Qerror_conditions,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10205 Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10206 Fput (Qundefined_color, Qerror_message,
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10207 build_string ("Undefined color"));
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10208
974
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10209 init_x_parm_symbols ();
4f88a1b78a46 * xfns.c (x_get_arg): Return Qunbound for an unspecified
Jim Blandy <jimb@redhat.com>
parents: 833
diff changeset
10210
9563
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
10211 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
ca99ee51077f Include paths.h.
Richard M. Stallman <rms@gnu.org>
parents: 9543
diff changeset
10212 "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
10213 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
10214
4328
3d43e65a593d (syms_of_xfns): Use DEFVAR_LISP, not DEFVAR_INT, for Vx_pointer_shape.
Roland McGrath <roland@gnu.org>
parents: 4309
diff changeset
10215 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
10216 "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
10217 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
10218 unless you set the mouse color.");
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10219 Vx_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10220
4146
0c681748d0ce * xfns.c (Fx_open_connection): Don't trust HAVE_XRMSETDATABASE;
Jim Blandy <jimb@redhat.com>
parents: 3923
diff changeset
10221 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
10222 "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
10223 `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
10224 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
10225 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
10226 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
10227 switches, if present.\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10228 \n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10229 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
10230 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
10231 Vx_resource_name = Qnil;
3170
647229114f47 * xfns.c: Make resource manager work correctly even when
Jim Blandy <jimb@redhat.com>
parents: 3141
diff changeset
10232
16966
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10233 DEFVAR_LISP ("x-resource-class", &Vx_resource_class,
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10234 "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
10235 `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
10236 when requesting resource values.\n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10237 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
10238 \n\
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10239 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
10240 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
10241 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
10242 Vx_resource_class = build_string (EMACS_CLASS);
df9f838f255a (Vx_resource_class): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16732
diff changeset
10243
7683
be3423efbdce (Vx_sensitive_text_pointer_shape):
Richard M. Stallman <rms@gnu.org>
parents: 7599
diff changeset
10244 #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
10245 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
10246 "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
10247 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
10248 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
10249 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10250 Vx_nontext_pointer_shape = Qnil;
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10251
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10252 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
10253 "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
10254 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
10255 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
10256 Vx_busy_pointer_shape = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10257
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10258 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
10259 "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
10260 display_busy_cursor_p = 1;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10261
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
10262 DEFVAR_LISP ("busy-cursor-delay", &Vbusy_cursor_delay,
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
10263 "*Seconds to wait before displaying a busy-cursor.\n\
27915
e5b8e194d279 (start_busy_cursor): Allow floats for busy-cursor-delay.
Gerd Moellmann <gerd@gnu.org>
parents: 27902
diff changeset
10264 Value must be an integer or float.");
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
10265 Vbusy_cursor_delay = make_number (DEFAULT_BUSY_CURSOR_DELAY);
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
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
8170
d92a24366b22 (x_toolkit): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8103
diff changeset
10311 #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
10312 Fprovide (intern ("x-toolkit"));
8170
d92a24366b22 (x_toolkit): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8103
diff changeset
10313 #endif
12094
a9fda5417acf (syms_of_xfns): Provide motif in Motif version.
Karl Heuer <kwzh@gnu.org>
parents: 12080
diff changeset
10314 #ifdef USE_MOTIF
a9fda5417acf (syms_of_xfns): Provide motif in Motif version.
Karl Heuer <kwzh@gnu.org>
parents: 12080
diff changeset
10315 Fprovide (intern ("motif"));
a9fda5417acf (syms_of_xfns): Provide motif in Motif version.
Karl Heuer <kwzh@gnu.org>
parents: 12080
diff changeset
10316 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10317
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10318 defsubr (&Sx_get_resource);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10319
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10320 /* X window properties. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10321 defsubr (&Sx_change_window_property);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10322 defsubr (&Sx_delete_window_property);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10323 defsubr (&Sx_window_property);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10324
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
10325 defsubr (&Sxw_display_color_p);
8779
12c6296bbb4b (Fx_display_grayscale_p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 8758
diff changeset
10326 defsubr (&Sx_display_grayscale_p);
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
10327 defsubr (&Sxw_color_defined_p);
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26571
diff changeset
10328 defsubr (&Sxw_color_values);
4279
d69483b37e0a (MAXREQUEST): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 4269
diff changeset
10329 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
10330 defsubr (&Sx_server_vendor);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10331 defsubr (&Sx_server_version);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10332 defsubr (&Sx_display_pixel_width);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10333 defsubr (&Sx_display_pixel_height);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10334 defsubr (&Sx_display_mm_width);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10335 defsubr (&Sx_display_mm_height);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10336 defsubr (&Sx_display_screens);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10337 defsubr (&Sx_display_planes);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10338 defsubr (&Sx_display_color_cells);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10339 defsubr (&Sx_display_visual_class);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10340 defsubr (&Sx_display_backing_store);
68328c3af38f (x_screen): Make this var file scope.
Richard M. Stallman <rms@gnu.org>
parents: 2197
diff changeset
10341 defsubr (&Sx_display_save_under);
2328
82e4fed9cdd6 * xfns.c (Fx_parse_geometry): Renamed from Fx_geometry.
Jim Blandy <jimb@redhat.com>
parents: 2295
diff changeset
10342 defsubr (&Sx_parse_geometry);
771
538c0bcb418e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
10343 defsubr (&Sx_create_frame);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10344 defsubr (&Sx_open_connection);
9690
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
10345 defsubr (&Sx_close_connection);
f6d4e1acb5a1 (Fx_create_frame): Don't increment refernce_count
Richard M. Stallman <rms@gnu.org>
parents: 9653
diff changeset
10346 defsubr (&Sx_display_list);
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10347 defsubr (&Sx_synchronize);
28044
88db4c84b6fd Remove a buch of really old code in #if 0.
Gerd Moellmann <gerd@gnu.org>
parents: 28010
diff changeset
10348 defsubr (&Sx_focus_frame);
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10349
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10350 /* Setting callback functions for fontset handler. */
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10351 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
10352
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10353 #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
10354 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
10355 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
10356 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10357
17048
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10358 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
10359 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
10360 query_font_func = x_query_font;
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10361 set_frame_fontset_func = x_set_font;
2da4e24ceee5 Include charset.h and fontset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16966
diff changeset
10362 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
10363
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10364 /* Images. */
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10365 Qxbm = intern ("xbm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10366 staticpro (&Qxbm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10367 QCtype = intern (":type");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10368 staticpro (&QCtype);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10369 QCalgorithm = intern (":algorithm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10370 staticpro (&QCalgorithm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10371 QCheuristic_mask = intern (":heuristic-mask");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10372 staticpro (&QCheuristic_mask);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10373 QCcolor_symbols = intern (":color-symbols");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10374 staticpro (&QCcolor_symbols);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10375 QCascent = intern (":ascent");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10376 staticpro (&QCascent);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10377 QCmargin = intern (":margin");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10378 staticpro (&QCmargin);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10379 QCrelief = intern (":relief");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10380 staticpro (&QCrelief);
25628
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
10381 Qpostscript = intern ("postscript");
98e238950125 (x_build_heuristic_mask): Accept a list `(R G B)'
Gerd Moellmann <gerd@gnu.org>
parents: 25620
diff changeset
10382 staticpro (&Qpostscript);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10383 QCloader = intern (":loader");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10384 staticpro (&QCloader);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10385 QCbounding_box = intern (":bounding-box");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10386 staticpro (&QCbounding_box);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10387 QCpt_width = intern (":pt-width");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10388 staticpro (&QCpt_width);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10389 QCpt_height = intern (":pt-height");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10390 staticpro (&QCpt_height);
25620
1c991744ce13 (QCindex): New.
Gerd Moellmann <gerd@gnu.org>
parents: 25593
diff changeset
10391 QCindex = intern (":index");
1c991744ce13 (QCindex): New.
Gerd Moellmann <gerd@gnu.org>
parents: 25593
diff changeset
10392 staticpro (&QCindex);
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10393 Qpbm = intern ("pbm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10394 staticpro (&Qpbm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10395
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10396 #if HAVE_XPM
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10397 Qxpm = intern ("xpm");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10398 staticpro (&Qxpm);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10399 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10400
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10401 #if HAVE_JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10402 Qjpeg = intern ("jpeg");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10403 staticpro (&Qjpeg);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10404 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10405
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10406 #if HAVE_TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10407 Qtiff = intern ("tiff");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10408 staticpro (&Qtiff);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10409 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10410
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10411 #if HAVE_GIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10412 Qgif = intern ("gif");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10413 staticpro (&Qgif);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10414 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10415
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10416 #if HAVE_PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10417 Qpng = intern ("png");
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10418 staticpro (&Qpng);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10419 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10420
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10421 defsubr (&Sclear_image_cache);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10422
27864
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
10423 busy_cursor_atimer = NULL;
ea05cbe65943 (inhibit_busy_cursor, busy_count): Removed.
Gerd Moellmann <gerd@gnu.org>
parents: 27798
diff changeset
10424 busy_cursor_shown_p = 0;
24994
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10425
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10426 defsubr (&Sx_show_tip);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10427 defsubr (&Sx_hide_tip);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10428 staticpro (&tip_timer);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10429 tip_timer = Qnil;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10430
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10431 #ifdef USE_MOTIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10432 defsubr (&Sx_file_dialog);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10433 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10434 }
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10435
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10436
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10437 void
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10438 init_xfns ()
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10439 {
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10440 image_types = NULL;
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10441 Vimage_types = Qnil;
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 define_image_type (&xbm_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10444 define_image_type (&gs_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10445 define_image_type (&pbm_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10446
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10447 #if HAVE_XPM
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10448 define_image_type (&xpm_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10449 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10450
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10451 #if HAVE_JPEG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10452 define_image_type (&jpeg_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10453 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10454
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10455 #if HAVE_TIFF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10456 define_image_type (&tiff_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10457 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10458
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10459 #if HAVE_GIF
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10460 define_image_type (&gif_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10461 #endif
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10462
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10463 #if HAVE_PNG
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10464 define_image_type (&png_type);
d549b7ac676d (x_real_positions): Don't subtract window borders
Gerd Moellmann <gerd@gnu.org>
parents: 24905
diff changeset
10465 #endif
389
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10466 }
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10467
6e0510766e66 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10468 #endif /* HAVE_X_WINDOWS */