clipboard #14
| @ -244,6 +244,27 @@ func (window *window) handleSelectionNotify ( | ||||
| 	if !window.selectionRequest.open() { window.selectionRequest = nil } | ||||
| } | ||||
| 
 | ||||
| func (window *window) handlePropertyNotify ( | ||||
| 	connection *xgbutil.XUtil, | ||||
| 	event xevent.PropertyNotifyEvent, | ||||
| ) { | ||||
| 	if window.selectionRequest == nil { return } | ||||
| 	window.selectionRequest.handlePropertyNotify(connection, event) | ||||
| 	if !window.selectionRequest.open() { window.selectionRequest = nil } | ||||
| } | ||||
| 
 | ||||
| func (window *window) handleSelectionClear ( | ||||
| 	connection *xgbutil.XUtil, | ||||
| 	event xevent.SelectionClearEvent, | ||||
| ) { | ||||
| 	// TODO: schedule the claim to be deleted. when the event loop fires we | ||||
| 	// will check to see if the claim is scheduled to be deleted and if it | ||||
| 	// is, delete it. | ||||
| 	if window.selectionClaim != nil { | ||||
| 		window.selectionClaim.scheduledDelete = true | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (window *window) compressExpose ( | ||||
| 	firstEvent xproto.ExposeEvent, | ||||
| ) ( | ||||
|  | ||||
| @ -13,7 +13,6 @@ type selReqState int; const ( | ||||
| 	selReqStateClosed selReqState = iota | ||||
| 	selReqStateAwaitTargets | ||||
| 	selReqStateAwaitValue | ||||
| 	selReqStateAwaitFirstChunk | ||||
| 	selReqStateAwaitChunk | ||||
| ) | ||||
| 
 | ||||
| @ -153,8 +152,7 @@ func (request *selectionRequest) handleSelectionNotify ( | ||||
| ) { | ||||
| 	// the only valid states that we can process a SelectionNotify event in | ||||
| 	invalidState := | ||||
| 		request.state != selReqStateAwaitFirstChunk && | ||||
| 		request.state != selReqStateAwaitValue      && | ||||
| 		request.state != selReqStateAwaitValue && | ||||
| 		request.state != selReqStateAwaitTargets | ||||
| 	if invalidState { return } | ||||
| 	 | ||||
| @ -168,13 +166,6 @@ func (request *selectionRequest) handleSelectionNotify ( | ||||
| 	// data. | ||||
| 	if event.Property == 0 { request.die(nil); return } | ||||
| 
 | ||||
| 	// if we are waiting for the first INCR chunk, do the special stuff for | ||||
| 	// that and not the other stuff. | ||||
| 	if request.state == selReqStateAwaitFirstChunk { | ||||
| 		request.handleINCRProperty(event.Property) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	// When using GetProperty to retrieve the value of a selection, the | ||||
| 	// property argument should be set to the corresponding value in the | ||||
| 	// SelectionNotify event. Because the requestor has no way of knowing | ||||
| @ -216,7 +207,7 @@ func (request *selectionRequest) handleSelectionNotify ( | ||||
| 		if err != nil { request.die(err); return } | ||||
| 
 | ||||
| 		// await the first chunk | ||||
| 		request.state = selReqStateAwaitFirstChunk | ||||
| 		request.state = selReqStateAwaitChunk | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| @ -337,6 +328,9 @@ func (request *selectionRequest) handleINCRProperty (property xproto.Atom) { | ||||
| 		// finalize the request with the data we have, and don't wait | ||||
| 		// for more. | ||||
| 		request.finalize(data.Bytes(request.incrMime, request.incrBuffer)) | ||||
| 
 | ||||
| 		// we want to be extra sure we aren't holding onto this memory | ||||
| 		request.incrBuffer = nil | ||||
| 	} else { | ||||
| 		// a property with content means the transfer is still ongoing. | ||||
| 		// we append the data we got and wait for more. | ||||
|  | ||||
							
								
								
									
										24
									
								
								backends/x/selectionclaim.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								backends/x/selectionclaim.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| package x | ||||
| 
 | ||||
| import "git.tebibyte.media/sashakoshka/tomo/data" | ||||
| 
 | ||||
| type selectionClaim struct { | ||||
| 	data data.Data | ||||
| 	scheduledDelete bool | ||||
| } | ||||
| 
 | ||||
| func (window *window) newSelectionClaim (data data.Data) *selectionClaim { | ||||
| 	return &selectionClaim{ | ||||
| 		data: data, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (claim *selectionClaim) idle () bool { | ||||
| 	// TODO | ||||
| } | ||||
| 
 | ||||
| func (claim *selectionClaim) handleSelectionRequest ( | ||||
| 	// TODO | ||||
| ) { | ||||
| 	// TODO | ||||
| } | ||||
| @ -34,6 +34,7 @@ type window struct { | ||||
| 	config config.Config | ||||
| 
 | ||||
| 	selectionRequest *selectionRequest | ||||
| 	selectionClaim   *selectionClaim | ||||
| 
 | ||||
| 	metrics struct { | ||||
| 		width  int | ||||
| @ -69,6 +70,7 @@ func (backend *Backend) newWindow ( | ||||
| 	err = window.xWindow.Listen ( | ||||
| 		xproto.EventMaskExposure, | ||||
| 		xproto.EventMaskStructureNotify, | ||||
| 		xproto.EventMaskPropertyChange, | ||||
| 		xproto.EventMaskPointerMotion, | ||||
| 		xproto.EventMaskKeyPress, | ||||
| 		xproto.EventMaskKeyRelease, | ||||
| @ -96,6 +98,10 @@ func (backend *Backend) newWindow ( | ||||
| 		Connect(backend.connection, window.xWindow.Id) | ||||
| 	xevent.SelectionNotifyFun(window.handleSelectionNotify). | ||||
| 		Connect(backend.connection, window.xWindow.Id) | ||||
| 	xevent.PropertyNotifyFun(window.handlePropertyNotify). | ||||
| 		Connect(backend.connection, window.xWindow.Id) | ||||
| 	xevent.SelectionClearFun(window.handleSelectionClear). | ||||
| 		Connect(backend.connection, window.xWindow.Id) | ||||
| 
 | ||||
| 	window.SetTheme(backend.theme) | ||||
| 	window.SetConfig(backend.config) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user