/* belongs to below */ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; int scr_w, scr_h, posy; wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); #if defined(__APPLE__) && !defined(GHOST_COCOA) { extern int macPrefState; /* creator.c */ initial_state += macPrefState; } #endif /* Disable AA for now, as GL_SELECT (used for border, lasso, ... select) * doesn't work well when AA is initialized, even if not used. */ ghostwin = GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, (GHOST_TWindowState)win->windowstate, GHOST_kDrawingContextTypeOpenGL, 0 /* no stereo */, 0 /* no AA */); if (ghostwin) { /* needed so we can detect the graphics card below */ GPU_extensions_init(); /* set the state*/ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } wm_window_swap_buffers(win); //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); /* standard state vars for window */ glEnable(GL_SCISSOR_TEST); GPU_state_init(); } }
LoggerWindow *loggerwindow_new(MultiTestApp *app) { GHOST_SystemHandle sys= multitestapp_get_system(app); GHOST_TUns32 screensize[2]; GHOST_WindowHandle win; GHOST_GetMainDisplayDimensions(sys, &screensize[0], &screensize[1]); win= GHOST_CreateWindow(sys, "MultiTest:Logger", 40, screensize[1]-432, 800, 300, GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL, FALSE, FALSE); if (win) { LoggerWindow *lw= MEM_callocN(sizeof(*lw), "loggerwindow_new"); int bbox[2][2]; lw->app= app; lw->win= win; #ifdef USE_BMF lw->font= BMF_GetFont(BMF_kScreen12); lw->fonttexid= BMF_GetFontTexture(lw->font); BMF_GetBoundingBox(lw->font, &bbox[0][0], &bbox[0][1], &bbox[1][0], &bbox[1][1]); lw->fontheight= rect_height(bbox); #else lw->font= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); BLF_size(lw->font, 11, 72); lw->fontheight= BLF_height(lw->font, "A_"); #endif lw->nloglines= lw->logsize= 0; lw->loglines= MEM_mallocN(sizeof(*lw->loglines)*lw->nloglines, "loglines"); lw->scroll= scrollbar_new(2, 40); GHOST_SetWindowUserData(lw->win, windowdata_new(lw, loggerwindow_handle)); loggerwindow_do_reshape(lw); return lw; } else { return NULL; } }
ExtraWindow *extrawindow_new(MultiTestApp *app) { GHOST_SystemHandle sys= multitestapp_get_system(app); GHOST_WindowHandle win; win= GHOST_CreateWindow(sys, "MultiTest:Extra", 500, 40, 400, 400, GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL, FALSE); if (win) { ExtraWindow *ew= MEM_callocN(sizeof(*ew), "mainwindow_new"); ew->app= app; ew->win= win; GHOST_SetWindowUserData(ew->win, windowdata_new(ew, extrawindow_handle)); return ew; } else { return NULL; } }
static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWindow *win) { 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; }
MainWindow *mainwindow_new(MultiTestApp *app) { GHOST_SystemHandle sys= multitestapp_get_system(app); GHOST_WindowHandle win; win= GHOST_CreateWindow(sys, "MultiTest:Main", 40, 40, 400, 400, GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL, FALSE); if (win) { MainWindow *mw= MEM_callocN(sizeof(*mw), "mainwindow_new"); mw->app= app; mw->win= win; GHOST_SetWindowUserData(mw->win, windowdata_new(mw, mainwindow_handle)); GHOST_InstallTimer(sys, 1000, 10000, mainwindow_timer_proc, mw); return mw; } else { return NULL; } }
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); } } }
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); } } }
/* belongs to below */ static void wm_window_add_ghostwindow(wmWindowManager *wm, const char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; GHOST_GLSettings glSettings = {0}; static int multisamples = -1; int scr_w, scr_h, posy; /* force setting multisamples only once, it requires restart - and you cannot * mix it, either all windows have it, or none (tested in OSX opengl) */ if (multisamples == -1) multisamples = U.ogl_multisamples; glSettings.numOfAASamples = multisamples; /* a new window is created when pageflip mode is required for a window */ if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) glSettings.flags |= GHOST_glStereoVisual; if (G.debug & G_DEBUG_GPU) { glSettings.flags |= GHOST_glDebugContext; } if (!(U.uiflag2 & USER_OPENGL_NO_WARN_SUPPORT)) glSettings.flags |= GHOST_glWarnSupport; wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); ghostwin = GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, (GHOST_TWindowState)win->windowstate, GHOST_kDrawingContextTypeOpenGL, glSettings); if (ghostwin) { GHOST_RectangleHandle bounds; /* the new window has already been made drawable upon creation */ wm->windrawable = win; /* needed so we can detect the graphics card below */ GPU_init(); win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); #ifdef __APPLE__ /* set the state here, else OSX would not recognize changed screen resolution */ /* we agreed to not set any fullscreen or iconized state on startup */ GHOST_SetWindowState(ghostwin, GHOST_kWindowStateNormal); #endif /* store actual window size in blender window */ bounds = GHOST_GetClientBounds(win->ghostwin); win->sizex = GHOST_GetWidthRectangle(bounds); win->sizey = GHOST_GetHeightRectangle(bounds); GHOST_DisposeRectangle(bounds); #ifndef __APPLE__ /* set the state here, so minimized state comes up correct on windows */ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); #endif /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } /* displays with larger native pixels, like Macbook. Used to scale dpi with */ /* needed here, because it's used before it reads userdef */ U.pixelsize = wm_window_pixelsize(win); BKE_userdef_state(); wm_window_swap_buffers(win); //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); /* standard state vars for window */ glEnable(GL_SCISSOR_TEST); GPU_state_init(); } }
/* belongs to below */ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; static int multisamples = -1; int scr_w, scr_h, posy; /* force setting multisamples only once, it requires restart - and you cannot * mix it, either all windows have it, or none (tested in OSX opengl) */ if (multisamples == -1) multisamples = U.ogl_multisamples; wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); ghostwin = GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, (GHOST_TWindowState)win->windowstate, GHOST_kDrawingContextTypeOpenGL, 0 /* no stereo */, multisamples /* AA */); if (ghostwin) { GHOST_RectangleHandle bounds; /* needed so we can detect the graphics card below */ GPU_extensions_init(); win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* set the state */ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } /* displays with larger native pixels, like Macbook. Used to scale dpi with */ /* needed here, because it's used before it reads userdef */ U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); BKE_userdef_state(); /* store actual window size in blender window */ bounds = GHOST_GetClientBounds(win->ghostwin); win->sizex = GHOST_GetWidthRectangle(bounds); win->sizey = GHOST_GetHeightRectangle(bounds); GHOST_DisposeRectangle(bounds); wm_window_swap_buffers(win); //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); /* standard state vars for window */ glEnable(GL_SCISSOR_TEST); GPU_state_init(); } }