Blame SOURCES/fltk-1_v2.3.x-clipboard.patch

ceac5b
diff -up fltk-1.3.x-r8659/FL/Fl.H.orig fltk-1.3.x-r8659/FL/Fl.H
ceac5b
--- fltk-1.3.x-r8659/FL/Fl.H.orig	2011-05-17 16:25:56.671744548 +0200
ceac5b
+++ fltk-1.3.x-r8659/FL/Fl.H	2011-05-17 16:26:05.709101536 +0200
ceac5b
@@ -108,6 +108,9 @@ typedef int (*Fl_Args_Handler)(int argc,
ceac5b
     \see Fl::event_dispatch(Fl_Event_Dispatch) */
ceac5b
 typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
ceac5b
 
ceac5b
+/** Signature of add_clipboard_notify functions passed as parameters */
ceac5b
+typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data);
ceac5b
+
ceac5b
 /** @} */ /* group callback_functions */
ceac5b
 
ceac5b
 
ceac5b
@@ -744,6 +747,19 @@ public:
ceac5b
   */
ceac5b
   static void paste(Fl_Widget &receiver, int source /*=0*/); // platform dependent
ceac5b
   /**
ceac5b
+  FLTK will call the registered callback whenever there is a change to the
ceac5b
+  selection buffer or the clipboard. The source argument indicates which
ceac5b
+  of the two has changed. Only changes by other applications are reported.
ceac5b
+  \note Some systems require polling to monitor the clipboard and may
ceac5b
+  therefore have some delay in detecting changes.
ceac5b
+  */
ceac5b
+  static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data);
ceac5b
+  /**
ceac5b
+  Stop calling the specified callback when there are changes to the selection
ceac5b
+  buffer or the clipboard.
ceac5b
+  */
ceac5b
+  static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h);
ceac5b
+  /**
ceac5b
     Initiate a Drag And Drop operation. The selection buffer should be
ceac5b
     filled with relevant data before calling this method. FLTK will
ceac5b
     then initiate the system wide drag and drop handling. Dropped data
ceac5b
diff -up fltk-1.3.x-r8659/src/Fl.cxx.orig fltk-1.3.x-r8659/src/Fl.cxx
ceac5b
--- fltk-1.3.x-r8659/src/Fl.cxx.orig	2011-05-18 15:20:26.667291459 +0200
ceac5b
+++ fltk-1.3.x-r8659/src/Fl.cxx	2011-05-18 16:31:15.522026086 +0200
ceac5b
@@ -430,6 +430,69 @@ static char in_idle;
ceac5b
 #endif
ceac5b
 
ceac5b
 ////////////////////////////////////////////////////////////////
ceac5b
+// Clipboard notifications
ceac5b
+
ceac5b
+struct Clipboard_Notify {
ceac5b
+  Fl_Clipboard_Notify_Handler handler;
ceac5b
+  void *data;
ceac5b
+  struct Clipboard_Notify *next;
ceac5b
+};
ceac5b
+
ceac5b
+static struct Clipboard_Notify *clip_notify_list = NULL;
ceac5b
+
ceac5b
+extern void fl_clipboard_notify_change(); // in Fl_<platform>.cxx
ceac5b
+
ceac5b
+void Fl::add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data) {
ceac5b
+  struct Clipboard_Notify *node;
ceac5b
+
ceac5b
+  remove_clipboard_notify(h);
ceac5b
+
ceac5b
+  node = new Clipboard_Notify;
ceac5b
+
ceac5b
+  node->handler = h;
ceac5b
+  node->data = data;
ceac5b
+  node->next = clip_notify_list;
ceac5b
+
ceac5b
+  clip_notify_list = node;
ceac5b
+
ceac5b
+  fl_clipboard_notify_change();
ceac5b
+}
ceac5b
+
ceac5b
+void Fl::remove_clipboard_notify(Fl_Clipboard_Notify_Handler h) {
ceac5b
+  struct Clipboard_Notify *node, **prev;
ceac5b
+
ceac5b
+  node = clip_notify_list;
ceac5b
+  prev = &clip_notify_list;
ceac5b
+  while (node != NULL) {
ceac5b
+    if (node->handler == h) {
ceac5b
+      *prev = node->next;
ceac5b
+      delete node;
ceac5b
+
ceac5b
+      fl_clipboard_notify_change();
ceac5b
+
ceac5b
+      return;
ceac5b
+    }
ceac5b
+
ceac5b
+    prev = &node->next;
ceac5b
+    node = node->next;
ceac5b
+  }
ceac5b
+}
ceac5b
+
ceac5b
+bool fl_clipboard_notify_empty(void) {
ceac5b
+  return clip_notify_list == NULL;
ceac5b
+}
ceac5b
+
ceac5b
+void fl_trigger_clipboard_notify(int source) {
ceac5b
+  struct Clipboard_Notify *node;
ceac5b
+
ceac5b
+  node = clip_notify_list;
ceac5b
+  while (node != NULL) {
ceac5b
+    node->handler(source, node->data);
ceac5b
+    node = node->next;
ceac5b
+  }
ceac5b
+}
ceac5b
+
ceac5b
+////////////////////////////////////////////////////////////////
ceac5b
 // wait/run/check/ready:
ceac5b
 
ceac5b
 void (*Fl::idle)(); // see Fl::add_idle.cxx for the add/remove functions