Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
|
tapted
2016/10/11 23:05:16
for the CL description, make sure you follow the g
| |
| 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 #import "ui/views/cocoa/bridged_native_widget.h" | 5 #import "ui/views/cocoa/bridged_native_widget.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 } | 545 } |
| 546 [window_ setContentView:bridged_view_]; | 546 [window_ setContentView:bridged_view_]; |
| 547 } | 547 } |
| 548 | 548 |
| 549 void BridgedNativeWidget::SetVisibilityState(WindowVisibilityState new_state) { | 549 void BridgedNativeWidget::SetVisibilityState(WindowVisibilityState new_state) { |
| 550 // Ensure that: | 550 // Ensure that: |
| 551 // - A window with an invisible parent is not made visible. | 551 // - A window with an invisible parent is not made visible. |
| 552 // - A parent changing visibility updates child window visibility. | 552 // - A parent changing visibility updates child window visibility. |
| 553 // * But only when changed via this function - ignore changes via the | 553 // * But only when changed via this function - ignore changes via the |
| 554 // NSWindow API, or changes propagating out from here. | 554 // NSWindow API, or changes propagating out from here. |
| 555 wants_to_be_visible_ = new_state != HIDE_WINDOW; | 555 const bool wants_to_be_visible = new_state != HIDE_WINDOW; |
| 556 if (wants_to_be_visible == wants_to_be_visible_) | |
| 557 return; | |
| 558 wants_to_be_visible_ = wants_to_be_visible; | |
| 556 | 559 |
| 557 if (new_state == HIDE_WINDOW) { | 560 if (new_state == HIDE_WINDOW) { |
| 558 [window_ orderOut:nil]; | 561 [window_ orderOut:nil]; |
| 559 DCHECK(!window_visible_); | 562 DCHECK(!window_visible_); |
| 560 return; | 563 return; |
| 561 } | 564 } |
| 562 | 565 |
| 563 DCHECK(wants_to_be_visible_); | 566 DCHECK(wants_to_be_visible_); |
| 564 // If the parent (or an ancestor) is hidden, return and wait for it to become | 567 // If the parent (or an ancestor) is hidden, return and wait for it to become |
| 565 // visible. | 568 // visible. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 580 // dialog types. | 583 // dialog types. |
| 581 if (layer() && [window_ isOpaque] && | 584 if (layer() && [window_ isOpaque] && |
| 582 !native_widget_mac_->GetWidget()->IsModal()) { | 585 !native_widget_mac_->GetWidget()->IsModal()) { |
| 583 initial_visibility_suppressed_ = true; | 586 initial_visibility_suppressed_ = true; |
| 584 [window_ setAlphaValue:0.0]; | 587 [window_ setAlphaValue:0.0]; |
| 585 [window_ setIgnoresMouseEvents:YES]; | 588 [window_ setIgnoresMouseEvents:YES]; |
| 586 } | 589 } |
| 587 | 590 |
| 588 if (new_state == SHOW_AND_ACTIVATE_WINDOW) { | 591 if (new_state == SHOW_AND_ACTIVATE_WINDOW) { |
| 589 [window_ makeKeyAndOrderFront:nil]; | 592 [window_ makeKeyAndOrderFront:nil]; |
| 590 [NSApp activateIgnoringOtherApps:YES]; | 593 [NSApp activateIgnoringOtherApps:YES]; |
|
tapted
2016/10/11 23:05:16
This line (and the line above) need to happen rega
| |
| 591 } else { | 594 } else { |
| 592 // ui::SHOW_STATE_INACTIVE is typically used to avoid stealing focus from a | 595 // ui::SHOW_STATE_INACTIVE is typically used to avoid stealing focus from a |
| 593 // parent window. So, if there's a parent, order above that. Otherwise, this | 596 // parent window. So, if there's a parent, order above that. Otherwise, this |
| 594 // will order above all windows at the same level. | 597 // will order above all windows at the same level. |
| 595 NSInteger parent_window_number = 0; | 598 NSInteger parent_window_number = 0; |
| 596 if (parent_) | 599 if (parent_) |
| 597 parent_window_number = [parent_->GetNSWindow() windowNumber]; | 600 parent_window_number = [parent_->GetNSWindow() windowNumber]; |
| 598 | 601 |
| 599 [window_ orderWindow:NSWindowAbove | 602 [window_ orderWindow:NSWindowAbove |
| 600 relativeTo:parent_window_number]; | 603 relativeTo:parent_window_number]; |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1390 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1393 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1391 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1394 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1392 // changes. Previously we tried adding an NSView and removing it, but for some | 1395 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1393 // reason it required reposting the mouse-down event, and didn't always work. | 1396 // reason it required reposting the mouse-down event, and didn't always work. |
| 1394 // Calling the below seems to be an effective solution. | 1397 // Calling the below seems to be an effective solution. |
| 1395 [window_ setMovableByWindowBackground:NO]; | 1398 [window_ setMovableByWindowBackground:NO]; |
| 1396 [window_ setMovableByWindowBackground:YES]; | 1399 [window_ setMovableByWindowBackground:YES]; |
| 1397 } | 1400 } |
| 1398 | 1401 |
| 1399 } // namespace views | 1402 } // namespace views |
| OLD | NEW |