Commit 8223756b authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

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: 's avatarKen Thomases <ken@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 742734b4
......@@ -3323,6 +3323,58 @@ void macdrv_set_view_window_and_frame(macdrv_view v, macdrv_window w, CGRect rec
}
/***********************************************************************
* 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
*
* Add an OpenGL context to the list being tracked for each view.
......
......@@ -514,6 +514,7 @@ extern void macdrv_set_window_min_max_sizes(macdrv_window w, CGSize min_size, CG
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;
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment