Exemple #1
0
gint vwm_fmod_wndlist_ON_KEYSTROKE(gint32 keystroke,WINDOW *window)
{
	MENU        *menu = NULL;
	MEVENT		mevent;
	// ITEM		*item;
	// guint32	window_state;

	menu = (MENU*)viper_window_get_userptr(window);

	if(keystroke == KEY_MOUSE)
	{
		menu_driver(menu,keystroke);
		getmouse(&mevent);
		if((mevent.bstate & BUTTON1_DOUBLE_CLICKED) == BUTTON1_DOUBLE_CLICKED)
			keystroke = KEY_CRLF;
	}

	viper_thread_enter();
	if(keystroke == KEY_UP) menu_driver(menu,REQ_UP_ITEM);
	if(keystroke == KEY_DOWN) menu_driver(menu,REQ_DOWN_ITEM);
	if(keystroke == KEY_CRLF)
	{
		// item = current_item(menu);
		/* viper_wnd=(VIPER_WND*)item_userptr(item); */
		viper_window_destroy(window);
/*
		if((viper_wnd->window_state & STATE_VISIBLE)==FALSE)
			viper_window_unhide(viper_wnd->window);
		viper_window_set_top(viper_wnd->window);
		viper_window_focus(TOPMOST_WINDOW);
*/
		/* viper_screen_redraw(REDRAW_ALL); */
		viper_thread_leave();
		return 1;
	}
	
	viper_window_redraw(window);
	viper_thread_leave();
	return 1;
}
Exemple #2
0
int16_t
vwmterm_psthread(ps_task_t *task,void *anything)
{
    WINDOW      *window;
    vterm_t     *vterm;
    ssize_t     bytes_read;

    window = (WINDOW*)anything;

    viper_thread_enter();
    vterm = viper_window_get_userptr(window);
    viper_thread_leave();

    bytes_read = vterm_read_pipe(vterm);

    // handle no data condition
    if(bytes_read == 0) return PSTHREAD_CONTINUE;

    // handle pipe error condition
    if(bytes_read == -1)
    {
        viper_thread_enter();
        viper_window_destroy(window);
        viper_thread_leave();

        return PSTHREAD_TERMINATE;
    }

    if(bytes_read > 0)
    {
        viper_thread_enter();
        vterm_wnd_update(vterm);
        viper_window_redraw(window);
        viper_thread_leave();
    }

    return PSTHREAD_CONTINUE;
}
Exemple #3
0
void viper_kmio_dispatch(gint32 keystroke,MEVENT *mouse_event)
{
   extern VIPER            *viper;
   static WINDOW           *event_window=NULL;
   static MEVENT           previous_mouse_event;
   static VIPER_WKEY_FUNC  func;
   static gint             event_mode=0;
   VIPER_KMIO_HOOK         kmio_dispatch_hook;
   gint                    beg_x,beg_y;
   gint                    max_x,max_y;
   MEVENT                  *new_mouse=NULL;     /* strictly for      */
   MEVENT                  *old_mouse=NULL;     /* for readability   */
#if !defined(_NO_GPM) && defined(__linux)
	extern int        		gpm_fd;
#endif

   // run the dispatch pre-processing hook
   if(viper->kmio_dispatch_hook[KMIO_HOOK_ENTER] != NULL)
   {
      kmio_dispatch_hook=viper->kmio_dispatch_hook[KMIO_HOOK_ENTER];
      keystroke=kmio_dispatch_hook(keystroke);
   }

   if(keystroke == -1) return;

   if(keystroke==KEY_RESIZE)
   {
      viper_event_run(VIPER_EVENT_BROADCAST,"term-resized");
      /* todo event handle for screen window instead  */
      viper_screen_redraw(REDRAW_ALL | REDRAW_BACKGROUND);
   }

   if(keystroke==KEY_MOUSE && mouse_event!=NULL)
   {
      new_mouse=mouse_event;
      old_mouse=&previous_mouse_event;

      if((new_mouse->bstate & REPORT_MOUSE_POSITION)
          && event_mode==EVENTMODE_MOVE)
      {
         viper_mvwin_rel(event_window,new_mouse->x-old_mouse->x,
            new_mouse->y-old_mouse->y);
         memcpy(old_mouse,new_mouse,sizeof(MEVENT));
      }

      if((new_mouse->bstate & REPORT_MOUSE_POSITION)
         && event_mode==EVENTMODE_RESIZE)
      {
         viper_wresize_rel(event_window,new_mouse->x-old_mouse->x,
            new_mouse->y-old_mouse->y);
         memcpy(old_mouse,new_mouse,sizeof(MEVENT));
      }

      /* check for a button press and a window hit */
      if((new_mouse->bstate & BUTTON1_PRESSED) && event_mode==EVENTMODE_IDLE)
      {
         event_window=viper_deck_hit_test(new_mouse->x,new_mouse->y);
         if(event_window!=NULL)
         {
            viper_window_set_top(event_window);
            memcpy(old_mouse,new_mouse,sizeof(MEVENT));
            getbegyx(WINDOW_FRAME(event_window),beg_y,beg_x);
            getmaxyx(WINDOW_FRAME(event_window),max_y,max_x);
            if(new_mouse->x==(beg_x+max_x-1) &&
               new_mouse->y==(beg_y+max_y)-1) event_mode=EVENTMODE_RESIZE;
            else event_mode=EVENTMODE_MOVE;
         }
         else event_mode=EVENTMODE_IDLE;
      }

     if(new_mouse->bstate & BUTTON1_RELEASED)
      {
         if(!(new_mouse->bstate & REPORT_MOUSE_POSITION))
         {
            if(event_mode==EVENTMODE_MOVE) viper_mvwin_rel(event_window,
               new_mouse->x-old_mouse->x,new_mouse->y-old_mouse->y);

            /* resize window  */
            if(event_mode==EVENTMODE_RESIZE)
            {
               viper_wresize_rel(event_window,new_mouse->x-old_mouse->x,
                  new_mouse->y-old_mouse->y);
               viper_screen_redraw(REDRAW_ALL);
            }
         }

         event_window=NULL;
         event_mode=EVENTMODE_IDLE;
      }

      if(new_mouse->bstate & BUTTON1_CLICKED)
      {
         event_window=viper_deck_hit_test(new_mouse->x,new_mouse->y);
         if(event_window!=NULL)
         {
            viper_window_set_top(event_window);
            viper_window_redraw(event_window);

            getbegyx(WINDOW_FRAME(event_window),beg_y,beg_x);
            getmaxyx(WINDOW_FRAME(event_window),max_y,max_x);
            if(new_mouse->x==(beg_x+max_x-2) && new_mouse->y==beg_y)
            {
               viper_window_close(event_window);
               keystroke=-1;
            }
            if(new_mouse->x==(beg_x+max_x-4) && new_mouse->y==beg_y)
            {
               viper_window_hide(event_window);
               viper_deck_cycle(VECTOR_BOTTOM_TO_TOP);
               keystroke=-1;
            }
         }
         event_window=NULL;
         event_mode=EVENTMODE_IDLE;
      }

      if(new_mouse->bstate & BUTTON1_DOUBLE_CLICKED)
      {
         event_window=viper_deck_hit_test(new_mouse->x,new_mouse->y);
         if(event_window!=NULL)
         {
            viper_window_set_top(event_window);
            viper_window_redraw(event_window);
         }

         event_window=NULL;
         event_mode=EVENTMODE_IDLE;
      }
   }

   // run the post-processing dispatch hook
   if(viper->kmio_dispatch_hook[KMIO_HOOK_LEAVE] != NULL)
   {
      kmio_dispatch_hook=viper->kmio_dispatch_hook[KMIO_HOOK_LEAVE];
      keystroke=kmio_dispatch_hook(keystroke);
   }

   // pass keystroke on to toplevel window
   if(keystroke != KEY_RESIZE && keystroke != -1)
   {
      func=viper_window_get_key_func(TOPMOST_WINDOW);
      if(func!=NULL) func(keystroke,(gpointer)TOPMOST_WINDOW);
   }

#if !defined(_NO_GPM) && defined(__linux)
	if(gpm_fd>0)
	{
   	viper_kmio_show_mouse(new_mouse);
   	viper_screen_redraw(REDRAW_ALL);
	}
#endif



}
Exemple #4
0
gint vwm_main_menu_ON_KEYSTROKE(gint32 keystroke,WINDOW *window)
{
	MENU			*menu=NULL;
	MEVENT		mevent;
	gchar			*item_text=NULL;
	WINDOW		*new_window;
	VWM_MODULE	*vwm_module;

	menu=(MENU*)viper_window_get_userptr(window);
   if(keystroke==-1) return 1;

   viper_thread_enter();

	if(keystroke==KEY_MOUSE)
	{
		menu_driver(menu,keystroke);
      vwm_menu_marshall(menu,REQ_DOWN_ITEM);
		getmouse(&mevent);
		if(mevent.bstate & BUTTON1_DOUBLE_CLICKED) keystroke=KEY_CRLF;
      else
      {
         viper_window_redraw(window);
         viper_thread_leave();
         return 1;
      }
	}

   if(keystroke=='s')
   {
      viper_thread_enter();
/*      new_window=viper_filedlg_create(window," Pick a file... ",0.5,0.5,0.5,0.5,
         NULL,FILEDLG_VIEW_EXTENDED); */
/*      new_window=viper_filedlg_create(window," Pick a file... ",0.5,0.5,0.5,0.5,
         NULL,FILEDLG_VIEW_BASIC | FILEDLG_SHOW_CTIME); */
      new_window=viper_filedlg_create(window," Pick a file... ",
			0.5,0.5,0.8,0.5,NULL,FILEDLG_FULL);
      viper_window_set_top(new_window);
      viper_thread_leave();
   }

	if(keystroke==KEY_UP)
   {
      menu_driver(menu,REQ_UP_ITEM);
      vwm_menu_marshall(menu,REQ_UP_ITEM);
   }
	if(keystroke==KEY_DOWN)
   {
      menu_driver(menu,REQ_DOWN_ITEM);
      vwm_menu_marshall(menu,REQ_DOWN_ITEM);
   }

	if(keystroke==KEY_CRLF)
	{
      item_text=(gchar*)item_name(current_item(menu));
		vwm_module=vwm_module_find(&item_text[2]);
		if(vwm_module!=NULL)
		{
			new_window=vwm_module->mod_main(vwm_module->anything);
         viper_window_close(window);
			if(new_window!=NULL) viper_window_set_top(new_window);
			viper_thread_leave();
			return 1;
		}
	}
	
	viper_window_redraw(window);
	viper_thread_leave();
	return 1;
}