void
be_handle_clipboard_changed_message (void)
{
+ int64 n_clipboard, n_primary, n_secondary;
+
+ n_clipboard = system_clipboard->SystemCount ();
+ n_primary = primary->SystemCount ();
+ n_secondary = secondary->SystemCount ();
+
if (count_clipboard != -1
- && (system_clipboard->SystemCount ()
- > count_clipboard + 1)
+ && (n_clipboard > count_clipboard + 1)
&& owned_clipboard)
{
owned_clipboard = false;
- haiku_selection_disowned (CLIPBOARD_CLIPBOARD);
+ haiku_selection_disowned (CLIPBOARD_CLIPBOARD,
+ n_clipboard);
}
if (count_primary != -1
- && (primary->SystemCount ()
- > count_primary + 1)
+ && (n_primary > count_primary + 1)
&& owned_primary)
{
owned_primary = false;
- haiku_selection_disowned (CLIPBOARD_PRIMARY);
+ haiku_selection_disowned (CLIPBOARD_PRIMARY,
+ n_primary);
}
if (count_secondary != -1
- && (secondary->SystemCount ()
- > count_secondary + 1)
+ && (n_secondary > count_secondary + 1)
&& owned_secondary)
{
owned_secondary = false;
- haiku_selection_disowned (CLIPBOARD_SECONDARY);
+ haiku_selection_disowned (CLIPBOARD_SECONDARY,
+ n_secondary);
}
}
clipboard = get_clipboard_object (id);
clipboard->StartWatching (be_app);
}
+
+bool
+be_selection_outdated_p (enum haiku_clipboard id, int64 count)
+{
+ if (id == CLIPBOARD_CLIPBOARD && count_clipboard > count)
+ return true;
+
+ if (id == CLIPBOARD_PRIMARY && count_primary > count)
+ return true;
+
+ if (id == CLIPBOARD_SECONDARY && count_secondary > count)
+ return true;
+
+ return false;
+}
void
haiku_handle_selection_clear (struct input_event *ie)
{
+ enum haiku_clipboard id;
+
+ id = haiku_get_clipboard_name (ie->arg);
+
+ if (be_selection_outdated_p (id, ie->timestamp))
+ return;
+
CALLN (Frun_hook_with_args,
Qhaiku_lost_selection_functions, ie->arg);
}
void
-haiku_selection_disowned (enum haiku_clipboard id)
+haiku_selection_disowned (enum haiku_clipboard id, int64 count)
{
struct input_event ie;
break;
}
+ ie.timestamp = count;
kbd_buffer_store_event (&ie);
}
{
#endif
/* Defined in haikuselect.c. */
-extern void haiku_selection_disowned (enum haiku_clipboard);
+extern void haiku_selection_disowned (enum haiku_clipboard, int64);
/* Defined in haiku_select.cc. */
extern void be_clipboard_init (void);
extern void be_unlock_clipboard (enum haiku_clipboard, bool);
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);
#ifdef __cplusplus
};