Exemplo n.º 1
0
 void Paint()
 {
     if (this->disableCount == 0)
     {
         cursor.Erase();
         cursor.Paint(this->posX, this->posY);
     }
     commonParams->mouse.x = this->prevX = this->posX;
     commonParams->mouse.y = this->prevY = this->posY;
     commonParams->mouse.buttons = this->prevButton = this->button;
 }
Exemplo n.º 2
0
    bool Initialize()
    {
        MessageInfo msg;
        uint32_t tid;
        if (monapi_name_whereis("/servers/process", tid) != M_OK) {
            monapi_warn("process server not found");
        }

        if (Message::sendReceive(&msg, tid, MSG_PROCESS_GET_COMMON_PARAMS) != M_OK)
        {
            syscall_print("Mouse Server: can not get common parameters\n");
            return false;
        }
        commonParams = (CommonParameters*)MemoryMap::map(msg.arg2);

        /* mouse information destination list */
        this->destList = new HList<uint32_t>();
        if (this->destList == NULL)
        {
            syscall_print("Mouse Server: destList error\n");
            return false;
        }

        /* screen size */
        this->w = screen.getWidth();
        this->h = screen.getHeight();

        /* cursor to center */
        commonParams->mouse.x = this->posX = this->prevX = this->w / 2;
        commonParams->mouse.y = this->posY = this->prevY = this->h / 2;
        commonParams->mouse.buttons = this->button = this->prevButton = 0;

        /* server start ok */
        if (!SendServerOK()) return false;

        cursor.Paint(this->posX, this->posY);

        return true;
    }
Exemplo n.º 3
0
    void MessageLoop()
    {
        for (MessageInfo receive;;)
        {
            if (Message::receive(&receive)) continue;

            switch(receive.header)
            {
            case MSG_ADD:
                /* arg1 = tid */
                this->destList->add(receive.arg1);
                Message::reply(&receive);
                break;

            case MSG_REMOVE:
                /* arg1 = tid */
                this->destList->remove(receive.arg1);
                Message::reply(&receive);
                break;

            case MSG_MOUSE_ENABLE_CURSOR:
                if (this->disableCount > 0)
                {
                    this->disableCount--;
                    if (this->disableCount == 0) cursor.Paint(this->prevX, this->prevY);
                }
                Message::reply(&receive);
                break;

            case MSG_MOUSE_DISABLE_CURSOR:
                if (this->disableCount == 0) cursor.Erase();
                this->disableCount++;
                Message::reply(&receive);
                break;

            case MSG_MOUSE_GET_CURSOR_POSITION:
                Message::reply(&receive, this->prevX, this->prevY);
                break;

            case MSG_MOUSE_SET_CURSOR_POSITION:
                this->posX = receive.arg1;
                this->posY = receive.arg2;
                Paint();
                Message::reply(&receive);
                SendMouseInformation();
                break;

            case MSG_INTERRUPTED:
                /* we get not all data */
                if (GetMouseData() != 2) break;

                /* state not changed. */
                if (!SetCurosor()) break;

                Paint();
                SendMouseInformation();

                break;

            default:
                /* ignore */
//                _printf("mouse:header=%x", receive.header);
                break;
            }
        }
    }