You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fltk-1_v2.3.x-clipboard-win32.patch 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. diff -ur fltk-1.3.0r9110.org/src/Fl.cxx fltk-1.3.0r9110/src/Fl.cxx
  2. --- fltk-1.3.0r9110.org/src/Fl.cxx 2012-06-17 19:47:09.988183253 +0200
  3. +++ fltk-1.3.0r9110/src/Fl.cxx 2012-06-17 19:47:10.127189919 +0200
  4. @@ -1421,6 +1421,7 @@
  5. // hide() destroys the X window, it does not do unmap!
  6. #if defined(WIN32)
  7. +extern void fl_clipboard_notify_untarget(HWND wnd);
  8. extern void fl_update_clipboard(void);
  9. #elif USE_XFT
  10. extern void fl_destroy_xft_draw(Window);
  11. @@ -1471,6 +1472,8 @@
  12. // to destroy the window that owns the selection.
  13. if (GetClipboardOwner()==ip->xid)
  14. fl_update_clipboard();
  15. + // Make sure we unlink this window from the clipboard chain
  16. + fl_clipboard_notify_untarget(ip->xid);
  17. // Send a message to myself so that I'll get out of the event loop...
  18. PostMessage(ip->xid, WM_APP, 0, 0);
  19. if (ip->private_dc) fl_release_dc(ip->xid, ip->private_dc);
  20. diff -ur fltk-1.3.0r9110.org/src/Fl_win32.cxx fltk-1.3.0r9110/src/Fl_win32.cxx
  21. --- fltk-1.3.0r9110.org/src/Fl_win32.cxx 2012-06-17 19:47:09.987183205 +0200
  22. +++ fltk-1.3.0r9110/src/Fl_win32.cxx 2012-06-17 19:47:19.069618739 +0200
  23. @@ -646,6 +646,38 @@
  24. }
  25. }
  26. +static HWND clipboard_wnd = 0;
  27. +static HWND next_clipboard_wnd = 0;
  28. +
  29. +static bool initial_clipboard = true;
  30. +
  31. +void fl_clipboard_notify_change() {
  32. + // No need to do anything here...
  33. +}
  34. +
  35. +void fl_clipboard_notify_target(HWND wnd) {
  36. + if (clipboard_wnd)
  37. + return;
  38. +
  39. + // We get one fake WM_DRAWCLIPBOARD immediately, which we therefore
  40. + // need to ignore.
  41. + initial_clipboard = true;
  42. +
  43. + clipboard_wnd = wnd;
  44. + next_clipboard_wnd = SetClipboardViewer(wnd);
  45. +}
  46. +
  47. +void fl_clipboard_notify_untarget(HWND wnd) {
  48. + if (wnd != clipboard_wnd)
  49. + return;
  50. +
  51. + ChangeClipboardChain(wnd, next_clipboard_wnd);
  52. + clipboard_wnd = next_clipboard_wnd = 0;
  53. +
  54. + if (Fl::first_window())
  55. + fl_clipboard_notify_target(fl_xid(Fl::first_window()));
  56. +}
  57. +
  58. ////////////////////////////////////////////////////////////////
  59. char fl_is_ime = 0;
  60. void fl_get_codepage()
  61. @@ -1327,6 +1359,27 @@
  62. Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL);
  63. return 0;
  64. + case WM_CHANGECBCHAIN:
  65. + if ((hWnd == clipboard_wnd) &&
  66. + (next_clipboard_wnd == (HWND)wParam)) {
  67. + next_clipboard_wnd = (HWND)lParam;
  68. + return 0;
  69. + }
  70. + break;
  71. +
  72. + case WM_DRAWCLIPBOARD:
  73. + // When the clipboard moves between two FLTK windows,
  74. + // fl_i_own_selection will temporarily be false as we are
  75. + // processing this message. Hence the need to use fl_find().
  76. + if (!initial_clipboard && !fl_find(GetClipboardOwner()))
  77. + fl_trigger_clipboard_notify(1);
  78. + initial_clipboard = false;
  79. +
  80. + if (next_clipboard_wnd)
  81. + SendMessage(next_clipboard_wnd, WM_DRAWCLIPBOARD, wParam, lParam);
  82. +
  83. + return 0;
  84. +
  85. default:
  86. if (Fl::handle(0,0)) return 0;
  87. break;
  88. @@ -1685,6 +1738,8 @@
  89. x->next = Fl_X::first;
  90. Fl_X::first = x;
  91. + fl_clipboard_notify_target(x->xid);
  92. +
  93. x->wait_for_expose = 1;
  94. if (fl_show_iconic) {showit = 0; fl_show_iconic = 0;}
  95. if (showit) {