Skip to content

Electron 6, maximize/restore not working correctly #19423

Closed

Description

@t57ser

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 6.0.0-beta.15
  • Operating System:
    • Windows 10 64bit
  • Last Known Working Electron version:
    • 5.0.8

Expected Behavior

The window restores its size to what it used to be

Actual Behavior

The window is shown in the smallest size

To Reproduce

  1. Maximize Window
  2. Minimize Window
  3. Restore Window (click on the icon in the taskbar)
  4. Unmaximize Window

Screenshots

grafik

Activity

  1. pushkin- commented on Jul 31, 2019

    @pushkin-

    Confirmed that this is an issue in Electron 6 (stable)

  2. TomaszMa commented on Aug 15, 2019

    @TomaszMa
    Contributor

    This issue is regression after cbb5164

    Potential solution for it is:

    diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc
    index d6fd2ae58..a6033a0f9 100644
    --- a/atom/browser/native_window_views_win.cc
    +++ b/atom/browser/native_window_views_win.cc
    @@ -419,7 +419,8 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
           if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
             if (consecutive_moves_)
               last_normal_bounds_ = last_normal_bounds_candidate_;
    -        last_normal_bounds_candidate_ = GetBounds();
    +        last_normal_bounds_candidate_ = IsMaximized() ?
    +            widget()->GetRestoredBounds() : GetBounds();
             consecutive_moves_ = true;
           }
           return false;
    @@ -498,6 +499,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
               case ui::SHOW_STATE_MAXIMIZED:
                 last_window_state_ = ui::SHOW_STATE_NORMAL;
                 root_view_->SetInsets(gfx::Insets(0));
    +            SetBounds(last_normal_bounds_candidate_, false);
                 NotifyWindowUnmaximize();
                 break;
               case ui::SHOW_STATE_MINIMIZED:
    
    
    
  3. whyboris commented on Aug 18, 2019

    @whyboris

    Confirming can reproduce above stated error within my app on current master after upgrading from Electron 5 to Electron 6 -- whyboris/Video-Hub-App#260

    I opened a related issue #19816 -- simply minimizing and restoring a window causes the size to be (momentarily) set to the minWidth and minHeight specified in new BrowserWindow object.

    I suspect in your case you do not have a minimum set, hence it collapses to the smallest OS-permitted-minimum (?) as shown in your screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions