Split sysData.show() into separate show() and firstShow() to accomodate Windows's differing rules for first-time window show; this will also allow me to remove the error returns from sysData.show() and sysData.hide() (later).
This commit is contained in:
parent
3ff9c7d233
commit
45e0779790
|
@ -22,6 +22,9 @@ type cSysData struct {
|
|||
func (c *cSysData) make(initText string, window *sysData) error {
|
||||
panic(runtime.GOOS + " sysData does not define make()")
|
||||
}
|
||||
func (c *cSysData) firstShow() error {
|
||||
panic(runtime.GOOS + " sysData does not define firstShow()")
|
||||
}
|
||||
func (c *cSysData) show() error {
|
||||
panic(runtime.GOOS + " sysData does not define show()")
|
||||
}
|
||||
|
|
|
@ -314,6 +314,12 @@ func (s *sysData) make(initText string, window *sysData) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// used for Windows; nothing special needed elsewhere
|
||||
func (s *sysData) firstShow() error {
|
||||
s.show()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *sysData) show() error {
|
||||
ret := make(chan struct{})
|
||||
defer close(ret)
|
||||
|
|
|
@ -156,6 +156,12 @@ func (s *sysData) make(initText string, window *sysData) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// used for Windows; nothing special needed elsewhere
|
||||
func (s *sysData) firstShow() error {
|
||||
s.show()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *sysData) show() error {
|
||||
ret := make(chan struct{})
|
||||
defer close(ret)
|
||||
|
|
|
@ -15,7 +15,6 @@ type sysData struct {
|
|||
children map[_HMENU]*sysData
|
||||
nextChildID _HMENU
|
||||
childrenLock sync.Mutex
|
||||
shownAlready bool
|
||||
}
|
||||
|
||||
type classData struct {
|
||||
|
@ -190,36 +189,42 @@ var (
|
|||
// if the object is a window, we need to do the following the first time
|
||||
// ShowWindow(hwnd, nCmdShow);
|
||||
// UpdateWindow(hwnd);
|
||||
// otherwise we go ahead and show the object normally with SW_SHOW
|
||||
func (s *sysData) show() (err error) {
|
||||
if s.ctype != c_window { // don't do the init ShowWindow/UpdateWindow chain on non-windows
|
||||
s.shownAlready = true
|
||||
}
|
||||
show := uintptr(_SW_SHOW)
|
||||
if !s.shownAlready {
|
||||
show = uintptr(nCmdShow)
|
||||
}
|
||||
func (s *sysData) firstShow() error {
|
||||
ret := make(chan uiret)
|
||||
defer close(ret)
|
||||
// TODO figure out how to handle error
|
||||
uitask <- &uimsg{
|
||||
call: _showWindow,
|
||||
p: []uintptr{uintptr(s.hwnd), show},
|
||||
p: []uintptr{
|
||||
uintptr(s.hwnd),
|
||||
uintptr(nCmdShow),
|
||||
},
|
||||
ret: ret,
|
||||
}
|
||||
<-ret
|
||||
if !s.shownAlready {
|
||||
uitask <- &uimsg{
|
||||
call: _updateWindow,
|
||||
p: []uintptr{uintptr(s.hwnd)},
|
||||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
if r.ret == 0 { // failure
|
||||
return fmt.Errorf("error updating window for the first time: %v", r.err)
|
||||
}
|
||||
s.shownAlready = true
|
||||
uitask <- &uimsg{
|
||||
call: _updateWindow,
|
||||
p: []uintptr{uintptr(s.hwnd)},
|
||||
ret: ret,
|
||||
}
|
||||
r := <-ret
|
||||
if r.ret == 0 { // failure
|
||||
return fmt.Errorf("error updating window for the first time: %v", r.err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *sysData) show() (err error) {
|
||||
ret := make(chan uiret)
|
||||
defer close(ret)
|
||||
uitask <- &uimsg{
|
||||
call: _showWindow,
|
||||
p: []uintptr{
|
||||
uintptr(s.hwnd),
|
||||
uintptr(_SW_SHOW),
|
||||
},
|
||||
ret: ret,
|
||||
}
|
||||
<-ret
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ func (w *Window) Open(control Control) (err error) {
|
|||
return fmt.Errorf("error setting window size (in Window.Open()): %v", err)
|
||||
}
|
||||
// TODO separate showing?
|
||||
err = w.sysData.show()
|
||||
err = w.sysData.firstShow()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error showing window (in Window.Open()): %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue