[CONSRV]: Implement CREATE_NO_WINDOW support.

svn path=/trunk/; revision=65471
This commit is contained in:
Hermès Bélusca-Maïto 2014-11-23 23:04:45 +00:00
parent 1dc01e0746
commit 398b0a3c4f
6 changed files with 117 additions and 44 deletions

View file

@ -922,6 +922,7 @@ CSR_API(SrvAllocConsole)
/* Initialize the console initialization info structure */
ConsoleInitInfo.ConsoleStartInfo = AllocConsoleRequest->ConsoleStartInfo;
ConsoleInitInfo.IsWindowVisible = TRUE; // The console window is always visible.
ConsoleInitInfo.TitleLength = AllocConsoleRequest->TitleLength;
ConsoleInitInfo.ConsoleTitle = AllocConsoleRequest->ConsoleTitle;
ConsoleInitInfo.DesktopLength = AllocConsoleRequest->DesktopLength;

View file

@ -11,6 +11,7 @@
typedef struct _CONSOLE_INIT_INFO
{
PCONSOLE_START_INFO ConsoleStartInfo;
BOOLEAN IsWindowVisible;
ULONG TitleLength;
PWCHAR ConsoleTitle;

View file

@ -686,7 +686,11 @@ OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
if (GuiData->IsWindowVisible)
{
SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
}
// FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
//CreateSysMenu(GuiData->hWindow);
@ -1048,6 +1052,9 @@ OnPaint(PGUI_CONSOLE_DATA GuiData)
PAINTSTRUCT ps;
RECT rcPaint;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return;
BeginPaint(GuiData->hWindow, &ps);
if (ps.hdc != NULL &&
ps.rcPaint.left < ps.rcPaint.right &&
@ -1096,6 +1103,9 @@ OnPaletteChanged(PGUI_CONSOLE_DATA GuiData)
{
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return;
// See WM_PALETTECHANGED message
// if ((HWND)wParam == hWnd) break;
@ -1306,6 +1316,9 @@ OnTimer(PGUI_CONSOLE_DATA GuiData)
PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return;
SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CURSOR_BLINK_TIME, NULL);
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
@ -1431,7 +1444,11 @@ OnNcDestroy(HWND hWnd)
{
PGUI_CONSOLE_DATA GuiData = GuiGetGuiData(hWnd);
KillTimer(hWnd, CONGUI_UPDATE_TIMER);
if (GuiData->IsWindowVisible)
{
KillTimer(hWnd, CONGUI_UPDATE_TIMER);
}
GetSystemMenu(hWnd, TRUE);
if (GuiData)
@ -1868,6 +1885,9 @@ OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
PCONSRV_CONSOLE Console = GuiData->Console;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
if ((GuiData->WindowSizeLock == FALSE) &&
@ -2191,6 +2211,9 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SETCURSOR:
{
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) goto Default;
/*
* The message was sent because we are manually triggering a change.
* Check whether the mouse is indeed present on this console window
@ -2263,6 +2286,9 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_CONTEXTMENU:
{
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) break;
if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
{
HMENU hMenu = CreatePopupMenu();
@ -2391,6 +2417,9 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
DWORD Width, Height;
UINT WidthUnit, HeightUnit;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) break;
GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
Width = Buff->ScreenBufferSize.X * WidthUnit ;

View file

@ -40,6 +40,8 @@ typedef struct _GUI_CONSOLE_DATA
HANDLE hGuiInitEvent;
HANDLE hGuiTermEvent;
BOOLEAN IsWindowVisible;
POINT OldCursor;
LONG_PTR WndStyle;

View file

@ -39,6 +39,7 @@ typedef struct _GUI_INIT_INFO
PCONSOLE_INFO ConsoleInfo;
PCONSOLE_START_INFO ConsoleStartInfo;
ULONG ProcessId;
BOOLEAN IsWindowVisible;
} GUI_INIT_INFO, *PGUI_INIT_INFO;
static BOOL ConsInitialized = FALSE;
@ -179,7 +180,7 @@ GuiConsoleInputThread(PVOID Data)
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
GuiData->IsWindowVisible ? HWND_DESKTOP : HWND_MESSAGE,
NULL,
ConSrvDllInstance,
(PVOID)GuiData);
@ -204,22 +205,33 @@ GuiConsoleInputThread(PVOID Data)
GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
/* Move and resize the window to the user's values */
/* CAN WE DEADLOCK ?? */
GuiConsoleMoveWindow(GuiData); // FIXME: This MUST be done via the CreateWindowExW call.
SendMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
if (GuiData->IsWindowVisible)
{
/* Move and resize the window to the user's values */
/* CAN WE DEADLOCK ?? */
GuiConsoleMoveWindow(GuiData); // FIXME: This MUST be done via the CreateWindowExW call.
SendMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
}
// FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
CreateSysMenu(GuiData->hWindow);
/* Switch to full-screen mode if necessary */
// FIXME: Move elsewhere, it cause misdrawings of the window.
if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE);
if (GuiData->IsWindowVisible)
{
/* Switch to full-screen mode if necessary */
// FIXME: Move elsewhere, it cause misdrawings of the window.
if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE);
DPRINT("PM_CREATE_CONSOLE -- showing window\n");
// ShowWindow(NewWindow, (int)GuiData->GuiInfo.ShowWindow);
ShowWindowAsync(NewWindow, (int)GuiData->GuiInfo.ShowWindow);
DPRINT("Window showed\n");
DPRINT("PM_CREATE_CONSOLE -- showing window\n");
// ShowWindow(NewWindow, (int)GuiData->GuiInfo.ShowWindow);
ShowWindowAsync(NewWindow, (int)GuiData->GuiInfo.ShowWindow);
DPRINT("Window showed\n");
}
else
{
DPRINT("PM_CREATE_CONSOLE -- hidden window\n");
ShowWindowAsync(NewWindow, SW_HIDE);
}
continue;
}
@ -369,6 +381,7 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
GuiData->Console = Console;
GuiData->ActiveBuffer = Console->ActiveBuffer;
GuiData->hWindow = NULL;
GuiData->IsWindowVisible = GuiInitInfo->IsWindowVisible;
/* The console can be resized */
Console->FixedSize = FALSE;
@ -383,33 +396,36 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
/* 1. Load the default settings */
GuiConsoleGetDefaultSettings(&TermInfo, GuiInitInfo->ProcessId);
/* 3. Load the remaining console settings via the registry */
if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
if (GuiData->IsWindowVisible)
{
/* Load the terminal infos from the registry */
GuiConsoleReadUserSettings(&TermInfo,
ConsoleInfo->ConsoleTitle,
GuiInitInfo->ProcessId);
/* 2. Load the remaining console settings via the registry */
if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
{
/* Load the terminal infos from the registry */
GuiConsoleReadUserSettings(&TermInfo,
ConsoleInfo->ConsoleTitle,
GuiInitInfo->ProcessId);
/*
* Now, update them with the properties the user might gave to us
* via the STARTUPINFO structure before calling CreateProcess
* (and which was transmitted via the ConsoleStartInfo structure).
* We therefore overwrite the values read in the registry.
*/
if (ConsoleStartInfo->dwStartupFlags & STARTF_USESHOWWINDOW)
{
TermInfo.ShowWindow = ConsoleStartInfo->wShowWindow;
}
if (ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION)
{
TermInfo.AutoPosition = FALSE;
TermInfo.WindowOrigin.x = ConsoleStartInfo->dwWindowOrigin.X;
TermInfo.WindowOrigin.y = ConsoleStartInfo->dwWindowOrigin.Y;
}
if (ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN)
{
TermInfo.FullScreen = TRUE;
/*
* Now, update them with the properties the user might gave to us
* via the STARTUPINFO structure before calling CreateProcess
* (and which was transmitted via the ConsoleStartInfo structure).
* We therefore overwrite the values read in the registry.
*/
if (ConsoleStartInfo->dwStartupFlags & STARTF_USESHOWWINDOW)
{
TermInfo.ShowWindow = ConsoleStartInfo->wShowWindow;
}
if (ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION)
{
TermInfo.AutoPosition = FALSE;
TermInfo.WindowOrigin.x = ConsoleStartInfo->dwWindowOrigin.X;
TermInfo.WindowOrigin.y = ConsoleStartInfo->dwWindowOrigin.Y;
}
if (ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN)
{
TermInfo.FullScreen = TRUE;
}
}
}
@ -539,6 +555,10 @@ GuiDrawRegion(IN OUT PFRONTEND This,
SMALL_RECT* Region)
{
PGUI_CONSOLE_DATA GuiData = This->Data;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return;
DrawRegion(GuiData, Region);
}
@ -558,6 +578,9 @@ GuiWriteStream(IN OUT PFRONTEND This,
if (NULL == GuiData || NULL == GuiData->hWindow) return;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return;
Buff = GuiData->ActiveBuffer;
if (GetType(Buff) != TEXTMODE_BUFFER) return;
@ -617,6 +640,9 @@ GuiSetCursorInfo(IN OUT PFRONTEND This,
{
PGUI_CONSOLE_DATA GuiData = This->Data;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return TRUE;
if (GuiData->ActiveBuffer == Buff)
{
InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
@ -633,6 +659,9 @@ GuiSetScreenInfo(IN OUT PFRONTEND This,
{
PGUI_CONSOLE_DATA GuiData = This->Data;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return TRUE;
if (GuiData->ActiveBuffer == Buff)
{
/* Redraw char at old position (remove cursor) */
@ -935,6 +964,9 @@ GuiSetDisplayMode(IN OUT PFRONTEND This,
if (NewMode & ~(CONSOLE_FULLSCREEN_MODE | CONSOLE_WINDOWED_MODE))
return FALSE;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return TRUE;
FullScreen = ((NewMode & CONSOLE_FULLSCREEN_MODE) != 0);
if (FullScreen != GuiData->GuiInfo.FullScreen)
@ -951,12 +983,15 @@ GuiShowMouseCursor(IN OUT PFRONTEND This,
{
PGUI_CONSOLE_DATA GuiData = This->Data;
/* Set the reference count */
if (Show) ++GuiData->MouseCursorRefCount;
else --GuiData->MouseCursorRefCount;
if (GuiData->IsWindowVisible)
{
/* Set the reference count */
if (Show) ++GuiData->MouseCursorRefCount;
else --GuiData->MouseCursorRefCount;
/* Effectively show (or hide) the cursor (use special values for (w|l)Param) */
PostMessageW(GuiData->hWindow, WM_SETCURSOR, -1, -1);
/* Effectively show (or hide) the cursor (use special values for (w|l)Param) */
PostMessageW(GuiData->hWindow, WM_SETCURSOR, -1, -1);
}
return GuiData->MouseCursorRefCount;
}
@ -967,6 +1002,9 @@ GuiSetMouseCursor(IN OUT PFRONTEND This,
{
PGUI_CONSOLE_DATA GuiData = This->Data;
/* Do nothing if the window is hidden */
if (!GuiData->IsWindowVisible) return TRUE;
/*
* Set the cursor's handle. If the given handle is NULL,
* then restore the default cursor.
@ -1068,6 +1106,7 @@ GuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
GuiInitInfo->ConsoleInfo = ConsoleInfo;
GuiInitInfo->ConsoleStartInfo = ConsoleInitInfo->ConsoleStartInfo;
GuiInitInfo->ProcessId = ProcessId;
GuiInitInfo->IsWindowVisible = ConsoleInitInfo->IsWindowVisible;
/* Finally, initialize the frontend structure */
FrontEnd->Vtbl = &GuiVtbl;

View file

@ -434,6 +434,7 @@ ConSrvConnect(IN PCSR_PROCESS CsrProcess,
/* Initialize the console initialization info structure */
ConsoleInitInfo.ConsoleStartInfo = &ConnectInfo->ConsoleStartInfo;
ConsoleInitInfo.IsWindowVisible = ConnectInfo->IsWindowVisible;
ConsoleInitInfo.TitleLength = ConnectInfo->TitleLength;
ConsoleInitInfo.ConsoleTitle = ConnectInfo->ConsoleTitle;
ConsoleInitInfo.DesktopLength = ConnectInfo->DesktopLength;