From 818e07fc8b3c883de1d133b8aa2164b4b211a7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 10 Jan 2021 12:34:08 +0100 Subject: [PATCH] cursor image as WS event. --- src/component/internal/messages.ts | 11 +++-------- src/component/overlay.vue | 4 ++-- src/component/types/events.ts | 2 ++ src/component/types/messages.ts | 13 +++++++++++++ src/component/types/state.ts | 6 ++++-- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/component/internal/messages.ts b/src/component/internal/messages.ts index b721c062..46f385fe 100644 --- a/src/component/internal/messages.ts +++ b/src/component/internal/messages.ts @@ -81,14 +81,9 @@ export class NekoMessages extends EventEmitter { // TODO: Handle. } - // TODO: Refactor. - protected ['cursor/image']({ payload }: any) { - console.log('cursor/image') - Vue.set(this.state.control, 'cursor', { - uri: payload.Uri, - hot_x: payload.Xhot, - hot_y: payload.Yhot, - }) + protected [EVENT.CURSOR_IMAGE]({ uri, width, height, x, y }: message.CursorImage) { + console.log('EVENT.CURSOR_IMAGE') + Vue.set(this.state.control, 'cursor', { uri, width, height, x, y }) } ///////////////////////////// diff --git a/src/component/overlay.vue b/src/component/overlay.vue index 033b5d48..5ed6211b 100644 --- a/src/component/overlay.vue +++ b/src/component/overlay.vue @@ -68,8 +68,8 @@ get cursor(): string { if (!this.control.cursor) return 'auto' - const { uri, hot_x, hot_y } = this.control.cursor - return 'url(' + uri + ') ' + hot_x + ' ' + hot_y + ', auto' + const { uri, x, y } = this.control.cursor + return 'url(' + uri + ') ' + x + ' ' + y + ', auto' } mounted() { diff --git a/src/component/types/events.ts b/src/component/types/events.ts index ac219890..38188d9c 100644 --- a/src/component/types/events.ts +++ b/src/component/types/events.ts @@ -28,4 +28,6 @@ export const CLIPBOARD_SET = 'clipboard/set' export const KEYBOARD_MODIFIERS = 'keyboard/modifiers' export const KEYBOARD_LAYOUT = 'keyboard/layout' +export const CURSOR_IMAGE = 'cursor/image' + export const BORADCAST_STATUS = 'broadcast/status' diff --git a/src/component/types/messages.ts b/src/component/types/messages.ts index 72d6e17f..c94de28c 100644 --- a/src/component/types/messages.ts +++ b/src/component/types/messages.ts @@ -146,6 +146,19 @@ export interface KeyboardLayout { layout: string } +///////////////////////////// +// Cursor +///////////////////////////// + +export interface CursorImage { + event: string | undefined + uri: string + width: number + height: number + x: number + y: number +} + ///////////////////////////// // Broadcast ///////////////////////////// diff --git a/src/component/types/state.ts b/src/component/types/state.ts index 245b5fe7..b5ef0871 100644 --- a/src/component/types/state.ts +++ b/src/component/types/state.ts @@ -48,8 +48,10 @@ export interface Scroll { export interface Cursor { uri: string - hot_x: number - hot_y: number + width: number + height: number + x: number + y: number } export interface Clipboard {