* nsterm.h (EmacsView): Add maximizing_resize, put it and old_title

inside NS_IMPL_COCOA.

* nsterm.m (windowWillResize:toSize:): Only change title if
! maximizing_resize && FULLSCREEN_NONE.  strdup title before
modifying it.
(viewDidEndLiveResize): New method.

Fixes: debbugs:15005
This commit is contained in:
Jan Djärv 2013-08-02 11:42:23 +02:00
parent 707c77c122
commit b19aa63653
3 changed files with 43 additions and 12 deletions

View file

@ -1,3 +1,13 @@
2013-08-02 Jan Djärv <jan.h.d@swipnet.se>
* nsterm.m (windowWillResize:toSize:): Only change title if
! maximizing_resize && FULLSCREEN_NONE (Bug#15005). strdup title before
modifying it.
(viewDidEndLiveResize): New method.
* nsterm.h (EmacsView): Add maximizing_resize, put it and old_title
inside NS_IMPL_COCOA.
2013-08-02 Dmitry Antipov <dmantipov@yandex.ru>
* insdel.c (adjust_after_replace, replace_range, del_range_2):

View file

@ -109,7 +109,10 @@ typedef float EmacsCGFloat;
@interface EmacsView : NSView <NSTextInput>
#endif
{
#ifdef NS_IMPL_COCOA
char *old_title;
BOOL maximizing_resize;
#endif
BOOL windowClosing;
NSString *workingText;
BOOL processingCompose;

View file

@ -5663,17 +5663,17 @@ - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
old_title = 0;
}
}
else
else if (fs_state == FULLSCREEN_NONE && ! maximizing_resize)
{
char *size_title;
NSWindow *window = [self window];
if (old_title == 0)
{
const char *t = [[[self window] title] UTF8String];
char *t = strdup ([[[self window] title] UTF8String]);
char *pos = strstr (t, " — ");
if (pos)
*pos = '\0';
old_title = xstrdup (t);
old_title = t;
}
size_title = xmalloc (strlen (old_title) + 40);
esprintf (size_title, "%s — (%d x %d)", old_title, cols, rows);
@ -5712,15 +5712,7 @@ - (void)windowDidResize: (NSNotification *)notification
NSTRACE (windowDidResize);
/*fprintf (stderr,"windowDidResize: %.0f\n",[theWindow frame].size.height); */
#ifdef NS_IMPL_COCOA
if (old_title != 0)
{
xfree (old_title);
old_title = 0;
}
#endif /* NS_IMPL_COCOA */
if (cols > 0 && rows > 0)
if (cols > 0 && rows > 0)
{
[self updateFrameSize: YES];
}
@ -5728,6 +5720,20 @@ - (void)windowDidResize: (NSNotification *)notification
ns_send_appdefined (-1);
}
#ifdef NS_IMPL_COCOA
- (void)viewDidEndLiveResize
{
[super viewDidEndLiveResize];
if (old_title != 0)
{
[[self window] setTitle: [NSString stringWithUTF8String: old_title]];
xfree (old_title);
old_title = 0;
}
maximizing_resize = NO;
}
#endif /* NS_IMPL_COCOA */
- (void)windowDidBecomeKey: (NSNotification *)notification
/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
@ -5831,7 +5837,10 @@ - (BOOL)isOpaque
FRAME_NS_VIEW (f) = self;
emacsframe = f;
#ifdef NS_IMPL_COCOA
old_title = 0;
maximizing_resize = NO;
#endif
win = [[EmacsWindow alloc]
initWithContentRect: r
@ -5974,6 +5983,9 @@ - (NSRect)windowWillUseStandardFrame:(NSWindow *)sender
maximized_width = -1;
result.origin.y = defaultFrame.origin.y;
[self setFSValue: FULLSCREEN_HEIGHT];
#ifdef NS_IMPL_COCOA
maximizing_resize = YES;
#endif
}
else if (next_maximized == FULLSCREEN_WIDTH)
{
@ -5992,12 +6004,18 @@ - (NSRect)windowWillUseStandardFrame:(NSWindow *)sender
maximized_width = result.size.width;
maximized_height = result.size.height;
[self setFSValue: FULLSCREEN_MAXIMIZED];
#ifdef NS_IMPL_COCOA
maximizing_resize = YES;
#endif
}
else
{
/* restore */
result = ns_userRect.size.height ? ns_userRect : result;
ns_userRect = NSMakeRect (0, 0, 0, 0);
#ifdef NS_IMPL_COCOA
maximizing_resize = fs_state != FULLSCREEN_NONE;
#endif
[self setFSValue: FULLSCREEN_NONE];
maximized_width = maximized_height = -1;
}