summaryrefslogtreecommitdiffstats
path: root/ui/base/win/singleton_hwnd.cc
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 15:53:01 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 15:53:01 +0000
commitbe5756e2d20c2aa54d8865c3695efb3cc2cba13e (patch)
treea9045beff453f5528ab6372ef22583b50ff2fc75 /ui/base/win/singleton_hwnd.cc
parent195588e411d59afe5c5c59f45b83db254ce9a9a0 (diff)
downloadchromium_src-be5756e2d20c2aa54d8865c3695efb3cc2cba13e.zip
chromium_src-be5756e2d20c2aa54d8865c3695efb3cc2cba13e.tar.gz
chromium_src-be5756e2d20c2aa54d8865c3695efb3cc2cba13e.tar.bz2
Respect the system ClearType setting in RenderTextWin.
BUG=113184, 105550 TEST=Build Chrome Windows with gyp flag use_canvas_skia_skia=1. Open Chrome and observe text rendering in the tab strip, bookmarks bar, etc. Change Windows ClearType settings while Chrome is running. Text rendering should be updated appropriately. Review URL: http://codereview.chromium.org/9370026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/win/singleton_hwnd.cc')
-rw-r--r--ui/base/win/singleton_hwnd.cc81
1 files changed, 81 insertions, 0 deletions
diff --git a/ui/base/win/singleton_hwnd.cc b/ui/base/win/singleton_hwnd.cc
new file mode 100644
index 0000000..7132be3
--- /dev/null
+++ b/ui/base/win/singleton_hwnd.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/win/singleton_hwnd.h"
+
+#include "base/memory/singleton.h"
+#include "base/process_util.h"
+#include "base/win/wrapped_window_proc.h"
+#include "ui/base/win/hwnd_util.h"
+
+namespace {
+
+// Windows class name to use for the listener window.
+const wchar_t kWindowClassName[] = L"Chrome_SingletonHwnd";
+
+// Windows callback for listening for WM_* messages.
+LRESULT CALLBACK ListenerWindowProc(HWND hwnd,
+ UINT message,
+ WPARAM wparam,
+ LPARAM lparam) {
+ ui::SingletonHwnd::GetInstance()->OnWndProc(hwnd, message, wparam, lparam);
+ return ::DefWindowProc(hwnd, message, wparam, lparam);
+}
+
+// Creates a listener window to receive WM_* messages.
+HWND CreateListenerWindow() {
+ WNDCLASSEX wc = {0};
+ wc.cbSize = sizeof(wc);
+ wc.lpfnWndProc = base::win::WrappedWindowProc<ListenerWindowProc>;
+ wc.hInstance = base::GetModuleFromAddress(&ListenerWindowProc);
+ wc.lpszClassName = kWindowClassName;
+ ATOM window_class = ::RegisterClassEx(&wc);
+ DCHECK(window_class);
+
+ return ::CreateWindow(MAKEINTATOM(window_class), 0, 0, 0, 0, 0, 0, 0, 0,
+ wc.hInstance, 0);
+}
+
+} // namespace
+
+namespace ui {
+
+// static
+SingletonHwnd* SingletonHwnd::GetInstance() {
+ return Singleton<SingletonHwnd>::get();
+}
+
+void SingletonHwnd::AddObserver(Observer* observer) {
+ if (!listener_window_) {
+ listener_window_ = CreateListenerWindow();
+ ui::CheckWindowCreated(listener_window_);
+ }
+ observer_list_.AddObserver(observer);
+}
+
+void SingletonHwnd::RemoveObserver(Observer* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
+void SingletonHwnd::OnWndProc(HWND hwnd,
+ UINT message,
+ WPARAM wparam,
+ LPARAM lparam) {
+ FOR_EACH_OBSERVER(Observer,
+ observer_list_,
+ OnWndProc(hwnd, message, wparam, lparam));
+}
+
+SingletonHwnd::SingletonHwnd()
+ : listener_window_(NULL) {
+}
+
+SingletonHwnd::~SingletonHwnd() {
+ if (listener_window_) {
+ ::DestroyWindow(listener_window_);
+ ::UnregisterClass(kWindowClassName, GetModuleHandle(NULL));
+ }
+}
+
+} // namespace ui