"Find the types of data available from CLIPBOARD.
CLIPBOARD should be the symbol `PRIMARY', `SECONDARY' or
`CLIPBOARD'. Return the available types as a list of strings."
- (mapcar #'car (haiku-selection-data clipboard nil)))
+ (delq 'type (mapcar #'car (haiku-selection-data clipboard nil))))
(defun haiku-select-encode-xstring (_selection value)
"Convert VALUE to a system message association.
(cl-defmethod gui-backend-get-selection (type data-type
&context (window-system haiku))
- (if (eq data-type 'TARGETS)
- (apply #'vector (mapcar #'intern
- (haiku-selection-targets type)))
- (if (eq type 'XdndSelection)
- haiku-dnd-selection-value
- (haiku-selection-data type (haiku--selection-type-to-mime data-type)))))
+ (cond
+ ((eq data-type 'TARGETS)
+ (apply #'vector (mapcar #'intern
+ (haiku-selection-targets type))))
+ ;; The timestamp here is really the number of times a program has
+ ;; put data into the selection. But it always increases, so it
+ ;; makes sense if one imagines that time is frozen until
+ ;; immediately before that happens.
+ ((eq data-type 'TIMESTAMP)
+ (haiku-selection-timestamp type))
+ ((eq type 'XdndSelection) haiku-dnd-selection-value)
+ (t (haiku-selection-data type
+ (haiku--selection-type-to-mime data-type)))))
(cl-defmethod gui-backend-set-selection (type value
&context (window-system haiku))
return false;
}
+
+int64
+be_get_clipboard_count (enum haiku_clipboard id)
+{
+ BClipboard *clipboard;
+
+ clipboard = get_clipboard_object (id);
+ return clipboard->SystemCount ();
+}
signal_error ("Invalid clipboard", clipboard);
}
+DEFUN ("haiku-selection-timestamp", Fhaiku_selection_timestamp,
+ Shaiku_selection_timestamp, 1, 1, 0,
+ doc: /* Retrieve the "timestamp" of the clipboard CLIPBOARD.
+CLIPBOARD can either be the symbol `PRIMARY', `SECONDARY' or
+`CLIPBOARD'. The timestamp is returned as a number describing the
+number of times programs have put data into CLIPBOARD. */)
+ (Lisp_Object clipboard)
+{
+ enum haiku_clipboard clipboard_name;
+ int64 timestamp;
+
+ clipboard_name = haiku_get_clipboard_name (clipboard);
+ timestamp = be_get_clipboard_count (clipboard_name);
+
+ return INT_TO_INTEGER (timestamp);
+}
+
DEFUN ("haiku-selection-data", Fhaiku_selection_data, Shaiku_selection_data,
2, 2, 0,
doc: /* Retrieve content typed as NAME from the clipboard
DEFSYM (Qalready_running, "already-running");
defsubr (&Shaiku_selection_data);
+ defsubr (&Shaiku_selection_timestamp);
defsubr (&Shaiku_selection_put);
defsubr (&Shaiku_selection_owner_p);
defsubr (&Shaiku_drag_message);
extern void be_handle_clipboard_changed_message (void);
extern void be_start_watching_selection (enum haiku_clipboard);
extern bool be_selection_outdated_p (enum haiku_clipboard, int64);
+extern int64 be_get_clipboard_count (enum haiku_clipboard);
#ifdef __cplusplus
};