Skip to content

Commit

Permalink
Merge branch 'v3-alpha' into fix-restore
Browse files Browse the repository at this point in the history
  • Loading branch information
fbbdev committed Mar 1, 2024
2 parents b0cfc08 + a9c22f0 commit f8b5cbe
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 13 deletions.
11 changes: 11 additions & 0 deletions mkdocs-website/docs/en/API/fullapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ import "github.com/wailsapp/wails/v3/pkg/application"
- [func \(w \*WebviewWindow\) Size\(\) \(int, int\)](#WebviewWindow.Size)
- [func \(w \*WebviewWindow\) ToggleDevTools\(\)](#WebviewWindow.ToggleDevTools)
- [func \(w \*WebviewWindow\) ToggleFullscreen\(\)](#WebviewWindow.ToggleFullscreen)
- [func \(w \*WebviewWindow\) ToggleMaximise\(\)](#WebviewWindow.ToggleMaximise)
- [func \(w \*WebviewWindow\) UnFullscreen\(\)](#WebviewWindow.UnFullscreen)
- [func \(w \*WebviewWindow\) UnMaximise\(\)](#WebviewWindow.UnMaximise)
- [func \(w \*WebviewWindow\) UnMinimise\(\)](#WebviewWindow.UnMinimise)
Expand Down Expand Up @@ -3715,6 +3716,16 @@ func (w *WebviewWindow) ToggleFullscreen()

ToggleFullscreen toggles the window between fullscreen and normal

<a name="WebviewWindow.ToggleMaximise"></a>

### func \(\*WebviewWindow\) [ToggleMaximise](https://github.com/wailsapp/wails/blob/master/v3/pkg/application/webview_window.go#L720)

```go
func (w *WebviewWindow) ToggleMaximise()
```

ToggleMaximise toggles the window between maximised and normal

<a name="WebviewWindow.UnFullscreen"></a>

### func \(\*WebviewWindow\) [UnFullscreen](https://github.com/wailsapp/wails/blob/master/v3/pkg/application/webview_window.go#L859)
Expand Down
2 changes: 2 additions & 0 deletions mkdocs-website/docs/en/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [linux] add task `run:linux` by [@marcus-crane](https://github.com/marcus-crane) in [#3146](https://github.com/wailsapp/wails/pull/3146)
- export `SetIcon` method by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3147)
- Improve `OnShutdown` by @almas1992 in [PR](https://github.com/wailsapp/wails/pull/3189)
- restore `ToggleMaximise` method in `Window` interface by [@fbbdev](https://github.com/fbbdev) in [#3281](https://github.com/wailsapp/wails/pull/3281)

### Fixed

Expand All @@ -39,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix replace line in `go.mod` to use relative paths. Fixes Windows paths with spaces - @leaanthony.
- Fix MacOS systray click handling when no attached window by [thomas-senechal](https://github.com/thomas-senechal) in PR [#3207](https://github.com/wailsapp/wails/pull/3207)
- Fix failing Windows build due to unknown option by [thomas-senechal](https://github.com/thomas-senechal) in PR [#3208](https://github.com/wailsapp/wails/pull/3208)
- Fix wrong baseURL when open window twice by @5aaee9 in PR [#3273](https://github.com/wailsapp/wails/pull/3273)
- Fix ordering of if branches in `WebviewWindow.Restore` method by [@fbbdev](https://github.com/fbbdev) in [#3279](https://github.com/wailsapp/wails/pull/3279)

### Changed
Expand Down
3 changes: 3 additions & 0 deletions v3/examples/window-api/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
<p class="blue-button-42" onclick="wails.Window.UnFullscreen()">UnFullscreen</p>
<p class="blue-button-42" onclick="wails.Window.Restore()">Restore</p>
</div>
<div>
<p class="blue-button-42" onclick="wails.Window.ToggleMaximise()">ToggleMaximise</p>
</div>
</body>
</html>

Expand Down
4 changes: 1 addition & 3 deletions v3/internal/assetserver/assetserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"path"
"strings"
"time"
)
Expand Down Expand Up @@ -160,8 +159,7 @@ func GetStartURL(userURL string) (string, error) {
return "", fmt.Errorf("Error parsing URL: " + err.Error())
}
if parsedURL.Scheme == "" {
baseURL.Path = path.Join(baseURL.Path, userURL)
startURL = baseURL.String()
startURL = baseURL.ResolveReference(&url.URL{Path: userURL}).String()
// if the original URL had a trailing slash, add it back
if strings.HasSuffix(userURL, "/") && !strings.HasSuffix(startURL, "/") {
startURL = startURL + "/"
Expand Down
20 changes: 10 additions & 10 deletions v3/pkg/application/messageprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
// as parameter through every function call.

const (
callRequest int = 0
clipboardRequest = 1
applicationRequest = 2
eventsRequest = 3
contextMenuRequest = 4
dialogRequest = 5
windowRequest = 6
screensRequest = 7
systemRequest = 8
browserRequest = 9
callRequest = 0
clipboardRequest = 1
applicationRequest = 2
eventsRequest = 3
contextMenuRequest = 4
dialogRequest = 5
windowRequest = 6
screensRequest = 7
systemRequest = 8
browserRequest = 9
)

type MessageProcessor struct {
Expand Down
3 changes: 3 additions & 0 deletions v3/pkg/application/messageprocessor_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func (m *MessageProcessor) processWindowMethod(method int, rw http.ResponseWrite
case WindowUnMaximise:
window.UnMaximise()
m.ok(rw)
case WindowToggleMaximise:
window.ToggleMaximise()
m.ok(rw)
case WindowRestore:
window.Restore()
m.ok(rw)
Expand Down
14 changes: 14 additions & 0 deletions v3/pkg/application/webview_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,20 @@ func (w *WebviewWindow) ToggleFullscreen() {
})
}

// ToggleMaximise toggles the window between maximised and normal
func (w *WebviewWindow) ToggleMaximise() {
if w.impl == nil && !w.isDestroyed() {
return
}
InvokeSync(func() {
if w.IsMaximised() {
w.UnMaximise()
} else {
w.Maximise()
}
})
}

func (w *WebviewWindow) ToggleDevTools() {
if w.impl == nil && !w.isDestroyed() {
return
Expand Down
1 change: 1 addition & 0 deletions v3/pkg/application/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Window interface {
Size() (width int, height int)
ToggleDevTools()
ToggleFullscreen()
ToggleMaximise()
UnFullscreen()
UnMaximise()
UnMinimise()
Expand Down
2 changes: 2 additions & 0 deletions v3/plugins/experimental/server/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ func (w Window) ToggleDevTools() {

func (w Window) ToggleFullscreen() {}

func (w Window) ToggleMaximise() {}

func (w Window) UnFullscreen() {}

func (w Window) UnMaximise() {}
Expand Down

0 comments on commit f8b5cbe

Please sign in to comment.