static status unlinkHyper(Hyper h) { if ( !onFlag(h->to, F_FREED|F_FREEING) ) sendv(h->to, NAME_deleteHyper, 1, (Any *)&h); if ( !onFlag(h->from, F_FREED|F_FREEING) ) sendv(h->from, NAME_deleteHyper, 1, (Any *)&h); succeed; }
void considerLocStillEvent() { if ( !loc_still_posted ) { unsigned long now = mclock(); if ( now - host_last_time < (unsigned long)loc_still_time ) { DEBUG(NAME_locStill, Cprintf("TimeDiff = %d (ignored)\n", now - host_last_time)); return; } if ( !pceMTTryLock(LOCK_PCE) ) return; if ( instanceOfObject(last_window, ClassWindow) && !onFlag(last_window, F_FREED|F_FREEING) && valInt(last_x) > 0 && valInt(last_y) > 0 ) { ServiceMode(is_service_window(last_window), { AnswerMark mark; EventObj e; markAnswerStack(mark); e = newObject(ClassEvent, NAME_locStill, last_window, last_x, last_y, last_buttons, toInt(last_time + now - host_last_time), EAV); addCodeReference(e); postNamedEvent(e, (Graphical) last_window, DEFAULT, NAME_postEvent); delCodeReference(e); freeableObj(e); rewindAnswerStack(mark, NIL); }) }
void newAssoc(Name name, Any obj) { PceITFSymbol symbol; Any old; if ( (old = getObjectAssoc(name)) ) deleteAssoc(old); deleteAssoc(obj); if ( onFlag(name, F_ITFNAME) ) { symbol = getMemberHashTable(NameToITFTable, name); symbol->object = obj; appendHashTable(ObjectToITFTable, obj, symbol); setFlag(obj, F_ASSOC); } else { symbol = newSymbol(obj, name); setFlag(name, F_ITFNAME); if ( isObject(obj) ) setFlag(obj, F_ASSOC); appendHashTable(ObjectToITFTable, obj, symbol); appendHashTable(NameToITFTable, name, symbol); } if ( isObject(obj) ) lockObj(obj); }
Name getNameAssoc(Any obj) { if ( (isObject(obj) && onFlag(obj, F_ASSOC)) ) { PceITFSymbol symbol = getMemberHashTable(ObjectToITFTable, obj); return symbol->name; } fail; }
Any getObjectAssoc(Name name) { if ( onFlag(name, F_ITFNAME) ) { PceITFSymbol symbol = getMemberHashTable(NameToITFTable, name); return symbol->object; } fail; }
void deleteAssoc(Any obj) { if ( isObject(obj) && onFlag(obj, F_ASSOC) ) { PceITFSymbol symbol = getMemberHashTable(ObjectToITFTable, obj); if ( symbol ) { symbol->object = NULL; deleteHashTable(ObjectToITFTable, obj); clearFlag(obj, F_ASSOC); } } }
static status removeCellImageTable(Table tab, TableCell cell, BoolObj keep) { Graphical gr = cell->image; if ( notNil(gr) ) { DeviceGraphical(gr, NIL); if ( keep != ON && !onFlag(gr, F_PROTECTED|F_LOCKED|F_FREED) ) qadSendv(gr, NAME_destroy, 0, NULL); } succeed; }
static status imageTableCell(TableCell c, Graphical gr) { if ( c->image != gr ) { Graphical old = c->image; Table tab = table_of_cell(c); if ( notNil(old) && !onFlag(old, F_FREEING|F_FREED) ) { Any nil = NIL; qadSendv(old, NAME_layoutInterface, 1, &nil); send(old, NAME_destroy, EAV); } assign(c, image, gr); qadSendv(gr, NAME_layoutInterface, 1, (Any *)&c); if ( tab && notNil(tab->device) ) send(tab->device, NAME_display, gr, EAV); requestComputeLayoutManager(c->layout_manager, DEFAULT); } succeed; }
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; }