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 "ui/base/win/hwnd_util.h" | 5 #include "ui/base/win/hwnd_util.h" |
6 | 6 |
| 7 #include "base/i18n/rtl.h" |
7 #include "base/string_util.h" | 8 #include "base/string_util.h" |
8 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
9 #include "ui/gfx/size.h" | 10 #include "ui/gfx/size.h" |
10 | 11 |
11 namespace ui { | 12 namespace ui { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // Adjust the window to fit, returning true if the window was resized or moved. | 16 // Adjust the window to fit, returning true if the window was resized or moved. |
16 bool AdjustWindowToFit(HWND hwnd, const RECT& bounds) { | 17 bool AdjustWindowToFit(HWND hwnd, const RECT& bounds) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } else { | 168 } else { |
168 NOTREACHED() << "Unable to adjust window to fit"; | 169 NOTREACHED() << "Unable to adjust window to fit"; |
169 } | 170 } |
170 } | 171 } |
171 | 172 |
172 void CheckWindowCreated(HWND hwnd) { | 173 void CheckWindowCreated(HWND hwnd) { |
173 if (!hwnd) | 174 if (!hwnd) |
174 LOG_GETLASTERROR(FATAL); | 175 LOG_GETLASTERROR(FATAL); |
175 } | 176 } |
176 | 177 |
| 178 void ShowSystemMenu(HWND window, int screen_x, int screen_y) { |
| 179 UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD; |
| 180 if (base::i18n::IsRTL()) |
| 181 flags |= TPM_RIGHTALIGN; |
| 182 HMENU system_menu = GetSystemMenu(window, FALSE); |
| 183 int command = TrackPopupMenu(system_menu, flags, screen_x, screen_y, 0, |
| 184 window, NULL); |
| 185 if (command) |
| 186 SendMessage(window, WM_SYSCOMMAND, command, 0); |
| 187 } |
| 188 |
177 } // namespace ui | 189 } // namespace ui |
OLD | NEW |