Skip to content

Commit

Permalink
Window Placement: Disable fullscreen display swapping on Mac by default
Browse files Browse the repository at this point in the history
Swapping fullscreen displays is a minor feature of Window Placement API.
It isn't critical for most Window Placement API usage, but nice to have.

This functionality is currently broken on Mac, so disable it by default.
Gate fullscreen display changes on the WindowPlacementV2 flag on Mac.

(cherry picked from commit fe92101)

Fixed: 1303048
Test: Fullscreen display changes are not possible by default on Mac.
Change-Id: Ic604734ab80577ce52f6ccebea6b5308c0c86d8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3504029
Auto-Submit: Mike Wasserman <msw@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#977842}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3508339
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/4896@{#359}
Cr-Branched-From: 1f63ff4-refs/heads/main@{#972766}
  • Loading branch information
Mike Wasserman authored and Chromium LUCI CQ committed Mar 7, 2022
1 parent f7d2d73 commit ef7d1d8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions third_party/blink/renderer/core/frame/fullscreen_controller.cc
Expand Up @@ -47,6 +47,7 @@
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/spatial_navigation.h"
#include "third_party/blink/renderer/core/page/spatial_navigation_controller.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"

namespace blink {

Expand Down Expand Up @@ -146,17 +147,26 @@ void FullscreenController::EnterFullscreen(LocalFrame& frame,
FullscreenRequestType request_type) {
const auto& screen_info = frame.GetChromeClient().GetScreenInfo(frame);

bool requesting_other_screen =
const bool requesting_other_screen =
options->hasScreen() &&
options->screen()->DisplayId() != Screen::kInvalidDisplayId &&
options->screen()->DisplayId() != screen_info.display_id;
bool requesting_fullscreen_screen_change =
state_ == State::kFullscreen && requesting_other_screen;
#if BUILDFLAG(IS_MAC)
// Moving a fullscreen window from one screen to another is gated by the
// Window Placement V2 feature state on Mac. See crbug.com/1303048
requesting_fullscreen_screen_change &=
RuntimeEnabledFeatures::WindowPlacementV2Enabled(frame.DomWindow());
#endif // BUILDFLAG(IS_MAC)

// TODO(dtapuska): If we are already in fullscreen. If the options are
// different than the currently requested one we may wish to request
// fullscreen mode again.
// If already fullscreen or exiting fullscreen, synchronously call
// |DidEnterFullscreen()|. When exiting, the coming |DidExitFullscreen()| call
// will again notify all frames.
if ((state_ == State::kFullscreen && !requesting_other_screen) ||
if ((state_ == State::kFullscreen && !requesting_fullscreen_screen_change) ||
state_ == State::kExitingFullscreen) {
State old_state = state_;
state_ = State::kEnteringFullscreen;
Expand All @@ -179,8 +189,7 @@ void FullscreenController::EnterFullscreen(LocalFrame& frame,
return;
}

DCHECK(state_ == State::kInitial ||
state_ == State::kFullscreen && requesting_other_screen);
DCHECK(state_ == State::kInitial || requesting_fullscreen_screen_change);
auto fullscreen_options = ToMojoOptions(&frame, options, request_type);

#if DCHECK_IS_ON()
Expand Down

0 comments on commit ef7d1d8

Please sign in to comment.