diff options
| author | Pierre Ossman <ossman@cendio.se> | 2013-09-11 12:54:40 +0000 |
|---|---|---|
| committer | Pierre Ossman <ossman@cendio.se> | 2013-09-11 12:54:40 +0000 |
| commit | 1d6cc80d591568fb05dcd0373b53f108ef06326f (patch) | |
| tree | b146baa80a03e2ed826c478b232bc989c6ce0e64 /src/Fl_cocoa.mm | |
| parent | f410352c7c2d90e62dc709af0a19a856b20620e9 (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_cocoa.mm')
| -rw-r--r-- | src/Fl_cocoa.mm | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 3c8d22da8..7b042d324 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -90,6 +90,7 @@ static void createAppleMenu(void); static Fl_Region MacRegionMinusRect(Fl_Region r, int x,int y,int w,int h); static void cocoaMouseHandler(NSEvent *theEvent); static int calc_mac_os_version(); +static void clipboard_check(void); Fl_Display_Device *Fl_Display_Device::_display = new Fl_Display_Device(new Fl_Quartz_Graphics_Driver); // the platform display @@ -1109,16 +1110,21 @@ static void cocoaMouseHandler(NSEvent *theEvent) fl_unlock_function(); return reply; } -/** - * Cocoa organizes the Z depth of windows on a global priority. FLTK however - * expects the window manager to organize Z level by application. The trickery - * below will change Z order during activation and deactivation. - */ - (void)applicationDidBecomeActive:(NSNotification *)notify { - fl_lock_function(); Fl_X *x; FLWindow *top = 0, *topModal = 0, *topNonModal = 0; + + fl_lock_function(); + + // update clipboard status + clipboard_check(); + + /** + * Cocoa organizes the Z depth of windows on a global priority. FLTK however + * expects the window manager to organize Z level by application. The trickery + * below will change Z order during activation and deactivation. + */ for (x = Fl_X::first;x;x = x->next) { FLWindow *cw = x->xid; Fl_Window *win = x->w; @@ -2720,6 +2726,26 @@ static void allocatePasteboard() { PasteboardCreate(kPasteboardClipboard, &myPasteboard); } +extern void fl_trigger_clipboard_notify(int source); + +void fl_clipboard_notify_change() { + // No need to do anything here... +} + +static void clipboard_check(void) +{ + PasteboardSyncFlags flags; + + allocatePasteboard(); + flags = PasteboardSynchronize(myPasteboard); + + if (!(flags & kPasteboardModified)) + return; + if (flags & kPasteboardClientIsOwner) + return; + + fl_trigger_clipboard_notify(1); +} /* * create a selection |
