summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nextstep/ChangeLog4
-rw-r--r--nextstep/templates/Info-gnustep.plist.in14
-rw-r--r--src/ChangeLog108
-rw-r--r--src/nsfns.m71
-rw-r--r--src/nsfont.m42
-rw-r--r--src/nsimage.m4
-rw-r--r--src/nsmenu.m70
-rw-r--r--src/nsselect.m3
-rw-r--r--src/nsterm.h44
-rw-r--r--src/nsterm.m206
-rw-r--r--src/process.c14
-rw-r--r--src/process.h1
12 files changed, 371 insertions, 210 deletions
diff --git a/nextstep/ChangeLog b/nextstep/ChangeLog
index 909580296e1..d76d832555c 100644
--- a/nextstep/ChangeLog
+++ b/nextstep/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-02 Jan Djärv <jan.h.d@swipnet.se>
+
+ * templates/Info-gnustep.plist.in: Add NSDocumentClass EmacsDocument.
+
2013-03-16 Jan Djärv <jan.h.d@swipnet.se>
* Makefile.in (${ns_appdir}): Add touch.
diff --git a/nextstep/templates/Info-gnustep.plist.in b/nextstep/templates/Info-gnustep.plist.in
index 4ac97e5cde6..42abc235761 100644
--- a/nextstep/templates/Info-gnustep.plist.in
+++ b/nextstep/templates/Info-gnustep.plist.in
@@ -20,7 +20,7 @@
NSRole = Application;
NSTypes = (
{
- NSDocumentClass = "";
+ NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
@@ -30,7 +30,7 @@
);
},
{
- NSDocumentClass = "";
+ NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
@@ -41,7 +41,7 @@
);
},
{
- NSDocumentClass = "";
+ NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
@@ -51,7 +51,7 @@
);
},
{
- NSDocumentClass = "";
+ NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
@@ -64,7 +64,7 @@
);
},
{
- NSDocumentClass = "";
+ NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
@@ -74,7 +74,7 @@
);
},
{
- NSDocumentClass = "";
+ NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
@@ -84,7 +84,7 @@
);
},
{
- NSDocumentClass = "";
+ NSDocumentClass = "EmacsDocument";
NSHumanReadableName = "";
NSIcon = "";
NSName = "";
diff --git a/src/ChangeLog b/src/ChangeLog
index 65a49bae1dc..a7791444e09 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,111 @@
+2013-06-02 Jan Djärv <jan.h.d@swipnet.se>
+
+ * process.h (catch_child_signal): Declare.
+
+ * process.c (catch_child_signal): New function.
+ (init_process_emacs): Call it.
+
+ * nsterm.m: Include process.h if NS_IMPL_GNUSTEP.
+ (ns_menu_bar_is_hidden, menu_will_open_state): Define only if
+ NS_IMPL_COCOA.
+ (x_set_cursor_type): Remove declaration.
+ (ns_update_begin): Only use r and bp if NS_IMPL_COCOA.
+ (ns_update_end, ns_focus, ns_unfocus): Remove GNUStep specific code.
+ (x_set_window_size): Remove 3 pixels from toolbar if NS_IMPL_GNUSTEP.
+ (ns_get_color): Use F suffix on float.
+ (ns_color_to_lisp, ns_query_color): Use EmacsCGFloat.
+ (ns_get_rgb_color): Remove.
+ (x_set_frame_alpha): Move view inside NS_IMPL_COCOA.
+ (note_mouse_movement): x and y are CGFloat.
+ (ns_draw_fringe_bitmap): Remove unused rowY.
+ Change #if to COCOA && >= 10_6.
+ (ns_draw_window_cursor): Remove unused overspill.
+ (ns_draw_underwave): width and x are EamcsCGFloat.
+ (ns_draw_box): thickness is CGFloat.
+ (ns_dumpglyphs_image): Change #if to COCOA && >= 10_6.
+ (ns_send_appdefined): When NS_IMPL_GNUSTEP, redirect to main thread
+ if not in main thread.
+ (ns_get_pending_menu_title, ns_check_menu_open)
+ (ns_check_pending_open_menu): Put inside #if COCOA && >= 10_5.
+ (ns_term_init): Call catch_child_signal if NS_IMPL_GNUSTEP && SIGCHLD.
+ (sendFromMainThread:): New method.
+ (changeFont:): size is CGFloat.
+ (keyDown:): Check for Delete when NS_IMPL_GNUSTEP.
+ Disable warning about permanent text.
+ (characterIndexForPoint:): Adjust return type depending on GNUStep
+ version.
+ (mouseDown:): delta is CGFloat.
+ (updateFrameSize): Remove unised variable f.
+ (initFrameFromEmacs): Move toggleButton inside NS_IMPL_COCOA.
+ Cast float to EmacsCGFloat.
+ (windowWillUseStandardFrame:defaultFrame:): Set maximized_height
+ also to -1 when restoring.
+ (windowDidExitFullScreen:): Put call to updateCollectionBehaviour
+ inside NS_IMPL_COCOA.
+ (toggleFullScreen:): Put call to toggleFullScreen inside
+ NS_IMPL_COCOA. Cast float to EmacsCGFloat.
+ (setPosition:portion:whole:): por is CGFloat.
+ (getMouseMotionPart:window:x:y:): Add F suffix to float.
+ (mouseDown:): Use CGFloat.
+ (mouseDragged:): Remove unised variable edge.
+ (EmacsDocument): Implement for NS_IMPL_GNUSTEP.
+
+ * nsterm.h (EmacsCGFloat): Typedef for OSX and GNUStep when the size
+ of CGFloat differs.
+ (EmacsApp): New variable nextappdefined. Declare sendFromMainThread
+ when NS_IMPL_GNUSTEP.
+ (EmacsDocument): Declare when NS_IMPL_GNUSTEP.
+ (EmacsView): Remove unlockFocusNeedsFlush, add windowDidMove.
+ (EmacsToolbar): Add clearAll. Add tag argument to
+ addDisplayItemWithImage.
+ (EmacsSavePanel, EmacsOpenPanel): Remove getFilename and getDirectory.
+
+ * nsselect.m (ns_get_local_selection): Remove unused variable type.
+
+ * nsmenu.m (ns_update_menubar): Make static.
+ (x_activate_menubar): Surround with ifdef NS_IMPL_COCOA
+ (fillWithWidgetValue:): Add cast to SEL for setAction.
+ (addSubmenuWithTitle:forFrame:): Add cast to SEL for action.
+ (update_frame_tool_bar): Update code for GNUStep.
+ (clearAll): New method.
+ (addDisplayItemWithImage:idx:tag:helpText:enabled:): Handle new tag
+ argument. Call insertItemWithItemIdentifier when NS_IMPL_GNUSTEP. Move
+ identifierToItem setObject and activeIdentifiers addObject before
+ call to insertItemWithItemIdentifier.
+ (validateVisibleItems): Fix indentation.
+ (toolbarAllowedItemIdentifiers:): Return activeIdentifiers.
+ (initWithContentRect:styleMask:backing:defer:): Add ClosableWindow and
+ UtilityWindow to aStyle, remove call to setStyleMask.
+
+ * nsimage.m (setXBMColor:, getPixelAtX:Y:): Use EmacsCGFloat.
+
+ * nsfont.m (ns_attribute_fvalue, ns_spec_to_descriptor)
+ (ns_charset_covers, ns_get_covering_families, nsfont_open):
+ Use F suffix on floats.
+ (ns_char_width): Returns CGFloat.
+ (ns_ascii_average_width): w is CGFloat instead of float.
+ (nsfont_draw): cbuf and c are unsigned. Cast to char* in call to
+ DPSxshow.
+ (ns_glyph_metrics): CGFloat instead of float.
+
+ * nsfns.m (x_set_foreground_color, x_set_background_color): Use
+ EmacsCGFloat.
+ (ns_implicitly_set_icon_type, Fx_create_frame): Make static, remove
+ unused variables.
+ (Fns_read_file_name): Keep track if panel is for save. Use
+ ns_filename_from_panel/ns_directory_from_panel.
+ (Fns_list_services): delegate only used for COCOA.
+ (Fns_convert_utf8_nfd_to_nfc): Remove warning for GNUStep. Just
+ return the input if GNUStep.
+ (x_screen_planes): Remove.
+ (Fxw_color_values): Use EmacsCGFloat
+ (Fns_display_monitor_attributes_list): Only get screen number for
+ Cocoa.
+ (getDirectory, getFilename): Removed from EmacsOpenPanel and
+ EmacsSavePanel.
+ (EmacsOpenPanel:ok:): Use ns_filename_from_panel and
+ ns_directory_from_panel.
+
2013-06-01 Paul Eggert <eggert@cs.ucla.edu>
* process.c (handle_child_signal): Also use WCONTINUED.
diff --git a/src/nsfns.m b/src/nsfns.m
index 1170472573e..94339183159 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -287,7 +287,7 @@ static void
x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSColor *col;
- CGFloat r, g, b, alpha;
+ EmacsCGFloat r, g, b, alpha;
if (ns_lisp_to_color (arg, &col))
{
@@ -319,7 +319,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
struct face *face;
NSColor *col;
NSView *view = FRAME_NS_VIEW (f);
- CGFloat r, g, b, alpha;
+ EmacsCGFloat r, g, b, alpha;
if (ns_lisp_to_color (arg, &col))
{
@@ -344,7 +344,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
[[view window] setBackgroundColor: col];
- if (alpha != 1.0)
+ if (alpha != (EmacsCGFloat) 1.0)
[[view window] setOpaque: NO];
else
[[view window] setOpaque: YES];
@@ -714,7 +714,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
}
-void
+static void
ns_implicitly_set_icon_type (struct frame *f)
{
Lisp_Object tem;
@@ -859,7 +859,7 @@ ns_cursor_type_to_lisp (int arg)
}
/* This is the same as the xfns.c definition. */
-void
+static void
x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
{
set_frame_cursor_types (f, arg);
@@ -1082,7 +1082,6 @@ This function is an internal primitive--use `make-frame' instead. */)
struct ns_display_info *dpyinfo = NULL;
Lisp_Object parent;
struct kboard *kb;
- Lisp_Object tfont, tfontsize;
static int desc_ctr = 1;
/* x_get_arg modifies parms. */
@@ -1189,10 +1188,10 @@ This function is an internal primitive--use `make-frame' instead. */)
{
/* use for default font name */
id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */
- tfontsize = x_default_parameter (f, parms, Qfontsize,
+ x_default_parameter (f, parms, Qfontsize,
make_number (0 /*(int)[font pointSize]*/),
"fontSize", "FontSize", RES_TYPE_NUMBER);
- tfont = x_default_parameter (f, parms, Qfont,
+ x_default_parameter (f, parms, Qfont,
build_string ([[font fontName] UTF8String]),
"font", "Font", RES_TYPE_STRING);
}
@@ -1410,6 +1409,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
{
static id fileDelegate = nil;
BOOL ret;
+ BOOL isSave = NILP (mustmatch) && NILP (dir_only_p);
id panel;
Lisp_Object fname;
@@ -1431,7 +1431,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
if ([dirS characterAtIndex: 0] == '~')
dirS = [dirS stringByExpandingTildeInPath];
- panel = NILP (mustmatch) && NILP (dir_only_p) ?
+ panel = isSave ?
(id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
[panel setTitle: promptS];
@@ -1446,7 +1446,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
[panel setCanChooseDirectories: YES];
[panel setCanChooseFiles: NO];
}
- else
+ else if (! isSave)
{
/* This is not quite what the documentation says, but it is compatible
with the Gtk+ code. Also, the menu entry says "Open File...". */
@@ -1481,8 +1481,8 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
if (ret)
{
- NSString *str = [panel getFilename];
- if (! str) str = [panel getDirectory];
+ NSString *str = ns_filename_from_panel (panel);
+ if (! str) str = ns_directory_from_panel (panel);
if (! str) ret = NO;
else fname = build_string ([str UTF8String]);
}
@@ -1909,7 +1909,9 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
#else
Lisp_Object ret = Qnil;
NSMenu *svcs;
+#ifdef NS_IMPL_COCOA
id delegate;
+#endif
check_window_system (NULL);
svcs = [[NSMenu alloc] initWithTitle: @"Services"];
@@ -1992,15 +1994,9 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc,
CHECK_STRING (str);
utfStr = [NSString stringWithUTF8String: SSDATA (str)];
- if (![utfStr respondsToSelector:
- @selector (precomposedStringWithCanonicalMapping)])
- {
- message1
- ("Warning: ns-convert-utf8-nfd-to-nfc unsupported under GNUstep.\n");
- return Qnil;
- }
- else
+#ifdef NS_IMPL_COCOA
utfStr = [utfStr precomposedStringWithCanonicalMapping];
+#endif
return build_string ([utfStr UTF8String]);
}
@@ -2155,6 +2151,9 @@ x_set_scroll_bar_default_width (struct frame *f)
}
+extern const char *x_get_string_resource (XrmDatabase, char *, char *);
+
+
/* terms impl this instead of x-get-resource directly */
const char *
x_get_string_resource (XrmDatabase rdb, char *name, char *class)
@@ -2203,13 +2202,6 @@ x_pixel_height (struct frame *f)
}
-int
-x_screen_planes (struct frame *f)
-{
- return FRAME_NS_DISPLAY_INFO (f)->n_planes;
-}
-
-
void
x_sync (struct frame *f)
{
@@ -2242,7 +2234,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
(Lisp_Object color, Lisp_Object frame)
{
NSColor * col;
- CGFloat red, green, blue, alpha;
+ EmacsCGFloat red, green, blue, alpha;
check_window_system (NULL);
CHECK_STRING (color);
@@ -2434,11 +2426,10 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
struct MonitorInfo *m = &monitors[i];
NSRect fr = [s frame];
NSRect vfr = [s visibleFrame];
- NSDictionary *dict = [s deviceDescription];
- NSValue *resval = [dict valueForKey:NSDeviceResolution];
short y, vy;
#ifdef NS_IMPL_COCOA
+ NSDictionary *dict = [s deviceDescription];
NSNumber *nid = [dict objectForKey:@"NSScreenNumber"];
CGDirectDisplayID did = [nid unsignedIntValue];
#endif
@@ -2776,14 +2767,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
[NSApp stop: self];
}
#endif
-- (NSString *) getFilename
-{
- return ns_filename_from_panel (self);
-}
-- (NSString *) getDirectory
-{
- return ns_directory_from_panel (self);
-}
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
@@ -2807,8 +2790,8 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
[super ok: sender];
// If not choosing directories, and Open is pressed on a directory, return.
- if (! [self canChooseDirectories] && [self getDirectory] &&
- ! [self getFilename])
+ if (! [self canChooseDirectories] && ns_directory_from_panel (self) &&
+ ! ns_filename_from_panel (self))
return;
panelOK = 1;
@@ -2821,14 +2804,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
}
#endif
-- (NSString *) getFilename
-{
- return ns_filename_from_panel (self);
-}
-- (NSString *) getDirectory
-{
- return ns_directory_from_panel (self);
-}
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
// NSOpenPanel inherits NSSavePanel, so passing self is OK.
diff --git a/src/nsfont.m b/src/nsfont.m
index 9ab369d1fcd..709f2cb0d86 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -119,7 +119,7 @@ ns_attribute_fvalue (NSFontDescriptor *fdesc, NSString *trait)
{
NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute];
NSNumber *val = [tdict objectForKey: trait];
- return val == nil ? 0.0 : [val floatValue];
+ return val == nil ? 0.0F : [val floatValue];
}
@@ -138,15 +138,15 @@ ns_spec_to_descriptor (Lisp_Object font_spec)
/* add each attr in font_spec to fdAttrs.. */
n = min (FONT_WEIGHT_NUMERIC (font_spec), 200);
if (n != -1 && n != STYLE_REF)
- [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
+ [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontWeightTrait];
n = min (FONT_SLANT_NUMERIC (font_spec), 200);
if (n != -1 && n != STYLE_REF)
- [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
+ [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontSlantTrait];
n = min (FONT_WIDTH_NUMERIC (font_spec), 200);
if (n > -1 && (n > STYLE_REF + 10 || n < STYLE_REF - 10))
- [tdict setObject: [NSNumber numberWithFloat: (n - 100.0) / 100.0]
+ [tdict setObject: [NSNumber numberWithFloat: (n - 100.0F) / 100.0F]
forKey: NSFontWidthTrait];
if ([tdict count] > 0)
[fdAttrs setObject: tdict forKey: NSFontTraitsAttribute];
@@ -240,10 +240,10 @@ ns_fallback_entity (void)
/* Utility: get width of a char c in screen font SFONT */
-static float
+static CGFloat
ns_char_width (NSFont *sfont, int c)
{
- float w = -1.0;
+ CGFloat w = -1.0;
NSString *cstr = [NSString stringWithFormat: @"%c", c];
#ifdef NS_IMPL_COCOA
@@ -269,7 +269,7 @@ static NSString *ascii_printable;
static int
ns_ascii_average_width (NSFont *sfont)
{
- float w = -1.0;
+ CGFloat w = -1.0;
if (!ascii_printable)
{
@@ -288,14 +288,14 @@ ns_ascii_average_width (NSFont *sfont)
w = [sfont advancementForGlyph: glyph].width;
#endif
- if (w < 0.0)
+ if (w < (CGFloat) 0.0)
{
NSDictionary *attrsDictionary =
[NSDictionary dictionaryWithObject: sfont forKey: NSFontAttributeName];
w = [ascii_printable sizeWithAttributes: attrsDictionary].width;
}
- return lrint (w / 95.0);
+ return lrint (w / (CGFloat) 95.0);
}
@@ -323,7 +323,7 @@ ns_charset_covers(NSCharacterSet *set1, NSCharacterSet *set2, float pct)
off++;
}
//fprintf(stderr, "off = %d\ttot = %d\n", off,tot);
- return (float)off / tot < 1.0 - pct;
+ return (float)off / tot < 1.0F - pct;
}
@@ -514,8 +514,8 @@ static NSSet
if (ns_charset_covers(fset, charset, pct))
[families addObject: family];
}
- pct -= 0.2;
- if ([families count] > 0 || pct < 0.05)
+ pct -= 0.2F;
+ if ([families count] > 0 || pct < 0.05F)
break;
}
[charset release];
@@ -763,9 +763,9 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
family = [[NSFont userFixedPitchFontOfSize: 0] familyName];
/* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that
when setting family in ns_spec_to_descriptor(). */
- if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50)
+ if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F)
traits |= NSBoldFontMask;
- if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05))
+ if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F))
traits |= NSItalicFontMask;
/* see http://cocoadev.com/forums/comments.php?DiscussionID=74 */
@@ -880,7 +880,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
font_info->max_bounds.width = lrint (font_info->width);
font_info->max_bounds.lbearing = lrint (brect.origin.x);
font_info->max_bounds.rbearing =
- lrint (brect.size.width - font_info->width);
+ lrint (brect.size.width - (CGFloat) font_info->width);
#ifdef NS_IMPL_COCOA
/* set up synthItal and the CG font */
@@ -1041,8 +1041,8 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
/* NOTE: focus and clip must be set
also, currently assumed (true in nsterm.m call) from ==0, to ==nchars */
{
- static char cbuf[1024];
- char *c = cbuf;
+ static unsigned char cbuf[1024];
+ unsigned char *c = cbuf;
#ifdef NS_IMPL_GNUSTEP
static float advances[1024];
float *adv = advances;
@@ -1209,7 +1209,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
[bgCol set];
DPSmoveto (context, r.origin.x, r.origin.y);
/*[context GSSetTextDrawingMode: GSTextFillStroke]; /// not implemented yet */
- DPSxshow (context, cbuf, advances, len);
+ DPSxshow (context, (const char *) cbuf, advances, len);
DPSstroke (context);
[col set];
/*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */
@@ -1219,7 +1219,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
/* draw with DPSxshow () */
DPSmoveto (context, r.origin.x, r.origin.y);
- DPSxshow (context, cbuf, advances, len);
+ DPSxshow (context, (const char *) cbuf, advances, len);
DPSstroke (context);
DPSgrestore (context);
@@ -1407,7 +1407,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
metrics = font_info->metrics[block];
for (g = block<<8, i =0; i<0x100 && g < numGlyphs; g++, i++, metrics++)
{
- float w, lb, rb;
+ CGFloat w, lb, rb;
NSRect r = [sfont boundingRectForGlyph: g];
w = max ([sfont advancementForGlyph: g].width, 2.0);
@@ -1419,7 +1419,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
if (lb < 0)
metrics->lbearing = round (lb - LCD_SMOOTHING_MARGIN);
if (font_info->ital)
- rb += 0.22 * font_info->height;
+ rb += (CGFloat) (0.22F * font_info->height);
metrics->rbearing = lrint (w + rb + LCD_SMOOTHING_MARGIN);
metrics->descent = r.origin.y < 0 ? -r.origin.y : 0;
diff --git a/src/nsimage.m b/src/nsimage.m
index 9d21ba8afca..a1703272ad2 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -334,7 +334,7 @@ static EmacsImage *ImageList = nil;
{
NSSize s = [self size];
unsigned char *planes[5];
- CGFloat r, g, b, a;
+ EmacsCGFloat r, g, b, a;
NSColor *rgbColor;
if (bmRep == nil || color == nil)
@@ -437,7 +437,7 @@ static EmacsImage *ImageList = nil;
else
{
NSColor *color = [bmRep colorAtX: x y: y];
- CGFloat r, g, b, a;
+ EmacsCGFloat r, g, b, a;
[color getRed: &r green: &g blue: &b alpha: &a];
return ((int)(a * 255.0) << 24)
| ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8)
diff --git a/src/nsmenu.m b/src/nsmenu.m
index baa683941f8..1d3d111e9a1 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -45,8 +45,6 @@ Carbon version by Yamamoto Mitsuharu. */
#include <sys/types.h>
#endif
-#define MenuStagger 10.0
-
#if 0
int menu_trace_num = 0;
#define NSTRACE(x) fprintf (stderr, "%s:%d: [%d] " #x "\n", \
@@ -112,7 +110,7 @@ popup_activated (void)
2) deep_p, submenu = nil: Recompute all submenus.
3) deep_p, submenu = non-nil: Update contents of a single submenu.
-------------------------------------------------------------------------- */
-void
+static void
ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
{
NSAutoreleasePool *pool;
@@ -505,6 +503,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
void
x_activate_menubar (struct frame *f)
{
+#ifdef NS_IMPL_COCOA
NSArray *a = [[NSApp mainMenu] itemArray];
/* Update each submenu separately so ns_update_menubar doesn't reset
the delegate. */
@@ -521,6 +520,7 @@ x_activate_menubar (struct frame *f)
++i;
}
ns_check_pending_open_menu ();
+#endif
}
@@ -740,7 +740,7 @@ extern NSString *NSMenuDidBeginTrackingNotification;
[self setSubmenu: submenu forItem: item];
[submenu fillWithWidgetValue: wv->contents];
[submenu release];
- [item setAction: nil];
+ [item setAction: (SEL)nil];
}
}
@@ -757,7 +757,7 @@ extern NSString *NSMenuDidBeginTrackingNotification;
{
NSString *titleStr = [NSString stringWithUTF8String: title];
NSMenuItem *item = [self addItemWithTitle: titleStr
- action: nil /*@selector (menuDown:) */
+ action: (SEL)nil /*@selector (menuDown:) */
keyEquivalent: @""];
EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr frame: f];
[self setSubmenu: submenu forItem: item];
@@ -1045,13 +1045,18 @@ update_frame_tool_bar (FRAME_PTR f)
Update toolbar contents
-------------------------------------------------------------------------- */
{
- int i;
+ int i, k = 0;
EmacsView *view = FRAME_NS_VIEW (f);
NSWindow *window = [view window];
EmacsToolbar *toolbar = [view toolbar];
block_input ();
+
+#ifdef NS_IMPL_COCOA
[toolbar clearActive];
+#else
+ [toolbar clearAll];
+#endif
/* update EmacsToolbar as in GtkUtils, build items list */
for (i = 0; i < f->n_tool_bar_items; ++i)
@@ -1067,6 +1072,15 @@ update_frame_tool_bar (FRAME_PTR f)
Lisp_Object helpObj;
const char *helpText;
+ /* Check if this is a separator. */
+ if (EQ (TOOLPROP (TOOL_BAR_ITEM_TYPE), Qt))
+ {
+ /* Skip separators. Newer OSX don't show them, and on GNUStep they
+ are wide as a button, thus overflowing the toolbar most of
+ the time. */
+ continue;
+ }
+
/* If image is a vector, choose the image according to the
button state. */
image = TOOLPROP (TOOL_BAR_ITEM_IMAGES);
@@ -1103,7 +1117,10 @@ update_frame_tool_bar (FRAME_PTR f)
continue;
}
- [toolbar addDisplayItemWithImage: img->pixmap idx: i helpText: helpText
+ [toolbar addDisplayItemWithImage: img->pixmap
+ idx: k++
+ tag: i
+ helpText: helpText
enabled: enabled_p];
#undef TOOLPROP
}
@@ -1111,6 +1128,7 @@ update_frame_tool_bar (FRAME_PTR f)
if (![toolbar isVisible])
[toolbar setVisible: YES];
+#ifdef NS_IMPL_COCOA
if ([toolbar changed])
{
/* inform app that toolbar has changed */
@@ -1132,6 +1150,7 @@ update_frame_tool_bar (FRAME_PTR f)
[toolbar setConfigurationFromDictionary: newDict];
[newDict release];
}
+#endif
FRAME_TOOLBAR_HEIGHT (f) =
NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
@@ -1159,6 +1178,7 @@ update_frame_tool_bar (FRAME_PTR f)
[self setDelegate: self];
identifierToItem = [[NSMutableDictionary alloc] initWithCapacity: 10];
activeIdentifiers = [[NSMutableArray alloc] initWithCapacity: 8];
+ prevIdentifiers = nil;
prevEnablement = enablement = 0L;
return self;
}
@@ -1180,18 +1200,29 @@ update_frame_tool_bar (FRAME_PTR f)
enablement = 0L;
}
+- (void) clearAll
+{
+ [self clearActive];
+ while ([[self items] count] > 0)
+ [self removeItemAtIndex: 0];
+}
+
- (BOOL) changed
{
return [activeIdentifiers isEqualToArray: prevIdentifiers] &&
enablement == prevEnablement ? NO : YES;
}
-- (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx
- helpText: (const char *)help enabled: (BOOL)enabled
+- (void) addDisplayItemWithImage: (EmacsImage *)img
+ idx: (int)idx
+ tag: (int)tag
+ helpText: (const char *)help
+ enabled: (BOOL)enabled
{
/* 1) come up w/identifier */
NSString *identifier
= [NSString stringWithFormat: @"%u", [img hash]];
+ [activeIdentifiers addObject: identifier];
/* 2) create / reuse item */
NSToolbarItem *item = [identifierToItem objectForKey: identifier];
@@ -1203,20 +1234,25 @@ update_frame_tool_bar (FRAME_PTR f)
[item setToolTip: [NSString stringWithUTF8String: help]];
[item setTarget: emacsView];
[item setAction: @selector (toolbarClicked:)];
+ [identifierToItem setObject: item forKey: identifier];
}
- [item setTag: idx];
+#ifdef NS_IMPL_GNUSTEP
+ [self insertItemWithItemIdentifier: identifier atIndex: idx];
+#endif
+
+ [item setTag: tag];
[item setEnabled: enabled];
/* 3) update state */
- [identifierToItem setObject: item forKey: identifier];
- [activeIdentifiers addObject: identifier];
enablement = (enablement << 1) | (enabled == YES);
}
/* This overrides super's implementation, which automatically sets
all items to enabled state (for some reason). */
-- (void)validateVisibleItems { }
+- (void)validateVisibleItems
+{
+}
/* delegate methods */
@@ -1239,7 +1275,8 @@ update_frame_tool_bar (FRAME_PTR f)
- (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar
{
/* return entire set... */
- return [identifierToItem allKeys];
+ return activeIdentifiers;
+ //return [identifierToItem allKeys];
}
/* optional and unneeded */
@@ -1531,7 +1568,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
[img autorelease];
[imgView autorelease];
- aStyle = NSTitledWindowMask;
+ aStyle = NSTitledWindowMask|NSClosableWindowMask|NSUtilityWindowMask;
flag = YES;
rows = 0;
cols = 1;
@@ -1599,9 +1636,6 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
[self setOneShot: YES];
[self setReleasedWhenClosed: YES];
[self setHidesOnDeactivate: YES];
- [self setStyleMask:
- NSTitledWindowMask|NSClosableWindowMask|NSUtilityWindowMask];
-
return self;
}
diff --git a/src/nsselect.m b/src/nsselect.m
index bb9eacd23cd..6053ee9ceb2 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -182,7 +182,7 @@ ns_get_local_selection (Lisp_Object selection_name,
Lisp_Object target_type)
{
Lisp_Object local_value;
- Lisp_Object handler_fn, value, type, check;
+ Lisp_Object handler_fn, value, check;
ptrdiff_t count;
local_value = assq_no_quit (selection_name, Vselection_alist);
@@ -203,7 +203,6 @@ ns_get_local_selection (Lisp_Object selection_name,
check = value;
if (CONSP (value) && SYMBOLP (XCAR (value)))
{
- type = XCAR (value);
check = XCDR (value);
}
diff --git a/src/nsterm.h b/src/nsterm.h
index 07cfc2e022e..fd8c9baa3e4 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -51,6 +51,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef __OBJC__
+/* CGFloat on GNUStep may be 4 or 8 byte, but functions expect float* for some
+ versions.
+ On Cocoa, functions expect CGFloat*. Make compatible type. */
+#if defined (NS_IMPL_COCOA) || GNUSTEP_GUI_MAJOR_VERSION > 0 || \
+ GNUSTEP_GUI_MINOR_VERSION >= 22
+typedef CGFloat EmacsCGFloat;
+#else
+typedef float EmacsCGFloat;
+#endif
+
/* ==========================================================================
The Emacs application
@@ -60,6 +70,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* We override sendEvent: as a means to stop/start the event loop */
@interface EmacsApp : NSApplication
{
+#ifdef NS_IMPL_GNUSTEP
+@public
+ int nextappdefined;
+#endif
}
- (void)logNotification: (NSNotification *)notification;
- (void)sendEvent: (NSEvent *)theEvent;
@@ -68,8 +82,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
- (void)fd_handler: (id)unused;
- (void)timeout_handler: (NSTimer *)timedEntry;
- (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg;
+#ifdef NS_IMPL_GNUSTEP
+- (void)sendFromMainThread:(id)unused;
+#endif
@end
+#ifdef NS_IMPL_GNUSTEP
+/* Dummy class to get rid of startup warnings. */
+@interface EmacsDocument : NSDocument
+{
+}
+@end
+#endif
/* ==========================================================================
@@ -128,8 +152,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif
#ifdef NS_IMPL_GNUSTEP
-/* Not declared, but useful. */
-- (void) unlockFocusNeedsFlush: (BOOL)needs;
+- (void)windowDidMove: (id)sender;
#endif
@end
@@ -199,10 +222,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
}
- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
- (void) clearActive;
+- (void) clearAll;
- (BOOL) changed;
-- (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx
+- (void) addDisplayItemWithImage: (EmacsImage *)img
+ idx: (int)idx
+ tag: (int)tag
helpText: (const char *)help
enabled: (BOOL)enabled;
+
/* delegate methods */
- (NSToolbarItem *)toolbar: (NSToolbar *)toolbar
itemForItemIdentifier: (NSString *)itemIdentifier
@@ -267,14 +294,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
@interface EmacsSavePanel : NSSavePanel
{
}
-- (NSString *) getFilename;
-- (NSString *) getDirectory;
@end
@interface EmacsOpenPanel : NSOpenPanel
{
}
-- (NSString *) getFilename;
-- (NSString *) getDirectory;
@end
@interface EmacsFileDelegate : NSObject
@@ -335,7 +358,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
NSResponder *prevResponder;
/* offset to the bottom of knob of last mouse down */
- float last_mouse_offset;
+ CGFloat last_mouse_offset;
float min_portion;
int pixel_height;
int last_hit_part;
@@ -789,9 +812,9 @@ extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
extern unsigned long ns_index_color (NSColor *color, struct frame *f);
extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
-extern const char *ns_get_pending_menu_title ();
+extern const char *ns_get_pending_menu_title (void);
extern void ns_check_menu_open (NSMenu *menu);
-extern void ns_check_pending_open_menu ();
+extern void ns_check_pending_open_menu (void);
#endif
/* C access to ObjC functionality */
@@ -840,6 +863,7 @@ extern int x_display_pixel_height (struct ns_display_info *);
extern int x_display_pixel_width (struct ns_display_info *);
/* This in nsterm.m */
+extern void x_destroy_window (struct frame *f);
extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, EMACS_TIME *timeout,
sigset_t *sigmask);
diff --git a/src/nsterm.m b/src/nsterm.m
index e882f00e977..9cf138837f6 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -60,6 +60,10 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
#include "buffer.h"
#include "font.h"
+#ifdef NS_IMPL_GNUSTEP
+#include "process.h"
+#endif
+
/* call tracing */
#if 0
int term_trace_num = 0;
@@ -196,7 +200,9 @@ static BOOL gsaved = NO;
static BOOL ns_fake_keydown = NO;
int ns_tmp_flags; /* FIXME */
struct nsfont_info *ns_tmp_font; /* FIXME */
+#ifdef NS_IMPL_COCOA
static BOOL ns_menu_bar_is_hidden = NO;
+#endif
/*static int debug_lock = 0; */
/* event loop */
@@ -228,6 +234,7 @@ static struct {
NULL, 0, 0
};
+#ifdef NS_IMPL_COCOA
/*
* State for pending menu activation:
* MENU_NONE Normal state
@@ -246,6 +253,7 @@ static CGPoint menu_mouse_point;
/* Title for the menu to open. */
static char *menu_pending_title = 0;
+#endif
/* Convert modifiers in a NeXTstep event to emacs style modifiers. */
#define NS_FUNCTION_KEY_MASK 0x800000
@@ -317,8 +325,6 @@ static char *menu_pending_title = 0;
ns_send_appdefined (-1); \
}
-void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object);
-
/* TODO: get rid of need for these forward declarations */
static void ns_condemn_scroll_bars (struct frame *f);
static void ns_judge_scroll_bars (struct frame *f);
@@ -670,8 +676,6 @@ ns_update_begin (struct frame *f)
-------------------------------------------------------------------------- */
{
NSView *view = FRAME_NS_VIEW (f);
- NSRect r = [view frame];
- NSBezierPath *bp;
NSTRACE (ns_update_begin);
ns_update_auto_hide_menu_bar ();
@@ -683,9 +687,15 @@ ns_update_begin (struct frame *f)
is for the minibuffer. But the display engine may draw more because
we have set the frame as garbaged. So reset clip path to the whole
view. */
+#ifdef NS_IMPL_COCOA
+ {
+ NSBezierPath *bp;
+ NSRect r = [view frame];
bp = [[NSBezierPath bezierPathWithRect: r] retain];
[bp setClip];
[bp release];
+ }
+#endif
#ifdef NS_IMPL_GNUSTEP
uRect = NSMakeRect (0, 0, 0, 0);
@@ -772,20 +782,13 @@ ns_update_end (struct frame *f)
external (RIF) call; for whole frame, called after update_window_end
-------------------------------------------------------------------------- */
{
- NSView *view = FRAME_NS_VIEW (f);
+ EmacsView *view = FRAME_NS_VIEW (f);
/* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
MOUSE_HL_INFO (f)->mouse_face_defer = 0;
block_input ();
-#ifdef NS_IMPL_GNUSTEP
- /* trigger flush only in the rectangle we tracked as being drawn */
- [view unlockFocusNeedsFlush: NO];
-/*fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", uRect.origin.x, uRect.origin.y, uRect.size.width, uRect.size.height); */
- [view lockFocusInRect: uRect];
-#endif
-
[view unlockFocus];
[[view window] flushWindow];
@@ -818,13 +821,6 @@ ns_focus (struct frame *f, NSRect *r, int n)
-------------------------------------------------------------------------- */
{
// NSTRACE (ns_focus);
-#ifdef NS_IMPL_GNUSTEP
- NSRect u;
- if (n == 2)
- u = NSUnionRect (r[0], r[1]);
- else if (r)
- u = *r;
-#endif
/* static int c =0;
fprintf (stderr, "focus: %d", c++);
if (r) fprintf (stderr, " (%.0f, %.0f : %.0f x %.0f)", r->origin.x, r->origin.y, r->size.width, r->size.height);
@@ -843,33 +839,11 @@ ns_focus (struct frame *f, NSRect *r, int n)
}
if (view)
-#ifdef NS_IMPL_GNUSTEP
- r ? [view lockFocusInRect: u] : [view lockFocus];
-#else
[view lockFocus];
-#endif
focus_view = view;
/*if (view) debug_lock++; */
}
-#ifdef NS_IMPL_GNUSTEP
- else
- {
- /* more than one rect being drawn into */
- if (view && r)
- {
- [view unlockFocus]; /* add prev rect to redraw list */
- [view lockFocusInRect: u]; /* focus for draw in new rect */
- }
- }
-#endif
- }
-#ifdef NS_IMPL_GNUSTEP
- else
- {
- /* in batch mode, but in GNUstep must still track rectangles explicitly */
- uRect = (r ? NSUnionRect (uRect, u) : [FRAME_NS_VIEW (f) visibleRect]);
}
-#endif
/* clipping */
if (r)
@@ -1317,12 +1291,17 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
/* If we have a toolbar, take its height into account. */
if (tb && ! [view isFullscreen])
+ {
/* NOTE: previously this would generate wrong result if toolbar not
yet displayed and fixing toolbar_height=32 helped, but
now (200903) seems no longer needed */
FRAME_TOOLBAR_HEIGHT (f) =
NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
- FRAME_NS_TITLEBAR_HEIGHT (f);
+#ifdef NS_IMPL_GNUSTEP
+ FRAME_TOOLBAR_HEIGHT (f) -= 3;
+#endif
+ }
else
FRAME_TOOLBAR_HEIGHT (f) = 0;
@@ -1548,7 +1527,7 @@ ns_get_color (const char *name, NSColor **col)
}
}
- if (r >= 0.0)
+ if (r >= 0.0F)
{
*col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0];
unblock_input ();
@@ -1609,7 +1588,7 @@ ns_color_to_lisp (NSColor *col)
Convert a color to a lisp string with the RGB equivalent
-------------------------------------------------------------------------- */
{
- CGFloat red, green, blue, alpha, gray;
+ EmacsCGFloat red, green, blue, alpha, gray;
char buf[1024];
const char *str;
NSTRACE (ns_color_to_lisp);
@@ -1651,7 +1630,7 @@ ns_query_color(void *col, XColor *color_def, int setPixel)
and set color_def pixel to the resulting index.
-------------------------------------------------------------------------- */
{
- CGFloat r, g, b, a;
+ EmacsCGFloat r, g, b, a;
[((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a];
color_def->red = r * 65535;
@@ -1696,26 +1675,6 @@ ns_defined_color (struct frame *f,
}
-unsigned long
-ns_get_rgb_color (struct frame *f, float r, float g, float b, float a)
-/* --------------------------------------------------------------------------
- return an autoreleased RGB color
- -------------------------------------------------------------------------- */
-{
-/*static int c = 1; fprintf (stderr, "color request %d\n", c++); */
- if (r < 0.0) r = 0.0;
- else if (r > 1.0) r = 1.0;
- if (g < 0.0) g = 0.0;
- else if (g > 1.0) g = 1.0;
- if (b < 0.0) b = 0.0;
- else if (b > 1.0) b = 1.0;
- if (a < 0.0) a = 0.0;
- else if (a > 1.0) a = 1.0;
- return (unsigned long) ns_index_color(
- [NSColor colorWithCalibratedRed: r green: g blue: b alpha: a], f);
-}
-
-
void
x_set_frame_alpha (struct frame *f)
/* --------------------------------------------------------------------------
@@ -1723,7 +1682,6 @@ x_set_frame_alpha (struct frame *f)
-------------------------------------------------------------------------- */
{
struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
- EmacsView *view = FRAME_NS_VIEW (f);
double alpha = 1.0;
double alpha_min = 1.0;
@@ -1745,7 +1703,10 @@ x_set_frame_alpha (struct frame *f)
alpha = alpha_min;
#ifdef NS_IMPL_COCOA
+ {
+ EmacsView *view = FRAME_NS_VIEW (f);
[[view window] setAlphaValue: alpha];
+ }
#endif
}
@@ -1798,7 +1759,7 @@ x_set_mouse_position (struct frame *f, int h, int v)
static int
-note_mouse_movement (struct frame *frame, float x, float y)
+note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y)
/* ------------------------------------------------------------------------
Called by EmacsView on mouseMovement events. Passes on
to emacs mainstream code if we moved off of a rect of interest
@@ -2257,7 +2218,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
{
struct frame *f = XFRAME (WINDOW_FRAME (w));
struct face *face = p->face;
- int rowY;
static EmacsImage **bimgs = NULL;
static int nBimgs = 0;
@@ -2271,7 +2231,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
}
/* Must clip because of partially visible lines. */
- rowY = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
ns_clip_to_row (w, row, -1, YES);
if (!p->overlay_p)
@@ -2359,7 +2318,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
[ns_lookup_indexed_color(face->background, f) set];
NSRectFill (r);
[img setXBMColor: ns_lookup_indexed_color(face->foreground, f)];
-#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[img drawInRect: r
fromRect: NSZeroRect
operation: NSCompositeSourceOver
@@ -2391,7 +2350,6 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
int fx, fy, h, cursor_height;
struct frame *f = WINDOW_XFRAME (w);
struct glyph *phys_cursor_glyph;
- int overspill;
struct glyph *cursor_glyph;
struct face *face;
NSColor *hollow_color = FRAME_BACKGROUND_COLOR (f);
@@ -2598,7 +2556,7 @@ ns_get_glyph_string_clip_rect (struct glyph_string *s, NativeRectangle *nr)
--------------------------------------------------------------------- */
static void
-ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x)
+ns_draw_underwave (struct glyph_string *s, EmacsCGFloat width, EmacsCGFloat x)
{
int wave_height = 3, wave_length = 2;
int y, dx, dy, odd, xmax;
@@ -2616,7 +2574,7 @@ ns_draw_underwave (struct glyph_string *s, CGFloat width, CGFloat x)
NSRectClip (waveClip);
/* Draw the waves */
- a.x = x - ((int)(x) % dx) + 0.5;
+ a.x = x - ((int)(x) % dx) + (EmacsCGFloat) 0.5;
b.x = a.x + dx;
odd = (int)(a.x/dx) % 2;
a.y = b.y = y + 0.5;
@@ -2756,7 +2714,8 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face,
}
static void
-ns_draw_box (NSRect r, float thickness, NSColor *col, char left_p, char right_p)
+ns_draw_box (NSRect r, CGFloat thickness, NSColor *col,
+ char left_p, char right_p)
/* --------------------------------------------------------------------------
Draw an unfilled rect inside r, optionally leaving left and/or right open.
Note we can't just use an NSDrawRect command, because of the possibility
@@ -3033,7 +2992,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
/* Draw the image.. do we need to draw placeholder if img ==nil? */
if (img != nil)
{
-#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
NSRect dr = NSMakeRect (x, y, s->slice.width, s->slice.height);
NSRect ir = NSMakeRect (s->slice.x, s->slice.y,
s->slice.width, s->slice.height);
@@ -3358,6 +3317,19 @@ ns_send_appdefined (int value)
{
/*NSTRACE (ns_send_appdefined); */
+#ifdef NS_IMPL_GNUSTEP
+ // GNUStep needs postEvent to happen on the main thread.
+ if (! [[NSThread currentThread] isMainThread])
+ {
+ EmacsApp *app = (EmacsApp *)NSApp;
+ app->nextappdefined = value;
+ [app performSelectorOnMainThread:@selector (sendFromMainThread:)
+ withObject:nil
+ waitUntilDone:YES];
+ return;
+ }
+#endif
+
/* Only post this event if we haven't already posted one. This will end
the [NXApp run] main loop after having processed all events queued at
this moment. */
@@ -3417,6 +3389,9 @@ check_native_fs ()
}
#endif
+/* GNUStep and OSX <= 10.4 does not have cancelTracking. */
+#if defined (NS_IMPL_COCOA) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
const char *
ns_get_pending_menu_title ()
{
@@ -3427,10 +3402,6 @@ ns_get_pending_menu_title ()
void
ns_check_menu_open (NSMenu *menu)
{
- /* GNUStep and OSX <= 10.4 does not have cancelTracking. */
-#if defined(NS_IMPL_COCOA) && \
- MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-
/* Click in menu bar? */
NSArray *a = [[NSApp mainMenu] itemArray];
int i;
@@ -3460,14 +3431,12 @@ ns_check_menu_open (NSMenu *menu)
menu_will_open_state = MENU_NONE;
}
}
-#endif
}
/* Redo saved menu click if state is MENU_PENDING. */
void
ns_check_pending_open_menu ()
{
-#ifdef NS_IMPL_COCOA
if (menu_will_open_state == MENU_PENDING)
{
CGEventSourceRef source
@@ -3484,9 +3453,8 @@ ns_check_pending_open_menu ()
menu_will_open_state = MENU_OPENING;
}
-#endif
}
-
+#endif /* NS_IMPL_COCOA) && >= MAC_OS_X_VERSION_10_5 */
static int
ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
@@ -4392,6 +4360,12 @@ ns_term_init (Lisp_Object display_name)
[NSApp run];
ns_do_open_file = YES;
+
+#if defined (NS_IMPL_GNUSTEP) && defined (SIGCHLD)
+ /* GNUstep steals SIGCHLD for use in NSTask, but we don't use NSTask.
+ We must re-catch it so subprocess works. */
+ catch_child_signal ();
+#endif
return dpyinfo;
}
@@ -4699,6 +4673,13 @@ not_in_argv (NSString *arg)
ns_send_appdefined (-2);
}
+#ifdef NS_IMPL_GNUSTEP
+- (void)sendFromMainThread:(id)unused
+{
+ ns_send_appdefined (nextappdefined);
+}
+#endif
+
- (void)fd_handler:(id)unused
/* --------------------------------------------------------------------------
Check data waiting on file descriptors and terminate if so
@@ -4863,7 +4844,7 @@ not_in_argv (NSString *arg)
NSEvent *e =[[self window] currentEvent];
struct face *face =FRAME_DEFAULT_FACE (emacsframe);
id newFont;
- float size;
+ CGFloat size;
NSTRACE (changeFont);
if (!emacs_event)
@@ -4982,7 +4963,16 @@ not_in_argv (NSString *arg)
{
/* COUNTERHACK: map 'Delete' on upper-right main KB to 'Backspace',
because Emacs treats Delete and KP-Delete same (in simple.el). */
- if (fnKeysym == 0xFFFF && [theEvent keyCode] == 0x33)
+ if ((fnKeysym == 0xFFFF && [theEvent keyCode] == 0x33)
+#ifdef NS_IMPL_GNUSTEP
+ /* GNUstep uses incompatible keycodes, even for those that are
+ supposed to be hardware independent. Just check for delete.
+ Keypad delete does not have keysym 0xFFFF.
+ See http://savannah.gnu.org/bugs/?25395
+ */
+ || (fnKeysym == 0xFFFF && code == 127)
+#endif
+ )
code = 0xFF08; /* backspace */
else
code = fnKeysym;
@@ -5135,10 +5125,14 @@ not_in_argv (NSString *arg)
#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
/* if we get here we should send the key for input manager processing */
+ /* Disable warning, there is nothing a user can do about it anyway, and
+ it does not seem to matter. */
+#if 0
if (firstTime && [[NSInputManager currentInputManager]
wantsToDelayTextChangeNotifications] == NO)
fprintf (stderr,
"Emacs: WARNING: TextInput mgr wants marked text to be permanent!\n");
+#endif
firstTime = NO;
#endif
if (NS_KEYLOG && !processingCompose)
@@ -5346,7 +5340,12 @@ not_in_argv (NSString *arg)
return NSMakeRange (NSNotFound, 0);
}
+#if defined (NS_IMPL_COCOA) || GNUSTEP_GUI_MAJOR_VERSION > 0 || \
+ GNUSTEP_GUI_MINOR_VERSION > 22
- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
+#else
+- (unsigned int)characterIndexForPoint: (NSPoint)thePoint
+#endif
{
if (NS_KEYLOG)
NSLog (@"characterIndexForPoint request");
@@ -5385,7 +5384,7 @@ not_in_argv (NSString *arg)
if ([theEvent type] == NSScrollWheel)
{
- float delta = [theEvent deltaY];
+ CGFloat delta = [theEvent deltaY];
/* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */
if (delta == 0)
return;
@@ -5569,7 +5568,6 @@ not_in_argv (NSString *arg)
if (oldr != rows || oldc != cols || neww != oldw || newh != oldh)
{
- struct frame *f = emacsframe;
NSView *view = FRAME_NS_VIEW (emacsframe);
NSWindow *win = [view window];
NSSize sz = [win resizeIncrements];
@@ -5778,7 +5776,6 @@ not_in_argv (NSString *arg)
NSRect r, wr;
Lisp_Object tem;
NSWindow *win;
- NSButton *toggleButton;
NSSize sz;
NSColor *col;
NSString *name;
@@ -5854,9 +5851,12 @@ not_in_argv (NSString *arg)
[win setToolbar: toolbar];
[toolbar setVisible: NO];
#ifdef NS_IMPL_COCOA
+ {
+ NSButton *toggleButton;
toggleButton = [win standardWindowButton: NSWindowToolbarButton];
[toggleButton setTarget: self];
[toggleButton setAction: @selector (toggleToolbar: )];
+ }
#endif
FRAME_TOOLBAR_HEIGHT (f) = 0;
@@ -5880,7 +5880,7 @@ not_in_argv (NSString *arg)
col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
(FRAME_DEFAULT_FACE (emacsframe)), emacsframe);
[win setBackgroundColor: col];
- if ([col alphaComponent] != 1.0)
+ if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[win setOpaque: NO];
[self allocateGState];
@@ -5973,7 +5973,7 @@ not_in_argv (NSString *arg)
result = ns_userRect.size.height ? ns_userRect : result;
ns_userRect = NSMakeRect (0, 0, 0, 0);
[self setFSValue: FULLSCREEN_NONE];
- maximized_width = maximized_width = -1;
+ maximized_width = maximized_height = -1;
}
if (fs_before_fs == -1) next_maximized = -1;
@@ -6066,7 +6066,9 @@ not_in_argv (NSString *arg)
{
[self setFSValue: fs_before_fs];
fs_before_fs = -1;
+#ifdef NS_IMPL_COCOA
[self updateCollectionBehaviour];
+#endif
if (FRAME_EXTERNAL_TOOL_BAR (emacsframe))
{
[toolbar setVisible:YES];
@@ -6125,7 +6127,9 @@ not_in_argv (NSString *arg)
if (fs_is_native)
{
+#ifdef NS_IMPL_COCOA
[[self window] toggleFullScreen:sender];
+#endif
return;
}
@@ -6171,7 +6175,7 @@ not_in_argv (NSString *arg)
[fw useOptimizedDrawing: YES];
[fw setResizeIncrements: sz];
[fw setBackgroundColor: col];
- if ([col alphaComponent] != 1.0)
+ if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[fw setOpaque: NO];
f->border_width = 0;
@@ -6209,7 +6213,7 @@ not_in_argv (NSString *arg)
[w setContentView:[fw contentView]];
[w setResizeIncrements: sz];
[w setBackgroundColor: col];
- if ([col alphaComponent] != 1.0)
+ if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[w setOpaque: NO];
f->border_width = bwidth;
@@ -6903,10 +6907,11 @@ not_in_argv (NSString *arg)
}
else
{
- float pos, por;
+ float pos;
+ CGFloat por;
portion = max ((float)whole*min_portion/pixel_height, portion);
pos = (float)position / (whole - portion);
- por = (float)portion/whole;
+ por = (CGFloat)portion/whole;
#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
[self setKnobProportion: por];
[self setDoubleValue: pos];
@@ -6931,7 +6936,7 @@ not_in_argv (NSString *arg)
*part = last_hit_part;
*window = win;
XSETINT (*y, pixel_height);
- if ([self floatValue] > 0.999)
+ if ([self floatValue] > 0.999F)
XSETINT (*x, pixel_height);
else
XSETINT (*x, pixel_height * [self floatValue]);
@@ -7005,7 +7010,7 @@ not_in_argv (NSString *arg)
NSRect sr, kr;
/* hitPart is only updated AFTER event is passed on */
NSScrollerPart part = [self testPart: [e locationInWindow]];
- double inc = 0.0, loc, kloc, pos;
+ CGFloat inc = 0.0, loc, kloc, pos;
int edge = 0;
NSTRACE (EmacsScroller_mouseDown);
@@ -7104,7 +7109,6 @@ not_in_argv (NSString *arg)
{
NSRect sr;
double loc, pos;
- int edge = 0;
NSTRACE (EmacsScroller_mouseDragged);
@@ -7115,15 +7119,13 @@ not_in_argv (NSString *arg)
if (loc <= 0.0)
{
loc = 0.0;
- edge = -1;
}
else if (loc >= NSHeight (sr) + last_mouse_offset)
{
loc = NSHeight (sr) + last_mouse_offset;
- edge = 1;
}
- pos = /*(edge ? loc :*/ (loc - last_mouse_offset) / NSHeight (sr);
+ pos = (loc - last_mouse_offset) / NSHeight (sr);
[self sendScrollEventAtLoc: pos fromEvent: e];
}
@@ -7150,6 +7152,12 @@ not_in_argv (NSString *arg)
@end /* EmacsScroller */
+#ifdef NS_IMPL_GNUSTEP
+/* Dummy class to get rid of startup warnings. */
+@implementation EmacsDocument
+
+@end
+#endif
/* ==========================================================================
diff --git a/src/process.c b/src/process.c
index 45e8afdd22c..9df003fa3a3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -7029,6 +7029,16 @@ integer or floating point values.
return system_process_attributes (pid);
}
+void
+catch_child_signal (void)
+{
+#ifdef SIGCHLD
+ struct sigaction action;
+ emacs_sigaction_init (&action, deliver_child_signal);
+ sigaction (SIGCHLD, &action, 0);
+#endif
+}
+
/* This is not called "init_process" because that is the name of a
Mach system call, so it would cause problems on Darwin systems. */
@@ -7044,9 +7054,7 @@ init_process_emacs (void)
if (! noninteractive || initialized)
#endif
{
- struct sigaction action;
- emacs_sigaction_init (&action, deliver_child_signal);
- sigaction (SIGCHLD, &action, 0);
+ catch_child_signal ();
}
FD_ZERO (&input_wait_mask);
diff --git a/src/process.h b/src/process.h
index 765e5d82567..9455df18beb 100644
--- a/src/process.h
+++ b/src/process.h
@@ -217,5 +217,6 @@ extern void add_read_fd (int fd, fd_callback func, void *data);
extern void delete_read_fd (int fd);
extern void add_write_fd (int fd, fd_callback func, void *data);
extern void delete_write_fd (int fd);
+extern void catch_child_signal (void);
INLINE_HEADER_END