TerminalDisplayWin::TerminalDisplayWin(): TerminalDisplay(false), fStartLine(0), fIsAttached(false) { fOut = ::GetStdHandle(STD_OUTPUT_HANDLE); bool isConsole = ::GetConsoleMode(fOut, &fOldMode) != 0; SetIsTTY(isConsole); if (isConsole) { // Prevent redirection from stealing our console handle, // simply open our own. fOut = ::CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); ::GetConsoleMode(fOut, &fOldMode); fMyMode = fOldMode | ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT; } HandleResizeEvent(); }
bool View::eventFilter(QObject* pTarget, QEvent* pEvent) { QEvent::Type eventType = pEvent->type(); if (eventType == QEvent::MouseMove) { TouchEvent touchEvent; touchEvent.x = ((QMouseEvent*)pEvent)->x(); touchEvent.y = ((QMouseEvent*)pEvent)->y(); touchEvent.id = 0; touchEvent.type = TouchEvent::Type_Move; HandleTouch(&touchEvent); return true; } else if (eventType == QEvent::MouseButtonPress) { if (m_numButtonsPressed == 0) { if (((QMouseEvent*)pEvent)->button() == Qt::RightButton) { InputModeChangeEvent event; event.mode = InputMode_Gesture; m_pEventDispatcher->DispatchInputModeChangeEvent(&event); } TouchEvent touchEvent; touchEvent.x = ((QMouseEvent*)pEvent)->x(); touchEvent.y = ((QMouseEvent*)pEvent)->y(); touchEvent.id = 0; touchEvent.type = TouchEvent::Type_Press; HandleTouch(&touchEvent); } m_numButtonsPressed++; return true; } else if (eventType == QEvent::MouseButtonRelease) { if (m_numButtonsPressed > 0) { /* * Only process the mouse release event if the * numButtonsPressed is greater than 0 since a * double click will send two release events for * every one press event which would otherwise * make numButtonsPressed negative. */ m_numButtonsPressed--; if (m_numButtonsPressed == 0) { TouchEvent touchEvent; touchEvent.x = ((QMouseEvent*)pEvent)->x(); touchEvent.y = ((QMouseEvent*)pEvent)->y(); touchEvent.id = 0; touchEvent.type = TouchEvent::Type_Release; HandleTouch(&touchEvent); } } return true; } else if ((eventType == QEvent::TouchUpdate) || (eventType == QEvent::TouchBegin) || (eventType == QEvent::TouchEnd)) { ProcessQTouchEvent((QTouchEvent*)pEvent); pEvent->setAccepted(true); return true; } else if (eventType == QEvent::KeyPress) { KeyEvent keyEvent; keyEvent.id = ((QKeyEvent*)pEvent)->key(); keyEvent.key = ((QKeyEvent*)pEvent)->key(); keyEvent.type = KeyEvent::Type_Press; ProcessKeyPressEvent(&keyEvent); return true; } else if (eventType == QEvent::KeyRelease) { KeyEvent keyEvent; keyEvent.id = ((QKeyEvent*)pEvent)->key(); keyEvent.key = ((QKeyEvent*)pEvent)->key(); keyEvent.type = KeyEvent::Type_Release; ProcessKeyReleaseEvent(&keyEvent); return true; } else if (eventType == QEvent::Resize) { HandleResizeEvent((QResizeEvent*)pEvent); return false; } else if (eventType == QEvent::Close) { HandleCloseEvent((QCloseEvent*)pEvent); return true; } return QObject::eventFilter(pTarget, pEvent); }