summaryrefslogtreecommitdiffstats
path: root/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2013-11-28 16:26:08 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2013-11-28 16:26:08 +0000
commit1ff04d1b8a7b8358b8d3ffcf28b57ade52241058 (patch)
tree0635743a5d75aca19f6375ecfb1de9d75558e1e3 /contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch
parentfefa48d3c47a2cfbedf6dd544354a2db97760b85 (diff)
downloadtigervnc-1ff04d1b8a7b8358b8d3ffcf28b57ade52241058.tar.gz
tigervnc-1ff04d1b8a7b8358b8d3ffcf28b57ade52241058.zip
Added 'contrib' folder to store patches necessary to build external dependecies, distribution-specific packaging files, etc. Also added a delimiter to the end of the fltk patch script defined in BUILDING.txt to make it easier to parse this script out for automated builds.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5139 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch')
-rw-r--r--contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch135
1 files changed, 135 insertions, 0 deletions
diff --git a/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch b/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch
new file mode 100644
index 00000000..b41af794
--- /dev/null
+++ b/contrib/packages/rpm/el5/SOURCES/fltk-1_v3.3.x-clipboard-win32-fix.patch
@@ -0,0 +1,135 @@
+diff -ur fltk-1.3.0r9110.org/src/Fl_win32.cxx fltk-1.3.0r9110/src/Fl_win32.cxx
+--- fltk-1.3.0r9110.org/src/Fl_win32.cxx 2012-06-17 19:42:02.169422400 +0200
++++ fltk-1.3.0r9110/src/Fl_win32.cxx 2012-06-17 19:43:38.286031455 +0200
+@@ -543,6 +543,37 @@
+ const char* GetValue() const { return(out); }
+ };
+
++void fl_update_clipboard(void) {
++ Fl_Window *w1 = Fl::first_window();
++ if (!w1)
++ return;
++
++ HWND hwnd = fl_xid(w1);
++
++ if (!OpenClipboard(hwnd))
++ return;
++
++ EmptyClipboard();
++
++ int utf16_len = fl_utf8toUtf16(fl_selection_buffer[1],
++ fl_selection_length[1], 0, 0);
++
++ HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and zero'ed mem alloc.
++ LPVOID memLock = GlobalLock(hMem);
++
++ fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1],
++ (unsigned short*) memLock, utf16_len + 1);
++
++ GlobalUnlock(hMem);
++ SetClipboardData(CF_UNICODETEXT, hMem);
++
++ CloseClipboard();
++
++ // In case Windows managed to lob of a WM_DESTROYCLIPBOARD during
++ // the above.
++ fl_i_own_selection[1] = 1;
++}
++
+ // call this when you create a selection:
+ void Fl::copy(const char *stuff, int len, int clipboard) {
+ if (!stuff || len<0) return;
+@@ -560,25 +591,9 @@
+ memcpy(fl_selection_buffer[clipboard], stuff, len);
+ fl_selection_buffer[clipboard][len] = 0; // needed for direct paste
+ fl_selection_length[clipboard] = len;
+- if (clipboard) {
+- // set up for "delayed rendering":
+- if (OpenClipboard(NULL)) {
+- // if the system clipboard works, use it
+- int utf16_len = fl_utf8toUtf16(fl_selection_buffer[clipboard], fl_selection_length[clipboard], 0, 0);
+- EmptyClipboard();
+- HGLOBAL hMem = GlobalAlloc(GHND, utf16_len * 2 + 2); // moveable and zero'ed mem alloc.
+- LPVOID memLock = GlobalLock(hMem);
+- fl_utf8toUtf16(fl_selection_buffer[clipboard], fl_selection_length[clipboard], (unsigned short*) memLock, utf16_len + 1);
+- GlobalUnlock(hMem);
+- SetClipboardData(CF_UNICODETEXT, hMem);
+- CloseClipboard();
+- GlobalFree(hMem);
+- fl_i_own_selection[clipboard] = 0;
+- } else {
+- // only if it fails, instruct paste() to use the internal buffers
+- fl_i_own_selection[clipboard] = 1;
+- }
+- }
++ fl_i_own_selection[clipboard] = 1;
++ if (clipboard)
++ fl_update_clipboard();
+ }
+
+ // Call this when a "paste" operation happens:
+@@ -1307,33 +1322,6 @@
+ fl_i_own_selection[1] = 0;
+ return 1;
+
+- case WM_RENDERALLFORMATS:
+- fl_i_own_selection[1] = 0;
+- // Windoze seems unhappy unless I do these two steps. Documentation
+- // seems to vary on whether opening the clipboard is necessary or
+- // is in fact wrong:
+- CloseClipboard();
+- OpenClipboard(NULL);
+- // fall through...
+- case WM_RENDERFORMAT: {
+- HANDLE h;
+-
+-// int l = fl_utf_nb_char((unsigned char*)fl_selection_buffer[1], fl_selection_length[1]);
+- int l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], NULL, 0); // Pass NULL buffer to query length required
+- h = GlobalAlloc(GHND, (l+1) * sizeof(unsigned short));
+- if (h) {
+- unsigned short *g = (unsigned short*) GlobalLock(h);
+-// fl_utf2unicode((unsigned char *)fl_selection_buffer[1], fl_selection_length[1], (xchar*)g);
+- l = fl_utf8toUtf16(fl_selection_buffer[1], fl_selection_length[1], g, (l+1));
+- g[l] = 0;
+- GlobalUnlock(h);
+- SetClipboardData(CF_UNICODETEXT, h);
+- }
+-
+- // Windoze also seems unhappy if I don't do this. Documentation very
+- // unclear on what is correct:
+- if (fl_msg.message == WM_RENDERALLFORMATS) CloseClipboard();
+- return 1;}
+ case WM_DISPLAYCHANGE: // occurs when screen configuration (number, position) changes
+ Fl::call_screen_init();
+ Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL);
+diff -ur fltk-1.3.0r9110.org/src/Fl.cxx fltk-1.3.0r9110/src/Fl.cxx
+--- fltk-1.3.0r9110.org/src/Fl.cxx 2012-06-17 19:42:02.173422595 +0200
++++ fltk-1.3.0r9110/src/Fl.cxx 2012-06-17 19:42:02.317429497 +0200
+@@ -1420,7 +1420,9 @@
+ ////////////////////////////////////////////////////////////////
+ // hide() destroys the X window, it does not do unmap!
+
+-#if !defined(WIN32) && USE_XFT
++#if defined(WIN32)
++extern void fl_update_clipboard(void);
++#elif USE_XFT
+ extern void fl_destroy_xft_draw(Window);
+ #endif
+
+@@ -1467,14 +1469,8 @@
+ #if defined(WIN32)
+ // this little trick keeps the current clipboard alive, even if we are about
+ // to destroy the window that owns the selection.
+- if (GetClipboardOwner()==ip->xid) {
+- Fl_Window *w1 = Fl::first_window();
+- if (w1 && OpenClipboard(fl_xid(w1))) {
+- EmptyClipboard();
+- SetClipboardData(CF_TEXT, NULL);
+- CloseClipboard();
+- }
+- }
++ if (GetClipboardOwner()==ip->xid)
++ fl_update_clipboard();
+ // 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);