[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36426] trunk/blender: Fix [#26981] Command window is not opening in 2.57.0
Nathan Letwory
nathan at letworyinteractive.com
Mon May 2 10:07:25 CEST 2011
Revision: 36426
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36426
Author: jesterking
Date: 2011-05-02 08:07:24 +0000 (Mon, 02 May 2011)
Log Message:
-----------
Fix [#26981] Command window is not opening in 2.57.0
Reported by Thomas Engel
Fix [#26938] Blender Zoom not working after startup (Windows)
Reported by Ilija Boshkov
by applying patch [#26881] Fix for console disappearing in debug mode [Windows]
Submitted by Alexander Kuznetsov (AlexK)
The patch moves console toggling code into GHOST and improves on the toggling behaviour.
The patch changes handling of WM_SYSCOMMAND so that alt-key toggling isn't a problem anymore.
Modified Paths:
--------------
trunk/blender/intern/ghost/GHOST_C-api.h
trunk/blender/intern/ghost/GHOST_ISystem.h
trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h
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/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/intern/ghost/GHOST_C-api.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_C-api.h 2011-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/intern/ghost/GHOST_C-api.h 2011-05-02 08:07:24 UTC (rev 36426)
@@ -845,6 +845,18 @@
extern void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection);
+
+/**
+ * Toggles console
+ * @action 0 - Hides
+ * 1 - Shows
+ * 2 - Toggles
+ * 3 - Hides if it runs not from command line
+ * * - Does nothing
+ * @return current status (1 -visible, 0 - hidden)
+ */
+extern int GHOST_toggleConsole(int action);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/blender/intern/ghost/GHOST_ISystem.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_ISystem.h 2011-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/intern/ghost/GHOST_ISystem.h 2011-05-02 08:07:24 UTC (rev 36426)
@@ -355,6 +355,16 @@
*/
virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const = 0;
+ /**
+ * Toggles console
+ * @action 0 - Hides
+ * 1 - Shows
+ * 2 - Toggles
+ * 3 - Hides if it runs not from command line
+ * * - Does nothing
+ * @return current status (1 -visible, 0 - hidden)
+ */
+ virtual int toggleConsole(int action) = 0;
/***************************************************************************************
** Access to clipboard.
Modified: trunk/blender/intern/ghost/intern/GHOST_C-api.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_C-api.cpp 2011-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/intern/ghost/intern/GHOST_C-api.cpp 2011-05-02 08:07:24 UTC (rev 36426)
@@ -877,3 +877,9 @@
GHOST_ISystem* system = GHOST_ISystem::getSystem();
system->putClipboard(buffer, selection);
}
+
+int GHOST_toggleConsole(int action)
+{
+ GHOST_ISystem* system = GHOST_ISystem::getSystem();
+ return system->toggleConsole(action);
+}
Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-05-02 08:07:24 UTC (rev 36426)
@@ -174,6 +174,8 @@
GHOST_ASSERT(m_displayManager, "GHOST_SystemWin32::GHOST_SystemWin32(): m_displayManager==0\n");
m_displayManager->initialize();
+ m_consoleStatus = 1;
+
// Check if current keyboard layout uses AltGr and save keylayout ID for
// specialized handling if keys like VK_OEM_*. I.e. french keylayout
// generates VK_OEM_8 for their exclamation key (key left of right shift)
@@ -186,6 +188,7 @@
{
// Shutdown COM
OleUninitialize();
+ toggleConsole(1);
}
@@ -847,7 +850,14 @@
* a dead key that is pressed while holding down the alt key.
* To prevent the sound, DefWindowProc must be avoided by return
*/
- return 0;
+ break;
+ case WM_SYSCOMMAND:
+ /* The WM_SYSCHAR message is sent to the window when system commands such as
+ * maximize, minimize or close the window are triggered. Also it is sent when ALT
+ * button is press for menu. To prevent this we must return preventing DefWindowProc.
+ */
+ if(wParam==SC_KEYMENU) return 0;
+ break;
////////////////////////////////////////////////////////////////////////
// Tablet events, processed
////////////////////////////////////////////////////////////////////////
@@ -1047,8 +1057,12 @@
* DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY
* message. WM_DESTROY is used to free the allocated memory object associated with the window.
*/
+ break;
case WM_KILLFOCUS:
- /* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus. */
+ /* The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus.
+ * We want to prevent this if a window is still active and it loses focus to nowhere*/
+ if(!wParam && hwnd==GetActiveWindow())
+ SetFocus(hwnd);
case WM_SHOWWINDOW:
/* The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown. */
case WM_WINDOWPOSCHANGING:
@@ -1196,3 +1210,32 @@
return;
}
}
+
+int GHOST_SystemWin32::toggleConsole(int action)
+{
+ switch(action)
+ {
+ case 3: //hide if no console
+ {
+ CONSOLE_SCREEN_BUFFER_INFO csbi = {{0}};
+ if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) || csbi.dwCursorPosition.X || csbi.dwCursorPosition.Y>1)
+ break;
+ }
+ case 0: //hide
+ ShowWindow(GetConsoleWindow(),SW_HIDE);
+ m_consoleStatus = 0;
+ break;
+ case 1: //show
+ ShowWindow(GetConsoleWindow(),SW_SHOW);
+ m_consoleStatus = 1;
+ break;
+ case 2: //toggle
+ ShowWindow(GetConsoleWindow(),m_consoleStatus?SW_HIDE:SW_SHOW);
+ m_consoleStatus=!m_consoleStatus;
+ break;
+
+ };
+
+
+ return m_consoleStatus;
+}
Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h 2011-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.h 2011-05-02 08:07:24 UTC (rev 36426)
@@ -415,6 +415,17 @@
* Initiates WM_INPUT messages from keyboard
*/
GHOST_TInt32 initKeyboardRawInput(void);
+
+ /**
+ * Toggles console
+ * @action 0 - Hides
+ * 1 - Shows
+ * 2 - Toggles
+ * 3 - Hides if it runs not from command line
+ * * - Does nothing
+ * @return current status (1 -visible, 0 - hidden)
+ */
+ int toggleConsole(int action);
/** The current state of the modifier keys. */
GHOST_ModifierKeys m_modifierKeys;
@@ -431,6 +442,9 @@
/** stores keyboard layout. */
HKL m_keylayout;
+ /** Console status */
+ int m_consoleStatus;
+
/** handle for user32.dll*/
HMODULE user32;
#ifdef NEED_RAW_PROC
@@ -471,6 +485,5 @@
}
}
}
-
#endif // _GHOST_SYSTEM_WIN32_H_
Modified: trunk/blender/source/blender/blenlib/BLI_winstuff.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_winstuff.h 2011-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/source/blender/blenlib/BLI_winstuff.h 2011-05-02 08:07:24 UTC (rev 36426)
@@ -127,7 +127,6 @@
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-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/source/blender/blenlib/intern/winstuff.c 2011-05-02 08:07:24 UTC (rev 36426)
@@ -66,14 +66,6 @@
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-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c 2011-05-02 08:07:24 UTC (rev 36426)
@@ -75,6 +75,7 @@
#include "SYS_System.h"
#endif
#include "GHOST_Path-api.h"
+#include "GHOST_C-api.h"
#include "RNA_define.h"
@@ -104,7 +105,6 @@
#include "BKE_depsgraph.h"
#include "BKE_sound.h"
-#include "GHOST_C-api.h"
static void wm_init_reports(bContext *C)
{
@@ -120,17 +120,11 @@
/* only called once, for startup */
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();
-
wm_operatortype_init();
set_free_windowmanager_cb(wm_close_and_free); /* library.c */
@@ -144,7 +138,6 @@
BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
BLF_lang_init();
-
/* get the default database, plus a wm */
WM_read_homefile(C, NULL, G.factory_startup);
@@ -167,6 +160,9 @@
(void)argv; /* unused */
#endif
+ if (!G.background && !wm_start_with_console)
+ GHOST_toggleConsole(3);
+
wm_init_reports(C); /* reports cant be initialized before the wm */
if (!G.background) {
@@ -194,7 +190,6 @@
*/
BLI_strncpy(G.lib, G.main->name, FILE_MAX);
-
}
void WM_init_splash(bContext *C)
@@ -357,9 +352,6 @@
sound_exit();
-#ifdef WIN32
- WM_console_toggle(C, 1); /* never leave behind invisible consoles */
-#endif
/* first wrap up running stuff, we assume only the active WM is running */
/* modal handlers are on window level freed, others too? */
@@ -481,7 +473,6 @@
getchar();
}
#endif
-
exit(G.afbreek==1);
}
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2011-05-02 08:04:05 UTC (rev 36425)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2011-05-02 08:07:24 UTC (rev 36426)
@@ -38,13 +38,8 @@
#include <stddef.h>
#include <assert.h>
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#include <windows.h>
+#include "GHOST_C-api.h"
-#include <io.h>
-#endif
-
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
@@ -2001,7 +1996,6 @@
#endif
-
/* *********************** */
static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
@@ -2035,28 +2029,10 @@
}
/* *********************** */
-#if defined(WIN32)
-static int console= 1;
-void WM_console_toggle(bContext *UNUSED(C), short show)
-{
- if(show) {
- ShowWindow(GetConsoleWindow(),SW_SHOW);
- console= 1;
- }
- else {
- ShowWindow(GetConsoleWindow(),SW_HIDE);
- console= 0;
- }
-}
static int wm_console_toggle_op(bContext *C, wmOperator *UNUSED(op))
{
- if(console) {
- WM_console_toggle(C, 0);
- }
- else {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list