Beispiel #1
0
static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
{
	wmWindowManager *oldwm, *wm;
	wmWindow *oldwin, *win;
	
	/* cases 1 and 2 */
	if(oldwmlist->first==NULL) {
		if(G.main->wm.first); /* nothing todo */
		else
			wm_add_default(C);
	}
	else {
		/* cases 3 and 4 */
		
		/* we've read file without wm..., keep current one entirely alive */
		if(G.main->wm.first==NULL) {
			bScreen *screen= CTX_wm_screen(C);
			
			/* match oldwm to new dbase, only old files */
			
			for(wm= oldwmlist->first; wm; wm= wm->id.next) {
				
				for(win= wm->windows.first; win; win= win->next) {
					/* all windows get active screen from file */
					if(screen->winid==0)
						win->screen= screen;
					else 
						win->screen= ED_screen_duplicate(win, screen);
					
					BLI_strncpy(win->screenname, win->screen->id.name+2, 21);
					win->screen->winid= win->winid;
				}
			}
			
			G.main->wm= *oldwmlist;
			
			/* screens were read from file! */
			ED_screens_initialize(G.main->wm.first);
		}
		else {
			/* what if old was 3, and loaded 1? */
			/* this code could move to setup_appdata */
			oldwm= oldwmlist->first;
			wm= G.main->wm.first;

			/* ensure making new keymaps and set space types */
			wm->initialized= 0;
			wm->winactive= NULL;
			
			/* only first wm in list has ghostwins */
			for(win= wm->windows.first; win; win= win->next) {
				for(oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) {
					
					if(oldwin->winid == win->winid ) {
						win->ghostwin= oldwin->ghostwin;
						win->active= oldwin->active;
						if(win->active)
							wm->winactive= win;

						GHOST_SetWindowUserData(win->ghostwin, win);	/* pointer back */
						oldwin->ghostwin= NULL;
						
						win->eventstate= oldwin->eventstate;
						oldwin->eventstate= NULL;
						
						/* ensure proper screen rescaling */
						win->sizex= oldwin->sizex;
						win->sizey= oldwin->sizey;
						win->posx= oldwin->posx;
						win->posy= oldwin->posy;
					}
				}
			}
			wm_close_and_free_all(C, oldwmlist);
		}
	}
}
Beispiel #2
0
static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
{
	wmWindowManager *oldwm, *wm;
	wmWindow *oldwin, *win;
	
	/* cases 1 and 2 */
	if (BLI_listbase_is_empty(oldwmlist)) {
		if (G.main->wm.first) {
			/* nothing todo */
		}
		else {
			wm_add_default(C);
		}
	}
	else {
		/* cases 3 and 4 */
		
		/* we've read file without wm..., keep current one entirely alive */
		if (BLI_listbase_is_empty(&G.main->wm)) {
			bScreen *screen = NULL;

			/* when loading without UI, no matching needed */
			if (!(G.fileflags & G_FILE_NO_UI) && (screen = CTX_wm_screen(C))) {

				/* match oldwm to new dbase, only old files */
				for (wm = oldwmlist->first; wm; wm = wm->id.next) {
					
					for (win = wm->windows.first; win; win = win->next) {
						/* all windows get active screen from file */
						if (screen->winid == 0)
							win->screen = screen;
						else 
							win->screen = ED_screen_duplicate(win, screen);
						
						BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
						win->screen->winid = win->winid;
					}
				}
			}
			
			G.main->wm = *oldwmlist;
			
			/* screens were read from file! */
			ED_screens_initialize(G.main->wm.first);
		}
		else {
			bool has_match = false;

			/* what if old was 3, and loaded 1? */
			/* this code could move to setup_appdata */
			oldwm = oldwmlist->first;
			wm = G.main->wm.first;

			/* preserve key configurations in new wm, to preserve their keymaps */
			wm->keyconfigs = oldwm->keyconfigs;
			wm->addonconf = oldwm->addonconf;
			wm->defaultconf = oldwm->defaultconf;
			wm->userconf = oldwm->userconf;

			BLI_listbase_clear(&oldwm->keyconfigs);
			oldwm->addonconf = NULL;
			oldwm->defaultconf = NULL;
			oldwm->userconf = NULL;

			/* ensure making new keymaps and set space types */
			wm->initialized = 0;
			wm->winactive = NULL;

			/* only first wm in list has ghostwins */
			for (win = wm->windows.first; win; win = win->next) {
				for (oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {

					if (oldwin->winid == win->winid) {
						has_match = true;

						wm_window_substitute_old(wm, oldwin, win);
					}
				}
			}

			/* make sure at least one window is kept open so we don't lose the context, check T42303 */
			if (!has_match) {
				oldwin = oldwm->windows.first;
				win = wm->windows.first;

				wm_window_substitute_old(wm, oldwin, win);
			}

			wm_close_and_free_all(C, oldwmlist);
		}
	}
}
Beispiel #3
0
static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
{
	wmWindowManager *oldwm, *wm;
	wmWindow *oldwin, *win;
	
	/* cases 1 and 2 */
	if (oldwmlist->first == NULL) {
		if (G.main->wm.first) {
			/* nothing todo */
		}
		else {
			wm_add_default(C);
		}
	}
	else {
		/* cases 3 and 4 */
		
		/* we've read file without wm..., keep current one entirely alive */
		if (G.main->wm.first == NULL) {
			bScreen *screen = NULL;

			/* when loading without UI, no matching needed */
			if (!(G.fileflags & G_FILE_NO_UI) && (screen = CTX_wm_screen(C))) {

				/* match oldwm to new dbase, only old files */
				for (wm = oldwmlist->first; wm; wm = wm->id.next) {
					
					for (win = wm->windows.first; win; win = win->next) {
						/* all windows get active screen from file */
						if (screen->winid == 0)
							win->screen = screen;
						else 
							win->screen = ED_screen_duplicate(win, screen);
						
						BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
						win->screen->winid = win->winid;
					}
				}
			}
			
			G.main->wm = *oldwmlist;
			
			/* screens were read from file! */
			ED_screens_initialize(G.main->wm.first);
		}
		else {
			/* what if old was 3, and loaded 1? */
			/* this code could move to setup_appdata */
			oldwm = oldwmlist->first;
			wm = G.main->wm.first;

			/* preserve key configurations in new wm, to preserve their keymaps */
			wm->keyconfigs = oldwm->keyconfigs;
			wm->addonconf = oldwm->addonconf;
			wm->defaultconf = oldwm->defaultconf;
			wm->userconf = oldwm->userconf;

			oldwm->keyconfigs.first = oldwm->keyconfigs.last = NULL;
			oldwm->addonconf = NULL;
			oldwm->defaultconf = NULL;
			oldwm->userconf = NULL;

			/* ensure making new keymaps and set space types */
			wm->initialized = 0;
			wm->winactive = NULL;
			
			/* only first wm in list has ghostwins */
			for (win = wm->windows.first; win; win = win->next) {
				for (oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {
					
					if (oldwin->winid == win->winid) {
						win->ghostwin = oldwin->ghostwin;
						win->active = oldwin->active;
						if (win->active)
							wm->winactive = win;

						if (!G.background) /* file loading in background mode still calls this */
							GHOST_SetWindowUserData(win->ghostwin, win);    /* pointer back */

						oldwin->ghostwin = NULL;
						
						win->eventstate = oldwin->eventstate;
						oldwin->eventstate = NULL;
						
						/* ensure proper screen rescaling */
						win->sizex = oldwin->sizex;
						win->sizey = oldwin->sizey;
						win->posx = oldwin->posx;
						win->posy = oldwin->posy;
					}
				}
			}
			wm_close_and_free_all(C, oldwmlist);
		}
	}
}