| Index: ash/utility/screenshot_controller.h
|
| diff --git a/ash/utility/partial_screenshot_controller.h b/ash/utility/screenshot_controller.h
|
| similarity index 56%
|
| rename from ash/utility/partial_screenshot_controller.h
|
| rename to ash/utility/screenshot_controller.h
|
| index 6f2ca36d65880409279debed738da74b4beb856e..3f13f760e116c650c6a9d25e70c5a2717ea2d208 100644
|
| --- a/ash/utility/partial_screenshot_controller.h
|
| +++ b/ash/utility/screenshot_controller.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef ASH_UTILITY_PARTIAL_SCREENSHOT_CONTROLLER_H_
|
| -#define ASH_UTILITY_PARTIAL_SCREENSHOT_CONTROLLER_H_
|
| +#ifndef ASH_UTILITY_SCREENSHOT_CONTROLLER_H_
|
| +#define ASH_UTILITY_SCREENSHOT_CONTROLLER_H_
|
|
|
| #include <stdint.h>
|
|
|
| @@ -13,6 +13,7 @@
|
| #include "ash/ash_export.h"
|
| #include "ash/shell_observer.h"
|
| #include "base/macros.h"
|
| +#include "ui/aura/window_observer.h"
|
| #include "ui/display/display_observer.h"
|
| #include "ui/events/event_handler.h"
|
| #include "ui/gfx/geometry/point.h"
|
| @@ -28,33 +29,46 @@ class LocatedEvent;
|
| namespace ash {
|
| class ScreenshotDelegate;
|
|
|
| -// This class controls a session of taking partial screenshot, i.e.: drawing
|
| -// region rectangles during drag, and changing the mouse cursor to indicate
|
| +// This class controls a session of taking partial/window screenshot, i.e.:
|
| +// drawing
|
| +// region rectangles during selection, and changing the mouse cursor to indicate
|
| // the current mode.
|
| // This class does not use aura::Window / views::Widget intentionally to avoid
|
| -// the conflicts of window manager features like mouse captures or window focus.
|
| -class ASH_EXPORT PartialScreenshotController : public ui::EventHandler,
|
| - public display::DisplayObserver {
|
| +class ASH_EXPORT ScreenshotController : public ui::EventHandler,
|
| + public display::DisplayObserver,
|
| + public aura::WindowObserver {
|
| public:
|
| - PartialScreenshotController();
|
| - ~PartialScreenshotController() override;
|
| + ScreenshotController();
|
| + ~ScreenshotController() override;
|
|
|
| // Starts the UI for taking partial screenshot; dragging to select a region.
|
| - // PartialScreenshotController manage their own lifetime so caller must not
|
| + // ScreenshotController manage their own lifetime so caller must not
|
| // delete the returned values.
|
| void StartPartialScreenshotSession(ScreenshotDelegate* screenshot_delegate);
|
|
|
| + // Starts the UI for taking a window screenshot;
|
| + void StartWindowScreenshotSession(ScreenshotDelegate* screenshot_delegate);
|
| +
|
| private:
|
| - friend class PartialScreenshotControllerTest;
|
| + enum Mode {
|
| + NONE,
|
| + PARTIAL,
|
| + WINDOW,
|
| + };
|
| +
|
| + friend class ScreenshotControllerTest;
|
|
|
| class ScopedCursorSetter;
|
| - class PartialScreenshotLayer;
|
| + class ScreenshotLayer;
|
|
|
| // Starts, ends, cancels, or updates the region selection.
|
| void MaybeStart(const ui::LocatedEvent& event);
|
| - void Complete();
|
| + void CompleteWindowScreenshot();
|
| + void CompletePartialScreenshot();
|
| void Cancel();
|
| void Update(const ui::LocatedEvent& event);
|
| + void UpdateSelectedWindow(ui::LocatedEvent* event);
|
| + void SetSelectedWindow(aura::Window* window);
|
|
|
| // ui::EventHandler:
|
| void OnKeyEvent(ui::KeyEvent* event) override;
|
| @@ -67,12 +81,20 @@ class ASH_EXPORT PartialScreenshotController : public ui::EventHandler,
|
| void OnDisplayMetricsChanged(const display::Display& display,
|
| uint32_t changed_metrics) override;
|
|
|
| + // aura::WindowObserver:
|
| + void OnWindowDestroying(aura::Window* window) override;
|
| +
|
| + Mode mode_;
|
| +
|
| // The data to build the screenshot region.
|
| gfx::Point start_position_;
|
| aura::Window* root_window_;
|
|
|
| - // Layers to create the visual effect of region selection.
|
| - std::map<aura::Window*, PartialScreenshotLayer*> layers_;
|
| + // Currently selected window in WINDOW mode.
|
| + aura::Window* selected_;
|
| +
|
| + // Layers to create the visual effect of region selection or selected window.
|
| + std::map<aura::Window*, ScreenshotLayer*> layers_;
|
|
|
| // The object to specify the crosshair cursor.
|
| std::unique_ptr<ScopedCursorSetter> cursor_setter_;
|
| @@ -80,9 +102,9 @@ class ASH_EXPORT PartialScreenshotController : public ui::EventHandler,
|
| // ScreenshotDelegate to take the actual screenshot. No ownership.
|
| ScreenshotDelegate* screenshot_delegate_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(PartialScreenshotController);
|
| + DISALLOW_COPY_AND_ASSIGN(ScreenshotController);
|
| };
|
|
|
| } // namespace ash
|
|
|
| -#endif // #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_
|
| +#endif // ASH_UTILITY_SCREENSHOT_CONTROLLER_H_
|
|
|