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

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 10892014: Make HWNDMessageHandler subclass WindowImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/views/win/hwnd_message_handler.h ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/win/hwnd_message_handler.cc
===================================================================
--- ui/views/win/hwnd_message_handler.cc (revision 153679)
+++ ui/views/win/hwnd_message_handler.cc (working copy)
@@ -361,8 +361,8 @@
HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate)
: delegate_(delegate),
- ALLOW_THIS_IN_INITIALIZER_LIST(fullscreen_handler_(new FullscreenHandler(
- delegate->AsNativeWidgetWin()->GetWidget()))),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ fullscreen_handler_(new FullscreenHandler)),
ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
remove_standard_frame_(false),
restore_focus_when_enabled_(false),
@@ -924,6 +924,8 @@
use_layered_buffer_ = !!(delegate_->AsNativeWidgetWin()->
window_ex_style() & WS_EX_LAYERED);
+ fullscreen_handler_->set_hwnd(hwnd());
+
// Attempt to detect screen readers by sending an event with our custom id.
NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kCustomObjectID, CHILDID_SELF);
@@ -955,6 +957,12 @@
// creation time.
ClientAreaSizeChanged();
+ // We need to add ourselves as a message loop observer so that we can repaint
+ // aggressively if the contents of our window become invalid. Unfortunately
+ // WM_PAINT messages are starved and we get flickery redrawing when resizing
+ // if we do not do this.
+ MessageLoopForUI::current()->AddObserver(this);
+
delegate_->HandleCreate();
// TODO(beng): move more of NWW::OnCreate here.
@@ -1011,7 +1019,7 @@
// Add the native frame border size to the minimum and maximum size if the
// view reports its size as the client size.
- if (delegate_->AsNativeWidgetWin()->WidgetSizeIsClientSize()) {
+ if (delegate_->WidgetSizeIsClientSize()) {
CRect client_rect, window_rect;
GetClientRect(hwnd(), &client_rect);
GetWindowRect(hwnd(), &window_rect);
@@ -1852,6 +1860,9 @@
HWND window = hwnd();
LRESULT result = 0;
+ if (delegate_->PreHandleMSG(message, w_param, l_param, &result))
+ return result;
+
// First allow messages sent by child controls to be processed directly by
// their associated views. If such a view is present, it will handle the
// message *instead of* this NativeWidgetWin.
@@ -1863,8 +1874,11 @@
window, message, w_param, l_param, result)) {
result = DefWindowProc(window, message, w_param, l_param);
}
- if (message == WM_NCDESTROY)
+ delegate_->PostHandleMSG(message, w_param, l_param);
+ if (message == WM_NCDESTROY) {
+ MessageLoopForUI::current()->RemoveObserver(this);
delegate_->HandleDestroyed();
+ }
// Only top level widget should store/restore focus.
if (message == WM_ACTIVATE && delegate_->CanSaveFocus())
@@ -1879,7 +1893,18 @@
return result;
}
+////////////////////////////////////////////////////////////////////////////////
+// HWNDMessageHandler, MessageLoopForUI::Observer implementation:
+base::EventStatus HWNDMessageHandler::WillProcessEvent(
+ const base::NativeEvent& event) {
+ return base::EVENT_CONTINUE;
+}
+
+void HWNDMessageHandler::DidProcessEvent(const base::NativeEvent& event) {
+ RedrawInvalidRect();
+}
+
////////////////////////////////////////////////////////////////////////////////
// HWNDMessageHandler, private:
@@ -1960,7 +1985,7 @@
void HWNDMessageHandler::ClientAreaSizeChanged() {
RECT r = {0, 0, 0, 0};
- if (delegate_->AsNativeWidgetWin()->WidgetSizeIsClientSize()) {
+ if (delegate_->WidgetSizeIsClientSize()) {
// TODO(beng): investigate whether this could be done
// from other branch of if-else.
if (!IsMinimized())
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698