| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 5 #ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
| 6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
| 7 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlapp.h> | 9 #include <atlapp.h> |
| 10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace gfx { | 35 namespace gfx { |
| 36 class Canvas; | 36 class Canvas; |
| 37 class Font; | 37 class Font; |
| 38 class Rect; | 38 class Rect; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace views { | 41 namespace views { |
| 42 | 42 |
| 43 class DropTargetWin; | 43 class DropTargetWin; |
| 44 class FullscreenHandler; |
| 44 class HWNDMessageHandler; | 45 class HWNDMessageHandler; |
| 45 class InputMethodDelegate; | 46 class InputMethodDelegate; |
| 46 class RootView; | 47 class RootView; |
| 47 class TooltipManagerWin; | 48 class TooltipManagerWin; |
| 48 | 49 |
| 49 // These two messages aren't defined in winuser.h, but they are sent to windows | 50 // These two messages aren't defined in winuser.h, but they are sent to windows |
| 50 // with captions. They appear to paint the window caption and frame. | 51 // with captions. They appear to paint the window caption and frame. |
| 51 // Unfortunately if you override the standard non-client rendering as we do | 52 // Unfortunately if you override the standard non-client rendering as we do |
| 52 // with CustomFrameWindow, sometimes Windows (not deterministically | 53 // with CustomFrameWindow, sometimes Windows (not deterministically |
| 53 // reproducibly but definitely frequently) will send these messages to the | 54 // reproducibly but definitely frequently) will send these messages to the |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Add a view that has recently fired an accessibility event. Returns a MSAA | 99 // Add a view that has recently fired an accessibility event. Returns a MSAA |
| 99 // child id which is generated by: -(index of view in vector + 1) which | 100 // child id which is generated by: -(index of view in vector + 1) which |
| 100 // guarantees a negative child id. This distinguishes the view from | 101 // guarantees a negative child id. This distinguishes the view from |
| 101 // positive MSAA child id's which are direct leaf children of views that have | 102 // positive MSAA child id's which are direct leaf children of views that have |
| 102 // associated hWnd's (e.g. NativeWidgetWin). | 103 // associated hWnd's (e.g. NativeWidgetWin). |
| 103 int AddAccessibilityViewEvent(View* view); | 104 int AddAccessibilityViewEvent(View* view); |
| 104 | 105 |
| 105 // Clear a view that has recently been removed on a hierarchy change. | 106 // Clear a view that has recently been removed on a hierarchy change. |
| 106 void ClearAccessibilityViewEvent(View* view); | 107 void ClearAccessibilityViewEvent(View* view); |
| 107 | 108 |
| 108 // Hides the window if it hasn't already been force-hidden. The force hidden | |
| 109 // count is tracked, so calling multiple times is allowed, you just have to | |
| 110 // be sure to call PopForceHidden the same number of times. | |
| 111 void PushForceHidden(); | |
| 112 | |
| 113 // Decrements the force hidden count, showing the window if we have reached | |
| 114 // the top of the stack. See PushForceHidden. | |
| 115 void PopForceHidden(); | |
| 116 | |
| 117 // Places the window in a pseudo-fullscreen mode where it looks and acts as | 109 // Places the window in a pseudo-fullscreen mode where it looks and acts as |
| 118 // like a fullscreen window except that it remains within the boundaries | 110 // like a fullscreen window except that it remains within the boundaries |
| 119 // of the metro snap divider. | 111 // of the metro snap divider. |
| 120 void SetMetroSnapFullscreen(bool metro_snap); | 112 void SetMetroSnapFullscreen(bool metro_snap); |
| 121 | 113 |
| 122 bool IsInMetroSnapMode() const; | 114 bool IsInMetroSnapMode() const; |
| 123 | 115 |
| 124 BOOL IsWindow() const { | 116 BOOL IsWindow() const { |
| 125 return ::IsWindow(GetNativeView()); | 117 return ::IsWindow(GetNativeView()); |
| 126 } | 118 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 virtual void ClearNativeFocus() OVERRIDE; | 250 virtual void ClearNativeFocus() OVERRIDE; |
| 259 virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; | 251 virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; |
| 260 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; | 252 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; |
| 261 virtual void SetInactiveRenderingDisabled(bool value) OVERRIDE; | 253 virtual void SetInactiveRenderingDisabled(bool value) OVERRIDE; |
| 262 virtual Widget::MoveLoopResult RunMoveLoop( | 254 virtual Widget::MoveLoopResult RunMoveLoop( |
| 263 const gfx::Point& drag_offset) OVERRIDE; | 255 const gfx::Point& drag_offset) OVERRIDE; |
| 264 virtual void EndMoveLoop() OVERRIDE; | 256 virtual void EndMoveLoop() OVERRIDE; |
| 265 virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; | 257 virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; |
| 266 | 258 |
| 267 protected: | 259 protected: |
| 268 // Information saved before going into fullscreen mode, used to restore the | |
| 269 // window afterwards. | |
| 270 struct SavedWindowInfo { | |
| 271 bool maximized; | |
| 272 LONG style; | |
| 273 LONG ex_style; | |
| 274 RECT window_rect; | |
| 275 }; | |
| 276 | |
| 277 // Overridden from MessageLoop::Observer: | 260 // Overridden from MessageLoop::Observer: |
| 278 virtual base::EventStatus WillProcessEvent( | 261 virtual base::EventStatus WillProcessEvent( |
| 279 const base::NativeEvent& event) OVERRIDE; | 262 const base::NativeEvent& event) OVERRIDE; |
| 280 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; | 263 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; |
| 281 | 264 |
| 282 // Overridden from WindowImpl: | 265 // Overridden from WindowImpl: |
| 283 virtual HICON GetDefaultWindowIcon() const OVERRIDE; | 266 virtual HICON GetDefaultWindowIcon() const OVERRIDE; |
| 284 virtual LRESULT OnWndProc(UINT message, | 267 virtual LRESULT OnWndProc(UINT message, |
| 285 WPARAM w_param, | 268 WPARAM w_param, |
| 286 LPARAM l_param) OVERRIDE; | 269 LPARAM l_param) OVERRIDE; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 // The TooltipManager. This is NULL if there is a problem creating the | 449 // The TooltipManager. This is NULL if there is a problem creating the |
| 467 // underlying tooltip window. | 450 // underlying tooltip window. |
| 468 // WARNING: RootView's destructor calls into the TooltipManager. As such, this | 451 // WARNING: RootView's destructor calls into the TooltipManager. As such, this |
| 469 // must be destroyed AFTER root_view_. | 452 // must be destroyed AFTER root_view_. |
| 470 scoped_ptr<TooltipManagerWin> tooltip_manager_; | 453 scoped_ptr<TooltipManagerWin> tooltip_manager_; |
| 471 | 454 |
| 472 scoped_refptr<DropTargetWin> drop_target_; | 455 scoped_refptr<DropTargetWin> drop_target_; |
| 473 | 456 |
| 474 const gfx::Rect& invalid_rect() const { return invalid_rect_; } | 457 const gfx::Rect& invalid_rect() const { return invalid_rect_; } |
| 475 | 458 |
| 476 // Saved window information from before entering fullscreen mode. | |
| 477 // TODO(beng): move to private once GetRestoredBounds() moves onto Widget. | |
| 478 SavedWindowInfo saved_window_info_; | |
| 479 | |
| 480 private: | 459 private: |
| 481 typedef ScopedVector<ui::ViewProp> ViewProps; | 460 typedef ScopedVector<ui::ViewProp> ViewProps; |
| 482 | 461 |
| 483 // TODO(beng): This friendship can be removed once all methods relating to | 462 // TODO(beng): This friendship can be removed once all methods relating to |
| 484 // this object being a WindowImpl are moved to HWNDMessageHandler. | 463 // this object being a WindowImpl are moved to HWNDMessageHandler. |
| 485 friend HWNDMessageHandler; | 464 friend HWNDMessageHandler; |
| 486 | 465 |
| 487 // Overridden from HWNDMessageHandlerDelegate: | 466 // Overridden from HWNDMessageHandlerDelegate: |
| 488 virtual bool IsWidgetWindow() const OVERRIDE; | 467 virtual bool IsWidgetWindow() const OVERRIDE; |
| 489 virtual bool IsUsingCustomFrame() const OVERRIDE; | 468 virtual bool IsUsingCustomFrame() const OVERRIDE; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 // Stops ignoring SetWindowPos() requests (see below). | 528 // Stops ignoring SetWindowPos() requests (see below). |
| 550 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; } | 529 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; } |
| 551 | 530 |
| 552 void RestoreEnabledIfNecessary(); | 531 void RestoreEnabledIfNecessary(); |
| 553 | 532 |
| 554 void SetInitialFocus(); | 533 void SetInitialFocus(); |
| 555 | 534 |
| 556 // Notifies any owned windows that we're closing. | 535 // Notifies any owned windows that we're closing. |
| 557 void NotifyOwnedWindowsParentClosing(); | 536 void NotifyOwnedWindowsParentClosing(); |
| 558 | 537 |
| 559 // Common implementation of fullscreen-related code. This method handles | |
| 560 // changing from windowed mode to a display mode (dubbed fullscreen mode) | |
| 561 // where the window occupies a fixed portion (possibly 100%) of the screen. | |
| 562 // |fullscreen| specifies whether we are entering or leaving fullscreen mode. | |
| 563 // |for_metro| specifies whether we are doing this at the behest of a metro | |
| 564 // snap transition. | |
| 565 void SetFullscreenInternal(bool fullscreen, bool for_metro); | |
| 566 | |
| 567 // A delegate implementation that handles events received here. | 538 // A delegate implementation that handles events received here. |
| 568 // See class documentation for Widget in widget.h for a note about ownership. | 539 // See class documentation for Widget in widget.h for a note about ownership. |
| 569 internal::NativeWidgetDelegate* delegate_; | 540 internal::NativeWidgetDelegate* delegate_; |
| 570 | 541 |
| 571 // The following factory is used for calls to close the NativeWidgetWin | 542 // The following factory is used for calls to close the NativeWidgetWin |
| 572 // instance. | 543 // instance. |
| 573 base::WeakPtrFactory<NativeWidgetWin> close_widget_factory_; | 544 base::WeakPtrFactory<NativeWidgetWin> close_widget_factory_; |
| 574 | 545 |
| 575 // Should we keep an off-screen buffer? This is false by default, set to true | 546 // Should we keep an off-screen buffer? This is false by default, set to true |
| 576 // when WS_EX_LAYERED is specified before the native window is created. | 547 // when WS_EX_LAYERED is specified before the native window is created. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // The current position of the view events vector. When incrementing, | 601 // The current position of the view events vector. When incrementing, |
| 631 // we always mod this value with the max view events above . | 602 // we always mod this value with the max view events above . |
| 632 int accessibility_view_events_index_; | 603 int accessibility_view_events_index_; |
| 633 | 604 |
| 634 // The last cursor that was active before the current one was selected. Saved | 605 // The last cursor that was active before the current one was selected. Saved |
| 635 // so that we can restore it. | 606 // so that we can restore it. |
| 636 gfx::NativeCursor previous_cursor_; | 607 gfx::NativeCursor previous_cursor_; |
| 637 | 608 |
| 638 ViewProps props_; | 609 ViewProps props_; |
| 639 | 610 |
| 640 // True if we're in fullscreen mode. | |
| 641 bool fullscreen_; | |
| 642 | |
| 643 // True if we're in metro snap mode. | |
| 644 bool metro_snap_; | |
| 645 | |
| 646 // If this is greater than zero, we should prevent attempts to make the window | |
| 647 // visible when we handle WM_WINDOWPOSCHANGING. Some calls like | |
| 648 // ShowWindow(SW_RESTORE) make the window visible in addition to restoring it, | |
| 649 // when all we want to do is restore it. | |
| 650 int force_hidden_count_; | |
| 651 | |
| 652 // The window styles before we modified them for the drag frame appearance. | 611 // The window styles before we modified them for the drag frame appearance. |
| 653 DWORD drag_frame_saved_window_style_; | 612 DWORD drag_frame_saved_window_style_; |
| 654 DWORD drag_frame_saved_window_ex_style_; | 613 DWORD drag_frame_saved_window_ex_style_; |
| 655 | 614 |
| 656 // When true, this flag makes us discard incoming SetWindowPos() requests that | 615 // When true, this flag makes us discard incoming SetWindowPos() requests that |
| 657 // only change our position/size. (We still allow changes to Z-order, | 616 // only change our position/size. (We still allow changes to Z-order, |
| 658 // activation, etc.) | 617 // activation, etc.) |
| 659 bool ignore_window_pos_changes_; | 618 bool ignore_window_pos_changes_; |
| 660 | 619 |
| 661 // The following factory is used to ignore SetWindowPos() calls for short time | 620 // The following factory is used to ignore SetWindowPos() calls for short time |
| 662 // periods. | 621 // periods. |
| 663 base::WeakPtrFactory<NativeWidgetWin> ignore_pos_changes_factory_; | 622 base::WeakPtrFactory<NativeWidgetWin> ignore_pos_changes_factory_; |
| 664 | 623 |
| 665 // The last-seen monitor containing us, and its rect and work area. These are | 624 // The last-seen monitor containing us, and its rect and work area. These are |
| 666 // used to catch updates to the rect and work area and react accordingly. | 625 // used to catch updates to the rect and work area and react accordingly. |
| 667 HMONITOR last_monitor_; | 626 HMONITOR last_monitor_; |
| 668 gfx::Rect last_monitor_rect_, last_work_area_; | 627 gfx::Rect last_monitor_rect_, last_work_area_; |
| 669 | 628 |
| 670 // Whether all ancestors have been enabled. This is only used if is_modal_ is | 629 // Whether all ancestors have been enabled. This is only used if is_modal_ is |
| 671 // true. | 630 // true. |
| 672 bool restored_enabled_; | 631 bool restored_enabled_; |
| 673 | 632 |
| 674 // True if the widget is going to have a non_client_view. We cache this value | 633 // True if the widget is going to have a non_client_view. We cache this value |
| 675 // rather than asking the Widget for the non_client_view so that we know at | 634 // rather than asking the Widget for the non_client_view so that we know at |
| 676 // Init time, before the Widget has created the NonClientView. | 635 // Init time, before the Widget has created the NonClientView. |
| 677 bool has_non_client_view_; | 636 bool has_non_client_view_; |
| 678 | 637 |
| 679 scoped_ptr<HWNDMessageHandler> message_handler_; | 638 scoped_ptr<HWNDMessageHandler> message_handler_; |
| 639 scoped_ptr<FullscreenHandler> fullscreen_handler_; |
| 680 | 640 |
| 681 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); | 641 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); |
| 682 }; | 642 }; |
| 683 | 643 |
| 684 } // namespace views | 644 } // namespace views |
| 685 | 645 |
| 686 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 646 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
| OLD | NEW |