Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_window.c
| Show First 20 Lines • Show All 424 Lines • ▼ Show 20 Lines | void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) | ||||
| if (win->parent == NULL && win_other == NULL) { | if (win->parent == NULL && win_other == NULL) { | ||||
| wm_quit_with_optional_confirmation_prompt(C, win); | wm_quit_with_optional_confirmation_prompt(C, win); | ||||
| return; | return; | ||||
| } | } | ||||
| /* Close child windows and bring windows back to front that dialogs have pushed behind the main | /* Close child windows and bring windows back to front that dialogs have pushed behind the main | ||||
| * window. */ | * window. */ | ||||
| for (wmWindow *iter_win = wm->windows.first; iter_win; iter_win = iter_win->next) { | LISTBASE_FOREACH (wmWindow *, iter_win, &wm->windows) { | ||||
| if (iter_win->parent == win) { | if (iter_win->parent == win) { | ||||
| wm_window_close(C, wm, iter_win); | wm_window_close(C, wm, iter_win); | ||||
| } | } | ||||
| else { | else { | ||||
| if (G.background == false) { | if (G.background == false) { | ||||
| if (is_dialog && iter_win != win && iter_win->parent && | if (is_dialog && iter_win != win && iter_win->parent && | ||||
| (GHOST_GetWindowState(iter_win->ghostwin) != GHOST_kWindowStateMinimized)) { | (GHOST_GetWindowState(iter_win->ghostwin) != GHOST_kWindowStateMinimized)) { | ||||
| wm_window_raise(iter_win); | wm_window_raise(iter_win); | ||||
| ▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | #ifdef WITH_X11 /* X11 */ | ||||
| /* pad */ | /* pad */ | ||||
| wm_init_state.start_x = WM_WIN_INIT_PAD; | wm_init_state.start_x = WM_WIN_INIT_PAD; | ||||
| wm_init_state.start_y = WM_WIN_INIT_PAD; | wm_init_state.start_y = WM_WIN_INIT_PAD; | ||||
| wm_init_state.size_x -= WM_WIN_INIT_PAD * 2; | wm_init_state.size_x -= WM_WIN_INIT_PAD * 2; | ||||
| wm_init_state.size_y -= WM_WIN_INIT_PAD * 2; | wm_init_state.size_y -= WM_WIN_INIT_PAD * 2; | ||||
| #endif | #endif | ||||
| } | } | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| wm_window_ghostwindow_ensure(wm, win, false); | wm_window_ghostwindow_ensure(wm, win, false); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Call after #wm_window_ghostwindows_ensure or #WM_check | * Call after #wm_window_ghostwindows_ensure or #WM_check | ||||
| * (after loading a new file) in the unlikely event a window couldn't be created. | * (after loading a new file) in the unlikely event a window couldn't be created. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 1,371 Lines • ▼ Show 20 Lines | |||||
| void WM_window_screen_rect_calc(const wmWindow *win, rcti *r_rect) | void WM_window_screen_rect_calc(const wmWindow *win, rcti *r_rect) | ||||
| { | { | ||||
| rcti window_rect, screen_rect; | rcti window_rect, screen_rect; | ||||
| WM_window_rect_calc(win, &window_rect); | WM_window_rect_calc(win, &window_rect); | ||||
| screen_rect = window_rect; | screen_rect = window_rect; | ||||
| /* Subtract global areas from screen rectangle. */ | /* Subtract global areas from screen rectangle. */ | ||||
| for (ScrArea *global_area = win->global_areas.areabase.first; global_area; | LISTBASE_FOREACH (ScrArea *, global_area, &win->global_areas.areabase) { | ||||
| global_area = global_area->next) { | |||||
| int height = ED_area_global_size_y(global_area) - 1; | int height = ED_area_global_size_y(global_area) - 1; | ||||
| if (global_area->global->flag & GLOBAL_AREA_IS_HIDDEN) { | if (global_area->global->flag & GLOBAL_AREA_IS_HIDDEN) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| switch (global_area->global->align) { | switch (global_area->global->align) { | ||||
| case GLOBAL_AREA_ALIGN_TOP: | case GLOBAL_AREA_ALIGN_TOP: | ||||
| Show All 31 Lines | |||||
| /** | /** | ||||
| * Some editor data may need to be synced with scene data (3D View camera and layers). | * Some editor data may need to be synced with scene data (3D View camera and layers). | ||||
| * This function ensures data is synced for editors | * This function ensures data is synced for editors | ||||
| * in visible workspaces and their visible layouts. | * in visible workspaces and their visible layouts. | ||||
| */ | */ | ||||
| void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene) | void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene) | ||||
| { | { | ||||
| for (wmWindow *win = win_lb->first; win; win = win->next) { | LISTBASE_FOREACH (wmWindow *, win, win_lb) { | ||||
| if (WM_window_get_active_scene(win) == scene) { | if (WM_window_get_active_scene(win) == scene) { | ||||
| ED_workspace_scene_data_sync(win->workspace_hook, scene); | ED_workspace_scene_data_sync(win->workspace_hook, scene); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Scene *WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen *screen) | Scene *WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen *screen) | ||||
| { | { | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| if (WM_window_get_active_screen(win) == screen) { | if (WM_window_get_active_screen(win) == screen) { | ||||
| return WM_window_get_active_scene(win); | return WM_window_get_active_scene(win); | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const bScreen *screen) | WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const bScreen *screen) | ||||
| { | { | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| if (WM_window_get_active_screen(win) == screen) { | if (WM_window_get_active_screen(win) == screen) { | ||||
| return WM_window_get_active_workspace(win); | return WM_window_get_active_workspace(win); | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| Scene *WM_window_get_active_scene(const wmWindow *win) | Scene *WM_window_get_active_scene(const wmWindow *win) | ||||
| Show All 11 Lines | void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene) | ||||
| bool changed = false; | bool changed = false; | ||||
| /* Set scene in parent and its child windows. */ | /* Set scene in parent and its child windows. */ | ||||
| if (win_parent->scene != scene) { | if (win_parent->scene != scene) { | ||||
| ED_screen_scene_change(C, win_parent, scene); | ED_screen_scene_change(C, win_parent, scene); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { | LISTBASE_FOREACH (wmWindow *, win_child, &wm->windows) { | ||||
| if (win_child->parent == win_parent && win_child->scene != scene) { | if (win_child->parent == win_parent && win_child->scene != scene) { | ||||
| ED_screen_scene_change(C, win_child, scene); | ED_screen_scene_change(C, win_child, scene); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| /* Update depsgraph and renderers for scene change. */ | /* Update depsgraph and renderers for scene change. */ | ||||
| Show All 29 Lines | |||||
| { | { | ||||
| BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != NULL); | BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != NULL); | ||||
| Main *bmain = G_MAIN; | Main *bmain = G_MAIN; | ||||
| wmWindowManager *wm = bmain->wm.first; | wmWindowManager *wm = bmain->wm.first; | ||||
| wmWindow *win_parent = (win->parent) ? win->parent : win; | wmWindow *win_parent = (win->parent) ? win->parent : win; | ||||
| /* Set view layer in parent and child windows. */ | /* Set view layer in parent and child windows. */ | ||||
| for (wmWindow *win_iter = wm->windows.first; win_iter; win_iter = win_iter->next) { | LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) { | ||||
| if ((win_iter == win_parent) || (win_iter->parent == win_parent)) { | if ((win_iter == win_parent) || (win_iter->parent == win_parent)) { | ||||
| STRNCPY(win_iter->view_layer_name, view_layer->name); | STRNCPY(win_iter->view_layer_name, view_layer->name); | ||||
| bScreen *screen = BKE_workspace_active_screen_get(win_iter->workspace_hook); | bScreen *screen = BKE_workspace_active_screen_get(win_iter->workspace_hook); | ||||
| ED_render_view_layer_changed(bmain, screen); | ED_render_view_layer_changed(bmain, screen); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 15 Lines | |||||
| void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *workspace) | void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *workspace) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *win_parent = (win->parent) ? win->parent : win; | wmWindow *win_parent = (win->parent) ? win->parent : win; | ||||
| ED_workspace_change(workspace, C, wm, win); | ED_workspace_change(workspace, C, wm, win); | ||||
| for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) { | LISTBASE_FOREACH (wmWindow *, win_child, &wm->windows) { | ||||
| if (win_child->parent == win_parent) { | if (win_child->parent == win_parent) { | ||||
| bScreen *screen = WM_window_get_active_screen(win_child); | bScreen *screen = WM_window_get_active_screen(win_child); | ||||
| /* Don't change temporary screens, they only serve a single purpose. */ | /* Don't change temporary screens, they only serve a single purpose. */ | ||||
| if (screen->temp) { | if (screen->temp) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ED_workspace_change(workspace, C, wm, win_child); | ED_workspace_change(workspace, C, wm, win_child); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines | |||||