bool NativeEnginePrivate::handleGlWidgetEvent(QEvent *event)
{
    switch (event->type()) {
    case QEvent::KeyPress:
        {
            QKeyEvent *ke = static_cast<QKeyEvent*>(event);
            if (keyPressCallback) {
                QScopedArrayPointer<wchar_t> text(new wchar_t[ke->text().length()]);
                ke->text().toWCharArray(text.data());
                keyPressCallback(ke->count(), ke->isAutoRepeat(), ke->key(), ke->modifiers(), text.data());
            }
        }
        return true;

    case QEvent::KeyRelease:
    {
        QKeyEvent *ke = static_cast<QKeyEvent*>(event);
        if (keyReleaseCallback) {
            QScopedArrayPointer<wchar_t> text(new wchar_t[ke->text().length()]);
            ke->text().toWCharArray(text.data());
            keyReleaseCallback(ke->count(), ke->isAutoRepeat(), ke->key(), ke->modifiers(), text.data());
        }
    }
        return true;

    case QEvent::MouseButtonDblClick:
        if (mouseDoubleClickCallback)
            mouseDoubleClickCallback(createMouseEvent(static_cast<QMouseEvent*>(event)));
        return true;

    case QEvent::MouseButtonPress:
        if (mousePressCallback)
            mousePressCallback(createMouseEvent(static_cast<QMouseEvent*>(event)));
        return true;

    case QEvent::MouseButtonRelease:
        if (mouseReleaseCallback)
            mouseReleaseCallback(createMouseEvent(static_cast<QMouseEvent*>(event)));
        return true;

    case QEvent::MouseMove:
        if (mouseMoveCallback)
            mouseMoveCallback(createMouseEvent(static_cast<QMouseEvent*>(event)));
        return true;

    case QEvent::Wheel:
        if (wheelCallback)
            wheelCallback(createWheelEvent(static_cast<QWheelEvent*>(event)));
        return true;

    case QEvent::Paint:
        // Ignore all paint events, we handle this ourselves
        return true;

    default:
        // By default pass unknown events to the widget
        return false;
    }
}
Beispiel #2
0
    //-----------------------------------------------------------------------
	void InputReader::mouseMoved()
	{

		if (mModifiers & InputEvent::BUTTON_ANY_MASK)	// don't need to know which button. you can get that from the modifiers
		{
			createMouseEvent(MouseEvent::ME_MOUSE_DRAGGED, 0);
		}
		else
		{
			createMouseEvent(MouseEvent::ME_MOUSE_MOVED, 0);
		}
	}
Beispiel #3
0
bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
{
    ASSERT(dragData);
    ASSERT(m_documentUnderMouse);
    RefPtr<Frame> mainFrame = m_page->mainFrame();
    RefPtr<FrameView> viewProtector = mainFrame->view();
    if (!viewProtector)
        return false;

    ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLocal() ? ClipboardReadable : ClipboardTypesReadable;
    RefPtr<Clipboard> clipboard = Clipboard::create(policy, dragData, mainFrame.get());
    DragOperation srcOpMask = dragData->draggingSourceOperationMask();
    clipboard->setSourceOperation(srcOpMask);

    PlatformMouseEvent event = createMouseEvent(dragData);
    if (!mainFrame->eventHandler()->updateDragAndDrop(event, clipboard.get())) {
        clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
        return false;
    }

    operation = clipboard->destinationOperation();
    if (clipboard->dropEffectIsUninitialized())
        operation = defaultOperationForDrag(srcOpMask);
    else if (!(srcOpMask & operation)) {
        // The element picked an operation which is not supported by the source
        operation = DragOperationNone;
    }

    clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
    return true;
}
Beispiel #4
0
bool DragController::performDrag(DragData* dragData)
{
    ASSERT(dragData);
    m_documentUnderMouse = m_page->mainFrame()->documentAtPoint(dragData->clientPosition());
    if (m_dragDestinationAction & DragDestinationActionDHTML) {
        m_client->willPerformDragDestinationAction(DragDestinationActionDHTML, dragData);
        RefPtr<Frame> mainFrame = m_page->mainFrame();
        bool preventedDefault = false;
        if (mainFrame->view()) {
            // Sending an event can result in the destruction of the view and part.
            RefPtr<Clipboard> clipboard = Clipboard::create(ClipboardReadable, dragData, mainFrame.get());
            clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
            preventedDefault = mainFrame->eventHandler()->performDragAndDrop(createMouseEvent(dragData), clipboard.get());
            clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard here for security
        }
        if (preventedDefault) {
            m_documentUnderMouse = 0;
            return true;
        }
    }

    if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDrag(dragData)) {
        m_documentUnderMouse = 0;
        return true;
    }

    m_documentUnderMouse = 0;

    if (operationForLoad(dragData) == DragOperationNone)
        return false;

    m_client->willPerformDragDestinationAction(DragDestinationActionLoad, dragData);
    m_page->mainFrame()->loader()->load(ResourceRequest(dragData->asURL(m_page->mainFrame())), false);
    return true;
}
Beispiel #5
0
    //-----------------------------------------------------------------------
	void InputReader::triggerMouseButton(int nMouseCode, bool mousePressed)
	{
		if (mousePressed)
		{
			mModifiers |= nMouseCode;
			createMouseEvent(MouseEvent::ME_MOUSE_PRESSED, nMouseCode);
            // Update immediate-mode mouse button state
            switch(nMouseCode)
            {
            case InputEvent::BUTTON0_MASK:
                mMouseState.Buttons |= 0x1;
                break;
            case InputEvent::BUTTON1_MASK:
                mMouseState.Buttons |= 0x2;
                break;
            case InputEvent::BUTTON2_MASK:
                mMouseState.Buttons |= 0x4;
                break;
            }

		}
		else
		{	// button up... trigger MouseReleased, and MouseClicked
			mModifiers &= ~nMouseCode;
			createMouseEvent(MouseEvent::ME_MOUSE_RELEASED, nMouseCode);
			//createMouseEvent(MouseEvent::ME_MOUSE_CLICKED, nMouseCode);	JCA - moved to EventDispatcher
            // Update immediate-mode mouse button state
            switch(nMouseCode)
            {
            case InputEvent::BUTTON0_MASK:
                mMouseState.Buttons &= 0xFE;
                break;
            case InputEvent::BUTTON1_MASK:
                mMouseState.Buttons &= 0xFD;
                break;
            case InputEvent::BUTTON2_MASK:
                mMouseState.Buttons &= 0xFB;
                break;
            }
		}

	}
