if (LoadStringW(ConSrvDllInstance,
Items[i].uID,
szMenuString,
- sizeof(szMenuString) / sizeof(szMenuString[0])) > 0)
+ ARRAYSIZE(szMenuString)) > 0)
{
if (Items[i].SubMenu != NULL)
{
if (hMenu != NULL)
{
mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STRING;
+ mii.fMask = MIIM_STRING;
mii.dwTypeData = szMenuStringBack;
mii.cch = sizeof(szMenuStringBack)/sizeof(WCHAR);
{
INPUT_RECORD er;
- DPRINT1("Menu item ID: %d\n", CmdId);
+ DPRINT("Menu item ID: %d\n", CmdId);
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return;
er.EventType = MENU_EVENT;
er.Event.MenuEvent.dwCommandId = CmdId;
DeleteFonts(PGUI_CONSOLE_DATA GuiData)
{
ULONG i;
- for (i = 0; i < sizeof(GuiData->Font) / sizeof(GuiData->Font[0]); ++i)
+ for (i = 0; i < ARRAYSIZE(GuiData->Font); ++i)
{
if (GuiData->Font[i] != NULL) DeleteObject(GuiData->Font[i]);
GuiData->Font[i] = NULL;
{
DPRINT1("GuiConsoleNcCreate: InitFonts failed\n");
GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
+ NtSetEvent(GuiData->hGuiInitEvent, NULL);
return FALSE;
}
SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
- SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
+ if (GuiData->IsWindowVisible)
+ {
+ SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
+ }
+
// FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
//CreateSysMenu(GuiData->hWindow);
DPRINT("OnNcCreate - setting start event\n");
- SetEvent(GuiData->hGuiInitEvent);
+ NtSetEvent(GuiData->hGuiInitEvent, NULL);
return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
}
{
WORD ActivationState = LOWORD(wParam);
- DPRINT1("WM_ACTIVATE - ActivationState = %d\n");
+ DPRINT("WM_ACTIVATE - ActivationState = %d\n", ActivationState);
if ( ActivationState == WA_ACTIVE ||
ActivationState == WA_CLICKACTIVE )
PCONSRV_CONSOLE Console = GuiData->Console;
INPUT_RECORD er;
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return;
er.EventType = FOCUS_EVENT;
er.Event.FocusEvent.bSetFocus = SetFocus;
LeaveCriticalSection(&Console->Lock);
if (SetFocus)
- DPRINT1("TODO: Create console caret\n");
+ DPRINT("TODO: Create console caret\n");
else
- DPRINT1("TODO: Destroy console caret\n");
+ DPRINT("TODO: Destroy console caret\n");
}
static VOID
wcscat(WindowTitle, L" - ");
wcscat(WindowTitle, Console->Title.Buffer);
- SetWindowText(GuiData->hWindow, WindowTitle);
+ SetWindowTextW(GuiData->hWindow, WindowTitle);
ConsoleFreeHeap(WindowTitle);
}
ConioUnpause(Console, PAUSED_FROM_SELECTION);
/* Restore the console title */
- SetWindowText(GuiData->hWindow, Console->Title.Buffer);
+ SetWindowTextW(GuiData->hWindow, Console->Title.Buffer);
}
DeleteObject(oldRgn);
PAINTSTRUCT ps;
RECT rcPaint;
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return;
+
BeginPaint(GuiData->hWindow, &ps);
if (ps.hdc != NULL &&
ps.rcPaint.left < ps.rcPaint.right &&
{
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return;
+
// See WM_PALETTECHANGED message
// if ((HWND)wParam == hWnd) break;
PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return;
ActiveBuffer = GuiData->ActiveBuffer;
PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return;
+
SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CURSOR_BLINK_TIME, NULL);
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return;
Buff = GuiData->ActiveBuffer;
{
PCONSRV_CONSOLE Console = GuiData->Console;
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE))
return TRUE;
// TODO: Prompt for termination ? (Warn the user about possible apps running in this console)
{
PGUI_CONSOLE_DATA GuiData = GuiGetGuiData(hWnd);
- KillTimer(hWnd, CONGUI_UPDATE_TIMER);
+ if (GuiData->IsWindowVisible)
+ {
+ KillTimer(hWnd, CONGUI_UPDATE_TIMER);
+ }
+
GetSystemMenu(hWnd, TRUE);
if (GuiData)
BOOL Err = FALSE;
PCONSRV_CONSOLE Console = GuiData->Console;
- // FIXME: It's here that we need to check whether we has focus or not
- // and whether we are in edit mode or not, to know if we need to deal
- // with the mouse, or not.
+ // FIXME: It's here that we need to check whether we have focus or not
+ // and whether we are or not in edit mode, in order to know if we need
+ // to deal with the mouse.
if (GuiData->IgnoreNextMouseSignal)
{
if (msg != WM_LBUTTONDOWN &&
msg != WM_MBUTTONDOWN &&
- msg != WM_RBUTTONDOWN)
+ msg != WM_RBUTTONDOWN &&
+ msg != WM_XBUTTONDOWN)
{
/*
* If this mouse signal is not a button-down action
- * then it is the last signal being ignored.
+ * then this is the last one being ignored.
*/
GuiData->IgnoreNextMouseSignal = FALSE;
}
goto Quit;
}
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE))
{
Err = TRUE;
goto Quit;
dwEventFlags = 0;
break;
+ case WM_XBUTTONDOWN:
+ {
+ /* Get which X-button was pressed */
+ WORD wButton = GET_XBUTTON_WPARAM(wParam);
+
+ /* Check for X-button validity */
+ if (wButton & ~(XBUTTON1 | XBUTTON2))
+ {
+ DPRINT1("X-button 0x%04x invalid\n", wButton);
+ Err = TRUE;
+ break;
+ }
+
+ SetCapture(GuiData->hWindow);
+ dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
+ : FROM_LEFT_4TH_BUTTON_PRESSED);
+ dwEventFlags = 0;
+ break;
+ }
+
case WM_LBUTTONUP:
ReleaseCapture();
dwButtonState = 0;
dwEventFlags = 0;
break;
+ case WM_XBUTTONUP:
+ {
+ /* Get which X-button was released */
+ WORD wButton = GET_XBUTTON_WPARAM(wParam);
+
+ /* Check for X-button validity */
+ if (wButton & ~(XBUTTON1 | XBUTTON2))
+ {
+ DPRINT1("X-button 0x%04x invalid\n", wButton);
+ /* Ok, just release the button anyway... */
+ }
+
+ ReleaseCapture();
+ dwButtonState = 0;
+ dwEventFlags = 0;
+ break;
+ }
+
case WM_LBUTTONDBLCLK:
dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
dwEventFlags = DOUBLE_CLICK;
dwEventFlags = DOUBLE_CLICK;
break;
+ case WM_XBUTTONDBLCLK:
+ {
+ /* Get which X-button was double-clicked */
+ WORD wButton = GET_XBUTTON_WPARAM(wParam);
+
+ /* Check for X-button validity */
+ if (wButton & ~(XBUTTON1 | XBUTTON2))
+ {
+ DPRINT1("X-button 0x%04x invalid\n", wButton);
+ Err = TRUE;
+ break;
+ }
+
+ dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
+ : FROM_LEFT_4TH_BUTTON_PRESSED);
+ dwEventFlags = DOUBLE_CLICK;
+ break;
+ }
+
case WM_MOUSEMOVE:
dwButtonState = 0;
dwEventFlags = MOUSE_MOVED;
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
+ case WM_XBUTTONDOWN:
GuiData->IgnoreNextMouseSignal = TRUE;
default:
break;
dwButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
if (wKeyState & MK_RBUTTON)
dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
+ if (wKeyState & MK_XBUTTON1)
+ dwButtonState |= FROM_LEFT_3RD_BUTTON_PRESSED;
+ if (wKeyState & MK_XBUTTON2)
+ dwButtonState |= FROM_LEFT_4TH_BUTTON_PRESSED;
if (GetKeyState(VK_RMENU) & 0x8000)
dwControlKeyState |= RIGHT_ALT_PRESSED;
static VOID
Copy(PGUI_CONSOLE_DATA GuiData)
{
- if (OpenClipboard(GuiData->hWindow) == TRUE)
+ if (OpenClipboard(GuiData->hWindow))
{
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
static VOID
Paste(PGUI_CONSOLE_DATA GuiData)
{
- if (OpenClipboard(GuiData->hWindow) == TRUE)
+ if (OpenClipboard(GuiData->hWindow))
{
PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer;
DWORD windx, windy;
UINT WidthUnit, HeightUnit;
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return;
ActiveBuffer = GuiData->ActiveBuffer;
{
PCONSRV_CONSOLE Console = GuiData->Console;
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) return;
+
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return;
if ((GuiData->WindowSizeLock == FALSE) &&
(wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED))
if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
// Compensate for added scroll bars in new window
- if (charx < Buff->ScreenBufferSize.X) windy -= GetSystemMetrics(SM_CYHSCROLL); // new window will have a horizontal scroll bar
- if (chary < Buff->ScreenBufferSize.Y) windx -= GetSystemMetrics(SM_CXVSCROLL); // new window will have a vertical scroll bar
+ if (charx < (DWORD)Buff->ScreenBufferSize.X) windy -= GetSystemMetrics(SM_CYHSCROLL); // new window will have a horizontal scroll bar
+ if (chary < (DWORD)Buff->ScreenBufferSize.Y) windx -= GetSystemMetrics(SM_CXVSCROLL); // new window will have a vertical scroll bar
charx = windx / (int)WidthUnit ;
chary = windy / (int)HeightUnit;
// Resize window
if ((charx != Buff->ViewSize.X) || (chary != Buff->ViewSize.Y))
{
- Buff->ViewSize.X = (charx <= Buff->ScreenBufferSize.X) ? charx : Buff->ScreenBufferSize.X;
- Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
+ Buff->ViewSize.X = (charx <= (DWORD)Buff->ScreenBufferSize.X) ? charx : Buff->ScreenBufferSize.X;
+ Buff->ViewSize.Y = (chary <= (DWORD)Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
}
ResizeConWnd(GuiData, WidthUnit, HeightUnit);
int old_pos, Maximum;
PSHORT pShowXY;
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return 0;
+ if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return 0;
Buff = GuiData->ActiveBuffer;
case WM_SETCURSOR:
{
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) goto Default;
+
/*
* The message was sent because we are manually triggering a change.
* Check whether the mouse is indeed present on this console window
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
+ case WM_XBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
+ case WM_XBUTTONUP:
case WM_LBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
+ case WM_XBUTTONDBLCLK:
case WM_MOUSEMOVE:
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
case WM_CONTEXTMENU:
{
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) break;
+
if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
{
HMENU hMenu = CreatePopupMenu();
DWORD Width, Height;
UINT WidthUnit, HeightUnit;
+ /* Do nothing if the window is hidden */
+ if (!GuiData->IsWindowVisible) break;
+
GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
Width = Buff->ScreenBufferSize.X * WidthUnit ;
break;
}
- case PM_APPLY_CONSOLE_INFO:
- {
- GuiApplyUserSettings(GuiData, (HANDLE)wParam, (BOOL)lParam);
- break;
- }
-
/*
* Undocumented message sent by Windows' console.dll for applying console info.
* See http://www.catch22.net/sites/default/source/files/setconsoleinfo.c
*/
case WM_SETCONSOLEINFO:
{
- DPRINT1("WM_SETCONSOLEINFO message\n");
- GuiApplyWindowsConsoleSettings(GuiData, (HANDLE)wParam);
+ GuiApplyUserSettings(GuiData, (HANDLE)wParam);
break;
}
break;
// case PM_CONSOLE_SET_TITLE:
- // SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
+ // SetWindowTextW(GuiData->hWindow, GuiData->Console->Title.Buffer);
// break;
default: Default: