summaryrefslogtreecommitdiff
path: root/src/Fl_win32.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2013-09-11 12:54:40 +0000
committerPierre Ossman <ossman@cendio.se>2013-09-11 12:54:40 +0000
commit1d6cc80d591568fb05dcd0373b53f108ef06326f (patch)
treeb146baa80a03e2ed826c478b232bc989c6ce0e64 /src/Fl_win32.cxx
parentf410352c7c2d90e62dc709af0a19a856b20620e9 (diff)
STR 2636. Add ability to get notifications whenever the
clipboard changes. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9974 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_win32.cxx')
-rw-r--r--src/Fl_win32.cxx55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 02cecd949..ce480b5d7 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -634,6 +634,38 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
}
}
+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()
@@ -1211,6 +1243,27 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL);
return 0;
+ 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;
@@ -1647,6 +1700,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) {