bool
CXWindowsClipboard::open(Time time) const
{
	assert(!m_open);

	LOG((CLOG_DEBUG "open clipboard %d", m_id));

	// assume not motif
	m_motif = false;

	// lock clipboard
	if (m_id == kClipboardClipboard) {
		if (!motifLockClipboard()) {
			return false;
		}

		// check if motif owns the selection.  unlock motif clipboard
		// if it does not.
		m_motif = motifOwnsClipboard();
		LOG((CLOG_DEBUG1 "motif does %sown clipboard", m_motif ? "" : "not "));
		if (!m_motif) {
			motifUnlockClipboard();
		}
	}

	// now open
	m_open = true;
	m_time = time;

	// be sure to flush the cache later if it's dirty
	m_checkCache = true;

	return true;
}
예제 #2
0
bool
XWindowsClipboard::motifGetSelection(const MotifClipFormat* format,
							Atom* actualTarget, String* data) const
{
	// if the current clipboard owner and the owner indicated by the
	// motif clip header are the same then transfer via a property on
	// the root window, otherwise transfer as a normal ICCCM client.
	if (!motifOwnsClipboard()) {
		return icccmGetSelection(format->m_type, actualTarget, data);
	}

	// use motif way
	// FIXME -- this isn't right.  it'll only work if the data is
	// already stored on the root window and only if it fits in a
	// property.  motif has some scheme for transferring part by
	// part that i don't know.
	char name[18 + 20];
	sprintf(name, "_MOTIF_CLIP_ITEM_%d", format->m_data);
   	Atom target = XInternAtom(m_display, name, False);
	Window root = RootWindow(m_display, DefaultScreen(m_display));
	return XWindowsUtil::getWindowProperty(m_display, root,
								target, data,
								actualTarget, NULL, False);
}