5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 06:51:26 +08:00

Revert "WIP"

This reverts commit b07fd608b3.
This commit is contained in:
Lea Anthony 2022-01-12 20:34:37 +11:00
parent 1724912cd8
commit 8b7d4393dc
5 changed files with 17 additions and 44 deletions

View File

@ -173,7 +173,7 @@ func (f *Frontend) WindowFullscreen() {
f.mainWindow.SetMaxSize(0, 0) f.mainWindow.SetMaxSize(0, 0)
f.mainWindow.SetMinSize(0, 0) f.mainWindow.SetMinSize(0, 0)
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false { if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
f.ExecJS("window.wails.enableFramelessResize();") f.ExecJS("window.wails.flags.enableResize = false;")
} }
f.mainWindow.Fullscreen() f.mainWindow.Fullscreen()
} }
@ -181,7 +181,7 @@ func (f *Frontend) WindowFullscreen() {
func (f *Frontend) WindowUnFullscreen() { func (f *Frontend) WindowUnFullscreen() {
runtime.LockOSThread() runtime.LockOSThread()
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false { if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
f.ExecJS("window.wails.enableFramelessResize();") f.ExecJS("window.wails.flags.enableResize = true;")
} }
f.mainWindow.UnFullscreen() f.mainWindow.UnFullscreen()
f.mainWindow.SetMaxSize(f.maxWidth, f.maxHeight) f.mainWindow.SetMaxSize(f.maxWidth, f.maxHeight)
@ -491,7 +491,7 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
} }
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false { if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
f.ExecJS("window.wails.enableFramelessResize();") f.ExecJS("window.wails.flags.enableResize = true;")
} }
if f.hasStarted { if f.hasStarted {

View File

@ -57,10 +57,10 @@ func NewWindow(parent winc.Controller, appoptions *options.App) *Window {
result.SetText(appoptions.Title) result.SetText(appoptions.Title)
if appoptions.Frameless == false && !appoptions.Fullscreen { if appoptions.Frameless == false && !appoptions.Fullscreen {
result.EnableMaxButton(!appoptions.DisableResize) result.EnableMaxButton(!appoptions.DisableResize)
result.EnableSizable(!appoptions.DisableResize)
result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight) result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight)
result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight) result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight)
} }
result.EnableSizable(!appoptions.DisableResize)
if appoptions.Windows != nil { if appoptions.Windows != nil {
if appoptions.Windows.WindowIsTranslucent { if appoptions.Windows.WindowIsTranslucent {

View File

@ -43,11 +43,9 @@ window.wails = {
flags: { flags: {
disableScrollbarDrag: false, disableScrollbarDrag: false,
disableWailsDefaultContextMenu: false, disableWailsDefaultContextMenu: false,
enableFramelessResize: false, enableResize: false,
defaultCursor: null defaultCursor: null
}, }
enableFramelessResize,
disableFramelessResize
}; };
// Set the bindings // Set the bindings
@ -66,7 +64,7 @@ if (ENV === 0) {
window.addEventListener('mousedown', (e) => { window.addEventListener('mousedown', (e) => {
// Check for resizing // Check for resizing
if (window.wails.flags.enableFramelessResize && window.wails.flags.resizeEdge) { if (window.wails.flags.resizeEdge) {
window.WailsInvoke("resize:" + window.wails.flags.resizeEdge); window.WailsInvoke("resize:" + window.wails.flags.resizeEdge);
e.preventDefault(); e.preventDefault();
return; return;
@ -97,7 +95,7 @@ function setResize(cursor) {
window.wails.flags.resizeEdge = cursor; window.wails.flags.resizeEdge = cursor;
} }
function mouseHandler(e) { window.addEventListener('mousemove', function (e) {
if (!window.wails.flags.enableResize) { if (!window.wails.flags.enableResize) {
return; return;
} }
@ -124,17 +122,7 @@ function mouseHandler(e) {
else if (bottomBorder) setResize("s-resize"); else if (bottomBorder) setResize("s-resize");
else if (rightBorder) setResize("e-resize"); else if (rightBorder) setResize("e-resize");
} });
export function enableFramelessResize() {
window.wails.flags.enableFramelessResize = true;
window.addEventListener('mousemove', mouseHandler);
}
export function disableFramelessResize() {
window.wails.flags.enableFramelessResize = false;
window.removeEventListener('mousemove', mouseHandler);
}
// Setup context menu hook // Setup context menu hook
window.addEventListener('contextmenu', function (e) { window.addEventListener('contextmenu', function (e) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long