https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7babd9310730a7804a9a7…
commit 7babd9310730a7804a9a74de0fc1f205a7633ef9
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Mar 1 17:22:05 2020 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Mar 2 01:08:41 2020 +0100
[CONSRV] Some code simplification and tidy up.
---
win32ss/user/winsrv/consrv/condrv/console.c | 23 +++++++++------------
win32ss/user/winsrv/consrv/condrv/dummyterm.c | 2 +-
win32ss/user/winsrv/consrv/condrv/graphics.c | 1 -
win32ss/user/winsrv/consrv/condrv/text.c | 2 +-
win32ss/user/winsrv/consrv/coninput.c | 25 +++++++++++++++++++++++
win32ss/user/winsrv/consrv/conoutput.c | 2 +-
win32ss/user/winsrv/consrv/console.c | 4 ++--
win32ss/user/winsrv/consrv/frontends/input.c | 20 +++---------------
win32ss/user/winsrv/consrv/include/conio.h | 7 +++----
win32ss/user/winsrv/consrv/include/conio_winsrv.h | 8 ++++----
10 files changed, 50 insertions(+), 44 deletions(-)
diff --git a/win32ss/user/winsrv/consrv/condrv/console.c
b/win32ss/user/winsrv/consrv/condrv/console.c
index e763a812553..a3d7a13ea79 100644
--- a/win32ss/user/winsrv/consrv/condrv/console.c
+++ b/win32ss/user/winsrv/consrv/condrv/console.c
@@ -79,24 +79,21 @@ RemoveConsole(IN PCONSOLE Console)
VOID NTAPI
ConDrvPause(PCONSOLE Console)
{
- /* In case we already have a pause event, just exit... */
- if (Console->UnpauseEvent) return;
+ /* In case we are already paused, just exit... */
+ if (Console->ConsolePaused) return;
- /* ... otherwise create it */
- NtCreateEvent(&Console->UnpauseEvent, EVENT_ALL_ACCESS,
- NULL, NotificationEvent, FALSE);
+ /* ... otherwise set the flag */
+ Console->ConsolePaused = TRUE;
}
VOID NTAPI
ConDrvUnpause(PCONSOLE Console)
{
- /* In case we already freed the event, just exit... */
- if (!Console->UnpauseEvent) return;
+ /* In case we are already unpaused, just exit... */
+ if (!Console->ConsolePaused) return;
- /* ... otherwise set and free it */
- NtSetEvent(Console->UnpauseEvent, NULL);
- NtClose(Console->UnpauseEvent);
- Console->UnpauseEvent = NULL;
+ /* ... otherwise reset the flag */
+ Console->ConsolePaused = FALSE;
}
@@ -248,7 +245,7 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
}
/* Make the new screen buffer active */
Console->ActiveBuffer = NewBuffer;
- Console->UnpauseEvent = NULL;
+ Console->ConsolePaused = FALSE;
DPRINT("Console initialized\n");
@@ -409,7 +406,7 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
/* Deinitialize the input buffer */
ConDrvDeinitInputBuffer(Console);
- if (Console->UnpauseEvent) NtClose(Console->UnpauseEvent);
+ Console->ConsolePaused = FALSE;
DPRINT("ConDrvDeleteConsole - Unlocking\n");
LeaveCriticalSection(&Console->Lock);
diff --git a/win32ss/user/winsrv/consrv/condrv/dummyterm.c
b/win32ss/user/winsrv/consrv/condrv/dummyterm.c
index 7261994f6c9..eaeb94561c7 100644
--- a/win32ss/user/winsrv/consrv/condrv/dummyterm.c
+++ b/win32ss/user/winsrv/consrv/condrv/dummyterm.c
@@ -61,7 +61,7 @@ DummyWriteStream(IN OUT PTERMINAL This,
*/
// /* Stop here if the console is paused */
- // if (Console->UnpauseEvent != NULL) return STATUS_PENDING;
+ // if (Console->ConsolePaused) return STATUS_PENDING;
return STATUS_PENDING;
}
diff --git a/win32ss/user/winsrv/consrv/condrv/graphics.c
b/win32ss/user/winsrv/consrv/condrv/graphics.c
index 04341c6b663..694c2f52106 100644
--- a/win32ss/user/winsrv/consrv/condrv/graphics.c
+++ b/win32ss/user/winsrv/consrv/condrv/graphics.c
@@ -228,7 +228,6 @@ GRAPHICS_BUFFER_Initialize(OUT PCONSOLE_SCREEN_BUFFER* Buffer,
}
NewBuffer->ViewOrigin.X = NewBuffer->ViewOrigin.Y = 0;
- NewBuffer->VirtualY = 0;
NewBuffer->CursorBlinkOn = FALSE;
NewBuffer->ForceCursorOff = TRUE;
diff --git a/win32ss/user/winsrv/consrv/condrv/text.c
b/win32ss/user/winsrv/consrv/condrv/text.c
index d38317de29a..2b568652ec2 100644
--- a/win32ss/user/winsrv/consrv/condrv/text.c
+++ b/win32ss/user/winsrv/consrv/condrv/text.c
@@ -793,7 +793,7 @@ ConDrvWriteConsole(IN PCONSOLE Console,
ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCharsToWrite ==
0));
/* Stop here if the console is paused */
- if (Console->UnpauseEvent != NULL) return STATUS_PENDING;
+ if (Console->ConsolePaused) return STATUS_PENDING;
/* Convert the string to UNICODE */
if (Unicode)
diff --git a/win32ss/user/winsrv/consrv/coninput.c
b/win32ss/user/winsrv/consrv/coninput.c
index d8f5b24d9db..8c2e0e82adb 100644
--- a/win32ss/user/winsrv/consrv/coninput.c
+++ b/win32ss/user/winsrv/consrv/coninput.c
@@ -202,6 +202,31 @@ ConioProcessInputEvent(PCONSRV_CONSOLE Console,
PINPUT_RECORD InputEvent)
{
ULONG NumEventsWritten;
+
+ if (InputEvent->EventType == KEY_EVENT)
+ {
+ BOOL Down = InputEvent->Event.KeyEvent.bKeyDown;
+ UINT VirtualKeyCode = InputEvent->Event.KeyEvent.wVirtualKeyCode;
+ DWORD ShiftState = InputEvent->Event.KeyEvent.dwControlKeyState;
+
+ /* Process Ctrl-C and Ctrl-Break */
+ if ( (GetConsoleInputBufferMode(Console) & ENABLE_PROCESSED_INPUT)
&&
+ Down && (VirtualKeyCode == VK_PAUSE || VirtualKeyCode ==
'C') &&
+ (ShiftState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) )
+ {
+ DPRINT1("Console_Api Ctrl-C\n");
+ ConSrvConsoleProcessCtrlEvent(Console, 0, CTRL_C_EVENT);
+
+ if (Console->LineBuffer && !Console->LineComplete)
+ {
+ /* Line input is in progress; end it */
+ Console->LinePos = Console->LineSize = 0;
+ Console->LineComplete = TRUE;
+ }
+ return STATUS_SUCCESS; // STATUS_CONTROL_C_EXIT;
+ }
+ }
+
return ConioAddInputEvents(Console,
InputEvent,
1,
diff --git a/win32ss/user/winsrv/consrv/conoutput.c
b/win32ss/user/winsrv/consrv/conoutput.c
index 15fd4ff5ede..173926032ed 100644
--- a/win32ss/user/winsrv/consrv/conoutput.c
+++ b/win32ss/user/winsrv/consrv/conoutput.c
@@ -206,7 +206,7 @@ CSR_API(SrvCreateConsoleScreenBuffer)
TEXTMODE_BUFFER_INFO TextModeInfo = {{80, 25},
{80, 25},
DEFAULT_SCREEN_ATTRIB,
- DEFAULT_POPUP_ATTRIB ,
+ DEFAULT_POPUP_ATTRIB,
TRUE,
CSR_DEFAULT_CURSOR_SIZE};
GRAPHICS_BUFFER_INFO GraphicsInfo;
diff --git a/win32ss/user/winsrv/consrv/console.c b/win32ss/user/winsrv/consrv/console.c
index 8b50465bfad..f838376204d 100644
--- a/win32ss/user/winsrv/consrv/console.c
+++ b/win32ss/user/winsrv/consrv/console.c
@@ -240,14 +240,14 @@ ConsoleFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
}
VOID
-ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
+ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags)
{
Console->PauseFlags |= Flags;
ConDrvPause((PCONSOLE)Console);
}
VOID
-ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
+ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags)
{
Console->PauseFlags &= ~Flags;
diff --git a/win32ss/user/winsrv/consrv/frontends/input.c
b/win32ss/user/winsrv/consrv/frontends/input.c
index 8bc0ad0ffae..053e2006efb 100644
--- a/win32ss/user/winsrv/consrv/frontends/input.c
+++ b/win32ss/user/winsrv/consrv/frontends/input.c
@@ -34,17 +34,20 @@ ConioGetShiftState(PBYTE KeyState, LPARAM lParam)
ssOut |= SCROLLLOCK_ON;
if (KeyState[VK_SHIFT] & 0x80)
+ // || (KeyState[VK_LSHIFT] & 0x80) || (KeyState[VK_RSHIFT] & 0x80)
ssOut |= SHIFT_PRESSED;
if (KeyState[VK_LCONTROL] & 0x80)
ssOut |= LEFT_CTRL_PRESSED;
if (KeyState[VK_RCONTROL] & 0x80)
ssOut |= RIGHT_CTRL_PRESSED;
+ // if (KeyState[VK_CONTROL] & 0x80) { ... }
if (KeyState[VK_LMENU] & 0x80)
ssOut |= LEFT_ALT_PRESSED;
if (KeyState[VK_RMENU] & 0x80)
ssOut |= RIGHT_ALT_PRESSED;
+ // if (KeyState[VK_MENU] & 0x80) { ... }
/* See WM_CHAR MSDN documentation for instance */
if (lParam & 0x01000000)
@@ -124,23 +127,6 @@ ConioProcessKey(PCONSRV_CONSOLE Console, MSG* msg)
if (Fake) return;
- /* Process Ctrl-C and Ctrl-Break */
- if ( (GetConsoleInputBufferMode(Console) & ENABLE_PROCESSED_INPUT) &&
- Down && (VirtualKeyCode == VK_PAUSE || VirtualKeyCode == 'C')
&&
- (ShiftState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) ||
KeyState[VK_CONTROL] & 0x80) )
- {
- DPRINT1("Console_Api Ctrl-C\n");
- ConSrvConsoleProcessCtrlEvent(Console, 0, CTRL_C_EVENT);
-
- if (Console->LineBuffer && !Console->LineComplete)
- {
- /* Line input is in progress; end it */
- Console->LinePos = Console->LineSize = 0;
- Console->LineComplete = TRUE;
- }
- return;
- }
-
//
// FIXME: Scrolling via keyboard shortcuts must be done differently,
// without touching the internal VirtualY variable.
diff --git a/win32ss/user/winsrv/consrv/include/conio.h
b/win32ss/user/winsrv/consrv/include/conio.h
index cff5de40975..dc68afc4898 100644
--- a/win32ss/user/winsrv/consrv/include/conio.h
+++ b/win32ss/user/winsrv/consrv/include/conio.h
@@ -93,8 +93,6 @@ struct _CONSOLE_SCREEN_BUFFER
COORD ViewOrigin; /* Beginning offset for the actual display area
*/
/***** Put that VV in TEXTMODE_SCREEN_BUFFER ?? *****/
- USHORT VirtualY; /* Top row of buffer being displayed, reported to
callers */
-
COORD CursorPosition; /* Current cursor position */
BOOLEAN CursorBlinkOn;
BOOLEAN ForceCursorOff;
@@ -152,6 +150,7 @@ typedef struct _TEXTMODE_SCREEN_BUFFER
{
CONSOLE_SCREEN_BUFFER; /* Screen buffer base class - MUST BE IN FIRST PLACE */
+ USHORT VirtualY; /* Top row of buffer being displayed, reported to callers
*/
PCHAR_INFO Buffer; /* Pointer to UNICODE screen buffer
(Buffer->Char.UnicodeChar only is valid, not Char.AsciiChar) */
USHORT ScreenDefaultAttrib; /* Default screen char attribute */
@@ -333,7 +332,7 @@ typedef struct _CONSOLE
CONSOLE_STATE State; /* State of the console */
TERMINAL TermIFace; /* Terminal-specific interface */
- HANDLE UnpauseEvent; /* When != NULL, event for pausing the
console */
+ BOOLEAN ConsolePaused; /* If TRUE, the console is paused */
/******************************** Input buffer ********************************/
CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
@@ -367,7 +366,7 @@ ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
/* conoutput.c */
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
-NTSTATUS ConioResizeBuffer(PCONSOLE /*PCONSRV_CONSOLE*/ Console,
+NTSTATUS ConioResizeBuffer(PCONSOLE Console,
PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
COORD Size);
diff --git a/win32ss/user/winsrv/consrv/include/conio_winsrv.h
b/win32ss/user/winsrv/consrv/include/conio_winsrv.h
index 5057a31e4ad..a77bfcb0d39 100644
--- a/win32ss/user/winsrv/consrv/include/conio_winsrv.h
+++ b/win32ss/user/winsrv/consrv/include/conio_winsrv.h
@@ -152,7 +152,7 @@ typedef struct _WINSRV_CONSOLE
BOOLEAN HasFocus; /* TRUE if the console has focus (is in the
foreground) */
/******************************* Pausing support ******************************/
- BYTE PauseFlags;
+ UCHAR PauseFlags;
LIST_ENTRY ReadWaitQueue; /* List head for the queue of unique input buffer
read wait blocks */
LIST_ENTRY WriteWaitQueue; /* List head for the queue of current screen-buffer
write wait blocks */
@@ -197,8 +197,8 @@ typedef struct _WINSRV_CONSOLE
} WINSRV_CONSOLE; // , *PWINSRV_CONSOLE;
/* console.c */
-VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags);
-VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags);
+VOID ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags);
+VOID ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags);
PCONSOLE_PROCESS_DATA NTAPI
ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console);
@@ -227,7 +227,7 @@ ConioProcessInputEvent(PCONSRV_CONSOLE Console,
/* conoutput.c */
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
-NTSTATUS ConioResizeBuffer(PCONSOLE /*PCONSRV_CONSOLE*/ Console,
+NTSTATUS ConioResizeBuffer(PCONSOLE Console,
PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
COORD Size);