mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3] Update dev guide. Remove implLock.
This commit is contained in:
parent
9f8f095a78
commit
4d2b4b4ee7
2 changed files with 16 additions and 12 deletions
|
|
@ -27,6 +27,8 @@ The project has the following structure:
|
|||
├── cmd/wails // CLI
|
||||
├── examples // Examples of Wails apps
|
||||
├── internal // Internal packages
|
||||
| ├── runtime // The Wails JS runtime
|
||||
| └── templates // The supported project templates
|
||||
├── pkg
|
||||
| ├── application // The core Wails library
|
||||
| └── events // The event definitions
|
||||
|
|
@ -39,6 +41,17 @@ The project has the following structure:
|
|||
|
||||
## Development
|
||||
|
||||
### Adding window functionality
|
||||
|
||||
The preferred way to add window functionality is to add a new function to the `pkg/application/webview_window.go` file. This should implement all the functionality required for all platforms. Any platform specific code should be called via a `webviewWindowImpl` interface method. This interface is implemented by each of the target platforms to provide the platform specific functionality. In some cases, this may do nothing.
|
||||
Once you've added the interface method, ensure each platform implements it. A good example of this is the `SetMinSize` method.
|
||||
|
||||
- Mac: `webview_window_darwin.go`
|
||||
- Windows: `webview_window_windows.go`
|
||||
- Linux: `webview_window_linux.go`
|
||||
|
||||
Most, if not all, of the platform specific code should be run on the main thread. To simplify this, there are a number of `invokeSync` methods defined in `application.go`.
|
||||
|
||||
### Updating the runtime
|
||||
|
||||
The runtime is located in `v3/internal/runtime`. When the runtime is updated, the following steps need to be taken:
|
||||
|
|
|
|||
|
|
@ -74,10 +74,9 @@ type WindowEventListener struct {
|
|||
}
|
||||
|
||||
type WebviewWindow struct {
|
||||
options WebviewWindowOptions
|
||||
impl webviewWindowImpl
|
||||
implLock sync.RWMutex
|
||||
id uint
|
||||
options WebviewWindowOptions
|
||||
impl webviewWindowImpl
|
||||
id uint
|
||||
|
||||
eventListeners map[uint][]*WindowEventListener
|
||||
eventListenersLock sync.RWMutex
|
||||
|
|
@ -149,8 +148,6 @@ func (w *WebviewWindow) addCancellationFunction(canceller func()) {
|
|||
|
||||
// SetTitle sets the title of the window
|
||||
func (w *WebviewWindow) SetTitle(title string) *WebviewWindow {
|
||||
w.implLock.RLock()
|
||||
defer w.implLock.RUnlock()
|
||||
w.options.Title = title
|
||||
if w.impl != nil {
|
||||
invokeSync(func() {
|
||||
|
|
@ -212,9 +209,7 @@ func (w *WebviewWindow) run() {
|
|||
if w.impl != nil {
|
||||
return
|
||||
}
|
||||
w.implLock.Lock()
|
||||
w.impl = newWindowImpl(w)
|
||||
w.implLock.Unlock()
|
||||
invokeSync(w.impl.run)
|
||||
}
|
||||
|
||||
|
|
@ -431,8 +426,6 @@ func (w *WebviewWindow) Size() (int, int) {
|
|||
|
||||
// IsFullscreen returns true if the window is fullscreen
|
||||
func (w *WebviewWindow) IsFullscreen() bool {
|
||||
w.implLock.RLock()
|
||||
defer w.implLock.RUnlock()
|
||||
if w.impl == nil {
|
||||
return false
|
||||
}
|
||||
|
|
@ -548,8 +541,6 @@ func (w *WebviewWindow) Height() int {
|
|||
|
||||
// Position returns the position of the window
|
||||
func (w *WebviewWindow) Position() (int, int) {
|
||||
w.implLock.RLock()
|
||||
defer w.implLock.RUnlock()
|
||||
if w.impl == nil {
|
||||
return 0, 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue