Commit b27ad88f authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

[Mac] Stop tabs dragged out of a fullscreen window from immediately entering fullscreen.

- Adds Widget::SetFullscreenAuxiliary(), which sets
  NSWindowCollectionBehaviorFullScreenAuxiliary and lets the dragging
  window exist in another window's fullscreen space.

- Sets that flag when tab dragging starts, clears it when dragging ends, and
  makes the new window fullscreen if the source was fullscreen.

Bug: 883910
Change-Id: I8889135320a0fb26abff9b546c5f5444ba6f4486
Reviewed-on: https://chromium-review.googlesource.com/c/1484491
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Auto-Submit: Sidney San Martín <sdy@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636278}
parent b6beb95c
...@@ -1282,6 +1282,7 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop( ...@@ -1282,6 +1282,7 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop(
Detach(can_release_capture_ ? RELEASE_CAPTURE : DONT_RELEASE_CAPTURE); Detach(can_release_capture_ ? RELEASE_CAPTURE : DONT_RELEASE_CAPTURE);
dragged_widget->SetCanAppearInExistingFullscreenSpaces(true);
dragged_widget->SetVisibilityChangedAnimationsEnabled(false); dragged_widget->SetVisibilityChangedAnimationsEnabled(false);
Attach(dragged_browser_view->tabstrip(), gfx::Point()); Attach(dragged_browser_view->tabstrip(), gfx::Point());
AdjustBrowserAndTabBoundsForDrag(last_tabstrip_width, AdjustBrowserAndTabBoundsForDrag(last_tabstrip_width,
...@@ -1441,6 +1442,7 @@ void TabDragController::EndDragImpl(EndDragType type) { ...@@ -1441,6 +1442,7 @@ void TabDragController::EndDragImpl(EndDragType type) {
RestoreFocus(); RestoreFocus();
} }
GetAttachedBrowserWidget()->SetCanAppearInExistingFullscreenSpaces(false);
if (type == CANCELED) if (type == CANCELED)
RevertDrag(); RevertDrag();
else else
...@@ -1669,6 +1671,10 @@ void TabDragController::CompleteDrag() { ...@@ -1669,6 +1671,10 @@ void TabDragController::CompleteDrag() {
void TabDragController::MaximizeAttachedWindow() { void TabDragController::MaximizeAttachedWindow() {
GetAttachedBrowserWidget()->Maximize(); GetAttachedBrowserWidget()->Maximize();
#if defined(OS_MACOSX)
if (was_source_fullscreen_)
GetAttachedBrowserWidget()->SetFullscreen(true);
#endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (was_source_fullscreen_) { if (was_source_fullscreen_) {
// In fullscreen mode it is only possible to get here if the source // In fullscreen mode it is only possible to get here if the source
......
...@@ -34,6 +34,8 @@ namespace gfx { ...@@ -34,6 +34,8 @@ namespace gfx {
void SetNSWindowCanFullscreen(NSWindow* window, bool allow_fullscreen) { void SetNSWindowCanFullscreen(NSWindow* window, bool allow_fullscreen) {
NSWindowCollectionBehavior behavior = [window collectionBehavior]; NSWindowCollectionBehavior behavior = [window collectionBehavior];
if (behavior & NSWindowCollectionBehaviorFullScreenAuxiliary)
return;
if (allow_fullscreen) if (allow_fullscreen)
behavior |= NSWindowCollectionBehaviorFullScreenPrimary; behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
else else
......
...@@ -876,6 +876,9 @@ bool DesktopNativeWidgetAura::IsFullscreen() const { ...@@ -876,6 +876,9 @@ bool DesktopNativeWidgetAura::IsFullscreen() const {
return content_window_ && desktop_window_tree_host_->IsFullscreen(); return content_window_ && desktop_window_tree_host_->IsFullscreen();
} }
void DesktopNativeWidgetAura::SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) {}
void DesktopNativeWidgetAura::SetOpacity(float opacity) { void DesktopNativeWidgetAura::SetOpacity(float opacity) {
if (content_window_) if (content_window_)
desktop_window_tree_host_->SetOpacity(opacity); desktop_window_tree_host_->SetOpacity(opacity);
......
...@@ -162,6 +162,8 @@ class VIEWS_EXPORT DesktopNativeWidgetAura ...@@ -162,6 +162,8 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
void Restore() override; void Restore() override;
void SetFullscreen(bool fullscreen) override; void SetFullscreen(bool fullscreen) override;
bool IsFullscreen() const override; bool IsFullscreen() const override;
void SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) override;
void SetOpacity(float opacity) override; void SetOpacity(float opacity) override;
void SetAspectRatio(const gfx::SizeF& aspect_ratio) override; void SetAspectRatio(const gfx::SizeF& aspect_ratio) override;
void FlashFrame(bool flash_frame) override; void FlashFrame(bool flash_frame) override;
......
...@@ -663,6 +663,9 @@ bool NativeWidgetAura::IsFullscreen() const { ...@@ -663,6 +663,9 @@ bool NativeWidgetAura::IsFullscreen() const {
ui::SHOW_STATE_FULLSCREEN; ui::SHOW_STATE_FULLSCREEN;
} }
void NativeWidgetAura::SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) {}
void NativeWidgetAura::SetOpacity(float opacity) { void NativeWidgetAura::SetOpacity(float opacity) {
if (window_) if (window_)
window_->layer()->SetOpacity(opacity); window_->layer()->SetOpacity(opacity);
......
...@@ -123,6 +123,8 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, ...@@ -123,6 +123,8 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
void Restore() override; void Restore() override;
void SetFullscreen(bool fullscreen) override; void SetFullscreen(bool fullscreen) override;
bool IsFullscreen() const override; bool IsFullscreen() const override;
void SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) override;
void SetOpacity(float opacity) override; void SetOpacity(float opacity) override;
void SetAspectRatio(const gfx::SizeF& aspect_ratio) override; void SetAspectRatio(const gfx::SizeF& aspect_ratio) override;
void FlashFrame(bool flash_frame) override; void FlashFrame(bool flash_frame) override;
......
...@@ -140,6 +140,8 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { ...@@ -140,6 +140,8 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
void Restore() override; void Restore() override;
void SetFullscreen(bool fullscreen) override; void SetFullscreen(bool fullscreen) override;
bool IsFullscreen() const override; bool IsFullscreen() const override;
void SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) override;
void SetOpacity(float opacity) override; void SetOpacity(float opacity) override;
void SetAspectRatio(const gfx::SizeF& aspect_ratio) override; void SetAspectRatio(const gfx::SizeF& aspect_ratio) override;
void FlashFrame(bool flash_frame) override; void FlashFrame(bool flash_frame) override;
......
...@@ -506,6 +506,14 @@ bool NativeWidgetMac::IsFullscreen() const { ...@@ -506,6 +506,14 @@ bool NativeWidgetMac::IsFullscreen() const {
return bridge_host_ && bridge_host_->target_fullscreen_state(); return bridge_host_ && bridge_host_->target_fullscreen_state();
} }
void NativeWidgetMac::SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) {
if (!bridge())
return;
bridge()->SetCanAppearInExistingFullscreenSpaces(
can_appear_in_existing_fullscreen_spaces);
}
void NativeWidgetMac::SetOpacity(float opacity) { void NativeWidgetMac::SetOpacity(float opacity) {
if (!bridge()) if (!bridge())
return; return;
......
...@@ -202,6 +202,8 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget { ...@@ -202,6 +202,8 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
virtual void Restore() = 0; virtual void Restore() = 0;
virtual void SetFullscreen(bool fullscreen) = 0; virtual void SetFullscreen(bool fullscreen) = 0;
virtual bool IsFullscreen() const = 0; virtual bool IsFullscreen() const = 0;
virtual void SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) = 0;
virtual void SetOpacity(float opacity) = 0; virtual void SetOpacity(float opacity) = 0;
virtual void SetAspectRatio(const gfx::SizeF& aspect_ratio) = 0; virtual void SetAspectRatio(const gfx::SizeF& aspect_ratio) = 0;
virtual void FlashFrame(bool flash) = 0; virtual void FlashFrame(bool flash) = 0;
......
...@@ -728,6 +728,12 @@ bool Widget::IsFullscreen() const { ...@@ -728,6 +728,12 @@ bool Widget::IsFullscreen() const {
return native_widget_->IsFullscreen(); return native_widget_->IsFullscreen();
} }
void Widget::SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) {
native_widget_->SetCanAppearInExistingFullscreenSpaces(
can_appear_in_existing_fullscreen_spaces);
}
void Widget::SetOpacity(float opacity) { void Widget::SetOpacity(float opacity) {
DCHECK(opacity >= 0.0f); DCHECK(opacity >= 0.0f);
DCHECK(opacity <= 1.0f); DCHECK(opacity <= 1.0f);
......
...@@ -555,6 +555,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, ...@@ -555,6 +555,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
void SetFullscreen(bool fullscreen); void SetFullscreen(bool fullscreen);
bool IsFullscreen() const; bool IsFullscreen() const;
// macOS: Sets whether the window can share fullscreen windows' spaces.
void SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces);
// Sets the opacity of the widget. This may allow widgets behind the widget // Sets the opacity of the widget. This may allow widgets behind the widget
// in the Z-order to become visible, depending on the capabilities of the // in the Z-order to become visible, depending on the capabilities of the
// underlying windowing system. // underlying windowing system.
......
...@@ -221,6 +221,8 @@ class VIEWS_EXPORT BridgedNativeWidgetImpl ...@@ -221,6 +221,8 @@ class VIEWS_EXPORT BridgedNativeWidgetImpl
views_bridge_mac::mojom::VisibilityTransition transitions) override; views_bridge_mac::mojom::VisibilityTransition transitions) override;
void SetVisibleOnAllSpaces(bool always_visible) override; void SetVisibleOnAllSpaces(bool always_visible) override;
void SetFullscreen(bool fullscreen) override; void SetFullscreen(bool fullscreen) override;
void SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) override;
void SetMiniaturized(bool miniaturized) override; void SetMiniaturized(bool miniaturized) override;
void SetSizeConstraints(const gfx::Size& min_size, void SetSizeConstraints(const gfx::Size& min_size,
const gfx::Size& max_size, const gfx::Size& max_size,
......
...@@ -1114,6 +1114,19 @@ void BridgedNativeWidgetImpl::SetFullscreen(bool fullscreen) { ...@@ -1114,6 +1114,19 @@ void BridgedNativeWidgetImpl::SetFullscreen(bool fullscreen) {
ToggleDesiredFullscreenState(); ToggleDesiredFullscreenState();
} }
void BridgedNativeWidgetImpl::SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) {
NSWindow* window = window_.get();
NSWindowCollectionBehavior collectionBehavior = window.collectionBehavior;
if (can_appear_in_existing_fullscreen_spaces) {
collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
} else {
collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary;
}
window.collectionBehavior = collectionBehavior;
}
void BridgedNativeWidgetImpl::SetMiniaturized(bool miniaturized) { void BridgedNativeWidgetImpl::SetMiniaturized(bool miniaturized) {
if (miniaturized) { if (miniaturized) {
// Calling performMiniaturize: will momentarily highlight the button, but // Calling performMiniaturize: will momentarily highlight the button, but
......
...@@ -153,6 +153,11 @@ interface BridgedNativeWidget { ...@@ -153,6 +153,11 @@ interface BridgedNativeWidget {
// fullscreen state. // fullscreen state.
SetFullscreen(bool fullscreen); SetFullscreen(bool fullscreen);
// Called by NativeWidgetMac; sets whether the window can share fullscreen
// windows' spaces by changing the NSWindow's collectionBehavior.
SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces);
// Miniaturize or deminiaturize the window. // Miniaturize or deminiaturize the window.
SetMiniaturized(bool miniaturized); SetMiniaturized(bool miniaturized);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment