static void draw(menu_t* menu, mp_image_t* mpi) {
  int h = mpi->h*mpriv->height/100;
  int w = mpi->w - 2* mpriv->minb;
  int x = mpriv->minb, y;
  int lw,lh,i, ll;

  if(mpriv->child) check_child(menu);

  ll = mpriv->last_line - 1;

  if(mpriv->hide_ts) {
    unsigned int t = GetTimerMS() - mpriv->hide_ts;
    if(t >= mpriv->hide_time) {
      mpriv->hide_ts = 0;
      menu->show = 0;
      return;
    }
    h = mpi->h*(mpriv->height - (mpriv->height * t /mpriv->hide_time))/100;
  } else if(mpriv->show_time && mpriv->show_ts == 0) {
    mpriv->show_ts = GetTimerMS();
    return;
  } else if(mpriv->show_ts > 0) {
    unsigned int t = GetTimerMS() - mpriv->show_ts;
    if(t > mpriv->show_time)
      mpriv->show_ts = -1;
    else
      h = mpi->h*(mpriv->height * t /mpriv->hide_time)/100;
  }

  y = h -  mpriv->vspace;

  if(x < 0 || y < 0 || w <= 0 || h <= 0 )
    return;

  if(mpriv->bg >= 0)
    menu_draw_box(mpi,mpriv->bg,mpriv->bg_alpha,0,0,mpi->w,h);

  if(!mpriv->child || !mpriv->raw_child){
    char input[strlen(mpriv->cur_history->buffer) + strlen(mpriv->prompt) + 1];
    sprintf(input,"%s%s",mpriv->prompt,mpriv->cur_history->buffer);
    menu_text_size(input,w,mpriv->vspace,1,&lw,&lh);
    menu_draw_text_full(mpi,input,x,y,w,h,mpriv->vspace,1,
			MENU_TEXT_BOT|MENU_TEXT_LEFT,
			MENU_TEXT_BOT|MENU_TEXT_LEFT);
    y -= lh + mpriv->vspace;
  }


  for( i = 0 ; y > mpriv->minb && i < mpriv->num_lines ; i++){
    int c = (ll - i) >= 0 ? ll - i : mpriv->buf_lines + ll - i;
    menu_text_size(mpriv->lines[c],w,mpriv->vspace,1,&lw,&lh);
    menu_draw_text_full(mpi,mpriv->lines[c],x,y,w,h,mpriv->vspace,1,
			MENU_TEXT_BOT|MENU_TEXT_LEFT,
			MENU_TEXT_BOT|MENU_TEXT_LEFT);
    y -= lh + mpriv->vspace;
  }
  return;
}
Example #2
0
static int cache_execute_control(cache_vars_t *s) {
  double double_res;
  unsigned uint_res;
  static unsigned last;
  int quit = s->control == -2;
  if (quit || !s->stream->control) {
    s->stream_time_length = 0;
    s->stream_time_pos = MP_NOPTS_VALUE;
    s->control_new_pos = 0;
    s->control_res = STREAM_UNSUPPORTED;
    s->control = -1;
    return !quit;
  }
  if (GetTimerMS() - last > 99) {
    double len, pos;
    if (s->stream->control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &len) == STREAM_OK)
      s->stream_time_length = len;
    else
      s->stream_time_length = 0;
    if (s->stream->control(s->stream, STREAM_CTRL_GET_CURRENT_TIME, &pos) == STREAM_OK)
      s->stream_time_pos = pos;
    else
      s->stream_time_pos = MP_NOPTS_VALUE;
    last = GetTimerMS();
  }
  if (s->control == -1) return 1;
  switch (s->control) {
    case STREAM_CTRL_SEEK_TO_TIME:
      double_res = s->control_double_arg;
    case STREAM_CTRL_GET_CURRENT_TIME:
    case STREAM_CTRL_GET_ASPECT_RATIO:
      s->control_res = s->stream->control(s->stream, s->control, &double_res);
      s->control_double_arg = double_res;
      break;
    case STREAM_CTRL_SEEK_TO_CHAPTER:
    case STREAM_CTRL_SET_ANGLE:
      uint_res = s->control_uint_arg;
    case STREAM_CTRL_GET_NUM_CHAPTERS:
    case STREAM_CTRL_GET_CURRENT_CHAPTER:
    case STREAM_CTRL_GET_NUM_ANGLES:
    case STREAM_CTRL_GET_ANGLE:
      s->control_res = s->stream->control(s->stream, s->control, &uint_res);
      s->control_uint_arg = uint_res;
      break;
    default:
      s->control_res = STREAM_UNSUPPORTED;
      break;
  }
  s->control_new_pos = s->stream->pos;
  s->control = -1;
  return 1;
}
Example #3
0
/**
 * @brief Handle automatic hiding of the cursor.
 */
void wsMouseAutohide(void)
{
    if (mouse_win && (GetTimerMS() - mouse_time >= MOUSEHIDE_DELAY)) {
        wsMouseVisibility(mouse_win, wsHideMouseCursor);
        mouse_win = NULL;
    }
}
/**
 * @brief Handle automatic hiding of the cursor.
 */
void wsAutohideCursor(void)
{
    if (mouse_win && (GetTimerMS() - mouse_time >= MOUSEHIDE_DELAY)) {
        wsVisibleMouse(mouse_win, wsHideMouseCursor);
        mouse_win = NULL;
    }
}
Example #5
0
/**
 * Initialization code to be run at the very start, most not depend
 * on option values.
 */
void common_preinit(void)
{
    InitTimer();
    srand(GetTimerMS());

    mp_msg_init();
}
Example #6
0
/**
 * Initialization code to be run at the very start, must not depend
 * on option values.
 */
void common_preinit(void)
{
    sanitize_os();
    InitTimer();
    srand(GetTimerMS());

    mp_msg_init();
}
Example #7
0
static int cache_execute_control(cache_vars_t *s) {
  int res = 1;
  static unsigned last;
  if (!s->stream->control) {
    s->stream_time_length = 0;
    s->control_new_pos = 0;
    s->control_res = STREAM_UNSUPPORTED;
    s->control = -1;
    return res;
  }
  if (GetTimerMS() - last > 99) {
    double len;
    if (s->stream->control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &len) == STREAM_OK)
      s->stream_time_length = len;
    else
      s->stream_time_length = 0;
    last = GetTimerMS();
  }
  if (s->control == -1) return res;
  switch (s->control) {
    case STREAM_CTRL_GET_CURRENT_TIME:
    case STREAM_CTRL_SEEK_TO_TIME:
    case STREAM_CTRL_GET_ASPECT_RATIO:
      s->control_res = s->stream->control(s->stream, s->control, &s->control_double_arg);
      break;
    case STREAM_CTRL_SEEK_TO_CHAPTER:
    case STREAM_CTRL_GET_NUM_CHAPTERS:
    case STREAM_CTRL_GET_CURRENT_CHAPTER:
    case STREAM_CTRL_GET_NUM_ANGLES:
    case STREAM_CTRL_GET_ANGLE:
    case STREAM_CTRL_SET_ANGLE:
      s->control_res = s->stream->control(s->stream, s->control, &s->control_uint_arg);
      break;
    case -2:
      res = 0;
    default:
      s->control_res = STREAM_UNSUPPORTED;
      break;
  }
  s->control_new_pos = s->stream->pos;
  s->control = -1;
  return res;
}
Example #8
0
void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
{
 wItem    * item;
 txSample * image = NULL;
 int        i;

 image_buffer=db;
 image_width=window->Width;

 for( i=0;i < nrItems + 1;i++ )
  {
   item=&Items[i];
   switch( item->type )
    {
     case itButton:
          PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
          break;
     case itPotmeter:
          if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
          else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
          break;
     case itHPotmeter:
          if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
          else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
          PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed );
          break;
     case itVPotmeter:
          PutImage( &item->Bitmap,
	    item->x,item->y,
	    item->phases,
	    item->phases * ( 1. - item->value / 100.0f ) );
          PutImage( &item->Mask,
	    item->x,item->y + (int)( ( item->height - item->psy ) * ( 1. - item->value / 100.0f ) ),
	    3,item->pressed );
          break;
     case itSLabel:
          image=fntRender( item,0,"%s",item->label );
          if ( image ) PutImage( image,item->x,item->y,1,0 );
     case itDLabel:
          {
           char * t = Translate( item->label );
           int    l = fntTextWidth( item->fontid,t );
           l=(l?l:item->width);
           image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t );
	  }
          if ( image ) PutImage( image,item->x,item->y,1,0 );
          break;
    }
  }
 wsConvert( window,db,size );
}
Example #9
0
void uiEvent(int ev, float param)
{
    int iparam     = (int)param;
    mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext);
    float aspect;
    char cmd[40];

    switch (ev) {
/* user events */
    case evExit:
        mplayer(MPLAYER_EXIT_GUI, EXIT_QUIT, 0);
        break;

    case evLoadURL:
        gtkShow(evLoadURL, NULL);
        break;

    case ivSetAudio:

        if (!mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam)
            break;

        mp_property_do("switch_audio", M_PROPERTY_SET, &iparam, guiInfo.mpcontext);
        break;

    case ivSetVideo:

        if (!mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam)
            break;

        mp_property_do("switch_video", M_PROPERTY_SET, &iparam, guiInfo.mpcontext);
        break;

    case ivSetSubtitle:
        mp_property_do("sub", M_PROPERTY_SET, &iparam, guiInfo.mpcontext);
        break;

#ifdef CONFIG_CDDA
    case ivSetCDTrack:
        guiInfo.Track = iparam;

    case evPlayCD:
        guiInfo.StreamType = STREAMTYPE_CDDA;
        goto play;
#endif
#ifdef CONFIG_VCD
    case ivSetVCDTrack:
        guiInfo.Track = iparam;

    case evPlayVCD:
        guiInfo.StreamType = STREAMTYPE_VCD;
        goto play;
#endif
#ifdef CONFIG_DVDREAD
    case ivSetDVDSubtitle:
        dvdsub_id = iparam;
        uiEvent(ivPlayDVD, 0);
        break;

    case ivSetDVDAudio:
        audio_id = iparam;
        uiEvent(ivPlayDVD, 0);
        break;

    case ivSetDVDChapter:
        guiInfo.Chapter = iparam;
        uiEvent(ivPlayDVD, 0);
        break;

    case ivSetDVDTitle:
        guiInfo.Track   = iparam;
        guiInfo.Chapter = 1;
        guiInfo.Angle   = 1;
        uiEvent(ivPlayDVD, 0);
        break;

    case evPlayDVD:
        guiInfo.Chapter = 1;
        guiInfo.Angle   = 1;

    case ivPlayDVD:
        guiInfo.StreamType = STREAMTYPE_DVD;
        goto play;
#endif
#ifdef CONFIG_TV
    case evPlayTV:
        guiInfo.StreamType = guiTV[gui_tv_digital].StreamType;
        goto play;
#endif
    case evPlay:
    case evPlaySwitchToPause:
play:

        if (guiInfo.Playing != GUI_PAUSE) {
            MediumPrepare(guiInfo.StreamType);

            switch (guiInfo.StreamType) {
            case STREAMTYPE_FILE:
            case STREAMTYPE_STREAM:
            case STREAMTYPE_PLAYLIST:

                if (!guiInfo.Track)
                    guiInfo.Track = 1;

                guiInfo.MediumChanged = GUI_MEDIUM_NEW;
                guiInfo.PlaylistNext  = !guiInfo.Playing;

                break;

            case STREAMTYPE_CDDA:
            case STREAMTYPE_VCD:
            case STREAMTYPE_DVD:
            case STREAMTYPE_TV:
            case STREAMTYPE_DVB:

                if (!guiInfo.Track)
                    guiInfo.Track = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1);

            case STREAMTYPE_BINCUE:   // track 0 is OK and will auto-select first media data track
                guiInfo.MediumChanged = GUI_MEDIUM_SAME;

                break;
            }
        }

        uiPlay();
        break;

    case evPause:
    case evPauseSwitchToPlay:
        uiPause();
        break;

    case evStop:
        guiInfo.Playing = GUI_STOP;
        uiState();
        break;

    case evLoadPlay:
        uiLoadPlay = True;

