| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/native_widget_win.h" | 5 #include "views/widget/native_widget_win.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 Show(native_show_state); | 927 Show(native_show_state); |
| 928 } | 928 } |
| 929 | 929 |
| 930 bool NativeWidgetWin::IsVisible() const { | 930 bool NativeWidgetWin::IsVisible() const { |
| 931 return !!::IsWindowVisible(hwnd()); | 931 return !!::IsWindowVisible(hwnd()); |
| 932 } | 932 } |
| 933 | 933 |
| 934 void NativeWidgetWin::Activate() { | 934 void NativeWidgetWin::Activate() { |
| 935 if (IsMinimized()) | 935 if (IsMinimized()) |
| 936 ::ShowWindow(GetNativeView(), SW_RESTORE); | 936 ::ShowWindow(GetNativeView(), SW_RESTORE); |
| 937 else if (!IsVisible()) |
| 938 Show(); |
| 937 ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0, | 939 ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0, |
| 938 SWP_NOSIZE | SWP_NOMOVE); | 940 SWP_NOSIZE | SWP_NOMOVE); |
| 939 SetForegroundWindow(GetNativeView()); | 941 SetForegroundWindow(GetNativeView()); |
| 940 } | 942 } |
| 941 | 943 |
| 942 void NativeWidgetWin::Deactivate() { | 944 void NativeWidgetWin::Deactivate() { |
| 943 HWND hwnd = ::GetNextWindow(GetNativeView(), GW_HWNDNEXT); | 945 HWND hwnd = ::GetNextWindow(GetNativeView(), GW_HWNDNEXT); |
| 944 if (hwnd) | 946 if (hwnd) |
| 945 ::SetForegroundWindow(hwnd); | 947 ::SetForegroundWindow(hwnd); |
| 946 } | 948 } |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) { | 2232 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) { |
| 2231 // Set non-style attributes. | 2233 // Set non-style attributes. |
| 2232 ownership_ = params.ownership; | 2234 ownership_ = params.ownership; |
| 2233 | 2235 |
| 2234 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS; | 2236 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
| 2235 DWORD ex_style = 0; | 2237 DWORD ex_style = 0; |
| 2236 DWORD class_style = CS_DBLCLKS; | 2238 DWORD class_style = CS_DBLCLKS; |
| 2237 | 2239 |
| 2238 // Set type-independent style attributes. | 2240 // Set type-independent style attributes. |
| 2239 if (params.child) | 2241 if (params.child) |
| 2240 style |= WS_CHILD | WS_VISIBLE; | 2242 style |= WS_CHILD; |
| 2241 if (params.show_state == ui::SHOW_STATE_MAXIMIZED) | 2243 if (params.show_state == ui::SHOW_STATE_MAXIMIZED) |
| 2242 style |= WS_MAXIMIZE; | 2244 style |= WS_MAXIMIZE; |
| 2243 if (params.show_state == ui::SHOW_STATE_MINIMIZED) | 2245 if (params.show_state == ui::SHOW_STATE_MINIMIZED) |
| 2244 style |= WS_MINIMIZE; | 2246 style |= WS_MINIMIZE; |
| 2245 if (!params.accept_events) | 2247 if (!params.accept_events) |
| 2246 ex_style |= WS_EX_TRANSPARENT; | 2248 ex_style |= WS_EX_TRANSPARENT; |
| 2247 if (!params.can_activate) | 2249 if (!params.can_activate) |
| 2248 ex_style |= WS_EX_NOACTIVATE; | 2250 ex_style |= WS_EX_NOACTIVATE; |
| 2249 if (params.keep_on_top) | 2251 if (params.keep_on_top) |
| 2250 ex_style |= WS_EX_TOPMOST; | 2252 ex_style |= WS_EX_TOPMOST; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2273 // NOTE: Turning this off means we lose the close button, which is bad. | 2275 // NOTE: Turning this off means we lose the close button, which is bad. |
| 2274 // Turning it on though means the user can maximize or size the window | 2276 // Turning it on though means the user can maximize or size the window |
| 2275 // from the system menu, which is worse. We may need to provide our own | 2277 // from the system menu, which is worse. We may need to provide our own |
| 2276 // menu to get the close button to appear properly. | 2278 // menu to get the close button to appear properly. |
| 2277 // style &= ~WS_SYSMENU; | 2279 // style &= ~WS_SYSMENU; |
| 2278 } | 2280 } |
| 2279 ex_style |= delegate_->IsDialogBox() ? WS_EX_DLGMODALFRAME : 0; | 2281 ex_style |= delegate_->IsDialogBox() ? WS_EX_DLGMODALFRAME : 0; |
| 2280 break; | 2282 break; |
| 2281 } | 2283 } |
| 2282 case Widget::InitParams::TYPE_CONTROL: | 2284 case Widget::InitParams::TYPE_CONTROL: |
| 2285 style |= WS_VISIBLE; |
| 2283 break; | 2286 break; |
| 2284 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: | 2287 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: |
| 2285 style |= WS_POPUP; | 2288 style |= WS_POPUP; |
| 2286 break; | 2289 break; |
| 2287 case Widget::InitParams::TYPE_BUBBLE: | 2290 case Widget::InitParams::TYPE_BUBBLE: |
| 2288 style |= WS_POPUP; | 2291 style |= WS_POPUP; |
| 2289 style |= WS_CLIPCHILDREN; | 2292 style |= WS_CLIPCHILDREN; |
| 2290 break; | 2293 break; |
| 2291 case Widget::InitParams::TYPE_POPUP: | 2294 case Widget::InitParams::TYPE_POPUP: |
| 2292 style |= WS_POPUP; | 2295 style |= WS_POPUP; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2625 return (GetKeyState(VK_LBUTTON) & 0x80) || | 2628 return (GetKeyState(VK_LBUTTON) & 0x80) || |
| 2626 (GetKeyState(VK_RBUTTON) & 0x80) || | 2629 (GetKeyState(VK_RBUTTON) & 0x80) || |
| 2627 (GetKeyState(VK_MBUTTON) & 0x80) || | 2630 (GetKeyState(VK_MBUTTON) & 0x80) || |
| 2628 (GetKeyState(VK_XBUTTON1) & 0x80) || | 2631 (GetKeyState(VK_XBUTTON1) & 0x80) || |
| 2629 (GetKeyState(VK_XBUTTON2) & 0x80); | 2632 (GetKeyState(VK_XBUTTON2) & 0x80); |
| 2630 } | 2633 } |
| 2631 | 2634 |
| 2632 } // namespace internal | 2635 } // namespace internal |
| 2633 | 2636 |
| 2634 } // namespace views | 2637 } // namespace views |
| OLD | NEW |