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

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 2387013003: Adds OnChildWindowVisibilityChanged to ui::WindowObserver (Closed)
Patch Set: fix test Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This has to be before any other includes, else default is picked up.
6 // See base/logging for details on this.
7 #define NOTIMPLEMENTED_POLICY 5
James Cook 2016/10/03 20:33:08 Gentle pushback: We're already pretty spammy at st
sky 2016/10/03 20:52:13 I realize we're spammy, but I think that's the poi
8
5 #include "ui/views/mus/native_widget_mus.h" 9 #include "ui/views/mus/native_widget_mus.h"
6 10
7 #include <utility> 11 #include <utility>
8 #include <vector> 12 #include <vector>
9 13
10 #include "base/callback.h" 14 #include "base/callback.h"
11 #include "base/macros.h" 15 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 17 #include "base/run_loop.h"
14 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 : native_widget_mus_(native_widget_mus), 405 : native_widget_mus_(native_widget_mus),
402 show_state_(ui::mojom::ShowState::DEFAULT) { 406 show_state_(ui::mojom::ShowState::DEFAULT) {
403 mus_window()->AddObserver(this); 407 mus_window()->AddObserver(this);
404 } 408 }
405 409
406 ~MusWindowObserver() override { 410 ~MusWindowObserver() override {
407 mus_window()->RemoveObserver(this); 411 mus_window()->RemoveObserver(this);
408 } 412 }
409 413
410 // ui::WindowObserver: 414 // ui::WindowObserver:
411 void OnWindowVisibilityChanging(ui::Window* window) override { 415 void OnWindowVisibilityChanging(ui::Window* window, bool visible) override {
412 native_widget_mus_->OnMusWindowVisibilityChanging(window); 416 native_widget_mus_->OnMusWindowVisibilityChanging(window, visible);
413 } 417 }
414 void OnWindowVisibilityChanged(ui::Window* window) override { 418 void OnWindowVisibilityChanged(ui::Window* window, bool visible) override {
415 native_widget_mus_->OnMusWindowVisibilityChanged(window); 419 native_widget_mus_->OnMusWindowVisibilityChanged(window, visible);
416 } 420 }
417 void OnWindowPredefinedCursorChanged(ui::Window* window, 421 void OnWindowPredefinedCursorChanged(ui::Window* window,
418 ui::mojom::Cursor cursor) override { 422 ui::mojom::Cursor cursor) override {
419 DCHECK_EQ(window, mus_window()); 423 DCHECK_EQ(window, mus_window());
420 native_widget_mus_->set_last_cursor(cursor); 424 native_widget_mus_->set_last_cursor(cursor);
421 } 425 }
422 void OnWindowSharedPropertyChanged( 426 void OnWindowSharedPropertyChanged(
423 ui::Window* window, 427 ui::Window* window,
424 const std::string& name, 428 const std::string& name,
425 const std::vector<uint8_t>* old_data, 429 const std::vector<uint8_t>* old_data,
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 void NativeWidgetMus::OnWidgetInitDone() { 772 void NativeWidgetMus::OnWidgetInitDone() {
769 // The client area is calculated from the NonClientView. During 773 // The client area is calculated from the NonClientView. During
770 // InitNativeWidget() the NonClientView has not been created. When this 774 // InitNativeWidget() the NonClientView has not been created. When this
771 // function is called the NonClientView has been created, so that we can 775 // function is called the NonClientView has been created, so that we can
772 // correctly calculate the client area and push it to the ui::Window. 776 // correctly calculate the client area and push it to the ui::Window.
773 UpdateClientArea(); 777 UpdateClientArea();
774 UpdateHitTestMask(); 778 UpdateHitTestMask();
775 } 779 }
776 780
777 bool NativeWidgetMus::ShouldUseNativeFrame() const { 781 bool NativeWidgetMus::ShouldUseNativeFrame() const {
778 // NOTIMPLEMENTED(); 782 NOTIMPLEMENTED();
779 return false; 783 return false;
780 } 784 }
781 785
782 bool NativeWidgetMus::ShouldWindowContentsBeTransparent() const { 786 bool NativeWidgetMus::ShouldWindowContentsBeTransparent() const {
783 // NOTIMPLEMENTED(); 787 NOTIMPLEMENTED();
784 return true; 788 return true;
785 } 789 }
786 790
787 void NativeWidgetMus::FrameTypeChanged() { 791 void NativeWidgetMus::FrameTypeChanged() {
788 // NOTIMPLEMENTED(); 792 NOTIMPLEMENTED();
789 } 793 }
790 794
791 Widget* NativeWidgetMus::GetWidget() { 795 Widget* NativeWidgetMus::GetWidget() {
792 return native_widget_delegate_->AsWidget(); 796 return native_widget_delegate_->AsWidget();
793 } 797 }
794 798
795 const Widget* NativeWidgetMus::GetWidget() const { 799 const Widget* NativeWidgetMus::GetWidget() const {
796 return native_widget_delegate_->AsWidget(); 800 return native_widget_delegate_->AsWidget();
797 } 801 }
798 802
(...skipping 11 matching lines...) Expand all
810 814
811 const ui::Compositor* NativeWidgetMus::GetCompositor() const { 815 const ui::Compositor* NativeWidgetMus::GetCompositor() const {
812 return window_tree_host_->compositor(); 816 return window_tree_host_->compositor();
813 } 817 }
814 818
815 const ui::Layer* NativeWidgetMus::GetLayer() const { 819 const ui::Layer* NativeWidgetMus::GetLayer() const {
816 return content_ ? content_->layer() : nullptr; 820 return content_ ? content_->layer() : nullptr;
817 } 821 }
818 822
819 void NativeWidgetMus::ReorderNativeViews() { 823 void NativeWidgetMus::ReorderNativeViews() {
820 // NOTIMPLEMENTED(); 824 NOTIMPLEMENTED();
821 } 825 }
822 826
823 void NativeWidgetMus::ViewRemoved(View* view) { 827 void NativeWidgetMus::ViewRemoved(View* view) {
824 // NOTIMPLEMENTED(); 828 NOTIMPLEMENTED();
825 } 829 }
826 830
827 // These methods are wrong in mojo. They're not usually used to associate 831 // These methods are wrong in mojo. They're not usually used to associate
828 // data with a window; they are used exclusively in chrome/ to unsafely pass 832 // data with a window; they are used exclusively in chrome/ to unsafely pass
829 // raw pointers around. I can only find two places where we do the "safe" 833 // raw pointers around. I can only find two places where we do the "safe"
830 // thing (and even that requires casting an integer to a void*). They can't be 834 // thing (and even that requires casting an integer to a void*). They can't be
831 // used safely in a world where we separate things with mojo. They should be 835 // used safely in a world where we separate things with mojo. They should be
832 // removed; not ported. 836 // removed; not ported.
833 void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) { 837 void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) {
834 native_window_properties_[name] = value; 838 native_window_properties_[name] = value;
835 } 839 }
836 840
837 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { 841 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const {
838 auto it = native_window_properties_.find(name); 842 auto it = native_window_properties_.find(name);
839 if (it == native_window_properties_.end()) 843 if (it == native_window_properties_.end())
840 return nullptr; 844 return nullptr;
841 return it->second; 845 return it->second;
842 } 846 }
843 847
844 TooltipManager* NativeWidgetMus::GetTooltipManager() const { 848 TooltipManager* NativeWidgetMus::GetTooltipManager() const {
845 // NOTIMPLEMENTED(); 849 NOTIMPLEMENTED();
846 return nullptr; 850 return nullptr;
847 } 851 }
848 852
849 void NativeWidgetMus::SetCapture() { 853 void NativeWidgetMus::SetCapture() {
850 if (content_) 854 if (content_)
851 content_->SetCapture(); 855 content_->SetCapture();
852 } 856 }
853 857
854 void NativeWidgetMus::ReleaseCapture() { 858 void NativeWidgetMus::ReleaseCapture() {
855 if (content_) 859 if (content_)
(...skipping 18 matching lines...) Expand all
874 gfx::Rect bounds = display::Screen::GetScreen() 878 gfx::Rect bounds = display::Screen::GetScreen()
875 ->GetDisplayNearestWindow(content_) 879 ->GetDisplayNearestWindow(content_)
876 .work_area(); 880 .work_area();
877 bounds.ClampToCenteredSize(size); 881 bounds.ClampToCenteredSize(size);
878 window_->SetBounds(bounds); 882 window_->SetBounds(bounds);
879 } 883 }
880 884
881 void NativeWidgetMus::GetWindowPlacement( 885 void NativeWidgetMus::GetWindowPlacement(
882 gfx::Rect* bounds, 886 gfx::Rect* bounds,
883 ui::WindowShowState* maximized) const { 887 ui::WindowShowState* maximized) const {
884 // NOTIMPLEMENTED(); 888 NOTIMPLEMENTED();
885 } 889 }
886 890
887 bool NativeWidgetMus::SetWindowTitle(const base::string16& title) { 891 bool NativeWidgetMus::SetWindowTitle(const base::string16& title) {
888 if (!window_ || is_parallel_widget_in_window_manager()) 892 if (!window_ || is_parallel_widget_in_window_manager())
889 return false; 893 return false;
890 const char* kWindowTitle_Property = 894 const char* kWindowTitle_Property =
891 ui::mojom::WindowManager::kWindowTitle_Property; 895 ui::mojom::WindowManager::kWindowTitle_Property;
892 const base::string16 current_title = 896 const base::string16 current_title =
893 window_->HasSharedProperty(kWindowTitle_Property) 897 window_->HasSharedProperty(kWindowTitle_Property)
894 ? window_->GetSharedProperty<base::string16>(kWindowTitle_Property) 898 ? window_->GetSharedProperty<base::string16>(kWindowTitle_Property)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 996
993 void NativeWidgetMus::SetSize(const gfx::Size& size) { 997 void NativeWidgetMus::SetSize(const gfx::Size& size) {
994 if (!window_tree_host_) 998 if (!window_tree_host_)
995 return; 999 return;
996 1000
997 gfx::Rect bounds = window_tree_host_->GetBounds(); 1001 gfx::Rect bounds = window_tree_host_->GetBounds();
998 SetBounds(gfx::Rect(bounds.origin(), size)); 1002 SetBounds(gfx::Rect(bounds.origin(), size));
999 } 1003 }
1000 1004
1001 void NativeWidgetMus::StackAbove(gfx::NativeView native_view) { 1005 void NativeWidgetMus::StackAbove(gfx::NativeView native_view) {
1002 // NOTIMPLEMENTED(); 1006 NOTIMPLEMENTED();
1003 } 1007 }
1004 1008
1005 void NativeWidgetMus::StackAtTop() { 1009 void NativeWidgetMus::StackAtTop() {
1006 // NOTIMPLEMENTED(); 1010 NOTIMPLEMENTED();
1007 } 1011 }
1008 1012
1009 void NativeWidgetMus::StackBelow(gfx::NativeView native_view) { 1013 void NativeWidgetMus::StackBelow(gfx::NativeView native_view) {
1010 // NOTIMPLEMENTED(); 1014 NOTIMPLEMENTED();
1011 } 1015 }
1012 1016
1013 void NativeWidgetMus::SetShape(std::unique_ptr<SkRegion> shape) { 1017 void NativeWidgetMus::SetShape(std::unique_ptr<SkRegion> shape) {
1014 // NOTIMPLEMENTED(); 1018 NOTIMPLEMENTED();
1015 } 1019 }
1016 1020
1017 void NativeWidgetMus::Close() { 1021 void NativeWidgetMus::Close() {
1018 Hide(); 1022 Hide();
1019 if (!close_widget_factory_.HasWeakPtrs()) { 1023 if (!close_widget_factory_.HasWeakPtrs()) {
1020 base::ThreadTaskRunnerHandle::Get()->PostTask( 1024 base::ThreadTaskRunnerHandle::Get()->PostTask(
1021 FROM_HERE, base::Bind(&NativeWidgetMus::CloseNow, 1025 FROM_HERE, base::Bind(&NativeWidgetMus::CloseNow,
1022 close_widget_factory_.GetWeakPtr())); 1026 close_widget_factory_.GetWeakPtr()));
1023 } 1027 }
1024 } 1028 }
(...skipping 12 matching lines...) Expand all
1037 if (!(window_ && window_tree_host_)) 1041 if (!(window_ && window_tree_host_))
1038 return; 1042 return;
1039 1043
1040 // NOTE: |window_tree_host_| and |window_| visibility is updated in 1044 // NOTE: |window_tree_host_| and |window_| visibility is updated in
1041 // OnMusWindowVisibilityChanged(). 1045 // OnMusWindowVisibilityChanged().
1042 window_->SetVisible(false); 1046 window_->SetVisible(false);
1043 } 1047 }
1044 1048
1045 void NativeWidgetMus::ShowMaximizedWithBounds( 1049 void NativeWidgetMus::ShowMaximizedWithBounds(
1046 const gfx::Rect& restored_bounds) { 1050 const gfx::Rect& restored_bounds) {
1047 // NOTIMPLEMENTED(); 1051 NOTIMPLEMENTED();
1048 } 1052 }
1049 1053
1050 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) { 1054 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) {
1051 if (!(window_ && window_tree_host_)) 1055 if (!(window_ && window_tree_host_))
1052 return; 1056 return;
1053 1057
1054 // NOTE: |window_tree_host_| and |window_| visibility is updated in 1058 // NOTE: |window_tree_host_| and |window_| visibility is updated in
1055 // OnMusWindowVisibilityChanged(). 1059 // OnMusWindowVisibilityChanged().
1056 window_->SetVisible(true); 1060 window_->SetVisible(true);
1057 if (native_widget_delegate_->CanActivate()) { 1061 if (native_widget_delegate_->CanActivate()) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 bool NativeWidgetMus::IsFullscreen() const { 1161 bool NativeWidgetMus::IsFullscreen() const {
1158 return GetShowState(window_) == ui::mojom::ShowState::FULLSCREEN; 1162 return GetShowState(window_) == ui::mojom::ShowState::FULLSCREEN;
1159 } 1163 }
1160 1164
1161 void NativeWidgetMus::SetOpacity(float opacity) { 1165 void NativeWidgetMus::SetOpacity(float opacity) {
1162 if (window_) 1166 if (window_)
1163 window_->SetOpacity(opacity); 1167 window_->SetOpacity(opacity);
1164 } 1168 }
1165 1169
1166 void NativeWidgetMus::FlashFrame(bool flash_frame) { 1170 void NativeWidgetMus::FlashFrame(bool flash_frame) {
1167 // NOTIMPLEMENTED(); 1171 NOTIMPLEMENTED();
1168 } 1172 }
1169 1173
1170 void NativeWidgetMus::RunShellDrag(View* view, 1174 void NativeWidgetMus::RunShellDrag(View* view,
1171 const ui::OSExchangeData& data, 1175 const ui::OSExchangeData& data,
1172 const gfx::Point& location, 1176 const gfx::Point& location,
1173 int drag_operations, 1177 int drag_operations,
1174 ui::DragDropTypes::DragEventSource source) { 1178 ui::DragDropTypes::DragEventSource source) {
1175 if (window_) 1179 if (window_)
1176 views::RunShellDrag(content_, data, location, drag_operations, source); 1180 views::RunShellDrag(content_, data, location, drag_operations, source);
1177 } 1181 }
(...skipping 12 matching lines...) Expand all
1190 // we support right now. If native_type() == kCursorCustom, than we should 1194 // we support right now. If native_type() == kCursorCustom, than we should
1191 // also send an image, but as the cursor code is currently written, the image 1195 // also send an image, but as the cursor code is currently written, the image
1192 // is in a platform native format that's already uploaded to the window 1196 // is in a platform native format that's already uploaded to the window
1193 // server. 1197 // server.
1194 ui::mojom::Cursor new_cursor = ui::mojom::Cursor(cursor.native_type()); 1198 ui::mojom::Cursor new_cursor = ui::mojom::Cursor(cursor.native_type());
1195 if (last_cursor_ != new_cursor) 1199 if (last_cursor_ != new_cursor)
1196 window_->SetPredefinedCursor(new_cursor); 1200 window_->SetPredefinedCursor(new_cursor);
1197 } 1201 }
1198 1202
1199 bool NativeWidgetMus::IsMouseEventsEnabled() const { 1203 bool NativeWidgetMus::IsMouseEventsEnabled() const {
1200 // NOTIMPLEMENTED(); 1204 NOTIMPLEMENTED();
1201 return true; 1205 return true;
1202 } 1206 }
1203 1207
1204 void NativeWidgetMus::ClearNativeFocus() { 1208 void NativeWidgetMus::ClearNativeFocus() {
1205 if (!IsActive()) 1209 if (!IsActive())
1206 return; 1210 return;
1207 ui::Window* focused = 1211 ui::Window* focused =
1208 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr; 1212 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr;
1209 if (focused && window_->Contains(focused) && focused != window_) 1213 if (focused && window_->Contains(focused) && focused != window_)
1210 window_->SetFocus(); 1214 window_->SetFocus();
1211 // Move aura-focus back to |content_|, so that the Widget still receives 1215 // Move aura-focus back to |content_|, so that the Widget still receives
1212 // events correctly. 1216 // events correctly.
1213 aura::client::GetFocusClient(content_)->ResetFocusWithinActiveWindow( 1217 aura::client::GetFocusClient(content_)->ResetFocusWithinActiveWindow(
1214 content_); 1218 content_);
1215 } 1219 }
1216 1220
1217 gfx::Rect NativeWidgetMus::GetWorkAreaBoundsInScreen() const { 1221 gfx::Rect NativeWidgetMus::GetWorkAreaBoundsInScreen() const {
1218 // NOTIMPLEMENTED(); 1222 NOTIMPLEMENTED();
1219 return gfx::Rect(); 1223 return gfx::Rect();
1220 } 1224 }
1221 1225
1222 Widget::MoveLoopResult NativeWidgetMus::RunMoveLoop( 1226 Widget::MoveLoopResult NativeWidgetMus::RunMoveLoop(
1223 const gfx::Vector2d& drag_offset, 1227 const gfx::Vector2d& drag_offset,
1224 Widget::MoveLoopSource source, 1228 Widget::MoveLoopSource source,
1225 Widget::MoveLoopEscapeBehavior escape_behavior) { 1229 Widget::MoveLoopEscapeBehavior escape_behavior) {
1226 ReleaseCapture(); 1230 ReleaseCapture();
1227 1231
1228 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); 1232 base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
(...skipping 15 matching lines...) Expand all
1244 run_loop.Run(); 1248 run_loop.Run();
1245 1249
1246 return success ? Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; 1250 return success ? Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED;
1247 } 1251 }
1248 1252
1249 void NativeWidgetMus::EndMoveLoop() { 1253 void NativeWidgetMus::EndMoveLoop() {
1250 window_->CancelWindowMove(); 1254 window_->CancelWindowMove();
1251 } 1255 }
1252 1256
1253 void NativeWidgetMus::SetVisibilityChangedAnimationsEnabled(bool value) { 1257 void NativeWidgetMus::SetVisibilityChangedAnimationsEnabled(bool value) {
1254 // NOTIMPLEMENTED(); 1258 NOTIMPLEMENTED();
1255 } 1259 }
1256 1260
1257 void NativeWidgetMus::SetVisibilityAnimationDuration( 1261 void NativeWidgetMus::SetVisibilityAnimationDuration(
1258 const base::TimeDelta& duration) { 1262 const base::TimeDelta& duration) {
1259 // NOTIMPLEMENTED(); 1263 NOTIMPLEMENTED();
1260 } 1264 }
1261 1265
1262 void NativeWidgetMus::SetVisibilityAnimationTransition( 1266 void NativeWidgetMus::SetVisibilityAnimationTransition(
1263 Widget::VisibilityTransition transition) { 1267 Widget::VisibilityTransition transition) {
1264 // NOTIMPLEMENTED(); 1268 NOTIMPLEMENTED();
1265 } 1269 }
1266 1270
1267 ui::NativeTheme* NativeWidgetMus::GetNativeTheme() const { 1271 ui::NativeTheme* NativeWidgetMus::GetNativeTheme() const {
1268 return ui::NativeThemeAura::instance(); 1272 return ui::NativeThemeAura::instance();
1269 } 1273 }
1270 1274
1271 void NativeWidgetMus::OnRootViewLayout() { 1275 void NativeWidgetMus::OnRootViewLayout() {
1272 // NOTIMPLEMENTED(); 1276 NOTIMPLEMENTED();
1273 } 1277 }
1274 1278
1275 bool NativeWidgetMus::IsTranslucentWindowOpacitySupported() const { 1279 bool NativeWidgetMus::IsTranslucentWindowOpacitySupported() const {
1276 // NOTIMPLEMENTED(); 1280 NOTIMPLEMENTED();
1277 return true; 1281 return true;
1278 } 1282 }
1279 1283
1280 void NativeWidgetMus::OnSizeConstraintsChanged() { 1284 void NativeWidgetMus::OnSizeConstraintsChanged() {
1281 if (!window_ || is_parallel_widget_in_window_manager()) 1285 if (!window_ || is_parallel_widget_in_window_manager())
1282 return; 1286 return;
1283 1287
1284 window_->SetSharedProperty<int32_t>( 1288 window_->SetSharedProperty<int32_t>(
1285 ui::mojom::WindowManager::kResizeBehavior_Property, 1289 ui::mojom::WindowManager::kResizeBehavior_Property,
1286 ResizeBehaviorFromDelegate(GetWidget()->widget_delegate())); 1290 ResizeBehaviorFromDelegate(GetWidget()->widget_delegate()));
1287 } 1291 }
1288 1292
1289 void NativeWidgetMus::RepostNativeEvent(gfx::NativeEvent native_event) { 1293 void NativeWidgetMus::RepostNativeEvent(gfx::NativeEvent native_event) {
1290 // NOTIMPLEMENTED(); 1294 NOTIMPLEMENTED();
1291 } 1295 }
1292 1296
1293 std::string NativeWidgetMus::GetName() const { 1297 std::string NativeWidgetMus::GetName() const {
1294 return window_->GetName(); 1298 return window_->GetName();
1295 } 1299 }
1296 1300
1297 //////////////////////////////////////////////////////////////////////////////// 1301 ////////////////////////////////////////////////////////////////////////////////
1298 // NativeWidgetMus, aura::WindowDelegate implementation: 1302 // NativeWidgetMus, aura::WindowDelegate implementation:
1299 1303
1300 gfx::Size NativeWidgetMus::GetMinimumSize() const { 1304 gfx::Size NativeWidgetMus::GetMinimumSize() const {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in); 1471 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in);
1468 // TODO(markdittmer): This should be this->OnEvent(event.get()), but that 1472 // TODO(markdittmer): This should be this->OnEvent(event.get()), but that
1469 // can't happen until IME is refactored out of in WindowTreeHostMus. 1473 // can't happen until IME is refactored out of in WindowTreeHostMus.
1470 platform_window_delegate()->DispatchEvent(event.get()); 1474 platform_window_delegate()->DispatchEvent(event.get());
1471 // NOTE: |this| may be deleted. 1475 // NOTE: |this| may be deleted.
1472 1476
1473 ack_handler.set_handled(event->handled()); 1477 ack_handler.set_handled(event->handled());
1474 // |ack_handler| acks the event on destruction if necessary. 1478 // |ack_handler| acks the event on destruction if necessary.
1475 } 1479 }
1476 1480
1477 void NativeWidgetMus::OnMusWindowVisibilityChanging(ui::Window* window) { 1481 void NativeWidgetMus::OnMusWindowVisibilityChanging(ui::Window* window,
1478 if (window == window_) { 1482 bool visible) {
1479 native_widget_delegate_->OnNativeWidgetVisibilityChanging( 1483 if (window == window_)
1480 !window->visible()); 1484 native_widget_delegate_->OnNativeWidgetVisibilityChanging(visible);
1481 }
1482 } 1485 }
1483 1486
1484 void NativeWidgetMus::OnMusWindowVisibilityChanged(ui::Window* window) { 1487 void NativeWidgetMus::OnMusWindowVisibilityChanged(ui::Window* window,
1488 bool visible) {
1485 if (window != window_) 1489 if (window != window_)
1486 return; 1490 return;
1487 1491
1488 if (window->visible()) { 1492 if (visible) {
1489 window_tree_host_->Show(); 1493 window_tree_host_->Show();
1490 GetNativeWindow()->Show(); 1494 GetNativeWindow()->Show();
1491 } else { 1495 } else {
1492 window_tree_host_->Hide(); 1496 window_tree_host_->Hide();
1493 GetNativeWindow()->Hide(); 1497 GetNativeWindow()->Hide();
1494 } 1498 }
1495 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); 1499 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible);
1496 } 1500 }
1497 1501
1498 void NativeWidgetMus::UpdateHitTestMask() { 1502 void NativeWidgetMus::UpdateHitTestMask() {
1499 // The window manager (or other underlay window provider) is not allowed to 1503 // The window manager (or other underlay window provider) is not allowed to
1500 // set a hit test mask, as that could interfere with a client app mask. 1504 // set a hit test mask, as that could interfere with a client app mask.
1501 if (is_parallel_widget_in_window_manager()) 1505 if (is_parallel_widget_in_window_manager())
1502 return; 1506 return;
1503 1507
1504 if (!native_widget_delegate_->HasHitTestMask()) { 1508 if (!native_widget_delegate_->HasHitTestMask()) {
1505 window_->ClearHitTestMask(); 1509 window_->ClearHitTestMask();
1506 return; 1510 return;
1507 } 1511 }
1508 1512
1509 gfx::Path mask_path; 1513 gfx::Path mask_path;
1510 native_widget_delegate_->GetHitTestMask(&mask_path); 1514 native_widget_delegate_->GetHitTestMask(&mask_path);
1511 // TODO(jamescook): Use the full path for the mask. 1515 // TODO(jamescook): Use the full path for the mask.
1512 gfx::Rect mask_rect = 1516 gfx::Rect mask_rect =
1513 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); 1517 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1514 window_->SetHitTestMask(mask_rect); 1518 window_->SetHitTestMask(mask_rect);
1515 } 1519 }
1516 1520
1517 } // namespace views 1521 } // namespace views
OLDNEW
« services/ui/public/cpp/window_observer.h ('K') | « ui/views/mus/native_widget_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698