Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: ui/views/win/hwnd_message_handler.cc

Issue 2645253002: DesktopAura: Track windows "owned" via the DesktopWindowTreeHost (Closed)
Patch Set: Rejig so we can use kDesktopNativeWidgetAuraKey Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ui/views/win/hwnd_message_handler.h" 5 #include "ui/views/win/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <oleacc.h> 8 #include <oleacc.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <tchar.h> 10 #include <tchar.h>
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 MONITORINFO monitor_info = { 0 }; 188 MONITORINFO monitor_info = { 0 };
189 monitor_info.cbSize = sizeof(monitor_info); 189 monitor_info.cbSize = sizeof(monitor_info);
190 GetMonitorInfo(*monitor, &monitor_info); 190 GetMonitorInfo(*monitor, &monitor_info);
191 *monitor_rect = gfx::Rect(monitor_info.rcMonitor); 191 *monitor_rect = gfx::Rect(monitor_info.rcMonitor);
192 *work_area = gfx::Rect(monitor_info.rcWork); 192 *work_area = gfx::Rect(monitor_info.rcWork);
193 return true; 193 return true;
194 } 194 }
195 195
196 struct FindOwnedWindowsData { 196 struct FindOwnedWindowsData {
197 HWND window; 197 HWND window;
198 std::vector<Widget*> owned_widgets; 198 std::vector<HWND> owned_windows;
199 }; 199 };
tapted 2017/01/25 11:23:03 (this struct was orphaned, but it was a handy link
200 200
201 BOOL CALLBACK FindOwnedWindowsCallback(HWND hwnd, LPARAM param) {
202 FindOwnedWindowsData* data = reinterpret_cast<FindOwnedWindowsData*>(param);
203 if (GetWindow(hwnd, GW_OWNER) == data->window)
204 data->owned_windows.push_back(hwnd);
205 return TRUE;
206 }
207
201 // Enables or disables the menu item for the specified command and menu. 208 // Enables or disables the menu item for the specified command and menu.
202 void EnableMenuItemByCommand(HMENU menu, UINT command, bool enabled) { 209 void EnableMenuItemByCommand(HMENU menu, UINT command, bool enabled) {
203 UINT flags = MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED); 210 UINT flags = MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
204 EnableMenuItem(menu, command, flags); 211 EnableMenuItem(menu, command, flags);
205 } 212 }
206 213
207 // Callback used to notify child windows that the top level window received a 214 // Callback used to notify child windows that the top level window received a
208 // DWMCompositionChanged message. 215 // DWMCompositionChanged message.
209 BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) { 216 BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) {
210 SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0); 217 SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 477 }
471 478
472 gfx::Rect HWNDMessageHandler::GetClientAreaBounds() const { 479 gfx::Rect HWNDMessageHandler::GetClientAreaBounds() const {
473 if (IsMinimized()) 480 if (IsMinimized())
474 return gfx::Rect(); 481 return gfx::Rect();
475 if (delegate_->WidgetSizeIsClientSize()) 482 if (delegate_->WidgetSizeIsClientSize())
476 return GetClientAreaBoundsInScreen(); 483 return GetClientAreaBoundsInScreen();
477 return GetWindowBoundsInScreen(); 484 return GetWindowBoundsInScreen();
478 } 485 }
479 486
487 std::vector<HWND> HWNDMessageHandler::GetOwnedWindows() const {
488 FindOwnedWindowsData data;
489 data.window = hwnd();
490 // The Windows API also offers EnumChildWindows(..), but it doesn't work.
491 EnumThreadWindows(GetCurrentThreadId(), FindOwnedWindowsCallback,
492 reinterpret_cast<LPARAM>(&data));
493 return data.owned_windows;
494 }
495
480 void HWNDMessageHandler::GetWindowPlacement( 496 void HWNDMessageHandler::GetWindowPlacement(
481 gfx::Rect* bounds, 497 gfx::Rect* bounds,
482 ui::WindowShowState* show_state) const { 498 ui::WindowShowState* show_state) const {
483 WINDOWPLACEMENT wp; 499 WINDOWPLACEMENT wp;
484 wp.length = sizeof(wp); 500 wp.length = sizeof(wp);
485 const bool succeeded = !!::GetWindowPlacement(hwnd(), &wp); 501 const bool succeeded = !!::GetWindowPlacement(hwnd(), &wp);
486 DCHECK(succeeded); 502 DCHECK(succeeded);
487 503
488 if (bounds != NULL) { 504 if (bounds != NULL) {
489 if (wp.showCmd == SW_SHOWNORMAL) { 505 if (wp.showCmd == SW_SHOWNORMAL) {
(...skipping 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 MONITORINFO monitor_info = {sizeof(monitor_info)}; 2797 MONITORINFO monitor_info = {sizeof(monitor_info)};
2782 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), 2798 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY),
2783 &monitor_info); 2799 &monitor_info);
2784 gfx::Rect shrunk_rect(monitor_info.rcMonitor); 2800 gfx::Rect shrunk_rect(monitor_info.rcMonitor);
2785 shrunk_rect.set_height(shrunk_rect.height() - 1); 2801 shrunk_rect.set_height(shrunk_rect.height() - 1);
2786 background_fullscreen_hack_ = true; 2802 background_fullscreen_hack_ = true;
2787 SetBoundsInternal(shrunk_rect, false); 2803 SetBoundsInternal(shrunk_rect, false);
2788 } 2804 }
2789 2805
2790 } // namespace views 2806 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698