[aseprite] 109/134: Add infinite editor scroll to OS X

Tobias Hansen thansen at moszumanska.debian.org
Sat Mar 14 17:10:14 UTC 2015


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit eff46d413496b76fbd0dd1564b29c4355fcaaff9
Author: David Capello <davidcapello at gmail.com>
Date:   Sun Jan 25 19:09:30 2015 -0300

    Add infinite editor scroll to OS X
    
    Fix osx_mouse_position()
---
 src/allegro/src/macosx/qzmouse.m | 30 ++++++++++++++----------------
 src/app/ui/editor/editor.cpp     |  2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/allegro/src/macosx/qzmouse.m b/src/allegro/src/macosx/qzmouse.m
index acbf35a..c2f5f16 100644
--- a/src/allegro/src/macosx/qzmouse.m
+++ b/src/allegro/src/macosx/qzmouse.m
@@ -216,26 +216,24 @@ static void osx_mouse_exit(void)
  */
 static void osx_mouse_position(int x, int y)
 {
-   CGPoint point;
-   NSRect frame;
-   int screen_height;
+   int scale, view_scale;
+   NSPoint pt;
+   CGPoint pos;
+   CGEventRef event;
+   NSView* view = [osx_window contentView];
 
    _unix_lock_mutex(osx_event_mutex);
 
-   _mouse_x = point.x = x;
-   _mouse_y = point.y = y;
+   pt = NSMakePoint(x, y);
+   pt = [view convertPoint:pt toView:view];
+   pt = [view convertPoint:pt toView:nil];
+   pt = [osx_window convertBaseToScreen:pt];
+   pt.y = [[osx_window screen] frame].size.height - pt.y;
 
-   if (osx_window) {
-      CFNumberGetValue(CFDictionaryGetValue(CGDisplayCurrentMode(kCGDirectMainDisplay), kCGDisplayHeight), kCFNumberSInt32Type, &screen_height);
-      frame = [osx_window frame];
-      point.x += frame.origin.x;
-      point.y += (screen_height - (frame.origin.y + gfx_driver->h));
-   }
-
-   CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, point);
-
-   mymickey_x = mymickey_y = 0;
-   osx_mouse_warped = TRUE;
+   pos = CGPointMake(pt.x, pt.y);
+   event = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pos, 0);
+   CGEventPost(kCGHIDEventTap, event);
+   CFRelease(event);
 
    _unix_unlock_mutex(osx_event_mutex);
 }
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index 35fa551..ac68cb3 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -738,7 +738,7 @@ gfx::Point Editor::autoScroll(MouseMessage* msg, AutoScroll dir, bool blit_valid
     }
     setEditorScroll(scroll.x, scroll.y, blit_valid_rgn);
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__APPLE__)
     mousePos -= delta;
     ui::set_mouse_position(mousePos);
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list