Module: wine Branch: master Commit: 8223756ba4f41f4c662a36af71c984e4415a6332 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8223756ba4f41f4c662a36af71...
Author: Ken Thomases ken@codeweavers.com Date: Thu May 12 18:50:40 2016 -0500
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
---
dlls/winemac.drv/cocoa_window.m | 52 +++++++++++++++++++++++++++++++++++++++++ dlls/winemac.drv/macdrv_cocoa.h | 1 + dlls/winemac.drv/opengl.c | 3 ++- 3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index ec5eb2b..7aba872 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -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. diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 2c06bea..6e70d6d 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -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; diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index fbdc645..0039f0a 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -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); }