void makeSticky(int wid) { CGSConnection cid; cid = _CGSDefaultConnection(); CGSWindowTag tags[2]; tags[0] = tags[1] = 0; OSStatus retVal = CGSGetWindowTags(cid, wid, tags, 32); if(!retVal) { tags[0] = CGSTagSticky; retVal = CGSSetWindowTags(cid, wid, tags, 32); } }
void DEHandleTagsEvent(DecEvent* event) { DecEventTags* eventTags = dec_event_tags_new(event); if (eventTags == NULL) return; int* eventTargets = dec_event_targets_get(event); int eventTargetsSize = dec_event_targets_size_get(event); if (eventTargets == NULL || eventTargetsSize == 0) { dec_event_tags_free(eventTags); return; } int i; CGSConnection cgConnection = _CGSDefaultConnection(); CGSWindowTag cgWindowTags[2] = { 0, 0 }; int tags = dec_event_tags_value_get(eventTags); DecTagsType type = dec_event_tags_type_get(eventTags); /* I would not feel good about setting the tags for all windows at once as I do not know what [1] = 0 means for clearing / setting */ for (i = 0; i < eventTargetsSize; i++) { OSStatus oResult = CGSGetWindowTags(cgConnection, eventTargets[i], cgWindowTags, 32); if (oResult) continue; cgWindowTags[0] = tags; if (type == kDecTagsClear) { CGSClearWindowTags( cgConnection, eventTargets[i], cgWindowTags, 32 ); } else { CGSSetWindowTags( cgConnection, eventTargets[i], cgWindowTags, 32 ); } } dec_event_tags_free(eventTags); }