Apply console part of patch [#26044] Windows thumbnails and improved filetype registration
submitted by Tom Edwards This patch introduces a switch -con and its longer version --start-console. When giving this on cmd-line you'll get the black console window. The new behaviour is to hide it by default. We'll still see briefly the console at startup and during exit, but that's something that cannot be changed. If you start blender from a cmd.exe, the console will not be hidden.
This commit is contained in:
@@ -127,6 +127,7 @@ typedef struct _DIR {
|
||||
struct dirent direntry;
|
||||
} DIR;
|
||||
|
||||
int IsConsoleEmpty(void);
|
||||
void RegisterBlendExtension(void);
|
||||
DIR *opendir (const char *path);
|
||||
struct dirent *readdir(DIR *dp);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "BLI_path_util.h"
|
||||
@@ -65,6 +66,14 @@ int BLI_getInstallationDir( char * str ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsConsoleEmpty(void)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi = {0};
|
||||
HANDLE hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
return GetConsoleScreenBufferInfo(hStdOutput, &csbi) && csbi.dwCursorPosition.X == 0 && csbi.dwCursorPosition.Y == 0;
|
||||
}
|
||||
|
||||
void RegisterBlendExtension_Fail(HKEY root)
|
||||
{
|
||||
printf("failed\n");
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "BKE_material.h" /* clear_matcopybuf */
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_winstuff.h"
|
||||
|
||||
#include "RE_pipeline.h" /* RE_ free stuff */
|
||||
|
||||
@@ -114,7 +115,7 @@ static void wm_free_reports(bContext *C)
|
||||
BKE_reports_clear(CTX_wm_reports(C));
|
||||
}
|
||||
|
||||
|
||||
int wm_start_with_console = 0;
|
||||
|
||||
/* only called once, for startup */
|
||||
void WM_init(bContext *C, int argc, const char **argv)
|
||||
@@ -123,6 +124,10 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
if (!G.background) {
|
||||
wm_ghost_init(C); /* note: it assigns C to ghost! */
|
||||
wm_init_cursor_data();
|
||||
#ifdef WIN32
|
||||
if (IsConsoleEmpty()) /* never hide if the console window pre-existed */
|
||||
WM_console_toggle(C, wm_start_with_console);
|
||||
#endif
|
||||
}
|
||||
GHOST_CreateSystemPaths();
|
||||
|
||||
@@ -352,6 +357,8 @@ void WM_exit(bContext *C)
|
||||
|
||||
sound_exit();
|
||||
|
||||
WM_console_toggle(C, 1); /* never leave behind invisible consoles */
|
||||
|
||||
/* first wrap up running stuff, we assume only the active WM is running */
|
||||
/* modal handlers are on window level freed, others too? */
|
||||
/* note; same code copied in wm_files.c */
|
||||
|
||||
@@ -247,6 +247,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
|
||||
BLI_argsPrintArgDoc(ba, "--window-border");
|
||||
BLI_argsPrintArgDoc(ba, "--window-borderless");
|
||||
BLI_argsPrintArgDoc(ba, "--window-geometry");
|
||||
BLI_argsPrintArgDoc(ba, "--start-console");
|
||||
|
||||
printf("\n");
|
||||
printf ("Game Engine Specific Options:\n");
|
||||
@@ -484,6 +485,13 @@ static int without_borders(int UNUSED(argc), const char **UNUSED(argv), void *UN
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int wm_start_with_console; // blender/windowmanager/intern/wm_init_exit.c
|
||||
static int start_with_console(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
|
||||
{
|
||||
wm_start_with_console = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int register_extension(int UNUSED(argc), const char **UNUSED(argv), void *data)
|
||||
{
|
||||
#ifdef WIN32
|
||||
@@ -1095,6 +1103,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
|
||||
BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL);
|
||||
BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL);
|
||||
BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening without borders", without_borders, NULL);
|
||||
BLI_argsAdd(ba, 2, "-con", "--start-console", "\n\tStart with the console window open (ignored if -b is set)", start_with_console, NULL);
|
||||
BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension, then exit (Windows only)", register_extension, NULL);
|
||||
BLI_argsAdd(ba, 2, "-r", NULL, "\n\tSilently register .blend extension, then exit (Windows only)", register_extension, ba);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user