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

Unified Diff: ui/base/win/singleton_hwnd.cc

Issue 9370026: Respect the system ClearType setting in RenderTextWin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/win/singleton_hwnd.h ('k') | ui/gfx/font_smoothing_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/singleton_hwnd.cc
===================================================================
--- ui/base/win/singleton_hwnd.cc (revision 0)
+++ ui/base/win/singleton_hwnd.cc (revision 0)
@@ -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
« no previous file with comments | « ui/base/win/singleton_hwnd.h ('k') | ui/gfx/font_smoothing_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698