int ws_provide_selection(int format) { DisplayObj d = CurrentDisplay(NIL); Hyper h; Function msg; Name which = NAME_primary; Name hypername = getAppendName(which, NAME_selectionOwner); Name type; if ( d && notNil(d) && (h = getFindHyperObject(d, hypername, DEFAULT)) && (type = getAttributeObject(h, NAME_type)) && (msg = getAttributeObject(h, NAME_convertFunction)) && (msg = checkType(msg, TypeFunction, NIL)) ) { Any val; DEBUG(NAME_selection, Cprintf("Provide %s selection of type %s\n", pp(which), pp(type))); if ( !(val = getForwardReceiverFunction(msg, h->to, which, type, EAV)) ) return FALSE; DEBUG(NAME_selection, Cprintf("Got %s\n", pp(val))); if ( type == NAME_text ) { CharArray ca = checkType(val, TypeCharArray, NIL); if ( ca ) { String s = &ca->data; HGLOBAL mem = ws_string_to_global_mem(s); if ( mem ) SetClipboardData(CF_UNICODETEXT, mem); return TRUE; } } else if ( type == NAME_emf || type == NAME_wmf ) { Any mf = checkType(val, nameToType(NAME_winMetafile), NIL); if ( mf ) { DEBUG(NAME_selection, Cprintf("Providing win_metafile\n")); return ws_on_clipboard_metafile(mf, type); } } else return errorPce(d, NAME_noSelectionType, type); } return FALSE; }
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; }