aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-09-29 20:09:37 -0700
committerPaul Eggert2016-09-29 20:13:40 -0700
commit3c2c50260e19deff2a0a054882eaea4049f25a2f (patch)
tree09b502d87a2ef0440bedd7ce676be26ea5730f14 /src
parentcbb2e845187bfbcc62e2accc9df7891a2326608a (diff)
downloademacs-3c2c50260e19deff2a0a054882eaea4049f25a2f.tar.gz
emacs-3c2c50260e19deff2a0a054882eaea4049f25a2f.zip
Fix problems found by static checking --with-ns
This is for Fedora 24 when configured with --enable-gcc-warnings. Although it does not fix all the problems, it fixes many of them. * src/frame.c (XParseGeometry): * src/nsterm.m (mouseDown:): Mark locals with UNINIT to pacify --enable-gcc-warnings. * src/image.c (PIX_MASK_DRAW, DefaultDepthOfScreen): Remove unused macros. (slurp_file xbm_scan, xbm_read_bitmap_data, xbm_load_image) (xbm_file_p, xbm_load, xpm_scan, xpm_make_color_table_v) (xpm_put_color_table_v, xpm_get_color_table_v) (xpm_make_color_table_h, xpm_put_color_table_h) (xpm_get_color_table_h, xpm_load_image, xpm_load) (pbm_next_char, pbm_scan_number, pbm_load, svg_load) (svg_load_image): * src/nsfns.m (x_get_string_resource): * src/nsimage.m (ns_image_from_XBM): Fix pointer signedness problems. * src/image.c (xpm_load_image, x_build_heuristic_mask, pbm_load) (imagemagick_load_image): Omit unused locals. * src/nsfns.m (ns_send_types, ns_return_types, ns_drag_types) (Fx_open_connection): * src/nsfont.m (ns_antialias_threshold): Move extern decl to nsterm.h so it can be checked. * src/nsmenu.m (svcsMenu, dockMenu): Move to the only file that uses them, so they can be static. * src/nsterm.h (find_and_call_menu_selection): * src/nsterm.m (x_set_frame_alpha): Omit duplicate decls. * src/nsterm.h (ns_dump_glyphstring): Mark as EXTERNALLY_VISIBLE. * src/nsfns.m (ns_tooltip, ns_display_info_for_name) (ns_set_name_as_filename, x_set_menu_bar_lines) (x_set_tool_bar_lines, x_set_internal_border_width): * src/nsterm.m (ns_drag_types, ns_draw_text_decoration): Now static. * src/nsfns.m (ns_lisp_to_cursor_type, ns_cursor_type_to_lisp): * src/nsterm.m (ns_free_indexed_color, ns_color_to_lisp): Remove; unused. * src/nsfont.m (ns_dump_glyphstring): * src/nsterm.m (hide_bell, ns_get_color, ns_color_to_lisp) (ns_clear_frame, keyDown:): Fix signedness problem with printf arg. * src/nsterm.h (ns_input_events, ns_finish_events): * src/nsterm.m (ns_finish_events, hide_bell): Prototype the decls. * src/nsterm.m (NSMenuDidBeginTrackingNotification): Omit unnecessary decl. (dockMenu): (mainMenu) [NS_IMPL_COCOA]: Now static, and in this file. (ns_dumpglyphs_box_or_relief, changeFont:, initFrameFromEmacs:) (toggleFullScreen:): Use FACE_FROM_ID instead of FACE_FROM_ID_OR_NULL in contexts where the caller expects the result to be non-null. (applicationShouldTerminate:): Fix misleading indentation.
Diffstat (limited to 'src')
-rw-r--r--src/frame.c4
-rw-r--r--src/image.c175
-rw-r--r--src/nsfns.m60
-rw-r--r--src/nsfont.m8
-rw-r--r--src/nsimage.m4
-rw-r--r--src/nsmenu.m3
-rw-r--r--src/nsterm.h25
-rw-r--r--src/nsterm.m119
8 files changed, 132 insertions, 266 deletions
diff --git a/src/frame.c b/src/frame.c
index 166623c980c..42a01f57724 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -4433,8 +4433,8 @@ XParseGeometry (char *string,
4433{ 4433{
4434 int mask = NoValue; 4434 int mask = NoValue;
4435 char *strind; 4435 char *strind;
4436 unsigned long tempWidth, tempHeight; 4436 unsigned long tempWidth UNINIT, tempHeight UNINIT;
4437 long int tempX, tempY; 4437 long int tempX UNINIT, tempY UNINIT;
4438 char *nextCharacter; 4438 char *nextCharacter;
4439 4439
4440 if (string == NULL || *string == '\0') 4440 if (string == NULL || *string == '\0')
diff --git a/src/image.c b/src/image.c
index 53ec3873632..e508550629c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -97,11 +97,9 @@ typedef struct ns_bitmap_record Bitmap_Record;
97#define NO_PIXMAP 0 97#define NO_PIXMAP 0
98 98
99#define PIX_MASK_RETAIN 0 99#define PIX_MASK_RETAIN 0
100#define PIX_MASK_DRAW 1
101 100
102#define x_defined_color(f, name, color_def, alloc) \ 101#define x_defined_color(f, name, color_def, alloc) \
103 ns_defined_color (f, name, color_def, alloc, 0) 102 ns_defined_color (f, name, color_def, alloc, 0)
104#define DefaultDepthOfScreen(screen) x_display_list->n_planes
105#endif /* HAVE_NS */ 103#endif /* HAVE_NS */
106 104
107#if (defined HAVE_X_WINDOWS \ 105#if (defined HAVE_X_WINDOWS \
@@ -2333,12 +2331,12 @@ x_find_image_file (Lisp_Object file)
2333 occurred. FD is a file descriptor open for reading FILE. Set 2331 occurred. FD is a file descriptor open for reading FILE. Set
2334 *SIZE to the size of the file. */ 2332 *SIZE to the size of the file. */
2335 2333
2336static unsigned char * 2334static char *
2337slurp_file (int fd, ptrdiff_t *size) 2335slurp_file (int fd, ptrdiff_t *size)
2338{ 2336{
2339 FILE *fp = fdopen (fd, "rb"); 2337 FILE *fp = fdopen (fd, "rb");
2340 2338
2341 unsigned char *buf = NULL; 2339 char *buf = NULL;
2342 struct stat st; 2340 struct stat st;
2343 2341
2344 if (fp) 2342 if (fp)
@@ -2563,9 +2561,9 @@ xbm_image_p (Lisp_Object object)
2563 scanning a number, store its value in *IVAL. */ 2561 scanning a number, store its value in *IVAL. */
2564 2562
2565static int 2563static int
2566xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) 2564xbm_scan (char **s, char *end, char *sval, int *ival)
2567{ 2565{
2568 unsigned int c; 2566 unsigned char c;
2569 2567
2570 loop: 2568 loop:
2571 2569
@@ -2617,7 +2615,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
2617 if (*s < end) 2615 if (*s < end)
2618 *s = *s - 1; 2616 *s = *s - 1;
2619 *ival = value; 2617 *ival = value;
2620 c = XBM_TK_NUMBER; 2618 return XBM_TK_NUMBER;
2621 } 2619 }
2622 else if (c_isalpha (c) || c == '_') 2620 else if (c_isalpha (c) || c == '_')
2623 { 2621 {
@@ -2628,7 +2626,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
2628 *sval = 0; 2626 *sval = 0;
2629 if (*s < end) 2627 if (*s < end)
2630 *s = *s - 1; 2628 *s = *s - 1;
2631 c = XBM_TK_IDENT; 2629 return XBM_TK_IDENT;
2632 } 2630 }
2633 else if (c == '/' && **s == '*') 2631 else if (c == '/' && **s == '*')
2634 { 2632 {
@@ -2765,11 +2763,11 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
2765 bitmap remains unread). */ 2763 bitmap remains unread). */
2766 2764
2767static bool 2765static bool
2768xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end, 2766xbm_read_bitmap_data (struct frame *f, char *contents, char *end,
2769 int *width, int *height, char **data, 2767 int *width, int *height, char **data,
2770 bool inhibit_image_error) 2768 bool inhibit_image_error)
2771{ 2769{
2772 unsigned char *s = contents; 2770 char *s = contents;
2773 char buffer[BUFSIZ]; 2771 char buffer[BUFSIZ];
2774 bool padding_p = 0; 2772 bool padding_p = 0;
2775 bool v10 = 0; 2773 bool v10 = 0;
@@ -2926,8 +2924,7 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
2926 successful. */ 2924 successful. */
2927 2925
2928static bool 2926static bool
2929xbm_load_image (struct frame *f, struct image *img, unsigned char *contents, 2927xbm_load_image (struct frame *f, struct image *img, char *contents, char *end)
2930 unsigned char *end)
2931{ 2928{
2932 bool rc; 2929 bool rc;
2933 char *data; 2930 char *data;
@@ -2987,8 +2984,8 @@ xbm_file_p (Lisp_Object data)
2987{ 2984{
2988 int w, h; 2985 int w, h;
2989 return (STRINGP (data) 2986 return (STRINGP (data)
2990 && xbm_read_bitmap_data (NULL, SDATA (data), 2987 && xbm_read_bitmap_data (NULL, SSDATA (data),
2991 (SDATA (data) + SBYTES (data)), 2988 SSDATA (data) + SBYTES (data),
2992 &w, &h, NULL, 1)); 2989 &w, &h, NULL, 1));
2993} 2990}
2994 2991
@@ -3017,7 +3014,7 @@ xbm_load (struct frame *f, struct image *img)
3017 } 3014 }
3018 3015
3019 ptrdiff_t size; 3016 ptrdiff_t size;
3020 unsigned char *contents = slurp_file (fd, &size); 3017 char *contents = slurp_file (fd, &size);
3021 if (contents == NULL) 3018 if (contents == NULL)
3022 { 3019 {
3023 image_error ("Error loading XBM image `%s'", file); 3020 image_error ("Error loading XBM image `%s'", file);
@@ -3078,9 +3075,8 @@ xbm_load (struct frame *f, struct image *img)
3078 } 3075 }
3079 3076
3080 if (in_memory_file_p) 3077 if (in_memory_file_p)
3081 success_p = xbm_load_image (f, img, SDATA (data), 3078 success_p = xbm_load_image (f, img, SSDATA (data),
3082 (SDATA (data) 3079 SSDATA (data) + SBYTES (data));
3083 + SBYTES (data)));
3084 else 3080 else
3085 { 3081 {
3086 USE_SAFE_ALLOCA; 3082 USE_SAFE_ALLOCA;
@@ -3894,14 +3890,12 @@ xpm_load (struct frame *f, struct image *img)
3894/* XPM support functions for NS where libxpm is not available. 3890/* XPM support functions for NS where libxpm is not available.
3895 Only XPM version 3 (without any extensions) is supported. */ 3891 Only XPM version 3 (without any extensions) is supported. */
3896 3892
3897static void xpm_put_color_table_v (Lisp_Object, const unsigned char *, 3893static void xpm_put_color_table_v (Lisp_Object, const char *,
3898 int, Lisp_Object); 3894 int, Lisp_Object);
3899static Lisp_Object xpm_get_color_table_v (Lisp_Object, 3895static Lisp_Object xpm_get_color_table_v (Lisp_Object, const char *, int);
3900 const unsigned char *, int); 3896static void xpm_put_color_table_h (Lisp_Object, const char *,
3901static void xpm_put_color_table_h (Lisp_Object, const unsigned char *,
3902 int, Lisp_Object); 3897 int, Lisp_Object);
3903static Lisp_Object xpm_get_color_table_h (Lisp_Object, 3898static Lisp_Object xpm_get_color_table_h (Lisp_Object, const char *, int);
3904 const unsigned char *, int);
3905 3899
3906/* Tokens returned from xpm_scan. */ 3900/* Tokens returned from xpm_scan. */
3907 3901
@@ -3920,12 +3914,9 @@ enum xpm_token
3920 length of the corresponding token, respectively. */ 3914 length of the corresponding token, respectively. */
3921 3915
3922static int 3916static int
3923xpm_scan (const unsigned char **s, 3917xpm_scan (const char **s, const char *end, const char **beg, ptrdiff_t *len)
3924 const unsigned char *end,
3925 const unsigned char **beg,
3926 ptrdiff_t *len)
3927{ 3918{
3928 int c; 3919 unsigned char c;
3929 3920
3930 while (*s < end) 3921 while (*s < end)
3931 { 3922 {
@@ -3988,12 +3979,9 @@ xpm_scan (const unsigned char **s,
3988 hash table is used. */ 3979 hash table is used. */
3989 3980
3990static Lisp_Object 3981static Lisp_Object
3991xpm_make_color_table_v (void (**put_func) (Lisp_Object, 3982xpm_make_color_table_v (void (**put_func) (Lisp_Object, const char *, int,
3992 const unsigned char *,
3993 int,
3994 Lisp_Object), 3983 Lisp_Object),
3995 Lisp_Object (**get_func) (Lisp_Object, 3984 Lisp_Object (**get_func) (Lisp_Object, const char *,
3996 const unsigned char *,
3997 int)) 3985 int))
3998{ 3986{
3999 *put_func = xpm_put_color_table_v; 3987 *put_func = xpm_put_color_table_v;
@@ -4003,28 +3991,27 @@ xpm_make_color_table_v (void (**put_func) (Lisp_Object,
4003 3991
4004static void 3992static void
4005xpm_put_color_table_v (Lisp_Object color_table, 3993xpm_put_color_table_v (Lisp_Object color_table,
4006 const unsigned char *chars_start, 3994 const char *chars_start,
4007 int chars_len, 3995 int chars_len,
4008 Lisp_Object color) 3996 Lisp_Object color)
4009{ 3997{
4010 ASET (color_table, *chars_start, color); 3998 unsigned char uc = *chars_start;
3999 ASET (color_table, uc, color);
4011} 4000}
4012 4001
4013static Lisp_Object 4002static Lisp_Object
4014xpm_get_color_table_v (Lisp_Object color_table, 4003xpm_get_color_table_v (Lisp_Object color_table,
4015 const unsigned char *chars_start, 4004 const char *chars_start,
4016 int chars_len) 4005 int chars_len)
4017{ 4006{
4018 return AREF (color_table, *chars_start); 4007 unsigned char uc = *chars_start;
4008 return AREF (color_table, uc);
4019} 4009}
4020 4010
4021static Lisp_Object 4011static Lisp_Object
4022xpm_make_color_table_h (void (**put_func) (Lisp_Object, 4012xpm_make_color_table_h (void (**put_func) (Lisp_Object, const char *, int,
4023 const unsigned char *,
4024 int,
4025 Lisp_Object), 4013 Lisp_Object),
4026 Lisp_Object (**get_func) (Lisp_Object, 4014 Lisp_Object (**get_func) (Lisp_Object, const char *,
4027 const unsigned char *,
4028 int)) 4015 int))
4029{ 4016{
4030 *put_func = xpm_put_color_table_h; 4017 *put_func = xpm_put_color_table_h;
@@ -4037,7 +4024,7 @@ xpm_make_color_table_h (void (**put_func) (Lisp_Object,
4037 4024
4038static void 4025static void
4039xpm_put_color_table_h (Lisp_Object color_table, 4026xpm_put_color_table_h (Lisp_Object color_table,
4040 const unsigned char *chars_start, 4027 const char *chars_start,
4041 int chars_len, 4028 int chars_len,
4042 Lisp_Object color) 4029 Lisp_Object color)
4043{ 4030{
@@ -4051,7 +4038,7 @@ xpm_put_color_table_h (Lisp_Object color_table,
4051 4038
4052static Lisp_Object 4039static Lisp_Object
4053xpm_get_color_table_h (Lisp_Object color_table, 4040xpm_get_color_table_h (Lisp_Object color_table,
4054 const unsigned char *chars_start, 4041 const char *chars_start,
4055 int chars_len) 4042 int chars_len)
4056{ 4043{
4057 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 4044 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
@@ -4085,20 +4072,22 @@ xpm_str_to_color_key (const char *s)
4085static bool 4072static bool
4086xpm_load_image (struct frame *f, 4073xpm_load_image (struct frame *f,
4087 struct image *img, 4074 struct image *img,
4088 const unsigned char *contents, 4075 const char *contents,
4089 const unsigned char *end) 4076 const char *end)
4090{ 4077{
4091 const unsigned char *s = contents, *beg, *str; 4078 const char *s = contents, *beg, *str;
4092 unsigned char buffer[BUFSIZ]; 4079 char buffer[BUFSIZ];
4093 int width, height, x, y; 4080 int width, height, x, y;
4094 int num_colors, chars_per_pixel; 4081 int num_colors, chars_per_pixel;
4095 ptrdiff_t len; 4082 ptrdiff_t len;
4096 int LA1; 4083 int LA1;
4097 void (*put_color_table) (Lisp_Object, const unsigned char *, int, Lisp_Object); 4084 void (*put_color_table) (Lisp_Object, const char *, int, Lisp_Object);
4098 Lisp_Object (*get_color_table) (Lisp_Object, const unsigned char *, int); 4085 Lisp_Object (*get_color_table) (Lisp_Object, const char *, int);
4099 Lisp_Object frame, color_symbols, color_table; 4086 Lisp_Object frame, color_symbols, color_table;
4100 int best_key; 4087 int best_key;
4088#ifndef HAVE_NS
4101 bool have_mask = false; 4089 bool have_mask = false;
4090#endif
4102 XImagePtr ximg = NULL, mask_img = NULL; 4091 XImagePtr ximg = NULL, mask_img = NULL;
4103 4092
4104#define match() \ 4093#define match() \
@@ -4337,7 +4326,7 @@ xpm_load (struct frame *f,
4337 } 4326 }
4338 4327
4339 ptrdiff_t size; 4328 ptrdiff_t size;
4340 unsigned char *contents = slurp_file (fd, &size); 4329 char *contents = slurp_file (fd, &size);
4341 if (contents == NULL) 4330 if (contents == NULL)
4342 { 4331 {
4343 image_error ("Error loading XPM image `%s'", file); 4332 image_error ("Error loading XPM image `%s'", file);
@@ -4357,8 +4346,8 @@ xpm_load (struct frame *f,
4357 image_error ("Invalid image data `%s'", data); 4346 image_error ("Invalid image data `%s'", data);
4358 return 0; 4347 return 0;
4359 } 4348 }
4360 success_p = xpm_load_image (f, img, SDATA (data), 4349 success_p = xpm_load_image (f, img, SSDATA (data),
4361 SDATA (data) + SBYTES (data)); 4350 SSDATA (data) + SBYTES (data));
4362 } 4351 }
4363 4352
4364 return success_p; 4353 return success_p;
@@ -5051,13 +5040,13 @@ static void
5051x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how) 5040x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
5052{ 5041{
5053 XImagePtr_or_DC ximg; 5042 XImagePtr_or_DC ximg;
5054#ifndef HAVE_NTGUI 5043#ifdef HAVE_NTGUI
5055 XImagePtr mask_img;
5056#else
5057 HGDIOBJ prev; 5044 HGDIOBJ prev;
5058 char *mask_img; 5045 char *mask_img;
5059 int row_width; 5046 int row_width;
5060#endif /* HAVE_NTGUI */ 5047#elif !defined HAVE_NS
5048 XImagePtr mask_img;
5049#endif
5061 int x, y; 5050 int x, y;
5062 bool use_img_background; 5051 bool use_img_background;
5063 unsigned long bg = 0; 5052 unsigned long bg = 0;
@@ -5232,20 +5221,22 @@ pbm_image_p (Lisp_Object object)
5232 end of input. */ 5221 end of input. */
5233 5222
5234static int 5223static int
5235pbm_next_char (unsigned char **s, unsigned char *end) 5224pbm_next_char (char **s, char *end)
5236{ 5225{
5237 int c = -1; 5226 while (*s < end)
5238
5239 while (*s < end && (c = *(*s)++, c == '#'))
5240 { 5227 {
5241 /* Skip to the next line break. */ 5228 unsigned char c = *(*s)++;
5242 while (*s < end && (c = *(*s)++, c != '\n' && c != '\r')) 5229 if (c != '#')
5243 ; 5230 return c;
5244 5231 while (*s < end)
5245 c = -1; 5232 {
5233 c = *(*s)++;
5234 if (c == '\n' || c == '\r')
5235 break;
5236 }
5246 } 5237 }
5247 5238
5248 return c; 5239 return -1;
5249} 5240}
5250 5241
5251 5242
@@ -5254,7 +5245,7 @@ pbm_next_char (unsigned char **s, unsigned char *end)
5254 end of input. */ 5245 end of input. */
5255 5246
5256static int 5247static int
5257pbm_scan_number (unsigned char **s, unsigned char *end) 5248pbm_scan_number (char **s, char *end)
5258{ 5249{
5259 int c = 0, val = -1; 5250 int c = 0, val = -1;
5260 5251
@@ -5284,12 +5275,9 @@ pbm_load (struct frame *f, struct image *img)
5284 int width, height, max_color_idx = 0; 5275 int width, height, max_color_idx = 0;
5285 Lisp_Object specified_file; 5276 Lisp_Object specified_file;
5286 enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type; 5277 enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type;
5287 unsigned char *contents = NULL; 5278 char *contents = NULL;
5288 unsigned char *end, *p; 5279 char *end, *p;
5289#ifdef USE_CAIRO 5280#ifndef USE_CAIRO
5290 unsigned char *data = 0;
5291 uint32_t *dataptr;
5292#else
5293 XImagePtr ximg; 5281 XImagePtr ximg;
5294#endif 5282#endif
5295 5283
@@ -5325,7 +5313,7 @@ pbm_load (struct frame *f, struct image *img)
5325 image_error ("Invalid image data `%s'", data); 5313 image_error ("Invalid image data `%s'", data);
5326 return 0; 5314 return 0;
5327 } 5315 }
5328 p = SDATA (data); 5316 p = SSDATA (data);
5329 end = p + SBYTES (data); 5317 end = p + SBYTES (data);
5330 } 5318 }
5331 5319
@@ -5376,8 +5364,8 @@ pbm_load (struct frame *f, struct image *img)
5376 height = pbm_scan_number (&p, end); 5364 height = pbm_scan_number (&p, end);
5377 5365
5378#ifdef USE_CAIRO 5366#ifdef USE_CAIRO
5379 data = (unsigned char *) xmalloc (width * height * 4); 5367 uint32_t *data = xmalloc (width * height * 4);
5380 dataptr = (uint32_t *) data; 5368 uint32_t *dataptr = data;
5381#endif 5369#endif
5382 5370
5383 if (type != PBM_MONO) 5371 if (type != PBM_MONO)
@@ -5406,7 +5394,8 @@ pbm_load (struct frame *f, struct image *img)
5406 5394
5407 if (type == PBM_MONO) 5395 if (type == PBM_MONO)
5408 { 5396 {
5409 int c = 0, g; 5397 unsigned char c = 0;
5398 int g;
5410 struct image_keyword fmt[PBM_LAST]; 5399 struct image_keyword fmt[PBM_LAST];
5411 unsigned long fg = FRAME_FOREGROUND_PIXEL (f); 5400 unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
5412 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); 5401 unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
@@ -8534,7 +8523,6 @@ imagemagick_load_image (struct frame *f, struct image *img,
8534 EMACS_INT ino; 8523 EMACS_INT ino;
8535 int desired_width, desired_height; 8524 int desired_width, desired_height;
8536 double rotation; 8525 double rotation;
8537 int pixelwidth;
8538 char hint_buffer[MaxTextExtent]; 8526 char hint_buffer[MaxTextExtent];
8539 char *filename_hint = NULL; 8527 char *filename_hint = NULL;
8540 8528
@@ -8763,7 +8751,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8763 on rgb display. 8751 on rgb display.
8764 seems about 3 times as fast as pixel pushing(not carefully measured) 8752 seems about 3 times as fast as pixel pushing(not carefully measured)
8765 */ 8753 */
8766 pixelwidth = CharPixel; /*??? TODO figure out*/ 8754 int pixelwidth = CharPixel; /*??? TODO figure out*/
8767 MagickExportImagePixels (image_wand, 0, 0, width, height, 8755 MagickExportImagePixels (image_wand, 0, 0, width, height,
8768 exportdepth, pixelwidth, ximg->data); 8756 exportdepth, pixelwidth, ximg->data);
8769 } 8757 }
@@ -8947,7 +8935,7 @@ static bool svg_image_p (Lisp_Object object);
8947static bool svg_load (struct frame *f, struct image *img); 8935static bool svg_load (struct frame *f, struct image *img);
8948 8936
8949static bool svg_load_image (struct frame *, struct image *, 8937static bool svg_load_image (struct frame *, struct image *,
8950 unsigned char *, ptrdiff_t, char *); 8938 char *, ptrdiff_t, char *);
8951 8939
8952/* Indices of image specification fields in svg_format, below. */ 8940/* Indices of image specification fields in svg_format, below. */
8953 8941
@@ -9155,7 +9143,7 @@ svg_load (struct frame *f, struct image *img)
9155 9143
9156 /* Read the entire file into memory. */ 9144 /* Read the entire file into memory. */
9157 ptrdiff_t size; 9145 ptrdiff_t size;
9158 unsigned char *contents = slurp_file (fd, &size); 9146 char *contents = slurp_file (fd, &size);
9159 if (contents == NULL) 9147 if (contents == NULL)
9160 { 9148 {
9161 image_error ("Error loading SVG image `%s'", file); 9149 image_error ("Error loading SVG image `%s'", file);
@@ -9179,7 +9167,7 @@ svg_load (struct frame *f, struct image *img)
9179 return 0; 9167 return 0;
9180 } 9168 }
9181 original_filename = BVAR (current_buffer, filename); 9169 original_filename = BVAR (current_buffer, filename);
9182 success_p = svg_load_image (f, img, SDATA (data), SBYTES (data), 9170 success_p = svg_load_image (f, img, SSDATA (data), SBYTES (data),
9183 (NILP (original_filename) ? NULL 9171 (NILP (original_filename) ? NULL
9184 : SSDATA (original_filename))); 9172 : SSDATA (original_filename)));
9185 } 9173 }
@@ -9187,19 +9175,16 @@ svg_load (struct frame *f, struct image *img)
9187 return success_p; 9175 return success_p;
9188} 9176}
9189 9177
9190/* svg_load_image is a helper function for svg_load, which does the 9178/* Load frame F and image IMG. CONTENTS contains the SVG XML data to
9191 actual loading given contents and size, apart from frame and image 9179 be parsed, SIZE is its size, and FILENAME is the name of the SVG
9192 structures, passed from svg_load. 9180 file being loaded.
9193 9181
9194 Uses librsvg to do most of the image processing. 9182 Use librsvg to do most of the image processing.
9195 9183
9196 Returns true when successful. */ 9184 Return true when successful. */
9197static bool 9185static bool
9198svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */ 9186svg_load_image (struct frame *f, struct image *img, char *contents,
9199 struct image *img, /* Pointer to emacs image structure. */ 9187 ptrdiff_t size, char *filename)
9200 unsigned char *contents, /* String containing the SVG XML data to be parsed. */
9201 ptrdiff_t size, /* Size of data in bytes. */
9202 char *filename) /* Name of SVG file being loaded. */
9203{ 9188{
9204 RsvgHandle *rsvg_handle; 9189 RsvgHandle *rsvg_handle;
9205 RsvgDimensionData dimension_data; 9190 RsvgDimensionData dimension_data;
@@ -9226,7 +9211,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9226 rsvg_handle_set_base_uri(rsvg_handle, filename); 9211 rsvg_handle_set_base_uri(rsvg_handle, filename);
9227 9212
9228 /* Parse the contents argument and fill in the rsvg_handle. */ 9213 /* Parse the contents argument and fill in the rsvg_handle. */
9229 rsvg_handle_write (rsvg_handle, contents, size, &err); 9214 rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err);
9230 if (err) goto rsvg_error; 9215 if (err) goto rsvg_error;
9231 9216
9232 /* The parsing is complete, rsvg_handle is ready to used, close it 9217 /* The parsing is complete, rsvg_handle is ready to used, close it
diff --git a/src/nsfns.m b/src/nsfns.m
index 4566b7e38e8..ce2622c8062 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -52,12 +52,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
52 52
53#ifdef HAVE_NS 53#ifdef HAVE_NS
54 54
55extern NSArray *ns_send_types, *ns_return_types, *ns_drag_types; 55static EmacsTooltip *ns_tooltip = nil;
56
57EmacsTooltip *ns_tooltip = nil;
58
59/* Need forward declaration here to preserve organizational integrity of file */
60Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
61 56
62/* Static variables to handle applescript execution. */ 57/* Static variables to handle applescript execution. */
63static Lisp_Object as_script, *as_result; 58static Lisp_Object as_script, *as_result;
@@ -65,6 +60,8 @@ static int as_status;
65 60
66static ptrdiff_t image_cache_refcount; 61static ptrdiff_t image_cache_refcount;
67 62
63static struct ns_display_info *ns_display_info_for_name (Lisp_Object);
64static void ns_set_name_as_filename (struct frame *);
68 65
69/* ========================================================================== 66/* ==========================================================================
70 67
@@ -132,7 +129,7 @@ ns_get_window (Lisp_Object maybeFrame)
132 129
133/* Return the X display structure for the display named NAME. 130/* Return the X display structure for the display named NAME.
134 Open a new connection if necessary. */ 131 Open a new connection if necessary. */
135struct ns_display_info * 132static struct ns_display_info *
136ns_display_info_for_name (Lisp_Object name) 133ns_display_info_for_name (Lisp_Object name)
137{ 134{
138 struct ns_display_info *dpyinfo; 135 struct ns_display_info *dpyinfo;
@@ -523,7 +520,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
523} 520}
524 521
525 522
526void 523static void
527ns_set_name_as_filename (struct frame *f) 524ns_set_name_as_filename (struct frame *f)
528{ 525{
529 NSView *view; 526 NSView *view;
@@ -622,7 +619,7 @@ ns_set_doc_edited (void)
622} 619}
623 620
624 621
625void 622static void
626x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) 623x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
627{ 624{
628 int nlines; 625 int nlines;
@@ -652,7 +649,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
652 649
653 650
654/* toolbar support */ 651/* toolbar support */
655void 652static void
656x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) 653x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
657{ 654{
658 /* Currently, when the tool bar change state, the frame is resized. 655 /* Currently, when the tool bar change state, the frame is resized.
@@ -720,7 +717,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
720} 717}
721 718
722 719
723void 720static void
724x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 721x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
725{ 722{
726 int old_width = FRAME_INTERNAL_BORDER_WIDTH (f); 723 int old_width = FRAME_INTERNAL_BORDER_WIDTH (f);
@@ -850,40 +847,6 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
850 [view setMiniwindowImage: setMini]; 847 [view setMiniwindowImage: setMini];
851} 848}
852 849
853
854/* TODO: move to nsterm? */
855int
856ns_lisp_to_cursor_type (Lisp_Object arg)
857{
858 char *str;
859 if (XTYPE (arg) == Lisp_String)
860 str = SSDATA (arg);
861 else if (XTYPE (arg) == Lisp_Symbol)
862 str = SSDATA (SYMBOL_NAME (arg));
863 else return -1;
864 if (!strcmp (str, "box")) return FILLED_BOX_CURSOR;
865 if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR;
866 if (!strcmp (str, "hbar")) return HBAR_CURSOR;
867 if (!strcmp (str, "bar")) return BAR_CURSOR;
868 if (!strcmp (str, "no")) return NO_CURSOR;
869 return -1;
870}
871
872
873Lisp_Object
874ns_cursor_type_to_lisp (int arg)
875{
876 switch (arg)
877 {
878 case FILLED_BOX_CURSOR: return Qbox;
879 case HOLLOW_BOX_CURSOR: return Qhollow;
880 case HBAR_CURSOR: return Qhbar;
881 case BAR_CURSOR: return Qbar;
882 case NO_CURSOR:
883 default: return intern ("no");
884 }
885}
886
887/* This is the same as the xfns.c definition. */ 850/* This is the same as the xfns.c definition. */
888static void 851static void
889x_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 852x_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
@@ -2273,9 +2236,10 @@ x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
2273 return NULL; 2236 return NULL;
2274 2237
2275 res = ns_get_defaults_value (toCheck); 2238 res = ns_get_defaults_value (toCheck);
2276 return (!res ? NULL : 2239 return (char *) (!res ? NULL
2277 (!c_strncasecmp (res, "YES", 3) ? "true" : 2240 : !c_strncasecmp (res, "YES", 3) ? "true"
2278 (!c_strncasecmp (res, "NO", 2) ? "false" : (char *) res))); 2241 : !c_strncasecmp (res, "NO", 2) ? "false"
2242 : res);
2279} 2243}
2280 2244
2281 2245
diff --git a/src/nsfont.m b/src/nsfont.m
index 569a69f9fe8..be7d2ec36b9 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -45,9 +45,6 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu)
45#define NSFONT_TRACE 0 45#define NSFONT_TRACE 0
46#define LCD_SMOOTHING_MARGIN 2 46#define LCD_SMOOTHING_MARGIN 2
47 47
48extern float ns_antialias_threshold;
49
50
51/* font glyph and metrics caching functions, implemented at end */ 48/* font glyph and metrics caching functions, implemented at end */
52static void ns_uni_to_glyphs (struct nsfont_info *font_info, 49static void ns_uni_to_glyphs (struct nsfont_info *font_info,
53 unsigned char block); 50 unsigned char block);
@@ -1516,7 +1513,10 @@ ns_dump_glyphstring (struct glyph_string *s)
1516 s->nchars, s->x, s->y, s->left_overhang, s->right_overhang, 1513 s->nchars, s->x, s->y, s->left_overhang, s->right_overhang,
1517 s->row->overlapping_p, s->background_filled_p); 1514 s->row->overlapping_p, s->background_filled_p);
1518 for (i =0; i<s->nchars; i++) 1515 for (i =0; i<s->nchars; i++)
1519 fprintf (stderr, "%c", s->first_glyph[i].u.ch); 1516 {
1517 int c = s->first_glyph[i].u.ch;
1518 fprintf (stderr, "%c", c);
1519 }
1520 fprintf (stderr, "\n"); 1520 fprintf (stderr, "\n");
1521} 1521}
1522 1522
diff --git a/src/nsimage.m b/src/nsimage.m
index 5b2534b9007..6d1b3937f94 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -46,11 +46,11 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
46 ========================================================================== */ 46 ========================================================================== */
47 47
48void * 48void *
49ns_image_from_XBM (unsigned char *bits, int width, int height, 49ns_image_from_XBM (char *bits, int width, int height,
50 unsigned long fg, unsigned long bg) 50 unsigned long fg, unsigned long bg)
51{ 51{
52 NSTRACE ("ns_image_from_XBM"); 52 NSTRACE ("ns_image_from_XBM");
53 return [[EmacsImage alloc] initFromXBM: bits 53 return [[EmacsImage alloc] initFromXBM: (unsigned char *) bits
54 width: width height: height 54 width: width height: height
55 fg: fg bg: bg]; 55 fg: fg bg: bg];
56} 56}
diff --git a/src/nsmenu.m b/src/nsmenu.m
index ea9f790990f..470d6d0dbcf 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -53,8 +53,7 @@ Carbon version by Yamamoto Mitsuharu. */
53#endif 53#endif
54 54
55extern long context_menu_value; 55extern long context_menu_value;
56EmacsMenu *mainMenu, *svcsMenu, *dockMenu; 56EmacsMenu *svcsMenu;
57
58/* Nonzero means a menu is currently active. */ 57/* Nonzero means a menu is currently active. */
59static int popup_activated_flag; 58static int popup_activated_flag;
60 59
diff --git a/src/nsterm.h b/src/nsterm.h
index c12c791c635..35c6e1a4cbc 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -731,7 +731,7 @@ char const * nstrace_fullscreen_type_name (int);
731 731
732extern NSArray *ns_send_types, *ns_return_types; 732extern NSArray *ns_send_types, *ns_return_types;
733extern NSString *ns_app_name; 733extern NSString *ns_app_name;
734extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu; 734extern EmacsMenu *svcsMenu;
735 735
736/* Apple removed the declaration, but kept the implementation */ 736/* Apple removed the declaration, but kept the implementation */
737#if defined (NS_IMPL_COCOA) 737#if defined (NS_IMPL_COCOA)
@@ -924,8 +924,6 @@ struct ns_display_info
924/* This is a chain of structures for all the NS displays currently in use. */ 924/* This is a chain of structures for all the NS displays currently in use. */
925extern struct ns_display_info *x_display_list; 925extern struct ns_display_info *x_display_list;
926 926
927extern struct ns_display_info *ns_display_info_for_name (Lisp_Object name);
928
929struct ns_output 927struct ns_output
930{ 928{
931#ifdef __OBJC__ 929#ifdef __OBJC__
@@ -1099,7 +1097,7 @@ extern void nsfont_make_fontset_for_font (Lisp_Object name,
1099 1097
1100/* In nsfont, for debugging */ 1098/* In nsfont, for debugging */
1101struct glyph_string; 1099struct glyph_string;
1102void ns_dump_glyphstring (struct glyph_string *s); 1100void ns_dump_glyphstring (struct glyph_string *s) EXTERNALLY_VISIBLE;
1103 1101
1104/* Implemented in nsterm, published in or needed from nsfns. */ 1102/* Implemented in nsterm, published in or needed from nsfns. */
1105extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern, 1103extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern,
@@ -1116,9 +1114,6 @@ extern void ns_string_to_pasteboard (id pb, Lisp_Object str);
1116extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name, 1114extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name,
1117 Lisp_Object target_type); 1115 Lisp_Object target_type);
1118extern void nxatoms_of_nsselect (void); 1116extern void nxatoms_of_nsselect (void);
1119extern int ns_lisp_to_cursor_type (Lisp_Object arg);
1120extern Lisp_Object ns_cursor_type_to_lisp (int arg);
1121extern void ns_set_name_as_filename (struct frame *f);
1122extern void ns_set_doc_edited (void); 1117extern void ns_set_doc_edited (void);
1123 1118
1124extern bool 1119extern bool
@@ -1130,11 +1125,9 @@ extern void
1130ns_query_color (void *col, XColor *color_def, int setPixel); 1125ns_query_color (void *col, XColor *color_def, int setPixel);
1131 1126
1132#ifdef __OBJC__ 1127#ifdef __OBJC__
1133extern Lisp_Object ns_color_to_lisp (NSColor *col);
1134extern int ns_lisp_to_color (Lisp_Object color, NSColor **col); 1128extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
1135extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f); 1129extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
1136extern unsigned long ns_index_color (NSColor *color, struct frame *f); 1130extern unsigned long ns_index_color (NSColor *color, struct frame *f);
1137extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
1138extern const char *ns_get_pending_menu_title (void); 1131extern const char *ns_get_pending_menu_title (void);
1139extern void ns_check_menu_open (NSMenu *menu); 1132extern void ns_check_menu_open (NSMenu *menu);
1140extern void ns_check_pending_open_menu (void); 1133extern void ns_check_pending_open_menu (void);
@@ -1152,8 +1145,6 @@ extern void ns_init_locale (void);
1152/* in nsmenu */ 1145/* in nsmenu */
1153extern void update_frame_tool_bar (struct frame *f); 1146extern void update_frame_tool_bar (struct frame *f);
1154extern void free_frame_tool_bar (struct frame *f); 1147extern void free_frame_tool_bar (struct frame *f);
1155extern void find_and_call_menu_selection (struct frame *f,
1156 int menu_bar_items_used, Lisp_Object vector, void *client_data);
1157extern Lisp_Object find_and_return_menu_selection (struct frame *f, 1148extern Lisp_Object find_and_return_menu_selection (struct frame *f,
1158 bool keymaps, 1149 bool keymaps,
1159 void *client_data); 1150 void *client_data);
@@ -1176,7 +1167,7 @@ extern void syms_of_nsselect (void);
1176 1167
1177/* From nsimage.m, needed in image.c */ 1168/* From nsimage.m, needed in image.c */
1178struct image; 1169struct image;
1179extern void *ns_image_from_XBM (unsigned char *bits, int width, int height, 1170extern void *ns_image_from_XBM (char *bits, int width, int height,
1180 unsigned long fg, unsigned long bg); 1171 unsigned long fg, unsigned long bg);
1181extern void *ns_image_for_XPM (int width, int height, int depth); 1172extern void *ns_image_for_XPM (int width, int height, int depth);
1182extern void *ns_image_from_file (Lisp_Object file); 1173extern void *ns_image_from_file (Lisp_Object file);
@@ -1192,6 +1183,7 @@ extern int x_display_pixel_height (struct ns_display_info *);
1192extern int x_display_pixel_width (struct ns_display_info *); 1183extern int x_display_pixel_width (struct ns_display_info *);
1193 1184
1194/* This in nsterm.m */ 1185/* This in nsterm.m */
1186extern float ns_antialias_threshold;
1195extern void x_destroy_window (struct frame *f); 1187extern void x_destroy_window (struct frame *f);
1196extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, 1188extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
1197 fd_set *exceptfds, struct timespec const *timeout, 1189 fd_set *exceptfds, struct timespec const *timeout,
@@ -1199,14 +1191,11 @@ extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
1199extern unsigned long ns_get_rgb_color (struct frame *f, 1191extern unsigned long ns_get_rgb_color (struct frame *f,
1200 float r, float g, float b, float a); 1192 float r, float g, float b, float a);
1201 1193
1202extern void ns_init_events (); 1194struct input_event;
1203extern void ns_finish_events (); 1195extern void ns_init_events (struct input_event *);
1196extern void ns_finish_events (void);
1204 1197
1205#ifdef __OBJC__ 1198#ifdef __OBJC__
1206/* From nsterm.m, needed in nsfont.m. */
1207extern void
1208ns_draw_text_decoration (struct glyph_string *s, struct face *face,
1209 NSColor *defaultCol, CGFloat width, CGFloat x);
1210/* Needed in nsfns.m. */ 1199/* Needed in nsfns.m. */
1211extern void 1200extern void
1212ns_set_represented_filename (NSString* fstr, struct frame *f); 1201ns_set_represented_filename (NSString* fstr, struct frame *f);
diff --git a/src/nsterm.m b/src/nsterm.m
index 26977e47fbd..1b44a73cd8b 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -68,9 +68,10 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
68#include "macfont.h" 68#include "macfont.h"
69#endif 69#endif
70 70
71 71static EmacsMenu *dockMenu;
72extern NSString *NSMenuDidBeginTrackingNotification; 72#ifdef NS_IMPL_COCOA
73 73static EmacsMenu *mainMenu;
74#endif
74 75
75/* ========================================================================== 76/* ==========================================================================
76 77
@@ -255,7 +256,8 @@ static unsigned convert_ns_to_X_keysym[] =
255 no way to control this behavior. */ 256 no way to control this behavior. */
256float ns_antialias_threshold; 257float ns_antialias_threshold;
257 258
258NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0; 259NSArray *ns_send_types = 0, *ns_return_types = 0;
260static NSArray *ns_drag_types = 0;
259NSString *ns_app_name = @"Emacs"; /* default changed later */ 261NSString *ns_app_name = @"Emacs"; /* default changed later */
260 262
261/* Display variables */ 263/* Display variables */
@@ -413,7 +415,6 @@ static CGPoint menu_mouse_point;
413/* TODO: get rid of need for these forward declarations */ 415/* TODO: get rid of need for these forward declarations */
414static void ns_condemn_scroll_bars (struct frame *f); 416static void ns_condemn_scroll_bars (struct frame *f);
415static void ns_judge_scroll_bars (struct frame *f); 417static void ns_judge_scroll_bars (struct frame *f);
416void x_set_frame_alpha (struct frame *f);
417 418
418 419
419/* ========================================================================== 420/* ==========================================================================
@@ -437,7 +438,7 @@ ns_init_events (struct input_event* ev)
437} 438}
438 439
439void 440void
440ns_finish_events () 441ns_finish_events (void)
441{ 442{
442 emacs_event = NULL; 443 emacs_event = NULL;
443} 444}
@@ -1423,7 +1424,8 @@ ns_ring_bell (struct frame *f)
1423} 1424}
1424 1425
1425 1426
1426static void hide_bell () 1427static void
1428hide_bell (void)
1427/* -------------------------------------------------------------------------- 1429/* --------------------------------------------------------------------------
1428 Ensure the bell is hidden. 1430 Ensure the bell is hidden.
1429 -------------------------------------------------------------------------- */ 1431 -------------------------------------------------------------------------- */
@@ -1897,37 +1899,6 @@ ns_index_color (NSColor *color, struct frame *f)
1897} 1899}
1898 1900
1899 1901
1900void
1901ns_free_indexed_color (unsigned long idx, struct frame *f)
1902{
1903 struct ns_color_table *color_table;
1904 NSColor *color;
1905 NSNumber *index;
1906
1907 if (!f)
1908 return;
1909
1910 color_table = FRAME_DISPLAY_INFO (f)->color_table;
1911
1912 if (idx <= 0 || idx >= color_table->size) {
1913 message1 ("ns_free_indexed_color: Color index out of range.\n");
1914 return;
1915 }
1916
1917 index = [NSNumber numberWithUnsignedInt: idx];
1918 if ([color_table->empty_indices containsObject: index]) {
1919 message1 ("ns_free_indexed_color: attempt to free already freed color.\n");
1920 return;
1921 }
1922
1923 color = color_table->colors[idx];
1924 [color release];
1925 color_table->colors[idx] = nil;
1926 [color_table->empty_indices addObject: index];
1927/*fprintf(stderr, "color_table: FREED %d\n",idx);*/
1928}
1929
1930
1931static int 1902static int
1932ns_get_color (const char *name, NSColor **col) 1903ns_get_color (const char *name, NSColor **col)
1933/* -------------------------------------------------------------------------- 1904/* --------------------------------------------------------------------------
@@ -2009,7 +1980,7 @@ ns_get_color (const char *name, NSColor **col)
2009 1980
2010 if (hex[0]) 1981 if (hex[0])
2011 { 1982 {
2012 int rr, gg, bb; 1983 unsigned int rr, gg, bb;
2013 float fscale = scaling == 4 ? 65535.0 : (scaling == 2 ? 255.0 : 15.0); 1984 float fscale = scaling == 4 ? 65535.0 : (scaling == 2 ? 255.0 : 15.0);
2014 if (sscanf (hex, "%x/%x/%x", &rr, &gg, &bb)) 1985 if (sscanf (hex, "%x/%x/%x", &rr, &gg, &bb))
2015 { 1986 {
@@ -2074,46 +2045,6 @@ ns_lisp_to_color (Lisp_Object color, NSColor **col)
2074} 2045}
2075 2046
2076 2047
2077Lisp_Object
2078ns_color_to_lisp (NSColor *col)
2079/* --------------------------------------------------------------------------
2080 Convert a color to a lisp string with the RGB equivalent
2081 -------------------------------------------------------------------------- */
2082{
2083 EmacsCGFloat red, green, blue, alpha, gray;
2084 char buf[1024];
2085 const char *str;
2086 NSTRACE ("ns_color_to_lisp");
2087
2088 block_input ();
2089 if ([[col colorSpaceName] isEqualToString: NSNamedColorSpace])
2090
2091 if ((str =[[col colorNameComponent] UTF8String]))
2092 {
2093 unblock_input ();
2094 return build_string ((char *)str);
2095 }
2096
2097 [[col colorUsingDefaultColorSpace]
2098 getRed: &red green: &green blue: &blue alpha: &alpha];
2099 if (red == green && red == blue)
2100 {
2101 [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace]
2102 getWhite: &gray alpha: &alpha];
2103 snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
2104 lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
2105 unblock_input ();
2106 return build_string (buf);
2107 }
2108
2109 snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
2110 lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
2111
2112 unblock_input ();
2113 return build_string (buf);
2114}
2115
2116
2117void 2048void
2118ns_query_color(void *col, XColor *color_def, int setPixel) 2049ns_query_color(void *col, XColor *color_def, int setPixel)
2119/* -------------------------------------------------------------------------- 2050/* --------------------------------------------------------------------------
@@ -2462,7 +2393,8 @@ ns_clear_frame (struct frame *f)
2462 2393
2463 block_input (); 2394 block_input ();
2464 ns_focus (f, &r, 1); 2395 ns_focus (f, &r, 1);
2465 [ns_lookup_indexed_color (NS_FACE_BACKGROUND (FRAME_DEFAULT_FACE (f)), f) set]; 2396 [ns_lookup_indexed_color (NS_FACE_BACKGROUND
2397 (FACE_FROM_ID (f, DEFAULT_FACE_ID)), f) set];
2466 NSRectFill (r); 2398 NSRectFill (r);
2467 ns_unfocus (f); 2399 ns_unfocus (f);
2468 2400
@@ -3074,7 +3006,7 @@ ns_draw_underwave (struct glyph_string *s, EmacsCGFloat width, EmacsCGFloat x)
3074 3006
3075 3007
3076 3008
3077void 3009static void
3078ns_draw_text_decoration (struct glyph_string *s, struct face *face, 3010ns_draw_text_decoration (struct glyph_string *s, struct face *face,
3079 NSColor *defaultCol, CGFloat width, CGFloat x) 3011 NSColor *defaultCol, CGFloat width, CGFloat x)
3080/* -------------------------------------------------------------------------- 3012/* --------------------------------------------------------------------------
@@ -3317,7 +3249,7 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s)
3317 face = FACE_FROM_ID_OR_NULL (s->f, 3249 face = FACE_FROM_ID_OR_NULL (s->f,
3318 MOUSE_HL_INFO (s->f)->mouse_face_face_id); 3250 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
3319 if (!face) 3251 if (!face)
3320 face = FACE_FROM_ID_OR_NULL (s->f, MOUSE_FACE_ID); 3252 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3321 } 3253 }
3322 else 3254 else
3323 face = s->face; 3255 face = s->face;
@@ -5433,15 +5365,11 @@ runAlertPanel(NSString *title,
5433 if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO 5365 if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO
5434 return NSTerminateNow; 5366 return NSTerminateNow;
5435 5367
5436 ret = runAlertPanel(ns_app_name, 5368 ret = runAlertPanel(ns_app_name,
5437 @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?", 5369 @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?",
5438 @"Save Buffers and Exit", @"Cancel"); 5370 @"Save Buffers and Exit", @"Cancel");
5439 5371
5440 if (ret) 5372 return ret ? NSTerminateNow : NSTerminateCancel;
5441 return NSTerminateNow;
5442 else
5443 return NSTerminateCancel;
5444 return NSTerminateNow; /* just in case */
5445} 5373}
5446 5374
5447static int 5375static int
@@ -5722,7 +5650,7 @@ not_in_argv (NSString *arg)
5722- (void)changeFont: (id)sender 5650- (void)changeFont: (id)sender
5723{ 5651{
5724 NSEvent *e = [[self window] currentEvent]; 5652 NSEvent *e = [[self window] currentEvent];
5725 struct face *face = FRAME_DEFAULT_FACE (emacsframe); 5653 struct face *face = FACE_FROM_ID (emacsframe, DEFAULT_FACE_ID);
5726 struct font *font = face->font; 5654 struct font *font = face->font;
5727 id newFont; 5655 id newFont;
5728 CGFloat size; 5656 CGFloat size;
@@ -5992,7 +5920,7 @@ not_in_argv (NSString *arg)
5992 5920
5993 if (NS_KEYLOG) 5921 if (NS_KEYLOG)
5994 fprintf (stderr, "keyDown: code =%x\tfnKey =%x\tflags = %x\tmods = %x\n", 5922 fprintf (stderr, "keyDown: code =%x\tfnKey =%x\tflags = %x\tmods = %x\n",
5995 code, fnKeysym, flags, emacs_event->modifiers); 5923 (unsigned) code, fnKeysym, flags, emacs_event->modifiers);
5996 5924
5997 /* if it was a function key or had modifiers, pass it directly to emacs */ 5925 /* if it was a function key or had modifiers, pass it directly to emacs */
5998 if (fnKeysym || (emacs_event->modifiers 5926 if (fnKeysym || (emacs_event->modifiers
@@ -6930,7 +6858,8 @@ not_in_argv (NSString *arg)
6930 [win makeFirstResponder: self]; 6858 [win makeFirstResponder: self];
6931 6859
6932 col = ns_lookup_indexed_color (NS_FACE_BACKGROUND 6860 col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
6933 (FRAME_DEFAULT_FACE (emacsframe)), emacsframe); 6861 (FACE_FROM_ID (emacsframe, DEFAULT_FACE_ID)),
6862 emacsframe);
6934 [win setBackgroundColor: col]; 6863 [win setBackgroundColor: col];
6935 if ([col alphaComponent] != (EmacsCGFloat) 1.0) 6864 if ([col alphaComponent] != (EmacsCGFloat) 1.0)
6936 [win setOpaque: NO]; 6865 [win setOpaque: NO];
@@ -7332,7 +7261,7 @@ not_in_argv (NSString *arg)
7332 f = emacsframe; 7261 f = emacsframe;
7333 wr = [w frame]; 7262 wr = [w frame];
7334 col = ns_lookup_indexed_color (NS_FACE_BACKGROUND 7263 col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
7335 (FRAME_DEFAULT_FACE (f)), 7264 (FACE_FROM_ID (f, DEFAULT_FACE_ID)),
7336 f); 7265 f);
7337 7266
7338 if (fs_state != FULLSCREEN_BOTH) 7267 if (fs_state != FULLSCREEN_BOTH)
@@ -8394,7 +8323,7 @@ not_in_argv (NSString *arg)
8394 NSRect sr, kr; 8323 NSRect sr, kr;
8395 /* hitPart is only updated AFTER event is passed on */ 8324 /* hitPart is only updated AFTER event is passed on */
8396 NSScrollerPart part = [self testPart: [e locationInWindow]]; 8325 NSScrollerPart part = [self testPart: [e locationInWindow]];
8397 CGFloat inc = 0.0, loc, kloc, pos; 8326 CGFloat loc, kloc, pos UNINIT;
8398 int edge = 0; 8327 int edge = 0;
8399 8328
8400 NSTRACE ("[EmacsScroller mouseDown:]"); 8329 NSTRACE ("[EmacsScroller mouseDown:]");