Ejemplo n.º 1
0
static status
eventTileAdjuster(TileAdjuster adj, EventObj ev)
{ Int offset;

  if ( postEventWindow((PceWindow) adj, ev) )
    succeed;

  if ( isDownEvent(ev) && (offset = getEventOffsetTileAdjuster(adj, ev)) )
  { send(adj, NAME_focus, adj, DEFAULT, adj->cursor, getButtonEvent(ev), EAV);

    assign(adj, down_offset, offset);
    succeed;
  } else if ( notNil(adj->offset) )
  { if ( isDragEvent(ev) )
    { DisplayObj d = getDisplayEvent(ev);

      if ( d && ws_events_queued_display(d) )
	succeed;

      forwardTileAdjuster(adj, ev);
    } else if ( isUpEvent(ev) )
    { forwardTileAdjuster(adj, ev);

      assign(adj, down_offset, NIL);
    }

    succeed;
  }

  fail;
}
Ejemplo n.º 2
0
static status
eventBrowserSelectGesture(BrowserSelectGesture g, EventObj ev)
{ status rval;
  ListBrowser lb = get_list_browser(ev);

					/* Handle the browsers scrollbar */
  if ( g->scrolling == ON )
  { send(lb->scroll_bar, NAME_event, ev, EAV);
    if ( isUpEvent(ev) )
      assign(g, scrolling, OFF);
    succeed;
  }
  if ( isDownEvent(ev) && insideEvent(ev, (Graphical)lb->scroll_bar) )
  { assign(g, scrolling, ON);
    send(lb->scroll_bar, NAME_event, ev, EAV);
    succeed;
  }

  rval = eventGesture(g, ev);

  if ( g->status == NAME_active &&
       (isAEvent(ev, NAME_locMove) ||
	isAEvent(ev, NAME_wheel)) )
  { send(g, NAME_drag, ev, EAV);
    succeed;
  }

  return rval;
}
Ejemplo n.º 3
0
static status
eventPopupGesture(PopupGesture g, EventObj ev)
{ if ( g->status == NAME_active && isUpEvent(ev) )
  { PceWindow sw;

    if ( !(sw = getWindowGraphical(ev->receiver)) )
      sw = ev->window;

    if ( notNil(g->current) && g->current->displayed == OFF )
    { send(g->current, NAME_open, ev->receiver,
	   getAreaPositionEvent(ev, DEFAULT), EAV);
      attributeObject(g, NAME_Stayup, ON);
      grabPointerWindow(sw, ON);
      focusWindow(sw, ev->receiver, (Recogniser) g, g->cursor, NIL);
    } else if ( valInt(getClickTimeEvent(ev)) < 400 &&
		getAttributeObject(g, NAME_Stayup) != ON )
    { attributeObject(g, NAME_Stayup, ON);
      grabPointerWindow(sw, ON);
      focusWindow(sw, ev->receiver, (Recogniser) g, g->cursor, NIL);
    } else
    { send(g, NAME_terminate, EAV);
      if ( isNil(g->current) )
      { grabPointerWindow(sw, OFF);
	focusWindow(sw, NIL, NIL, NIL, NIL);
	deleteAttributeObject(g, NAME_Stayup);
	assign(g, status, NAME_inactive);
      }
    }

    succeed;
  } else if ( notNil(g->current) && g->current->displayed == ON )
    return postEvent(ev, (Graphical) g->current, DEFAULT);

  if ( eventGesture(g, ev) )
    succeed;

  if ( g->status == NAME_active && isAEvent(ev, NAME_keyboard) )
  { Name key;

    TRY(updatePopupGesture(g, ev));
    key = characterName(getIdEvent(ev));

    if ( send(g->current, NAME_key, key, EAV) )
    { Any context = g->context;
      PopupObj current = g->current;

      assign(g, context, NIL);
      assign(g, current, NIL);

      send(current, NAME_execute, context, EAV);
      succeed;
    } else
      send(g, NAME_cancel, ev, EAV);
  }

  fail;
}
Ejemplo n.º 4
0
status
eventGesture(Any obj, EventObj ev)
{ Gesture g = obj;

  if ( g->active == OFF )
    fail;

  if ( g->status == NAME_active &&
       notNil(g->drag_scroll) )
  { Graphical gr;

    if ( tryDragScrollGesture(g, ev) )
      succeed;
    if ( isAEvent(ev, NAME_wheel) &&
	 (gr=getScrollTarget(g, ev)) )
      return postEvent(ev, gr, DEFAULT);
  }

  if ( isDownEvent(ev) &&
       hasModifierEvent(ev, g->modifier) &&
       getButtonEvent(ev) == g->button &&
       (isNil(g->condition) || forwardReceiverCode(g->condition, g, ev, EAV)) &&
       send(g, NAME_verify, ev, EAV) )
  { TRY( send(g, NAME_initiate, ev, EAV) );
    assign(g, status, NAME_active);
    send(ev->window, NAME_focus,
	 ev->receiver, g, g->cursor, getButtonEvent(ev), EAV);
    succeed;
  } else if ( g->status != NAME_inactive )
  { if ( isDragEvent(ev) )
    { send(g, NAME_drag, ev, EAV);
      succeed;
    } else if ( isUpEvent(ev) && getButtonEvent(ev) == g->button )
    { cancelDragScrollGesture(g);
      send(g, NAME_terminate, ev, EAV);
      assign(g, status, NAME_inactive);
      succeed;
    }
  }

  fail;
}
Ejemplo n.º 5
0
static status
initialiseEvent(EventObj e, Name id, Any window,
		Int x, Int y, Int bts, Int time)
{ unsigned long t = valInt(time);

  initialiseProgramObject(e);

  if ( notNil(EVENT->value) )
  { EventObj parent = EVENT->value;

    if ( isDefault(x) )      x      = parent->x;
    if ( isDefault(y) )      y      = parent->y;
    if ( isDefault(bts) )    bts    = parent->buttons;
    if ( isDefault(window) ) window = parent->window;
    if ( isDefault(time) )   t      = max(last_time, parent->time);
  } else
  { if ( isDefault(x) )      x      = last_x;
    if ( isDefault(y) )      y      = last_y;
    if ( isDefault(bts) )    bts    = last_buttons;
    if ( isDefault(window) ) window = last_window;
    if ( isDefault(time) )   t      = last_time;
  }

  host_last_time = mclock();
  last_time      = t;
  last_buttons   = bts;			/* save these values */
  last_x         = x;
  last_y         = y;

  assign(e, window,	window);
  assign(e, receiver,	window);
  assign(e, id,		id);
  assign(e, x,		x);
  assign(e, y,		y);
  assign(e, buttons,	bts);
  e->time = t;

  if ( isDownEvent(e) )
  { int clt = CLICK_TYPE_single;
    int px  = valInt(x);
    int py  = valInt(y);

    DEBUG(NAME_multiclick, Cprintf("t: %ld (%ld), x: %d (%d), y: %d (%d) --> ",
				   t, last_down_time, px, last_down_x,
				   py, last_down_y));

    if ( (valInt(e->buttons) & CLICK_TYPE_mask) == CLICK_TYPE_double )
    { switch( last_click_type )
      { case CLICK_TYPE_single:	clt = CLICK_TYPE_double; break;
	case CLICK_TYPE_double:	clt = CLICK_TYPE_triple; break;
	default:		clt = CLICK_TYPE_single; break;
      }
      e->buttons = toInt(valInt(e->buttons) & ~CLICK_TYPE_mask);
    } else
    { if ( (t - last_down_time) < multi_click_time &&
	   abs(last_down_x - px) <= multi_click_diff &&
	   abs(last_down_y - py) <= multi_click_diff &&
	   (valInt(last_down_bts)&BUTTON_mask) == (valInt(bts)&BUTTON_mask) &&
	   last_window == window )
      { switch( last_click_type )
	{ case CLICK_TYPE_single:	clt = CLICK_TYPE_double; break;
	  case CLICK_TYPE_double:	clt = CLICK_TYPE_triple; break;
	}
      }
    }

    last_click_type = clt;
    assign(e, buttons, toInt(valInt(e->buttons) | clt));

    DEBUG(NAME_multiclick, Cprintf("%s\n", strName(getMulticlickEvent(e))));

    last_down_bts     = bts;
    last_down_time    = t;
    last_down_x       = px;
    last_down_y       = py;
  } else if ( isUpEvent(e) )
  { assign(e, buttons, toInt(valInt(e->buttons) | last_click_type));
  }

  if ( !onFlag(window, F_FREED|F_FREEING) )
    last_window = window;

  if ( loc_still_posted )
  { if ( isAEvent(e, NAME_locMove) )
    { DEBUG(NAME_locStill, Cprintf("Re-enabled loc-still on %s\n", pp(e->id)));
      loc_still_posted = FALSE;
    }
  } else if ( isAEvent(e, NAME_area) ||
	      isAEvent(e, NAME_deactivateKeyboardFocus) )
  { DEBUG(NAME_locStill, Cprintf("Disabled loc-still on %s\n", pp(e->id)));
    loc_still_posted = TRUE;
  }

  succeed;
}