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

Unified Diff: services/ui/ws/cursor_state.cc

Issue 2949353003: Implement large cursors in Mushrome. (Closed)
Patch Set: Remove old cursor.h includes. Created 3 years, 6 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
Index: services/ui/ws/cursor_state.cc
diff --git a/services/ui/ws/cursor_state.cc b/services/ui/ws/cursor_state.cc
index 7e17d13fa64ec184bc6a2f888112d9192a8fa7ea..a1196571f55a31ba032620fca79f555b38f22650 100644
--- a/services/ui/ws/cursor_state.cc
+++ b/services/ui/ws/cursor_state.cc
@@ -14,10 +14,9 @@ namespace ws {
class CursorState::StateSnapshot {
public:
- StateSnapshot()
- : cursor_data_(ui::CursorData(ui::CursorType::kNull)), visible_(true) {}
+ StateSnapshot() = default;
StateSnapshot(const StateSnapshot& rhs) = default;
- ~StateSnapshot() {}
+ ~StateSnapshot() = default;
const base::Optional<ui::CursorData>& global_override_cursor() const {
return global_override_cursor_;
@@ -32,16 +31,22 @@ class CursorState::StateSnapshot {
bool visible() const { return visible_; }
void set_visible(bool visible) { visible_ = visible; }
+ ui::CursorSet cursor_set() const { return cursor_set_; }
+ void set_cursor_set(ui::CursorSet cursor_set) { cursor_set_ = cursor_set; }
+
private:
// An optional cursor set by the window manager which overrides per-window
// requests.
base::Optional<ui::CursorData> global_override_cursor_;
// The last cursor set. Used to track whether we need to change the cursor.
- ui::CursorData cursor_data_;
+ ui::CursorData cursor_data_ = ui::CursorData(ui::CursorType::kNull);
+
+ // Which cursor set to use.
+ ui::CursorSet cursor_set_ = CursorSet::kNormal;
// Whether the cursor is visible.
- bool visible_;
+ bool visible_ = true;
};
CursorState::CursorState(DisplayManager* display_manager)
@@ -73,6 +78,7 @@ void CursorState::UnlockCursor() {
return;
*current_state_ = *state_on_unlock_;
+ SetPlatformCursorSet();
SetPlatformCursor();
}
@@ -94,6 +100,22 @@ void CursorState::SetGlobalOverrideCursor(
}
}
+void CursorState::SetCursorSet(ui::CursorSet cursor_set) {
+ state_on_unlock_->set_cursor_set(cursor_set);
+ if (cursor_lock_count_ == 0 &&
+ current_state_->cursor_set() != state_on_unlock_->cursor_set()) {
+ current_state_->set_cursor_set(cursor_set);
+ SetPlatformCursorSet();
+ SetPlatformCursor();
+ }
+}
+
+void CursorState::SetPlatformCursorSet() {
+ DisplayManager* manager = display_manager_;
+ for (Display* display : manager->displays())
+ display->SetNativeCursorSet(current_state_->cursor_set());
+}
+
void CursorState::SetPlatformCursor() {
DisplayManager* manager = display_manager_;
auto set_on_all = [manager](const ui::CursorData& cursor) {

Powered by Google App Engine
This is Rietveld 408576698