public:
virtual ~Selection() {}
- /// Tell the window system whether we have a selection.
+ /**
+ * Tell the window system whether we set or cleared our selection.
+ * This is a noop on systems that don't have a selection.
+ * This should be called by the kernel whenever a selection is
+ * created, changed or cleared.
+ * \param own
+ * If true: Tell that we got a valid selection.
+ * If false: Tell that we cleared our selection.
+ */
virtual void haveSelection(bool) = 0;
/**
* Get the X selection contents.
if (!qApp->clipboard()->supportsSelection())
return;
+ // Tell qt that we have a selection by setting a dummy selection.
+ // We don't use the interface provided by Qt for setting the
+ // selection for performance reasons (see documentation of
+ // Selection::put()). Instead we only tell here that we have a
+ // selection by setting the selection to the empty string.
+ // The real selection is set in GuiApplication::x11EventFilter when
+ // an application actually requests it.
+ // This way calling Selection::have() is cheap and we can do it as
+ // often as we want.
if (own)
qApp->clipboard()->setText(QString(), QClipboard::Selection);
// We don't need to do anything if own = false, as this case is