DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2636
Version: 1.3-feature


Attached file "fltk-1.3.x-clipboard-win32.patch"...


Link: http://www.fltk.org/str.php?L2636
Version: 1.3-feature
diff -up fltk-1.3.x-r8659/src/Fl.cxx.win32-fix fltk-1.3.x-r8659/src/Fl.cxx
--- fltk-1.3.x-r8659/src/Fl.cxx.win32-fix       2011-05-19 13:47:56.082954290 
+0200
+++ fltk-1.3.x-r8659/src/Fl.cxx 2011-05-19 13:47:35.540869893 +0200
@@ -1413,6 +1413,7 @@ int Fl::handle_(int e, Fl_Window* window
 // hide() destroys the X window, it does not do unmap!
 
 #if defined(WIN32)
+extern void fl_clipboard_notify_untarget(HWND wnd);
 extern void fl_update_clipboard(void);
 #elif USE_XFT
 extern void fl_destroy_xft_draw(Window);
@@ -1463,6 +1464,8 @@ void Fl_Window::hide() {
   // to destroy the window that owns the selection.
   if (GetClipboardOwner()==ip->xid)
     fl_update_clipboard();
+  // Make sure we unlink this window from the clipboard chain
+  fl_clipboard_notify_untarget(ip->xid);
   // Send a message to myself so that I'll get out of the event loop...
   PostMessage(ip->xid, WM_APP, 0, 0);
   if (ip->private_dc) fl_release_dc(ip->xid, ip->private_dc);
diff -up fltk-1.3.x-r8659/src/Fl_win32.cxx.win32-fix 
fltk-1.3.x-r8659/src/Fl_win32.cxx
--- fltk-1.3.x-r8659/src/Fl_win32.cxx.win32-fix 2011-05-19 13:49:31.147228227 
+0200
+++ fltk-1.3.x-r8659/src/Fl_win32.cxx   2011-05-19 13:47:42.548922155 +0200
@@ -654,6 +654,38 @@ void Fl::paste(Fl_Widget &receiver, int 
   }
 }
 
+static HWND clipboard_wnd = 0;
+static HWND next_clipboard_wnd = 0;
+
+static bool initial_clipboard = true;
+
+void fl_clipboard_notify_change() {
+  // No need to do anything here...
+}
+
+void fl_clipboard_notify_target(HWND wnd) {
+  if (clipboard_wnd)
+    return;
+
+  // We get one fake WM_DRAWCLIPBOARD immediately, which we therefore
+  // need to ignore.
+  initial_clipboard = true;
+
+  clipboard_wnd = wnd;
+  next_clipboard_wnd = SetClipboardViewer(wnd);
+}
+
+void fl_clipboard_notify_untarget(HWND wnd) {
+  if (wnd != clipboard_wnd)
+    return;
+
+  ChangeClipboardChain(wnd, next_clipboard_wnd);
+  clipboard_wnd = next_clipboard_wnd = 0;
+
+  if (Fl::first_window())
+    fl_clipboard_notify_target(fl_xid(Fl::first_window()));
+}
+
 ////////////////////////////////////////////////////////////////
 char fl_is_ime = 0;
 void fl_get_codepage()
@@ -1296,6 +1328,27 @@ static LRESULT CALLBACK WndProc(HWND hWn
     fl_i_own_selection[1] = 0;
     return 1;
 
+  case WM_CHANGECBCHAIN:
+    if ((hWnd == clipboard_wnd) &&
+        (next_clipboard_wnd == (HWND)wParam)) {
+      next_clipboard_wnd = (HWND)lParam;
+      return 0;
+    }
+    break;
+
+  case WM_DRAWCLIPBOARD:
+    // When the clipboard moves between two FLTK windows,
+    // fl_i_own_selection will temporarily be false as we are
+    // processing this message. Hence the need to use fl_find().
+    if (!initial_clipboard && !fl_find(GetClipboardOwner()))
+      fl_trigger_clipboard_notify(1);
+    initial_clipboard = false;
+
+    if (next_clipboard_wnd)
+      SendMessage(next_clipboard_wnd, WM_DRAWCLIPBOARD, wParam, lParam);
+
+    return 0;
+
   default:
     if (Fl::handle(0,0)) return 0;
     break;
@@ -1652,6 +1705,8 @@ Fl_X* Fl_X::make(Fl_Window* w) {
   x->next = Fl_X::first;
   Fl_X::first = x;
 
+  fl_clipboard_notify_target(x->xid);
+
   x->wait_for_expose = 1;
   if (fl_show_iconic) {showit = 0; fl_show_iconic = 0;}
   if (showit) {
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to