| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "views/widget/widget_win.h" | 5 #include "views/widget/widget_win.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/path.h" | 8 #include "app/gfx/path.h" |
| 9 #include "app/l10n_util_win.h" | 9 #include "app/l10n_util_win.h" |
| 10 #include "app/win_util.h" | 10 #include "app/win_util.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 WidgetWin::WidgetWin() | 45 WidgetWin::WidgetWin() |
| 46 : close_widget_factory_(this), | 46 : close_widget_factory_(this), |
| 47 active_mouse_tracking_flags_(0), | 47 active_mouse_tracking_flags_(0), |
| 48 has_capture_(false), | 48 has_capture_(false), |
| 49 use_layered_buffer_(true), | 49 use_layered_buffer_(true), |
| 50 layered_alpha_(255), | 50 layered_alpha_(255), |
| 51 delete_on_destroy_(true), | 51 delete_on_destroy_(true), |
| 52 can_update_layered_window_(true), | 52 can_update_layered_window_(true), |
| 53 last_mouse_event_was_move_(false), | 53 last_mouse_event_was_move_(false), |
| 54 is_mouse_down_(false), | 54 is_mouse_down_(false), |
| 55 is_window_(false) { | 55 is_window_(false), |
| 56 restore_focus_when_enabled_(false) { |
| 56 } | 57 } |
| 57 | 58 |
| 58 WidgetWin::~WidgetWin() { | 59 WidgetWin::~WidgetWin() { |
| 59 MessageLoopForUI::current()->RemoveObserver(this); | 60 MessageLoopForUI::current()->RemoveObserver(this); |
| 60 } | 61 } |
| 61 | 62 |
| 62 /////////////////////////////////////////////////////////////////////////////// | 63 /////////////////////////////////////////////////////////////////////////////// |
| 63 // Widget implementation: | 64 // Widget implementation: |
| 64 | 65 |
| 65 void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) { | 66 void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) { |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 if (ProcessNativeControlMessage(message, w_param, l_param, &result)) | 920 if (ProcessNativeControlMessage(message, w_param, l_param, &result)) |
| 920 return result; | 921 return result; |
| 921 | 922 |
| 922 // Otherwise we handle everything else. | 923 // Otherwise we handle everything else. |
| 923 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) | 924 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) |
| 924 result = DefWindowProc(window, message, w_param, l_param); | 925 result = DefWindowProc(window, message, w_param, l_param); |
| 925 if (message == WM_NCDESTROY) | 926 if (message == WM_NCDESTROY) |
| 926 OnFinalMessage(window); | 927 OnFinalMessage(window); |
| 927 if (message == WM_ACTIVATE) | 928 if (message == WM_ACTIVATE) |
| 928 PostProcessActivateMessage(this, LOWORD(w_param)); | 929 PostProcessActivateMessage(this, LOWORD(w_param)); |
| 930 if (message == WM_ENABLE && restore_focus_when_enabled_) { |
| 931 restore_focus_when_enabled_ = false; |
| 932 focus_manager_->RestoreFocusedView(); |
| 933 } |
| 929 return result; | 934 return result; |
| 930 } | 935 } |
| 931 | 936 |
| 932 // static | 937 // static |
| 933 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, | 938 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, |
| 934 int activation_state) { | 939 int activation_state) { |
| 935 if (!widget->focus_manager_.get()) { | 940 if (!widget->focus_manager_.get()) { |
| 936 NOTREACHED(); | 941 NOTREACHED(); |
| 937 return; | 942 return; |
| 938 } | 943 } |
| 939 if (WA_INACTIVE == activation_state) { | 944 if (WA_INACTIVE == activation_state) { |
| 940 widget->focus_manager_->StoreFocusedView(); | 945 widget->focus_manager_->StoreFocusedView(); |
| 941 } else { | 946 } else { |
| 942 // We must restore the focus after the message has been DefProc'ed as it | 947 // We must restore the focus after the message has been DefProc'ed as it |
| 943 // does set the focus to the last focused HWND. | 948 // does set the focus to the last focused HWND. |
| 949 // Note that if the window is not enabled, we cannot restore the focus as |
| 950 // calling ::SetFocus on a child of the non-enabled top-window would fail. |
| 951 // This is the case when showing a modal dialog (such as 'open file', |
| 952 // 'print'...) from a different thread. |
| 953 // In that case we delay the focus restoration to when the window is enabled |
| 954 // again. |
| 955 if (!IsWindowEnabled(widget->GetNativeView())) { |
| 956 DCHECK(!widget->restore_focus_when_enabled_); |
| 957 widget->restore_focus_when_enabled_ = true; |
| 958 return; |
| 959 } |
| 944 widget->focus_manager_->RestoreFocusedView(); | 960 widget->focus_manager_->RestoreFocusedView(); |
| 945 } | 961 } |
| 946 } | 962 } |
| 947 | 963 |
| 948 //////////////////////////////////////////////////////////////////////////////// | 964 //////////////////////////////////////////////////////////////////////////////// |
| 949 // Widget, public: | 965 // Widget, public: |
| 950 | 966 |
| 951 // static | 967 // static |
| 952 Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { | 968 Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { |
| 953 WidgetWin* popup = new WidgetWin; | 969 WidgetWin* popup = new WidgetWin; |
| 954 popup->set_window_style(WS_POPUP); | 970 popup->set_window_style(WS_POPUP); |
| 955 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | | 971 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | |
| 956 WS_EX_TRANSPARENT | | 972 WS_EX_TRANSPARENT | |
| 957 l10n_util::GetExtendedTooltipStyles()); | 973 l10n_util::GetExtendedTooltipStyles()); |
| 958 popup->set_delete_on_destroy(delete_on_destroy); | 974 popup->set_delete_on_destroy(delete_on_destroy); |
| 959 return popup; | 975 return popup; |
| 960 } | 976 } |
| 961 | 977 |
| 962 } // namespace views | 978 } // namespace views |
| OLD | NEW |