Esempio n. 1
0
void InternalWindow::setIconify(bool Iconify)
{
    if(Iconify && !getIsIcon())
    {
        //TODO: Implement
        setIsIcon(Iconify);

        produceWindowIconified();
    }
    else if(!Iconify && getIsIcon())
    {
        //TODO: Implement
        setIsIcon(Iconify);

        produceWindowDeiconified();
    }
}
Esempio n. 2
0
void XWindow::handleEvent(XEvent& Event)
{
    switch (Event.type) 
    {
        case KeyPress:
            //produceKeyPressed(determineKey(wParam),getKeyModifiers());
            _LastKeyboardMouseButtonMask = Event.xkey.state;
            produceKeyPressed(determineKey(XLookupKeysym(&(Event.xkey), 0)),determineKeyModifiers(Event.xkey.state));
            break;
        case KeyRelease:
            //produceKeyReleased(determineKey(wParam),getKeyModifiers());
            _LastKeyboardMouseButtonMask = Event.xkey.state;
            produceKeyReleased(determineKey(XLookupKeysym(&(Event.xkey),0)),determineKeyModifiers(Event.xkey.state));
            break;
        case MotionNotify:
            {
                _LastKeyboardMouseButtonMask = Event.xmotion.state;
                _LastMousePosition.setValues(Event.xbutton.x, Event.xbutton.y);
                if(Event.xmotion.state & Button1MotionMask)
                {
                    produceMouseDragged(MouseEventDetails::BUTTON1,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f));
                }
                if(Event.xmotion.state & Button2MotionMask)
                {
                    produceMouseDragged(MouseEventDetails::BUTTON2,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f));
                }
                if(Event.xmotion.state & Button3MotionMask)
                {
                    produceMouseDragged(MouseEventDetails::BUTTON3,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f));
                }
                if(Event.xmotion.state & Button4MotionMask)
                {
                    produceMouseDragged(MouseEventDetails::BUTTON4,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f));
                }
                if(Event.xmotion.state & Button5MotionMask)
                {
                    produceMouseDragged(MouseEventDetails::BUTTON5,Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f));
                }
                
                produceMouseMoved(Pnt2f(Event.xmotion.x, Event.xmotion.y), Vec2f(0.0f,0.0f));
                break;
            }
         case ButtonPress:
            {
                _LastKeyboardMouseButtonMask = Event.xbutton.state;
               _LastMousePosition.setValues(Event.xbutton.x, Event.xbutton.y);
               MouseEventDetails::MouseButton OSGButton(MouseEventDetails::NO_BUTTON);
               switch(Event.xbutton.button)
               {
               case  1:
                  OSGButton = MouseEventDetails::BUTTON1;
                  break;
               case  2:
                  OSGButton = MouseEventDetails::BUTTON2;
                  break;
               case  3:
                  OSGButton = MouseEventDetails::BUTTON3;
                  break;
               case   4:
				  produceMouseWheelMoved(1, Pnt2f(Event.xbutton.x, Event.xbutton.y));
                  break;
               case   5:
				  produceMouseWheelMoved(-1, Pnt2f(Event.xbutton.x, Event.xbutton.y));
                  break;
               case   6:
                  OSGButton = MouseEventDetails::BUTTON6;
                  break;
               case   7:
                  OSGButton = MouseEventDetails::BUTTON7;
                  break;
               case   8:
                  OSGButton = MouseEventDetails::BUTTON8;
                  break;
               case   9:
                  OSGButton = MouseEventDetails::BUTTON9;
                  break;
               case   10:
                  OSGButton = MouseEventDetails::BUTTON10;
                  break;
               default:
                  OSGButton = MouseEventDetails::NO_BUTTON;
                  break;
               }
               if(OSGButton != MouseEventDetails::NO_BUTTON)
               {
                   produceMousePressed(OSGButton, Pnt2f(Event.xbutton.x, Event.xbutton.y));
               }
               break;
            }

         case ButtonRelease:
            {
               _LastKeyboardMouseButtonMask = Event.xbutton.state;
               _LastMousePosition.setValues(Event.xbutton.x, Event.xbutton.y);
               MouseEventDetails::MouseButton OSGButton(MouseEventDetails::NO_BUTTON);
              switch(Event.xbutton.button)
              {
              case  1:
                 OSGButton = MouseEventDetails::BUTTON1;
                 break;
              case  2:
                 OSGButton = MouseEventDetails::BUTTON2;
                 break;
               case  3:
                  OSGButton = MouseEventDetails::BUTTON3;
                  break;
               case   6:
                  OSGButton = MouseEventDetails::BUTTON6;
                  break;
               case   7:
                  OSGButton = MouseEventDetails::BUTTON7;
                  break;
               case   8:
                  OSGButton = MouseEventDetails::BUTTON8;
                  break;
               case   9:
                  OSGButton = MouseEventDetails::BUTTON9;
                  break;
               case   10:
                  OSGButton = MouseEventDetails::BUTTON10;
                  break;
              default:
                 break;
              }
               if(OSGButton != MouseEventDetails::NO_BUTTON)
               {
                   produceMouseReleased(OSGButton, Pnt2f(Event.xbutton.x, Event.xbutton.y));
               }
              break;
            }
         case ConfigureNotify:
               this->resize( Event.xconfigure.width,
                            Event.xconfigure.height );

               internalReshape(Vec2f(Event.xconfigure.width, Event.xconfigure.height));
            break;
            
         case DestroyNotify:
            produceWindowClosing();
            produceWindowClosed();
            break;
         case EnterNotify:
            produceWindowEntered();
            break;
         case LeaveNotify:
            produceWindowExited();
            break;
         case UnmapNotify:
            produceWindowIconified();
            break;
         case MapNotify:
            produceWindowDeiconified();
            break;
         case FocusIn:
            produceWindowActivated();
            break;
         case FocusOut:
            produceWindowDeactivated();
            break;
         case Expose:
            internalDraw();
            break;
        case ClientMessage:
        {
            Atom wm_delete_window=XInternAtom(this->getDisplay(), "WM_DELETE_WINDOW", False);
            Atom wm_protocols=XInternAtom(this->getDisplay(), "WM_PROTOCOLS", False);
            if (Event.xclient.message_type == wm_protocols &&
                Event.xclient.data.l[0] == (long)wm_delete_window)
            {
                XDestroyWindow(this->getDisplay(),this->getWindow());
            }
            break;
        }
        default:
            //std::cout << "Event Type: " << Event.type << std::endl;
            break;
      }
}