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

Unified Diff: ash/laser/laser_pointer_controller.h

Issue 2311393004: Laser tool blocks events from propagating. (Closed)
Patch Set: Fixed patch set 4 errors. 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..57e931eac18c2a86f4c8061b77a3ef8e054a428b
--- /dev/null
+++ b/ash/laser/laser_pointer_controller.h
@@ -0,0 +1,81 @@
+// 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/macros.h"
+#include "ui/aura/window_observer.h"
+#include "ui/events/event.h"
jdufault 2016/09/16 18:43:53 Do you need this include?
sammiequon 2016/09/16 19:21:03 Done.
+#include "ui/events/event_handler.h"
+#include "ui/gfx/geometry/point.h"
+
+namespace base {
+class Timer;
+}
+
+namespace ui {
+class LocatedEvent;
jdufault 2016/09/16 18:43:53 Is this needed?
sammiequon 2016/09/16 19:21:03 Done.
+class MouseEvent;
+class TouchEvent;
jdufault 2016/09/16 18:43:53 Is this needed?
sammiequon 2016/09/16 19:21:03 Done.
+}
+
+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:
+ LaserPointerController();
+ ~LaserPointerController() override;
+
+ // Turns the laser pointer feature on or off. The user still has to press and
+ // drag to see the laser pointer.
+ void SetEnabled(bool enabled);
+
+ private:
+ friend class LaserPointerControllerTestApi;
+
+ // ui::EventHandler:
+ void OnMouseEvent(ui::MouseEvent* event) override;
+
+ // aura::WindowObserver:
+ void OnWindowDestroying(aura::Window* window) override;
+
+ void StopTimer();
jdufault 2016/09/16 18:43:53 StopStationaryTimer?
sammiequon 2016/09/16 19:21:03 Done.
+
+ // Reparent, recreate or destroy LaserPointerView instance as needed based on
+ // the current window and the widgets window.
+ void SwitchTargetRootWindowIfNeeded(aura::Window* root_window);
+
+ // 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> stationary_timer_;
+ int stationary_timer_repeat_count_ = 0;
+
+ bool enabled_ = false;
+
+ // The last seen mouse location in screen coordinates.
+ gfx::Point current_mouse_location_;
+
+ // |laser_pointer_view_| will only hold an instance when the laser pointer is
+ // enabled and activated (pressed or dragged).
+ std::unique_ptr<LaserPointerView> laser_pointer_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(LaserPointerController);
+};
+
+} // namespace ash
+
+#endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698