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

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

Issue 136003015: Remove native_control* and some other non-Aura windows code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 <shellapi.h> 8 #include <shellapi.h>
9 #include <wtsapi32.h> 9 #include <wtsapi32.h>
10 #pragma comment(lib, "wtsapi32.lib") 10 #pragma comment(lib, "wtsapi32.lib")
(...skipping 16 matching lines...) Expand all
27 #include "ui/gfx/icon_util.h" 27 #include "ui/gfx/icon_util.h"
28 #include "ui/gfx/insets.h" 28 #include "ui/gfx/insets.h"
29 #include "ui/gfx/path.h" 29 #include "ui/gfx/path.h"
30 #include "ui/gfx/path_win.h" 30 #include "ui/gfx/path_win.h"
31 #include "ui/gfx/screen.h" 31 #include "ui/gfx/screen.h"
32 #include "ui/gfx/win/dpi.h" 32 #include "ui/gfx/win/dpi.h"
33 #include "ui/gfx/win/hwnd_util.h" 33 #include "ui/gfx/win/hwnd_util.h"
34 #include "ui/native_theme/native_theme_win.h" 34 #include "ui/native_theme/native_theme_win.h"
35 #include "ui/views/views_delegate.h" 35 #include "ui/views/views_delegate.h"
36 #include "ui/views/widget/monitor_win.h" 36 #include "ui/views/widget/monitor_win.h"
37 #include "ui/views/widget/native_widget_win.h"
38 #include "ui/views/widget/widget_hwnd_utils.h" 37 #include "ui/views/widget/widget_hwnd_utils.h"
39 #include "ui/views/win/appbar.h" 38 #include "ui/views/win/appbar.h"
40 #include "ui/views/win/fullscreen_handler.h" 39 #include "ui/views/win/fullscreen_handler.h"
41 #include "ui/views/win/hwnd_message_handler_delegate.h" 40 #include "ui/views/win/hwnd_message_handler_delegate.h"
42 #include "ui/views/win/scoped_fullscreen_visibility.h" 41 #include "ui/views/win/scoped_fullscreen_visibility.h"
43 42
44 #if !defined(USE_AURA) 43 #if !defined(USE_AURA)
45 #include "ui/views/accessibility/native_view_accessibility_win.h" 44 #include "ui/views/accessibility/native_view_accessibility_win.h"
46 #include "ui/views/widget/child_window_message_processor.h" 45 #include "ui/views/widget/child_window_message_processor.h"
47 #endif 46 #endif
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 934
936 LRESULT HWNDMessageHandler::OnWndProc(UINT message, 935 LRESULT HWNDMessageHandler::OnWndProc(UINT message,
937 WPARAM w_param, 936 WPARAM w_param,
938 LPARAM l_param) { 937 LPARAM l_param) {
939 HWND window = hwnd(); 938 HWND window = hwnd();
940 LRESULT result = 0; 939 LRESULT result = 0;
941 940
942 if (delegate_ && delegate_->PreHandleMSG(message, w_param, l_param, &result)) 941 if (delegate_ && delegate_->PreHandleMSG(message, w_param, l_param, &result))
943 return result; 942 return result;
944 943
945 #if !defined(USE_AURA)
946 // First allow messages sent by child controls to be processed directly by
947 // their associated views. If such a view is present, it will handle the
948 // message *instead of* this NativeWidgetWin.
949 if (ProcessChildWindowMessage(message, w_param, l_param, &result))
950 return result;
951 #endif
952
953 // Otherwise we handle everything else. 944 // Otherwise we handle everything else.
954 // NOTE: We inline ProcessWindowMessage() as 'this' may be destroyed during 945 // NOTE: We inline ProcessWindowMessage() as 'this' may be destroyed during
955 // dispatch and ProcessWindowMessage() doesn't deal with that well. 946 // dispatch and ProcessWindowMessage() doesn't deal with that well.
956 const BOOL old_msg_handled = msg_handled_; 947 const BOOL old_msg_handled = msg_handled_;
957 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); 948 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
958 const BOOL processed = 949 const BOOL processed =
959 _ProcessWindowMessage(window, message, w_param, l_param, result, 0); 950 _ProcessWindowMessage(window, message, w_param, l_param, result, 0);
960 if (!ref) 951 if (!ref)
961 return 0; 952 return 0;
962 msg_handled_ = old_msg_handled; 953 msg_handled_ = old_msg_handled;
963 954
964 if (!processed) 955 if (!processed)
965 result = DefWindowProc(window, message, w_param, l_param); 956 result = DefWindowProc(window, message, w_param, l_param);
966 957
967 // DefWindowProc() may have destroyed the window in a nested message loop. 958 // DefWindowProc() may have destroyed the window in a nested message loop.
968 if (!::IsWindow(window)) 959 if (!::IsWindow(window))
969 return result; 960 return result;
970 961
971 if (delegate_) 962 if (delegate_)
972 delegate_->PostHandleMSG(message, w_param, l_param); 963 delegate_->PostHandleMSG(message, w_param, l_param);
973 if (message == WM_NCDESTROY) { 964 if (message == WM_NCDESTROY) {
974 #if !defined(USE_AURA)
975 base::MessageLoopForUI::current()->RemoveObserver(this);
976 #endif
977 if (delegate_) 965 if (delegate_)
978 delegate_->HandleDestroyed(); 966 delegate_->HandleDestroyed();
979 } 967 }
980 968
981 // Only top level widget should store/restore focus. 969 // Only top level widget should store/restore focus.
982 if (message == WM_ACTIVATE && delegate_->CanSaveFocus()) 970 if (message == WM_ACTIVATE && delegate_->CanSaveFocus())
983 PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param)); 971 PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param));
984 972
985 if (message == WM_ENABLE && restore_focus_when_enabled_) { 973 if (message == WM_ENABLE && restore_focus_when_enabled_) {
986 // This path should be executed only for top level as 974 // This path should be executed only for top level as
987 // restore_focus_when_enabled_ is set in PostProcessActivateMessage. 975 // restore_focus_when_enabled_ is set in PostProcessActivateMessage.
988 DCHECK(delegate_->CanSaveFocus()); 976 DCHECK(delegate_->CanSaveFocus());
989 restore_focus_when_enabled_ = false; 977 restore_focus_when_enabled_ = false;
990 delegate_->RestoreFocusOnEnable(); 978 delegate_->RestoreFocusOnEnable();
991 } 979 }
992 return result; 980 return result;
993 } 981 }
994 982
995 //////////////////////////////////////////////////////////////////////////////// 983 ////////////////////////////////////////////////////////////////////////////////
996 // HWNDMessageHandler, MessageLoopForUI::Observer implementation:
997
998 base::EventStatus HWNDMessageHandler::WillProcessEvent(
999 const base::NativeEvent& event) {
1000 return base::EVENT_CONTINUE;
1001 }
1002
1003 void HWNDMessageHandler::DidProcessEvent(const base::NativeEvent& event) {
1004 RedrawInvalidRect();
1005 }
1006
1007 ////////////////////////////////////////////////////////////////////////////////
1008 // HWNDMessageHandler, private: 984 // HWNDMessageHandler, private:
1009 985
1010 int HWNDMessageHandler::GetAppbarAutohideEdges(HMONITOR monitor) { 986 int HWNDMessageHandler::GetAppbarAutohideEdges(HMONITOR monitor) {
1011 autohide_factory_.InvalidateWeakPtrs(); 987 autohide_factory_.InvalidateWeakPtrs();
1012 return Appbar::instance()->GetAutohideEdges( 988 return Appbar::instance()->GetAutohideEdges(
1013 monitor, 989 monitor,
1014 base::Bind(&HWNDMessageHandler::OnAppbarAutohideEdgesChanged, 990 base::Bind(&HWNDMessageHandler::OnAppbarAutohideEdgesChanged,
1015 autohide_factory_.GetWeakPtr())); 991 autohide_factory_.GetWeakPtr()));
1016 } 992 }
1017 993
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 } 1210 }
1235 1211
1236 void HWNDMessageHandler::UnlockUpdates(bool force) { 1212 void HWNDMessageHandler::UnlockUpdates(bool force) {
1237 if ((force || !ui::win::IsAeroGlassEnabled()) && --lock_updates_count_ <= 0) { 1213 if ((force || !ui::win::IsAeroGlassEnabled()) && --lock_updates_count_ <= 0) {
1238 SetWindowLong(hwnd(), GWL_STYLE, 1214 SetWindowLong(hwnd(), GWL_STYLE,
1239 GetWindowLong(hwnd(), GWL_STYLE) | WS_VISIBLE); 1215 GetWindowLong(hwnd(), GWL_STYLE) | WS_VISIBLE);
1240 lock_updates_count_ = 0; 1216 lock_updates_count_ = 0;
1241 } 1217 }
1242 } 1218 }
1243 1219
1244 void HWNDMessageHandler::RedrawInvalidRect() {
1245 // TODO(cpu): Remove the caller and this class as a message loop observer
1246 // because we don't need agressive repaints via RDW_UPDATENOW in Aura. The
1247 // general tracking bug for repaint issues is 177115.
1248 #if !defined(USE_AURA)
1249 if (!use_layered_buffer_) {
1250 RECT r = { 0, 0, 0, 0 };
1251 if (GetUpdateRect(hwnd(), &r, FALSE) && !IsRectEmpty(&r)) {
1252 RedrawWindow(hwnd(), &r, NULL,
1253 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
1254 }
1255 }
1256 #endif
1257 }
1258
1259 void HWNDMessageHandler::RedrawLayeredWindowContents() { 1220 void HWNDMessageHandler::RedrawLayeredWindowContents() {
1260 waiting_for_redraw_layered_window_contents_ = false; 1221 waiting_for_redraw_layered_window_contents_ = false;
1261 if (invalid_rect_.IsEmpty()) 1222 if (invalid_rect_.IsEmpty())
1262 return; 1223 return;
1263 1224
1264 // We need to clip to the dirty rect ourselves. 1225 // We need to clip to the dirty rect ourselves.
1265 layered_window_contents_->sk_canvas()->save(SkCanvas::kClip_SaveFlag); 1226 layered_window_contents_->sk_canvas()->save(SkCanvas::kClip_SaveFlag);
1266 double scale = gfx::win::GetDeviceScaleFactor(); 1227 double scale = gfx::win::GetDeviceScaleFactor();
1267 layered_window_contents_->sk_canvas()->scale( 1228 layered_window_contents_->sk_canvas()->scale(
1268 SkScalar(scale),SkScalar(scale)); 1229 SkScalar(scale),SkScalar(scale));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 1344
1384 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && 1345 if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
1385 ui::AreTouchEventsEnabled()) 1346 ui::AreTouchEventsEnabled())
1386 RegisterTouchWindow(hwnd(), TWF_WANTPALM); 1347 RegisterTouchWindow(hwnd(), TWF_WANTPALM);
1387 1348
1388 // We need to allow the delegate to size its contents since the window may not 1349 // We need to allow the delegate to size its contents since the window may not
1389 // receive a size notification when its initial bounds are specified at window 1350 // receive a size notification when its initial bounds are specified at window
1390 // creation time. 1351 // creation time.
1391 ClientAreaSizeChanged(); 1352 ClientAreaSizeChanged();
1392 1353
1393 #if !defined(USE_AURA)
1394 // We need to add ourselves as a message loop observer so that we can repaint
1395 // aggressively if the contents of our window become invalid. Unfortunately
1396 // WM_PAINT messages are starved and we get flickery redrawing when resizing
1397 // if we do not do this.
1398 base::MessageLoopForUI::current()->AddObserver(this);
1399 #endif
1400
1401 delegate_->HandleCreate(); 1354 delegate_->HandleCreate();
1402 1355
1403 WTSRegisterSessionNotification(hwnd(), NOTIFY_FOR_THIS_SESSION); 1356 WTSRegisterSessionNotification(hwnd(), NOTIFY_FOR_THIS_SESSION);
1404 1357
1405 // TODO(beng): move more of NWW::OnCreate here. 1358 // TODO(beng): move more of NWW::OnCreate here.
1406 return 0; 1359 return 0;
1407 } 1360 }
1408 1361
1409 void HWNDMessageHandler::OnDestroy() { 1362 void HWNDMessageHandler::OnDestroy() {
1410 WTSUnRegisterSessionNotification(hwnd()); 1363 WTSUnRegisterSessionNotification(hwnd());
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
2388 SetMsgHandled(FALSE); 2341 SetMsgHandled(FALSE);
2389 } 2342 }
2390 2343
2391 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { 2344 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) {
2392 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); 2345 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
2393 for (size_t i = 0; i < touch_events.size() && ref; ++i) 2346 for (size_t i = 0; i < touch_events.size() && ref; ++i)
2394 delegate_->HandleTouchEvent(touch_events[i]); 2347 delegate_->HandleTouchEvent(touch_events[i]);
2395 } 2348 }
2396 2349
2397 } // namespace views 2350 } // namespace views
OLDNEW
« ui/views/win/hwnd_message_handler.h ('K') | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698