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> |
11 #include <atlmisc.h> | 11 #include <atlmisc.h> |
12 | 12 |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
22 #include "base/win/scoped_comptr.h" | 22 #include "base/win/scoped_comptr.h" |
23 #include "base/win/win_util.h" | 23 #include "base/win/win_util.h" |
24 #include "ui/base/win/window_impl.h" | 24 #include "ui/base/win/window_impl.h" |
25 #include "ui/views/focus/focus_manager.h" | 25 #include "ui/views/focus/focus_manager.h" |
26 #include "ui/views/layout/layout_manager.h" | 26 #include "ui/views/layout/layout_manager.h" |
| 27 #include "ui/views/widget/hwnd_message_handler_delegate.h" |
27 #include "ui/views/widget/native_widget_private.h" | 28 #include "ui/views/widget/native_widget_private.h" |
28 | 29 |
29 namespace ui { | 30 namespace ui { |
30 class Compositor; | 31 class Compositor; |
31 class ViewProp; | 32 class ViewProp; |
32 } | 33 } |
33 | 34 |
34 namespace gfx { | 35 namespace gfx { |
35 class Canvas; | 36 class Canvas; |
36 class Font; | 37 class Font; |
37 class Rect; | 38 class Rect; |
38 } | 39 } |
39 | 40 |
40 namespace views { | 41 namespace views { |
41 | 42 |
42 class DropTargetWin; | 43 class DropTargetWin; |
| 44 class HWNDMessageHandler; |
43 class RootView; | 45 class RootView; |
44 class TooltipManagerWin; | 46 class TooltipManagerWin; |
45 | 47 |
46 // These two messages aren't defined in winuser.h, but they are sent to windows | 48 // These two messages aren't defined in winuser.h, but they are sent to windows |
47 // with captions. They appear to paint the window caption and frame. | 49 // with captions. They appear to paint the window caption and frame. |
48 // Unfortunately if you override the standard non-client rendering as we do | 50 // Unfortunately if you override the standard non-client rendering as we do |
49 // with CustomFrameWindow, sometimes Windows (not deterministically | 51 // with CustomFrameWindow, sometimes Windows (not deterministically |
50 // reproducibly but definitely frequently) will send these messages to the | 52 // reproducibly but definitely frequently) will send these messages to the |
51 // window and paint the standard caption/title over the top of the custom one. | 53 // window and paint the standard caption/title over the top of the custom one. |
52 // So we need to handle these messages in CustomFrameWindow to prevent this | 54 // So we need to handle these messages in CustomFrameWindow to prevent this |
53 // from happening. | 55 // from happening. |
54 const int WM_NCUAHDRAWCAPTION = 0xAE; | 56 const int WM_NCUAHDRAWCAPTION = 0xAE; |
55 const int WM_NCUAHDRAWFRAME = 0xAF; | 57 const int WM_NCUAHDRAWFRAME = 0xAF; |
56 | 58 |
57 /////////////////////////////////////////////////////////////////////////////// | 59 /////////////////////////////////////////////////////////////////////////////// |
58 // | 60 // |
59 // NativeWidgetWin | 61 // NativeWidgetWin |
60 // A Widget for a views hierarchy used to represent anything that can be | 62 // A Widget for a views hierarchy used to represent anything that can be |
61 // contained within an HWND, e.g. a control, a window, etc. Specializations | 63 // contained within an HWND, e.g. a control, a window, etc. Specializations |
62 // suitable for specific tasks, e.g. top level window, are derived from this. | 64 // suitable for specific tasks, e.g. top level window, are derived from this. |
63 // | 65 // |
64 // This Widget contains a RootView which owns the hierarchy of views within it. | 66 // This Widget contains a RootView which owns the hierarchy of views within it. |
65 // As long as views are part of this tree, they will be deleted automatically | 67 // As long as views are part of this tree, they will be deleted automatically |
66 // when the RootView is destroyed. If you remove a view from the tree, you are | 68 // when the RootView is destroyed. If you remove a view from the tree, you are |
67 // then responsible for cleaning up after it. | 69 // then responsible for cleaning up after it. |
68 // | 70 // |
69 /////////////////////////////////////////////////////////////////////////////// | 71 /////////////////////////////////////////////////////////////////////////////// |
70 class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, | 72 class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, |
71 public MessageLoopForUI::Observer, | 73 public MessageLoopForUI::Observer, |
72 public internal::NativeWidgetPrivate { | 74 public internal::NativeWidgetPrivate, |
| 75 public HWNDMessageHandlerDelegate { |
73 public: | 76 public: |
74 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); | 77 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); |
75 virtual ~NativeWidgetWin(); | 78 virtual ~NativeWidgetWin(); |
76 | 79 |
77 // Returns true if we are on Windows Vista or greater and composition is | 80 // Returns true if we are on Windows Vista or greater and composition is |
78 // enabled. | 81 // enabled. |
79 static bool IsAeroGlassEnabled(); | 82 static bool IsAeroGlassEnabled(); |
80 | 83 |
81 // Returns the system set window title font. | 84 // Returns the system set window title font. |
82 static gfx::Font GetWindowTitleFont(); | 85 static gfx::Font GetWindowTitleFont(); |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 const gfx::Rect& invalid_rect() const { return invalid_rect_; } | 479 const gfx::Rect& invalid_rect() const { return invalid_rect_; } |
477 | 480 |
478 // Saved window information from before entering fullscreen mode. | 481 // Saved window information from before entering fullscreen mode. |
479 // TODO(beng): move to private once GetRestoredBounds() moves onto Widget. | 482 // TODO(beng): move to private once GetRestoredBounds() moves onto Widget. |
480 SavedWindowInfo saved_window_info_; | 483 SavedWindowInfo saved_window_info_; |
481 | 484 |
482 private: | 485 private: |
483 typedef ScopedVector<ui::ViewProp> ViewProps; | 486 typedef ScopedVector<ui::ViewProp> ViewProps; |
484 typedef std::set<DWORD> TouchIDs; | 487 typedef std::set<DWORD> TouchIDs; |
485 | 488 |
| 489 // TODO(beng): This friendship can be removed once all methods relating to |
| 490 // this object being a WindowImpl are moved to HWNDMessageHandler. |
| 491 friend HWNDMessageHandler; |
| 492 |
| 493 // Overridden from HWNDMessageHandlerDelegate: |
| 494 virtual bool IsWidgetWindow() const OVERRIDE; |
| 495 virtual bool IsUsingCustomFrame() const OVERRIDE; |
| 496 virtual void HandleAppDeactivated() OVERRIDE; |
| 497 virtual bool HandleAppCommand(short command) OVERRIDE; |
| 498 virtual void HandleCaptureLost() OVERRIDE; |
| 499 virtual void HandleClose() OVERRIDE; |
| 500 virtual bool HandleCommand(int command) OVERRIDE; |
| 501 virtual void HandleDestroy() OVERRIDE; |
| 502 virtual void HandleDisplayChange() OVERRIDE; |
| 503 virtual void HandleGlassModeChange() OVERRIDE; |
| 504 virtual void HandleBeginWMSizeMove() OVERRIDE; |
| 505 virtual void HandleEndWMSizeMove() OVERRIDE; |
| 506 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; |
| 507 |
486 // Called after the WM_ACTIVATE message has been processed by the default | 508 // Called after the WM_ACTIVATE message has been processed by the default |
487 // windows procedure. | 509 // windows procedure. |
488 static void PostProcessActivateMessage(NativeWidgetWin* widget, | 510 static void PostProcessActivateMessage(NativeWidgetWin* widget, |
489 int activation_state); | 511 int activation_state); |
490 | 512 |
491 void SetInitParams(const Widget::InitParams& params); | 513 void SetInitParams(const Widget::InitParams& params); |
492 | 514 |
493 // Synchronously paints the invalid contents of the Widget. | 515 // Synchronously paints the invalid contents of the Widget. |
494 void RedrawInvalidRect(); | 516 void RedrawInvalidRect(); |
495 | 517 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // This flag can be initialized and checked after certain operations (such as | 692 // This flag can be initialized and checked after certain operations (such as |
671 // DefWindowProc) to avoid stack-controlled NativeWidgetWin operations (such | 693 // DefWindowProc) to avoid stack-controlled NativeWidgetWin operations (such |
672 // as unlocking the Window with a ScopedRedrawLock) after Widget destruction. | 694 // as unlocking the Window with a ScopedRedrawLock) after Widget destruction. |
673 bool* destroyed_; | 695 bool* destroyed_; |
674 | 696 |
675 // True if the widget is going to have a non_client_view. We cache this value | 697 // True if the widget is going to have a non_client_view. We cache this value |
676 // rather than asking the Widget for the non_client_view so that we know at | 698 // rather than asking the Widget for the non_client_view so that we know at |
677 // Init time, before the Widget has created the NonClientView. | 699 // Init time, before the Widget has created the NonClientView. |
678 bool has_non_client_view_; | 700 bool has_non_client_view_; |
679 | 701 |
680 bool remove_standard_frame_; | |
681 | |
682 // The set of touch devices currently down. | 702 // The set of touch devices currently down. |
683 TouchIDs touch_ids_; | 703 TouchIDs touch_ids_; |
684 | 704 |
| 705 scoped_ptr<HWNDMessageHandler> message_handler_; |
| 706 |
685 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); | 707 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); |
686 }; | 708 }; |
687 | 709 |
688 } // namespace views | 710 } // namespace views |
689 | 711 |
690 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 712 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
OLD | NEW |