diff options
Diffstat (limited to 'nexgb/res/res.go')
-rw-r--r-- | nexgb/res/res.go | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/nexgb/res/res.go b/nexgb/res/res.go index dd53857..e3d7b02 100644 --- a/nexgb/res/res.go +++ b/nexgb/res/res.go @@ -19,16 +19,15 @@ func Init(c *xgb.Conn) error { return xgb.Errorf("No extension named X-Resource could be found on on the server.") } - xgb.ExtLock.Lock() + c.ExtLock.Lock() c.Extensions["X-Resource"] = reply.MajorOpcode + c.ExtLock.Unlock() for evNum, fun := range xgb.NewExtEventFuncs["X-Resource"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["X-Resource"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } - xgb.ExtLock.Unlock() - return nil } @@ -511,6 +510,8 @@ type QueryClientIdsCookie struct { // QueryClientIds sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryClientIdsCookie.Reply() func QueryClientIds(c *xgb.Conn, NumSpecs uint32, Specs []ClientIdSpec) QueryClientIdsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClientIds' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -522,6 +523,8 @@ func QueryClientIds(c *xgb.Conn, NumSpecs uint32, Specs []ClientIdSpec) QueryCli // QueryClientIdsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryClientIdsUnchecked(c *xgb.Conn, NumSpecs uint32, Specs []ClientIdSpec) QueryClientIdsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClientIds' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -583,7 +586,9 @@ func queryClientIdsRequest(c *xgb.Conn, NumSpecs uint32, Specs []ClientIdSpec) [ b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["X-Resource"] + c.ExtLock.RUnlock() b += 1 buf[b] = 4 // request opcode @@ -608,6 +613,8 @@ type QueryClientPixmapBytesCookie struct { // QueryClientPixmapBytes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryClientPixmapBytesCookie.Reply() func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -619,6 +626,8 @@ func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCooki // QueryClientPixmapBytesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClientPixmapBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -677,7 +686,9 @@ func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["X-Resource"] + c.ExtLock.RUnlock() b += 1 buf[b] = 3 // request opcode @@ -700,6 +711,8 @@ type QueryClientResourcesCookie struct { // QueryClientResources sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryClientResourcesCookie.Reply() func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -711,6 +724,8 @@ func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { // QueryClientResourcesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryClientResourcesUnchecked(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClientResources' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -772,7 +787,9 @@ func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["X-Resource"] + c.ExtLock.RUnlock() b += 1 buf[b] = 2 // request opcode @@ -795,6 +812,8 @@ type QueryClientsCookie struct { // QueryClients sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryClientsCookie.Reply() func QueryClients(c *xgb.Conn) QueryClientsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -806,6 +825,8 @@ func QueryClients(c *xgb.Conn) QueryClientsCookie { // QueryClientsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryClients' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -867,7 +888,9 @@ func queryClientsRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["X-Resource"] + c.ExtLock.RUnlock() b += 1 buf[b] = 1 // request opcode @@ -887,6 +910,8 @@ type QueryResourceBytesCookie struct { // QueryResourceBytes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryResourceBytesCookie.Reply() func QueryResourceBytes(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []ResourceIdSpec) QueryResourceBytesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryResourceBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -898,6 +923,8 @@ func QueryResourceBytes(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []Res // QueryResourceBytesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryResourceBytesUnchecked(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []ResourceIdSpec) QueryResourceBytesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryResourceBytes' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -959,7 +986,9 @@ func queryResourceBytesRequest(c *xgb.Conn, Client uint32, NumSpecs uint32, Spec b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["X-Resource"] + c.ExtLock.RUnlock() b += 1 buf[b] = 5 // request opcode @@ -987,6 +1016,8 @@ type QueryVersionCookie struct { // QueryVersion sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -998,6 +1029,8 @@ func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionC // QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["X-Resource"]; !ok { panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'X-Resource'. res.Init(connObj) must be called first.") } @@ -1056,7 +1089,9 @@ func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["X-Resource"] + c.ExtLock.RUnlock() b += 1 buf[b] = 0 // request opcode |