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

Unified Diff: ash/laser/laser_pointer_controller.h

Issue 2311393004: Laser tool blocks events from propagating. (Closed)
Patch Set: Created 4 years, 3 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: ash/laser/laser_pointer_controller.h
diff --git a/ash/laser/laser_pointer_controller.h b/ash/laser/laser_pointer_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..ac0ebe797bd77a17574ad77fc09b62e4d4fc1bea
--- /dev/null
+++ b/ash/laser/laser_pointer_controller.h
@@ -0,0 +1,77 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_LASER_LASER_POINTER_CONTROLLER_H_
+#define ASH_LASER_LASER_POINTER_CONTROLLER_H_
+
+#include <memory>
+
+#include "ash/ash_export.h"
+#include "base/timer/timer.h"
+#include "ui/aura/window_observer.h"
+#include "ui/events/event.h"
+#include "ui/events/event_handler.h"
+#include "ui/gfx/geometry/point.h"
+
+namespace base {
+class Timer;
+}
+
+namespace ui {
+class LocatedEvent;
+class MouseEvent;
+class TouchEvent;
+}
+
+namespace ash {
+
+class LaserPointerView;
+
+// Controller for the laser pointer functionality. Enables/disables laser
+// pointer as well as receives points and passes them off to be rendered.
+class ASH_EXPORT LaserPointerController : public ui::EventHandler,
+ public aura::WindowObserver {
+ public:
+ explicit LaserPointerController();
+ ~LaserPointerController() override;
+
+ void SetEnabled(bool enabled);
jdufault 2016/09/12 21:10:11 Add a comment
sammiequon 2016/09/13 01:09:56 Done.
+
+ private:
+ friend class LaserPointerControllerTestApi;
+
+ // WindowObserver:
jdufault 2016/09/12 21:10:11 aura::WindowObserver
jdufault 2016/09/12 21:10:11 Move this to below the ui::EventHandler overrides
sammiequon 2016/09/13 01:09:56 Done.
sammiequon 2016/09/13 01:09:56 Done.
+ void OnWindowDestroying(aura::Window* window) override;
+
+ // ui::EventHandler:
+ void OnMouseEvent(ui::MouseEvent* event) override;
+ void OnTouchEvent(ui::TouchEvent* event) override;
+
+ // Contains common logic between OnMouseEvent and OnTouchEvent.
+ void OnLocatedEvent(ui::LocatedEvent* event,
+ const ui::PointerDetails& pointer_details);
+
+ void StopTimer();
+ void SwitchTargetRootWindowIfNeeded();
+
+ // Timer callback which adds a point where the mouse was last seen. This
+ // allows the trail to fade away when the mouse is stationary.
+ void AddStationaryPoint();
+
+ // Timer which will add a new stationary point when the mouse stops moving.
+ // This will remove points that are too old.
+ std::unique_ptr<base::Timer> timer_;
+ int timer_repeat_count_ = 0;
+
+ bool enabled_ = false;
+
+ gfx::Point current_mouse_location_;
+ std::unique_ptr<LaserPointerView> laser_pointer_view_;
jdufault 2016/09/12 21:10:11 I'd add a comment saying that laser_pointer_view_
sammiequon 2016/09/13 01:09:56 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(LaserPointerController);
+};
+
+} // namespace ash
+
+#endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698