Skip to content

Commit

Permalink
[Windows] Remove app cut at the bottom and force refresh when back fr…
Browse files Browse the repository at this point in the history
…om fullscreen (#359)

- Removes the line that `cuts the app at the bottom by the pixel to prevent jitter when resizing app`
- Remove the line that `cuts the app by 3 pixels at the bottom when full screen`
- Fixes #311, #266, #228, #355, #237
  • Loading branch information
wisetarman authored Jul 1, 2023
1 parent 64c058e commit 88f2842
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions example/windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
// Version
//

#ifdef FLUTTER_BUILD_NUMBER
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
#else
#define VERSION_AS_NUMBER 1,0,0
#define VERSION_AS_NUMBER 1,0,0,0
#endif

#ifdef FLUTTER_BUILD_NAME
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
#if defined(FLUTTER_VERSION)
#define VERSION_AS_STRING FLUTTER_VERSION
#else
#define VERSION_AS_STRING "1.0.0"
#endif
Expand Down
7 changes: 7 additions & 0 deletions lib/src/window_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ class WindowManager {
'isFullScreen': isFullScreen,
};
await _channel.invokeMethod('setFullScreen', arguments);
// (Windows) Force refresh the app so it 's back to the correct size
// (see GitHub issue #311)
if (!isFullScreen && Platform.isWindows) {
final size = await getSize();
setSize(size + const Offset(1, 1));
setSize(size);
}
}

/// This will make a window maintain an aspect ratio.
Expand Down
5 changes: 0 additions & 5 deletions windows/window_manager_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd,
// This must always be first or else the one of other two ifs will execute
// when window is in full screen and we don't want that
if (wParam && window_manager->IsFullScreen()) {
NCCALCSIZE_PARAMS* sz = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
sz->rgrc[0].bottom -= 3;
return 0;
}

Expand All @@ -132,9 +130,6 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd,
sz->rgrc[0].right -= 8;
sz->rgrc[0].bottom -= 9;
}
// This cuts the app at the bottom by one pixel but that's necessary to
// prevent jitter when resizing the app
sz->rgrc[0].bottom += 1;
return 0;
}

Expand Down

0 comments on commit 88f2842

Please sign in to comment.