1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-08 18:40:55 +03:00

OCC22250 Windows lost focus with DRAWEXE launched in 'virtual windows' mode

This commit is contained in:
KGV 2011-04-28 15:47:42 +00:00 committed by bugmaster
parent 1aeb969a54
commit 87c58d4f03
2 changed files with 72 additions and 65 deletions
src

@ -1301,8 +1301,11 @@ HWND DrawWindow::CreateDrawWindow(HWND hWndClient, int nitem)
WS_OVERLAPPEDWINDOW, WS_OVERLAPPEDWINDOW,
1,1,1,1, 1,1,1,1,
NULL, NULL,::GetModuleHandle(NULL), NULL); NULL, NULL,::GetModuleHandle(NULL), NULL);
if (!Draw_VirtualWindows)
{
SetWindowPos(aWin, HWND_TOPMOST, 1,1,1,1, SWP_NOMOVE); SetWindowPos(aWin, HWND_TOPMOST, 1,1,1,1, SWP_NOMOVE);
SetWindowPos(aWin, HWND_NOTOPMOST, 1,1,1,1, SWP_NOMOVE); SetWindowPos(aWin, HWND_NOTOPMOST, 1,1,1,1, SWP_NOMOVE);
}
return aWin; return aWin;
} }
else { else {
@ -1955,7 +1958,6 @@ Standard_Boolean Init_Appli(HINSTANCE hInst,
DWORD IDThread; DWORD IDThread;
HANDLE hThread; HANDLE hThread;
console_semaphore = STOP_CONSOLE; console_semaphore = STOP_CONSOLE;
theCommands.Init(); theCommands.Init();
interp = theCommands.Interp(); interp = theCommands.Interp();
Tcl_Init(interp) ; Tcl_Init(interp) ;
@ -1994,11 +1996,6 @@ Standard_Boolean Init_Appli(HINSTANCE hInst,
if(!RegisterAppClass(hInst)) if(!RegisterAppClass(hInst))
return(Standard_False); return(Standard_False);
if (Draw_VirtualWindows) {
// main window will never shown
Tcl_Eval(theCommands.Interp(), "wm withdraw .");
}
/* /*
** Enter the application message-polling loop. This is the anchor for ** Enter the application message-polling loop. This is the anchor for
** the application. ** the application.
@ -2052,7 +2049,6 @@ void exitProc(ClientData /*dc*/)
static DWORD WINAPI tkLoop(VOID) static DWORD WINAPI tkLoop(VOID)
{ {
Tcl_CreateExitHandler(exitProc, 0); Tcl_CreateExitHandler(exitProc, 0);
#if (TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5)) #if (TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5))
Tcl_RegisterChannel(theCommands.Interp(), Tcl_GetStdChannel(TCL_STDIN)); Tcl_RegisterChannel(theCommands.Interp(), Tcl_GetStdChannel(TCL_STDIN));
Tcl_RegisterChannel(theCommands.Interp(), Tcl_GetStdChannel(TCL_STDOUT)); Tcl_RegisterChannel(theCommands.Interp(), Tcl_GetStdChannel(TCL_STDOUT));
@ -2060,38 +2056,40 @@ static DWORD WINAPI tkLoop(VOID)
#endif #endif
#ifdef _TK #ifdef _TK
try { // initialize the Tk library if not in 'virtual windows' mode
// (virtual windows are created by OCCT with native APIs,
// thus Tk will be useless)
if (!Draw_VirtualWindows)
{
try
{
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
Standard_Integer res = Tk_Init (interp); Standard_Integer res = Tk_Init (interp);
if (res != TCL_OK) if (res != TCL_OK)
{
cout << "tkLoop: error in Tk initialization. Tcl reported: " << interp->result << endl; cout << "tkLoop: error in Tk initialization. Tcl reported: " << interp->result << endl;
}
} catch (Standard_Failure) { }
cout <<"tkLoop: exception in TK_Init "<<endl; catch (Standard_Failure)
{
cout << "tkLoop: exception in TK_Init\n";
} }
Tcl_StaticPackage (interp, "Tk", Tk_Init, (Tcl_PackageInitProc* ) NULL); Tcl_StaticPackage (interp, "Tk", Tk_Init, (Tcl_PackageInitProc* ) NULL);
mainWindow = Tk_MainWindow (interp);
mainWindow = if (mainWindow == NULL)
Tk_MainWindow(interp) ; {
if (mainWindow == NULL) {
fprintf (stderr, "%s\n", interp->result); fprintf (stderr, "%s\n", interp->result);
cout << "tkLoop: Tk_MainWindow() returned NULL. Exiting..." << endl; cout << "tkLoop: Tk_MainWindow() returned NULL. Exiting...\n";
Tcl_Exit (0); Tcl_Exit (0);
} }
Tk_Name(mainWindow) = Tk_Name(mainWindow) = Tk_GetUid (Tk_SetAppName (mainWindow, "Draw"));
Tk_GetUid(Tk_SetAppName(mainWindow,
"Draw")) ;
if (Draw_VirtualWindows) {
// main window will never shown
Tcl_Eval(theCommands.Interp(), "wm withdraw .");
} }
#endif //#ifdef _TK #endif //#ifdef _TK
// msv - 16/09/2004 - set signal handler in the new thread // set signal handler in the new thread
OSD::SetSignal(); OSD::SetSignal();
// san - 06/08/2002 - inform the others that we have started // inform the others that we have started
isTkLoopStarted = true; isTkLoopStarted = true;
while (console_semaphore == STOP_CONSOLE) while (console_semaphore == STOP_CONSOLE)
@ -2101,27 +2099,32 @@ static DWORD WINAPI tkLoop(VOID)
Prompt(interp, 0); Prompt(interp, 0);
//process a command //process a command
#ifdef _TK Standard_Boolean toLoop = Standard_True;
// san - 10/07/02 -- We should not exit until the Main Tk window is closed while (toLoop)
while (Tk_GetNumMainWindows() > 0) { {
#else
while (1) {
#endif
while(Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT)); while(Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT));
if (console_semaphore == HAS_CONSOLE_COMMAND) { if (console_semaphore == HAS_CONSOLE_COMMAND)
{
if (Draw_Interprete (console_command)) if (Draw_Interprete (console_command))
{
if (Draw_IsConsoleSubsystem) Prompt (interp, 0); if (Draw_IsConsoleSubsystem) Prompt (interp, 0);
}
else else
{
if (Draw_IsConsoleSubsystem) Prompt (interp, 1); if (Draw_IsConsoleSubsystem) Prompt (interp, 1);
}
console_semaphore = WAIT_CONSOLE_COMMAND; console_semaphore = WAIT_CONSOLE_COMMAND;
} }
else else
{
Sleep(100); Sleep(100);
} }
#ifdef _TK
// We should not exit until the Main Tk window is closed
toLoop = (Tk_GetNumMainWindows() > 0) || Draw_VirtualWindows;
#endif
}
Tcl_Exit(0); Tcl_Exit(0);
return 0; return 0;
} }

@ -26,12 +26,16 @@ if { [file exist $dir] } {
source [file join $dir StandardCommands.tcl] source [file join $dir StandardCommands.tcl]
source [file join $dir StandardViews.tcl] source [file join $dir StandardViews.tcl]
source [file join $dir Geometry.tcl] source [file join $dir Geometry.tcl]
if [info exists tk_version] {source [file join $dir DrawTK.tcl]}
if [file readable DrawAppliInit] {
source DrawAppliInit
}
set stationname $tcl_platform(platform) set stationname $tcl_platform(platform)
if [info exists tk_version] {
source [file join $dir DrawTK.tcl]
# setup the icon for main window
if { ${stationname} == "windows" } { if { ${stationname} == "windows" } {
wm iconbitmap . -default [file join $dir lamp.ico] wm iconbitmap . -default [file join $dir lamp.ico]
} }
} }
if [file readable DrawAppliInit] {
source DrawAppliInit
}
}