[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36057] trunk/blender/source: Apply console part of patch [#26044] Windows thumbnails and improved filetype registration

Nathan Letwory nathan at letworyinteractive.com
Fri Apr 8 14:49:38 CEST 2011


Revision: 36057
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36057
Author:   jesterking
Date:     2011-04-08 12:49:38 +0000 (Fri, 08 Apr 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_winstuff.h
    trunk/blender/source/blender/blenlib/intern/winstuff.c
    trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/source/blender/blenlib/BLI_winstuff.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_winstuff.h	2011-04-08 12:28:59 UTC (rev 36056)
+++ trunk/blender/source/blender/blenlib/BLI_winstuff.h	2011-04-08 12:49:38 UTC (rev 36057)
@@ -127,6 +127,7 @@
 	struct dirent direntry;
 } DIR;
 
+int IsConsoleEmpty(void);
 void RegisterBlendExtension(void);
 DIR *opendir (const char *path);
 struct dirent *readdir(DIR *dp);

Modified: trunk/blender/source/blender/blenlib/intern/winstuff.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/winstuff.c	2011-04-08 12:28:59 UTC (rev 36056)
+++ trunk/blender/source/blender/blenlib/intern/winstuff.c	2011-04-08 12:49:38 UTC (rev 36057)
@@ -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 @@
 	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");

Modified: trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c	2011-04-08 12:28:59 UTC (rev 36056)
+++ trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c	2011-04-08 12:49:38 UTC (rev 36057)
@@ -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,8 +115,8 @@
 	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 @@
 	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 @@
 
 	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 */

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2011-04-08 12:28:59 UTC (rev 36056)
+++ trunk/blender/source/creator/creator.c	2011-04-08 12:49:38 UTC (rev 36057)
@@ -247,6 +247,7 @@
 	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 @@
 	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 @@
 	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);
 




More information about the Bf-blender-cvs mailing list