From 962f764d58847614d083dc382285d997652d6992 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Jun 2015 01:25:34 +1000 Subject: WM: refactor window code for stereo3d Window copy code made it hard to test fixes. --- source/blender/windowmanager/intern/wm_stereo.c | 34 ++++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_stereo.c') diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index 60863515dd1..3f80570dd7b 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -448,9 +448,10 @@ static void wm_stereo3d_set_init(bContext *C, wmOperator *op) int wm_stereo3d_set_exec(bContext *C, wmOperator *op) { wmWindowManager *wm = CTX_wm_manager(C); - wmWindow *win = CTX_wm_window(C); - const bool is_fullscreen = WM_window_is_fullscreen(win); - char prev_display_mode = win->stereo3d_format->display_mode; + wmWindow *win_src = CTX_wm_window(C); + wmWindow *win_dst = NULL; + const bool is_fullscreen = WM_window_is_fullscreen(win_src); + char prev_display_mode = win_src->stereo3d_format->display_mode; Stereo3dData *s3dd; bool ok = true; @@ -464,14 +465,14 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op) } s3dd = op->customdata; - *win->stereo3d_format = s3dd->stereo3d_format; + *win_src->stereo3d_format = s3dd->stereo3d_format; if (prev_display_mode == S3D_DISPLAY_PAGEFLIP && - prev_display_mode != win->stereo3d_format->display_mode) + prev_display_mode != win_src->stereo3d_format->display_mode) { /* in case the hardward supports pageflip but not the display */ - if (wm_window_duplicate_exec(C, op) == OPERATOR_FINISHED) { - wm_window_close(C, wm, win); + if ((win_dst = wm_window_copy_test(C, win_src))) { + /* pass */ } else { BKE_report(op->reports, RPT_ERROR, @@ -479,23 +480,22 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op) ok = false; } } - else if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) { + else if (win_src->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) { /* pageflip requires a new window to be created with the proper OS flags */ - if (wm_window_duplicate_exec(C, op) == OPERATOR_FINISHED) { + if ((win_dst = wm_window_copy_test(C, win_src))) { if (wm_stereo3d_quadbuffer_supported()) { - wm_window_close(C, wm, win); BKE_report(op->reports, RPT_INFO, "Quad-buffer window successfully created"); } else { - wmWindow *win_new = wm->windows.last; - wm_window_close(C, wm, win_new); - win->stereo3d_format->display_mode = prev_display_mode; + wm_window_close(C, wm, win_dst); + win_dst = NULL; + win_src->stereo3d_format->display_mode = prev_display_mode; BKE_report(op->reports, RPT_ERROR, "Quad-buffer not supported by the system"); ok = false; } } else { - win->stereo3d_format->display_mode = prev_display_mode; + win_src->stereo3d_format->display_mode = prev_display_mode; BKE_report(op->reports, RPT_ERROR, "Failed to create a window compatible with the time sequential display method"); ok = false; @@ -511,12 +511,16 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op) MEM_freeN(op->customdata); if (ok) { + if (win_dst) { + wm_window_close(C, wm, win_src); + } + WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_FINISHED; } else { /* without this, the popup won't be freed freed properly T44688 */ - CTX_wm_window_set(C, win); + CTX_wm_window_set(C, win_src); return OPERATOR_CANCELLED; } } -- cgit v1.2.3