Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / ozone / platform / drm / host / drm_cursor.h
blob2fba1443e220775fb05277e43eed4baf097edf1d
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_DRM_CURSOR_H_
6 #define UI_OZONE_PLATFORM_DRM_HOST_DRM_CURSOR_H_
8 #include "base/callback.h"
9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h"
12 #include "ui/base/cursor/cursor.h"
13 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
14 #include "ui/gfx/geometry/point_f.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/native_widget_types.h"
17 #include "ui/ozone/public/gpu_platform_support_host.h"
19 namespace gfx {
20 class PointF;
21 class Vector2dF;
22 class Rect;
25 namespace ui {
27 class BitmapCursorOzone;
28 class BitmapCursorFactoryOzone;
29 class DrmGpuPlatformSupportHost;
30 class DrmWindowHostManager;
32 class DrmCursor : public CursorDelegateEvdev {
33 public:
34 explicit DrmCursor(DrmWindowHostManager* window_manager);
35 ~DrmCursor() override;
37 // Change the cursor over the specifed window.
38 void SetCursor(gfx::AcceleratedWidget window, PlatformCursor platform_cursor);
40 // Handle window lifecycle.
41 void OnWindowAdded(gfx::AcceleratedWidget window,
42 const gfx::Rect& bounds_in_screen,
43 const gfx::Rect& cursor_confined_bounds);
44 void OnWindowRemoved(gfx::AcceleratedWidget window);
46 // Handle window bounds changes.
47 void CommitBoundsChange(gfx::AcceleratedWidget window,
48 const gfx::Rect& new_display_bounds_in_screen,
49 const gfx::Rect& new_confined_bounds);
51 // CursorDelegateEvdev:
52 void MoveCursorTo(gfx::AcceleratedWidget window,
53 const gfx::PointF& location) override;
54 void MoveCursorTo(const gfx::PointF& screen_location) override;
55 void MoveCursor(const gfx::Vector2dF& delta) override;
56 bool IsCursorVisible() override;
57 gfx::PointF GetLocation() override;
58 gfx::Rect GetCursorConfinedBounds() override;
60 // IPC.
61 void OnChannelEstablished(
62 int host_id,
63 scoped_refptr<base::SingleThreadTaskRunner> send_runner,
64 const base::Callback<void(IPC::Message*)>& sender);
65 void OnChannelDestroyed(int host_id);
66 bool OnMessageReceived(const IPC::Message& message);
68 private:
69 // Set the location (clamps to cursor bounds).
70 void SetCursorLocationLocked(const gfx::PointF& location);
72 // The location of the bitmap (the cursor location is the hotspot location).
73 gfx::Point GetBitmapLocationLocked();
75 // IPC-related functions.
76 bool IsConnectedLocked();
77 void SendCursorShowLocked();
78 void SendCursorHideLocked();
79 void SendCursorMoveLocked();
80 void SendLocked(IPC::Message* message);
82 DrmWindowHostManager* window_manager_; // Not owned.
84 // Task runner for main thread.
85 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
87 struct CursorState {
88 CursorState();
89 ~CursorState();
91 // The current cursor bitmap (immutable).
92 scoped_refptr<BitmapCursorOzone> bitmap;
94 // The window under the cursor.
95 gfx::AcceleratedWidget window;
97 // The location of the cursor within the window.
98 gfx::PointF location;
100 // The bounds of the display under the cursor.
101 gfx::Rect display_bounds_in_screen;
103 // The bounds that the cursor is confined to in |window|.
104 gfx::Rect confined_bounds;
106 int host_id;
108 // Callback for IPC updates.
109 base::Callback<void(IPC::Message*)> send_callback;
110 scoped_refptr<base::SingleThreadTaskRunner> send_runner;
112 // The mutex synchronizing this object.
113 base::Lock lock;
116 CursorState state_;
119 } // namespace ui
121 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_CURSOR_H_