Skip to content

Commit

Permalink
Revert "WIP"
Browse files Browse the repository at this point in the history
This reverts commit b07fd60.
  • Loading branch information
leaanthony committed Jan 12, 2022
1 parent 1724912 commit 8b7d439
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 44 deletions.
6 changes: 3 additions & 3 deletions v2/internal/frontend/desktop/windows/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ func (f *Frontend) WindowFullscreen() {
f.mainWindow.SetMaxSize(0, 0)
f.mainWindow.SetMinSize(0, 0)
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
f.ExecJS("window.wails.enableFramelessResize();")
f.ExecJS("window.wails.flags.enableResize = false;")
}
f.mainWindow.Fullscreen()
}

func (f *Frontend) WindowUnFullscreen() {
runtime.LockOSThread()
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.SetMaxSize(f.maxWidth, f.maxHeight)
Expand Down Expand Up @@ -491,7 +491,7 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
}

if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
f.ExecJS("window.wails.enableFramelessResize();")
f.ExecJS("window.wails.flags.enableResize = true;")
}

if f.hasStarted {
Expand Down
2 changes: 1 addition & 1 deletion v2/internal/frontend/desktop/windows/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func NewWindow(parent winc.Controller, appoptions *options.App) *Window {
result.SetText(appoptions.Title)
if appoptions.Frameless == false && !appoptions.Fullscreen {
result.EnableMaxButton(!appoptions.DisableResize)
result.EnableSizable(!appoptions.DisableResize)
result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight)
result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight)
}
result.EnableSizable(!appoptions.DisableResize)

if appoptions.Windows != nil {
if appoptions.Windows.WindowIsTranslucent {
Expand Down
22 changes: 5 additions & 17 deletions v2/internal/frontend/runtime/desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ window.wails = {
flags: {
disableScrollbarDrag: false,
disableWailsDefaultContextMenu: false,
enableFramelessResize: false,
enableResize: false,
defaultCursor: null
},
enableFramelessResize,
disableFramelessResize
}
};

// Set the bindings
Expand All @@ -66,7 +64,7 @@ if (ENV === 0) {
window.addEventListener('mousedown', (e) => {

// Check for resizing
if (window.wails.flags.enableFramelessResize && window.wails.flags.resizeEdge) {
if (window.wails.flags.resizeEdge) {
window.WailsInvoke("resize:" + window.wails.flags.resizeEdge);
e.preventDefault();
return;
Expand Down Expand Up @@ -97,7 +95,7 @@ function setResize(cursor) {
window.wails.flags.resizeEdge = cursor;
}

function mouseHandler(e) {
window.addEventListener('mousemove', function (e) {
if (!window.wails.flags.enableResize) {
return;
}
Expand All @@ -124,17 +122,7 @@ function mouseHandler(e) {
else if (bottomBorder) setResize("s-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
window.addEventListener('contextmenu', function (e) {
Expand Down
29 changes: 7 additions & 22 deletions v2/internal/frontend/runtime/runtime_dev_desktop.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/internal/frontend/runtime/runtime_prod_desktop.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8b7d439

Please sign in to comment.