aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Third2020-04-04 15:13:58 +0100
committerAlan Third2020-04-16 19:11:05 +0100
commit24cb6908d70c14792c686679cb08091447b9c3b1 (patch)
treee8866b8bb53e1742b3c1c6eec7d948c36dfc18cf /src
parent6a60701bba3d87f5d9a1730e18b6da827f41a062 (diff)
downloademacs-24cb6908d70c14792c686679cb08091447b9c3b1.tar.gz
emacs-24cb6908d70c14792c686679cb08091447b9c3b1.zip
Fix NS frame resizing issues (bug#40200, bug#28872)
* src/nsmenu.m (update_frame_tool_bar): Remove reference to updateFrameSize. * src/nsterm.h: ([EmacsView updateFrameSize]): ([EmacsView setRows:andColumns:]): Remove unused method definitions. (NS_PARENT_WINDOW_LEFT_POS): (NS_PARENT_WINDOW_TOP_POS): Move to nsterm.m. * src/nsterm.m (ns_parent_window_rect): New function. (NS_PARENT_WINDOW_LEFT_POS): (NS_PARENT_WINDOW_TOP_POS): Move to nsterm.m and simplify. (ns_set_offset): Fix strange behaviours when using negative values. (ns_set_window_size): (ns_set_undecorated): ([EmacsView windowDidResize:]): ([EmacsView windowDidExitFullScreen]): (ns_judge_scroll_bars): Remove references to updateFrameSize. ([EmacsView dealloc]): Unset resize notification and release buffer. ([EmacsView updateFrameSize:]): Remove function. ([EmacsView windowWillResize:toSize:]): Move some code to viewDidResize. ([EmacsView viewDidResize]): New function. ([EmacsView initFrameFromEmacs:]): Set up resize notification and move buffer creation until after the prerequisite objects are created. ([EmacsView toggleFullScreen:]): Set frame to the size of the contentview, not the whole window, and remove reference to updateFrameSize. ([EmacsView setRows:andColumns:]): Remove unused method. ([EmacsView windowDidMove:]): Tidy up.
Diffstat (limited to 'src')
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/nsterm.h15
-rw-r--r--src/nsterm.m318
3 files changed, 150 insertions, 185 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 67f9a45a401..b7e4cbd5654 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1141,8 +1141,6 @@ update_frame_tool_bar (struct frame *f)
1141 } 1141 }
1142#endif 1142#endif
1143 1143
1144 if (oldh != FRAME_TOOLBAR_HEIGHT (f))
1145 [view updateFrameSize:YES];
1146 if (view->wait_for_tool_bar && FRAME_TOOLBAR_HEIGHT (f) > 0) 1144 if (view->wait_for_tool_bar && FRAME_TOOLBAR_HEIGHT (f) > 0)
1147 { 1145 {
1148 view->wait_for_tool_bar = NO; 1146 view->wait_for_tool_bar = NO;
diff --git a/src/nsterm.h b/src/nsterm.h
index 8396a542f77..e142dbd4f07 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -439,7 +439,6 @@ typedef id instancetype;
439#endif 439#endif
440@public 440@public
441 struct frame *emacsframe; 441 struct frame *emacsframe;
442 int rows, cols;
443 int scrollbarsNeedingUpdate; 442 int scrollbarsNeedingUpdate;
444 EmacsToolbar *toolbar; 443 EmacsToolbar *toolbar;
445 NSRect ns_userRect; 444 NSRect ns_userRect;
@@ -458,11 +457,9 @@ typedef id instancetype;
458/* Emacs-side interface */ 457/* Emacs-side interface */
459- (instancetype) initFrameFromEmacs: (struct frame *) f; 458- (instancetype) initFrameFromEmacs: (struct frame *) f;
460- (void) createToolbar: (struct frame *)f; 459- (void) createToolbar: (struct frame *)f;
461- (void) setRows: (int) r andColumns: (int) c;
462- (void) setWindowClosing: (BOOL)closing; 460- (void) setWindowClosing: (BOOL)closing;
463- (EmacsToolbar *) toolbar; 461- (EmacsToolbar *) toolbar;
464- (void) deleteWorkingText; 462- (void) deleteWorkingText;
465- (void) updateFrameSize: (BOOL) delay;
466- (void) handleFS; 463- (void) handleFS;
467- (void) setFSValue: (int)value; 464- (void) setFSValue: (int)value;
468- (void) toggleFullScreen: (id) sender; 465- (void) toggleFullScreen: (id) sender;
@@ -1084,18 +1081,6 @@ struct x_output
1084 (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f) \ 1081 (FRAME_SCROLL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f) \
1085 - NS_SCROLL_BAR_HEIGHT (f)) : 0) 1082 - NS_SCROLL_BAR_HEIGHT (f)) : 0)
1086 1083
1087/* Calculate system coordinates of the left and top of the parent
1088 window or, if there is no parent window, the screen. */
1089#define NS_PARENT_WINDOW_LEFT_POS(f) \
1090 (FRAME_PARENT_FRAME (f) != NULL \
1091 ? [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.x : 0)
1092#define NS_PARENT_WINDOW_TOP_POS(f) \
1093 (FRAME_PARENT_FRAME (f) != NULL \
1094 ? ([FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.y \
1095 + [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.size.height \
1096 - FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f))) \
1097 : [[[NSScreen screens] objectAtIndex: 0] frame].size.height)
1098
1099#define FRAME_NS_FONT_TABLE(f) (FRAME_DISPLAY_INFO (f)->font_table) 1084#define FRAME_NS_FONT_TABLE(f) (FRAME_DISPLAY_INFO (f)->font_table)
1100 1085
1101#define FRAME_FONTSET(f) ((f)->output_data.ns->fontset) 1086#define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
diff --git a/src/nsterm.m b/src/nsterm.m
index 2f181eafd03..a75c3ef4dba 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -843,6 +843,32 @@ ns_menu_bar_height (NSScreen *screen)
843} 843}
844 844
845 845
846/* Get the frame rect, in system coordinates, of the parent window or,
847 if there is no parent window, the main screen. */
848static inline NSRect
849ns_parent_window_rect (struct frame *f)
850{
851 NSRect parentRect;
852
853 if (FRAME_PARENT_FRAME (f) != NULL)
854 {
855 EmacsView *parentView = FRAME_NS_VIEW (FRAME_PARENT_FRAME (f));
856 parentRect = [parentView convertRect:[parentView frame]
857 toView:nil];
858 parentRect = [[parentView window] convertRectToScreen:parentRect];
859 }
860 else
861 parentRect = [[[NSScreen screens] objectAtIndex:0] frame];
862
863 return parentRect;
864}
865
866/* Calculate system coordinates of the left and top of the parent
867 window or, if there is no parent window, the main screen. */
868#define NS_PARENT_WINDOW_LEFT_POS(f) NSMinX (ns_parent_window_rect (f))
869#define NS_PARENT_WINDOW_TOP_POS(f) NSMaxY (ns_parent_window_rect (f))
870
871
846static NSRect 872static NSRect
847ns_row_rect (struct window *w, struct glyph_row *row, 873ns_row_rect (struct window *w, struct glyph_row *row,
848 enum glyph_row_area area) 874 enum glyph_row_area area)
@@ -1741,61 +1767,64 @@ ns_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
1741 -------------------------------------------------------------------------- */ 1767 -------------------------------------------------------------------------- */
1742{ 1768{
1743 NSView *view = FRAME_NS_VIEW (f); 1769 NSView *view = FRAME_NS_VIEW (f);
1744 NSScreen *screen = [[view window] screen]; 1770 NSRect windowFrame = [[view window] frame];
1771 NSPoint topLeft;
1745 1772
1746 NSTRACE ("ns_set_offset"); 1773 NSTRACE ("ns_set_offset");
1747 1774
1748 block_input (); 1775 block_input ();
1749 1776
1750 f->left_pos = xoff; 1777 if (FRAME_PARENT_FRAME (f))
1751 f->top_pos = yoff; 1778 {
1779 /* Convert the parent frame's view rectangle into screen
1780 coords. */
1781 EmacsView *parentView = FRAME_NS_VIEW (FRAME_PARENT_FRAME (f));
1782 NSRect parentRect = [parentView convertRect:[parentView frame]
1783 toView:nil];
1784 parentRect = [[parentView window] convertRectToScreen:parentRect];
1785
1786 if (f->size_hint_flags & XNegative)
1787 topLeft.x = NSMaxX (parentRect) - NSWidth (windowFrame) + xoff;
1788 else
1789 topLeft.x = NSMinX (parentRect) + xoff;
1752 1790
1753 if (view != nil) 1791 if (f->size_hint_flags & YNegative)
1792 topLeft.y = NSMinY (parentRect) + NSHeight (windowFrame) - yoff;
1793 else
1794 topLeft.y = NSMaxY (parentRect) - yoff;
1795 }
1796 else
1754 { 1797 {
1755 if (FRAME_PARENT_FRAME (f) == NULL && screen) 1798 /* If there is no parent frame then just convert to screen
1756 { 1799 coordinates, UNLESS we have negative values, in which case I
1757 f->left_pos = f->size_hint_flags & XNegative 1800 think it's best to position from the bottom and right of the
1758 ? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f) 1801 current screen rather than the main screen or whole
1759 : f->left_pos; 1802 display. */
1760 /* We use visibleFrame here to take menu bar into account. 1803 NSRect screenFrame = [[[view window] screen] frame];
1761 Ideally we should also adjust left/top with visibleFrame.origin. */
1762
1763 f->top_pos = f->size_hint_flags & YNegative
1764 ? ([screen visibleFrame].size.height + f->top_pos
1765 - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f)
1766 - FRAME_TOOLBAR_HEIGHT (f))
1767 : f->top_pos;
1768#ifdef NS_IMPL_GNUSTEP
1769 if (f->left_pos < 100)
1770 f->left_pos = 100; /* don't overlap menu */
1771#endif
1772 }
1773 else if (FRAME_PARENT_FRAME (f) != NULL)
1774 {
1775 struct frame *parent = FRAME_PARENT_FRAME (f);
1776 1804
1777 /* On X negative values for child frames always result in 1805 if (f->size_hint_flags & XNegative)
1778 positioning relative to the bottom right corner of the 1806 topLeft.x = NSMaxX (screenFrame) - NSWidth (windowFrame) + xoff;
1779 parent frame. */ 1807 else
1780 if (f->left_pos < 0) 1808 topLeft.x = xoff;
1781 f->left_pos = FRAME_PIXEL_WIDTH (parent) - FRAME_PIXEL_WIDTH (f) + f->left_pos;
1782 1809
1783 if (f->top_pos < 0) 1810 if (f->size_hint_flags & YNegative)
1784 f->top_pos = FRAME_PIXEL_HEIGHT (parent) + FRAME_TOOLBAR_HEIGHT (parent) 1811 topLeft.y = NSMinY (screenFrame) + NSHeight (windowFrame) - yoff;
1785 - FRAME_PIXEL_HEIGHT (f) + f->top_pos; 1812 else
1786 } 1813 topLeft.y = NSMaxY ([[[NSScreen screens] objectAtIndex:0] frame]) - yoff;
1814
1815#ifdef NS_IMPL_GNUSTEP
1816 /* Don't overlap the menu.
1787 1817
1788 /* Constrain the setFrameTopLeftPoint so we don't move behind the 1818 FIXME: Surely there's a better way than just hardcoding 100
1789 menu bar. */ 1819 in here? */
1790 NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos 1820 boundsRect.origin.x = 100;
1791 + NS_PARENT_WINDOW_LEFT_POS (f)), 1821#endif
1792 SCREENMAXBOUND (NS_PARENT_WINDOW_TOP_POS (f)
1793 - f->top_pos));
1794 NSTRACE_POINT ("setFrameTopLeftPoint", pt);
1795 [[view window] setFrameTopLeftPoint: pt];
1796 f->size_hint_flags &= ~(XNegative|YNegative);
1797 } 1822 }
1798 1823
1824 NSTRACE_POINT ("setFrameTopLeftPoint", topLeft);
1825 [[view window] setFrameTopLeftPoint:topLeft];
1826 f->size_hint_flags &= ~(XNegative|YNegative);
1827
1799 unblock_input (); 1828 unblock_input ();
1800} 1829}
1801 1830
@@ -1862,9 +1891,16 @@ ns_set_window_size (struct frame *f,
1862 make_fixnum (FRAME_NS_TITLEBAR_HEIGHT (f)), 1891 make_fixnum (FRAME_NS_TITLEBAR_HEIGHT (f)),
1863 make_fixnum (FRAME_TOOLBAR_HEIGHT (f)))); 1892 make_fixnum (FRAME_TOOLBAR_HEIGHT (f))));
1864 1893
1865 [window setFrame: wr display: YES]; 1894 /* Usually it seems safe to delay changing the frame size, but when a
1895 series of actions are taken with no redisplay between them then we
1896 can end up using old values so don't delay here. */
1897 change_frame_size (f,
1898 FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth),
1899 FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight),
1900 0, NO, 0, 1);
1901
1902 [window setFrame:wr display:NO];
1866 1903
1867 [view updateFrameSize: NO];
1868 unblock_input (); 1904 unblock_input ();
1869} 1905}
1870 1906
@@ -1913,7 +1949,6 @@ ns_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
1913 so some key presses (TAB) are swallowed by the system. */ 1949 so some key presses (TAB) are swallowed by the system. */
1914 [window makeFirstResponder: view]; 1950 [window makeFirstResponder: view];
1915 1951
1916 [view updateFrameSize: NO];
1917 unblock_input (); 1952 unblock_input ();
1918 } 1953 }
1919} 1954}
@@ -5026,9 +5061,6 @@ ns_judge_scroll_bars (struct frame *f)
5026 if ([view judge]) 5061 if ([view judge])
5027 removed = YES; 5062 removed = YES;
5028 } 5063 }
5029
5030 if (removed)
5031 [eview updateFrameSize: NO];
5032} 5064}
5033 5065
5034/* ========================================================================== 5066/* ==========================================================================
@@ -6215,6 +6247,15 @@ not_in_argv (NSString *arg)
6215- (void)dealloc 6247- (void)dealloc
6216{ 6248{
6217 NSTRACE ("[EmacsView dealloc]"); 6249 NSTRACE ("[EmacsView dealloc]");
6250
6251 /* Clear the view resize notification. */
6252 [[NSNotificationCenter defaultCenter]
6253 removeObserver:self
6254 name:NSViewFrameDidChangeNotification
6255 object:nil];
6256
6257 CGContextRelease (drawingBuffer);
6258
6218 [toolbar release]; 6259 [toolbar release];
6219 if (fs_state == FULLSCREEN_BOTH) 6260 if (fs_state == FULLSCREEN_BOTH)
6220 [nonfs_window release]; 6261 [nonfs_window release];
@@ -7056,108 +7097,12 @@ not_in_argv (NSString *arg)
7056 return NO; 7097 return NO;
7057} 7098}
7058 7099
7059- (void) updateFrameSize: (BOOL) delay
7060{
7061 NSWindow *window = [self window];
7062 NSRect wr = [window frame];
7063 int extra = 0;
7064 int oldc = cols, oldr = rows;
7065 int oldw = FRAME_PIXEL_WIDTH (emacsframe);
7066 int oldh = FRAME_PIXEL_HEIGHT (emacsframe);
7067 int neww, newh;
7068
7069 NSTRACE ("[EmacsView updateFrameSize:]");
7070 NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh));
7071 NSTRACE_RECT ("Original frame", wr);
7072 NSTRACE_MSG ("Original columns: %d", cols);
7073 NSTRACE_MSG ("Original rows: %d", rows);
7074
7075 if (! [self isFullscreen])
7076 {
7077 int toolbar_height;
7078#ifdef NS_IMPL_GNUSTEP
7079 // GNUstep does not always update the tool bar height. Force it.
7080 if (toolbar && [toolbar isVisible])
7081 update_frame_tool_bar (emacsframe);
7082#endif
7083
7084 toolbar_height = FRAME_TOOLBAR_HEIGHT (emacsframe);
7085 if (toolbar_height < 0)
7086 toolbar_height = 35;
7087
7088 extra = FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
7089 + toolbar_height;
7090 }
7091
7092 if (wait_for_tool_bar)
7093 {
7094 /* The toolbar height is always 0 in fullscreen and undecorated
7095 frames, so don't wait for it to become available. */
7096 if (FRAME_TOOLBAR_HEIGHT (emacsframe) == 0
7097 && FRAME_UNDECORATED (emacsframe) == false
7098 && ! [self isFullscreen])
7099 {
7100 NSTRACE_MSG ("Waiting for toolbar");
7101 return;
7102 }
7103 wait_for_tool_bar = NO;
7104 }
7105
7106 neww = (int)wr.size.width - emacsframe->border_width;
7107 newh = (int)wr.size.height - extra;
7108
7109 NSTRACE_SIZE ("New size", NSMakeSize (neww, newh));
7110 NSTRACE_MSG ("FRAME_TOOLBAR_HEIGHT: %d", FRAME_TOOLBAR_HEIGHT (emacsframe));
7111 NSTRACE_MSG ("FRAME_NS_TITLEBAR_HEIGHT: %d", FRAME_NS_TITLEBAR_HEIGHT (emacsframe));
7112
7113 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, neww);
7114 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, newh);
7115
7116 if (cols < MINWIDTH)
7117 cols = MINWIDTH;
7118
7119 if (rows < MINHEIGHT)
7120 rows = MINHEIGHT;
7121
7122 NSTRACE_MSG ("New columns: %d", cols);
7123 NSTRACE_MSG ("New rows: %d", rows);
7124
7125 if (oldr != rows || oldc != cols || neww != oldw || newh != oldh)
7126 {
7127 NSView *view = FRAME_NS_VIEW (emacsframe);
7128
7129 change_frame_size (emacsframe,
7130 FRAME_PIXEL_TO_TEXT_WIDTH (emacsframe, neww),
7131 FRAME_PIXEL_TO_TEXT_HEIGHT (emacsframe, newh),
7132 0, delay, 0, 1);
7133 SET_FRAME_GARBAGED (emacsframe);
7134 cancel_mouse_face (emacsframe);
7135
7136 /* The next two lines set the frame to the same size as we've
7137 already set above. We need to do this when we switch back
7138 from non-native fullscreen, in other circumstances it appears
7139 to be a noop. (bug#28872) */
7140 wr = NSMakeRect (0, 0, neww, newh);
7141 [view setFrame: wr];
7142#ifdef NS_DRAW_TO_BUFFER
7143 [self createDrawingBuffer];
7144#endif
7145
7146 // To do: consider using [NSNotificationCenter postNotificationName:].
7147 [self windowDidMove: // Update top/left.
7148 [NSNotification notificationWithName:NSWindowDidMoveNotification
7149 object:[view window]]];
7150 }
7151 else
7152 {
7153 NSTRACE_MSG ("No change");
7154 }
7155}
7156 7100
7157- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize 7101- (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
7158/* Normalize frame to gridded text size. */ 7102/* Normalize frame to gridded text size. */
7159{ 7103{
7160 int extra = 0; 7104 int extra = 0;
7105 int cols, rows;
7161 7106
7162 NSTRACE ("[EmacsView windowWillResize:toSize: " NSTRACE_FMT_SIZE "]", 7107 NSTRACE ("[EmacsView windowWillResize:toSize: " NSTRACE_FMT_SIZE "]",
7163 NSTRACE_ARG_SIZE (frameSize)); 7108 NSTRACE_ARG_SIZE (frameSize));
@@ -7294,11 +7239,6 @@ not_in_argv (NSString *arg)
7294 sz = [self windowWillResize: theWindow toSize: sz]; 7239 sz = [self windowWillResize: theWindow toSize: sz];
7295#endif /* NS_IMPL_GNUSTEP */ 7240#endif /* NS_IMPL_GNUSTEP */
7296 7241
7297 if (cols > 0 && rows > 0)
7298 {
7299 [self updateFrameSize: YES];
7300 }
7301
7302 ns_send_appdefined (-1); 7242 ns_send_appdefined (-1);
7303} 7243}
7304 7244
@@ -7319,6 +7259,50 @@ not_in_argv (NSString *arg)
7319#endif /* NS_IMPL_COCOA */ 7259#endif /* NS_IMPL_COCOA */
7320 7260
7321 7261
7262- (void)viewDidResize:(NSNotification *)notification
7263{
7264 NSRect frame = [self frame];
7265 int oldw, oldh, neww, newh;
7266
7267 if (! FRAME_LIVE_P (emacsframe))
7268 return;
7269
7270#ifdef NS_DRAW_TO_BUFFER
7271 CGFloat scale = [[self window] backingScaleFactor];
7272 oldw = (CGFloat)CGBitmapContextGetWidth (drawingBuffer) / scale;
7273 oldh = (CGFloat)CGBitmapContextGetHeight (drawingBuffer) / scale;
7274#else
7275 oldw = FRAME_PIXEL_WIDTH (emacsframe);
7276 oldh = FRAME_PIXEL_HEIGHT (emacsframe);
7277#endif
7278 neww = (int)NSWidth (frame);
7279 newh = (int)NSHeight (frame);
7280
7281 NSTRACE ("[EmacsView viewDidResize]");
7282
7283 /* Don't want to do anything when the view size hasn't changed. */
7284 if ((oldh == newh && oldw == neww))
7285 {
7286 NSTRACE_MSG ("No change");
7287 return;
7288 }
7289
7290 NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh));
7291 NSTRACE_SIZE ("New size", NSMakeSize (neww, newh));
7292
7293 change_frame_size (emacsframe,
7294 FRAME_PIXEL_TO_TEXT_WIDTH (emacsframe, neww),
7295 FRAME_PIXEL_TO_TEXT_HEIGHT (emacsframe, newh),
7296 0, YES, 0, 1);
7297
7298#ifdef NS_DRAW_TO_BUFFER
7299 [self createDrawingBuffer];
7300#endif
7301 SET_FRAME_GARBAGED (emacsframe);
7302 cancel_mouse_face (emacsframe);
7303}
7304
7305
7322- (void)windowDidBecomeKey: (NSNotification *)notification 7306- (void)windowDidBecomeKey: (NSNotification *)notification
7323/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */ 7307/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
7324{ 7308{
@@ -7480,10 +7464,6 @@ not_in_argv (NSString *arg)
7480 maximizing_resize = NO; 7464 maximizing_resize = NO;
7481#endif 7465#endif
7482 7466
7483#ifdef NS_DRAW_TO_BUFFER
7484 [self createDrawingBuffer];
7485#endif
7486
7487 win = [[EmacsWindow alloc] 7467 win = [[EmacsWindow alloc]
7488 initWithContentRect: r 7468 initWithContentRect: r
7489 styleMask: (FRAME_UNDECORATED (f) 7469 styleMask: (FRAME_UNDECORATED (f)
@@ -7589,6 +7569,17 @@ not_in_argv (NSString *arg)
7589 [NSApp registerServicesMenuSendTypes: ns_send_types 7569 [NSApp registerServicesMenuSendTypes: ns_send_types
7590 returnTypes: [NSArray array]]; 7570 returnTypes: [NSArray array]];
7591 7571
7572#ifdef NS_DRAW_TO_BUFFER
7573 [self createDrawingBuffer];
7574#endif
7575
7576 /* Set up view resize notifications. */
7577 [self setPostsFrameChangedNotifications:YES];
7578 [[NSNotificationCenter defaultCenter]
7579 addObserver:self
7580 selector:@selector (viewDidResize:)
7581 name:NSViewFrameDidChangeNotification object:nil];
7582
7592 /* macOS Sierra automatically enables tabbed windows. We can't 7583 /* macOS Sierra automatically enables tabbed windows. We can't
7593 allow this to be enabled until it's available on a Free system. 7584 allow this to be enabled until it's available on a Free system.
7594 Currently it only happens by accident and is buggy anyway. */ 7585 Currently it only happens by accident and is buggy anyway. */
@@ -7618,9 +7609,8 @@ not_in_argv (NSString *arg)
7618 return; 7609 return;
7619 if (screen != nil) 7610 if (screen != nil)
7620 { 7611 {
7621 emacsframe->left_pos = r.origin.x - NS_PARENT_WINDOW_LEFT_POS (emacsframe); 7612 emacsframe->left_pos = NSMinX (r) - NS_PARENT_WINDOW_LEFT_POS (emacsframe);
7622 emacsframe->top_pos = 7613 emacsframe->top_pos = NS_PARENT_WINDOW_TOP_POS (emacsframe) - NSMaxY (r);
7623 NS_PARENT_WINDOW_TOP_POS (emacsframe) - (r.origin.y + r.size.height);
7624 7614
7625 // FIXME: after event part below didExitFullScreen is not received 7615 // FIXME: after event part below didExitFullScreen is not received
7626 // if (emacs_event) 7616 // if (emacs_event)
@@ -7919,7 +7909,6 @@ not_in_argv (NSString *arg)
7919 { 7909 {
7920 [toolbar setVisible:YES]; 7910 [toolbar setVisible:YES];
7921 update_frame_tool_bar (emacsframe); 7911 update_frame_tool_bar (emacsframe);
7922 [self updateFrameSize:YES];
7923 [[self window] display]; 7912 [[self window] display];
7924 } 7913 }
7925 else 7914 else
@@ -8132,11 +8121,11 @@ not_in_argv (NSString *arg)
8132 // send notifications. 8121 // send notifications.
8133 8122
8134 [self windowWillExitFullScreen]; 8123 [self windowWillExitFullScreen];
8135 [fw setFrame: [w frame] display:YES animate:ns_use_fullscreen_animation]; 8124 [fw setFrame:[[w contentView] frame]
8125 display:YES animate:ns_use_fullscreen_animation];
8136 [fw close]; 8126 [fw close];
8137 [w makeKeyAndOrderFront:NSApp]; 8127 [w makeKeyAndOrderFront:NSApp];
8138 [self windowDidExitFullScreen]; 8128 [self windowDidExitFullScreen];
8139 [self updateFrameSize:YES];
8140 } 8129 }
8141} 8130}
8142 8131
@@ -8645,13 +8634,6 @@ not_in_argv (NSString *arg)
8645} 8634}
8646 8635
8647 8636
8648- (void) setRows: (int) r andColumns: (int) c
8649{
8650 NSTRACE ("[EmacsView setRows:%d andColumns:%d]", r, c);
8651 rows = r;
8652 cols = c;
8653}
8654
8655- (int) fullscreenState 8637- (int) fullscreenState
8656{ 8638{
8657 return fs_state; 8639 return fs_state;