Author: hbelusca
Date: Sun Nov 23 23:04:45 2014
New Revision: 65471

URL: http://svn.reactos.org/svn/reactos?rev=65471&view=rev
Log:
[CONSRV]: Implement CREATE_NO_WINDOW support.

Modified:
    trunk/reactos/win32ss/user/winsrv/consrv/console.c
    trunk/reactos/win32ss/user/winsrv/consrv/console.h
    trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
    trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h
    trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
    trunk/reactos/win32ss/user/winsrv/consrv/init.c

Modified: trunk/reactos/win32ss/user/winsrv/consrv/console.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv/console.c?rev=65471&r1=65470&r2=65471&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/console.c  [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/console.c  [iso-8859-1] Sun Nov 23 
23:04:45 2014
@@ -922,6 +922,7 @@
 
     /* 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;

Modified: trunk/reactos/win32ss/user/winsrv/consrv/console.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv/console.h?rev=65471&r1=65470&r2=65471&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/console.h  [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/console.h  [iso-8859-1] Sun Nov 23 
23:04:45 2014
@@ -11,6 +11,7 @@
 typedef struct _CONSOLE_INIT_INFO
 {
     PCONSOLE_START_INFO ConsoleStartInfo;
+    BOOLEAN IsWindowVisible;
 
     ULONG  TitleLength;
     PWCHAR ConsoleTitle;

Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c?rev=65471&r1=65470&r2=65471&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c     
[iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c     
[iso-8859-1] Sun Nov 23 23:04:45 2014
@@ -686,7 +686,11 @@
 
     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 @@
     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 &&
@@ -1095,6 +1102,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;
@@ -1305,6 +1315,9 @@
 {
     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);
 
@@ -1431,7 +1444,11 @@
 {
     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 @@
 {
     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 @@
 
         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 @@
 
         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 @@
             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 ;

Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h?rev=65471&r1=65470&r2=65471&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h     
[iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h     
[iso-8859-1] Sun Nov 23 23:04:45 2014
@@ -40,6 +40,8 @@
     HANDLE hGuiInitEvent;
     HANDLE hGuiTermEvent;
 
+    BOOLEAN IsWindowVisible;
+
     POINT OldCursor;
 
     LONG_PTR WndStyle;

Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c?rev=65471&r1=65470&r2=65471&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c    
[iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c    
[iso-8859-1] Sun Nov 23 23:04:45 2014
@@ -39,6 +39,7 @@
     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 @@
                                             CW_USEDEFAULT,
                                             CW_USEDEFAULT,
                                             CW_USEDEFAULT,
-                                            NULL,
+                                            GuiData->IsWindowVisible ? 
HWND_DESKTOP : HWND_MESSAGE,
                                             NULL,
                                             ConSrvDllInstance,
                                             (PVOID)GuiData);
@@ -204,22 +205,33 @@
                 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;
             }
@@ -369,6 +381,7 @@
     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 @@
     /* 1. Load the default settings */
     GuiConsoleGetDefaultSettings(&TermInfo, GuiInitInfo->ProcessId);
 
-    /* 3. 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)
+    if (GuiData->IsWindowVisible)
+    {
+        /* 2. Load the remaining console settings via the registry */
+        if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
         {
-            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;
+            /* 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;
+            }
         }
     }
 
@@ -539,6 +555,10 @@
               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 @@
 
     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 @@
 {
     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);
@@ -632,6 +658,9 @@
                  SHORT OldCursorY)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
+
+    /* Do nothing if the window is hidden */
+    if (!GuiData->IsWindowVisible) return TRUE;
 
     if (GuiData->ActiveBuffer == Buff)
     {
@@ -935,6 +964,9 @@
     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 @@
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
 
-    /* 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);
+    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);
+    }
 
     return GuiData->MouseCursorRefCount;
 }
@@ -966,6 +1001,9 @@
                   HCURSOR CursorHandle)
 {
     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,
@@ -1068,6 +1106,7 @@
     GuiInitInfo->ConsoleInfo      = ConsoleInfo;
     GuiInitInfo->ConsoleStartInfo = ConsoleInitInfo->ConsoleStartInfo;
     GuiInitInfo->ProcessId        = ProcessId;
+    GuiInitInfo->IsWindowVisible  = ConsoleInitInfo->IsWindowVisible;
 
     /* Finally, initialize the frontend structure */
     FrontEnd->Vtbl    = &GuiVtbl;

Modified: trunk/reactos/win32ss/user/winsrv/consrv/init.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv/init.c?rev=65471&r1=65470&r2=65471&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/init.c     [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/init.c     [iso-8859-1] Sun Nov 23 
23:04:45 2014
@@ -434,6 +434,7 @@
 
     /* 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;


Reply via email to