go-flutter-desktop / go-flutter

Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.
https://hover.build/
BSD 3-Clause "New" or "Revised" License
5.85k stars 283 forks source link

SetPosCallback no effect #633

Closed niuhuan closed 2 years ago

niuhuan commented 2 years ago

Main

I need save windows size and position , reduction at restart.

impl InitPluginGLFW

SetSizeCallback is ok. but SetPosCallback is not work.

I think this Pos is mean "Position", window position on monitor.

I have other questions, : How to get monitor size and listen full screen event.

Thank you for reading this poor English.

Thank you in advance for your reply.


func (p *MyPlugin) InitPluginGLFW(window *glfw.Window) error {
    window.SetSizeCallback(func(w *glfw.Window, width int, height int) {
        go func() {
            println("Size") // print success when modify window size
            properties.SaveProperty("window_width", strconv.Itoa(width))
            properties.SaveProperty("window_height", strconv.Itoa(height))
        }()
    })
    window.SetPosCallback(func(w *glfw.Window, xPos int, yPos int) {
        go func() {
            println("Pos") // not print when modify window pos
            properties.SaveProperty("window_x", strconv.Itoa(xPos))
            properties.SaveProperty("window_y", strconv.Itoa(yPos))
        }()
    })
    return nil
}

Hover doctor

✗ hover doctor
hover: Hover version (devel) running on darwin
hover: Sharing packaging tools
hover: darwin-bundle is supported
hover: darwin-dmg is supported
hover: darwin-pkg is supported
hover: Packaging linux-appimage is not supported on darwin
hover: To still package linux-appimage on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-deb is not supported on darwin
hover: To still package linux-deb on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-pkg is not supported on darwin
hover: To still package linux-pkg on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-rpm is not supported on darwin
hover: To still package linux-rpm on darwin you need to run hover with the `--docker` flag.
hover: Packaging linux-snap is not supported on darwin
hover: To still package linux-snap on darwin you need to run hover with the `--docker` flag.
hover: Packaging windows-msi is not supported on darwin
hover: To still package windows-msi on darwin you need to run hover with the `--docker` flag.
hover: 
hover: Sharing flutter version
Flutter 2.2.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f4abaa0735 (5 months ago) • 2021-07-01 12:46:11 -0700
Engine • revision 241c87ad80
Tools • Dart 2.13.4
hover: Flutter engine commit: https://github.com/flutter/engine/commit/241c87ad800beeab545ab867354d4683d5bfb6ce
hover: ⚠ The go-flutter project tries to stay compatible with the beta channel of Flutter.
hover: ⚠     It's advised to use the beta channel: `flutter channel beta`
hover: Finding out the C compiler version
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
hover: Sharing the content of go.mod
module pikapika

go 1.16

require (
        github.com/PuerkitoBio/goquery v1.7.1
        github.com/go-flutter-desktop/go-flutter v0.43.0
        github.com/go-flutter-desktop/plugins/url_launcher v0.1.2
        github.com/go-gl/glfw/v3.3/glfw v0.0.0-20201108214237-06ea97f0c265
        github.com/miguelpruivo/flutter_file_picker/go v0.0.0-20210622152105-9f0a811028a0
        github.com/niuhuan/pica-go v0.0.0-20211115032844-c44c612e1641
        github.com/pkg/errors v0.9.1
        golang.org/x/image v0.0.0-20190802002840-cff245a6509b
        golang.org/x/mobile v0.0.0-20210924032853-1c027f395ef7 // indirect
        golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
        gorm.io/driver/sqlite v1.1.4
        gorm.io/gorm v1.21.12
)
hover: Sharing the content of hover.yaml
application-name: ""
executable-name: ""
package-name: ""
organization-name: niuhuan
license: ""
target: lib/main_desktop.dart
branch: ""
cache-path: ""
opengl: ""
engine-version: ""

Error output

not need
pchampio commented 2 years ago

Please read: https://github.com/go-flutter-desktop/go-flutter/wiki/Tips-and-tricks#4-save-the-windows-mode-fullscreen-or-default ;)

niuhuan commented 2 years ago

thanks