winemac: Add function macdrv_set_view_superview().

This allows for nesting views in a hierarchy rather than only ever adding them
as direct subviews of the window content view.  This functionality will be used
in subsequent commits.

This takes over some of the functionality of macdrv_set_view_window_and_frame(),
which will be removed in a subsequent commit.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2016-05-12 18:50:40 -05:00 committed by Alexandre Julliard
parent 742734b44f
commit 8223756ba4
3 changed files with 55 additions and 1 deletions

View file

@ -3322,6 +3322,58 @@ void macdrv_set_view_window_and_frame(macdrv_view v, macdrv_window w, CGRect rec
[pool release];
}
/***********************************************************************
* macdrv_set_view_superview
*
* Move a view to a new superview and position it relative to its
* siblings. If p is non-NULL, the view is ordered behind it.
* Otherwise, the view is ordered above n. If s is NULL, use the
* content view of w as the new superview.
*/
void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, macdrv_view p, macdrv_view n)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
WineContentView* view = (WineContentView*)v;
WineContentView* superview = (WineContentView*)s;
WineWindow* window = (WineWindow*)w;
WineContentView* prev = (WineContentView*)p;
WineContentView* next = (WineContentView*)n;
if (!superview)
superview = [window contentView];
OnMainThread(^{
if (superview == [view superview])
{
NSArray* subviews = [superview subviews];
NSUInteger index = [subviews indexOfObjectIdenticalTo:view];
if (!prev && !next && index == 0)
return;
if (prev && index > 0 && [subviews objectAtIndex:index - 1] == prev)
return;
if (!prev && next && index + 1 < [subviews count] && [subviews objectAtIndex:index + 1] == next)
return;
}
WineWindow* oldWindow = (WineWindow*)[view window];
WineWindow* newWindow = (WineWindow*)[superview window];
[view removeFromSuperview];
if (prev)
[superview addSubview:view positioned:NSWindowBelow relativeTo:prev];
else
[superview addSubview:view positioned:NSWindowAbove relativeTo:next];
if (oldWindow != newWindow)
{
[oldWindow updateForGLSubviews];
[newWindow updateForGLSubviews];
}
});
[pool release];
}
/***********************************************************************
* macdrv_add_view_opengl_context
*

View file

@ -514,6 +514,7 @@ extern void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat
extern macdrv_view macdrv_create_view(macdrv_window w, CGRect rect) DECLSPEC_HIDDEN;
extern void macdrv_dispose_view(macdrv_view v) DECLSPEC_HIDDEN;
extern void macdrv_set_view_window_and_frame(macdrv_view v, macdrv_window w, CGRect rect) DECLSPEC_HIDDEN;
extern void macdrv_set_view_superview(macdrv_view v, macdrv_view s, macdrv_window w, macdrv_view p, macdrv_view n) DECLSPEC_HIDDEN;
extern void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
extern void macdrv_remove_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
extern int macdrv_get_view_backing_size(macdrv_view v, int backing_size[2]) DECLSPEC_HIDDEN;

View file

@ -1735,7 +1735,8 @@ void set_gl_view_parent(HWND hwnd, HWND parent)
return;
}
macdrv_set_view_window_and_frame(data->gl_view, cocoa_window, cgrect_from_rect(data->gl_rect));
macdrv_set_view_superview(data->gl_view, NULL, cocoa_window, NULL, NULL);
macdrv_set_view_window_and_frame(data->gl_view, NULL, cgrect_from_rect(data->gl_rect));
mark_contexts_for_moved_view(data->gl_view);
}