summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-06-10 14:23:46 +0000
committerPierre Ossman <ossman@cendio.se>2014-06-10 14:23:46 +0000
commitf27bde8316b28db2fc3214ce97fd4278e2d9efec (patch)
treeba14ec5b8e4a51098fe086cf4266963c7c3ea6a9 /src
parent6944612e56b8968b6d6f80a915aadd16b1f132ff (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/Fl_win32.cxx18
1 files changed, 16 insertions, 2 deletions
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;}