summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stdwndclass_windows.go23
-rw-r--r--sysdata_windows.go3
-rw-r--r--sysdatacache_windows.go8
3 files changed, 19 insertions, 15 deletions
diff --git a/stdwndclass_windows.go b/stdwndclass_windows.go
index f720051..fae357a 100644
--- a/stdwndclass_windows.go
+++ b/stdwndclass_windows.go
@@ -16,7 +16,10 @@ var (
)
func stdWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESULT {
-// sysData := getSysData(hwnd)
+ sysData := getSysData(hwnd)
+ if sysData == nil { // not ready for events yet
+ goto defwndproc
+ }
switch uMsg {
case _WM_COMMAND:
id := wParam.LOWORD()
@@ -32,19 +35,21 @@ func stdWndProc(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRESUL
// TODO
return 0
case _WM_CLOSE:
-/* if sysData.closing != nil {
+ if sysData.closing != nil {
sysData.closing <- struct{}{}
}
-*/ return 0
+ return 0
default:
- r1, _, _ := defWindowProc.Call(
- uintptr(hwnd),
- uintptr(uMsg),
- uintptr(wParam),
- uintptr(lParam))
- return _LRESULT(r1)
+ goto defwndproc
}
panic(fmt.Sprintf("stdWndProc message %d did not return: internal bug in ui library", uMsg))
+defwndproc:
+ r1, _, _ := defWindowProc.Call(
+ uintptr(hwnd),
+ uintptr(uMsg),
+ uintptr(wParam),
+ uintptr(lParam))
+ return _LRESULT(r1)
}
type _WNDCLASS struct {
diff --git a/sysdata_windows.go b/sysdata_windows.go
index 72ac46b..714f501 100644
--- a/sysdata_windows.go
+++ b/sysdata_windows.go
@@ -38,9 +38,6 @@ var classTypes = [nctypes]*classData{
}
func (s *sysData) make() (err error) {
- sysDatasLock.Lock()
- defer sysDatasLock.Unlock()
-
ret := make(chan uiret)
defer close(ret)
ct := classTypes[s.ctype]
diff --git a/sysdatacache_windows.go b/sysdatacache_windows.go
index 1bdb128..620d6ac 100644
--- a/sysdatacache_windows.go
+++ b/sysdatacache_windows.go
@@ -18,16 +18,18 @@ var (
sysDatasLock sync.Mutex
)
-// MUST HAVE LOCKED BEFORE CALLING
func addSysData(hwnd _HWND, s *sysData) {
+ sysDatasLock.Lock()
+ defer sysDatasLock.Unlock()
sysDatas[hwnd] = &sdcEntry{
s: s,
members: map[_HMENU]*sysData{},
}
}
-// MUST HAVE LOCKED BEFORE CALLING
func addIDSysData(hwnd _HWND, id _HMENU, s *sysData) {
+ sysDatasLock.Lock()
+ defer sysDatasLock.Unlock()
if ss, ok := sysDatas[hwnd]; ok {
ss.members[id] = s
}
@@ -40,7 +42,7 @@ func getSysData(hwnd _HWND) *sysData {
if ss, ok := sysDatas[hwnd]; ok {
return ss.s
}
- panic(fmt.Sprintf("getting nonexistent HWND %d\n", hwnd))
+ return nil
}
func getIDSysData(hwnd _HWND, id _HMENU) *sysData {