//      guiInfo.StreamType=STREAMTYPE_FILE;
    case evLoad:
        gtkShow(evLoad, NULL);
        break;

    case evLoadSubtitle:
        gtkShow(evLoadSubtitle, NULL);
        break;

    case evDropSubtitle:
        nfree(guiInfo.SubtitleFilename);
        mplayerLoadSubtitle(NULL);
        break;

    case evLoadAudioFile:
        gtkShow(evLoadAudioFile, NULL);
        break;

    case evPlayImage:
        gtkShow(evPlayImage, NULL);
        break;

    case evPrev:
        uiPrev();
        break;

    case evNext:
        uiNext();
        break;

    case evPlaylist:
        gtkShow(evPlaylist, NULL);
        break;

    case evSkinBrowser:
        gtkShow(evSkinBrowser, skinName);
        break;

    case evAbout:
        gtkShow(evAbout, NULL);
        break;

    case evPreferences:
        gtkShow(evPreferences, NULL);
        break;

    case evEqualizer:
        gtkShow(evEqualizer, NULL);
        break;

    case evForward10min:
        uiRelSeek(600);
        break;

    case evBackward10min:
        uiRelSeek(-600);
        break;

    case evForward1min:
        uiRelSeek(60);
        break;

    case evBackward1min:
        uiRelSeek(-60);
        break;

    case evForward10sec:
        uiRelSeek(10);
        break;

    case evBackward10sec:
        uiRelSeek(-10);
        break;

    case evSetMoviePosition:
        guiInfo.Position = param;
        uiPctSeek(guiInfo.Position);
        break;

    case evIncVolume:
        mplayer_put_key(KEY_VOLUME_UP);
        break;

    case evDecVolume:
        mplayer_put_key(KEY_VOLUME_DOWN);
        break;

    case evMute:
        mixer_mute(mixer);
        break;

    case evSetVolume:
    case ivSetVolume:
        guiInfo.Volume = param;
        {
            float l = guiInfo.Volume * (100.0 - guiInfo.Balance) / 50.0;
            float r = guiInfo.Volume * guiInfo.Balance / 50.0;
            mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume));
        }

        if (ev == ivSetVolume)
            break;

        if (osd_level) {
            osd_visible = (GetTimerMS() + 1000) | 1;
            vo_osd_progbar_type  = OSD_VOLUME;
            vo_osd_progbar_value = guiInfo.Volume * 256.0 / 100.0;
            vo_osd_changed(OSDTYPE_PROGBAR);
        }

        break;

    case evSetBalance:
    case ivSetBalance:
        guiInfo.Balance = param;
        mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0);     // transform 0..100 to -1..1
        uiEvent(ivSetVolume, guiInfo.Volume);

        if (ev == ivSetBalance)
            break;

        if (osd_level) {
            osd_visible = (GetTimerMS() + 1000) | 1;
            vo_osd_progbar_type  = OSD_BALANCE;
            vo_osd_progbar_value = guiInfo.Balance * 256.0 / 100.0;
            vo_osd_changed(OSDTYPE_PROGBAR);
        }

        break;

    case evMenu:
        /*if (guiApp.menuIsPresent)   NOTE TO MYSELF: Uncomment only after mouse
         * {                                            pointer and cursor keys work
         * gtkShow( ivHidePopUpMenu,NULL );            with this menu from skin as
         * uiMenuShow( 0,0 );                          they do with normal menus.
         * }
         * else*/gtkShow(ivShowPopUpMenu, NULL);
        break;

    case evIconify:

        switch (iparam) {
        case 0:
            wsWindowIconify(&guiApp.mainWindow);
            break;

        case 1:
            wsWindowIconify(&guiApp.videoWindow);
            break;
        }

        break;

    case evHalfSize:

        if (guiInfo.VideoWindow && guiInfo.Playing) {
            if (guiApp.videoWindow.isFullScreen) {
                uiFullScreen();
            }

            wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2);
            btnSet(evFullScreen, btnReleased);
        }

        break;

    case evDoubleSize:

        if (guiInfo.VideoWindow && guiInfo.Playing) {
            if (guiApp.videoWindow.isFullScreen) {
                uiFullScreen();
            }

            wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2);
            wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y);
            btnSet(evFullScreen, btnReleased);
        }

        break;

    case evNormalSize:

        if (guiInfo.VideoWindow && guiInfo.Playing) {
            if (guiApp.videoWindow.isFullScreen) {
                uiFullScreen();
            }

            wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight);
            btnSet(evFullScreen, btnReleased);
            break;
        } else if (!guiApp.videoWindow.isFullScreen)
            break;

    case evFullScreen:

        if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) {
            uiFullScreen();

            if (!guiApp.videoWindow.isFullScreen)
                wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height);
        }

        if (guiApp.videoWindow.isFullScreen)
            btnSet(evFullScreen, btnPressed);
        else
            btnSet(evFullScreen, btnReleased);

        break;

    case evSetAspect:

        switch (iparam) {
        case 2:
            aspect = 16.0f / 9.0f;
            break;

        case 3:
            aspect = 4.0f / 3.0f;
            break;

        case 4:
            aspect = 2.35f;
            break;

        case 1:
        default:
            aspect = -1;
            break;
        }

        snprintf(cmd, sizeof(cmd), "pausing_keep switch_ratio %f", aspect);
        mp_input_queue_cmd(mp_input_parse_cmd(cmd));

        break;

    case evSetRotation:

        switch (iparam) {
        case 90:
            guiInfo.Rotation = 1;
            break;

        case -90:
            guiInfo.Rotation = 2;
            break;

        case 180:
            guiInfo.Rotation = 8;
            break;

        case 0:
        default:
            guiInfo.Rotation = -1;
            break;
        }

        guiInfo.MediumChanged = GUI_MEDIUM_SAME;

        break;

/* timer events */
    case ivRedraw:
    {
        unsigned int now = GetTimerMS();

        if ((now > last_redraw_time) &&
            (now < last_redraw_time + GUI_REDRAW_WAIT) &&
            !uiPlaybarFade && (iparam == 0))
            break;

        last_redraw_time = now;
    }
        uiMainRender = True;
        wsWindowRedraw(&guiApp.mainWindow);
        wsWindowRedraw(&guiApp.playbarWindow);
        break;

/* system events */
    case evNone:
        mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n");
        break;

    default:
        mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param);
        break;
    }
}
void mplEventHandling( int msg,float param )
{
 int iparam = (int)param;
 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);

 switch( msg )
  {
// --- user events
   case evExit:
        exit_player( "Exit" );
        break;

   case evPlayNetwork:
        gfree( (void **)&guiIntfStruct.Subtitlename );
	gfree( (void **)&guiIntfStruct.AudioFile );
	guiIntfStruct.StreamType=STREAMTYPE_STREAM;
        goto play;
   case evSetURL:
        gtkShow( evPlayNetwork,NULL );
	break;

   case evSetAudio:
        if ( !guiIntfStruct.demuxer || audio_id == iparam ) break;
	audio_id=iparam;
	goto play;

   case evSetVideo:
        if ( !guiIntfStruct.demuxer || video_id == iparam ) break;
	video_id=iparam;
	goto play;

   case evSetSubtitle:
        mp_property_do("sub",M_PROPERTY_SET,&iparam,guiIntfStruct.mpcontext);
	break;

#ifdef CONFIG_VCD
   case evSetVCDTrack:
        guiIntfStruct.Track=iparam;
   case evPlayVCD:
 	gtkSet( gtkClearStruct,0,(void *)guiALL );
	guiIntfStruct.StreamType=STREAMTYPE_VCD;
	goto play;
#endif
#ifdef CONFIG_DVDREAD
   case evPlayDVD:
        guiIntfStruct.DVD.current_title=1;
        guiIntfStruct.DVD.current_chapter=1;
        guiIntfStruct.DVD.current_angle=1;
play_dvd_2:
 	gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD) );
        guiIntfStruct.StreamType=STREAMTYPE_DVD;
	goto play;
#endif
   case evPlay:
   case evPlaySwitchToPause:
play:

        if ( ( msg == evPlaySwitchToPause )&&( guiIntfStruct.Playing == 2 ) ) goto NoPause;

	if ( gtkSet( gtkGetCurrPlItem,0,NULL ) &&( guiIntfStruct.StreamType == STREAMTYPE_FILE ) )
	 {
	  plItem * next = gtkSet( gtkGetCurrPlItem,0,NULL );
	  plLastPlayed=next;
	  mplSetFileName( next->path,next->name,STREAMTYPE_FILE );
	 }

        switch ( guiIntfStruct.StreamType )
         {
	  case STREAMTYPE_STREAM:
	  case STREAMTYPE_FILE:
	       gtkSet( gtkClearStruct,0,(void *)(guiALL - guiFilenames) );
	       break;
#ifdef CONFIG_VCD
          case STREAMTYPE_VCD:
	       gtkSet( gtkClearStruct,0,(void *)(guiALL - guiVCD - guiFilenames) );
	       if ( !cdrom_device ) cdrom_device=gstrdup( DEFAULT_CDROM_DEVICE );
	       mplSetFileName( NULL,cdrom_device,STREAMTYPE_VCD );
	       if ( guiIntfStruct.Playing != 2 )
	        {
		 if ( !guiIntfStruct.Track )
		  {
		   if ( guiIntfStruct.VCDTracks > 1 ) guiIntfStruct.Track=2;
		    else guiIntfStruct.Track=1;
		  }
                 guiIntfStruct.DiskChanged=1;
		}
	       break;
#endif
#ifdef CONFIG_DVDREAD
          case STREAMTYPE_DVD:
	       gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) );
	       if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE );
	       mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD );
	       if ( guiIntfStruct.Playing != 2 )
	        {
		 guiIntfStruct.Title=guiIntfStruct.DVD.current_title;
		 guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter;
		 guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle;
                 guiIntfStruct.DiskChanged=1;
		}
               break;
#endif
         }
	guiIntfStruct.NewPlay=1;
        mplPlay();
        break;
#ifdef CONFIG_DVDREAD
   case evSetDVDSubtitle:
        dvdsub_id=iparam;
        goto play_dvd_2;
        break;
   case evSetDVDAudio:
        audio_id=iparam;
        goto play_dvd_2;
        break;
   case evSetDVDChapter:
        guiIntfStruct.DVD.current_chapter=iparam;
        goto play_dvd_2;
        break;
   case evSetDVDTitle:
        guiIntfStruct.DVD.current_title=iparam;
	guiIntfStruct.DVD.current_chapter=1;
	guiIntfStruct.DVD.current_angle=1;
        goto play_dvd_2;
        break;
#endif

   case evPause:
   case evPauseSwitchToPlay:
NoPause:
        mplPause();
        break;

   case evStop:
	guiIntfStruct.Playing=guiSetStop;
	mplState();
	guiIntfStruct.NoWindow=False;
	break;

   case evLoadPlay:
        mplMainAutoPlay=1;
//	guiIntfStruct.StreamType=STREAMTYPE_FILE;
   case evLoad:
	gtkSet( gtkDelPl,0,NULL );
        gtkShow( evLoad,NULL );
        break;
   case evLoadSubtitle:  gtkShow( evLoadSubtitle,NULL );  break;
   case evDropSubtitle:
	gfree( (void **)&guiIntfStruct.Subtitlename );
	guiLoadSubtitle( NULL );
	break;
   case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break;
   case evPrev: mplPrev(); break;
   case evNext: mplNext(); break;

   case evPlayList:    gtkShow( evPlayList,NULL );        break;
   case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break;
   case evAbout:       gtkShow( evAbout,NULL );           break;
   case evPreferences: gtkShow( evPreferences,NULL );     break;
   case evEqualizer:   gtkShow( evEqualizer,NULL );       break;

   case evForward10min:	    mplRelSeek( 600 ); break;
   case evBackward10min:    mplRelSeek( -600 );break;
   case evForward1min:      mplRelSeek( 60 );  break;
   case evBackward1min:     mplRelSeek( -60 ); break;
   case evForward10sec:     mplRelSeek( 10 );  break;
   case evBackward10sec:    mplRelSeek( -10 ); break;
   case evSetMoviePosition: mplAbsSeek( param ); break;

   case evIncVolume:  vo_x11_putkey( wsGrayMul ); break;
   case evDecVolume:  vo_x11_putkey( wsGrayDiv ); break;
   case evMute:       mixer_mute( mixer ); break;

   case evSetVolume:
        guiIntfStruct.Volume=param;
	goto set_volume;
   case evSetBalance:
        guiIntfStruct.Balance=param;
set_volume:
        {
	 float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 );
	 float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 );
	 if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume;
	 if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume;
//	 printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r );
         mixer_setvolume( mixer,l,r );
	}
	if ( osd_level )
	 {
	  osd_visible=(GetTimerMS() + 1000) | 1;
	  vo_osd_progbar_type=OSD_VOLUME;
	  vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0;
	  vo_osd_changed( OSDTYPE_PROGBAR );
	 }
        break;


   case evIconify:
        switch ( iparam )
         {
          case 0: wsIconify( appMPlayer.mainWindow ); break;
          case 1: wsIconify( appMPlayer.subWindow ); break;
         }
        break;
   case evHalfSize:
        btnSet( evFullScreen,btnReleased );
        if ( guiIntfStruct.Playing )
         {
          if ( appMPlayer.subWindow.isFullScreen )
           {
            mplFullScreen();
           }
          wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 );
          wsMoveWindow( &appMPlayer.subWindow, 0,
                        ( wsMaxX - guiIntfStruct.MovieWidth/2  )/2 + wsOrgX,
                        ( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY  );
         }
        break;
   case evDoubleSize:
    	btnSet( evFullScreen,btnReleased );
        if ( guiIntfStruct.Playing )
         {
          if ( appMPlayer.subWindow.isFullScreen )
           {
            mplFullScreen();
           }
          wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 );
          wsMoveWindow( &appMPlayer.subWindow, 0,
                        ( wsMaxX - guiIntfStruct.MovieWidth*2  )/2 + wsOrgX,
                        ( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY  );
         }
        break;
   case evNormalSize:
	btnSet( evFullScreen,btnReleased );
        if ( guiIntfStruct.Playing )
         {
          if ( appMPlayer.subWindow.isFullScreen )
           {
            mplFullScreen();
           }
          wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth, guiIntfStruct.MovieHeight );
          wsMoveWindow( &appMPlayer.subWindow, 0,
                        ( wsMaxX - guiIntfStruct.MovieWidth  )/2 + wsOrgX,
                        ( wsMaxY - guiIntfStruct.MovieHeight )/2 + wsOrgY  );
	  break;
         } else if ( !appMPlayer.subWindow.isFullScreen ) break;
   case evFullScreen:
        if ( !guiIntfStruct.Playing && !gtkShowVideoWindow ) break;
        mplFullScreen();
	if ( appMPlayer.subWindow.isFullScreen ) btnSet( evFullScreen,btnPressed );
	 else btnSet( evFullScreen,btnReleased );
        break;

   case evSetAspect:
	switch ( iparam )
	 {
	  case 2:  movie_aspect=16.0f / 9.0f; break;
	  case 3:  movie_aspect=4.0f / 3.0f;  break;
	  case 4:  movie_aspect=2.35;         break;
	  case 1:
	  default: movie_aspect=-1;
	 }
	wsClearWindow( appMPlayer.subWindow );
#ifdef CONFIG_DVDREAD
	if ( guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_VCD ) goto play_dvd_2;
	 else
#endif
	 guiIntfStruct.NewPlay=1;
	break;

// --- timer events
   case evRedraw:
        {
          unsigned now = GetTimerMS();
          extern int mplPBFade;
          if ((now > last_redraw_time) &&
              (now < last_redraw_time + GUI_REDRAW_WAIT) &&
              !mplPBFade)
            break;
          last_redraw_time = now;
        }
        mplMainRender=1;
        wsPostRedisplay( &appMPlayer.mainWindow );
	wsPostRedisplay( &appMPlayer.barWindow );
        break;
// --- system events
#ifdef MP_DEBUG
   case evNone:
        mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] event none received.\n" );
        break;
   default:
        mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] unknown event received ( %d,%.2f ).\n",msg,param );
        break;
#endif
  }
}
Example #11
0
/**
 * @brief Render all GUI items in a window, i.e. copy the respective images
 *        into the draw buffer.
 *
 * @param window pointer to a ws window structure of the window to be rendered
 * @param items pointer to the array of items
 * @param till maximum index in use for the @a items, i.e. number of last item in array
 * @param drawbuf memory location of the @a window's draw buffer
 */
void RenderAll(wsWindow *window, guiItem *items, int till, char *drawbuf)
{
    uint32_t *db;
    guiItem *item;
    guiImage *image = NULL;
    int dw, i, index, x;
    char *trans;
    unsigned int d;

    db = (uint32_t *)drawbuf;
    dw = window->Width;

    for (i = 0; i <= till; i++) {
        item = &items[i];

        switch (item->pressed) {
        case btnPressed:
            index = 0;
            break;

        case btnReleased:
            index = 1;
            break;

        default:
            index = 2;
            break;
        }

        switch (item->type) {
        case itButton:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, 3, index, True);
            break;

        case itPimage:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True);
            break;

        case itHPotmeter:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True);
            PutImage(item->x + (item->width - item->pbwidth) * item->value / 100.0, item->y, db, dw, &item->Mask, 3, index, True);
            break;

        case itVPotmeter:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, False);
            PutImage(item->x, item->y + (item->height - item->pbheight) * (1.0 - item->value / 100.0), db, dw, &item->Mask, 3, index, True);
            break;

        case itRPotmeter:

            PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True);

            if (item->Mask.Image) {
                double radius, radian;
                int y;

                // keep the button inside the potmeter outline
                radius = (FFMIN(item->width, item->height) - FFMAX(item->pbwidth, item->pbheight)) / 2.0;

                radian = item->value / 100.0 * item->arclength + item->zeropoint;

                // coordinates plus a correction for a non-square item
                // (remember: both axes are mirrored, we have a clockwise radian)
                x = radius * (1 + cos(radian)) + FFMAX(0, (item->width - item->height) / 2.0) + 0.5;
                y = radius * (1 + sin(radian)) + FFMAX(0, (item->height - item->width) / 2.0) + 0.5;

                PutImage(item->x + x, item->y + y, db, dw, &item->Mask, 3, index, True);
            }

            break;

        case itSLabel:

            if (item->width == -1)
                item->width = fntTextWidth(item->fontid, item->label);

            image = fntTextRender(item, 0, item->label);

            if (image)
                PutImage(item->x, item->y, db, dw, image, 1, 0, True);

            break;

        case itDLabel:

            trans = TranslateVariables(item->label);

            if (!item->text || (strcmp(item->text, trans) != 0)) {
                free(item->text);
                item->text      = strdup(trans);
                item->textwidth = fntTextWidth(item->fontid, trans);
                item->starttime = GetTimerMS();
                item->last_x    = 0;
            }

            d = GetTimerMS() - item->starttime;

            if (d < DLABEL_DELAY)
                x = item->last_x;                   // don't scroll yet
            else {
                int l;
                char c[2];

                l    = (item->textwidth ? item->textwidth : item->width);
                x    = (l ? l - ((d - DLABEL_DELAY) / 20) % l - 1 : 0);
                c[0] = *item->text;
                c[1] = 0;

                if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) {
                    item->starttime = GetTimerMS(); // stop again
                    item->last_x    = x;            // at current x pos
                }
            }

            image = fntTextRender(item, x, trans);

            if (image)
                PutImage(item->x, item->y, db, dw, image, 1, 0, True);

            break;
        }
    }

    wsImageRender(window, drawbuf);
}
void uiEventHandling( int msg,float param )
{
 int iparam = (int)param;
 mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext);

 switch( msg )
  {
/* user events */
   case evExit:
        mplayer( MPLAYER_EXIT_GUI, EXIT_QUIT, 0 );
        break;

   case evLoadURL:
        gtkShow( evLoadURL,NULL );
	break;

   case ivSetAudio:
        if ( !mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam ) break;
	mp_property_do("switch_audio",M_PROPERTY_SET,&iparam,guiInfo.mpcontext);
	break;

   case ivSetVideo:
        if ( !mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam ) break;
	mp_property_do("switch_video",M_PROPERTY_SET,&iparam,guiInfo.mpcontext);
	break;

   case ivSetSubtitle:
        mp_property_do("sub",M_PROPERTY_SET,&iparam,guiInfo.mpcontext);
	break;

#ifdef CONFIG_CDDA
   case ivSetCDTrack:
        guiInfo.Track=iparam;
   case evPlayCD:
 	guiInfoMediumClear ( CLEAR_ALL );
	guiInfo.StreamType=STREAMTYPE_CDDA;
	goto play;
#endif
#ifdef CONFIG_VCD
   case ivSetVCDTrack:
        guiInfo.Track=iparam;
   case evPlayVCD:
 	guiInfoMediumClear ( CLEAR_ALL );
	guiInfo.StreamType=STREAMTYPE_VCD;
	goto play;
#endif
#ifdef CONFIG_DVDREAD
   case ivSetDVDSubtitle:
        dvdsub_id=iparam;
        uiEventHandling( ivPlayDVD, 0 );
        break;
   case ivSetDVDAudio:
        audio_id=iparam;
        uiEventHandling( ivPlayDVD, 0 );
        break;
   case ivSetDVDChapter:
        guiInfo.Chapter=iparam;
        uiEventHandling( ivPlayDVD, 0 );
        break;
   case ivSetDVDTitle:
        guiInfo.Track=iparam;
        guiInfo.Chapter=1;
        guiInfo.Angle=1;
        uiEventHandling( ivPlayDVD, 0 );
        break;
   case evPlayDVD:
        guiInfo.Track=1;
        guiInfo.Chapter=1;
        guiInfo.Angle=1;
   case ivPlayDVD:
 	guiInfoMediumClear( CLEAR_ALL - CLEAR_DVD );
        guiInfo.StreamType=STREAMTYPE_DVD;
	goto play;
#endif
   case evPlay:
   case evPlaySwitchToPause:
play:

        if ( ( msg == evPlaySwitchToPause )&&( guiInfo.Playing == GUI_PAUSE ) ) goto NoPause;

	if ( listMgr( PLAYLIST_ITEM_GET_CURR,0 ) &&( guiInfo.StreamType == STREAMTYPE_FILE ) )
	 {
	  plItem * next = listMgr( PLAYLIST_ITEM_GET_CURR,0 );
	  uiSetFileName( next->path,next->name,SAME_STREAMTYPE );
	 }

        switch ( guiInfo.StreamType )
         {
	  case STREAMTYPE_FILE:
	  case STREAMTYPE_STREAM:
	  case STREAMTYPE_PLAYLIST:
	       guiInfoMediumClear( CLEAR_ALL - CLEAR_FILE );
	       if ( !guiInfo.Track )
	         guiInfo.Track=1;
	       guiInfo.NewPlay=GUI_FILE_NEW;
	       break;

          case STREAMTYPE_CDDA:
	       guiInfoMediumClear( CLEAR_ALL - CLEAR_VCD - CLEAR_FILE );
	       if ( guiInfo.Playing != GUI_PAUSE )
	        {
		 if ( !guiInfo.Track )
                   guiInfo.Track=1;
                 guiInfo.NewPlay=GUI_FILE_SAME;
		}
	       break;

          case STREAMTYPE_VCD:
	       guiInfoMediumClear( CLEAR_ALL - CLEAR_VCD - CLEAR_FILE );
	       if ( guiInfo.Playing != GUI_PAUSE )
	        {
		 if ( !guiInfo.Track )
                   guiInfo.Track=2;
                 guiInfo.NewPlay=GUI_FILE_SAME;
		}
	       break;

          case STREAMTYPE_DVD:
	       guiInfoMediumClear( CLEAR_ALL - CLEAR_DVD - CLEAR_FILE );
	       if ( guiInfo.Playing != GUI_PAUSE )
	        {
                 guiInfo.NewPlay=GUI_FILE_SAME;
		}
               break;
         }
        uiPlay();
        break;

   case evPause:
   case evPauseSwitchToPlay:
NoPause:
        uiPause();
        break;

   case evStop:
	guiInfo.Playing=GUI_STOP;
	uiState();
	break;

   case evLoadPlay:
        uiMainAutoPlay=1;
//	guiInfo.StreamType=STREAMTYPE_FILE;
   case evLoad:
	listMgr( PLAYLIST_DELETE,0 );
        gtkShow( evLoad,NULL );
        break;
   case evLoadSubtitle:  gtkShow( evLoadSubtitle,NULL );  break;
   case evDropSubtitle:
	nfree( guiInfo.SubtitleFilename );
	mplayerLoadSubtitle( NULL );
	break;
   case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break;
   case evPrev: uiPrev(); break;
   case evNext: uiNext(); break;

   case evPlaylist:    gtkShow( evPlaylist,NULL );        break;
   case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break;
   case evAbout:       gtkShow( evAbout,NULL );           break;
   case evPreferences: gtkShow( evPreferences,NULL );     break;
   case evEqualizer:   gtkShow( evEqualizer,NULL );       break;

   case evForward10min:	    uiRelSeek( 600 ); break;
   case evBackward10min:    uiRelSeek( -600 );break;
   case evForward1min:      uiRelSeek( 60 );  break;
   case evBackward1min:     uiRelSeek( -60 ); break;
   case evForward10sec:     uiRelSeek( 10 );  break;
   case evBackward10sec:    uiRelSeek( -10 ); break;
   case evSetMoviePosition: uiAbsSeek( param ); break;

   case evIncVolume:  vo_x11_putkey( wsGrayMul ); break;
   case evDecVolume:  vo_x11_putkey( wsGrayDiv ); break;
   case evMute:       mixer_mute( mixer ); break;

   case evSetVolume:
        guiInfo.Volume=param;
	goto set_volume;
   case evSetBalance:
        guiInfo.Balance=param;
set_volume:
        {
	 float l = guiInfo.Volume * ( ( 100.0 - guiInfo.Balance ) / 50.0 );
	 float r = guiInfo.Volume * ( ( guiInfo.Balance ) / 50.0 );
	 if ( l > guiInfo.Volume ) l=guiInfo.Volume;
	 if ( r > guiInfo.Volume ) r=guiInfo.Volume;
//	 printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiInfo.Volume,guiInfo.Balance,l,r );
         mixer_setvolume( mixer,l,r );
	}
	if ( osd_level )
	 {
	  osd_visible=(GetTimerMS() + 1000) | 1;
	  vo_osd_progbar_type=OSD_VOLUME;
	  vo_osd_progbar_value=( ( guiInfo.Volume ) * 256.0 ) / 100.0;
	  vo_osd_changed( OSDTYPE_PROGBAR );
	 }
        break;


   case evMenu:
        /*if (guiApp.menuIsPresent)   NOTE TO MYSELF: Uncomment only after mouse
         {                                            pointer and cursor keys work
          gtkShow( ivHidePopUpMenu,NULL );            with this menu from skin as
          uiShowMenu( 0,0 );                          they do with normal menus.
         }
        else*/ gtkShow( ivShowPopUpMenu,NULL );
        break;

   case evIconify:
        switch ( iparam )
         {
          case 0: wsIconify( guiApp.mainWindow ); break;
          case 1: wsIconify( guiApp.videoWindow ); break;
         }
        break;
   case evHalfSize:
        if ( guiInfo.VideoWindow && guiInfo.Playing )
         {
          if ( guiApp.videoWindow.isFullScreen )
           {
            uiFullScreen();
           }
          wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2 );
          wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y );
          btnSet( evFullScreen,btnReleased );
         }
        break;
   case evDoubleSize:
        if ( guiInfo.VideoWindow && guiInfo.Playing )
         {
          if ( guiApp.videoWindow.isFullScreen )
           {
            uiFullScreen();
           }
          wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2 );
          wsMoveWindowWithin( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y );
          btnSet( evFullScreen,btnReleased );
         }
        break;
   case evNormalSize:
        if ( guiInfo.VideoWindow && guiInfo.Playing )
         {
          if ( guiApp.videoWindow.isFullScreen )
           {
            uiFullScreen();
           }
          wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight );
          wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y );
          btnSet( evFullScreen,btnReleased );
	  break;
         } else if ( !guiApp.videoWindow.isFullScreen ) break;
   case evFullScreen:
        if ( guiInfo.VideoWindow && guiInfo.Playing )
         {
          uiFullScreen();
          if ( !guiApp.videoWindow.isFullScreen )
           {
            wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight );
            wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y );
           }
         }
	if ( guiApp.videoWindow.isFullScreen ) btnSet( evFullScreen,btnPressed );
	 else btnSet( evFullScreen,btnReleased );
        break;

   case evSetAspect:
	switch ( iparam )
	 {
	  case 2:  movie_aspect=16.0f / 9.0f; break;
	  case 3:  movie_aspect=4.0f / 3.0f;  break;
	  case 4:  movie_aspect=2.35;         break;
	  case 1:
	  default: movie_aspect=-1;
	 }
	wsClearWindow( guiApp.videoWindow );
	if ( guiInfo.StreamType == STREAMTYPE_VCD ) uiEventHandling( evPlayVCD, 0 );
	 else if ( guiInfo.StreamType == STREAMTYPE_DVD ) uiEventHandling( ivPlayDVD, 0 );
	 else
	 guiInfo.NewPlay=GUI_FILE_NEW;
	break;

/* timer events */
   case ivRedraw:
        {
          unsigned now = GetTimerMS();
          if ((now > last_redraw_time) &&
              (now < last_redraw_time + GUI_REDRAW_WAIT) &&
              !uiPlaybarFade && (iparam == 0))
            break;
          last_redraw_time = now;
        }
        uiMainRender=1;
        wsPostRedisplay( &guiApp.mainWindow );
	wsPostRedisplay( &guiApp.playbarWindow );
        break;
/* system events */
   case evNone:
        mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: evNone\n" );
        break;
   default:
        mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: unknown event %d, param %.2f\n", msg, param );
        break;
  }
}
Example #13
0
void wsEvent(XEvent *event)
{
    unsigned long i = 0;
    int l;
    int x, y;
    Window child_window = 0;

    l = wsWindowListSearch(event->xany.window);

    if (l == -1)
        return;

    wsWindowList[l]->State = wsNone;

    switch (event->type) {
    case ClientMessage:

        if (event->xclient.message_type == wsWindowList[l]->AtomProtocols) {
            if ((Atom)event->xclient.data.l[0] == wsWindowList[l]->AtomDeleteWindow) {
                i = wsWindowClosed;
                goto expose;
            }

            if ((Atom)event->xclient.data.l[0] == wsWindowList[l]->AtomTakeFocus) {
                i = wsWindowFocusIn;
                wsWindowList[l]->Focused = wsFocused;
                goto expose;
            }

            if ((Atom)event->xclient.data.l[0] == wsWindowList[l]->AtomRolle) {
                mp_msg(MSGT_GPLAYER, MSGL_V, "[ws] role set.\n");
            }
        } else {
            /* try to process DND events */
            wsXDNDProcessClientMessage(&event->xclient);
        }

        break;

    case MapNotify:

        i = wsWindowMapped;
        wsWindowList[l]->Mapped = wsMapped;
        goto expose;

    case UnmapNotify:

        i = wsWindowUnmapped;
        wsWindowList[l]->Mapped = wsNo;
        goto expose;

    case FocusIn:

        if (wsWindowList[l]->Focused == wsFocused)
            break;

        i = wsWindowFocusIn;
        wsWindowList[l]->Focused = wsFocused;
        goto expose;

    case FocusOut:

        if (wsWindowList[l]->Focused == wsNo)
            break;

        i = wsWindowFocusOut;
        wsWindowList[l]->Focused = wsNo;
        goto expose;

    case VisibilityNotify:

        switch (event->xvisibility.state) {
        case VisibilityUnobscured:
            i = wsWindowVisible;
            wsWindowList[l]->Visible = wsVisible;
            goto expose;

        case VisibilityFullyObscured:
            i = wsWindowNotVisible;
            wsWindowList[l]->Visible = wsNotVisible;
            goto expose;

        case VisibilityPartiallyObscured:
            i = wsWindowPartialVisible;
            wsWindowList[l]->Visible = wsPVisible;
            goto expose;
        }

expose:
        wsWindowList[l]->State = i;

        if (wsWindowList[l]->DrawHandler)
            wsWindowList[l]->DrawHandler();

        break;

    case Expose:

        wsWindowList[l]->State = wsWindowExpose;

        if ((wsWindowList[l]->DrawHandler) && (!event->xexpose.count))
            wsWindowList[l]->DrawHandler();

        break;

    case ConfigureNotify:

        XTranslateCoordinates(wsDisplay, wsWindowList[l]->WindowID, wsRootWin, 0, 0, &x, &y, &child_window);

        if ((wsWindowList[l]->X != x) || (wsWindowList[l]->Y != y) || (wsWindowList[l]->Width != event->xconfigure.width) || (wsWindowList[l]->Height != event->xconfigure.height)) {
            wsWindowList[l]->X      = x;
            wsWindowList[l]->Y      = y;
            wsWindowList[l]->Width  = event->xconfigure.width;
            wsWindowList[l]->Height = event->xconfigure.height;
        }

        wsWindowList[l]->Rolled = wsNo;

        if (event->xconfigure.y < 0) {
            i = wsWindowRolled;
            wsWindowList[l]->Rolled = wsRolled;
            goto expose;
        }

        break;

    case KeyPress:

        i = wsKeyPressed;
        goto keypressed;

    case KeyRelease:

        i = wsKeyReleased;
keypressed:
        wsWindowList[l]->Alt      = False;
        wsWindowList[l]->Shift    = False;
        wsWindowList[l]->NumLock  = False;
        wsWindowList[l]->Control  = False;
        wsWindowList[l]->CapsLock = False;

        if (event->xkey.state & Mod1Mask)
            wsWindowList[l]->Alt = True;

        if (event->xkey.state & Mod2Mask)
            wsWindowList[l]->NumLock = True;

        if (event->xkey.state & ControlMask)
            wsWindowList[l]->Control = True;

        if (event->xkey.state & ShiftMask)
            wsWindowList[l]->Shift = True;

        if (event->xkey.state & LockMask)
            wsWindowList[l]->CapsLock = True;

#if 0
        {
            KeySym keySym;
            keySym = XKeycodeToKeysym(wsDisplay, event->xkey.keycode, 0);

            if (keySym != NoSymbol) {
                keySym = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym));

                if (wsWindowList[l]->KeyHandler)
                    wsWindowList[l]->KeyHandler(event->xkey.state, i, keySym);
            }
        }
#else
        {
            int key;
            char buf[100];
            KeySym keySym;
            static XComposeStatus stat;

            XLookupString(&event->xkey, buf, sizeof(buf), &keySym, &stat);
            key = ((keySym & 0xff00) != 0 ? ((keySym & 0x00ff) + 256) : (keySym));

            if (wsWindowList[l]->KeyHandler)
                wsWindowList[l]->KeyHandler(event->xkey.keycode, i, key);
        }
#endif
        break;

    case MotionNotify:

        i = wsMoveMouse;
        {
            /* pump all motion events from the display queue:
             * this way it works faster when moving the window */
            static XEvent e;

            if (event->xmotion.state) {
                while (XCheckTypedWindowEvent(wsDisplay, event->xany.window, MotionNotify, &e)) {
                    /* FIXME: need to make sure we didn't release/press the button in between...*/
                    /* FIXME: do we need some timeout here to make sure we don't spend too much time
                     * removing events from the queue? */
                    event = &e;
                }
            }
        }

        if (wsWindowList[l]->wsCursor != None) {
            wsMouseVisibility(wsWindowList[l], wsShowMouseCursor);
            mouse_win  = wsWindowList[l];
            mouse_time = GetTimerMS();
        }

        goto buttonreleased;

    case ButtonRelease:

        i = event->xbutton.button + 128;

        if (wsWindowList[l]->wsCursor != None) {
            wsMouseVisibility(wsWindowList[l], wsShowMouseCursor);
            mouse_win  = wsWindowList[l];
            mouse_time = GetTimerMS();
        }

        goto buttonreleased;

    case ButtonPress:

        i = event->xbutton.button;

        if (wsWindowList[l]->wsCursor != None) {
            wsMouseVisibility(wsWindowList[l], wsShowMouseCursor);
            mouse_win  = wsWindowList[l];
            mouse_time = GetTimerMS();
        }

        goto buttonreleased;

    case EnterNotify:

        i = wsEnterWindow;
        goto buttonreleased;

    case LeaveNotify:

        i = wsLeaveWindow;
buttonreleased:

        if (wsWindowList[l]->MouseHandler)
            wsWindowList[l]->MouseHandler(i, event->xbutton.x, event->xbutton.y, event->xmotion.x_root, event->xmotion.y_root);

        break;

    case SelectionNotify:

        /* Handle drag & drop */
        wsXDNDProcessSelection(wsWindowList[l], event);
        break;
    }

    XFlush(wsDisplay);
    XSync(wsDisplay, False);
}
Example #14
0
static int cache_execute_control(cache_vars_t *s) {
  double double_res;
  unsigned uint_res;
  int needs_flush = 0;
  static unsigned last;
  int quit = s->control == -2;
  if (quit || !s->stream->control) {
    s->stream_time_length = 0;
    s->stream_time_pos = MP_NOPTS_VALUE;
    s->control_res = STREAM_UNSUPPORTED;
    s->control = -1;
    return !quit;
  }
  if (GetTimerMS() - last > 99) {
    double len, pos;
    if (s->stream->control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &len) == STREAM_OK)
      s->stream_time_length = len;
    else
      s->stream_time_length = 0;
    if (s->stream->control(s->stream, STREAM_CTRL_GET_CURRENT_TIME, &pos) == STREAM_OK)
      s->stream_time_pos = pos;
    else
      s->stream_time_pos = MP_NOPTS_VALUE;
#if FORKED_CACHE
    // if parent PID changed, main process was killed -> exit
    if (s->ppid != getppid()) {
      mp_msg(MSGT_CACHE, MSGL_WARN, "Parent process disappeared, exiting cache process.\n");
      return 0;
    }
#endif
    last = GetTimerMS();
  }
  if (s->control == -1) return 1;
  switch (s->control) {
    case STREAM_CTRL_SEEK_TO_TIME:
      needs_flush = 1;
      double_res = s->control_double_arg;
    case STREAM_CTRL_GET_CURRENT_TIME:
    case STREAM_CTRL_GET_ASPECT_RATIO:
      s->control_res = s->stream->control(s->stream, s->control, &double_res);
      s->control_double_arg = double_res;
      break;
    case STREAM_CTRL_SEEK_TO_CHAPTER:
    case STREAM_CTRL_SET_ANGLE:
      needs_flush = 1;
      uint_res = s->control_uint_arg;
    case STREAM_CTRL_GET_NUM_CHAPTERS:
    case STREAM_CTRL_GET_CURRENT_CHAPTER:
    case STREAM_CTRL_GET_NUM_ANGLES:
    case STREAM_CTRL_GET_ANGLE:
      s->control_res = s->stream->control(s->stream, s->control, &uint_res);
      s->control_uint_arg = uint_res;
      break;
    default:
      s->control_res = STREAM_UNSUPPORTED;
      break;
  }
  if (needs_flush) {
    s->read_filepos = s->stream->pos;
    s->eof = s->stream->eof;
    cache_flush(s);
  }
  s->control = -1;
  return 1;
}
Example #15
0
void RenderAll(wsTWindow *window, wItem *Items, int nrItems, char *db)
{
    wItem *item;
    guiImage *image = NULL;
    int i, ofs;

    image_buffer = db;
    image_width  = window->Width;

    for (i = 0; i < nrItems + 1; i++) {
        item = &Items[i];

        switch (item->pressed) {
        case btnPressed:
            ofs = 0;
            break;

        case btnReleased:
            ofs = 1;
            break;

        default:
            ofs = 2;
            break;
        }

        switch (item->type) {
        case itButton:
            PutImage(&item->Bitmap, item->x, item->y, 3, ofs);
            break;

        case itPotmeter:
            if (item->numphases == 1)
                SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0);
            else
                PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0));
            break;

        case itHPotmeter:
            if (item->numphases == 1)
                SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0);
            else
                PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0));
            PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0), item->y, 3, ofs);
            break;

        case itVPotmeter:
            PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0 - item->value / 100.0));
            PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0 - item->value / 100.0), 3, ofs);
            break;

        case itSLabel:
            if (item->width == -1)
                item->width = fntTextWidth(item->fontid, item->label);
            image = fntRender(item, 0, item->label);
            if (image)
                PutImage(image, item->x, item->y, 1, 0);
            break;

        case itDLabel:
        {
            int x;
            unsigned int d;
            char *t = Translate(item->label);

            if (!item->text || (strcmp(item->text, t) != 0)) {
                free(item->text);
                item->text      = strdup(t);
                item->textwidth = fntTextWidth(item->fontid, t);
                item->starttime = GetTimerMS();
                item->last_x    = 0;
            }

            d = GetTimerMS() - item->starttime;

            if (d < DLABEL_DELAY)
                x = item->last_x;                     // don't scroll yet
            else {
                int l;
                char c[2];

                l    = (item->textwidth ? item->textwidth : item->width);
                x    = l - ((d - DLABEL_DELAY) / 20) % l - 1;
                c[0] = *item->text;
                c[1] = '\0';

                if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) {
                    item->starttime = GetTimerMS();   // stop again
                    item->last_x    = x;              // at current x pos
                }
            }

            image = fntRender(item, x, t);
        }

            if (image)
                PutImage(image, item->x, item->y, 1, 0);

            break;
        }
    }

    wsConvert(window, db);
}
static void read_cmd(menu_t* menu,int cmd) {
  switch(cmd) {
  case MENU_CMD_CANCEL:
    if(mpriv->hide_time)
      mpriv->hide_ts = GetTimerMS();
    else
      menu->show = 0;
    mpriv->show_ts = 0;
    return;
  case MENU_CMD_OK: {
    mp_cmd_t* c;
    if(mpriv->child) {
      char *str = mpriv->cur_history->buffer;
      int l = strlen(str);
      while(l > 0) {
	int w = write(mpriv->child_fd[0],str,l);
	if(w < 0) {
	  mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
	  break;
	}
	l -= w;
	str += w;
      }
      if(write(mpriv->child_fd[0],"\n",1) < 0)
	mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
      enter_cmd(menu);
      return;
    }
    c = mp_input_parse_cmd(mpriv->cur_history->buffer);
    enter_cmd(menu);
    if(!c)
      add_line(mpriv,"Invalid command try help");
    else {
      switch(c->id) {
      case MP_CMD_CHELP:
	add_line(mpriv,"MPlayer console 0.01");
	add_line(mpriv,"TODO: meaningful help message ;)");
	add_line(mpriv,"Enter any slave command");
	add_line(mpriv,"exit close this console");
	break;
      case MP_CMD_CEXIT:
	menu->show = 0;
	menu->cl = 1;
	break;
      case MP_CMD_CHIDE:
	if(mpriv->hide_time)
	  mpriv->hide_ts = GetTimerMS();
	else
	  menu->show = 0;
	mpriv->show_ts = 0;
	break;
      case MP_CMD_RUN:
	run_shell_cmd(menu,c->args[0].v.s);
	break;
      default: // Send the other commands to mplayer
	mp_input_queue_cmd(c);
      }
    }
    return;
  }
  case MENU_CMD_UP:
    if(mpriv->cur_history->prev)
      mpriv->cur_history = mpriv->cur_history->prev;
    break;
  case MENU_CMD_DOWN:
    if(mpriv->cur_history->next)
      mpriv->cur_history = mpriv->cur_history->next;
    break;
  }
}
Example #17
0
static void read_key(menu_t* menu,int c) {
  if(!mpriv->child || !mpriv->raw_child) switch(c) {
  case KEY_ESC:
    if(mpriv->hide_time)
      mpriv->hide_ts = GetTimerMS();
    else
      menu->show = 0;
    mpriv->show_ts = 0;
    return;
  case KEY_ENTER: {
    mp_cmd_t* c;
    if(mpriv->child) {
      char *str = mpriv->cur_history->buffer;
      int l = strlen(str);
      while(l > 0) {
	int w = write(mpriv->child_fd[0],str,l);
	if(w < 0) {
	  mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
	  break;
	}
	l -= w;
	str += w;
      }
      if(write(mpriv->child_fd[0],"\n",1) < 0)
	mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
      enter_cmd(menu);
      return;
    }
    c = mp_input_parse_cmd(mpriv->cur_history->buffer);
    enter_cmd(menu);
    if(!c)
      add_line(mpriv,"Invalid command try help");
    else {
      switch(c->id) {
      case MP_CMD_CHELP:
	add_line(mpriv,"MPlayer console 0.01");
	add_line(mpriv,"TODO: meaningful help message ;)");
	add_line(mpriv,"Enter any slave command");
	add_line(mpriv,"exit close this console");
	break;
      case MP_CMD_CEXIT:
	menu->show = 0;
	menu->cl = 1;
	break;
      case MP_CMD_CHIDE:
	if(mpriv->hide_time)
	  mpriv->hide_ts = GetTimerMS();
	else
	  menu->show = 0;
	mpriv->show_ts = 0;
	break;
      case MP_CMD_RUN:
	run_shell_cmd(menu,c->args[0].v.s);
	break;
      default: // Send the other commands to mplayer
	mp_input_queue_cmd(c);
      }
    }
    return;
  }
  case KEY_DELETE:
  case KEY_BS: {
    unsigned int i = strlen(mpriv->cur_history->buffer);
    if(i > 0)
      mpriv->cur_history->buffer[i-1] = '\0';
    return;
  }
  case KEY_UP:
    if(mpriv->cur_history->prev)
      mpriv->cur_history = mpriv->cur_history->prev;
    break;
  case KEY_DOWN:
    if(mpriv->cur_history->next)
      mpriv->cur_history = mpriv->cur_history->next;
    break;
  }

  if(mpriv->child && mpriv->raw_child) {
    write(mpriv->child_fd[0],&c,sizeof(int));
    return;
  }

  if(isascii(c)) {
    int l = strlen(mpriv->cur_history->buffer);
    if(l >= mpriv->cur_history->size) {
      mpriv->cur_history->size += 255;
      mpriv->cur_history->buffer = realloc(mpriv->cur_history,mpriv->cur_history->size);
    }
    mpriv->cur_history->buffer[l] = (char)c;
    mpriv->cur_history->buffer[l+1] = '\0';
  }

}