[CONSRV] Deduplicate GetScreenBufferSizeUnits(), SmallRectToRect() and ConsoleInput...
authorAmine Khaldi <amine.khaldi@reactos.org>
Fri, 8 Dec 2017 22:04:48 +0000 (23:04 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Fri, 8 Dec 2017 22:04:48 +0000 (23:04 +0100)
win32ss/user/winsrv/consrv/condrv/coninput.c
win32ss/user/winsrv/consrv/condrv/console.c
win32ss/user/winsrv/consrv/consrv.h
win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
win32ss/user/winsrv/consrv/frontends/terminal.c

index 393c9af..e3894d8 100644 (file)
 #define NDEBUG
 #include <debug.h>
 
-/* GLOBALS ********************************************************************/
-
-typedef struct ConsoleInput_t
-{
-    LIST_ENTRY ListEntry;
-    INPUT_RECORD InputEvent;
-} ConsoleInput;
-
-
 /* PRIVATE FUNCTIONS **********************************************************/
 
 // ConDrvAddInputEvents
index df0f411..d088f31 100644 (file)
@@ -23,7 +23,7 @@
 static ULONG CurrentConsoleID = 0;
 
 /* Linked list of consoles */
-static LIST_ENTRY ConsoleList;
+static LIST_ENTRY ConDrvConsoleList;
 static RTL_RESOURCE ListLock;
 
 #define ConDrvLockConsoleListExclusive()    \
@@ -37,7 +37,7 @@ static RTL_RESOURCE ListLock;
 
 
 static NTSTATUS
-InsertConsole(IN PCONSOLE Console)
+ConDrvInsertConsole(IN PCONSOLE Console)
 {
     ASSERT(Console);
 
@@ -45,7 +45,7 @@ InsertConsole(IN PCONSOLE Console)
     ConDrvLockConsoleListExclusive();
 
     DPRINT("Insert in the list\n");
-    InsertTailList(&ConsoleList, &Console->ListEntry);
+    InsertTailList(&ConDrvConsoleList, &Console->ListEntry);
 
     // FIXME: Move this code to the caller function!!
     /* Get a new console ID */
@@ -152,7 +152,7 @@ ConDrvInitConsoleSupport(VOID)
     DPRINT("CONSRV: ConDrvInitConsoleSupport()\n");
 
     /* Initialize the console list and its lock */
-    InitializeListHead(&ConsoleList);
+    InitializeListHead(&ConDrvConsoleList);
     RtlInitializeResource(&ListLock);
 }
 
@@ -248,7 +248,7 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
     DPRINT("Console initialized\n");
 
     /* All went right, so add the console to the list */
-    Status = InsertConsole(Console);
+    Status = ConDrvInsertConsole(Console);
     if (!NT_SUCCESS(Status))
     {
         /* Fail */
index c17573e..4ea7d2e 100644 (file)
@@ -54,6 +54,11 @@ typedef struct _CONSOLE_PROCESS_DATA
     // LPTHREAD_START_ROUTINE ImeRoutine;
 } CONSOLE_PROCESS_DATA, *PCONSOLE_PROCESS_DATA;
 
+typedef struct ConsoleInput_t
+{
+    LIST_ENTRY ListEntry;
+    INPUT_RECORD InputEvent;
+} ConsoleInput;
 
 // Helper for code refactoring
 // #define USE_NEW_CONSOLE_WAY
index 6058956..860244f 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "font.h"
 #include "guiterm.h"
-#include "conwnd.h"
 #include "resource.h"
 
 /* GLOBALS ********************************************************************/
@@ -172,28 +171,6 @@ UnRegisterConWndClass(HINSTANCE hInstance)
     return !!UnregisterClassW(GUI_CONWND_CLASS, hInstance);
 }
 
