Author: jmorlan
Date: Tue Jul 29 11:10:38 2008
New Revision: 34928
URL:
http://svn.reactos.org/svn/reactos?rev=34928&view=rev
Log:
- Remove unused hVScrollBar and hHScrollBar members in GUI_CONSOLE_DATA.
- Remove ScreenBufferSize member from GUI_CONSOLE_DATA; when building the structure for
console.dll, send the actual screen buffer size instead.
- GuiConsolePaint, GuiIntDrawRegion: Adjust coordinates based on buffer's scroll
position.
- GuiConsolePaint: Use ConioCoordToPointer when finding attribute at top-left.
- GuiConsoleHandlePaint: Don't leak the DC when the paint rectangle is empty.
- GuiConsoleHandleScroll: Actually update the buffer's scroll position, not just the
scrollbar's. Allow scrolling either horizontally or vertically. Fix typo in
SB_THUMBTRACK case. Don't rely on GetScrollInfo for bound checking - any thread can
sabotage the scrollbar ranges.
- CsrGetScreenBufferInfo: Return the visible area in srWindow.
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Tue Jul 29 11:10:38
2008
@@ -1292,6 +1292,7 @@
CSR_API(CsrGetScreenBufferInfo)
{
NTSTATUS Status;
+ PCSRSS_CONSOLE Console;
PCSRSS_SCREEN_BUFFER Buff;
PCONSOLE_SCREEN_BUFFER_INFO pInfo;
@@ -1300,9 +1301,15 @@
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
+ Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (! NT_SUCCESS(Status))
+ {
+ return Request->Status = Status;
+ }
Status = ConioLockScreenBuffer(ProcessData,
Request->Data.ScreenBufferInfoRequest.ConsoleHandle, &Buff, GENERIC_READ);
if (! NT_SUCCESS(Status))
{
+ ConioUnlockConsole(Console);
return Request->Status = Status;
}
pInfo = &Request->Data.ScreenBufferInfoRequest.Info;
@@ -1311,13 +1318,14 @@
pInfo->dwCursorPosition.X = Buff->CurrentX;
pInfo->dwCursorPosition.Y = Buff->CurrentY;
pInfo->wAttributes = Buff->DefaultAttrib;
- pInfo->srWindow.Left = 0;
- pInfo->srWindow.Right = Buff->MaxX - 1;
- pInfo->srWindow.Top = 0;
- pInfo->srWindow.Bottom = Buff->MaxY - 1;
+ pInfo->srWindow.Left = Buff->ShowX;
+ pInfo->srWindow.Right = Buff->ShowX + Console->Size.X - 1;
+ pInfo->srWindow.Top = Buff->ShowY;
+ pInfo->srWindow.Bottom = Buff->ShowY + Console->Size.Y - 1;
pInfo->dwMaximumWindowSize.X = Buff->MaxX;
pInfo->dwMaximumWindowSize.Y = Buff->MaxY;
ConioUnlockScreenBuffer(Buff);
+ ConioUnlockConsole(Console);
Request->Status = STATUS_SUCCESS;
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] Tue Jul 29
11:10:38 2008
@@ -32,8 +32,6 @@
BOOL MouseDown;
HMODULE ConsoleLibrary;
HANDLE hGuiInitEvent;
- HWND hVScrollBar;
- HWND hHScrollBar;
WCHAR FontName[LF_FACESIZE];
DWORD FontSize;
DWORD FontWeight;
@@ -44,7 +42,6 @@
DWORD NumberOfHistoryBuffers;
DWORD HistoryBufferSize;
DWORD WindowPosition;
- DWORD ScreenBufferSize;
DWORD UseRasterFonts;
COLORREF ScreenText;
COLORREF ScreenBackground;
@@ -620,7 +617,6 @@
GuiData->PopupText = RGB(128, 0, 128);
GuiData->PopupBackground = RGB(255, 255, 255);
GuiData->WindowPosition = UINT_MAX;
- GuiData->ScreenBufferSize = MAKELONG(80, 300); //FIXME
GuiData->UseRasterFonts = TRUE;
memcpy(GuiData->Colors, s_Colors, sizeof(s_Colors));
@@ -868,16 +864,16 @@
Buff = Console->ActiveBuffer;
- TopLine = rc->top / GuiData->CharHeight;
- BottomLine = (rc->bottom + (GuiData->CharHeight - 1)) / GuiData->CharHeight
- 1;
- LeftChar = rc->left / GuiData->CharWidth;
- RightChar = (rc->right + (GuiData->CharWidth - 1)) / GuiData->CharWidth -
1;
- LastAttribute = Buff->Buffer[(TopLine * Buff->MaxX + LeftChar) * 2 + 1];
+ EnterCriticalSection(&Buff->Header.Lock);
+
+ TopLine = rc->top / GuiData->CharHeight + Buff->ShowY;
+ BottomLine = (rc->bottom + (GuiData->CharHeight - 1)) / GuiData->CharHeight
- 1 + Buff->ShowY;
+ LeftChar = rc->left / GuiData->CharWidth + Buff->ShowX;
+ RightChar = (rc->right + (GuiData->CharWidth - 1)) / GuiData->CharWidth - 1
+ Buff->ShowX;
+ LastAttribute = ConioCoordToPointer(Buff, LeftChar, TopLine)[1];
SetTextColor(hDC, GuiConsoleRGBFromAttribute(GuiData, LastAttribute));
SetBkColor(hDC, GuiConsoleRGBFromAttribute(GuiData, LastAttribute >> 4));
-
- EnterCriticalSection(&Buff->Header.Lock);
if (BottomLine >= Buff->MaxY) BottomLine = Buff->MaxY - 1;
if (RightChar >= Buff->MaxX) RightChar = Buff->MaxX - 1;
@@ -896,8 +892,8 @@
if (*(From + 1) != LastAttribute)
{
TextOutW(hDC,
- Start * GuiData->CharWidth,
- Line * GuiData->CharHeight,
+ (Start - Buff->ShowX) * GuiData->CharWidth,
+ (Line - Buff->ShowY) * GuiData->CharHeight,
GuiData->LineBuffer,
Char - Start);
Start = Char;
@@ -922,8 +918,8 @@
}
TextOutW(hDC,
- Start * GuiData->CharWidth,
- Line * GuiData->CharHeight,
+ (Start - Buff->ShowX) * GuiData->CharWidth,
+ (Line - Buff->ShowY) * GuiData->CharHeight,
GuiData->LineBuffer,
RightChar - Start + 1);
}
@@ -955,8 +951,8 @@
OldBrush = SelectObject(hDC,
CursorBrush);
PatBlt(hDC,
- CursorX * GuiData->CharWidth,
- CursorY * GuiData->CharHeight + (GuiData->CharHeight -
CursorHeight),
+ (CursorX - Buff->ShowX) * GuiData->CharWidth,
+ (CursorY - Buff->ShowY) * GuiData->CharHeight +
(GuiData->CharHeight - CursorHeight),
GuiData->CharWidth,
CursorHeight,
PATCOPY);
@@ -1027,8 +1023,8 @@
}
}
- EndPaint(hWnd, &ps);
- }
+ }
+ EndPaint(hWnd, &ps);
}
static VOID FASTCALL
@@ -1054,14 +1050,14 @@
}
static VOID FASTCALL
-GuiIntDrawRegion(PGUI_CONSOLE_DATA GuiData, HWND Wnd, RECT *Region)
+GuiIntDrawRegion(PCSRSS_SCREEN_BUFFER Buff, PGUI_CONSOLE_DATA GuiData, HWND Wnd, RECT
*Region)
{
RECT RegionRect;
- RegionRect.left = Region->left * GuiData->CharWidth;
- RegionRect.top = Region->top * GuiData->CharHeight;
- RegionRect.right = (Region->right + 1) * GuiData->CharWidth;
- RegionRect.bottom = (Region->bottom + 1) * GuiData->CharHeight;
+ RegionRect.left = (Region->left - Buff->ShowX) * GuiData->CharWidth;
+ RegionRect.top = (Region->top - Buff->ShowY) * GuiData->CharHeight;
+ RegionRect.right = (Region->right + 1 - Buff->ShowX) * GuiData->CharWidth;
+ RegionRect.bottom = (Region->bottom + 1 - Buff->ShowY) * GuiData->CharHeight;
InvalidateRect(Wnd, &RegionRect, FALSE);
}
@@ -1073,12 +1069,12 @@
if (NULL != Console->hWindow && NULL != GuiData)
{
- GuiIntDrawRegion(GuiData, Console->hWindow, Region);
+ GuiIntDrawRegion(Console->ActiveBuffer, GuiData, Console->hWindow, Region);
}
}
static VOID FASTCALL
-GuiInvalidateCell(PGUI_CONSOLE_DATA GuiData, HWND Wnd, UINT x, UINT y)
+GuiInvalidateCell(PCSRSS_SCREEN_BUFFER Buff, PGUI_CONSOLE_DATA GuiData, HWND Wnd, UINT x,
UINT y)
{
RECT CellRect;
@@ -1087,7 +1083,7 @@
CellRect.right = x;
CellRect.bottom = y;
- GuiIntDrawRegion(GuiData, Wnd, &CellRect);
+ GuiIntDrawRegion(Buff, GuiData, Wnd, &CellRect);
}
static VOID STDCALL
@@ -1140,12 +1136,12 @@
SW_INVALIDATE);
}
- GuiIntDrawRegion(GuiData, Console->hWindow, Region);
+ GuiIntDrawRegion(Buff, GuiData, Console->hWindow, Region);
if (CursorStartX < Region->left || Region->right < CursorStartX
|| CursorStartY < Region->top || Region->bottom < CursorStartY)
{
- GuiInvalidateCell(GuiData, Console->hWindow, CursorStartX, CursorStartY);
+ GuiInvalidateCell(Buff, GuiData, Console->hWindow, CursorStartX, CursorStartY);
}
CursorEndX = Buff->CurrentX;
@@ -1154,7 +1150,7 @@
|| CursorEndY < Region->top || Region->bottom < CursorEndY)
&& (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
{
- GuiInvalidateCell(GuiData, Console->hWindow, CursorEndX, CursorEndY);
+ GuiInvalidateCell(Buff, GuiData, Console->hWindow, CursorEndX, CursorEndY);
}
}
@@ -1463,7 +1459,7 @@
SharedInfo.PopupBackground = GuiData->PopupBackground;
SharedInfo.WindowSize = (DWORD)MAKELONG(Console->Size.X, Console->Size.Y);
SharedInfo.WindowPosition = GuiData->WindowPosition;
- SharedInfo.ScreenBuffer = GuiData->ScreenBufferSize;
+ SharedInfo.ScreenBuffer = (DWORD)MAKELONG(Console->ActiveBuffer->MaxX,
Console->ActiveBuffer->MaxY);
SharedInfo.UseRasterFonts = GuiData->UseRasterFonts;
SharedInfo.FontSize = (DWORD)GuiData->FontSize;
SharedInfo.FontWeight = GuiData->FontWeight;
@@ -1687,18 +1683,39 @@
static
LRESULT
-GuiConsoleHandleScroll(HWND hwnd, UINT uMsg, WPARAM wParam, PGUI_CONSOLE_DATA GuiData)
-{
+GuiConsoleHandleScroll(HWND hwnd, UINT uMsg, WPARAM wParam)
+{
+ PCSRSS_CONSOLE Console;
+ PCSRSS_SCREEN_BUFFER Buff;
+ PGUI_CONSOLE_DATA GuiData;
SCROLLINFO sInfo;
- int old_pos;
+ int fnBar;
+ int old_pos, Maximum;
+ PUSHORT pShowXY;
+
+ GuiConsoleGetDataPointers(hwnd, &Console, &GuiData);
+ if (Console == NULL || GuiData == NULL)
+ return FALSE;
+ Buff = Console->ActiveBuffer;
+
+ if (uMsg == WM_HSCROLL)
+ {
+ fnBar = SB_HORZ;
+ Maximum = Buff->MaxX - Console->Size.X;
+ pShowXY = &Buff->ShowX;
+ }
+ else
+ {
+ fnBar = SB_VERT;
+ Maximum = Buff->MaxY - Console->Size.Y;
+ pShowXY = &Buff->ShowY;
+ }
/* set scrollbar sizes */
sInfo.cbSize = sizeof(SCROLLINFO);
sInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_TRACKPOS;
- if (!GetScrollInfo(hwnd,
- (uMsg == WM_HSCROLL ? SB_HORZ : SB_VERT),
- &sInfo))
+ if (!GetScrollInfo(hwnd, fnBar, &sInfo))
{
return FALSE;
}
@@ -1724,7 +1741,7 @@
break;
case SB_THUMBTRACK:
- sInfo.nPage = sInfo.nTrackPos;
+ sInfo.nPos = sInfo.nTrackPos;
break;
case SB_TOP:
@@ -1739,38 +1756,26 @@
break;
}
- sInfo.fMask = SIF_POS;
- sInfo.cbSize = sizeof(SCROLLINFO);
-
- SetScrollInfo(hwnd,
- (uMsg == WM_HSCROLL ? SB_HORZ : SB_VERT),
- &sInfo,
- TRUE);
-
- sInfo.cbSize = sizeof(SCROLLINFO);
- sInfo.fMask = SIF_POS;
-
- if (!GetScrollInfo(hwnd,
- (uMsg == WM_HSCROLL ? SB_HORZ : SB_VERT),
- &sInfo))
- {
- return 0;
- }
+ sInfo.nPos = max(sInfo.nPos, 0);
+ sInfo.nPos = min(sInfo.nPos, Maximum);
if (old_pos != sInfo.nPos)
{
- ///
- /// fixme scroll window
- ///
+ USHORT OldX = Buff->ShowX;
+ USHORT OldY = Buff->ShowY;
+ *pShowXY = sInfo.nPos;
ScrollWindowEx(hwnd,
- 0,
- GuiData->CharHeight * (old_pos - sInfo.nPos),
+ (OldX - Buff->ShowX) * GuiData->CharWidth,
+ (OldY - Buff->ShowY) * GuiData->CharHeight,
NULL,
NULL,
NULL,
NULL,
SW_INVALIDATE);
+
+ sInfo.fMask = SIF_POS;
+ SetScrollInfo(hwnd, fnBar, &sInfo, TRUE);
UpdateWindow(hwnd);
}
@@ -1827,7 +1832,7 @@
break;
case WM_HSCROLL:
case WM_VSCROLL:
- Result = GuiConsoleHandleScroll(hWnd, msg, wParam, GuiData);
+ Result = GuiConsoleHandleScroll(hWnd, msg, wParam);
break;
case WM_SIZE:
GuiConsoleResize(hWnd, wParam, lParam);