aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsfns.m
diff options
context:
space:
mode:
authorJan Djärv2013-06-02 21:14:25 +0200
committerJan Djärv2013-06-02 21:14:25 +0200
commitc0342369acfbad2f0ea86b949a2f116304186353 (patch)
treeee60679ec6f2c20b201ef8a71be515582e27c268 /src/nsfns.m
parenta2d98946738ffd42f90b3f54d2a32be9d7b6429e (diff)
downloademacs-c0342369acfbad2f0ea86b949a2f116304186353.tar.gz
emacs-c0342369acfbad2f0ea86b949a2f116304186353.zip
Update the GNUStep port so it works OK. Redraw and sizing bugs remain.
* nextstep/templates/Info-gnustep.plist.in: Add NSDocumentClass EmacsDocument. * src/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. * src/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. * src/nsimage.m (setXBMColor:, getPixelAtX:Y:): Use EmacsCGFloat. * src/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. * src/nsselect.m (ns_get_local_selection): Remove unused variable type. * src/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. * src/nsterm.m: Include src/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. * src/process.c (catch_child_signal): New function. (init_process_emacs): Call it. * src/process.h (catch_child_signal): Declare.
Diffstat (limited to 'src/nsfns.m')
-rw-r--r--src/nsfns.m71
1 files changed, 23 insertions, 48 deletions
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
287x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 287x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
288{ 288{
289 NSColor *col; 289 NSColor *col;
290 CGFloat r, g, b, alpha; 290 EmacsCGFloat r, g, b, alpha;
291 291
292 if (ns_lisp_to_color (arg, &col)) 292 if (ns_lisp_to_color (arg, &col))
293 { 293 {
@@ -319,7 +319,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
319 struct face *face; 319 struct face *face;
320 NSColor *col; 320 NSColor *col;
321 NSView *view = FRAME_NS_VIEW (f); 321 NSView *view = FRAME_NS_VIEW (f);
322 CGFloat r, g, b, alpha; 322 EmacsCGFloat r, g, b, alpha;
323 323
324 if (ns_lisp_to_color (arg, &col)) 324 if (ns_lisp_to_color (arg, &col))
325 { 325 {
@@ -344,7 +344,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
344 { 344 {
345 [[view window] setBackgroundColor: col]; 345 [[view window] setBackgroundColor: col];
346 346
347 if (alpha != 1.0) 347 if (alpha != (EmacsCGFloat) 1.0)
348 [[view window] setOpaque: NO]; 348 [[view window] setOpaque: NO];
349 else 349 else
350 [[view window] setOpaque: YES]; 350 [[view window] setOpaque: YES];
@@ -714,7 +714,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
714} 714}
715 715
716 716
717void 717static void
718ns_implicitly_set_icon_type (struct frame *f) 718ns_implicitly_set_icon_type (struct frame *f)
719{ 719{
720 Lisp_Object tem; 720 Lisp_Object tem;
@@ -859,7 +859,7 @@ ns_cursor_type_to_lisp (int arg)
859} 859}
860 860
861/* This is the same as the xfns.c definition. */ 861/* This is the same as the xfns.c definition. */
862void 862static void
863x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval) 863x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
864{ 864{
865 set_frame_cursor_types (f, arg); 865 set_frame_cursor_types (f, arg);
@@ -1082,7 +1082,6 @@ This function is an internal primitive--use `make-frame' instead. */)
1082 struct ns_display_info *dpyinfo = NULL; 1082 struct ns_display_info *dpyinfo = NULL;
1083 Lisp_Object parent; 1083 Lisp_Object parent;
1084 struct kboard *kb; 1084 struct kboard *kb;
1085 Lisp_Object tfont, tfontsize;
1086 static int desc_ctr = 1; 1085 static int desc_ctr = 1;
1087 1086
1088 /* x_get_arg modifies parms. */ 1087 /* x_get_arg modifies parms. */
@@ -1189,10 +1188,10 @@ This function is an internal primitive--use `make-frame' instead. */)
1189 { 1188 {
1190 /* use for default font name */ 1189 /* use for default font name */
1191 id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */ 1190 id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */
1192 tfontsize = x_default_parameter (f, parms, Qfontsize, 1191 x_default_parameter (f, parms, Qfontsize,
1193 make_number (0 /*(int)[font pointSize]*/), 1192 make_number (0 /*(int)[font pointSize]*/),
1194 "fontSize", "FontSize", RES_TYPE_NUMBER); 1193 "fontSize", "FontSize", RES_TYPE_NUMBER);
1195 tfont = x_default_parameter (f, parms, Qfont, 1194 x_default_parameter (f, parms, Qfont,
1196 build_string ([[font fontName] UTF8String]), 1195 build_string ([[font fontName] UTF8String]),
1197 "font", "Font", RES_TYPE_STRING); 1196 "font", "Font", RES_TYPE_STRING);
1198 } 1197 }
@@ -1410,6 +1409,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1410{ 1409{
1411 static id fileDelegate = nil; 1410 static id fileDelegate = nil;
1412 BOOL ret; 1411 BOOL ret;
1412 BOOL isSave = NILP (mustmatch) && NILP (dir_only_p);
1413 id panel; 1413 id panel;
1414 Lisp_Object fname; 1414 Lisp_Object fname;
1415 1415
@@ -1431,7 +1431,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1431 if ([dirS characterAtIndex: 0] == '~') 1431 if ([dirS characterAtIndex: 0] == '~')
1432 dirS = [dirS stringByExpandingTildeInPath]; 1432 dirS = [dirS stringByExpandingTildeInPath];
1433 1433
1434 panel = NILP (mustmatch) && NILP (dir_only_p) ? 1434 panel = isSave ?
1435 (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel]; 1435 (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
1436 1436
1437 [panel setTitle: promptS]; 1437 [panel setTitle: promptS];
@@ -1446,7 +1446,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1446 [panel setCanChooseDirectories: YES]; 1446 [panel setCanChooseDirectories: YES];
1447 [panel setCanChooseFiles: NO]; 1447 [panel setCanChooseFiles: NO];
1448 } 1448 }
1449 else 1449 else if (! isSave)
1450 { 1450 {
1451 /* This is not quite what the documentation says, but it is compatible 1451 /* This is not quite what the documentation says, but it is compatible
1452 with the Gtk+ code. Also, the menu entry says "Open File...". */ 1452 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. */)
1481 1481
1482 if (ret) 1482 if (ret)
1483 { 1483 {
1484 NSString *str = [panel getFilename]; 1484 NSString *str = ns_filename_from_panel (panel);
1485 if (! str) str = [panel getDirectory]; 1485 if (! str) str = ns_directory_from_panel (panel);
1486 if (! str) ret = NO; 1486 if (! str) ret = NO;
1487 else fname = build_string ([str UTF8String]); 1487 else fname = build_string ([str UTF8String]);
1488 } 1488 }
@@ -1909,7 +1909,9 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
1909#else 1909#else
1910 Lisp_Object ret = Qnil; 1910 Lisp_Object ret = Qnil;
1911 NSMenu *svcs; 1911 NSMenu *svcs;
1912#ifdef NS_IMPL_COCOA
1912 id delegate; 1913 id delegate;
1914#endif
1913 1915
1914 check_window_system (NULL); 1916 check_window_system (NULL);
1915 svcs = [[NSMenu alloc] initWithTitle: @"Services"]; 1917 svcs = [[NSMenu alloc] initWithTitle: @"Services"];
@@ -1992,15 +1994,9 @@ DEFUN ("ns-convert-utf8-nfd-to-nfc", Fns_convert_utf8_nfd_to_nfc,
1992 1994
1993 CHECK_STRING (str); 1995 CHECK_STRING (str);
1994 utfStr = [NSString stringWithUTF8String: SSDATA (str)]; 1996 utfStr = [NSString stringWithUTF8String: SSDATA (str)];
1995 if (![utfStr respondsToSelector: 1997#ifdef NS_IMPL_COCOA
1996 @selector (precomposedStringWithCanonicalMapping)])
1997 {
1998 message1
1999 ("Warning: ns-convert-utf8-nfd-to-nfc unsupported under GNUstep.\n");
2000 return Qnil;
2001 }
2002 else
2003 utfStr = [utfStr precomposedStringWithCanonicalMapping]; 1998 utfStr = [utfStr precomposedStringWithCanonicalMapping];
1999#endif
2004 return build_string ([utfStr UTF8String]); 2000 return build_string ([utfStr UTF8String]);
2005} 2001}
2006 2002
@@ -2155,6 +2151,9 @@ x_set_scroll_bar_default_width (struct frame *f)
2155} 2151}
2156 2152
2157 2153
2154extern const char *x_get_string_resource (XrmDatabase, char *, char *);
2155
2156
2158/* terms impl this instead of x-get-resource directly */ 2157/* terms impl this instead of x-get-resource directly */
2159const char * 2158const char *
2160x_get_string_resource (XrmDatabase rdb, char *name, char *class) 2159x_get_string_resource (XrmDatabase rdb, char *name, char *class)
@@ -2203,13 +2202,6 @@ x_pixel_height (struct frame *f)
2203} 2202}
2204 2203
2205 2204
2206int
2207x_screen_planes (struct frame *f)
2208{
2209 return FRAME_NS_DISPLAY_INFO (f)->n_planes;
2210}
2211
2212
2213void 2205void
2214x_sync (struct frame *f) 2206x_sync (struct frame *f)
2215{ 2207{
@@ -2242,7 +2234,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2242 (Lisp_Object color, Lisp_Object frame) 2234 (Lisp_Object color, Lisp_Object frame)
2243{ 2235{
2244 NSColor * col; 2236 NSColor * col;
2245 CGFloat red, green, blue, alpha; 2237 EmacsCGFloat red, green, blue, alpha;
2246 2238
2247 check_window_system (NULL); 2239 check_window_system (NULL);
2248 CHECK_STRING (color); 2240 CHECK_STRING (color);
@@ -2434,11 +2426,10 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
2434 struct MonitorInfo *m = &monitors[i]; 2426 struct MonitorInfo *m = &monitors[i];
2435 NSRect fr = [s frame]; 2427 NSRect fr = [s frame];
2436 NSRect vfr = [s visibleFrame]; 2428 NSRect vfr = [s visibleFrame];
2437 NSDictionary *dict = [s deviceDescription];
2438 NSValue *resval = [dict valueForKey:NSDeviceResolution];
2439 short y, vy; 2429 short y, vy;
2440 2430
2441#ifdef NS_IMPL_COCOA 2431#ifdef NS_IMPL_COCOA
2432 NSDictionary *dict = [s deviceDescription];
2442 NSNumber *nid = [dict objectForKey:@"NSScreenNumber"]; 2433 NSNumber *nid = [dict objectForKey:@"NSScreenNumber"];
2443 CGDirectDisplayID did = [nid unsignedIntValue]; 2434 CGDirectDisplayID did = [nid unsignedIntValue];
2444#endif 2435#endif
@@ -2776,14 +2767,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
2776 [NSApp stop: self]; 2767 [NSApp stop: self];
2777} 2768}
2778#endif 2769#endif
2779- (NSString *) getFilename
2780{
2781 return ns_filename_from_panel (self);
2782}
2783- (NSString *) getDirectory
2784{
2785 return ns_directory_from_panel (self);
2786}
2787 2770
2788- (BOOL)performKeyEquivalent:(NSEvent *)theEvent 2771- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
2789{ 2772{
@@ -2807,8 +2790,8 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
2807 [super ok: sender]; 2790 [super ok: sender];
2808 2791
2809 // If not choosing directories, and Open is pressed on a directory, return. 2792 // If not choosing directories, and Open is pressed on a directory, return.
2810 if (! [self canChooseDirectories] && [self getDirectory] && 2793 if (! [self canChooseDirectories] && ns_directory_from_panel (self) &&
2811 ! [self getFilename]) 2794 ! ns_filename_from_panel (self))
2812 return; 2795 return;
2813 2796
2814 panelOK = 1; 2797 panelOK = 1;
@@ -2821,14 +2804,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
2821} 2804}
2822 2805
2823#endif 2806#endif
2824- (NSString *) getFilename
2825{
2826 return ns_filename_from_panel (self);
2827}
2828- (NSString *) getDirectory
2829{
2830 return ns_directory_from_panel (self);
2831}
2832- (BOOL)performKeyEquivalent:(NSEvent *)theEvent 2807- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
2833{ 2808{
2834 // NSOpenPanel inherits NSSavePanel, so passing self is OK. 2809 // NSOpenPanel inherits NSSavePanel, so passing self is OK.