- Fix some files' info-header text.
- Move code of SrvSetConsoleWindowInfo to ConDrvSetConsoleWindowInfo.
- Introduce the helper function GetScreenBufferSizeUnits to retrieve screen-buffer width/height units.

svn path=/trunk/; revision=59433
This commit is contained in:
Hermès Bélusca-Maïto
2013-07-06 15:59:28 +00:00
parent f77cf0c5fc
commit 72badc4dd2
6 changed files with 107 additions and 118 deletions
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/coninput.c
* PROJECT: ReactOS Console Driver DLL
* FILE: win32ss/user/consrv/condrv/coninput.c
* PURPOSE: Console Input functions
* PROGRAMMERS: Jeffrey Morlan
* Hermes Belusca-Maito ([email protected])
@@ -200,7 +200,7 @@ ConDrvProcessKey(IN PCONSOLE Console,
}
/* PUBLIC SERVER APIS *********************************************************/
/* PUBLIC DRIVER APIS *********************************************************/
NTSTATUS NTAPI
ConDrvReadConsole(IN PCONSOLE Console,
@@ -1,6 +1,6 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* PROJECT: ReactOS Console Driver DLL
* FILE: win32ss/user/consrv/condrv/conoutput.c
* PURPOSE: General Console Output Functions
* PROGRAMMERS: Jeffrey Morlan
@@ -184,7 +184,7 @@ ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
return (Console ? Console->ActiveBuffer : NULL);
}
/* PUBLIC SERVER APIS *********************************************************/
/* PUBLIC DRIVER APIS *********************************************************/
NTSTATUS NTAPI
ConDrvInvalidateBitMapRect(IN PCONSOLE Console,
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/graphics.c
* PROJECT: ReactOS Console Driver DLL
* FILE: win32ss/user/consrv/condrv/graphics.c
* PURPOSE: Console Output Functions for graphics-mode screen-buffers
* PROGRAMMERS: Hermes Belusca-Maito ([email protected])
*
+47 -3
View File
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/text.c
* PROJECT: ReactOS Console Driver DLL
* FILE: win32ss/user/consrv/condrv/text.c
* PURPOSE: Console Output Functions for text-mode screen-buffers
* PROGRAMMERS: Jeffrey Morlan
* Hermes Belusca-Maito ([email protected])
@@ -592,7 +592,7 @@ ConioWriteConsole(PCONSOLE Console,
}
/* PUBLIC SERVER APIS *********************************************************/
/* PUBLIC DRIVER APIS *********************************************************/
NTSTATUS NTAPI
ConDrvReadConsoleOutput(IN PCONSOLE Console,
@@ -1299,4 +1299,48 @@ ConDrvScrollConsoleScreenBuffer(IN PCONSOLE Console,
return STATUS_SUCCESS;
}
NTSTATUS NTAPI
ConDrvSetConsoleWindowInfo(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,
IN BOOLEAN Absolute,
IN PSMALL_RECT WindowRect)
{
SMALL_RECT CapturedWindowRect;
if (Console == NULL || Buffer == NULL || WindowRect == NULL)
return STATUS_INVALID_PARAMETER;
/* Validity check */
ASSERT(Console == Buffer->Header.Console);
CapturedWindowRect = *WindowRect;
if (Absolute == FALSE)
{
/* Relative positions given. Transform them to absolute ones */
CapturedWindowRect.Left += Buffer->ViewOrigin.X;
CapturedWindowRect.Top += Buffer->ViewOrigin.Y;
CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
}
/* See MSDN documentation on SetConsoleWindowInfo about the performed checks */
if ( (CapturedWindowRect.Left < 0) || (CapturedWindowRect.Top < 0) ||
(CapturedWindowRect.Right >= Buffer->ScreenBufferSize.X) ||
(CapturedWindowRect.Bottom >= Buffer->ScreenBufferSize.Y) ||
(CapturedWindowRect.Right <= CapturedWindowRect.Left) ||
(CapturedWindowRect.Bottom <= CapturedWindowRect.Top) )
{
return STATUS_INVALID_PARAMETER;
}
Buffer->ViewOrigin.X = CapturedWindowRect.Left;
Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1;
Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1;
return STATUS_SUCCESS;
}
/* EOF */
+20 -38
View File
@@ -756,56 +756,38 @@ CSR_API(SrvScrollConsoleScreenBuffer)
return Status;
}
NTSTATUS NTAPI
ConDrvSetConsoleWindowInfo(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,
IN BOOLEAN Absolute,
IN PSMALL_RECT WindowRect);
CSR_API(SrvSetConsoleWindowInfo)
{
NTSTATUS Status;
PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest;
PCONSOLE_SCREEN_BUFFER Buff;
SMALL_RECT WindowRect = SetWindowInfoRequest->WindowRect;
// PCONSOLE_SCREEN_BUFFER Buffer;
PTEXTMODE_SCREEN_BUFFER Buffer;
DPRINT("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n",
DPRINT1("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n",
SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute,
WindowRect.Left, WindowRect.Top, WindowRect.Right, WindowRect.Bottom);
SetWindowInfoRequest->WindowRect.Left ,
SetWindowInfoRequest->WindowRect.Top ,
SetWindowInfoRequest->WindowRect.Right,
SetWindowInfoRequest->WindowRect.Bottom);
// ConSrvGetScreenBuffer
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetWindowInfoRequest->OutputHandle,
&Buff,
GENERIC_READ,
TRUE);
&Buffer, GENERIC_READ, TRUE);
if (!NT_SUCCESS(Status)) return Status;
if (SetWindowInfoRequest->Absolute == FALSE)
{
/* Relative positions given. Transform them to absolute ones */
WindowRect.Left += Buff->ViewOrigin.X;
WindowRect.Top += Buff->ViewOrigin.Y;
WindowRect.Right += Buff->ViewOrigin.X + Buff->ViewSize.X - 1;
WindowRect.Bottom += Buff->ViewOrigin.Y + Buff->ViewSize.Y - 1;
}
Status = ConDrvSetConsoleWindowInfo(Buffer->Header.Console,
Buffer,
SetWindowInfoRequest->Absolute,
&SetWindowInfoRequest->WindowRect);
/* See MSDN documentation on SetConsoleWindowInfo about the performed checks */
if ( (WindowRect.Left < 0) || (WindowRect.Top < 0) ||
(WindowRect.Right >= Buff->ScreenBufferSize.X) ||
(WindowRect.Bottom >= Buff->ScreenBufferSize.Y) ||
(WindowRect.Right <= WindowRect.Left) ||
(WindowRect.Bottom <= WindowRect.Top) )
{
ConSrvReleaseScreenBuffer(Buff, TRUE);
return STATUS_INVALID_PARAMETER;
}
Buff->ViewOrigin.X = WindowRect.Left;
Buff->ViewOrigin.Y = WindowRect.Top;
Buff->ViewSize.X = WindowRect.Right - WindowRect.Left + 1;
Buff->ViewSize.Y = WindowRect.Bottom - WindowRect.Top + 1;
ConSrvReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
ConSrvReleaseScreenBuffer(Buffer, TRUE);
return Status;
}
/* EOF */
@@ -143,6 +143,32 @@ const COLORREF s_Colors[16] =
/* FUNCTIONS ******************************************************************/
static VOID
GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer,
IN PGUI_CONSOLE_DATA GuiData,
OUT PUINT WidthUnit,
OUT PUINT HeightUnit)
{
if (Buffer == NULL || GuiData == NULL ||
WidthUnit == NULL || HeightUnit == NULL)
{
return;
}
if (GetType(Buffer) == TEXTMODE_BUFFER)
{
*WidthUnit = GuiData->CharWidth ;
*HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
{
*WidthUnit = 1;
*HeightUnit = 1;
}
}
static VOID
GuiConsoleAppendMenuItems(HMENU hMenu,
const GUICONSOLE_MENUITEM *Items)
@@ -374,16 +400,7 @@ GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
DWORD Width, Height;
UINT WidthUnit, HeightUnit;
if (GetType(Buff) == TEXTMODE_BUFFER)
{
WidthUnit = GuiData->CharWidth ;
HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
{
WidthUnit = 1;
HeightUnit = 1;
}
GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
Width = Buff->ViewSize.X * WidthUnit +
2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
@@ -576,16 +593,7 @@ SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
PCONSOLE_SCREEN_BUFFER Buffer = ConDrvGetActiveScreenBuffer(Console);
UINT WidthUnit, HeightUnit;
if (GetType(Buffer) == TEXTMODE_BUFFER)
{
WidthUnit = GuiData->CharWidth ;
HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
{
WidthUnit = 1;
HeightUnit = 1;
}
GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
Rect->left = (SmallRect->Left - Buffer->ViewOrigin.X) * WidthUnit ;
Rect->top = (SmallRect->Top - Buffer->ViewOrigin.Y) * HeightUnit;
@@ -1061,16 +1069,7 @@ PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
COORD Coord;
UINT WidthUnit, HeightUnit;
if (GetType(Buffer) == TEXTMODE_BUFFER)
{
WidthUnit = GuiData->CharWidth ;
HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
{
WidthUnit = 1;
HeightUnit = 1;
}
GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
Coord.X = Buffer->ViewOrigin.X + ((SHORT)LOWORD(lParam) / (int)WidthUnit );
Coord.Y = Buffer->ViewOrigin.Y + ((SHORT)HIWORD(lParam) / (int)HeightUnit);
@@ -1400,16 +1399,7 @@ GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
{
WidthUnit = GuiData->CharWidth ;
HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
{
WidthUnit = 1;
HeightUnit = 1;
}
GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
windx = CONGUI_MIN_WIDTH * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
windy = CONGUI_MIN_HEIGHT * HeightUnit + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION);
@@ -1443,16 +1433,7 @@ GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
DWORD windx, windy, charx, chary;
UINT WidthUnit, HeightUnit;
if (GetType(Buff) == TEXTMODE_BUFFER)
{
WidthUnit = GuiData->CharWidth ;
HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
{
WidthUnit = 1;
HeightUnit = 1;
}
GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
GuiData->WindowSizeLock = TRUE;
@@ -1615,16 +1596,7 @@ GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
*pShowXY = sInfo.nPos;
if (GetType(Buff) == TEXTMODE_BUFFER)
{
WidthUnit = GuiData->CharWidth ;
HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
{
WidthUnit = 1;
HeightUnit = 1;
}
GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
ScrollWindowEx(GuiData->hWindow,
(OldX - Buff->ViewOrigin.X) * WidthUnit ,
@@ -2684,16 +2656,7 @@ GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console);
if (ActiveBuffer)
{
if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
{
WidthUnit = GuiData->CharWidth ;
HeightUnit = GuiData->CharHeight;
}
else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
{
WidthUnit = 1;
HeightUnit = 1;
}
GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
}
else
{