[aseprite] 182/250: Simplify update_mouse_cursor() code

Tobias Hansen thansen at moszumanska.debian.org
Sun Dec 20 15:27:28 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 74c2ce83dcfc282701c15de817bb666d909be031
Author: David Capello <davidcapello at gmail.com>
Date:   Wed Oct 14 19:36:46 2015 -0300

    Simplify update_mouse_cursor() code
---
 src/ui/system.cpp | 62 ++++++++++++++++++++-----------------------------------
 1 file changed, 22 insertions(+), 40 deletions(-)

diff --git a/src/ui/system.cpp b/src/ui/system.cpp
index 500cef5..1750d8a 100644
--- a/src/ui/system.cpp
+++ b/src/ui/system.cpp
@@ -14,6 +14,7 @@
 #include "she/clock.h"
 #include "she/display.h"
 #include "she/surface.h"
+#include "she/system.h"
 #include "ui/cursor.h"
 #include "ui/intern.h"
 #include "ui/intern.h"
@@ -27,19 +28,11 @@ namespace ui {
 
 // Current mouse cursor type.
 
-static CursorType mouse_cursor_type = kNoCursor;
+static CursorType mouse_cursor_type = kOutsideDisplay;
 static Cursor* mouse_cursor = NULL;
 static she::Display* mouse_display = NULL;
 static Overlay* mouse_cursor_overlay = NULL;
 static bool use_native_mouse_cursor = false;
-#ifdef USE_ALLEG4_BACKEND
-  // The native cursor is hidden by default in the Allegro backend
-  static bool native_cursor_set = false; // TODO remove this when we remove the Allegro backend
-#else
-  // The native cursor should be visible by default in
-  // other "she" library backends.
-  static bool native_cursor_set = true;
-#endif
 
 // Mouse information (button and position).
 
@@ -78,11 +71,11 @@ static void update_mouse_cursor()
 {
   // Use native cursor when it's possible/available/configured to do so.
 
-  bool native_cursor_available = false;
-  if (use_native_mouse_cursor || mouse_cursor_type == kOutsideDisplay) {
-    she::NativeCursor nativeCursor = she::kNoCursor;
+  she::NativeCursor nativeCursor = she::kNoCursor;
+  Cursor* cursor = nullptr;
 
-    native_cursor_available = true;
+  if (use_native_mouse_cursor ||
+      mouse_cursor_type == kOutsideDisplay) {
     switch (mouse_cursor_type) {
       case ui::kOutsideDisplay:
         nativeCursor = she::kArrowCursor;
@@ -112,45 +105,34 @@ static void update_mouse_cursor()
       case ui::kSizeSWCursor: nativeCursor = she::kSizeSWCursor; break;
       case ui::kSizeWCursor: nativeCursor = she::kSizeWCursor; break;
       case ui::kSizeNWCursor: nativeCursor = she::kSizeNWCursor; break;
-      default:
-        native_cursor_available = false;
-        break;
-    }
-
-    if (native_cursor_available) {
-      native_cursor_available =
-        mouse_display->setNativeMouseCursor(nativeCursor);
-      native_cursor_set = (nativeCursor != she::kNoCursor);
     }
   }
 
-  // Hide native cursor if it is visible but the current cursor type
-  // is not supported natively.
+  // Set native cursor
+  if (mouse_display) {
+    bool ok = mouse_display->setNativeMouseCursor(nativeCursor);
 
-  if (!native_cursor_available && native_cursor_set) {
-    mouse_display->setNativeMouseCursor(she::kNoCursor);
-    native_cursor_set = false;
+    // It looks like the specific native cursor is not supported,
+    // so we can should use the internal overlay (even when we
+    // have use_native_mouse_cursor flag enabled).
+    if (!ok)
+      nativeCursor = she::kNoCursor;
   }
 
   // Use a software cursor with the overlay.
-
-  if (!native_cursor_set) {
-    if (mouse_cursor_type == ui::kNoCursor) {
-      update_mouse_overlay(NULL);
-    }
-    else {
-      update_mouse_overlay(CurrentTheme::get()->getCursor(mouse_cursor_type));
-    }
-  }
-  else {
-    // Hide the overlay if we are using a native cursor.
-    update_mouse_overlay(NULL);
+  if (nativeCursor == she::kNoCursor &&
+      mouse_cursor_type != ui::kOutsideDisplay &&
+      CurrentTheme::get()) {
+    cursor = CurrentTheme::get()->getCursor(mouse_cursor_type);
   }
+
+  // Set internal overlay
+  update_mouse_overlay(cursor);
 }
 
 UISystem::UISystem()
 {
-  mouse_cursor_type = kNoCursor;
+  mouse_cursor_type = kOutsideDisplay;
 
   details::initWidgets();
 }

-- 
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