https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6429bfcd8f8fe1dd6ca83…
commit 6429bfcd8f8fe1dd6ca836421f723a139f0fea78
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Fri Dec 8 23:04:48 2017 +0100
[CONSRV] Deduplicate GetScreenBufferSizeUnits(), SmallRectToRect() and ConsoleInput.
Rename ConsoleList and InsertConsole(). #179
---
win32ss/user/winsrv/consrv/condrv/coninput.c | 9 ------
win32ss/user/winsrv/consrv/condrv/console.c | 10 +++---
win32ss/user/winsrv/consrv/consrv.h | 5 +++
win32ss/user/winsrv/consrv/frontends/gui/conwnd.c | 37 ----------------------
win32ss/user/winsrv/consrv/frontends/gui/guiterm.c | 21 ------------
win32ss/user/winsrv/consrv/frontends/gui/guiterm.h | 36 +++++++++++++++++++++
win32ss/user/winsrv/consrv/frontends/terminal.c | 7 ----
7 files changed, 46 insertions(+), 79 deletions(-)
diff --git a/win32ss/user/winsrv/consrv/condrv/coninput.c
b/win32ss/user/winsrv/consrv/condrv/coninput.c
index 393c9af365..e3894d8a54 100644
--- a/win32ss/user/winsrv/consrv/condrv/coninput.c
+++ b/win32ss/user/winsrv/consrv/condrv/coninput.c
@@ -14,15 +14,6 @@
#define NDEBUG
#include <debug.h>
-/* GLOBALS ********************************************************************/
-
-typedef struct ConsoleInput_t
-{
- LIST_ENTRY ListEntry;
- INPUT_RECORD InputEvent;
-} ConsoleInput;
-
-
/* PRIVATE FUNCTIONS **********************************************************/
// ConDrvAddInputEvents
diff --git a/win32ss/user/winsrv/consrv/condrv/console.c
b/win32ss/user/winsrv/consrv/condrv/console.c
index df0f4118bf..d088f317eb 100644
--- a/win32ss/user/winsrv/consrv/condrv/console.c
+++ b/win32ss/user/winsrv/consrv/condrv/console.c
@@ -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 */
diff --git a/win32ss/user/winsrv/consrv/consrv.h b/win32ss/user/winsrv/consrv/consrv.h
index c17573e8e0..4ea7d2ee17 100644
--- a/win32ss/user/winsrv/consrv/consrv.h
+++ b/win32ss/user/winsrv/consrv/consrv.h
@@ -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
diff --git a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
index 6058956599..860244f6c5 100644
--- a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
+++ b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
@@ -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,
diff --git a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
index 1258b792f8..c3e14d3099 100644
--- a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
+++ b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
@@ -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)
diff --git a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
index 3b252afdb3..627237237d 100644
--- a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
+++ b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
@@ -14,6 +14,42 @@
#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);
diff --git a/win32ss/user/winsrv/consrv/frontends/terminal.c
b/win32ss/user/winsrv/consrv/frontends/terminal.c
index 49f2d1fe3a..d4f380ba3e 100644
--- a/win32ss/user/winsrv/consrv/frontends/terminal.c
+++ b/win32ss/user/winsrv/consrv/frontends/terminal.c
@@ -40,13 +40,6 @@
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