void wm_window_title(wmWindowManager *wm, wmWindow *win) { /* handle the 'temp' window, only set title when not set before */ if (win->screen && win->screen->temp) { char *title = GHOST_GetTitle(win->ghostwin); if (title == NULL || title[0] == 0) GHOST_SetTitle(win->ghostwin, "Blender"); } else { /* this is set to 1 if you don't have startup.blend open */ if (G.save_over && G.main->name[0]) { char str[sizeof(G.main->name) + 12]; BLI_snprintf(str, sizeof(str), "Blender%s [%s]", wm->file_saved ? "" : "*", G.main->name); GHOST_SetTitle(win->ghostwin, str); } else GHOST_SetTitle(win->ghostwin, "Blender"); /* Informs GHOST of unsaved changes, to set window modified visual indicator (MAC OS X) * and to give hint of unsaved changes for a user warning mechanism * in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */ GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved); #if defined(__APPLE__) && !defined(GHOST_COCOA) if (wm->file_saved) GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateUnModified); else GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateModified); #endif } }
void wm_window_title(wmWindowManager *wm, wmWindow *win) { if (win->screen && win->screen->temp) { /* nothing to do for 'temp' windows, * because WM_window_open_temp always sets window title */ } else { /* this is set to 1 if you don't have startup.blend open */ if (G.save_over && G.main->name[0]) { char str[sizeof(G.main->name) + 24]; BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*", G.main->name, G.main->recovered ? " (Recovered)" : ""); GHOST_SetTitle(win->ghostwin, str); } else GHOST_SetTitle(win->ghostwin, "Blender"); /* Informs GHOST of unsaved changes, to set window modified visual indicator (MAC OS X) * and to give hint of unsaved changes for a user warning mechanism * in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */ GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved); #if defined(__APPLE__) && !defined(GHOST_COCOA) if (wm->file_saved) GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateUnModified); else GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateModified); #endif } }
/* fullscreen operator callback */ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { wmWindow *window = CTX_wm_window(C); GHOST_TWindowState state; if (G.background) return OPERATOR_CANCELLED; state = GHOST_GetWindowState(window->ghostwin); if (state != GHOST_kWindowStateFullScreen) GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen); else GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal); return OPERATOR_FINISHED; }
/* 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(); } }
/* 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(); } }