示例#1
0
/******************************************************************************
  ProcessMessage - Process the message coming from Fvwm
    Skeleton based on processmessage() from FvwmIdent:
      Copyright 1994, Robert Nation and Nobutaka Suzuki.
******************************************************************************/
void ProcessMessage(unsigned long type,unsigned long *body)
{
  int redraw=0,i;
  long flags;
  char *name,*string;
  static current_focus=-1;

  Picture p;

  switch(type)
  {
    case M_ADD_WINDOW:
    case M_CONFIGURE_WINDOW:
      if (body[0] == win)
      {
        win_x=(int)body[3];
        win_y=(int)body[4];

        win_title=(int)body[9];
        win_border=(int)body[10];
      }
      if ((i = FindItem(&windows,body[0]))!=-1) 
      { 
/*	printf("does it go here on MOVE %ld, %ld ?\n", i, CurrentDesk);
*/
	if(UpdateItemDesk(&windows, i, body[7]) > 0)
        {
/*         printf("why doesnt it go here on MOVE ?\n");
*/
          AdjustWindow();
          RedrawWindow(1);
        }
	break;
      }

      if (!(body[8]&WINDOWLISTSKIP) || !UseSkipList)
        AddItem(&windows,body[0],body[8], body[7] /* desk */);
      break;
    case M_DESTROY_WINDOW:
      if ((i=DeleteItem(&windows,body[0]))==-1) break;
      RemoveButton(&buttons,i);
      if (WindowIsUp)
        AdjustWindow();

      redraw=1;
      break;

  case M_MINI_ICON:
    if ((i=FindItem(&windows,body[0]))==-1) break;

    if (UpdateButton(&buttons,i,NULL,-1)!=-1)
    {
      p.picture = body[1];
      p.mask = body[2];
      p.width = body[3];
      p.height = body[4];
      p.depth = body[5];
      UpdateButtonPicture(&buttons, i, &p);
      redraw = 0;
    }
    break;

    case M_WINDOW_NAME:
    case M_ICON_NAME:
      if ((type==M_ICON_NAME && !UseIconNames) || 
          (type==M_WINDOW_NAME && UseIconNames)) break;
      if ((i=UpdateItemName(&windows,body[0],(char *)&body[3]))==-1) break;
      string=(char *)&body[3];
      name=makename(string,ItemFlags(&windows,body[0]));
      if (UpdateButton(&buttons,i,name,-1)==-1)
      {
	AddButton(&buttons, name, NULL, 1);
	UpdateButtonSet(&buttons,i,ItemFlags(&windows,body[0])&ICONIFIED?1:0);
        UpdateButtonDesk(&buttons,i,ItemDesk(&windows, body[0]));
      }
      free(name);
      if (WindowIsUp) AdjustWindow();
      redraw=1;
      break;
    case M_DEICONIFY:
    case M_ICONIFY:
      if ((i=FindItem(&windows,body[0]))==-1) break;
      flags=ItemFlags(&windows,body[0]);
      if (type==M_DEICONIFY && !(flags&ICONIFIED)) break;
      if (type==M_ICONIFY && flags&ICONIFIED) break;
      flags^=ICONIFIED;
      UpdateItemFlags(&windows,body[0],flags);
      string=ItemName(&windows,i);
      name=makename(string,flags);
      if (UpdateButton(&buttons,i,name,-1)!=-1) redraw=1;
      if (i!=current_focus||(flags&ICONIFIED))
        if (UpdateButtonSet(&buttons,i,(flags&ICONIFIED) ? 1 : 0)!=-1) redraw=1;
      free(name);
      break;
    case M_FOCUS_CHANGE:

/* old coded, before Task bar code spliced in

      i=FindItem(&windows,body[0]);
      if (i==current_focus) break;
      if (current_focus!=-1)
	if ((ItemFlags(&windows,ItemID(&windows,current_focus))&ICONIFIED)==0)
	  if (UpdateButtonSet(&buttons,current_focus,0)!=-1) redraw=1;
      current_focus=-1;
      if (i!=-1&&(ItemFlags(&windows,body[0])&ICONIFIED)) break;
      current_focus=i;
      if (current_focus!=-1)
	if (UpdateButtonSet(&buttons,current_focus,2)!=-1) redraw=1;
* end of old code */

/* Code copied Straight from TaskBar */

    if ((i=FindItem(&windows,body[0]))!=-1)
    {
	    flags=ItemFlags(&windows,body[0]);
 	    UpdateItemFlags(&windows,body[0],flags);
    }
    RadioButton(&buttons,i);
    redraw = 1;
    break;

      break;
    case M_END_WINDOWLIST:
      if (!WindowIsUp) MakeMeWindow();
      redraw=1;
      break;
    case M_NEW_DESK:
	CurrentDesk = body[0];
	if(ShowCurrentDesk)
	{
	  RESIZE_BUG_HACK = 1;
	  AdjustWindow();
	  RESIZE_BUG_HACK = 0;
	  RedrawWindow(1);
        }
      break;
    case M_NEW_PAGE:
      break;
  }

  if (redraw && WindowIsUp==1) RedrawWindow(0);
}
示例#2
0
/******************************************************************************
  ProcessMessage - Process the message coming from Fvwm
    Skeleton based on processmessage() from FvwmIdent:
      Copyright 1994, Robert Nation and Nobutaka Suzuki.
******************************************************************************/
void ProcessMessage(unsigned long type,unsigned long *body)
{
    int redraw=0,i;
    long flags;
    char *name,*string;
    static int current_focus=-1;

    FvwmPicture p;

    switch(type)
    {
    case M_ADD_WINDOW:
    case M_CONFIGURE_WINDOW:
        if ((i = FindItem(&windows,body[0]))!=-1)
        {
            if(UpdateItemDesk(&windows, i, body[7]) > 0)
            {
                AdjustWindow();
                RedrawWindow(1);
            }
            break;
        }

        if (!(body[8]&WINDOWLISTSKIP) || !UseSkipList)
            AddItem(&windows,body[0],body[8], body[7] /* desk */);
        break;
    case M_DESTROY_WINDOW:
        if ((i=DeleteItem(&windows,body[0]))==-1) break;
        RemoveButton(&buttons,i);
        if (WindowIsUp)
            AdjustWindow();

        redraw=1;
        break;

#ifdef MINI_ICONS
    case M_MINI_ICON:
        if ((i=FindItem(&windows,body[0]))==-1) break;

        if (UpdateButton(&buttons,i,NULL,-1)!=-1)
        {
            p.width = body[3];
            p.height = body[4];
            p.depth = body[5];
            p.picture = body[6];
            p.mask = body[7];

            UpdateButtonPicture(&buttons, i, &p);
            redraw = 0;
        }
        break;
#endif

    case M_WINDOW_NAME:
    case M_ICON_NAME:
        if ((type==M_ICON_NAME && !UseIconNames) ||
                (type==M_WINDOW_NAME && UseIconNames)) break;
        if ((i=UpdateItemName(&windows,body[0],(char *)&body[3]))==-1) break;
        string=(char *)&body[3];
        name=makename(string,ItemFlags(&windows,body[0]));
        if (UpdateButton(&buttons,i,name,-1)==-1)
        {
            AddButton(&buttons, name, NULL, 1);
            UpdateButtonSet(&buttons,i,ItemFlags(&windows,body[0])&ICONIFIED?1:0);
            UpdateButtonDesk(&buttons,i,ItemDesk(&windows, body[0]));
        }
        free(name);
        if (WindowIsUp) AdjustWindow();
        redraw=1;
        break;
    case M_DEICONIFY:
    case M_ICONIFY:
        if ((i=FindItem(&windows,body[0]))==-1) break;
        flags=ItemFlags(&windows,body[0]);
        if (type==M_DEICONIFY && !(flags&ICONIFIED)) break;
        if (type==M_ICONIFY && flags&ICONIFIED) break;
        flags^=ICONIFIED;
        UpdateItemFlags(&windows,body[0],flags);
        string=ItemName(&windows,i);
        name=makename(string,flags);
        if (UpdateButton(&buttons,i,name,-1)!=-1) redraw=1;
        if (i!=current_focus||(flags&ICONIFIED))
            if (UpdateButtonSet(&buttons,i,(flags&ICONIFIED) ? 1 : 0)!=-1) redraw=1;
        free(name);
        break;
    case M_FOCUS_CHANGE:
        if ((i=FindItem(&windows,body[0]))!=-1)
        {
            flags=ItemFlags(&windows,body[0]);
            UpdateItemFlags(&windows,body[0],flags);
            RadioButton(&buttons,i);
        }
        else
            RadioButton(&buttons,-1);
        redraw = 1;
        break;
    case M_END_WINDOWLIST:
        if (!WindowIsUp) MakeMeWindow();
        redraw = 1;
        break;
    case M_NEW_DESK:
        CurrentDesk = body[0];
        if(ShowCurrentDesk)
        {
            AdjustWindow();
            RedrawWindow(1);
        }
        break;
    case M_NEW_PAGE:
        break;
    }

    if (redraw && WindowIsUp==1) RedrawWindow(0);
}