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.
This commit is contained in:
parent
a5f718c4c5
commit
f92264fc2a
2 changed files with 32 additions and 18 deletions
|
@ -1073,11 +1073,11 @@ struct x_output
|
||||||
window or, if there is no parent window, the screen. */
|
window or, if there is no parent window, the screen. */
|
||||||
#define NS_PARENT_WINDOW_LEFT_POS(f) \
|
#define NS_PARENT_WINDOW_LEFT_POS(f) \
|
||||||
(FRAME_PARENT_FRAME (f) != NULL \
|
(FRAME_PARENT_FRAME (f) != NULL \
|
||||||
? [[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.x : 0)
|
? [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.x : 0)
|
||||||
#define NS_PARENT_WINDOW_TOP_POS(f) \
|
#define NS_PARENT_WINDOW_TOP_POS(f) \
|
||||||
(FRAME_PARENT_FRAME (f) != NULL \
|
(FRAME_PARENT_FRAME (f) != NULL \
|
||||||
? ([[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.y \
|
? ([FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.origin.y \
|
||||||
+ [[FRAME_NS_VIEW (f) window] parentWindow].frame.size.height \
|
+ [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window].frame.size.height \
|
||||||
- FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f))) \
|
- FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f))) \
|
||||||
: [[[NSScreen screens] objectAtIndex: 0] frame].size.height)
|
: [[[NSScreen screens] objectAtIndex: 0] frame].size.height)
|
||||||
|
|
||||||
|
|
44
src/nsterm.m
44
src/nsterm.m
|
@ -1736,7 +1736,6 @@ -(void)remove
|
||||||
{
|
{
|
||||||
NSView *view = FRAME_NS_VIEW (f);
|
NSView *view = FRAME_NS_VIEW (f);
|
||||||
NSArray *screens = [NSScreen screens];
|
NSArray *screens = [NSScreen screens];
|
||||||
NSScreen *fscreen = [screens objectAtIndex: 0];
|
|
||||||
NSScreen *screen = [[view window] screen];
|
NSScreen *screen = [[view window] screen];
|
||||||
|
|
||||||
NSTRACE ("x_set_offset");
|
NSTRACE ("x_set_offset");
|
||||||
|
@ -1746,26 +1745,41 @@ -(void)remove
|
||||||
f->left_pos = xoff;
|
f->left_pos = xoff;
|
||||||
f->top_pos = yoff;
|
f->top_pos = yoff;
|
||||||
|
|
||||||
if (view != nil && screen && fscreen)
|
if (view != nil)
|
||||||
{
|
{
|
||||||
f->left_pos = f->size_hint_flags & XNegative
|
if (FRAME_PARENT_FRAME (f) == NULL && screen)
|
||||||
? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f)
|
{
|
||||||
: f->left_pos;
|
f->left_pos = f->size_hint_flags & XNegative
|
||||||
/* We use visibleFrame here to take menu bar into account.
|
? [screen visibleFrame].size.width + f->left_pos - FRAME_PIXEL_WIDTH (f)
|
||||||
Ideally we should also adjust left/top with visibleFrame.origin. */
|
: f->left_pos;
|
||||||
|
/* We use visibleFrame here to take menu bar into account.
|
||||||
|
Ideally we should also adjust left/top with visibleFrame.origin. */
|
||||||
|
|
||||||
f->top_pos = f->size_hint_flags & YNegative
|
f->top_pos = f->size_hint_flags & YNegative
|
||||||
? ([screen visibleFrame].size.height + f->top_pos
|
? ([screen visibleFrame].size.height + f->top_pos
|
||||||
- FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f)
|
- FRAME_PIXEL_HEIGHT (f) - FRAME_NS_TITLEBAR_HEIGHT (f)
|
||||||
- FRAME_TOOLBAR_HEIGHT (f))
|
- FRAME_TOOLBAR_HEIGHT (f))
|
||||||
: f->top_pos;
|
: f->top_pos;
|
||||||
#ifdef NS_IMPL_GNUSTEP
|
#ifdef NS_IMPL_GNUSTEP
|
||||||
if (FRAME_PARENT_FRAME (f) == NULL)
|
|
||||||
{
|
|
||||||
if (f->left_pos < 100)
|
if (f->left_pos < 100)
|
||||||
f->left_pos = 100; /* don't overlap menu */
|
f->left_pos = 100; /* don't overlap menu */
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else if (FRAME_PARENT_FRAME (f) != NULL)
|
||||||
|
{
|
||||||
|
struct frame *parent = FRAME_PARENT_FRAME (f);
|
||||||
|
|
||||||
|
/* On X negative values for child frames always result in
|
||||||
|
positioning relative to the bottom right corner of the
|
||||||
|
parent frame. */
|
||||||
|
if (f->left_pos < 0)
|
||||||
|
f->left_pos = FRAME_PIXEL_WIDTH (parent) - FRAME_PIXEL_WIDTH (f) + f->left_pos;
|
||||||
|
|
||||||
|
if (f->top_pos < 0)
|
||||||
|
f->top_pos = FRAME_PIXEL_HEIGHT (parent) + FRAME_TOOLBAR_HEIGHT (parent)
|
||||||
|
- FRAME_PIXEL_HEIGHT (f) + f->top_pos;
|
||||||
|
}
|
||||||
|
|
||||||
/* Constrain the setFrameTopLeftPoint so we don't move behind the
|
/* Constrain the setFrameTopLeftPoint so we don't move behind the
|
||||||
menu bar. */
|
menu bar. */
|
||||||
NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos
|
NSPoint pt = NSMakePoint (SCREENMAXBOUND (f->left_pos
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue