예제 #1
0
파일: event.c 프로젝트: ebfe/vix
void
simtk_widget_trigger_create (struct simtk_widget *widget)
{
  struct simtk_event event = {0, 0, 0};
  
  trigger_hook (widget->event_hooks, SIMTK_EVENT_CREATE, &event);
}
예제 #2
0
void
trigger_config_change_trigger_arguments (const void *pointer, void *data,
                                         struct t_config_option *option)
{
    struct t_trigger *ptr_trigger;

    /* make C compiler happy */
    (void) pointer;
    (void) data;

    ptr_trigger = trigger_search_with_option (option);
    if (!ptr_trigger)
        return;

    if (ptr_trigger->options[TRIGGER_OPTION_HOOK])
        trigger_hook (ptr_trigger);
}
예제 #3
0
void
trigger_command_set_enabled (struct t_trigger *trigger,
                             int enable, const char *enable_string,
                             int display_error)
{
    if (trigger->hook_running)
    {
        trigger_command_error_running (trigger, enable_string);
        return;
    }

    if (enable == 2)
    {
        if (weechat_config_boolean (trigger->options[TRIGGER_OPTION_ENABLED]))
        {
            trigger_hook (trigger);
            weechat_printf_date_tags (NULL, 0, "no_trigger",
                                      _("Trigger \"%s\" restarted"),
                                      trigger->name);
        }
        else if (display_error)
        {
            weechat_printf_date_tags (NULL, 0, "no_trigger",
                                      _("%s%s: a disabled trigger can not be "
                                        "restarted"),
                                      weechat_prefix ("error"),
                                      TRIGGER_PLUGIN_NAME);
        }
    }
    else
    {
        if (enable < 0)
        {
            enable = weechat_config_boolean (trigger->options[TRIGGER_OPTION_ENABLED]) ?
                0 : 1;
        }
        weechat_config_option_set (trigger->options[TRIGGER_OPTION_ENABLED],
                                   (enable) ? "on" : "off", 1);
        weechat_printf_date_tags (NULL, 0, "no_trigger",
                                  (enable) ?
                                  _("Trigger \"%s\" enabled") :
                                  _("Trigger \"%s\" disabled"),
                                  trigger->name);
    }
}
예제 #4
0
void
trigger_config_change_trigger_enabled (const void *pointer, void *data,
                                       struct t_config_option *option)
{
    struct t_trigger *ptr_trigger;

    /* make C compiler happy */
    (void) pointer;
    (void) data;

    ptr_trigger = trigger_search_with_option (option);
    if (!ptr_trigger)
        return;

    if (weechat_config_boolean (option))
        trigger_hook (ptr_trigger);
    else
        trigger_unhook (ptr_trigger);
}
예제 #5
0
파일: redraw.c 프로젝트: ebfe/vix
void
simtk_redraw_from (struct simtk_widget *root)
{
  struct simtk_widget *this = root;
  struct simtk_event event = {0, 0, 0};

  while (this != NULL)
  {    
    simtk_widget_lock (this);
    
    simtk_widget_draw_border (this, this == this->parent->current_widget ? this->focused_border_color : this->blurred_border_color);

    simtk_widget_dump_to_screen (this);

    trigger_hook (this->event_hooks, SIMTK_EVENT_REDRAW, &event);
    
    simtk_widget_unlock (this);
 
    this = this->next;
  }
}
예제 #6
0
struct t_trigger *
trigger_new_with_options (const char *name, struct t_config_option **options)
{
    struct t_trigger *new_trigger;
    int i;

    new_trigger = trigger_alloc (name);
    if (!new_trigger)
        return NULL;

    for (i = 0; i < TRIGGER_NUM_OPTIONS; i++)
    {
        new_trigger->options[i] = options[i];
    }
    trigger_add (new_trigger, &triggers, &last_trigger);
    triggers_count++;

    if (trigger_regex_split (weechat_config_string (new_trigger->options[TRIGGER_OPTION_REGEX]),
                             &new_trigger->regex_count,
                             &new_trigger->regex) < 0)
    {
        weechat_printf (NULL,
                        _("%s%s: invalid regular expression in trigger "
                          "\"%s\""),
                        weechat_prefix ("error"), TRIGGER_PLUGIN_NAME,
                        name);
    }
    trigger_split_command (weechat_config_string (new_trigger->options[TRIGGER_OPTION_COMMAND]),
                           &new_trigger->commands_count,
                           &new_trigger->commands);

    if (weechat_config_boolean (new_trigger->options[TRIGGER_OPTION_ENABLED]))
        trigger_hook (new_trigger);

    return new_trigger;
}
예제 #7
0
파일: event.c 프로젝트: ebfe/vix
void
simtk_container_event_cascade (struct simtk_container *cont, enum simtk_event_type type, struct simtk_event *event) /* Container-relative event */
{
  struct simtk_widget *widget = NULL;
  struct simtk_widget *focused_widget = NULL;
  struct simtk_widget *blurred_widget = NULL;
  
  struct simtk_event simtk_event;

  int prevent_exec_focus = 0;
  int ign_event = 0;
  
  blurred_widget = cont->current_widget;
  
  switch (type)
  {    
  case SIMTK_EVENT_MOUSEUP:
  case SIMTK_EVENT_MOUSEDOWN:
  case SIMTK_EVENT_MOUSEMOVE:
    
    if ((widget = simtk_find_widget (cont, event->x, event->y)) != NULL)
    {
      if (type == SIMTK_EVENT_MOUSEDOWN)
      {
	cont->current_widget = widget;
        widget->z = HUGE_Z;
	simtk_set_redraw_pending ();
      }
      
      simtk_event.x = event->x - widget->x;
      simtk_event.y = event->y - widget->y;
    }

    break;

  case SIMTK_EVENT_KEYDOWN:
  case SIMTK_EVENT_KEYUP:
    widget = cont->current_widget;
    
    if ((simtk_event.button = event->button) == '\t' &&
	(type == SIMTK_EVENT_KEYDOWN))
    { 
      cont->current_widget = widget->next == NULL ? cont->widget_list[0] : widget->next;
      
      simtk_set_redraw_pending ();

      ++ign_event;
      
      break;
    }

    if (type == SIMTK_EVENT_KEYDOWN && widget->next != NULL)
    {
      widget->z = HUGE_Z;

      simtk_set_redraw_pending ();
    }

    break;

  default:
    ++prevent_exec_focus;
    widget = cont->current_widget;
  }

  focused_widget = cont->current_widget;
        
  if (widget != NULL && !ign_event)
    trigger_hook (widget->event_hooks, type, &simtk_event);

  if (blurred_widget != focused_widget && !prevent_exec_focus)
  { 
    if (blurred_widget != NULL)
      trigger_hook (blurred_widget->event_hooks, SIMTK_EVENT_BLUR, &simtk_event);

    if (focused_widget != NULL)
      trigger_hook (focused_widget->event_hooks, SIMTK_EVENT_FOCUS, &simtk_event);
  }
}
예제 #8
0
파일: event.c 프로젝트: ebfe/vix
/* TODO: fix this */
void
simtk_parse_event_SDL (struct simtk_container *cont, SDL_Event *sdl_event)
{
  struct simtk_event simtk_event;
  enum simtk_event_type type;

  struct simtk_widget *focused_widget = NULL;
  struct simtk_widget *blurred_widget = NULL;
  
  struct simtk_widget *widget = NULL;
  
  int x, y;
  int prevent_exec_focus = 0;
  int ign_event = 0;
  
  blurred_widget = cont->current_widget;
  
  /* Corrent x and y to container */

  switch (sdl_event->type)
  {
  case SDL_QUIT:
    simtk_redraw_thread_quit ();
    
    simtk_container_destroy (cont);

    exit (0);
    
  case SDL_MOUSEBUTTONDOWN:
  case SDL_MOUSEBUTTONUP:
  case SDL_MOUSEMOTION:
    
    type = sdl_event->type == SDL_MOUSEBUTTONDOWN ? SIMTK_EVENT_MOUSEDOWN : (sdl_event->type == SDL_MOUSEMOTION ? SIMTK_EVENT_MOUSEMOVE : SIMTK_EVENT_MOUSEUP);
    
    simtk_event.button = sdl_event->button.button;

    x = sdl_event->button.x - cont->x;
    y = sdl_event->button.y - cont->y;

    if ((widget = cont->motion_widget) == NULL)
      widget = simtk_find_widget (cont, x, y);
    
    if (widget != NULL)
    {
      if (type == SIMTK_EVENT_MOUSEDOWN)
      {
	cont->current_widget = widget;
	cont->motion_widget  = widget;
        widget->z = HUGE_Z;

	simtk_set_redraw_pending ();
      }
      else if (type == SIMTK_EVENT_MOUSEUP)
	cont->motion_widget = NULL;
      
      simtk_event.x = x - widget->x;
      simtk_event.y = y - widget->y;
    }

    break;

  case SDL_KEYDOWN:
  case SDL_KEYUP:
    widget = cont->current_widget;
    
    type = sdl_event->type == SDL_KEYDOWN ? SIMTK_EVENT_KEYDOWN : SIMTK_EVENT_KEYUP;
    
    if ((simtk_event.button = sdl_event->key.keysym.sym) == '\t' &&
	(type == SIMTK_EVENT_KEYDOWN))
    {
      cont->current_widget = widget->next == NULL ? cont->widget_list[0] : widget->next;
      
      simtk_set_redraw_pending ();

      ++ign_event;
      
      break;
    }

    if (type == SIMTK_EVENT_KEYDOWN && widget->next != NULL)
    {
      widget->z = HUGE_Z;
      
      simtk_set_redraw_pending ();
    }
    
    break;

  default:
    ++prevent_exec_focus;
    return;
  }

  focused_widget = cont->current_widget;
    
  if (widget != NULL && !ign_event)
    trigger_hook (widget->event_hooks, type, &simtk_event);

  if (blurred_widget != focused_widget && !prevent_exec_focus)
  { 
    if (blurred_widget != NULL)
      trigger_hook (blurred_widget->event_hooks, SIMTK_EVENT_BLUR, &simtk_event);

    if (focused_widget != NULL)
      trigger_hook (focused_widget->event_hooks, SIMTK_EVENT_FOCUS, &simtk_event);
  }
}