void NativeEngine::handle_cmd(int32_t cmd){
	switch (cmd) {
		case APP_CMD_INPUT_CHANGED:
			on_input_changed();
			break;
		case APP_CMD_INIT_WINDOW:
			on_init_window();
			break;
		case APP_CMD_TERM_WINDOW:
			on_term_window();
			break;
		case APP_CMD_WINDOW_RESIZED:
			on_window_resized();
			break;
		case APP_CMD_WINDOW_REDRAW_NEEDED:
			on_window_redraw_needed();
			break;
		case APP_CMD_CONTENT_RECT_CHANGED:
			on_content_rect_changed();
			break;
		case APP_CMD_GAINED_FOCUS:
			on_gained_focus();
			break;
		case APP_CMD_LOST_FOCUS:
			on_lost_focus();
			break;
		case APP_CMD_CONFIG_CHANGED:
			on_config_changed();
			break;
		case APP_CMD_LOW_MEMORY:
			on_low_memory();
			break;
		case APP_CMD_START:
			on_start();
			break;
		case APP_CMD_RESUME:
			on_resume();
			break;
		case APP_CMD_SAVE_STATE:
			on_save_state();
			break;
		case APP_CMD_PAUSE:
			on_pause();
			break;
		case APP_CMD_STOP:
			on_stop();
			break;
		case APP_CMD_DESTROY:
			on_destroy();
			break;
	}
}
Exemplo n.º 2
0
  bool window::dispatch_event ( XEvent& evt )
	{
    switch ( evt.type )
		{
      case Expose:
        exposed();
        break;
		case ButtonPress:
	      if ( evt.xbutton.button & Button2 )
           on_right_button_down ( evt.xbutton.x, evt.xbutton.y );
		    else if ( evt.xbutton.button & Button1 )
           on_left_button_down ( evt.xbutton.x, evt.xbutton.y );
		    break;
		case ButtonRelease:
		    if ( evt.xbutton.button & Button2 )
            on_right_button_up ( evt.xbutton.x, evt.xbutton.y );
		    else if ( evt.xbutton.button & Button1 )
            on_left_button_up ( evt.xbutton.x, evt.xbutton.y );
		    break;
		case EnterNotify:
		    on_mouse_enter ( evt.xcrossing.x, evt.xcrossing.y );
		    break;
		case LeaveNotify:
		    on_mouse_exit ( evt.xcrossing.x, evt.xcrossing.y );
		    break;
		case MotionNotify:
		    on_mouse_move ( evt.xmotion.x, evt.xmotion.y );
		    break;
		case FocusIn:
		    on_got_focus();
		    break;
		case FocusOut:
		    on_lost_focus();
		    break;
		case KeyPress:
		case KeyRelease:
        {
          character cp;
          KeySym keysym;
          XComposeStatus status;
          int count = XLookupString ( &evt.xkey, cp.text, character::MAX_CHAR_TEXT, &keysym, &status );
          cp.text[count] = 0;
          if ( evt.type == KeyPress )
            on_key_press ( cp );
          else
            on_key_release ( cp );
        } break;

		case MapNotify:
		  state = WINDOW_SHOWN;
      shown();
		  break;

		case UnmapNotify:
		  state = WINDOW_HIDDEN;
	    hidden();
		  break;

    case ConfigureNotify:
      //XClearWindow ( env, hwnd );
	    //XFlush ( env );
      position_changed();
      break;

		case ClientMessage:
		  {
		    if ( atomDelete == (Atom)evt.xclient.data.l[0] )
          destroy();
		    break;
		  }
		}
    return true;
	}