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

Side by Side Diff: components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm

Issue 2562653002: Mac: Fix window ordering for certificate viewer/selector sheets and overlays.
Patch Set: Switch to using NSFooWindowLevels. Created 4 years 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 | « chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/constrained_window/native_web_contents_modal_dialog_manager _views_mac.h" 5 #include "components/constrained_window/native_web_contents_modal_dialog_manager _views_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "components/constrained_window/constrained_window_views.h" 9 #include "components/constrained_window/constrained_window_views.h"
10 #include "components/guest_view/browser/guest_view_base.h" 10 #include "components/guest_view/browser/guest_view_base.h"
11 #include "components/web_modal/web_contents_modal_dialog_manager.h" 11 #include "components/web_modal/web_contents_modal_dialog_manager.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #import "ui/gfx/mac/coordinate_conversion.h" 13 #import "ui/gfx/mac/coordinate_conversion.h"
14 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
15 #include "ui/views/widget/widget_delegate.h" 15 #include "ui/views/widget/widget_delegate.h"
16 16
17 using web_modal::WebContentsModalDialogManager; 17 using web_modal::WebContentsModalDialogManager;
18 using web_modal::SingleWebContentsDialogManager; 18 using web_modal::SingleWebContentsDialogManager;
19 19
20 namespace { 20 namespace {
21 21
22 // Sets visibility and mouse events for a Cocoa NSWindow* and an attached sheet. 22 // Sets visibility and mouse events for a Cocoa NSWindow* and an attached sheet.
23 void SetSheetVisible(gfx::NativeWindow overlay, bool visible) { 23 void SetSheetVisible(gfx::NativeWindow overlay, bool visible) {
24 CGFloat alpha = visible ? 1.0 : 0.0;
25 BOOL ignore_events = visible ? NO : YES; 24 BOOL ignore_events = visible ? NO : YES;
26 25
27 // Don't allow interaction with the tab underneath the overlay. 26 // Don't allow interaction with the tab underneath the overlay.
28 [overlay setIgnoresMouseEvents:ignore_events]; 27 [overlay setIgnoresMouseEvents:ignore_events];
29 28
30 [[overlay attachedSheet] setAlphaValue:alpha]; 29 [[overlay attachedSheet] setAlphaValue:visible ? 1.0 : 0.0];
31 [[overlay attachedSheet] setIgnoresMouseEvents:ignore_events]; 30 [[overlay attachedSheet] setIgnoresMouseEvents:ignore_events];
31
32 // Make sure overlay layers for hidden Cocoa dialogs are always behind
33 // overlays which are in use. If they are not hidden, the attached sheet needs
34 // to be in front of its corresponding overlay window to accept mouse clicks.
35 [overlay setLevel:visible ? NSFloatingWindowLevel : NSNormalWindowLevel];
tapted 2016/12/11 23:28:20 I think NSFloatingWindowLevel would mean that drag
Patti Lor 2016/12/12 01:29:04 That works! Have done this for all three cases. Al
36 [[overlay attachedSheet]
37 setLevel:visible ? NSStatusWindowLevel : NSNormalWindowLevel];
32 } 38 }
33 39
34 } // namespace 40 } // namespace
35 41
36 namespace constrained_window { 42 namespace constrained_window {
37 43
38 NativeWebContentsModalDialogManagerViewsMac:: 44 NativeWebContentsModalDialogManagerViewsMac::
39 NativeWebContentsModalDialogManagerViewsMac( 45 NativeWebContentsModalDialogManagerViewsMac(
40 gfx::NativeWindow dialog, 46 gfx::NativeWindow dialog,
41 web_modal::SingleWebContentsDialogManagerDelegate* native_delegate) 47 web_modal::SingleWebContentsDialogManagerDelegate* native_delegate)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void NativeWebContentsModalDialogManagerViewsMac::HideWidget( 95 void NativeWebContentsModalDialogManagerViewsMac::HideWidget(
90 views::Widget* widget) { 96 views::Widget* widget) {
91 NSWindow* dialog_window = widget->GetNativeWindow(); 97 NSWindow* dialog_window = widget->GetNativeWindow();
92 // Avoid views::Widget::Hide(), as a call to orderOut: on a NSWindow with an 98 // Avoid views::Widget::Hide(), as a call to orderOut: on a NSWindow with an
93 // attached sheet will close the sheet. Instead, just set the sheet to 0 99 // attached sheet will close the sheet. Instead, just set the sheet to 0
94 // opacity and don't accept click events. 100 // opacity and don't accept click events.
95 SetSheetVisible(dialog_window, false); 101 SetSheetVisible(dialog_window, false);
96 } 102 }
97 103
98 } // namespace constrained_window 104 } // namespace constrained_window
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698