mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: fullscreen windows aren't resizable on macOS (#34433)
* fix: fullscreen windows aren't resizable on macOS * chore: GetStyleMask -> HasStyleMask * chore: depreacate style names Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
This commit is contained in:
@@ -167,6 +167,7 @@ class NativeWindowMac : public NativeWindow,
|
||||
void UpdateVibrancyRadii(bool fullscreen);
|
||||
|
||||
// Set the attribute of NSWindow while work around a bug of zoom button.
|
||||
bool HasStyleMask(NSUInteger flag) const;
|
||||
void SetStyleMask(bool on, NSUInteger flag);
|
||||
void SetCollectionBehavior(bool on, NSUInteger flag);
|
||||
void SetWindowLevel(int level);
|
||||
|
||||
@@ -646,7 +646,7 @@ void NativeWindowMac::Unmaximize() {
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsMaximized() {
|
||||
if (([window_ styleMask] & NSWindowStyleMaskResizable) != 0)
|
||||
if (HasStyleMask(NSWindowStyleMaskResizable) != 0)
|
||||
return [window_ isZoomed];
|
||||
|
||||
NSRect rectScreen = GetAspectRatio() > 0.0
|
||||
@@ -729,7 +729,7 @@ void NativeWindowMac::SetFullScreen(bool fullscreen) {
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsFullscreen() const {
|
||||
return [window_ styleMask] & NSWindowStyleMaskFullScreen;
|
||||
return HasStyleMask(NSWindowStyleMaskFullScreen);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||
@@ -829,7 +829,10 @@ void NativeWindowMac::SetResizable(bool resizable) {
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsResizable() {
|
||||
return [window_ styleMask] & NSWindowStyleMaskResizable;
|
||||
bool in_fs_transition =
|
||||
fullscreen_transition_state() != FullScreenTransitionState::NONE;
|
||||
bool has_rs_mask = HasStyleMask(NSWindowStyleMaskResizable);
|
||||
return has_rs_mask && !IsFullscreen() && !in_fs_transition;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMovable(bool movable) {
|
||||
@@ -845,7 +848,7 @@ void NativeWindowMac::SetMinimizable(bool minimizable) {
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsMinimizable() {
|
||||
return [window_ styleMask] & NSWindowStyleMaskMiniaturizable;
|
||||
return HasStyleMask(NSWindowStyleMaskMiniaturizable);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetMaximizable(bool maximizable) {
|
||||
@@ -875,7 +878,7 @@ void NativeWindowMac::SetClosable(bool closable) {
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsClosable() {
|
||||
return [window_ styleMask] & NSWindowStyleMaskClosable;
|
||||
return HasStyleMask(NSWindowStyleMaskClosable);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAlwaysOnTop(ui::ZOrderLevel z_order,
|
||||
@@ -1383,8 +1386,7 @@ void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) {
|
||||
NSVisualEffectView* vibrantView = [window_ vibrantView];
|
||||
|
||||
if (vibrantView != nil && !vibrancy_type_.empty()) {
|
||||
const bool no_rounded_corner =
|
||||
!([window_ styleMask] & NSWindowStyleMaskTitled);
|
||||
const bool no_rounded_corner = !HasStyleMask(NSWindowStyleMaskTitled);
|
||||
if (!has_frame() && !is_modal() && !no_rounded_corner) {
|
||||
CGFloat radius;
|
||||
if (fullscreen) {
|
||||
@@ -1752,6 +1754,10 @@ void NativeWindowMac::OverrideNSWindowContentView() {
|
||||
AddContentViewLayers();
|
||||
}
|
||||
|
||||
bool NativeWindowMac::HasStyleMask(NSUInteger flag) const {
|
||||
return [window_ styleMask] & flag;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
|
||||
// Changing the styleMask of a frameless windows causes it to change size so
|
||||
// we explicitly disable resizing while setting it.
|
||||
|
||||
@@ -234,12 +234,14 @@ using FullScreenTransitionState =
|
||||
}
|
||||
|
||||
- (void)windowWillEnterFullScreen:(NSNotification*)notification {
|
||||
// Store resizable mask so it can be restored after exiting fullscreen.
|
||||
is_resizable_ = shell_->HasStyleMask(NSWindowStyleMaskResizable);
|
||||
|
||||
shell_->SetFullScreenTransitionState(FullScreenTransitionState::ENTERING);
|
||||
|
||||
shell_->NotifyWindowWillEnterFullScreen();
|
||||
|
||||
// Setting resizable to true before entering fullscreen.
|
||||
is_resizable_ = shell_->IsResizable();
|
||||
// Set resizable to true before entering fullscreen.
|
||||
shell_->SetResizable(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user