[branch-1.3] 371eb65 - macOS: Avoid premature FL_RELEASE event at start of drag-n-drop - cont'd

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[branch-1.3] 371eb65 - macOS: Avoid premature FL_RELEASE event at start of drag-n-drop - cont'd "ManoloFLTK" 23:47 May 26 top right image
 
commit 371eb65654940d6eca1de5716445b1e12bbe86c3
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Thu May 27 08:36:41 2021 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Thu May 27 08:36:41 2021 +0200

    macOS: Avoid premature FL_RELEASE event at start of drag-n-drop - cont'd

 src/Fl_cocoa.mm | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git src/Fl_cocoa.mm src/Fl_cocoa.mm
index fd2c50b..152b3e8 100644
--- src/Fl_cocoa.mm
+++ src/Fl_cocoa.mm
@@ -717,6 +717,8 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data)
 #endif
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
 - (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context;
+- (void)draggingSession:(NSDraggingSession *)session
+           endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation;
 #endif
 - (BOOL)did_view_resolution_change;
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
@@ -2700,17 +2702,6 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
   }
   fl_unlock_function();
 }
-- (void)draggingSession:(NSDraggingSession *)session
-           endedAtPoint:(NSPoint)screenPoint
-              operation:(NSDragOperation)operation {
-  Fl_Widget *w = Fl::pushed();
-  if ( w ) {
-    int old_event = Fl::e_number;
-    w->handle(Fl::e_number = FL_RELEASE);
-    Fl::e_number = old_event;
-    Fl::pushed( 0 );
-  }
-}
 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
 {
   return NSDragOperationGeneric;
@@ -2947,6 +2938,17 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
 {
   return NSDragOperationCopy;
 }
+- (void)draggingSession:(NSDraggingSession *)session
+           endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
+{
+  Fl_Widget *w = Fl::pushed();
+  if ( w ) {
+    int old_event = Fl::e_number;
+    w->handle(Fl::e_number = FL_RELEASE);
+    Fl::e_number = old_event;
+    Fl::pushed( 0 );
+  }
+}
 #endif
 
 @end
@@ -4283,7 +4285,10 @@ static NSImage *defaultDragImage(int *pwidth, int *pheight)
   else {
     width = 16; height = 16;
     }
-  Fl_Offscreen off = fl_create_offscreen(width, height);
+  void *data = calloc(width * height, 4);
+  CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+  CGContextRef off = CGBitmapContextCreate(data, width, height, 8, width*4, lut, kCGImageAlphaPremultipliedLast);
+  CGColorSpaceRelease(lut);
   fl_begin_offscreen(off);
   if (fl_mac_os_version >= version_threshold) {
     fl_font(FL_HELVETICA, 20);
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2021 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.