#define PM_DESTROY_CONSOLE (WM_APP + 2)
-/* Not defined in any header file */
-extern VOID NTAPI PrivateCsrssManualGuiCheck(LONG Check);
-// See winsrv/usersrv/init.c line 234
-
-
/* GLOBALS ********************************************************************/
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;
CreateSysMenu(HWND hWnd);
static DWORD NTAPI
-GuiConsoleInputThread(PVOID Data)
+GuiConsoleInputThread(PVOID Param)
{
- PHANDLE GraphicsStartupEvent = (PHANDLE)Data;
+ PHANDLE GraphicsStartupEvent = (PHANDLE)Param;
LONG WindowCount = 0;
MSG msg;
/*
- * This thread dispatches all the console notifications to the notify window.
- * It is common for all the console windows.
+ * This thread dispatches all the console notifications to the
+ * notification window. It is common for all the console windows.
*/
/* The thread has been initialized, set the event */
- SetEvent(*GraphicsStartupEvent);
+ NtSetEvent(*GraphicsStartupEvent, NULL);
while (GetMessageW(&msg, NULL, 0, 0))
{
DPRINT("PM_CREATE_CONSOLE -- creating window\n");
- PrivateCsrssManualGuiCheck(-1); // co_AddGuiApp
-
NewWindow = CreateWindowExW(WS_EX_CLIENTEDGE,
GUI_CONWND_CLASS,
Console->Title.Buffer,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
- NULL,
+ GuiData->IsWindowVisible ? HWND_DESKTOP : HWND_MESSAGE,
NULL,
ConSrvDllInstance,
(PVOID)GuiData);
if (NewWindow == NULL)
{
DPRINT1("Failed to create a new console window\n");
- PrivateCsrssManualGuiCheck(+1); // RemoveGuiApp
continue;
}
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);
-
- DPRINT("PM_CREATE_CONSOLE -- showing window\n");
- // ShowWindow(NewWindow, (int)GuiData->GuiInfo.ShowWindow);
- ShowWindowAsync(NewWindow, (int)GuiData->GuiInfo.ShowWindow);
- DPRINT("Window showed\n");
+ 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");
+ }
+ else
+ {
+ DPRINT("PM_CREATE_CONSOLE -- hidden window\n");
+ ShowWindowAsync(NewWindow, SW_HIDE);
+ }
continue;
}
if (GuiData->hWindow == NULL) continue;
DestroyWindow(GuiData->hWindow);
- PrivateCsrssManualGuiCheck(+1); // RemoveGuiApp
- SetEvent(GuiData->hGuiTermEvent);
+ NtSetEvent(GuiData->hGuiTermEvent, NULL);
if (InterlockedDecrement(&WindowCount) == 0)
{
*/
if (hInputThread == NULL)
{
- HANDLE GraphicsStartupEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- if (GraphicsStartupEvent == NULL) return FALSE;
+ HANDLE GraphicsStartupEvent;
+ NTSTATUS Status;
+
+ Status = NtCreateEvent(&GraphicsStartupEvent, EVENT_ALL_ACCESS,
+ NULL, SynchronizationEvent, FALSE);
+ if (!NT_SUCCESS(Status)) return FALSE;
hInputThread = CreateThread(NULL,
0,
&dwInputThreadId);
if (hInputThread == NULL)
{
- CloseHandle(GraphicsStartupEvent);
+ NtClose(GraphicsStartupEvent);
DPRINT1("CONSRV: Failed to create graphics console thread.\n");
return FALSE;
}
CloseHandle(hInputThread);
WaitForSingleObject(GraphicsStartupEvent, INFINITE);
- CloseHandle(GraphicsStartupEvent);
+ NtClose(GraphicsStartupEvent);
}
// ConsInitialized = TRUE;
PGUI_CONSOLE_DATA GuiData;
GUI_CONSOLE_INFO TermInfo;
- SIZE_T Length = 0;
-
- if (This == NULL || Console == NULL || This->OldData == NULL)
+ if (This == NULL || Console == NULL || This->Context2 == NULL)
return STATUS_INVALID_PARAMETER;
ASSERT(This->Console == Console);
- GuiInitInfo = This->OldData;
+ GuiInitInfo = This->Context2;
if (GuiInitInfo->ConsoleInfo == NULL || GuiInitInfo->ConsoleStartInfo == NULL)
return STATUS_INVALID_PARAMETER;
DPRINT1("CONSRV: Failed to create GUI_CONSOLE_DATA\n");
return STATUS_UNSUCCESSFUL;
}
- ///// /* HACK */ Console->FrontEndIFace.Data = (PVOID)GuiData; /* HACK */
+ ///// /* HACK */ Console->FrontEndIFace.Context = (PVOID)GuiData; /* HACK */
GuiData->Console = Console;
GuiData->ActiveBuffer = Console->ActiveBuffer;
GuiData->hWindow = NULL;
+ GuiData->IsWindowVisible = GuiInitInfo->IsWindowVisible;
/* The console can be resized */
Console->FixedSize = FALSE;
/* 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);
-
- /*
- * 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)
+ /* 2. Load the remaining console settings via the registry */
+ if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
{
- TermInfo.FullScreen = TRUE;
+ /* 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;
+ }
}
}
*/
// Font data
- Length = min(wcslen(TermInfo.FaceName) + 1, LF_FACESIZE); // wcsnlen
wcsncpy(GuiData->GuiInfo.FaceName, TermInfo.FaceName, LF_FACESIZE);
- GuiData->GuiInfo.FaceName[Length] = L'\0';
+ GuiData->GuiInfo.FaceName[LF_FACESIZE - 1] = UNICODE_NULL;
GuiData->GuiInfo.FontFamily = TermInfo.FontFamily;
GuiData->GuiInfo.FontSize = TermInfo.FontSize;
GuiData->GuiInfo.FontWeight = TermInfo.FontWeight;
// TODO: Retrieve the selection mode via the registry.
/* Finally, finish to initialize the frontend structure */
- This->Data = GuiData;
- if (This->OldData) ConsoleFreeHeap(This->OldData);
- This->OldData = NULL;
+ This->Context = GuiData;
+ if (This->Context2) ConsoleFreeHeap(This->Context2);
+ This->Context2 = NULL;
/*
* We need to wait until the GUI has been fully initialized
* Ideally we could use SendNotifyMessage for this but its not
* yet implemented.
*/
- GuiData->hGuiInitEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- GuiData->hGuiTermEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ NtCreateEvent(&GuiData->hGuiInitEvent, EVENT_ALL_ACCESS,
+ NULL, SynchronizationEvent, FALSE);
+ NtCreateEvent(&GuiData->hGuiTermEvent, EVENT_ALL_ACCESS,
+ NULL, SynchronizationEvent, FALSE);
DPRINT("GUI - Checkpoint\n");
/* Wait until initialization has finished */
WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE);
DPRINT("OK we created the console window\n");
- CloseHandle(GuiData->hGuiInitEvent);
+ NtClose(GuiData->hGuiInitEvent);
GuiData->hGuiInitEvent = NULL;
/* Check whether we really succeeded in initializing the terminal window */
static VOID NTAPI
GuiDeinitFrontEnd(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
DPRINT("Send PM_DESTROY_CONSOLE message and wait on hGuiTermEvent...\n");
PostThreadMessageW(dwInputThreadId, PM_DESTROY_CONSOLE, 0, (LPARAM)GuiData);
WaitForSingleObject(GuiData->hGuiTermEvent, INFINITE);
DPRINT("hGuiTermEvent set\n");
- CloseHandle(GuiData->hGuiTermEvent);
+ NtClose(GuiData->hGuiTermEvent);
GuiData->hGuiTermEvent = NULL;
DPRINT("Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ; GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
DestroyIcon(GuiData->hIconSm);
}
- This->Data = NULL;
+ This->Context = NULL;
DeleteCriticalSection(&GuiData->Lock);
ConsoleFreeHeap(GuiData);
GuiDrawRegion(IN OUT PFRONTEND This,
SMALL_RECT* Region)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
+
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return;
+
DrawRegion(GuiData, Region);
}
PWCHAR Buffer,
UINT Length)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
PCONSOLE_SCREEN_BUFFER Buff;
SHORT CursorEndX, CursorEndY;
RECT ScrollRect;
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;
/* static */ VOID NTAPI
GuiRingBell(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
/* Emit an error beep sound */
SendNotifyMessage(GuiData->hWindow, PM_CONSOLE_BEEP, 0, 0);
GuiSetCursorInfo(IN OUT PFRONTEND This,
PCONSOLE_SCREEN_BUFFER Buff)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
+
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return TRUE;
if (GuiData->ActiveBuffer == Buff)
{
SHORT OldCursorX,
SHORT OldCursorY)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
+
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return TRUE;
if (GuiData->ActiveBuffer == Buff)
{
static VOID NTAPI
GuiResizeTerminal(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
/* Resize the window to the user's values */
PostMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
static VOID NTAPI
GuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
HPALETTE hPalette;
hPalette = ActiveBuffer->PaletteHandle;
}
- DPRINT1("GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette);
+ DPRINT("GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette);
/* Set the new palette for the framebuffer */
SelectPalette(GuiData->hMemDC, hPalette, FALSE);
GuiReleaseScreenBuffer(IN OUT PFRONTEND This,
IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
/*
* If we were notified to release a screen buffer that is not actually
static VOID NTAPI
GuiRefreshInternalInfo(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
/* Update the console leader information held by the window */
SetConWndConsoleLeaderCID(GuiData);
static VOID NTAPI
GuiChangeTitle(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
// PostMessageW(GuiData->hWindow, PM_CONSOLE_SET_TITLE, 0, 0);
SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
}
GuiChangeIcon(IN OUT PFRONTEND This,
HICON IconHandle)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
HICON hIcon, hIconSm;
if (IconHandle == NULL)
static HWND NTAPI
GuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
return GuiData->hWindow;
}
GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
PCOORD pSize)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
RECT WorkArea;
LONG width, height;
GuiGetSelectionInfo(IN OUT PFRONTEND This,
PCONSOLE_SELECTION_INFO pSelectionInfo)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
if (pSelectionInfo == NULL) return FALSE;
HPALETTE PaletteHandle,
UINT PaletteUsage)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
HPALETTE OldPalette;
// if (GetType(GuiData->ActiveBuffer) != GRAPHICS_BUFFER) return FALSE;
static ULONG NTAPI
GuiGetDisplayMode(IN OUT PFRONTEND This)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
ULONG DisplayMode = 0;
if (GuiData->GuiInfo.FullScreen)
GuiSetDisplayMode(IN OUT PFRONTEND This,
ULONG NewMode)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
BOOL FullScreen;
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)
GuiShowMouseCursor(IN OUT PFRONTEND This,
BOOL Show)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
- /* 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;
}
GuiSetMouseCursor(IN OUT PFRONTEND This,
HCURSOR CursorHandle)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
+
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return TRUE;
/*
* Set the cursor's handle. If the given handle is NULL,
UINT CmdIdLow,
UINT CmdIdHigh)
{
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
GuiData->CmdIdLow = CmdIdLow ;
GuiData->CmdIdHigh = CmdIdHigh;
* for more information.
*/
- PGUI_CONSOLE_DATA GuiData = This->Data;
+ PGUI_CONSOLE_DATA GuiData = This->Context;
HMENU hSysMenu = GetSystemMenu(GuiData->hWindow, FALSE);
if (hSysMenu == NULL) return FALSE;
GuiInitInfo->ConsoleInfo = ConsoleInfo;
GuiInitInfo->ConsoleStartInfo = ConsoleInitInfo->ConsoleStartInfo;
GuiInitInfo->ProcessId = ProcessId;
+ GuiInitInfo->IsWindowVisible = ConsoleInitInfo->IsWindowVisible;
/* Finally, initialize the frontend structure */
- FrontEnd->Vtbl = &GuiVtbl;
- FrontEnd->Data = NULL;
- FrontEnd->OldData = GuiInitInfo;
+ FrontEnd->Vtbl = &GuiVtbl;
+ FrontEnd->Context = NULL;
+ FrontEnd->Context2 = GuiInitInfo;
return STATUS_SUCCESS;
}
{
if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
- if (FrontEnd->Data) GuiDeinitFrontEnd(FrontEnd);
- if (FrontEnd->OldData) ConsoleFreeHeap(FrontEnd->OldData);
+ if (FrontEnd->Context ) GuiDeinitFrontEnd(FrontEnd);
+ if (FrontEnd->Context2) ConsoleFreeHeap(FrontEnd->Context2);
return STATUS_SUCCESS;
}