aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Third2018-01-03 13:45:03 +0000
committerAlan Third2018-01-06 23:10:21 +0000
commitf92264fc2acf3af3f98ebefa5ef0e1d4e9be4b80 (patch)
treedb53321c46261c705b9b914d42e38c9e74274ab9
parenta5f718c4c58c821fb121196a499df01391bb7ba4 (diff)
downloademacs-f92264fc2acf3af3f98ebefa5ef0e1d4e9be4b80.tar.gz
emacs-f92264fc2acf3af3f98ebefa5ef0e1d4e9be4b80.zip
Fix child frame placement issues (bug#29953)
* src/nsterm.h (NS_PARENT_WINDOW_LEFT_POS): (NS_PARENT_WINDOW_TOP_POS): Get the parent frame through the frame struct as invisible child windows are detached from their parents in NS. * src/nsterm.m (x_set_offset): Offscreen frames have `nil' screen value, so handle that gracefully. Child frames with negative left and top should be positioned relative to the bottom right of the parent frame.
-rw-r--r--src/nsterm.h6
-rw-r--r--src/nsterm.m46
2 files changed, 33 insertions, 19 deletions
diff --git a/src/nsterm.h b/src/nsterm.h
index c40ddf3284a..588b9fc6443 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1073,11 +1073,11 @@ struct x_output
1073 window or, if there is no parent window, the screen. */ 1073 window or, if there is no parent window, the screen. */
1074#define NS_PARENT_WINDOW_LEFT_POS(f) \ 1074#define NS_PARENT_WINDOW_LEFT_POS(f) \
1075 (FRAME_PARENT_FRAME (f) != NULL \ 1075 (FRAME_PARENT_FRAME (f) != NULL \
1076 ? [[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.x : 0) 1076 ? [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.x : 0)
1077#define NS_PARENT_WINDOW_TOP_POS(f) \ 1077#define NS_PARENT_WINDOW_TOP_POS(f) \
1078 (FRAME_PARENT_FRAME (f) != NULL \ 1078 (FRAME_PARENT_FRAME (f) != NULL \
1079 ? ([[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.y \ 1079 ? ([FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.y \
1080 + [[FRAME_NS_VIEW (f) window] parentWindow].frame.size.height \ 1080 + [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.size.height \
1081 - FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f))) \ 1081 - FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f))) \
1082 : [[[NSScreen screens] objectAtIndex: 0] frame].size.height) 1082 : [[[NSScreen screens] objectAtIndex: 0] frame].size.height)
1083 1083
diff --git a/src/nsterm.m b/src/nsterm.m
index 5798f4fd0b4..419a37033f7 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1736,7 +1736,6 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
1736{ 1736{
1737 NSView *view = FRAME_NS_VIEW (f); 1737 NSView *view = FRAME_NS_VIEW (f);
1738 NSArray *screens = [NSScreen screens]; 1738 NSArray *screens = [NSScreen screens];
1739 NSScreen *fscreen = [screens objectAtIndex: 0];
1740 NSScreen *screen = [[view window] screen]; 1739 NSScreen *screen = [[view window] screen];
1741 1740
1742 NSTRACE ("x_set_offset"); 1741 NSTRACE ("x_set_offset");
@@ -1746,26 +1745,41 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
1746 f->left_pos = xoff; 1745 f->left_pos = xoff;
1747 f->top_pos = yoff; 1746 f->top_pos = yoff;
1748 1747
1749 if (view != nil && screen && fscreen) 1748 if (view != nil)
1750 { 1749 {
1751 f->left_pos = f->size_hint_flags & XNegative 1750 if (FRAME_PARENT_FRAME (f) == NULL && screen)
1752 ? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f) 1751 {
1753 : f->left_pos; 1752 f->left_pos = f->size_hint_flags & XNegative
1754 /* We use visibleFrame here to take menu bar into account. 1753 ? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f)
1755 Ideally we should also adjust left/top with visibleFrame.origin. */ 1754 : f->left_pos;
1756 1755 /* We use visibleFrame here to take menu bar into account.
1757 f->top_pos = f->size_hint_flags & YNegative 1756 Ideally we should also adjust left/top with visibleFrame.origin. */
1758 ? ([screen visibleFrame].size.height + f->top_pos 1757
1759 - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f) 1758 f->top_pos = f->size_hint_flags & YNegative
1760 - FRAME_TOOLBAR_HEIGHT (f)) 1759 ? ([screen visibleFrame].size.height + f->top_pos
1761 : f->top_pos; 1760 - FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f)
1761 - FRAME_TOOLBAR_HEIGHT (f))
1762 : f->top_pos;
1762#ifdef NS_IMPL_GNUSTEP 1763#ifdef NS_IMPL_GNUSTEP
1763 if (FRAME_PARENT_FRAME (f) == NULL)
1764 {
1765 if (f->left_pos < 100) 1764 if (f->left_pos < 100)
1766 f->left_pos = 100; /* don't overlap menu */ 1765 f->left_pos = 100; /* don't overlap menu */
1767 }
1768#endif 1766#endif
1767 }
1768 else if (FRAME_PARENT_FRAME (f) != NULL)
1769 {
1770 struct frame *parent = FRAME_PARENT_FRAME (f);
1771
1772 /* On X negative values for child frames always result in
1773 positioning relative to the bottom right corner of the
1774 parent frame. */
1775 if (f->left_pos < 0)
1776 f->left_pos = FRAME_PIXEL_WIDTH (parent) - FRAME_PIXEL_WIDTH (f) + f->left_pos;
1777
1778 if (f->top_pos < 0)
1779 f->top_pos = FRAME_PIXEL_HEIGHT (parent) + FRAME_TOOLBAR_HEIGHT (parent)
1780 - FRAME_PIXEL_HEIGHT (f) + f->top_pos;
1781 }
1782
1769 /* Constrain the setFrameTopLeftPoint so we don't move behind the 1783 /* Constrain the setFrameTopLeftPoint so we don't move behind the
1770 menu bar. */ 1784 menu bar. */
1771 NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos 1785 NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos