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

Side by Side Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 2312133002: MacViews: Fix flashing of opaque non-modal windows on display. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #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
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // If the parent (or an ancestor) is hidden, return and wait for it to become 564 // If the parent (or an ancestor) is hidden, return and wait for it to become
565 // visible. 565 // visible.
566 if (parent() && !parent()->IsVisibleParent()) 566 if (parent() && !parent()->IsVisibleParent())
567 return; 567 return;
568 568
569 if (native_widget_mac_->IsWindowModalSheet()) { 569 if (native_widget_mac_->IsWindowModalSheet()) {
570 ShowAsModalSheet(); 570 ShowAsModalSheet();
571 return; 571 return;
572 } 572 }
573 573
574 // Non-modal windows are not animated. Hence opaque non-modal windows can
575 // appear with a "flash" if they are made visible before the frame from the
576 // compositor arrives. To get around this, set the alpha value of the window
577 // to 0, till we receive the correct frame from the compositor. Also, ignore
578 // mouse clicks till then.
579 // TODO(karandeepb): Investigate whether similar technique is needed for other
580 // dialog types.
581 if ([window_ isOpaque] && !native_widget_mac_->GetWidget()->IsModal()) {
582 initial_visibility_suppressed_ = true;
583 [window_ setAlphaValue:0.0];
584 [window_ setIgnoresMouseEvents:YES];
585 }
586
574 if (new_state == SHOW_AND_ACTIVATE_WINDOW) { 587 if (new_state == SHOW_AND_ACTIVATE_WINDOW) {
575 [window_ makeKeyAndOrderFront:nil]; 588 [window_ makeKeyAndOrderFront:nil];
576 [NSApp activateIgnoringOtherApps:YES]; 589 [NSApp activateIgnoringOtherApps:YES];
577 } else { 590 } else {
578 // ui::SHOW_STATE_INACTIVE is typically used to avoid stealing focus from a 591 // ui::SHOW_STATE_INACTIVE is typically used to avoid stealing focus from a
579 // parent window. So, if there's a parent, order above that. Otherwise, this 592 // parent window. So, if there's a parent, order above that. Otherwise, this
580 // will order above all windows at the same level. 593 // will order above all windows at the same level.
581 NSInteger parent_window_number = 0; 594 NSInteger parent_window_number = 0;
582 if (parent_) 595 if (parent_)
583 parent_window_number = [parent_->GetNSWindow() windowNumber]; 596 parent_window_number = [parent_->GetNSWindow() windowNumber];
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 *timebase = base::TimeTicks(); 1106 *timebase = base::TimeTicks();
1094 *interval = base::TimeDelta(); 1107 *interval = base::TimeDelta();
1095 } 1108 }
1096 1109
1097 void BridgedNativeWidget::AcceleratedWidgetSwapCompleted() { 1110 void BridgedNativeWidget::AcceleratedWidgetSwapCompleted() {
1098 // Ignore frames arriving "late" for an old size. A frame at the new size 1111 // Ignore frames arriving "late" for an old size. A frame at the new size
1099 // should arrive soon. 1112 // should arrive soon.
1100 if (!compositor_widget_->HasFrameOfSize(GetClientAreaSize())) 1113 if (!compositor_widget_->HasFrameOfSize(GetClientAreaSize()))
1101 return; 1114 return;
1102 1115
1116 if (initial_visibility_suppressed_) {
1117 initial_visibility_suppressed_ = false;
1118 [window_ setAlphaValue:1.0];
1119 [window_ setIgnoresMouseEvents:NO];
1120 }
1121
1103 if (invalidate_shadow_on_frame_swap_) { 1122 if (invalidate_shadow_on_frame_swap_) {
1104 invalidate_shadow_on_frame_swap_ = false; 1123 invalidate_shadow_on_frame_swap_ = false;
1105 [window_ invalidateShadow]; 1124 [window_ invalidateShadow];
1106 } 1125 }
1107 } 1126 }
1108 1127
1109 //////////////////////////////////////////////////////////////////////////////// 1128 ////////////////////////////////////////////////////////////////////////////////
1110 // BridgedNativeWidget, BridgedNativeWidgetOwner: 1129 // BridgedNativeWidget, BridgedNativeWidgetOwner:
1111 1130
1112 NSWindow* BridgedNativeWidget::GetNSWindow() { 1131 NSWindow* BridgedNativeWidget::GetNSWindow() {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 [bridged_view_ setMouseDownCanMoveWindow:draggable]; 1384 [bridged_view_ setMouseDownCanMoveWindow:draggable];
1366 // AppKit will not update its cache of mouseDownCanMoveWindow unless something 1385 // AppKit will not update its cache of mouseDownCanMoveWindow unless something
1367 // changes. Previously we tried adding an NSView and removing it, but for some 1386 // changes. Previously we tried adding an NSView and removing it, but for some
1368 // reason it required reposting the mouse-down event, and didn't always work. 1387 // reason it required reposting the mouse-down event, and didn't always work.
1369 // Calling the below seems to be an effective solution. 1388 // Calling the below seems to be an effective solution.
1370 [window_ setMovableByWindowBackground:NO]; 1389 [window_ setMovableByWindowBackground:NO];
1371 [window_ setMovableByWindowBackground:YES]; 1390 [window_ setMovableByWindowBackground:YES];
1372 } 1391 }
1373 1392
1374 } // namespace views 1393 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698