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

Unified Diff: components/mus/ws/window_manager_state.cc

Issue 1881253002: mus: Implement ScreenMus::GetCursorScreenPoint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually apply the 32bit patch now that the delegate crash was fixed. Created 4 years, 8 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: components/mus/ws/window_manager_state.cc
diff --git a/components/mus/ws/window_manager_state.cc b/components/mus/ws/window_manager_state.cc
index 7fc9bd2556f0b80562c7b4eb5b9c1fa5fef1e4a4..d741d0d03593319b2a339a9bef596f714978858a 100644
--- a/components/mus/ws/window_manager_state.cc
+++ b/components/mus/ws/window_manager_state.cc
@@ -165,6 +165,43 @@ void WindowManagerState::OnWillDestroyTree(WindowTree* tree) {
: mojom::EventResult::UNHANDLED);
}
+mojo::ScopedSharedBufferHandle WindowManagerState::GetCursorLocationMemory() {
sky 2016/04/27 20:10:28 If you put this code here, it means we're only get
+ if (!cursor_location_memory_) {
+ // Create our shared memory segment to share the cursor state with our
+ // window clients.
+ MojoResult result = mojo::CreateSharedBuffer(nullptr,
+ sizeof(base::subtle::Atomic32),
+ &cursor_location_handle_);
+ if (result != MOJO_RESULT_OK)
+ return mojo::ScopedSharedBufferHandle();
+ DCHECK(cursor_location_handle_.is_valid());
+
+ result = mojo::MapBuffer(cursor_location_handle_.get(), 0,
+ sizeof(base::subtle::Atomic32),
+ reinterpret_cast<void**>(&cursor_location_memory_),
+ MOJO_MAP_BUFFER_FLAG_NONE);
+ if (result != MOJO_RESULT_OK)
+ return mojo::ScopedSharedBufferHandle();
+ DCHECK(cursor_location_memory_);
+
+ base::subtle::NoBarrier_Store(cursor_location_memory_,
+ current_cursor_location_);
+ }
+
+ mojo::ScopedSharedBufferHandle duped;
+ MojoDuplicateBufferHandleOptions options = {
+ sizeof(MojoDuplicateBufferHandleOptions),
+ MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_READ_ONLY
+ };
+ MojoResult result = mojo::DuplicateBuffer(cursor_location_handle_.get(),
+ &options, &duped);
+ if (result != MOJO_RESULT_OK)
+ return mojo::ScopedSharedBufferHandle();
+ DCHECK(duped.is_valid());
+
+ return duped;
+}
+
WindowManagerState::WindowManagerState(Display* display,
PlatformDisplay* platform_display,
cc::SurfaceId surface_id,
@@ -174,7 +211,9 @@ WindowManagerState::WindowManagerState(Display* display,
platform_display_(platform_display),
is_user_id_valid_(is_user_id_valid),
user_id_(user_id),
- event_dispatcher_(this) {
+ event_dispatcher_(this),
+ current_cursor_location_(0),
+ cursor_location_memory_(nullptr) {
frame_decoration_values_ = mojom::FrameDecorationValues::New();
frame_decoration_values_->normal_client_area_insets = mojo::Insets::New();
frame_decoration_values_->maximized_client_area_insets = mojo::Insets::New();
@@ -369,6 +408,17 @@ void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) {
window_server()->ProcessLostCapture(window);
}
+void WindowManagerState::OnMouseCursorLocationChanged(
+ const gfx::Point& point) {
+ current_cursor_location_ =
+ static_cast<base::subtle::Atomic32>(
+ (point.x() & 0xFFFF) << 16 | (point.y() & 0xFFFF));
+ if (cursor_location_memory_) {
+ base::subtle::NoBarrier_Store(cursor_location_memory_,
+ current_cursor_location_);
+ }
+}
+
void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target,
bool in_nonclient_area,
const ui::Event& event,

Powered by Google App Engine
This is Rietveld 408576698