#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_NATIVE_WIDGET_AURA_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_NATIVE_WIDGET_AURA_H_
#include "base/memory/weak_ptr.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_tree_host_observer.h"
#include "ui/base/cursor/cursor.h"
#include "ui/views/ime/input_method_delegate.h"
#include "ui/views/widget/native_widget_private.h"
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/public/activation_change_observer.h"
#include "ui/wm/public/activation_delegate.h"
#include "ui/wm/public/drag_drop_delegate.h"
namespace aura {
class WindowEventDispatcher;
class WindowTreeHost;
namespace client {
class DragDropClient;
class FocusClient;
class ScreenPositionClient;
class WindowTreeClient;
}
}
namespace wm {
class CompoundEventFilter;
class CursorManager;
class FocusController;
class InputMethodEventFilter;
class ShadowController;
class VisibilityController;
class WindowModalityController;
}
namespace views {
namespace corewm {
class TooltipController;
}
class DesktopCaptureClient;
class DesktopDispatcherClient;
class DesktopEventClient;
class DesktopNativeCursorManager;
class DesktopWindowTreeHost;
class DropHelper;
class FocusManagerEventHandler;
class TooltipManagerAura;
class WindowReorderer;
class VIEWS_EXPORT DesktopNativeWidgetAura
: public internal::NativeWidgetPrivate,
public aura::WindowDelegate,
public aura::client::ActivationDelegate,
public aura::client::ActivationChangeObserver,
public aura::client::FocusChangeObserver,
public views::internal::InputMethodDelegate,
public aura::client::DragDropDelegate,
public aura::WindowTreeHostObserver {
public:
explicit DesktopNativeWidgetAura(internal::NativeWidgetDelegate* delegate);
virtual ~DesktopNativeWidgetAura();
static DesktopNativeWidgetAura* ForWindow(aura::Window* window);
virtual void OnHostClosed();
virtual void OnDesktopWindowTreeHostDestroyed(aura::WindowTreeHost* host);
wm::InputMethodEventFilter* input_method_event_filter() {
return input_method_event_filter_.get();
}
wm::CompoundEventFilter* root_window_event_filter() {
return root_window_event_filter_;
}
aura::WindowTreeHost* host() {
return host_.get();
}
virtual ui::EventHandler* GetEventHandler() OVERRIDE;
void HandleActivationChanged(bool active);
protected:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
virtual bool ShouldUseNativeFrame() const OVERRIDE;
virtual bool ShouldWindowContentsBeTransparent() const OVERRIDE;
virtual void FrameTypeChanged() OVERRIDE;
virtual Widget* GetWidget() OVERRIDE;
virtual const Widget* GetWidget() const OVERRIDE;
virtual gfx::NativeView GetNativeView() const OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
virtual Widget* GetTopLevelWidget() OVERRIDE;
virtual const ui::Compositor* GetCompositor() const OVERRIDE;
virtual ui::Compositor* GetCompositor() OVERRIDE;
virtual ui::Layer* GetLayer() OVERRIDE;
virtual void ReorderNativeViews() OVERRIDE;
virtual void ViewRemoved(View* view) OVERRIDE;
virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE;
virtual TooltipManager* GetTooltipManager() const OVERRIDE;
virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE;
virtual bool HasCapture() const OVERRIDE;
virtual InputMethod* CreateInputMethod() OVERRIDE;
virtual internal::InputMethodDelegate* GetInputMethodDelegate() OVERRIDE;
virtual void CenterWindow(const gfx::Size& size) OVERRIDE;
virtual void GetWindowPlacement(
gfx::Rect* bounds,
ui::WindowShowState* maximized) const OVERRIDE;
virtual bool SetWindowTitle(const base::string16& title) OVERRIDE;
virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) OVERRIDE;
virtual void InitModalType(ui::ModalType modal_type) OVERRIDE;
virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE;
virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE;
virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual void StackAbove(gfx::NativeView native_view) OVERRIDE;
virtual void StackAtTop() OVERRIDE;
virtual void StackBelow(gfx::NativeView native_view) OVERRIDE;
virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void CloseNow() OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
virtual void ShowMaximizedWithBounds(
const gfx::Rect& restored_bounds) OVERRIDE;
virtual void ShowWithWindowState(ui::WindowShowState state) OVERRIDE;
virtual bool IsVisible() const OVERRIDE;
virtual void Activate() OVERRIDE;
virtual void Deactivate() OVERRIDE;
virtual bool IsActive() const OVERRIDE;
virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
virtual bool IsAlwaysOnTop() const OVERRIDE;
virtual void SetVisibleOnAllWorkspaces(bool always_visible) OVERRIDE;
virtual void Maximize() OVERRIDE;
virtual void Minimize() OVERRIDE;
virtual bool IsMaximized() const OVERRIDE;
virtual bool IsMinimized() const OVERRIDE;
virtual void Restore() OVERRIDE;
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
virtual void SetOpacity(unsigned char opacity) OVERRIDE;
virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
virtual void FlashFrame(bool flash_frame) OVERRIDE;
virtual void RunShellDrag(View* view,
const ui::OSExchangeData& data,
const gfx::Point& location,
int operation,
ui::DragDropTypes::DragEventSource source) OVERRIDE;
virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
virtual bool IsMouseEventsEnabled() const OVERRIDE;
virtual void ClearNativeFocus() OVERRIDE;
virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE;
virtual Widget::MoveLoopResult RunMoveLoop(
const gfx::Vector2d& drag_offset,
Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) OVERRIDE;
virtual void EndMoveLoop() OVERRIDE;
virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
virtual void OnRootViewLayout() const OVERRIDE;
virtual gfx::Size GetMinimumSize() const OVERRIDE;
virtual gfx::Size GetMaximumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE {}
virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool ShouldDescendIntoChildForEventHandling(
aura::Window* child,
const gfx::Point& location) OVERRIDE;
virtual bool CanFocus() OVERRIDE;
virtual void OnCaptureLost() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
virtual bool HasHitTestMask() const OVERRIDE;
virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual bool ShouldActivate() const OVERRIDE;
virtual void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) OVERRIDE;
virtual void OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) OVERRIDE;
virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE;
virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
virtual void OnDragExited() OVERRIDE;
virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE;
virtual void OnHostResized(const aura::WindowTreeHost* host) OVERRIDE;
virtual void OnHostMoved(const aura::WindowTreeHost* host,
const gfx::Point& new_origin) OVERRIDE;
private:
friend class FocusManagerEventHandler;
friend class RootWindowDestructionObserver;
void InstallInputMethodEventFilter();
void UpdateWindowTransparency();
void RootWindowDestroyed();
scoped_ptr<aura::WindowTreeHost> host_;
DesktopWindowTreeHost* desktop_window_tree_host_;
Widget::InitParams::Ownership ownership_;
scoped_ptr<DesktopCaptureClient> capture_client_;
base::WeakPtrFactory<DesktopNativeWidgetAura> close_widget_factory_;
bool can_activate_;
aura::Window* content_window_container_;
aura::Window* content_window_;
internal::NativeWidgetDelegate* native_widget_delegate_;
scoped_ptr<wm::FocusController> focus_client_;
scoped_ptr<DesktopDispatcherClient> dispatcher_client_;
scoped_ptr<aura::client::ScreenPositionClient> position_client_;
scoped_ptr<aura::client::DragDropClient> drag_drop_client_;
scoped_ptr<aura::client::WindowTreeClient> window_tree_client_;
scoped_ptr<DesktopEventClient> event_client_;
scoped_ptr<FocusManagerEventHandler> focus_manager_event_handler_;
wm::CompoundEventFilter* root_window_event_filter_;
scoped_ptr<wm::InputMethodEventFilter> input_method_event_filter_;
scoped_ptr<DropHelper> drop_helper_;
int last_drop_operation_;
scoped_ptr<corewm::TooltipController> tooltip_controller_;
scoped_ptr<TooltipManagerAura> tooltip_manager_;
scoped_ptr<wm::VisibilityController> visibility_controller_;
scoped_ptr<wm::WindowModalityController>
window_modality_controller_;
bool restore_focus_on_activate_;
gfx::NativeCursor cursor_;
static int cursor_reference_count_;
static wm::CursorManager* cursor_manager_;
static views::DesktopNativeCursorManager* native_cursor_manager_;
scoped_ptr<wm::ShadowController> shadow_controller_;
scoped_ptr<WindowReorderer> window_reorderer_;
Widget::InitParams::Type widget_type_;
DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAura);
};
}
#endif