Author: hbelusca
Date: Tue Oct 18 17:16:57 2016
New Revision: 72984
URL: http://svn.reactos.org/svn/reactos?rev=72984&view=rev
Log:
[CONSRV]: Fixes for SetConsoleWindowInfo, where one notices that again the MSDN documentation on SetConsoleWindowInfo is partially wrong.
This makes all the kernel32_apitest:SetConsoleWindowInfo tests pass now.
Also, notify the console window about the size change.
Modified:
trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] Tue Oct 18 17:16:57 2016
@@ -1225,7 +1225,7 @@
CapturedWindowRect = *WindowRect;
- if (Absolute == FALSE)
+ if (!Absolute)
{
/* Relative positions given. Transform them to absolute ones */
CapturedWindowRect.Left += Buffer->ViewOrigin.X;
@@ -1234,12 +1234,34 @@
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) )
+ /*
+ * The MSDN documentation on SetConsoleWindowInfo is partially wrong about
+ * the performed checks this API performs. While it is correct that the
+ * 'Right'/'Bottom' members cannot be strictly smaller than the 'Left'/'Top'
+ * members, they can be equal.
+ * Also, if the 'Left' or 'Top' members are negative, this is automatically
+ * corrected for, and the window rectangle coordinates are shifted accordingly.
+ */
+ if ((CapturedWindowRect.Right < CapturedWindowRect.Left) ||
+ (CapturedWindowRect.Bottom < CapturedWindowRect.Top))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Shift the window rectangle coordinates if 'Left' or 'Top' are negative */
+ if (CapturedWindowRect.Left < 0)
+ {
+ CapturedWindowRect.Right -= CapturedWindowRect.Left;
+ CapturedWindowRect.Left = 0;
+ }
+ if (CapturedWindowRect.Top < 0)
+ {
+ CapturedWindowRect.Bottom -= CapturedWindowRect.Top;
+ CapturedWindowRect.Top = 0;
+ }
+
+ if ((CapturedWindowRect.Right >= Buffer->ScreenBufferSize.X) ||
+ (CapturedWindowRect.Bottom >= Buffer->ScreenBufferSize.Y))
{
return STATUS_INVALID_PARAMETER;
}
@@ -1250,7 +1272,7 @@
Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1;
Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1;
- // TermResizeTerminal(Console);
+ TermResizeTerminal(Console);
return STATUS_SUCCESS;
}