Author: hbelusca
Date: Wed Apr 16 22:25:29 2014
New Revision: 62760
URL:
http://svn.reactos.org/svn/reactos?rev=62760&view=rev
Log:
[KERNEL32]
Fix a DPRINT.
[CONSRV]
Some code reorganization and few fixes.
Modified:
trunk/reactos/dll/win32/kernel32/client/console/init.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
Modified: trunk/reactos/dll/win32/kernel32/client/console/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/console/init.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/console/init.c [iso-8859-1] Wed Apr 16
22:25:29 2014
@@ -70,7 +70,7 @@
if (ConsoleLibrary == NULL)
{
- DPRINT1("Failed to load console.dll");
+ DPRINT1("Failed to load console.dll\n");
AlreadyDisplayingProps = FALSE;
return STATUS_UNSUCCESSFUL;
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1] Wed Apr
16 22:25:29 2014
@@ -200,8 +200,8 @@
}
static VOID
-GuiConsoleAppendMenuItems(HMENU hMenu,
- const GUICONSOLE_MENUITEM *Items)
+AppendMenuItems(HMENU hMenu,
+ const GUICONSOLE_MENUITEM *Items)
{
UINT i = 0;
WCHAR szMenuString[255];
@@ -221,8 +221,7 @@
hSubMenu = CreatePopupMenu();
if (hSubMenu != NULL)
{
- GuiConsoleAppendMenuItems(hSubMenu,
- Items[i].SubMenu);
+ AppendMenuItems(hSubMenu, Items[i].SubMenu);
if (!AppendMenuW(hMenu,
MF_STRING | MF_POPUP,
@@ -254,18 +253,18 @@
}
static VOID
-GuiConsoleCreateSysMenu(HWND hWnd)
+CreateSysMenu(HWND hWnd)
{
HMENU hMenu = GetSystemMenu(hWnd, FALSE);
if (hMenu != NULL)
{
- GuiConsoleAppendMenuItems(hMenu, GuiConsoleMainMenuItems);
+ AppendMenuItems(hMenu, GuiConsoleMainMenuItems);
DrawMenuBar(hWnd);
}
}
static VOID
-GuiSendMenuEvent(PCONSOLE Console, UINT CmdId)
+SendMenuEvent(PCONSOLE Console, UINT CmdId)
{
INPUT_RECORD er;
@@ -277,27 +276,83 @@
}
static VOID
-GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData);
+Copy(PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsolePaste(PGUI_CONSOLE_DATA GuiData);
+Paste(PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord);
+UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord);
+
static VOID
-GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit);
+Mark(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
+
+ /* Clear the old selection */
+ // UpdateSelection(GuiData, NULL);
+ Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
+
+ /* Restart a new selection */
+ Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
+ Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
+ Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
+ UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor);
+}
+
+static VOID
+SelectAll(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
+
+ /* Clear the old selection */
+ // UpdateSelection(GuiData, NULL);
+ Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
+
+ /*
+ * The selection area extends to the whole screen buffer's width.
+ */
+ Console->Selection.dwSelectionAnchor.X = 0;
+ Console->Selection.dwSelectionAnchor.Y = 0;
+ Console->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
+
+ /*
+ * Determine whether the selection must extend to just some part
+ * (for text-mode screen buffers) or to all of the screen buffer's
+ * height (for graphics ones).
+ */
+ if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
+ {
+ /*
+ * We select all the characters from the first line
+ * to the line where the cursor is positioned.
+ */
+ Console->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
+ }
+ else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
+ {
+ /*
+ * We select all the screen buffer area.
+ */
+ Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
+ }
+
+ /* Restart a new selection */
+ Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION;
+ UpdateSelection(GuiData, &Console->dwSelectionCursor);
+}
static LRESULT
-GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
+OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
LRESULT Ret = TRUE;
PCONSOLE Console = GuiData->Console;
- PCONSOLE_SCREEN_BUFFER ActiveBuffer;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
Ret = FALSE;
goto Quit;
}
- ActiveBuffer = GuiData->ActiveBuffer;
/*
* In case the selected menu item belongs to the user-reserved menu id range,
@@ -306,7 +361,7 @@
*/
if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <=
GuiData->CmdIdHigh)
{
- GuiSendMenuEvent(Console, (UINT)wParam);
+ SendMenuEvent(Console, (UINT)wParam);
goto Unlock_Quit;
}
@@ -314,68 +369,20 @@
switch (wParam)
{
case ID_SYSTEM_EDIT_MARK:
- {
- /* Clear the old selection */
- // GuiConsoleUpdateSelection(Console, NULL);
- Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
-
- /* Restart a new selection */
- Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
- Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
- Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
- GuiConsoleUpdateSelection(Console,
&Console->Selection.dwSelectionAnchor);
-
- break;
- }
+ Mark(GuiData);
+ break;
case ID_SYSTEM_EDIT_COPY:
- GuiConsoleCopy(GuiData);
+ Copy(GuiData);
break;
case ID_SYSTEM_EDIT_PASTE:
- GuiConsolePaste(GuiData);
+ Paste(GuiData);
break;
case ID_SYSTEM_EDIT_SELECTALL:
- {
- /* Clear the old selection */
- // GuiConsoleUpdateSelection(Console, NULL);
- Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
-
- /*
- * The selection area extends to the whole screen buffer's width.
- */
- Console->Selection.dwSelectionAnchor.X = 0;
- Console->Selection.dwSelectionAnchor.Y = 0;
- Console->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
-
- /*
- * Determine whether the selection must extend to just some part
- * (for text-mode screen buffers) or to all of the screen buffer's
- * height (for graphics ones).
- */
- if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
- {
- /*
- * We select all the characters from the first line
- * to the line where the cursor is positioned.
- */
- Console->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
- }
- else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
- {
- /*
- * We select all the screen buffer area.
- */
- Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y -
1;
- }
-
- /* Restart a new selection */
- Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION;
- GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
-
- break;
- }
+ SelectAll(GuiData);
+ break;
case ID_SYSTEM_EDIT_SCROLL:
DPRINT1("Scrolling is not handled yet\n");
@@ -416,7 +423,7 @@
}
static VOID
-GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
+ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
{
PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
SCROLLINFO sInfo;
@@ -468,7 +475,7 @@
}
static BOOL
-GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
+OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
{
PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
PCONSOLE Console;
@@ -476,8 +483,6 @@
HFONT OldFont;
TEXTMETRICW Metrics;
SIZE CharSize;
-
- DPRINT("GuiConsoleHandleNcCreate\n");
if (NULL == GuiData)
{
@@ -556,6 +561,13 @@
GuiData->hBitmap = NULL;
GuiData->hSysPalette = NULL; /* Original system palette */
+ /* Update the icons of the window */
+ if (GuiData->hIcon != ghDefaultIcon)
+ {
+ DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_BIG ,
(LPARAM)GuiData->hIcon );
+ DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_SMALL,
(LPARAM)GuiData->hIconSm);
+ }
+
// FIXME: Keep these instructions here ? ///////////////////////////////////
Console->ActiveBuffer->CursorBlinkOn = TRUE;
Console->ActiveBuffer->ForceCursorOff = FALSE;
@@ -564,12 +576,81 @@
SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
- GuiConsoleCreateSysMenu(GuiData->hWindow);
-
- DPRINT("GuiConsoleHandleNcCreate - setting start event\n");
+ CreateSysMenu(GuiData->hWindow);
+
+ DPRINT("OnNcCreate - setting start event\n");
SetEvent(GuiData->hGuiInitEvent);
return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
+}
+
+
+BOOL
+EnterFullScreen(PGUI_CONSOLE_DATA GuiData);
+VOID
+LeaveFullScreen(PGUI_CONSOLE_DATA GuiData);
+VOID
+SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
+VOID
+GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData);
+
+static VOID
+OnActivate(PGUI_CONSOLE_DATA GuiData, WPARAM wParam)
+{
+ PCONSOLE Console = GuiData->Console;
+ WORD ActivationState = LOWORD(wParam);
+
+ DPRINT1("WM_ACTIVATE - ActivationState = %d\n");
+
+ if ( ActivationState == WA_ACTIVE ||
+ ActivationState == WA_CLICKACTIVE )
+ {
+ if (GuiData->GuiInfo.FullScreen)
+ {
+ EnterFullScreen(GuiData);
+ // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+ // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+ }
+ }
+ else // if (ActivationState == WA_INACTIVE)
+ {
+ if (GuiData->GuiInfo.FullScreen)
+ {
+ SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ LeaveFullScreen(GuiData);
+ // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ }
+ }
+
+ /*
+ * When we are in QuickEdit mode, ignore the next mouse signal
+ * when we are going to be enabled again via the mouse, in order
+ * to prevent e.g. an erroneous right-click from the user which
+ * would have as an effect to paste some unwanted text...
+ */
+ if (Console->QuickEdit && (ActivationState == WA_CLICKACTIVE))
+ GuiData->IgnoreNextMouseSignal = TRUE;
+}
+
+static VOID
+OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
+{
+ PCONSOLE Console = GuiData->Console;
+ INPUT_RECORD er;
+
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
+ er.EventType = FOCUS_EVENT;
+ er.Event.FocusEvent.bSetFocus = SetFocus;
+ ConioProcessInputEvent(Console, &er);
+
+ if (SetFocus)
+ DPRINT1("TODO: Create console caret\n");
+ else
+ DPRINT1("TODO: Destroy console caret\n");
+
+ LeaveCriticalSection(&Console->Lock);
}
static VOID
@@ -587,9 +668,9 @@
}
static VOID
-GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
-{
- PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD coord)
+{
+ PCONSOLE Console = GuiData->Console;
RECT oldRect;
SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection);
@@ -696,7 +777,7 @@
PRECT rcFramebuffer);
static VOID
-GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
+OnPaint(PGUI_CONSOLE_DATA GuiData)
{
BOOL Success = TRUE;
PCONSOLE Console = GuiData->Console;
@@ -763,6 +844,27 @@
DefWindowProcW(GuiData->hWindow, WM_PAINT, 0, 0);
return;
+}
+
+static VOID
+OnPaletteChanged(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
+
+ // See WM_PALETTECHANGED message
+ // if ((HWND)wParam == hWnd) break;
+
+ // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
+ if (ActiveBuffer->PaletteHandle)
+ {
+ DPRINT("WM_PALETTECHANGED changing palette\n");
+
+ /* Specify the use of the system palette for the framebuffer */
+ SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
+
+ /* Realize the (logical) palette */
+ RealizePalette(GuiData->hMemDC);
+ }
}
static BOOL
@@ -789,7 +891,7 @@
}
static VOID
-GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
+OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
@@ -807,14 +909,14 @@
if (VirtualKeyCode == VK_RETURN)
{
/* Copy (and clear) selection if ENTER is pressed */
- GuiConsoleCopy(GuiData);
+ Copy(GuiData);
goto Quit;
}
else if ( VirtualKeyCode == VK_ESCAPE ||
(VirtualKeyCode == 'C' && GetKeyState(VK_CONTROL) &
0x8000) )
{
/* Cancel selection if ESC or Ctrl-C are pressed */
- GuiConsoleUpdateSelection(Console, NULL);
+ UpdateSelection(GuiData, NULL);
goto Quit;
}
@@ -906,7 +1008,7 @@
if (!MajPressed)
Console->Selection.dwSelectionAnchor =
Console->dwSelectionCursor;
- GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
+ UpdateSelection(GuiData, &Console->dwSelectionCursor);
}
else if (!IsSystemKey(VirtualKeyCode))
{
@@ -923,7 +1025,7 @@
if (!IsSystemKey(VirtualKeyCode))
{
/* Clear the selection and send the key into the input buffer */
- GuiConsoleUpdateSelection(Console, NULL);
+ UpdateSelection(GuiData, NULL);
}
else
{
@@ -949,12 +1051,13 @@
}
-// FIXME: Remove after fixing GuiConsoleHandleTimer
+// FIXME: Remove after fixing OnTimer
VOID
-GuiInvalidateCell(IN OUT PFRONTEND This, SHORT x, SHORT y);
+InvalidateCell(PGUI_CONSOLE_DATA GuiData,
+ SHORT x, SHORT y);
static VOID
-GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
+OnTimer(PGUI_CONSOLE_DATA GuiData)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
@@ -967,7 +1070,7 @@
if (GetType(Buff) == TEXTMODE_BUFFER)
{
- GuiInvalidateCell(&Console->TermIFace, Buff->CursorPosition.X,
Buff->CursorPosition.Y);
+ InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
if ((GuiData->OldCursor.x != Buff->CursorPosition.X) ||
@@ -1059,7 +1162,7 @@
}
static BOOL
-GuiConsoleHandleClose(PGUI_CONSOLE_DATA GuiData)
+OnClose(PGUI_CONSOLE_DATA GuiData)
{
PCONSOLE Console = GuiData->Console;
@@ -1080,7 +1183,7 @@
}
static LRESULT
-GuiConsoleHandleNcDestroy(HWND hWnd)
+OnNcDestroy(HWND hWnd)
{
PGUI_CONSOLE_DATA GuiData = GuiGetGuiData(hWnd);
@@ -1129,7 +1232,7 @@
}
static LRESULT
-GuiConsoleHandleMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
+OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL Err = FALSE;
PCONSOLE Console = GuiData->Console;
@@ -1172,14 +1275,14 @@
case WM_LBUTTONDOWN:
{
/* Clear the old selection */
- // GuiConsoleUpdateSelection(Console, NULL);
+ // UpdateSelection(GuiData, NULL);
Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
/* Restart a new selection */
Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
SetCapture(GuiData->hWindow);
Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION |
CONSOLE_MOUSE_DOWN;
- GuiConsoleUpdateSelection(Console,
&Console->Selection.dwSelectionAnchor);
+ UpdateSelection(GuiData, &Console->Selection.dwSelectionAnchor);
break;
}
@@ -1192,7 +1295,7 @@
// c = PointToCoord(GuiData, lParam);
Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
- // GuiConsoleUpdateSelection(Console, &c);
+ // UpdateSelection(GuiData, &c);
ReleaseCapture();
break;
@@ -1241,7 +1344,7 @@
Console->dwSelectionCursor = cR;
Console->Selection.dwFlags |= CONSOLE_MOUSE_SELECTION |
CONSOLE_MOUSE_DOWN;
- GuiConsoleUpdateSelection(Console,
&Console->dwSelectionCursor);
+ UpdateSelection(GuiData, &Console->dwSelectionCursor);
/* Ignore the next mouse move signal */
GuiData->IgnoreNextMouseSignal = TRUE;
@@ -1255,11 +1358,11 @@
{
if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
{
- GuiConsolePaste(GuiData);
+ Paste(GuiData);
}
else
{
- GuiConsoleCopy(GuiData);
+ Copy(GuiData);
}
/* Ignore the next mouse move signal */
@@ -1275,7 +1378,7 @@
if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into
view */
- GuiConsoleUpdateSelection(Console, &c);
+ UpdateSelection(GuiData, &c);
break;
}
@@ -1426,10 +1529,8 @@
PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
-{
- PCONSOLE Console = GuiData->Console;
-
+Copy(PGUI_CONSOLE_DATA GuiData)
+{
if (OpenClipboard(GuiData->hWindow) == TRUE)
{
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
@@ -1447,7 +1548,7 @@
}
/* Clear the selection */
- GuiConsoleUpdateSelection(Console, NULL);
+ UpdateSelection(GuiData, NULL);
}
VOID
@@ -1458,7 +1559,7 @@
PGUI_CONSOLE_DATA GuiData);
static VOID
-GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
+Paste(PGUI_CONSOLE_DATA GuiData)
{
if (OpenClipboard(GuiData->hWindow) == TRUE)
{
@@ -1478,7 +1579,7 @@
}
static VOID
-GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
+OnGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
@@ -1510,7 +1611,7 @@
}
static VOID
-GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
+OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
PCONSOLE Console = GuiData->Console;
@@ -1559,7 +1660,7 @@
Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary :
Buff->ScreenBufferSize.Y;
}
- GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
+ ResizeConWnd(GuiData, WidthUnit, HeightUnit);
// Adjust the start of the visible area if we are attempting to show nonexistent
areas
if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) <
Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X -
Buff->ViewSize.X;
@@ -1568,6 +1669,25 @@
GuiData->WindowSizeLock = FALSE;
}
+
+ LeaveCriticalSection(&Console->Lock);
+}
+
+static VOID
+OnMove(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+ RECT rcWnd;
+
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
+ // TODO: Simplify the code.
+ // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
+
+ /* Retrieve our real position */
+ GetWindowRect(GuiData->hWindow, &rcWnd);
+ GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
+ GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
LeaveCriticalSection(&Console->Lock);
}
@@ -1602,7 +1722,7 @@
*/
static LRESULT
-GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
+OnScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
{
PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
@@ -1710,15 +1830,6 @@
}
-BOOL
-EnterFullScreen(PGUI_CONSOLE_DATA GuiData);
-VOID
-LeaveFullScreen(PGUI_CONSOLE_DATA GuiData);
-VOID
-SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
-VOID
-GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData);
-
static LRESULT CALLBACK
ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -1734,11 +1845,11 @@
*/
if (msg == WM_NCCREATE)
{
- return (LRESULT)GuiConsoleHandleNcCreate(hWnd, (LPCREATESTRUCTW)lParam);
+ return (LRESULT)OnNcCreate(hWnd, (LPCREATESTRUCTW)lParam);
}
else if (msg == WM_NCDESTROY)
{
- return GuiConsoleHandleNcDestroy(hWnd);
+ return OnNcDestroy(hWnd);
}
/*
@@ -1763,60 +1874,23 @@
switch (msg)
{
case WM_ACTIVATE:
- {
- WORD ActivationState = LOWORD(wParam);
-
- DPRINT1("WM_ACTIVATE - ActivationState = %d\n");
-
- if ( ActivationState == WA_ACTIVE ||
- ActivationState == WA_CLICKACTIVE )
- {
- if (GuiData->GuiInfo.FullScreen)
- {
- EnterFullScreen(GuiData);
- // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE,
0);
- // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
- }
- }
- else // if (ActivationState == WA_INACTIVE)
- {
- if (GuiData->GuiInfo.FullScreen)
- {
- SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
- LeaveFullScreen(GuiData);
- // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE,
0);
- // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
- }
- }
-
- /*
- * When we are in QuickEdit mode, ignore the next mouse signal
- * when we are going to be enabled again via the mouse, in order
- * to prevent e.g. an erroneous right-click from the user which
- * would have as an effect to paste some unwanted text...
- */
- if (Console->QuickEdit && (ActivationState == WA_CLICKACTIVE))
- GuiData->IgnoreNextMouseSignal = TRUE;
-
- break;
- }
+ OnActivate(GuiData, wParam);
+ break;
case WM_CLOSE:
- if (GuiConsoleHandleClose(GuiData)) goto Default;
+ if (OnClose(GuiData)) goto Default;
break;
case WM_PAINT:
- GuiConsoleHandlePaint(GuiData);
+ OnPaint(GuiData);
break;
case WM_TIMER:
- GuiConsoleHandleTimer(GuiData);
+ OnTimer(GuiData);
break;
case WM_PALETTECHANGED:
{
- PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
-
DPRINT("WM_PALETTECHANGED called\n");
/*
@@ -1835,21 +1909,8 @@
if ((HWND)wParam == hWnd) break;
DPRINT("WM_PALETTECHANGED ok\n");
-
- // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
- if (ActiveBuffer->PaletteHandle)
- {
- DPRINT("WM_PALETTECHANGED changing palette\n");
-
- /* Specify the use of the system palette for the framebuffer */
- SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
-
- /* Realize the (logical) palette */
- RealizePalette(GuiData->hMemDC);
- }
-
+ OnPaletteChanged(GuiData);
DPRINT("WM_PALETTECHANGED quit\n");
-
break;
}
@@ -1872,7 +1933,7 @@
break;
}
- GuiConsoleHandleKey(GuiData, msg, wParam, lParam);
+ OnKey(GuiData, msg, wParam, lParam);
break;
}
@@ -1937,40 +1998,16 @@
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
{
- Result = GuiConsoleHandleMouse(GuiData, msg, wParam, lParam);
+ Result = OnMouse(GuiData, msg, wParam, lParam);
break;
}
case WM_HSCROLL:
case WM_VSCROLL:
{
- Result = GuiConsoleHandleScroll(GuiData, msg, wParam);
- break;
- }
-
- case WM_NCRBUTTONDOWN:
- {
- DPRINT1("WM_NCRBUTTONDOWN\n");
- /*
- * HACK: !! Because, when we deal with WM_RBUTTON* and we do not
- * call after that DefWindowProc, on ReactOS, right-clicks on the
- * (non-client) application title-bar does not display the system
- * menu and does not trigger a WM_NCRBUTTONUP message too.
- * See:
http://git.reactos.org/?p=reactos.git;a=blob;f=reactos/win32ss/user/user32/…
- * and line 1135 too.
- */
-#if 0
- if (DefWindowProcW(hWnd, WM_NCHITTEST, 0, lParam) == HTCAPTION)
- {
- /* Call DefWindowProcW with the WM_CONTEXTMENU message */
- msg = WM_CONTEXTMENU;
- }
-#endif
- goto Default;
- }
- // case WM_NCRBUTTONUP:
- // DPRINT1("WM_NCRBUTTONUP\n");
- // goto Default;
+ Result = OnScroll(GuiData, msg, wParam);
+ break;
+ }
case WM_CONTEXTMENU:
{
@@ -1979,7 +2016,7 @@
HMENU hMenu = CreatePopupMenu();
if (hMenu != NULL)
{
- GuiConsoleAppendMenuItems(hMenu, GuiConsoleEditMenuItems);
+ AppendMenuItems(hMenu, GuiConsoleEditMenuItems);
TrackPopupMenuEx(hMenu,
TPM_RIGHTBUTTON,
GET_X_LPARAM(lParam),
@@ -2018,7 +2055,7 @@
if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
- GuiSendMenuEvent(Console, WM_INITMENU);
+ SendMenuEvent(Console, WM_INITMENU);
LeaveCriticalSection(&Console->Lock);
}
break;
@@ -2030,7 +2067,7 @@
{
if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
{
- GuiSendMenuEvent(Console, WM_MENUSELECT);
+ SendMenuEvent(Console, WM_MENUSELECT);
LeaveCriticalSection(&Console->Lock);
}
}
@@ -2040,57 +2077,65 @@
case WM_COMMAND:
case WM_SYSCOMMAND:
{
- Result = GuiConsoleHandleSysMenuCommand(GuiData, wParam, lParam);
+ Result = OnCommand(GuiData, wParam, lParam);
break;
}
case WM_SETFOCUS:
case WM_KILLFOCUS:
- {
- if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
- {
- BOOL SetFocus = (msg == WM_SETFOCUS);
- INPUT_RECORD er;
-
- er.EventType = FOCUS_EVENT;
- er.Event.FocusEvent.bSetFocus = SetFocus;
- ConioProcessInputEvent(Console, &er);
-
- if (SetFocus)
- DPRINT1("TODO: Create console caret\n");
- else
- DPRINT1("TODO: Destroy console caret\n");
-
- LeaveCriticalSection(&Console->Lock);
- }
- break;
- }
+ OnFocus(GuiData, (msg == WM_SETFOCUS));
+ break;
case WM_GETMINMAXINFO:
- GuiConsoleGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
+ OnGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
break;
case WM_MOVE:
- {
- if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
- {
- // TODO: Simplify the code.
- // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
-
- RECT rcWnd;
-
- /* Retrieve our real position */
- GetWindowRect(GuiData->hWindow, &rcWnd);
- GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
- GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
-
- LeaveCriticalSection(&Console->Lock);
- }
- break;
- }
+ OnMove(GuiData);
+ break;
+
+#if 0 // This code is here to prepare & control dynamic console SB resizing.
+ case WM_SIZING:
+ {
+ PRECT dragRect = (PRECT)lParam;
+ switch (wParam)
+ {
+ case WMSZ_LEFT:
+ DPRINT1("WMSZ_LEFT\n");
+ break;
+ case WMSZ_RIGHT:
+ DPRINT1("WMSZ_RIGHT\n");
+ break;
+ case WMSZ_TOP:
+ DPRINT1("WMSZ_TOP\n");
+ break;
+ case WMSZ_TOPLEFT:
+ DPRINT1("WMSZ_TOPLEFT\n");
+ break;
+ case WMSZ_TOPRIGHT:
+ DPRINT1("WMSZ_TOPRIGHT\n");
+ break;
+ case WMSZ_BOTTOM:
+ DPRINT1("WMSZ_BOTTOM\n");
+ break;
+ case WMSZ_BOTTOMLEFT:
+ DPRINT1("WMSZ_BOTTOMLEFT\n");
+ break;
+ case WMSZ_BOTTOMRIGHT:
+ DPRINT1("WMSZ_BOTTOMRIGHT\n");
+ break;
+ default:
+ DPRINT1("wParam = %d\n", wParam);
+ break;
+ }
+ DPRINT1("dragRect = {.left = %d ; .top = %d ; .right = %d ; .bottom =
%d}\n",
+ dragRect->left, dragRect->top, dragRect->right,
dragRect->bottom);
+ break;
+ }
+#endif
case WM_SIZE:
- GuiConsoleResize(GuiData, wParam, lParam);
+ OnSize(GuiData, wParam, lParam);
break;
case PM_RESIZE_TERMINAL:
@@ -2120,7 +2165,7 @@
/* Resize the window to the user's values */
GuiData->WindowSizeLock = TRUE;
- GuiConsoleResizeWindow(GuiData, WidthUnit, HeightUnit);
+ ResizeConWnd(GuiData, WidthUnit, HeightUnit);
GuiData->WindowSizeLock = FALSE;
break;
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c [iso-8859-1] Wed Apr
16 22:25:29 2014
@@ -113,14 +113,24 @@
Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
}
-static VOID NTAPI
-GuiDrawRegion(IN OUT PFRONTEND This,
- SMALL_RECT* Region);
+static VOID
+DrawRegion(PGUI_CONSOLE_DATA GuiData,
+ SMALL_RECT* Region)
+{
+ RECT RegionRect;
+
+ SmallRectToRect(GuiData, &RegionRect, Region);
+ /* Do not erase the background: it speeds up redrawing and reduce flickering */
+ InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
+ /**UpdateWindow(GuiData->hWindow);**/
+}
+
VOID
-GuiInvalidateCell(IN OUT PFRONTEND This, SHORT x, SHORT y)
+InvalidateCell(PGUI_CONSOLE_DATA GuiData,
+ SHORT x, SHORT y)
{
SMALL_RECT CellRect = { x, y, x, y };
- GuiDrawRegion(This, &CellRect);
+ DrawRegion(GuiData, &CellRect);
}
@@ -151,6 +161,8 @@
PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)lParam;
PCONSOLE Console = GuiData->Console;
RECT rcWnd;
+
+ DPRINT("PM_CREATE_CONSOLE -- creating window\n");
NewWindow = CreateWindowExW(WS_EX_CLIENTEDGE,
GUI_CONWND_CLASS,
@@ -172,33 +184,26 @@
WindowCount++;
SetWindowLongW(hWnd, GWL_USERDATA, WindowCount);
- DPRINT("Set icons via PM_CREATE_CONSOLE\n");
- if (GuiData->hIcon == NULL)
- {
- DPRINT("Not really /o\\...\n");
- GuiData->hIcon = ghDefaultIcon;
- GuiData->hIconSm = ghDefaultIconSm;
- }
- else if (GuiData->hIcon != ghDefaultIcon)
- {
- DPRINT("Yes \\o/\n");
- SendMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG,
(LPARAM)GuiData->hIcon);
- SendMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL,
(LPARAM)GuiData->hIconSm);
- }
+ //
+ // FIXME: TODO: Move everything there into conwnd.c!OnNcCreate()
+ //
/* Retrieve our real position */
+ // See conwnd.c!OnMove()
GetWindowRect(GuiData->hWindow, &rcWnd);
GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
/* Move and resize the window to the user's values */
/* CAN WE DEADLOCK ?? */
- GuiConsoleMoveWindow(GuiData);
+ GuiConsoleMoveWindow(GuiData); // FIXME: This MUST be done via the
CreateWindowExW call.
SendMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
/* Switch to full-screen mode if necessary */
+ // FIXME: Move elsewhere, it cause misdrawings of the window.
if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE);
+ DPRINT("PM_CREATE_CONSOLE -- showing window\n");
// ShowWindow(NewWindow, (int)wParam);
ShowWindowAsync(NewWindow, (int)wParam);
DPRINT("Window showed\n");
@@ -424,7 +429,7 @@
DPRINT1("CONSRV: Failed to create GUI_CONSOLE_DATA\n");
return STATUS_UNSUCCESSFUL;
}
- /* HACK */ Console->TermIFace.Data = (PVOID)GuiData; /* HACK */
+ ///// /* HACK */ Console->TermIFace.Data = (PVOID)GuiData; /* HACK */
GuiData->Console = Console;
GuiData->ActiveBuffer = Console->ActiveBuffer;
GuiData->hWindow = NULL;
@@ -509,13 +514,10 @@
&hIconSm,
1);
DPRINT("hIcon = 0x%p ; hIconSm = 0x%p\n", hIcon, hIconSm);
- if (hIcon != NULL)
- {
- DPRINT("Effectively set the icons\n");
- GuiData->hIcon = hIcon;
- GuiData->hIconSm = hIconSm;
- }
- }
+ if (hIcon != NULL) GuiData->hIcon = hIcon;
+ if (hIconSm != NULL) GuiData->hIconSm = hIconSm;
+ }
+ ASSERT(GuiData->hIcon && GuiData->hIconSm);
/* Mouse is shown by default with its default cursor shape */
GuiData->hCursor = ghDefaultCursor;
@@ -597,12 +599,7 @@
SMALL_RECT* Region)
{
PGUI_CONSOLE_DATA GuiData = This->Data;
- RECT RegionRect;
-
- SmallRectToRect(GuiData, &RegionRect, Region);
- /* Do not erase the background: it speeds up redrawing and reduce flickering */
- InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
- /**UpdateWindow(GuiData->hWindow);**/
+ DrawRegion(GuiData, Region);
}
static VOID NTAPI
@@ -641,12 +638,12 @@
SW_INVALIDATE);
}
- GuiDrawRegion(This, Region);
+ DrawRegion(GuiData, Region);
if (CursorStartX < Region->Left || Region->Right < CursorStartX
|| CursorStartY < Region->Top || Region->Bottom < CursorStartY)
{
- GuiInvalidateCell(This, CursorStartX, CursorStartY);
+ InvalidateCell(GuiData, CursorStartX, CursorStartY);
}
CursorEndX = Buff->CursorPosition.X;
@@ -655,7 +652,7 @@
|| CursorEndY < Region->Top || Region->Bottom < CursorEndY)
&& (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
{
- GuiInvalidateCell(This, CursorEndX, CursorEndY);
+ InvalidateCell(GuiData, CursorEndX, CursorEndY);
}
// HACK!!
@@ -673,7 +670,7 @@
if (GuiData->ActiveBuffer == Buff)
{
- GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y);
+ InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
}
return TRUE;
@@ -690,9 +687,9 @@
if (GuiData->ActiveBuffer == Buff)
{
/* Redraw char at old position (remove cursor) */
- GuiInvalidateCell(This, OldCursorX, OldCursorY);
+ InvalidateCell(GuiData, OldCursorX, OldCursorY);
/* Redraw char at new position (show cursor) */
- GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y);
+ InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
}
return TRUE;
@@ -884,7 +881,7 @@
GuiData->hIconSm = hIconSm;
DPRINT("Set icons in GuiChangeIcon\n");
- PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG,
(LPARAM)GuiData->hIcon);
+ PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG ,
(LPARAM)GuiData->hIcon );
PostMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL,
(LPARAM)GuiData->hIconSm);
}