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

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: Fix windows more. 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 c81bb8cb86b78b4d1ccfc2e6e0649a9e30cc96f3..c3370e7909d3c747208dc47fc635b637c971118d 100644
--- a/components/mus/ws/window_manager_state.cc
+++ b/components/mus/ws/window_manager_state.cc
@@ -165,6 +165,38 @@ void WindowManagerState::OnWillDestroyTree(WindowTree* tree) {
: mojom::EventResult::UNHANDLED);
}
+mojo::ScopedSharedBufferHandle WindowManagerState::GetCursorLocationMemory() {
+ 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::Atomic64),
+ &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::Atomic64),
+ 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;
+ MojoResult result = mojo::DuplicateBuffer(cursor_location_handle_.get(),
sky 2016/04/20 23:46:36 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_READ_ONL
+ nullptr, &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 +206,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();
@@ -362,6 +396,16 @@ void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) {
window_server()->ProcessLostCapture(window);
}
+void WindowManagerState::OnMouseCursorLocationChanged(
+ const gfx::Point& point) {
+ current_cursor_location_ =
+ (static_cast<base::subtle::Atomic64>(point.x()) << 32) | point.y();
+ 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