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

Issue 891003004: MacViews: Implement SetCursor (Closed)

Created:
5 years, 10 months ago by tapted
Modified:
5 years, 10 months ago
Reviewers:
Robert Sesek, Andre
CC:
chromium-reviews, tfarina, tdanderson+views_chromium.org, chrome-apps-syd-reviews_chromium.org, mac-views-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@20150129-MacViews-Bringup5
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

MacViews: Implement NativeWidgetMac::SetCursor() Tracking areas in Cocoa are a horrible mess. 10.5 semi-deprecated NSWindow cursorRects, and introduced [NSResponder cursorUpdate:]. Both are supported and they react with each other in strange ways. Intercepting events for toolkit-views SetCapture seems to further complicate things. After numerous dead-ends, this CL implements SetCursor() by overriding cursorUpdate: on NativeWidgetMac's NSWindow override. This works because cursorUpdate: messages are forwarded along the responder chain (starting from varied and somewhat unpredictable starting points), and usually end up at the NSWindow. Rather than adding more NSTrackingArea cruft, the one in BridgedContentView is updated to handle cursor updates. This ensures the cursor is reset to "normal" whenever it leaves the content area. Installing a global event monitor also resets the mouse cursor to an arrow. I tried tracing this with NSObjCMessageLoggingEnabled, but the reset isn't done with Objective-C. To fix, "remind" AppKit what the cursor should be after setting capture. See code comments for all the other traps. Testing tracking rectangles with simulated events is pretty much a lost cause, but NativeWidgetMacTest.SetCursor() is added which gets some coverage by sending an event directly to [NSWindow cursorUpdate:], and using the ui::test::EventGenerator to forward events to toolkit-views to actually request new cursors to set. BUG=454698 Committed: https://crrev.com/715cb510d3fe596bf604c2e48741fbc08d1e9aee Cr-Commit-Position: refs/heads/master@{#314660}

Patch Set 1 : first failed attempt (actually more like the 3rd or 4th..) #

Patch Set 2 : Here is all the tracing. But I think I have something workable #

Patch Set 3 : OK - I think this is close as we can get #

Patch Set 4 : Just update in content area. More comments. #

Patch Set 5 : Well... I actually managed to test something #

Patch Set 6 : cl format #

Total comments: 2

Patch Set 7 : rebase? #

Patch Set 8 : assign -> retain #

Unified diffs Side-by-side diffs Delta from patch set Stats (+146 lines, -8 lines) Patch
M ui/views/cocoa/bridged_content_view.mm View 1 2 3 4 5 6 1 chunk +8 lines, -7 lines 0 comments Download
M ui/views/cocoa/bridged_native_widget.h View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
M ui/views/cocoa/bridged_native_widget.mm View 1 2 3 4 2 chunks +12 lines, -0 lines 0 comments Download
M ui/views/cocoa/native_widget_mac_nswindow.mm View 1 2 3 4 5 6 1 chunk +22 lines, -0 lines 0 comments Download
M ui/views/cocoa/views_nswindow_delegate.h View 1 2 3 4 5 6 7 2 chunks +7 lines, -0 lines 0 comments Download
M ui/views/cocoa/views_nswindow_delegate.mm View 1 2 1 chunk +12 lines, -0 lines 0 comments Download
M ui/views/widget/native_widget_mac.mm View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M ui/views/widget/native_widget_mac_unittest.mm View 1 2 3 4 5 2 chunks +80 lines, -0 lines 0 comments Download

Messages

Total messages: 11 (3 generated)
tapted
Hi Andre and Robert.. adding you both as reviewers since this CL turned out to ...
5 years, 10 months ago (2015-02-03 07:58:46 UTC) #2
Andre
LGTM https://codereview.chromium.org/891003004/diff/100001/ui/views/cocoa/views_nswindow_delegate.h File ui/views/cocoa/views_nswindow_delegate.h (right): https://codereview.chromium.org/891003004/diff/100001/ui/views/cocoa/views_nswindow_delegate.h#newcode31 ui/views/cocoa/views_nswindow_delegate.h:31: @property(assign, nonatomic) NSCursor* cursor; Should be documented as ...
5 years, 10 months ago (2015-02-04 02:05:56 UTC) #3
tapted
Robert - do you see any red flags in this approach? https://codereview.chromium.org/891003004/diff/100001/ui/views/cocoa/views_nswindow_delegate.h File ui/views/cocoa/views_nswindow_delegate.h (right): ...
5 years, 10 months ago (2015-02-04 08:49:28 UTC) #5
Robert Sesek
LGTM, sorry I didn't get to this yesterday.
5 years, 10 months ago (2015-02-04 15:58:50 UTC) #6
tapted
Thanks for taking a look!
5 years, 10 months ago (2015-02-04 22:00:07 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/891003004/140001
5 years, 10 months ago (2015-02-04 22:00:46 UTC) #9
commit-bot: I haz the power
Committed patchset #8 (id:140001)
5 years, 10 months ago (2015-02-04 22:25:24 UTC) #10
commit-bot: I haz the power
5 years, 10 months ago (2015-02-04 22:28:07 UTC) #11
Message was sent while issue was closed.
Patchset 8 (id:??) landed as
https://crrev.com/715cb510d3fe596bf604c2e48741fbc08d1e9aee
Cr-Commit-Position: refs/heads/master@{#314660}

Powered by Google App Engine
This is Rietveld 408576698