summaryrefslogtreecommitdiffstats
path: root/chromium/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm')
-rw-r--r--chromium/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm163
1 files changed, 5 insertions, 158 deletions
diff --git a/chromium/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/chromium/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
index 517333705c9..6e837d66209 100644
--- a/chromium/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
+++ b/chromium/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm
@@ -10,7 +10,6 @@
#include "base/mac/mac_util.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/trace_event/trace_event.h"
-#import "components/remote_cocoa/app_shim/browser_native_widget_window_mac.h"
#import "components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"
#include "components/remote_cocoa/app_shim/native_widget_ns_window_host_helper.h"
#import "components/remote_cocoa/app_shim/views_nswindow_delegate.h"
@@ -99,17 +98,6 @@ void OrderChildWindow(NSWindow* child_window,
}
}
-// A struct to record child window ordering commands.
-struct ChildWindowOrderingCommand {
- NSWindowOrderingMode windowOrderingMode;
- NSInteger otherWindowNumber;
-
- bool operator!=(const ChildWindowOrderingCommand& other) const {
- return this->windowOrderingMode != other.windowOrderingMode ||
- this->otherWindowNumber != other.otherWindowNumber;
- }
-};
-
} // namespace
@interface NSWindow (Private)
@@ -133,16 +121,6 @@ struct ChildWindowOrderingCommand {
// Private API on NSWindow, determines whether the title is drawn on the title
// bar. The title is still visible in menus, Expose, etc.
- (BOOL)_isTitleHidden;
-
-// Completes the processing of child windows whose removal or ordering was
-// deferred while we were fullscreen and not in the active space.
-- (void)processDeferredChildWindowOperations;
-
-// Executes any window ordering commands that were requested while the child
-// window was not on the active space. We collect them rather than execute
-// them to avoid triggering a Space change.
-- (void)processChildWindowOrderingCommands;
-
@end
// Use this category to implement mouseDown: on multiple frame view classes
@@ -192,8 +170,6 @@ struct ChildWindowOrderingCommand {
CommandDispatcher* __strong _commandDispatcher;
id<UserInterfaceItemCommandHandler> __strong _commandHandler;
id<WindowTouchBarDelegate> __weak _touchBarDelegate;
- NSMutableArray<NSWindow*>* _childWindowsToRemove;
- std::vector<ChildWindowOrderingCommand> _windowOrderingCommands;
uint64_t _bridgedNativeWidgetId;
// This field is not a raw_ptr<> because it requires @property rewrite.
RAW_PTR_EXCLUSION remote_cocoa::NativeWidgetNSWindowBridge* _bridge;
@@ -204,7 +180,6 @@ struct ChildWindowOrderingCommand {
BOOL _isHeadless;
BOOL _isShufflingForOrdering;
BOOL _miniaturizationInProgress;
- BOOL _isOrderingOut;
}
@synthesize bridgedNativeWidgetId = _bridgedNativeWidgetId;
@synthesize bridge = _bridge;
@@ -266,31 +241,13 @@ struct ChildWindowOrderingCommand {
}
}
-// Overridden to ensure that removing a child window does not trigger a Space
-// change, and to perform post-removal operations.
-- (void)removeChildWindow:(NSWindow*)childWindow {
- if (self != childWindow.parentWindow) {
+- (void)removeChildWindow:(NSWindow*)childWin {
+ if (self != childWin.parentWindow) {
return;
}
-
- // For any non-Chrome windows (i.e. those created by the frameworks),
- // remove as usual. Also continue as usual if we're on the active space,
- // or we happen to be a child of another window.
- if (![childWindow isKindOfClass:[NativeWidgetMacNSWindow class]] ||
- [self isOnActiveSpace] || [self parentWindow] != nil) {
- [super removeChildWindow:childWindow];
- } else {
- // Defer removal to avoid triggering a space change.
- [self removeChildWindowOnActivation:childWindow];
- }
-
- // If there's a windowRemoved handler, we'll call it even if we've deferred
- // the actual NSWindow removal via -removeChildWindowOnActivation:. As far as
- // Chrome is concerned, the child window no longer exists (for example, it's
- // no longer in self.ordered_children). The removeChildWindow: that finally
- // removes the child will happen at some future date.
+ [super removeChildWindow:childWin];
if (self.childWindowRemovedHandler) {
- self.childWindowRemovedHandler(childWindow);
+ self.childWindowRemovedHandler(childWin);
}
}
@@ -523,21 +480,6 @@ struct ChildWindowOrderingCommand {
return;
}
- // Calling OrderChildWindow() when we're not on the active Space will
- // will trigger a Space switch. Instead, save the window ordering command
- // until we're on the active space.
- if (![self isOnActiveSpace]) {
- ChildWindowOrderingCommand newCommand = {orderingMode, otherWindowNumber};
-
- // Add the command, but ignore any repeats of the last command in the list.
- if (_windowOrderingCommands.empty() ||
- _windowOrderingCommands.back() != newCommand) {
- _windowOrderingCommands.push_back(newCommand);
- }
-
- return;
- }
-
base::AutoReset<BOOL> shuffling(&_isShufflingForOrdering, YES);
// `otherWindow` is nil if `otherWindowNumber` is 0. In this case, place
@@ -607,25 +549,7 @@ struct ChildWindowOrderingCommand {
- (void)orderOut:(id)sender {
_miniaturizationInProgress = NO;
- _isOrderingOut = YES;
-
- // If we're a child window and our parent is not on the active space,
- // arrange for our removal after our parent becomes the active window
- // to avoid triggering a Space switch.
- NativeWidgetMacNSWindow* parentWindow =
- base::apple::ObjCCast<NativeWidgetMacNSWindow>([self parentWindow]);
- if (parentWindow != nil && ![parentWindow isOnActiveSpace]) {
- [parentWindow removeChildWindowOnActivation:self];
- } else {
- [self processDeferredChildWindowOperations];
-
- // Throw away our own ordering commands (if we have any).
- _windowOrderingCommands.clear();
-
- [super orderOut:sender];
- }
-
- _isOrderingOut = NO;
+ [super orderOut:sender];
}
// NSResponder implementation.
@@ -818,81 +742,4 @@ struct ChildWindowOrderingCommand {
return nil;
}
-- (BOOL)isFullScreen {
- return (self.styleMask & NSWindowStyleMaskFullScreen) ==
- NSWindowStyleMaskFullScreen;
-}
-
-- (void)removeChildWindowOnActivation:(NSWindow*)childWindow {
- if (_childWindowsToRemove == nil) {
- _childWindowsToRemove = [[NSMutableArray alloc] init];
- }
-
- // Ignore if a duplicate request.
- if ([_childWindowsToRemove containsObject:childWindow]) {
- return;
- }
-
- // Hide `childWindow` by making it transparent and schedule it for deferred
- // removal.
- childWindow.alphaValue = 0.0;
- [_childWindowsToRemove addObject:childWindow];
-}
-
-- (BOOL)willRemoveChildWindowOnActivation:(NSWindow*)aWindow {
- return [_childWindowsToRemove containsObject:aWindow];
-}
-
-- (BOOL)hasDeferredChildWindowRemovalsForTesting {
- return _childWindowsToRemove.count > 0;
-}
-
-- (BOOL)hasDeferredChildWindowOrderingCommandsForTesting {
- return !_windowOrderingCommands.empty();
-}
-
-- (void)processDeferredChildWindowOperations {
- // Remove any child windows where removal was pending.
- for (NSWindow* childWindow in _childWindowsToRemove) {
- [super removeChildWindow:childWindow];
- }
- [_childWindowsToRemove removeAllObjects];
-
- // Process any child window ordering commands, unless we're ordering out.
- if (_isOrderingOut) {
- return;
- }
-
- for (NSWindow* childWindow in self.childWindows) {
- NativeWidgetMacNSWindow* nativeWidgetMacNSWindow =
- base::apple::ObjCCast<NativeWidgetMacNSWindow>(childWindow);
-
- [nativeWidgetMacNSWindow
- performSelector:@selector(processChildWindowOrderingCommands)
- withObject:nil];
- }
-}
-
-- (void)processChildWindowOrderingCommands {
- for (const auto& command : _windowOrderingCommands) {
- [self orderWindowByShuffling:command.windowOrderingMode
- relativeTo:command.otherWindowNumber];
- }
- _windowOrderingCommands.clear();
-}
-
-- (void)becomeMainWindow {
- [super becomeMainWindow];
-
- [self processDeferredChildWindowOperations];
-}
-
-- (void)toggleFullScreen:(id)sender {
- [super toggleFullScreen:sender];
-
- // We're either entering fullscreen or exiting - either way, process the
- // deferred child window operations.
- [self processDeferredChildWindowOperations];
-}
-
@end