Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Unified Diff: ui/aura/cursor.h

Issue 9463003: aura-x11: Add custom web cursor support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/cursor_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/cursor.h
diff --git a/ui/aura/cursor.h b/ui/aura/cursor.h
index 33664e89ef05d6e3de60342c320e97f0baafe701..32314e5ebefded006c49cb24f6dc3783c433dfb9 100644
--- a/ui/aura/cursor.h
+++ b/ui/aura/cursor.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,8 +6,30 @@
#define UI_AURA_CURSOR_H_
#pragma once
+#include "build/build_config.h"
+#include "ui/aura/aura_export.h"
+
+namespace gfx {
+class Point;
+class Size;
+}
+
+#if defined(OS_WIN)
+typedef struct HINSTANCE__* HINSTANCE;
+typedef struct HICON__* HICON;
+typedef HICON HCURSOR;
+#endif
+
namespace aura {
+#if defined(OS_WIN)
+typedef ::HCURSOR PlatformCursor;
+#elif defined(USE_X11)
+typedef unsigned long PlatformCursor;
+#else
+typedef void* PlatformCursor;
+#endif
+
// TODO(jamescook): Once we're on C++0x we could change these constants
// to an enum and forward declare it in native_widget_types.h.
@@ -61,6 +83,65 @@ const int kCursorGrab = 42;
const int kCursorGrabbing = 43;
const int kCursorCustom = 44;
+// Ref-counted cursor that supports both default and custom cursors.
+class AURA_EXPORT Cursor {
+ public:
+ Cursor()
+ : native_type_(0),
+ platform_(0) {
+ }
+
+ // Implicit constructor.
+ Cursor(int type)
+ : native_type_(type),
+ platform_(0) {
+ }
+
+ // Allow copy.
+ Cursor(const Cursor& cursor)
+ : native_type_(cursor.native_type_),
+ platform_(cursor.platform_) {
+ if (native_type_ == kCursorCustom)
+ RefCustomCursor();
+ }
+
+ ~Cursor() {
+ if (native_type_ == kCursorCustom)
+ UnrefCustomCursor();
+ }
+
+ void SetPlatformCursor(const PlatformCursor& platform) {
+ if (platform_)
+ UnrefCustomCursor();
+ native_type_ = kCursorCustom;
+ platform_ = platform;
+ RefCustomCursor();
+ }
+
+ void RefCustomCursor();
+ void UnrefCustomCursor();
+
+ int native_type() const { return native_type_; }
+ PlatformCursor platform() const { return platform_; }
+
+ bool operator==(int type) const { return native_type_ == type; }
Daniel Erat 2012/02/27 17:53:55 This feels a bit weird to me. I think that it'd b
+ bool operator==(const Cursor& cursor) const {
+ return native_type_ == cursor.native_type_ &&
+ platform_ == cursor.platform_;
+ }
+ bool operator!=(int type) const { return native_type_ != type; }
+ bool operator!=(const Cursor& cursor) const {
+ return native_type_ != cursor.native_type_ ||
+ platform_ != cursor.platform_;
+ }
+
+ private:
+ // See definitions above.
+ int native_type_;
+
+ PlatformCursor platform_;
Daniel Erat 2012/02/27 17:53:55 nit: rename to platform_cursor_
+};
+
} // namespace aura
#endif // UI_AURA_CURSOR_H_
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/cursor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698