clipboard #14
@ -244,6 +244,27 @@ func (window *window) handleSelectionNotify (
|
|||||||
if !window.selectionRequest.open() { window.selectionRequest = nil }
|
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 (
|
func (window *window) compressExpose (
|
||||||
firstEvent xproto.ExposeEvent,
|
firstEvent xproto.ExposeEvent,
|
||||||
) (
|
) (
|
||||||
|
@ -13,7 +13,6 @@ type selReqState int; const (
|
|||||||
selReqStateClosed selReqState = iota
|
selReqStateClosed selReqState = iota
|
||||||
selReqStateAwaitTargets
|
selReqStateAwaitTargets
|
||||||
selReqStateAwaitValue
|
selReqStateAwaitValue
|
||||||
selReqStateAwaitFirstChunk
|
|
||||||
selReqStateAwaitChunk
|
selReqStateAwaitChunk
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -153,7 +152,6 @@ func (request *selectionRequest) handleSelectionNotify (
|
|||||||
) {
|
) {
|
||||||
// the only valid states that we can process a SelectionNotify event in
|
// the only valid states that we can process a SelectionNotify event in
|
||||||
invalidState :=
|
invalidState :=
|
||||||
request.state != selReqStateAwaitFirstChunk &&
|
|
||||||
request.state != selReqStateAwaitValue &&
|
request.state != selReqStateAwaitValue &&
|
||||||
request.state != selReqStateAwaitTargets
|
request.state != selReqStateAwaitTargets
|
||||||
if invalidState { return }
|
if invalidState { return }
|
||||||
@ -168,13 +166,6 @@ func (request *selectionRequest) handleSelectionNotify (
|
|||||||
// data.
|
// data.
|
||||||
if event.Property == 0 { request.die(nil); return }
|
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
|
// When using GetProperty to retrieve the value of a selection, the
|
||||||
// property argument should be set to the corresponding value in the
|
// property argument should be set to the corresponding value in the
|
||||||
// SelectionNotify event. Because the requestor has no way of knowing
|
// 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 }
|
if err != nil { request.die(err); return }
|
||||||
|
|
||||||
// await the first chunk
|
// await the first chunk
|
||||||
request.state = selReqStateAwaitFirstChunk
|
request.state = selReqStateAwaitChunk
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,6 +328,9 @@ func (request *selectionRequest) handleINCRProperty (property xproto.Atom) {
|
|||||||
// finalize the request with the data we have, and don't wait
|
// finalize the request with the data we have, and don't wait
|
||||||
// for more.
|
// for more.
|
||||||
request.finalize(data.Bytes(request.incrMime, request.incrBuffer))
|
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 {
|
} else {
|
||||||
// a property with content means the transfer is still ongoing.
|
// a property with content means the transfer is still ongoing.
|
||||||
// we append the data we got and wait for more.
|
// 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
|
config config.Config
|
||||||
|
|
||||||
selectionRequest *selectionRequest
|
selectionRequest *selectionRequest
|
||||||
|
selectionClaim *selectionClaim
|
||||||
|
|
||||||
metrics struct {
|
metrics struct {
|
||||||
width int
|
width int
|
||||||
@ -69,6 +70,7 @@ func (backend *Backend) newWindow (
|
|||||||
err = window.xWindow.Listen (
|
err = window.xWindow.Listen (
|
||||||
xproto.EventMaskExposure,
|
xproto.EventMaskExposure,
|
||||||
xproto.EventMaskStructureNotify,
|
xproto.EventMaskStructureNotify,
|
||||||
|
xproto.EventMaskPropertyChange,
|
||||||
xproto.EventMaskPointerMotion,
|
xproto.EventMaskPointerMotion,
|
||||||
xproto.EventMaskKeyPress,
|
xproto.EventMaskKeyPress,
|
||||||
xproto.EventMaskKeyRelease,
|
xproto.EventMaskKeyRelease,
|
||||||
@ -96,6 +98,10 @@ func (backend *Backend) newWindow (
|
|||||||
Connect(backend.connection, window.xWindow.Id)
|
Connect(backend.connection, window.xWindow.Id)
|
||||||
xevent.SelectionNotifyFun(window.handleSelectionNotify).
|
xevent.SelectionNotifyFun(window.handleSelectionNotify).
|
||||||
Connect(backend.connection, window.xWindow.Id)
|
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.SetTheme(backend.theme)
|
||||||
window.SetConfig(backend.config)
|
window.SetConfig(backend.config)
|
||||||
|
Reference in New Issue
Block a user