Skip to content

Commit 3f3e74a

Browse files
committed
windowstate: framework
1 parent e9b4825 commit 3f3e74a

File tree

1 file changed

+48
-36
lines changed

1 file changed

+48
-36
lines changed

packages/flutter/lib/src/widgets/window_win32.dart

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,44 @@ class RegularWindowControllerWin32 extends RegularWindowController
143143
ffi.calloc.free(ffiSizing);
144144
}
145145

146+
@override
147+
bool isFullscreen() {
148+
return false;
149+
}
150+
151+
@override
152+
void setFullscreen(bool fullscreen, {int? displayId}) {
153+
154+
}
155+
156+
@override
157+
bool isMaximized() {
158+
_ensureNotDestroyed();
159+
return _isZoomed(getWindowHandle()) != 0;
160+
}
161+
162+
@override
163+
bool isMinimized() {
164+
_ensureNotDestroyed();
165+
return _isIconic(getWindowHandle()) != 0;
166+
}
167+
168+
@override
169+
void minimize() {
170+
_ensureNotDestroyed();
171+
_showWindow(getWindowHandle(), SW_MINIMIZE);
172+
}
173+
174+
@override
175+
void setMaximized(bool maximized) {
176+
_ensureNotDestroyed();
177+
if (maximized) {
178+
_showWindow(getWindowHandle(), SW_MAXIMIZE);
179+
} else {
180+
_showWindow(getWindowHandle(), SW_RESTORE);
181+
}
182+
}
183+
146184
/// Returns HWND pointer to the top level window.
147185
Pointer<Void> getWindowHandle() {
148186
_ensureNotDestroyed();
@@ -172,6 +210,10 @@ class RegularWindowControllerWin32 extends RegularWindowController
172210
static const int _WM_SIZE = 0x0005;
173211
static const int _WM_CLOSE = 0x0010;
174212

213+
static const int SW_RESTORE = 9;
214+
static const int SW_MAXIMIZE = 3;
215+
static const int SW_MINIMIZE = 6;
216+
175217
@override
176218
int? handleWindowsMessage(
177219
FlutterView view,
@@ -209,50 +251,20 @@ class RegularWindowControllerWin32 extends RegularWindowController
209251
@Native<_Size Function(Pointer<Void>)>(symbol: 'FlutterGetWindowContentSize')
210252
external static _Size _getWindowContentSize(Pointer<Void> windowHandle);
211253

212-
@Native<Int64 Function(Pointer<Void>)>(symbol: 'FlutterGetWindowState')
213-
external static int _getWindowState(Pointer<Void> windowHandle);
214-
215-
@Native<Void Function(Pointer<Void>, Int64)>(symbol: 'FlutterSetWindowState')
216-
external static void _setWindowState(Pointer<Void> windowHandle, int state);
217-
218254
@Native<Void Function(Pointer<Void>, Pointer<ffi.Utf16>)>(symbol: 'SetWindowTextW')
219255
external static void _setWindowTitle(Pointer<Void> windowHandle, Pointer<ffi.Utf16> title);
220256

221257
@Native<Void Function(Pointer<Void>, Pointer<_Sizing>)>(symbol: 'FlutterSetWindowContentSize')
222258
external static void _setWindowContentSize(Pointer<Void> windowHandle, Pointer<_Sizing> size);
223259

224-
@override
225-
bool isFullscreen() {
226-
// TODO: implement isFullscreen
227-
throw UnimplementedError();
228-
}
260+
@Native<Void Function(Pointer<Void>, Int32)>(symbol: 'ShowWindow')
261+
external static void _showWindow(Pointer<Void> windowHandle, int command);
229262

230-
@override
231-
bool isMaximized() {
232-
// TODO: implement isMaximized
233-
throw UnimplementedError();
234-
}
263+
@Native<Int32 Function(Pointer<Void>)>(symbol: 'IsIconic')
264+
external static int _isIconic(Pointer<Void> windowHandle);
235265

236-
@override
237-
bool isMinimized() {
238-
// TODO: implement isMinimized
239-
throw UnimplementedError();
240-
}
241-
242-
@override
243-
void minimize() {
244-
// TODO: implement minimize
245-
}
246-
247-
@override
248-
void setFullscreen(bool fullscreen, {int? displayId}) {
249-
// TODO: implement setFullscreen
250-
}
251-
252-
@override
253-
void setMaximized(bool maximized) {
254-
// TODO: implement setMaximized
255-
}
266+
@Native<Int32 Function(Pointer<Void>)>(symbol: 'IsZoomed')
267+
external static int _isZoomed(Pointer<Void> windowHandle);
256268
}
257269

258270
/// Request to initialize windowing system.

0 commit comments

Comments
 (0)