- Implement GetLargestConsoleWindowSize (and add a DPRINT to see what happens when Far 1.65 is launched).
- Implement SetConsoleWindowInfo in kernel32 and pre-implement its CONSRV counterpart.
svn path=/branches/ros-csrss/; revision=58726
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &ApiMessage.Data.GetDisplayModeRequest;
+ if (lpModeFlags == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
// GetDisplayModeRequest->OutputHandle = hConsoleOutput;
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
/*
* @implemented (Undocumented)
*/
-DWORD
+BOOL
WINAPI
GetConsoleHardwareState(HANDLE hConsoleOutput,
DWORD Flags,
DPRINT1("GetConsoleHardwareState(%d, 0x%p) UNIMPLEMENTED!\n", Flags, State);
+ if (State == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
HardwareStateRequest->OutputHandle = hConsoleOutput;
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
SetDisplayModeRequest->OutputHandle = hConsoleOutput;
SetDisplayModeRequest->DisplayMode = dwFlags;
- SetDisplayModeRequest->NewSBDim = (COORD){0,0};
+ SetDisplayModeRequest->NewSBDim = (COORD){0, 0};
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
NULL,
return FALSE;
}
- *lpNewScreenBufferDimensions = SetDisplayModeRequest->NewSBDim;
+ if (lpNewScreenBufferDimensions)
+ *lpNewScreenBufferDimensions = SetDisplayModeRequest->NewSBDim;
+
return TRUE;
}
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest;
+ if (lpMode == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
ConsoleModeRequest->ConsoleHandle = hConsoleHandle;
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
/*--------------------------------------------------------------
* GetLargestConsoleWindowSize
*
- * @unimplemented
+ * @implemented
*/
COORD
WINAPI
GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
{
- COORD Coord = {80,25};
- DPRINT1("GetLargestConsoleWindowSize(0x%x) UNIMPLEMENTED!\n", hConsoleOutput);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return Coord;
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &ApiMessage.Data.GetLargestWindowSizeRequest;
+
+ GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
+ GetLargestWindowSizeRequest->Size = (COORD){0, 0};
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetLargestWindowSize),
+ sizeof(CONSOLE_GETLARGESTWINDOWSIZE));
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ }
+
+ DPRINT1("GetLargestConsoleWindowSize, X = %d, Y = %d\n", GetLargestWindowSizeRequest->Size.X, GetLargestWindowSizeRequest->Size.Y);
+ return GetLargestWindowSizeRequest->Size;
}
/*--------------------------------------------------------------
* SetConsoleWindowInfo
*
- * @unimplemented
+ * @implemented
*/
BOOL
WINAPI
BOOL bAbsolute,
CONST SMALL_RECT *lpConsoleWindow)
{
- DPRINT1("SetConsoleWindowInfo(0x%x, 0x%x, 0x%x) UNIMPLEMENTED!\n", hConsoleOutput, bAbsolute, lpConsoleWindow);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &ApiMessage.Data.SetWindowInfoRequest;
+
+ if (lpConsoleWindow == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ SetWindowInfoRequest->OutputHandle = hConsoleOutput;
+ SetWindowInfoRequest->Absolute = bAbsolute;
+ SetWindowInfoRequest->WindowRect = *lpConsoleWindow;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetWindowInfo),
+ sizeof(CONSOLE_SETWINDOWINFO));
+ if (!NT_SUCCESS(Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ return TRUE;
}
ConsolepSetMode,
ConsolepSetActiveScreenBuffer,
ConsolepFlushInputBuffer,
- // ConsolepGetLargestWindowSize,
+ ConsolepGetLargestWindowSize,
ConsolepSetScreenBufferSize,
ConsolepSetCursorPosition,
ConsolepSetCursorInfo,
- // ConsolepSetWindowInfo,
+ ConsolepSetWindowInfo,
ConsolepScrollScreenBuffer,
ConsolepSetTextAttribute,
// ConsolepSetFont,
} CONSOLE_OPENCONSOLE, *PCONSOLE_OPENCONSOLE;
+typedef struct
+{
+ HANDLE OutputHandle;
+ COORD Size;
+} CONSOLE_GETLARGESTWINDOWSIZE, *PCONSOLE_GETLARGESTWINDOWSIZE;
+
+typedef struct
+{
+ HANDLE OutputHandle;
+ BOOL Absolute;
+ SMALL_RECT WindowRect; // New console window position in the screen-buffer frame (Absolute == TRUE)
+ // or in the old window position frame (Absolute == FALSE).
+} CONSOLE_SETWINDOWINFO, *PCONSOLE_SETWINDOWINFO;
+
typedef struct
{
HWND WindowHandle;
ULONG Reserved;
union
{
+ /* Console initialization and uninitialization */
CONSOLE_ALLOCCONSOLE AllocConsoleRequest;
CONSOLE_ATTACHCONSOLE AttachConsoleRequest;
CONSOLE_FREECONSOLE FreeConsoleRequest;
+ /* Process list */
+ CONSOLE_GETPROCESSLIST GetProcessListRequest;
+
/* Handles */
CONSOLE_OPENCONSOLE OpenConsoleRequest;
CONSOLE_CLOSEHANDLE CloseHandleRequest;
CONSOLE_GETSETCURSORINFO CursorInfoRequest;
CONSOLE_SETCURSORPOSITION SetCursorPositionRequest;
- /* Screen buffer */
+ /* Screen-buffer */
CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest;
CONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest;
CONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest;
/* Console window */
CONSOLE_GETSETCONSOLETITLE TitleRequest;
+ CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest;
+ CONSOLE_SETWINDOWINFO SetWindowInfoRequest;
CONSOLE_GETWINDOW GetWindowRequest;
CONSOLE_SETICON SetIconRequest;
/* Input and Output Code Pages */
CONSOLE_GETSETINPUTOUTPUTCP ConsoleCPRequest;
-
- CONSOLE_GETPROCESSLIST GetProcessListRequest;
} Data;
} CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
CSR_API(SrvSetConsoleHardwareState);
CSR_API(SrvGetConsoleDisplayMode);
CSR_API(SrvSetConsoleDisplayMode);
+CSR_API(SrvGetLargestConsoleWindowSize);
+CSR_API(SrvSetConsoleWindowInfo);
CSR_API(SrvGetConsoleWindow);
CSR_API(SrvSetConsoleIcon);
CSR_API(SrvGetConsoleCP);
#define ConioResizeTerminal(Console) (Console)->TermIFace.Vtbl->ResizeTerminal((Console))
#define ConioProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode, Down) \
(Console)->TermIFace.Vtbl->ProcessKeyCallback((Console), (Msg), (KeyStateMenu), (ShiftState), (VirtualKeyCode), (Down))
+#define ConioGetLargestConsoleWindowSize(Console, pSize) \
+ (Console)->TermIFace.Vtbl->GetLargestConsoleWindowSize((Console), (pSize))
#define ConioGetConsoleWindowHandle(Console) \
(Console)->TermIFace.Vtbl->GetConsoleWindowHandle((Console))
#define ConioRefreshInternalInfo(Console) \
PCONSOLE Console;
Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- HardwareStateRequest->OutputHandle,
- &Buff,
- GENERIC_READ,
- TRUE);
+ HardwareStateRequest->OutputHandle,
+ &Buff,
+ GENERIC_READ,
+ TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to get console handle in SrvGetConsoleHardwareState\n");
PCONSOLE Console;
Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- HardwareStateRequest->OutputHandle,
- &Buff,
- GENERIC_WRITE,
- TRUE);
+ HardwareStateRequest->OutputHandle,
+ &Buff,
+ GENERIC_WRITE,
+ TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to get console handle in SrvSetConsoleHardwareState\n");
return Status;
}
+CSR_API(SrvGetLargestConsoleWindowSize)
+{
+ NTSTATUS Status;
+ PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetLargestWindowSizeRequest;
+ PCONSOLE_SCREEN_BUFFER Buff;
+ PCONSOLE Console;
+
+ Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ GetLargestWindowSizeRequest->OutputHandle,
+ &Buff,
+ GENERIC_READ,
+ TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Console = Buff->Header.Console;
+ ConioGetLargestConsoleWindowSize(Console, &GetLargestWindowSizeRequest->Size);
+
+ ConSrvReleaseScreenBuffer(Buff, TRUE);
+ return STATUS_SUCCESS;
+}
+
+CSR_API(SrvSetConsoleWindowInfo)
+{
+#if 0
+ NTSTATUS Status;
+#endif
+ PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest;
+#if 0
+ PCONSOLE_SCREEN_BUFFER Buff;
+ PCONSOLE Console;
+#endif
+ SMALL_RECT WindowRect = SetWindowInfoRequest->WindowRect;
+
+#if 0
+ Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ SetWindowInfoRequest->OutputHandle,
+ &Buff,
+ GENERIC_READ,
+ TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Console = Buff->Header.Console;
+
+ if (SetWindowInfoRequest->Absolute == FALSE)
+ {
+ /* Relative positions given. Transform them to absolute ones */
+ WindowRect.Left += Buff->ShowX;
+ WindowRect.Top += Buff->ShowY;
+ WindowRect.Right += Buff->ShowX + Console->ConsoleSize.X - 1;
+ WindowRect.Bottom += Buff->ShowY + Console->ConsoleSize.Y - 1;
+ }
+
+ if ( (WindowRect.Left < 0) || (WindowRect.Top < 0) ||
+ (WindowRect.Right > ScreenBufferSize.X) ||
+ (WindowRect.Bottom > ScreenBufferSize.Y) ||
+ (WindowRect.Right <= WindowRect.Left) ||
+ (WindowRect.Bottom <= WindowRect.Top) )
+ {
+ ConSrvReleaseScreenBuffer(Buff, TRUE);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ Buff->ShowX = WindowRect.Left;
+ Buff->ShowY = WindowRect.Top;
+
+ // These two lines are frontend-specific.
+ Console->ConsoleSize.X = WindowRect.Right - WindowRect.Left + 1;
+ Console->ConsoleSize.Y = WindowRect.Bottom - WindowRect.Top + 1;
+
+ // ConioGetLargestConsoleWindowSize(Console, &GetLargestWindowSizeRequest->Size);
+
+ ConSrvReleaseScreenBuffer(Buff, TRUE);
+ return STATUS_SUCCESS;
+#else
+ DPRINT1("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) UNIMPLEMENTED\n",
+ SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute,
+ WindowRect.Left, WindowRect.Top, WindowRect.Right, WindowRect.Bottom);
+ return STATUS_NOT_IMPLEMENTED;
+#endif
+}
+
CSR_API(SrvGetConsoleWindow)
{
NTSTATUS Status;
if (!NT_SUCCESS(Status)) return Status;
GetWindowRequest->WindowHandle = ConioGetConsoleWindowHandle(Console);
- ConSrvReleaseConsole(Console, TRUE);
+ ConSrvReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
: STATUS_UNSUCCESSFUL);
ConSrvReleaseConsole(Console, TRUE);
-
return Status;
}
if (!ConSrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
- windx = CONGUI_MIN_WIDTH * GuiData->CharWidth + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
+ windx = CONGUI_MIN_WIDTH * GuiData->CharWidth + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
windy = CONGUI_MIN_HEIGHT * GuiData->CharHeight + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION);
minMaxInfo->ptMinTrackSize.x = windx;
return GuiData->hWindow;
}
+static VOID WINAPI
+GuiGetLargestConsoleWindowSize(PCONSOLE Console, PCOORD pSize)
+{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+ HWND hDesktop;
+ RECT desktop;
+ LONG width, height;
+
+ if (!pSize) return;
+
+ /*
+ * This is one solution. Surely better solutions exist :
+ * http://stackoverflow.com/questions/4631292/how-detect-current-screen-resolution
+ * http://www.clearevo.com/blog/programming/2011/08/30/windows_c_c++_-_get_monitor_display_screen_size_in_pixels.html
+ */
+ hDesktop = GetDesktopWindow();
+ if (!hDesktop) return;
+
+ GetWindowRect(hDesktop, &desktop);
+
+ width = desktop.right;
+ height = desktop.bottom;
+
+ width -= (2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE)));
+ height -= (2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION));
+
+ if (width < 0) width = 0;
+ if (height < 0) height = 0;
+
+ pSize->X = (SHORT)(width / GuiData->CharWidth );
+ pSize->Y = (SHORT)(height / GuiData->CharHeight);
+}
+
static FRONTEND_VTBL GuiVtbl =
{
GuiCleanupConsole,
GuiRefreshInternalInfo,
GuiChangeTitle,
GuiChangeIcon,
- GuiGetConsoleWindowHandle
+ GuiGetConsoleWindowHandle,
+ GuiGetLargestConsoleWindowSize
};
NTSTATUS FASTCALL
BOOL (WINAPI *ChangeIcon)(struct _CONSOLE* Console,
HICON hWindowIcon);
HWND (WINAPI *GetConsoleWindowHandle)(struct _CONSOLE* Console);
+ VOID (WINAPI *GetLargestConsoleWindowSize)(struct _CONSOLE* Console,
+ PCOORD pSize);
} FRONTEND_VTBL, *PFRONTEND_VTBL;
SrvSetConsoleMode,
SrvSetConsoleActiveScreenBuffer,
SrvFlushConsoleInputBuffer,
- // SrvGetLargestConsoleWindowSize,
+ SrvGetLargestConsoleWindowSize,
SrvSetConsoleScreenBufferSize,
SrvSetConsoleCursorPosition,
SrvSetConsoleCursorInfo,
- // SrvSetConsoleWindowInfo,
+ SrvSetConsoleWindowInfo,
SrvScrollConsoleScreenBuffer,
SrvSetConsoleTextAttribute,
// SrvSetConsoleFont,
FALSE, // SrvSetConsoleMode,
FALSE, // SrvSetConsoleActiveScreenBuffer,
FALSE, // SrvFlushConsoleInputBuffer,
- // FALSE, // SrvGetLargestConsoleWindowSize,
+ FALSE, // SrvGetLargestConsoleWindowSize,
FALSE, // SrvSetConsoleScreenBufferSize,
FALSE, // SrvSetConsoleCursorPosition,
FALSE, // SrvSetConsoleCursorInfo,
- // FALSE, // SrvSetConsoleWindowInfo,
+ FALSE, // SrvSetConsoleWindowInfo,
FALSE, // SrvScrollConsoleScreenBuffer,
FALSE, // SrvSetConsoleTextAttribute,
// FALSE, // SrvSetConsoleFont,
"SetConsoleMode",
"SetConsoleActiveScreenBuffer",
"FlushConsoleInputBuffer",
- // "GetLargestConsoleWindowSize",
+ "GetLargestConsoleWindowSize",
"SetConsoleScreenBufferSize",
"SetConsoleCursorPosition",
"SetConsoleCursorInfo",
- // "SetConsoleWindowInfo",
+ "SetConsoleWindowInfo",
"ScrollConsoleScreenBuffer",
"SetConsoleTextAttribute",
// "SetConsoleFont",