Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Letwory <nathan@letworyinteractive.com>2011-05-02 12:07:24 +0400
committerNathan Letwory <nathan@letworyinteractive.com>2011-05-02 12:07:24 +0400
commitd197ec74e31c0a90b440246e5c48dd0644055740 (patch)
tree0623a838e26a1cb1c84b807b1abdb1b6051ebc94
parent17451136390980fc26e971cd7fb8308a509bb22d (diff)
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.
-rw-r--r--intern/ghost/GHOST_C-api.h12
-rw-r--r--intern/ghost/GHOST_ISystem.h10
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp6
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp47
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h15
-rw-r--r--source/blender/blenlib/BLI_winstuff.h1
-rw-r--r--source/blender/blenlib/intern/winstuff.c8
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c17
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c29
9 files changed, 93 insertions, 52 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index be8dc138797..75837239c4a 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -845,6 +845,18 @@ extern GHOST_TUns8* GHOST_getClipboard(int selection);
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
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 38c732153d7..69e10070be5 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -355,6 +355,16 @@ public:
*/
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.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index a1e1bafa82f..7ba8d7db411 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -877,3 +877,9 @@ void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
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);
+}
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index dc16711b532..c901c402716 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -174,6 +174,8 @@ GHOST_SystemWin32::GHOST_SystemWin32()
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 @@ GHOST_SystemWin32::~GHOST_SystemWin32()
{
// Shutdown COM
OleUninitialize();
+ toggleConsole(1);
}
@@ -847,7 +850,14 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* 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 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
* 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 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const
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;
+}
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index d79b9a22b69..2dad3a6f44d 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -415,6 +415,17 @@ protected:
* 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 @@ protected:
/** 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 @@ inline void GHOST_SystemWin32::handleKeyboardChange(void)
}
}
}
-
#endif // _GHOST_SYSTEM_WIN32_H_
diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h
index 176e7319bf7..d0eb3c7d67d 100644
--- a/source/blender/blenlib/BLI_winstuff.h
+++ b/source/blender/blenlib/BLI_winstuff.h
@@ -127,7 +127,6 @@ typedef struct _DIR {
struct dirent direntry;
} DIR;
-int IsConsoleEmpty(void);
void RegisterBlendExtension(void);
DIR *opendir (const char *path);
struct dirent *readdir(DIR *dp);
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index 596ab2b0470..66080ed2a85 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -66,14 +66,6 @@ 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");
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 58485b1f544..620d3314d43 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -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 @@ int wm_start_with_console = 0;
/* 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 @@ void WM_init(bContext *C, int argc, const char **argv)
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 WM_init(bContext *C, int argc, const char **argv)
(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 @@ void WM_init(bContext *C, int argc, const char **argv)
*/
BLI_strncpy(G.lib, G.main->name, FILE_MAX);
-
}
void WM_init_splash(bContext *C)
@@ -357,9 +352,6 @@ void WM_exit(bContext *C)
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 @@ void WM_exit(bContext *C)
getchar();
}
#endif
-
exit(G.afbreek==1);
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 100dd914026..fd39755607f 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -38,12 +38,7 @@
#include <stddef.h>
#include <assert.h>
-#ifdef WIN32
-#include "BLI_winstuff.h"
-#include <windows.h>
-
-#include <io.h>
-#endif
+#include "GHOST_C-api.h"
#include "MEM_guardedalloc.h"
@@ -2001,7 +1996,6 @@ static void WM_OT_collada_import(wmOperatorType *ot)
#endif
-
/* *********************** */
static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
@@ -2035,28 +2029,10 @@ static void WM_OT_quit_blender(wmOperatorType *ot)
}
/* *********************** */
-#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 {
- WM_console_toggle(C, 1);
- }
+ GHOST_toggleConsole(2);
return OPERATOR_FINISHED;
}
@@ -2069,7 +2045,6 @@ static void WM_OT_console_toggle(wmOperatorType *ot)
ot->exec= wm_console_toggle_op;
ot->poll= WM_operator_winactive;
}
-#endif
/* ************ default paint cursors, draw always around cursor *********** */
/*