summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-10-08 12:47:20 +0000
committerPierre Ossman <ossman@cendio.se>2014-10-08 12:47:20 +0000
commit6d06bb425da4f471841de9f2ad072b64780dde58 (patch)
tree5b78a40d4ae7be433d2bc39ccd95ad0fbbcda599
parent15de7c0600ade64152e1fc32e81a5e6b0c9f10b2 (diff)
Make the retargeting of the Windows clipboard notification
more explicit. Otherwise we could end up with Fl::remove_clipboard_notify() unregistering, just to have it immediately re-register again. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10364 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl.cxx4
-rw-r--r--src/Fl_win32.cxx42
2 files changed, 27 insertions, 19 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index bb1079ca4..e800d79e7 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1464,7 +1464,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_clipboard_notify_retarget(HWND wnd);
extern void fl_update_clipboard(void);
#elif USE_XFT
extern void fl_destroy_xft_draw(Window);
@@ -1542,7 +1542,7 @@ void Fl_Window::hide() {
if (GetClipboardOwner()==ip->xid)
fl_update_clipboard();
// Make sure we unlink this window from the clipboard chain
- fl_clipboard_notify_untarget(ip->xid);
+ fl_clipboard_notify_retarget(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 --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index bbe9905e6..3a4cdfab4 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -790,23 +790,8 @@ static HWND clipboard_wnd = 0;
static HWND next_clipboard_wnd = 0;
static bool initial_clipboard = true;
-void fl_clipboard_notify_target(HWND wnd);
-void fl_clipboard_notify_change() {
- // untarget clipboard monitor if no handlers are registered
- if (clipboard_wnd != NULL && fl_clipboard_notify_empty())
- {
- fl_clipboard_notify_untarget(clipboard_wnd);
- return;
- }
-
- // if there are clipboard notify handlers but no window targeted
- // target first window if available
- if (clipboard_wnd == NULL && Fl::first_window())
- fl_clipboard_notify_target(fl_xid(Fl::first_window()));
-}
-
-void fl_clipboard_notify_target(HWND wnd) {
+static void fl_clipboard_notify_target(HWND wnd) {
if (clipboard_wnd)
return;
@@ -818,17 +803,40 @@ void fl_clipboard_notify_target(HWND wnd) {
next_clipboard_wnd = SetClipboardViewer(wnd);
}
-void fl_clipboard_notify_untarget(HWND wnd) {
+static void fl_clipboard_notify_untarget(HWND wnd) {
if (wnd != clipboard_wnd)
return;
ChangeClipboardChain(wnd, next_clipboard_wnd);
clipboard_wnd = next_clipboard_wnd = 0;
+}
+
+void fl_clipboard_notify_retarget(HWND wnd) {
+ // The given window is getting destroyed. If it's part of the
+ // clipboard chain then we need to unregister it and find a
+ // replacement window.
+ if (wnd != clipboard_wnd)
+ return;
+
+ fl_clipboard_notify_untarget(wnd);
if (Fl::first_window())
fl_clipboard_notify_target(fl_xid(Fl::first_window()));
}
+void fl_clipboard_notify_change() {
+ // untarget clipboard monitor if no handlers are registered
+ if (clipboard_wnd != NULL && fl_clipboard_notify_empty()) {
+ fl_clipboard_notify_untarget(clipboard_wnd);
+ return;
+ }
+
+ // if there are clipboard notify handlers but no window targeted
+ // target first window if available
+ if (clipboard_wnd == NULL && Fl::first_window())
+ fl_clipboard_notify_target(fl_xid(Fl::first_window()));
+}
+
////////////////////////////////////////////////////////////////
void fl_get_codepage()
{