summaryrefslogtreecommitdiffstats
path: root/win8/metro_driver
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-11 20:13:29 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-11 20:13:29 +0000
commite6fb17a8db94a4dc103b7a5d74f2c877ced32a9e (patch)
treee718fbdd062d0a2bc5ce47473556d71be04cf8bc /win8/metro_driver
parent81b4dfdc41e5286e15eaef932e19084fc8b6c1b0 (diff)
downloadchromium_src-e6fb17a8db94a4dc103b7a5d74f2c877ced32a9e.zip
chromium_src-e6fb17a8db94a4dc103b7a5d74f2c877ced32a9e.tar.gz
chromium_src-e6fb17a8db94a4dc103b7a5d74f2c877ced32a9e.tar.bz2
Remove code in ChromeAppView that used winrt_utils::FindCoreWindow. Remove FindCoreWindow.
BUG=15171 TEST=NONE Review URL: https://chromiumcodereview.appspot.com/13933009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8/metro_driver')
-rw-r--r--win8/metro_driver/chrome_app_view.cc45
-rw-r--r--win8/metro_driver/chrome_app_view.h7
-rw-r--r--win8/metro_driver/winrt_utils.cc22
-rw-r--r--win8/metro_driver/winrt_utils.h4
4 files changed, 28 insertions, 50 deletions
diff --git a/win8/metro_driver/chrome_app_view.cc b/win8/metro_driver/chrome_app_view.cc
index 4c177a7..ef2baf7 100644
--- a/win8/metro_driver/chrome_app_view.cc
+++ b/win8/metro_driver/chrome_app_view.cc
@@ -4,24 +4,23 @@
#include "win8/metro_driver/stdafx.h"
#include "win8/metro_driver/chrome_app_view.h"
-#include "win8/metro_driver/direct3d_helper.h"
-#include <algorithm>
+#include <corewindow.h>
#include <windows.applicationModel.datatransfer.h>
#include <windows.foundation.h>
+#include <algorithm>
+
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/win/metro.h"
-
-#include "ui/gfx/native_widget_types.h"
-#include "ui/metro_viewer/metro_viewer_messages.h"
-
// This include allows to send WM_SYSCOMMANDs to chrome.
#include "chrome/app/chrome_command_ids.h"
+#include "ui/base/ui_base_switches.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/metro_viewer/metro_viewer_messages.h"
#include "win8/metro_driver/metro_driver.h"
#include "win8/metro_driver/winrt_utils.h"
-#include "ui/base/ui_base_switches.h"
typedef winfoundtn::ITypedEventHandler<
winapp::Core::CoreApplicationView*,
@@ -150,12 +149,13 @@ void SendMnemonic(WORD mnemonic_char, Modifier modifiers, bool extended,
// ICoreApplicationExit::Exit function in a background delayed task which
// ensures that chrome exits.
void MetroExit(bool send_alt_f4_mnemonic) {
- if (send_alt_f4_mnemonic && globals.core_window == ::GetForegroundWindow()) {
+ if (send_alt_f4_mnemonic && globals.view &&
+ globals.view->core_window_hwnd() == ::GetForegroundWindow()) {
DVLOG(1) << "We are in the foreground. Exiting via Alt F4";
SendMnemonic(VK_F4, ALT, false, false);
DWORD core_window_process_id = 0;
DWORD core_window_thread_id = GetWindowThreadProcessId(
- globals.core_window, &core_window_process_id);
+ globals.view->core_window_hwnd(), &core_window_process_id);
if (core_window_thread_id != ::GetCurrentThreadId()) {
globals.appview_msg_loop->PostDelayedTask(
FROM_HERE,
@@ -164,13 +164,12 @@ void MetroExit(bool send_alt_f4_mnemonic) {
}
} else {
globals.app_exit->Exit();
- globals.core_window = NULL;
}
}
void AdjustToFitWindow(HWND hwnd, int flags) {
RECT rect = {0};
- ::GetWindowRect(globals.core_window, &rect);
+ ::GetWindowRect(globals.view->core_window_hwnd() , &rect);
int cx = rect.right - rect.left;
int cy = rect.bottom - rect.top;
@@ -436,7 +435,7 @@ void MetroUnsnap() {
extern "C" __declspec(dllexport)
HWND GetRootWindow() {
DVLOG(1) << __FUNCTION__;
- return globals.core_window;
+ return globals.view->core_window_hwnd();
}
extern "C" __declspec(dllexport)
@@ -639,7 +638,7 @@ DWORD WINAPI HostMainThreadProc(void*) {
globals.g_core_proc =
reinterpret_cast<WNDPROC>(::SetWindowLongPtr(
- globals.core_window, GWLP_WNDPROC,
+ globals.view->core_window_hwnd(), GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(ChromeAppView::CoreWindowProc)));
DWORD exit_code = globals.host_main(globals.host_context);
@@ -650,7 +649,8 @@ DWORD WINAPI HostMainThreadProc(void*) {
ChromeAppView::ChromeAppView()
: osk_visible_notification_received_(false),
- osk_offset_adjustment_(0) {
+ osk_offset_adjustment_(0),
+ core_window_hwnd_(NULL) {
globals.previous_state =
winapp::Activation::ApplicationExecutionState_NotRunning;
}
@@ -663,7 +663,6 @@ IFACEMETHODIMP
ChromeAppView::Initialize(winapp::Core::ICoreApplicationView* view) {
view_ = view;
DVLOG(1) << __FUNCTION__;
- globals.main_thread_id = ::GetCurrentThreadId();
HRESULT hr = view_->add_Activated(mswr::Callback<ActivatedHandler>(
this, &ChromeAppView::OnActivate).Get(),
@@ -677,7 +676,14 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) {
window_ = window;
DVLOG(1) << __FUNCTION__;
- HRESULT hr = url_launch_handler_.Initialize();
+ // Retrieve the native window handle via the interop layer.
+ mswr::ComPtr<ICoreWindowInterop> interop;
+ HRESULT hr = window->QueryInterface(interop.GetAddressOf());
+ CheckHR(hr);
+ hr = interop->get_WindowHandle(&core_window_hwnd_);
+ CheckHR(hr);
+
+ hr = url_launch_handler_.Initialize();
CheckHR(hr, "Failed to initialize url launch handler.");
// Register for size notifications.
hr = window_->add_SizeChanged(mswr::Callback<SizeChangedHandler>(
@@ -920,11 +926,6 @@ HRESULT ChromeAppView::OnActivate(winapp::Core::ICoreApplicationView*,
return S_OK;
}
- globals.core_window =
- winrt_utils::FindCoreWindow(globals.main_thread_id, 10);
-
- DVLOG(1) << "CoreWindow found: " << std::hex << globals.core_window;
-
if (!globals.host_thread) {
DWORD chrome_ui_thread_id = 0;
globals.host_thread =
@@ -937,7 +938,7 @@ HRESULT ChromeAppView::OnActivate(winapp::Core::ICoreApplicationView*,
}
}
- if (RegisterHotKey(globals.core_window, kFlipWindowsHotKeyId,
+ if (RegisterHotKey(core_window_hwnd_, kFlipWindowsHotKeyId,
MOD_CONTROL, VK_F12)) {
DVLOG(1) << "Registered flip window hotkey.";
} else {
diff --git a/win8/metro_driver/chrome_app_view.h b/win8/metro_driver/chrome_app_view.h
index 8c08176..ced5cca 100644
--- a/win8/metro_driver/chrome_app_view.h
+++ b/win8/metro_driver/chrome_app_view.h
@@ -74,6 +74,8 @@ class ChromeAppView
// Returns the current view state of the chrome window.
winui::ViewManagement::ApplicationViewState GetViewState();
+ HWND core_window_hwnd() { return core_window_hwnd_; }
+
private:
HRESULT OnActivate(winapp::Core::ICoreApplicationView* view,
winapp::Activation::IActivatedEventArgs* args);
@@ -115,6 +117,9 @@ class ChromeAppView
EventRegistrationToken input_pane_hiding_token_;
EventRegistrationToken app_exit_token_;
+ // The actual window behind the view surface.
+ HWND core_window_hwnd_;
+
ChromeUrlLaunchHandler url_launch_handler_;
metro_driver::DevicesHandler devices_handler_;
SettingsHandler settings_handler_;
@@ -143,13 +148,11 @@ class ChromeAppView
struct Globals {
LPTHREAD_START_ROUTINE host_main;
void* host_context;
- HWND core_window;
// The pair below contains the HWND and a bool which indicates whether the
// window was displaced to ensure that the focused region is visible when
// the OSK is displayed.
std::list<std::pair<HWND, bool> > host_windows;
HANDLE host_thread;
- DWORD main_thread_id;
ChromeAppView* view;
WNDPROC g_core_proc;
string16 navigation_url;
diff --git a/win8/metro_driver/winrt_utils.cc b/win8/metro_driver/winrt_utils.cc
index e956c47..be348dc 100644
--- a/win8/metro_driver/winrt_utils.cc
+++ b/win8/metro_driver/winrt_utils.cc
@@ -71,19 +71,6 @@ HRESULT Create ## Name ## Property(Type value, \
*result = 0; \
hr = S_OK
-
-BOOL CALLBACK CoreWindowFinder(HWND hwnd, LPARAM param) {
- HWND* window = reinterpret_cast<HWND*>(param);
- char classname[128];
- if (::GetClassNameA(hwnd, classname, ARRAYSIZE(classname))) {
- if (lstrcmpiA("Windows.UI.Core.CoreWindow", classname) == 0) {
- *window = hwnd;
- return FALSE;
- }
- }
- return TRUE;
-}
-
} // namespace
namespace winrt_utils {
@@ -236,13 +223,4 @@ string16 ReadArgumentsFromPinnedTaskbarShortcut() {
return L"";
}
-HWND FindCoreWindow(DWORD thread_id, int wait_ms) {
- HWND window = NULL;
- do {
- ::Sleep(wait_ms);
- ::EnumThreadWindows(thread_id, &CoreWindowFinder, LPARAM(&window));
- } while (window == NULL);
- return window;
-}
-
} // namespace winrt_utils
diff --git a/win8/metro_driver/winrt_utils.h b/win8/metro_driver/winrt_utils.h
index 1ad0a05..c3be1b1 100644
--- a/win8/metro_driver/winrt_utils.h
+++ b/win8/metro_driver/winrt_utils.h
@@ -55,10 +55,6 @@ HRESULT CompareProperties(
// empty string on failure.
string16 ReadArgumentsFromPinnedTaskbarShortcut();
-// Looks for a Window with the right class name that belongs to |thread_id|
-// thread. It loops forever looking for it, waiting |wait_ms| between loops.
-HWND FindCoreWindow(DWORD thread_id, int wait_ms);
-
} // namespace winrt_utils
#endif // WIN8_METRO_DRIVER_WINRT_UTILS_H_