Where and How is GHOST_CreateWindow() Used?

[FOUND IT, :D]

I Have been wandering around and looking at GHOST code… I have got a pretty good Understanding Of it…(I think :slightly_smiling_face:) But What I cant find out is How and Where is it Even Used?

[Note: Searching on Github only shows this 1 Function wm_window_ghostwindow_add() that has GHOST_CreateWindow() inside it]

creator.c calls WM_init()
WM_init() calls wm_ghost_init() // Which then assigns bContext to GHOST [Or Simply Saying, it enables OS Specific EVENT comms with bContext and also creates OS specific GHOST system for stuffs like creating windows, g_system is a pointer to that GHOST System class]

but none of these really “Creates a window”…
I Checked Everything inside WM_init() that looked related to GHOST or window creation. But couldn’t really find any “Window Creation” stuffs… Couldn’t find the code that opens first window after entry point…

[UPDATE: I found some code saying WM_CHECK Creates the windows, a,k,a calls wm_window_add_ghostwindows(), but HOW and WHERE… cause seeing WM_CHECK’s Code really doesn’t Feel like that]

[UPDATE 2: I think I Got it: I think I found it wm_window_ghostwindows_ensure() calls wm_window_ghostwindow_ensure() for every window object registered to window manager… Then it checks ghostwin inside window object, and calls wm_window_ghostwindow_add() based on that… and that Last one Calls GHOST_CreateWindow() or GHOST_CreatwDialogueWindow()]

For future reference, the easiest way to track down things like this, is put a breakpoint in the function you are interested in and run it in the debugger, then you can check the callstack on how you ended up there.

example for GHOST_CreateWindow

>	blender.exe!GHOST_CreateWindow(GHOST_SystemHandle__ * systemhandle, const char * title, int left, int top, unsigned int width, unsigned int height, GHOST_TWindowState state, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings) Line 167	C++
 	blender.exe!wm_window_ghostwindow_add(wmWindowManager * wm, const unsigned char * title, wmWindow * win, bool is_dialog) Line 607	C
 	blender.exe!wm_window_ghostwindow_ensure(wmWindowManager * wm, wmWindow * win, bool is_dialog) Line 684	C
 	blender.exe!wm_window_ghostwindows_ensure(wmWindowManager * wm) Line 747	C
 	blender.exe!WM_check(bContext * C) Line 511	C
 	blender.exe!wm_homefile_read(bContext * C, ReportList * reports, bool use_factory_settings, bool use_empty_data, bool use_data, bool use_userdef, const unsigned char * filepath_startup_override, const unsigned char * app_template_override, bool * r_is_factory_startup) Line 1141	C
 	blender.exe!WM_init(bContext * C, int argc, const unsigned char * * argv) Line 303	C
 	blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 477	C
 	[External Code]	
2 Likes