From f27bde8316b28db2fc3214ce97fd4278e2d9efec Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 10 Jun 2014 14:23:46 +0000 Subject: Windows' clipboard chain is a very fragile thing that can easily break if an application misbehaves and/or crashes. So to minimise risk, don't register ourselves unless we really need to. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10188 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_win32.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index e00a92e41..ba8915b10 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -738,9 +738,20 @@ 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() { - // No need to do anything here... + // 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) { @@ -1798,7 +1809,10 @@ Fl_X* Fl_X::make(Fl_Window* w) { x->next = Fl_X::first; Fl_X::first = x; - fl_clipboard_notify_target(x->xid); + // Setup clipboard monitor target if there are registered handlers and + // no window is targeted. + if (!fl_clipboard_notify_empty() && clipboard_wnd == NULL) + fl_clipboard_notify_target(x->xid); x->wait_for_expose = 1; if (fl_show_iconic) {showit = 0; fl_show_iconic = 0;} -- cgit v1.2.3