mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Feature: WindowToggleMaximise (#1159)
* [windows] Add WindowToggleMaximise * Add mac support * Update docs * [linux] Toggle Maximise
This commit is contained in:
@@ -30,6 +30,7 @@ void Fullscreen(void* ctx);
|
||||
void UnFullscreen(void* ctx);
|
||||
void Minimise(void* ctx);
|
||||
void UnMinimise(void* ctx);
|
||||
void ToggleMaximise(void* ctx);
|
||||
void Maximise(void* ctx);
|
||||
void UnMaximise(void* ctx);
|
||||
void Hide(void* ctx);
|
||||
|
||||
@@ -156,6 +156,13 @@ void Maximise(void* inctx) {
|
||||
);
|
||||
}
|
||||
|
||||
void ToggleMaximise(void* inctx) {
|
||||
WailsContext *ctx = (__bridge WailsContext*) inctx;
|
||||
ON_MAIN_THREAD(
|
||||
[ctx ToggleMaximise];
|
||||
);
|
||||
}
|
||||
|
||||
const char* GetSize(void *inctx) {
|
||||
WailsContext *ctx = (__bridge WailsContext*) inctx;
|
||||
NSRect frame = [ctx.mainWindow frame];
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
- (void) Minimise;
|
||||
- (void) UnMinimise;
|
||||
- (void) Maximise;
|
||||
- (void) ToggleMaximise;
|
||||
- (void) UnMaximise;
|
||||
- (void) SetRGBA:(int)r :(int)g :(int)b :(int)a;
|
||||
- (void) HideMouse;
|
||||
|
||||
@@ -322,11 +322,6 @@
|
||||
return (mask & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen;
|
||||
}
|
||||
|
||||
- (bool) isMaximised {
|
||||
long mask = [self.mainWindow styleMask];
|
||||
return (mask & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen;
|
||||
}
|
||||
|
||||
// Fullscreen sets the main window to be fullscreen
|
||||
- (void) Fullscreen {
|
||||
if( ! [self isFullScreen] ) {
|
||||
@@ -366,6 +361,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void) ToggleMaximise {
|
||||
[self.mainWindow zoom:nil];
|
||||
}
|
||||
|
||||
- (void) UnMaximise {
|
||||
if ([self.mainWindow isZoomed]) {
|
||||
[self.mainWindow zoom:nil];
|
||||
|
||||
@@ -181,6 +181,9 @@ func (f *Frontend) WindowHide() {
|
||||
func (f *Frontend) WindowMaximise() {
|
||||
f.mainWindow.Maximise()
|
||||
}
|
||||
func (f *Frontend) WindowToggleMaximise() {
|
||||
f.mainWindow.ToggleMaximise()
|
||||
}
|
||||
func (f *Frontend) WindowUnmaximise() {
|
||||
f.mainWindow.UnMaximise()
|
||||
}
|
||||
|
||||
@@ -154,6 +154,9 @@ func (w *Window) SetTitle(title string) {
|
||||
func (w *Window) Maximise() {
|
||||
C.Maximise(w.context)
|
||||
}
|
||||
func (w *Window) ToggleMaximise() {
|
||||
C.ToggleMaximise(w.context)
|
||||
}
|
||||
|
||||
func (w *Window) UnMaximise() {
|
||||
C.UnMaximise(w.context)
|
||||
|
||||
@@ -173,6 +173,9 @@ func (f *Frontend) WindowHide() {
|
||||
func (f *Frontend) WindowMaximise() {
|
||||
f.mainWindow.Maximise()
|
||||
}
|
||||
func (f *Frontend) WindowToggleMaximise() {
|
||||
f.mainWindow.ToggleMaximise()
|
||||
}
|
||||
func (f *Frontend) WindowUnmaximise() {
|
||||
f.mainWindow.UnMaximise()
|
||||
}
|
||||
|
||||
@@ -80,6 +80,13 @@ int IsFullscreen(GtkWidget *widget) {
|
||||
return state & GDK_WINDOW_STATE_FULLSCREEN == GDK_WINDOW_STATE_FULLSCREEN;
|
||||
}
|
||||
|
||||
int IsMaximised(GtkWidget *widget) {
|
||||
GdkWindow *gdkwindow = gtk_widget_get_window(widget);
|
||||
GdkWindowState state = gdk_window_get_state(GDK_WINDOW(gdkwindow));
|
||||
return state & GDK_WINDOW_STATE_MAXIMIZED;
|
||||
}
|
||||
|
||||
|
||||
extern void processMessage(char*);
|
||||
|
||||
static void sendMessageToBackend(WebKitUserContentManager *contentManager,
|
||||
@@ -673,6 +680,11 @@ func (w *Window) IsFullScreen() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *Window) IsMaximised() bool {
|
||||
result := C.IsMaximised(w.asGTKWidget())
|
||||
return result > 0
|
||||
}
|
||||
|
||||
func (w *Window) SetRGBA(r uint8, g uint8, b uint8, a uint8) {
|
||||
data := C.RGBAOptions{
|
||||
r: C.uchar(r),
|
||||
@@ -813,3 +825,11 @@ func (w *Window) MessageDialog(dialogOptions frontend.MessageDialogOptions) {
|
||||
}
|
||||
C.ExecuteOnMainThread(C.messageDialog, C.gpointer(&data))
|
||||
}
|
||||
|
||||
func (w *Window) ToggleMaximise() {
|
||||
if w.IsMaximised() {
|
||||
w.UnMaximise()
|
||||
} else {
|
||||
w.Maximise()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +199,18 @@ func (f *Frontend) WindowMaximise() {
|
||||
f.frontendOptions.WindowStartState = options.Maximised
|
||||
}
|
||||
}
|
||||
func (f *Frontend) WindowToggleMaximise() {
|
||||
runtime.LockOSThread()
|
||||
if !f.hasStarted {
|
||||
return
|
||||
}
|
||||
if f.mainWindow.IsMaximised() {
|
||||
f.WindowUnmaximise()
|
||||
} else {
|
||||
f.WindowMaximise()
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Frontend) WindowUnmaximise() {
|
||||
runtime.LockOSThread()
|
||||
f.mainWindow.Restore()
|
||||
|
||||
@@ -207,6 +207,11 @@ func (w *Window) WndProc(msg uint32, wparam, lparam uintptr) uintptr {
|
||||
return w.Form.WndProc(msg, wparam, lparam)
|
||||
}
|
||||
|
||||
func (w *Window) IsMaximised() bool {
|
||||
style := uint32(w32.GetWindowLong(w.Handle(), w32.GWL_STYLE))
|
||||
return style&w32.WS_MAXIMIZE != 0
|
||||
}
|
||||
|
||||
// TODO this should be put into the winc if we are happy with this solution.
|
||||
var (
|
||||
modkernel32 = syscall.NewLazyDLL("dwmapi.dll")
|
||||
|
||||
@@ -187,6 +187,10 @@ func (d *DevWebServer) WindowMaximise() {
|
||||
d.desktopFrontend.WindowMaximise()
|
||||
}
|
||||
|
||||
func (d *DevWebServer) WindowToggleMaximise() {
|
||||
d.desktopFrontend.WindowToggleMaximise()
|
||||
}
|
||||
|
||||
func (d *DevWebServer) WindowUnmaximise() {
|
||||
d.desktopFrontend.WindowUnmaximise()
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ func (d *Dispatcher) processWindowMessage(message string, sender frontend.Fronte
|
||||
go sender.WindowSetRGBA(&rgba)
|
||||
case 'M':
|
||||
go sender.WindowMaximise()
|
||||
case 't':
|
||||
go sender.WindowToggleMaximise()
|
||||
case 'U':
|
||||
go sender.WindowUnmaximise()
|
||||
case 'm':
|
||||
|
||||
@@ -72,6 +72,7 @@ type Frontend interface {
|
||||
WindowShow()
|
||||
WindowHide()
|
||||
WindowCenter()
|
||||
WindowToggleMaximise()
|
||||
WindowMaximise()
|
||||
WindowUnmaximise()
|
||||
WindowMinimise()
|
||||
|
||||
@@ -146,6 +146,15 @@ export function WindowMaximise() {
|
||||
window.WailsInvoke('WM');
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the Maximise of the Window
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export function WindowToggleMaximise() {
|
||||
window.WailsInvoke('Wt');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmaximise the Window
|
||||
*
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -65,6 +65,8 @@ export interface runtime {
|
||||
|
||||
WindowMaximise(): void;
|
||||
|
||||
WindowToggleMaximise(): void;
|
||||
|
||||
WindowUnmaximise(): void;
|
||||
|
||||
WindowMinimise(): void;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -149,6 +149,15 @@ export function WindowMaximise() {
|
||||
window.runtime.WindowMaximise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the Maximise of the Window
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export function WindowToggleMaximise() {
|
||||
window.runtime.WindowToggleMaximise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmaximise the Window
|
||||
*
|
||||
|
||||
@@ -88,6 +88,12 @@ func WindowMaximise(ctx context.Context) {
|
||||
appFrontend.WindowMaximise()
|
||||
}
|
||||
|
||||
// WindowToggleMaximise the window
|
||||
func WindowToggleMaximise(ctx context.Context) {
|
||||
appFrontend := getFrontend(ctx)
|
||||
appFrontend.WindowToggleMaximise()
|
||||
}
|
||||
|
||||
// WindowUnmaximise the window
|
||||
func WindowUnmaximise(ctx context.Context) {
|
||||
appFrontend := getFrontend(ctx)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user