void DragController::dragExited(DragData* dragData)
{
    ASSERT(dragData);
    Frame* mainFrame = m_page->mainFrame();

    if (RefPtr<FrameView> v = mainFrame->view()) {
        ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnderMouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable;
        RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
        clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
        mainFrame->eventHandler()->cancelDragAndDrop(createMouseEvent(dragData), clipboard.get());
        clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
    }
    mouseMovedIntoDocument(0);
}
Beispiel #7
0
	void Renderer::begin()
	{
		ContextSettings contextSettings;
		contextSettings.depthBits = 32;
		window = new RenderWindow ( VideoMode ( tam.x, tam.y ), name, Style::Default, contextSettings );

		active = true;
		window->setActive();

		glClearDepth ( 0xff );
		glClearColor ( 0xff, 0xff, 0xff, 0xff );

		bool kb[256] = {0};
//    sprite.getOrigin(0,0);
		while ( window->isOpen() ) {
			for ( auto x : syncList ) {
				x->update ( 0 );

			}

			Event event;
			while ( window->pollEvent ( event ) ) {
				if ( event.type == Event::Closed || !active ) {
					window->close();
				}
				createMouseEvent ( event );
				createKeyBoardEvent ( event );
				createCharEvents ( event );
				if ( event.type == Event::Resized ) {
				}
			}
			std::this_thread::sleep_for ( std::chrono::milliseconds ( 16 ) );

			window->clear ( Color ( 0x00, 0x00, 0x00, 0x00 ) );

			drawSprites();

			window->display();
		}
	}
DragOperation DragController::tryDHTMLDrag(DragData* dragData)
{   
    ASSERT(dragData);
    ASSERT(m_document);
    DragOperation op = DragOperationNone;
    RefPtr<Frame> frame = m_page->mainFrame();
    RefPtr<FrameView> viewProtector = frame->view();
    if (!viewProtector)
        return DragOperationNone;
    
    ClipboardAccessPolicy policy = frame->loader()->baseURL().isLocalFile() ? ClipboardReadable : ClipboardTypesReadable;
    RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
    DragOperation srcOp = dragData->draggingSourceOperationMask();
    clipboard->setSourceOperation(srcOp);
    
    PlatformMouseEvent event = createMouseEvent(dragData);
    if (frame->eventHandler()->updateDragAndDrop(event, clipboard.get())) {
        // *op unchanged if no source op was set
        if (!clipboard->destinationOperation(op)) {
            // The element accepted but they didn't pick an operation, so we pick one for them
            // (as does WinIE).
            if (srcOp & DragOperationCopy)
                op = DragOperationCopy;
            else if (srcOp & DragOperationMove || srcOp & DragOperationGeneric)
                op = DragOperationMove;
            else if (srcOp & DragOperationLink)
                op = DragOperationLink;
            else
                op = DragOperationGeneric;
        } else if (!(op & srcOp)) {
            op = DragOperationNone;
        }

        clipboard->setAccessPolicy(ClipboardNumb);    // invalidate clipboard here for security
        return op;
    }
    return op;
}
Beispiel #9
0
EventPtr SDLWindow::createMouseButtonEvent(Event::Type type, 
        const SDL_Event& sdlEvent) 
{
    long button = 0;
    switch (sdlEvent.button.button) {
        case SDL_BUTTON_LEFT:
            button = MouseEvent::LEFT_BUTTON;
            break;
        case SDL_BUTTON_MIDDLE:
            button = MouseEvent::MIDDLE_BUTTON;
            break;
        case SDL_BUTTON_RIGHT:
            button = MouseEvent::RIGHT_BUTTON;
            break;
        case SDL_BUTTON_WHEELUP:
            button = MouseEvent::WHEELUP_BUTTON;
            break;
        case SDL_BUTTON_WHEELDOWN:
            button = MouseEvent::WHEELDOWN_BUTTON;
            break;
    }
    return createMouseEvent(type, sdlEvent, button);
 
}
Beispiel #10
0
void wxGripWindow::OnMotion( wxMouseEvent& event ) {
    // create a motion event
    int x = 0, y = 0;
    event.GetPosition( &x, &y );
    createMouseEvent( wxEVT_GRIP_MOTION, x, y );
}
Beispiel #11
0
void wxGripWindow::OnLeftUp( wxMouseEvent& event ) {
    // create a left-up event
    int x = 0, y = 0;
    event.GetPosition( &x, &y );
    createMouseEvent( wxEVT_GRIP_LEFTUP, x, y );
}
Beispiel #12
0
void wxGripWindow::OnLeftDown( wxMouseEvent& event ) {
    // create a left-down event
    int x = 0, y = 0;
    event.GetPosition( &x, &y );
    createMouseEvent( wxEVT_GRIP_LEFTDOWN, x, y );
}
Beispiel #13
0
void wxGripWindow::OnDoubleClick( wxMouseEvent& event ) {
    // create a double-click event
    int x = 0, y = 0;
    event.GetPosition( &x, &y );
    createMouseEvent( wxEVT_GRIP_DBLCLICK, x, y );
}
Beispiel #14
0
vector<EventPtr> SDLWindow::pollEvents()
{
    SDL_Event sdlEvent;
    vector<EventPtr> events;

    int numEvents = 0;
    while (SDL_PollEvent(&sdlEvent)) {
        numEvents++;
        EventPtr pNewEvent;
        switch (sdlEvent.type) {
            case SDL_MOUSEMOTION:
                {
                    pNewEvent = createMouseEvent(Event::CURSOR_MOTION, sdlEvent, 
                            MouseEvent::NO_BUTTON);
                    CursorEventPtr pNewCursorEvent = 
                            boost::dynamic_pointer_cast<CursorEvent>(pNewEvent);
                    if (!events.empty()) {
                        CursorEventPtr pLastEvent = 
                                boost::dynamic_pointer_cast<CursorEvent>(events.back());
                        if (pLastEvent && *pNewCursorEvent == *pLastEvent) {
                            pNewEvent = EventPtr();
                        }
                    }
                }
                break;
            case SDL_MOUSEBUTTONDOWN:
                pNewEvent = createMouseButtonEvent(Event::CURSOR_DOWN, sdlEvent);
                break;
            case SDL_MOUSEBUTTONUP:
                pNewEvent = createMouseButtonEvent(Event::CURSOR_UP, sdlEvent);
                break;
            case SDL_JOYAXISMOTION:
//                pNewEvent = createAxisEvent(sdlEvent));
                break;
            case SDL_JOYBUTTONDOWN:
//                pNewEvent = createButtonEvent(Event::BUTTON_DOWN, sdlEvent));
                break;
            case SDL_JOYBUTTONUP:
//                pNewEvent = createButtonEvent(Event::BUTTON_UP, sdlEvent));
                break;
            case SDL_KEYDOWN:
                pNewEvent = createKeyEvent(Event::KEY_DOWN, sdlEvent);
                break;
            case SDL_KEYUP:
                pNewEvent = createKeyEvent(Event::KEY_UP, sdlEvent);
                break;
            case SDL_QUIT:
                pNewEvent = EventPtr(new Event(Event::QUIT, Event::NONE));
                break;
            case SDL_VIDEORESIZE:
                break;
            case SDL_SYSWMEVENT:
                {
#if defined(HAVE_XI2_1) || defined(HAVE_XI2_2) 
                    SDL_SysWMmsg* pMsg = sdlEvent.syswm.msg;
                    AVG_ASSERT(pMsg->subsystem == SDL_SYSWM_X11);
                    if (m_pXIMTInputDevice) {
                        m_pXIMTInputDevice->handleXIEvent(pMsg->event.xevent);
                    }
#endif
                }
                break;
            default:
                // Ignore unknown events.
                break;
        }
        if (pNewEvent) {
            events.push_back(pNewEvent);
        }
    }
    if (numEvents > 124) {
        AVG_TRACE(Logger::category::EVENTS, Logger::severity::WARNING, 
                "SDL Event queue full, dropping events.");
    }
    return events;
}