/* NeXT/Open/GNUstep / MacOSX communication module.
-Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2014 Free Software
+Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2015 Free Software
Foundation, Inc.
This file is part of GNU Emacs.
NULL, 0, 0
};
+static NSString *represented_filename = nil;
+static struct frame *represented_frame = 0;
+
#ifdef NS_IMPL_COCOA
/*
* State for pending menu activation:
========================================================================== */
+void
+ns_set_represented_filename (NSString* fstr, struct frame *f)
+{
+ represented_filename = [fstr retain];
+ represented_frame = f;
+}
+
void
ns_init_events (struct input_event* ev)
{
static void
-ns_frame_raise_lower (struct frame *f, int raise)
+ns_frame_raise_lower (struct frame *f, bool raise)
/* --------------------------------------------------------------------------
External (hook)
-------------------------------------------------------------------------- */
void
x_set_window_size (struct frame *f,
- int change_grav,
+ bool change_gravity,
int width,
int height,
bool pixelwise)
/* 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. */
+
+#ifdef NS_IMPL_COCOA
+ if (! send_appdefined)
+ {
+ /* OSX 10.10.1 swallows the AppDefined event we are sending ourselves
+ in certain situations (rapid incoming events).
+ So check if we have one, if not add one. */
+ NSEvent *appev = [NSApp nextEventMatchingMask:NSApplicationDefinedMask
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue:NO];
+ if (! appev) send_appdefined = YES;
+ }
+#endif
+
if (send_appdefined)
{
NSEvent *nxev;
EmacsScroller *bar;
int window_y, window_height;
int top, left, height, width;
+ BOOL update_p = YES;
/* optimization; display engine sends WAY too many of these.. */
if (!NILP (window->vertical_scroll_bar))
}
else
view->scrollbarsNeedingUpdate--;
+ update_p = NO;
}
}
bar = XNS_SCROLL_BAR (window->vertical_scroll_bar);
[bar removeFromSuperview];
wset_vertical_scroll_bar (window, Qnil);
+ [bar release];
}
ns_clear_frame_area (f, left, top, width, height);
unblock_input ();
bar = [[EmacsScroller alloc] initFrame: r window: win];
wset_vertical_scroll_bar (window, make_save_ptr (bar));
+ update_p = YES;
}
else
{
}
}
- [bar setPosition: position portion: portion whole: whole];
+ if (update_p)
+ [bar setPosition: position portion: portion whole: whole];
unblock_input ();
}
int top, height, left, width;
int window_x, window_width;
int pixel_width = WINDOW_PIXEL_WIDTH (window);
+ BOOL update_p = YES;
/* optimization; display engine sends WAY too many of these.. */
if (!NILP (window->horizontal_scroll_bar))
}
else
view->scrollbarsNeedingUpdate--;
+ update_p = NO;
}
}
bar = [[EmacsScroller alloc] initFrame: r window: win];
wset_horizontal_scroll_bar (window, make_save_ptr (bar));
+ update_p = YES;
}
else
{
if (oldRect.origin.x != r.origin.x)
ns_clear_frame_area (f, left, top, width, height);
[bar setFrame: r];
+ update_p = YES;
}
}
- [bar setPosition: position portion: portion whole: whole];
+ if (update_p)
+ [bar setPosition: position portion: portion whole: whole];
unblock_input ();
}
{
view = [subviews objectAtIndex: i];
if (![view isKindOfClass: [EmacsScroller class]]) continue;
- [view judge];
- removed = YES;
+ if ([view judge])
+ removed = YES;
}
if (removed)
#ifdef NS_IMPL_COCOA
- (void)run
{
-#ifndef NSAppKitVersionNumber10_8
-#define NSAppKitVersionNumber10_8 1187
+#ifndef NSAppKitVersionNumber10_9
+#define NSAppKitVersionNumber10_9 1265
#endif
- if (NSAppKitVersionNumber <= NSAppKitVersionNumber10_8)
- {
- [super run];
- return;
- }
+ if ((int)NSAppKitVersionNumber != NSAppKitVersionNumber10_9)
+ {
+ [super run];
+ return;
+ }
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode
dequeue:YES];
+
[self sendEvent:event];
[self updateWindows];
} while (shouldKeepRunning);
}
#endif
+ if (represented_filename != nil && represented_frame)
+ {
+ NSString *fstr = represented_filename;
+ NSView *view = FRAME_NS_VIEW (represented_frame);
+#ifdef NS_IMPL_COCOA
+ /* work around a bug observed on 10.3 and later where
+ setTitleWithRepresentedFilename does not clear out previous state
+ if given filename does not exist */
+ if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
+ [[view window] setRepresentedFilename: @""];
+#endif
+ [[view window] setRepresentedFilename: fstr];
+ [represented_filename release];
+ represented_filename = nil;
+ represented_frame = NULL;
+ }
+
if (type == NSApplicationDefined)
{
switch ([theEvent data2])
if (pixel_height == 0) pixel_height = 1;
min_portion = 20 / pixel_height;
[super setFrame: newRect];
- [self display];
/* unblock_input (); */
}
+- (void)dealloc
+{
+ NSTRACE (EmacsScroller_dealloc);
+ if (window)
+ wset_vertical_scroll_bar (window, Qnil);
+ window = 0;
+ [super dealloc];
+}
+
+
- condemn
{
NSTRACE (condemn);
}
-- judge
+-(bool)judge
{
NSTRACE (judge);
+ bool ret = condemned;
if (condemned)
{
EmacsView *view;
view = (EmacsView *)FRAME_NS_VIEW (frame);
if (view != nil)
view->scrollbarsNeedingUpdate++;
+ if (window)
+ wset_vertical_scroll_bar (window, Qnil);
+ window = 0;
[self removeFromSuperview];
[self release];
unblock_input ();
}
- return self;
+ return ret;
}
#endif
}
- /* Events may come here even if the event loop is not running.
- If we don't enter the event loop, the scroll bar will not update.
- So send SIGIO to ourselves. */
- if (apploopnr == 0) raise (SIGIO);
-
return self;
}
/* Now make the frame display the given font. */
if (FRAME_NS_WINDOW (f) != 0 && ! [view isFullscreen])
- x_set_window_size (f, 0, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
- FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 1);
+ x_set_window_size (f, false, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
+ FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), true);
return font_object;
}