[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/ns/refactor 17c9369 2/4: Fix GNUstep build warnings
From: |
Alan Third |
Subject: |
scratch/ns/refactor 17c9369 2/4: Fix GNUstep build warnings |
Date: |
Wed, 9 Jun 2021 17:50:30 -0400 (EDT) |
branch: scratch/ns/refactor
commit 17c9369083fa0edd79c2208e54347f8544bb4910
Author: Alan Third <alan@idiocy.org>
Commit: Alan Third <alan@idiocy.org>
Fix GNUstep build warnings
* src/nsterm.h ([EmacsWindow orderedIndex]):
* src/nsterm.m ([EmacsWindow orderedIndex]): Implement orderedIndex
for use under GNUstep.
* src/nsmenu.m (free_frame_menubar):
(ns_update_menubar):
([EmacsMenu addSubmenuWithTitle:]):
([EmacsMenu addItemWithWidgetValue:attributes:]): Cast return values
to correct types.
([EmacsMenu fillWithWidgetValue:]): Move variable definition inside
relevant #ifdef block.
([EmacsMenu menuWillOpen:]):
([EmacsMenu menuDidClose:]):
([EmacsMenu confinementRectForMenu:onScreen:]):
([EmacsMenu menu:willHighlightItem:]): New functions to silence build
warnings.
* src/nsfont.m (nsfont_open): Remove pointless fabs call.
---
src/nsfont.m | 2 +-
src/nsmenu.m | 39 +++++++++++++++++++++++++++++++--------
src/nsterm.h | 4 ++++
src/nsterm.m | 10 ++++++++++
4 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/src/nsfont.m b/src/nsfont.m
index f4f0d28..06e10d5 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -700,7 +700,7 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int
pixel_size)
when setting family in ns_spec_to_descriptor(). */
if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F)
traits |= NSBoldFontMask;
- if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F))
+ if (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F)
traits |= NSItalicFontMask;
/* see
https://web.archive.org/web/20100201175731/http://cocoadev.com/forums/comments.php?DiscussionID=74
*/
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 24aa5a0..1d3e1ac 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -73,7 +73,7 @@ free_frame_menubar (struct frame *f)
id menu = [NSApp mainMenu];
for (int i = [menu numberOfItems] - 1 ; i >= 0; i--)
{
- NSMenuItem *item = [menu itemAtIndex:i];
+ NSMenuItem *item = (NSMenuItem *)[menu itemAtIndex:i];
NSString *title = [item title];
if ([ns_app_name isEqualToString:title])
@@ -358,7 +358,7 @@ ns_update_menubar (struct frame *f, bool deep_p)
if (i < [menu numberOfItems])
{
NSString *titleStr = [NSString stringWithUTF8String: wv->name];
- NSMenuItem *item = [menu itemAtIndex:i];
+ NSMenuItem *item = (NSMenuItem *)[menu itemAtIndex:i];
submenu = (EmacsMenu*)[item submenu];
[item setTitle:titleStr];
@@ -368,8 +368,10 @@ ns_update_menubar (struct frame *f, bool deep_p)
else
submenu = [menu addSubmenuWithTitle: wv->name];
+#ifdef NS_IMPL_COCOA
if ([[submenu title] isEqualToString:@"Help"])
[NSApp setHelpMenu:submenu];
+#endif
if (deep_p)
[submenu fillWithWidgetValue: wv->contents];
@@ -472,7 +474,7 @@ set_frame_menubar (struct frame *f, bool deep_p)
if (menu_separator_name_p (wv->name))
{
- item = [NSMenuItem separatorItem];
+ item = (NSMenuItem *)[NSMenuItem separatorItem];
}
else
{
@@ -534,7 +536,7 @@ set_frame_menubar (struct frame *f, bool deep_p)
needsUpdate = YES;
}
-
+#ifdef NS_IMPL_COCOA
typedef struct {
const char *from, *to;
} subst_t;
@@ -591,17 +593,18 @@ prettify_key (const char *key)
xfree (buf);
return SSDATA (result);
}
+#endif /* NS_IMPL_COCOA */
- (void)fillWithWidgetValue: (void *)wvptr
{
widget_value *first_wv = (widget_value *)wvptr;
- NSFont *menuFont = [NSFont menuFontOfSize:0];
NSDictionary *attributes = nil;
#ifdef NS_IMPL_COCOA
/* Cocoa doesn't allow multi-key sequences in its menu display, so
work around it by using tabs to split the title into two
columns. */
+ NSFont *menuFont = [NSFont menuFontOfSize:0];
NSDictionary *font_attribs = @{NSFontAttributeName: menuFont};
CGFloat maxNameWidth = 0;
CGFloat maxKeyWidth = 0;
@@ -672,9 +675,9 @@ prettify_key (const char *key)
- (EmacsMenu *)addSubmenuWithTitle: (const char *)title
{
NSString *titleStr = [NSString stringWithUTF8String: title];
- NSMenuItem *item = [self addItemWithTitle: titleStr
- action: (SEL)nil /*@selector (menuDown:)
*/
- keyEquivalent: @""];
+ NSMenuItem *item = (NSMenuItem *)[self addItemWithTitle: titleStr
+ action: (SEL)nil
+ keyEquivalent: @""];
EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr];
[self setSubmenu: submenu forItem: item];
[submenu release];
@@ -711,6 +714,26 @@ prettify_key (const char *key)
: Qnil;
}
+#ifdef NS_IMPL_GNUSTEP
+/* GNUstep seems to have a number of required methods in
+ NSMenuDelegate that are optional in Cocoa. */
+
+- (void) menuWillOpen:(NSMenu *)menu
+{
+}
+- (void) menuDidClose:(NSMenu *)menu
+{
+}
+- (NSRect)confinementRectForMenu:(NSMenu *)menu
+ onScreen:(NSScreen *)screen
+{
+ return NSZeroRect;
+}
+- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
+{
+}
+#endif
+
@end /* EmacsMenu */
diff --git a/src/nsterm.h b/src/nsterm.h
index af628ab..be1352d 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -491,6 +491,10 @@ typedef id instancetype;
NSPoint grabOffset;
}
+#ifdef NS_IMPL_GNUSTEP
+- (NSInteger) orderedIndex;
+#endif
+
- (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above;
- (void)setAppearance;
@end
diff --git a/src/nsterm.m b/src/nsterm.m
index 363fbe8..d890bab 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -8619,6 +8619,16 @@ not_in_argv (NSString *arg)
}
+#ifdef NS_IMPL_GNUSTEP
+/* orderedIndex isn't yet available in GNUstep, but it seems pretty
+ easy to implement. */
+- (NSInteger) orderedIndex
+{
+ return [[NSApp orderedWindows] indexOfObjectIdenticalTo:self];
+}
+#endif
+
+
/* The array returned by [NSWindow parentWindow] may already be
sorted, but the documentation doesn't tell us whether or not it is,
so to be safe we'll sort it. */