-
-/* NOTE: Also used in guiterm.c */
-/* static */ VOID
-GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer,
-                         IN PGUI_CONSOLE_DATA GuiData,
-                         OUT PUINT WidthUnit,
-                         OUT PUINT HeightUnit)
-{
-    ASSERT(Buffer && GuiData && WidthUnit && HeightUnit);
-
-    if (GetType(Buffer) == TEXTMODE_BUFFER)
-    {
-        *WidthUnit  = GuiData->CharWidth ;
-        *HeightUnit = GuiData->CharHeight;
-    }
-    else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
-    {
-        *WidthUnit  = 1;
-        *HeightUnit = 1;
-    }
-}
-
 static VOID
 AppendMenuItems(HMENU hMenu,
                 const GUICONSOLE_MENUITEM *Items)
@@ -742,20 +719,6 @@ OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
         DPRINT("TODO: Destroy console caret\n");
 }
 
-static VOID
-SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
-{
-    PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
-    UINT WidthUnit, HeightUnit;
-
-    GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
-
-    Rect->left   = (SmallRect->Left       - Buffer->ViewOrigin.X) * WidthUnit ;
-    Rect->top    = (SmallRect->Top        - Buffer->ViewOrigin.Y) * HeightUnit;
-    Rect->right  = (SmallRect->Right  + 1 - Buffer->ViewOrigin.X) * WidthUnit ;
-    Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
-}
-
 VOID
 GetSelectionBeginEnd(PCOORD Begin, PCOORD End,
                      PCOORD SelectionAnchor,
index 1258b79..c3e14d3 100644 (file)
@@ -56,13 +56,6 @@ UnRegisterConWndClass(HINSTANCE hInstance);
 
 /* FUNCTIONS ******************************************************************/
 
-/* NOTE: Defined in conwnd.c */
-VOID
-GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer,
-                         IN PGUI_CONSOLE_DATA GuiData,
-                         OUT PUINT WidthUnit,
-                         OUT PUINT HeightUnit);
-
 VOID
 GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
 {
@@ -78,20 +71,6 @@ GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
     }
 }
 
-static VOID
-SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
-{
-    PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
-    UINT WidthUnit, HeightUnit;
-
-    GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
-
-    Rect->left   = (SmallRect->Left       - Buffer->ViewOrigin.X) * WidthUnit ;
-    Rect->top    = (SmallRect->Top        - Buffer->ViewOrigin.Y) * HeightUnit;
-    Rect->right  = (SmallRect->Right  + 1 - Buffer->ViewOrigin.X) * WidthUnit ;
-    Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
-}
-
 static VOID
 DrawRegion(PGUI_CONSOLE_DATA GuiData,
            SMALL_RECT* Region)
index 3b252af..6272372 100644 (file)
 #include "guisettings.h"
 #include "conwnd.h"
 
+extern inline
+VOID
+GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer,
+                         IN PGUI_CONSOLE_DATA GuiData,
+                         OUT PUINT WidthUnit,
+                         OUT PUINT HeightUnit)
+{
+    ASSERT(Buffer && GuiData && WidthUnit && HeightUnit);
+
+    if (GetType(Buffer) == TEXTMODE_BUFFER)
+    {
+        *WidthUnit  = GuiData->CharWidth ;
+        *HeightUnit = GuiData->CharHeight;
+    }
+    else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
+    {
+        *WidthUnit  = 1;
+        *HeightUnit = 1;
+    }
+}
+
+extern inline
+VOID
+SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
+{
+    PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
+    UINT WidthUnit, HeightUnit;
+
+    GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
+
+    Rect->left   = (SmallRect->Left       - Buffer->ViewOrigin.X) * WidthUnit ;
+    Rect->top    = (SmallRect->Top        - Buffer->ViewOrigin.Y) * HeightUnit;
+    Rect->right  = (SmallRect->Right  + 1 - Buffer->ViewOrigin.X) * WidthUnit ;
+    Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
+}
+
 VOID
 GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData);
 
index 49f2d1f..d4f380b 100644 (file)
     ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
     MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
 
-typedef struct ConsoleInput_t
-{
-    LIST_ENTRY ListEntry;
-    INPUT_RECORD InputEvent;
-} ConsoleInput;
-
-
 /* PRIVATE FUNCTIONS **********************************************************/
 
 #if 0