mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 00:11:48 -06:00
This commit is contained in:
@@ -263,6 +263,10 @@
|
|||||||
return this.$accessor.connecting
|
return this.$accessor.connecting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get controlling() {
|
||||||
|
return this.$accessor.remote.controlling
|
||||||
|
}
|
||||||
|
|
||||||
get hosting() {
|
get hosting() {
|
||||||
return this.$accessor.remote.hosting
|
return this.$accessor.remote.hosting
|
||||||
}
|
}
|
||||||
@@ -752,12 +756,17 @@
|
|||||||
first.target.dispatchEvent(simulatedEvent)
|
first.target.dispatchEvent(simulatedEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isMouseDown = false
|
||||||
|
|
||||||
onMouseDown(e: MouseEvent) {
|
onMouseDown(e: MouseEvent) {
|
||||||
if (!this.hosting) {
|
this.isMouseDown = true
|
||||||
this.$emit('control-attempt', e)
|
|
||||||
|
if (this.locked) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.hosting || this.locked) {
|
if (!this.controlling) {
|
||||||
|
this.implicitHostingRequest(e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,7 +775,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMouseUp(e: MouseEvent) {
|
onMouseUp(e: MouseEvent) {
|
||||||
if (!this.hosting || this.locked) {
|
// only if we are the one who started the mouse down
|
||||||
|
if (!this.isMouseDown) return
|
||||||
|
this.isMouseDown = false
|
||||||
|
|
||||||
|
if (this.locked) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.controlling) {
|
||||||
|
this.implicitHostingRequest(e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -774,6 +792,40 @@
|
|||||||
this.$client.sendData('mouseup', { key: e.button + 1 })
|
this.$client.sendData('mouseup', { key: e.button + 1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private reqMouseDown: MouseEvent | null = null
|
||||||
|
private reqMouseUp: MouseEvent | null = null
|
||||||
|
|
||||||
|
@Watch('controlling')
|
||||||
|
onControlChange(controlling: boolean) {
|
||||||
|
if (controlling && this.reqMouseDown) {
|
||||||
|
this.onMouseDown(this.reqMouseDown)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controlling && this.reqMouseUp) {
|
||||||
|
this.onMouseUp(this.reqMouseUp)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.reqMouseDown = null
|
||||||
|
this.reqMouseUp = null
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitHostingRequest(e: MouseEvent) {
|
||||||
|
if (this.implicitHosting) {
|
||||||
|
if (e.type === 'mousedown') {
|
||||||
|
this.reqMouseDown = e
|
||||||
|
this.reqMouseUp = null
|
||||||
|
this.$accessor.remote.request()
|
||||||
|
} else if (e.type === 'mouseup') {
|
||||||
|
this.reqMouseUp = e
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.type === 'mousedown') {
|
||||||
|
this.$emit('control-attempt', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMouseMove(e: MouseEvent) {
|
onMouseMove(e: MouseEvent) {
|
||||||
if (!this.hosting || this.locked) {
|
if (!this.hosting || this.locked) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ export const state = () => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const getters = getterTree(state, {
|
export const getters = getterTree(state, {
|
||||||
|
controlling: (state, getters, root) => {
|
||||||
|
return root.user.id === state.id
|
||||||
|
},
|
||||||
hosting: (state, getters, root) => {
|
hosting: (state, getters, root) => {
|
||||||
return root.user.id === state.id || state.implicitHosting
|
return root.user.id === state.id || state.implicitHosting
|
||||||
},
|
},
|
||||||
@@ -89,7 +92,7 @@ export const actions = actionTree(
|
|||||||
},
|
},
|
||||||
|
|
||||||
request({ getters }) {
|
request({ getters }) {
|
||||||
if (!accessor.connected || getters.hosting) {
|
if (!accessor.connected || getters.controlling) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user