Exemple #1
0
static unsigned int scrollScreen(unsigned int offset) {
    if (offset < VIDEO_ROWS * VIDEO_COLS * 2) {
        return offset;
    }

    // copy each row to the row above it
    for (unsigned int i = 1; i < VIDEO_ROWS; ++i) {
        memcpy((char*)(VIDEO_ADDR + screenOffset(i-1, 0)),
               (char*)(VIDEO_ADDR + screenOffset(i, 0)),
                VIDEO_COLS * 2);
    }

    // zero out last line
    char* lastLine = (char*)(VIDEO_ADDR + screenOffset(VIDEO_ROWS - 1, 0));
    for (unsigned int i = 0; i < VIDEO_COLS * 2; ++i) {
        lastLine[i] = 0;
    }

    // move cursor offset up 1 row
    offset -= 2 * VIDEO_COLS;

    return offset;
}
void
SoXipMenuBase::GLRender( SoGLRenderAction* action )
{
	if( on.getValue() == FALSE )
		return ;

	// Compute the 3D position of the menu, given the mouse 2D position
	saveViewInformation( action );

	mMenuOffset->translation.setValue( mPlaneProj->project( position.getValue() ) );

	SoGetBoundingBoxAction bba( action->getViewportRegion() );
	bba.apply( mMenuSeparator );

	SbBox3f bbox = bba.getBoundingBox();
	bbox.transform( mModelMatrix );

	float viewportAR = mViewport.getViewportAspectRatio();
	SbVec3f screenOffset(0, 0, 0);
	if( viewportAR < 1. )
	{
		screenOffset[0] = bbox.getMax()[0] - 1.;
		screenOffset[1] = bbox.getMax()[1] - 1. / viewportAR;
	}
	else
	{
		screenOffset[0] = bbox.getMax()[0] - viewportAR;
		screenOffset[1] = bbox.getMax()[1] - 1;
	}

	if( screenOffset[0] < 0 )
		screenOffset[0] = 0;
	if( screenOffset[1] < 0 )
		screenOffset[1] = 0;

	SbVec3f worldOffset;
	mModelMatrix.inverse().multVecMatrix( screenOffset, worldOffset );

	mMenuOffset->translation.setValue( mMenuOffset->translation.getValue() - worldOffset );

	glPushAttrib( GL_ENABLE_BIT );
	glDisable( GL_DEPTH_TEST );

	SoXipKit::GLRender( action );

	glPopAttrib();
}
Exemple #3
0
char kPutChar(char ch) {
    char* vidmem = (char *) VIDEO_ADDR;

    unsigned int offset = getCursorOffset();

    if (ch == '\n') {
        int row = offset / (VIDEO_COLS * 2);
        offset = screenOffset(row + 1, 0);
    } else if (ch == '\b') {
        offset -= 2;
        vidmem[offset] = ' ';
        vidmem[offset+1] = g_attr;
    } else {
        vidmem[offset] = ch;
        vidmem[offset+1] = g_attr;
        offset += 2;
    }

    offset = scrollScreen(offset);

    setCursorOffset(offset);

    return ch;
}
Exemple #4
0
void TouchEventHandler::handleTouchPoint(const Platform::TouchPoint& point, unsigned modifiers)
{
    // Enable input mode on any touch event.
    m_webPage->m_inputHandler->setInputModeEnabled();

    bool shiftActive = modifiers & KEYMOD_SHIFT;
    bool altActive = modifiers & KEYMOD_ALT;
    bool ctrlActive = modifiers & KEYMOD_CTRL;

    switch (point.state()) {
    case Platform::TouchPoint::TouchPressed:
        {
            // Clear spellcheck state on any touch event
            m_webPage->m_inputHandler->clearDidSpellCheckState();

            if (!m_lastFatFingersResult.isValid())
                doFatFingers(point);

            Element* elementUnderFatFinger = m_lastFatFingersResult.nodeAsElementIfApplicable();

            // Check for text selection
            if (m_lastFatFingersResult.isTextInput()) {
                elementUnderFatFinger = m_lastFatFingersResult.nodeAsElementIfApplicable(FatFingersResult::ShadowContentNotAllowed, true /* shouldUseRootEditableElement */);
                m_shouldRequestSpellCheckOptions = m_webPage->m_inputHandler->shouldRequestSpellCheckingOptionsForPoint(point.documentContentPosition(), elementUnderFatFinger, m_spellCheckOptionRequest);
            }

            handleFatFingerPressed(shiftActive, altActive, ctrlActive);
            break;
        }
    case Platform::TouchPoint::TouchReleased:
        {

            if (!m_shouldRequestSpellCheckOptions)
                m_webPage->m_inputHandler->processPendingKeyboardVisibilityChange();

            // The rebase has eliminated a necessary event when the mouse does not
            // trigger an actual selection change preventing re-showing of the
            // keyboard. If input mode is active, call showVirtualKeyboard which
            // will update the state and display keyboard if needed.
            if (m_webPage->m_inputHandler->isInputMode())
                m_webPage->m_inputHandler->notifyClientOfKeyboardVisibilityChange(true);

            m_webPage->m_tapHighlight->hide();

            IntPoint adjustedPoint = m_webPage->mapFromContentsToViewport(m_lastFatFingersResult.adjustedPosition());
            PlatformMouseEvent mouseEvent(adjustedPoint, m_lastScreenPoint, PlatformEvent::MouseReleased, 1, LeftButton, shiftActive, ctrlActive, altActive, TouchScreen);

            m_webPage->handleMouseEvent(mouseEvent);

            if (m_shouldRequestSpellCheckOptions) {
                IntPoint pixelPositionRelativeToViewport = m_webPage->mapToTransformed(adjustedPoint);
                IntSize screenOffset(m_lastScreenPoint - pixelPositionRelativeToViewport);
                m_webPage->m_inputHandler->requestSpellingCheckingOptions(m_spellCheckOptionRequest, screenOffset);
                m_shouldRequestSpellCheckOptions = false;
            }

            m_lastFatFingersResult.reset(); // Reset the fat finger result as its no longer valid when a user's finger is not on the screen.
            break;
        }
    case Platform::TouchPoint::TouchMoved:
        {
            // Clear spellcheck state on any touch event
            m_webPage->m_inputHandler->clearDidSpellCheckState();

            // You can still send mouse move events
            PlatformMouseEvent mouseEvent(point.documentViewportPosition(), m_lastScreenPoint, PlatformEvent::MouseMoved, 1, LeftButton, shiftActive, ctrlActive, altActive, TouchScreen);
            m_lastScreenPoint = point.screenPosition();
            m_webPage->handleMouseEvent(mouseEvent);
            break;
        }
    default:
        break;
    }
}
Exemple #5
0
void kSetCursor(unsigned int row, unsigned int col) {
    unsigned int offset = screenOffset(row, col);
    setCursorOffset(offset);
}