diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-30 09:57:44 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-30 09:57:44 -0400 |
| commit | 33155f7496a818a1ed83fe49cccb63be7842bc81 (patch) | |
| tree | bbb14af3d92becf7d5ca5abfb28630a2b413ad93 /sysdata.go | |
| parent | e032807546a96e6489d18a0e42ced51b7c31a55c (diff) | |
Reverted everything back to the old API.
Diffstat (limited to 'sysdata.go')
| -rw-r--r-- | sysdata.go | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -2,16 +2,21 @@ package ui +const eventbufsiz = 100 // suggested by skelterjohn + +// newEvent returns a new channel suitable for listening for events. +func newEvent() chan struct{} { + return make(chan struct{}, eventbufsiz) +} + // The sysData type contains all system data. It provides the system-specific underlying implementation. It is guaranteed to have the following by embedding: type cSysData struct { ctype int + event chan struct{} allocate func(x int, y int, width int, height int, d *sysSizeData) []*allocation spaced bool alternate bool // editable for Combobox, multi-select for listbox, password for lineedit - handler AreaHandler // for Areas; TODO rename to areahandler - winhandler WindowHandler // for Windows - close func(*bool) // provided by each Window - event func() // provided by each control + handler AreaHandler // for Areas } // this interface is used to make sure all sysDatas are synced @@ -39,6 +44,19 @@ var _xSysData interface { setChecked(bool) } = &sysData{} // this line will error if there's an inconsistency +// signal sends the event signal. This raise is done asynchronously to avoid deadlocking the UI task. +// Thanks skelterjohn for this techinque: if we can't queue any more events, drop them +func (s *cSysData) signal() { + if s.event != nil { + go func() { + select { + case s.event <- struct{}{}: + default: + } + }() + } +} + const ( c_window = iota c_button |
