From bd376578d4631217588b2d275cfdf8831987132b Mon Sep 17 00:00:00 2001 From: Unrud Date: Sun, 16 Aug 2020 10:06:57 +0200 Subject: [PATCH 001/203] Snap: Update --- snap/snapcraft.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 35e7943..93e34f5 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,3 +1,9 @@ +# Build by running "snapcraft". + +# WARNING: +# Snapcraft uses caching for already build steps but it's buggy and can cause strange problems. +# Clean the cache by running "snapcraft clean". + name: remote-touchpad license: GPL-3.0+ grade: stable @@ -31,6 +37,7 @@ parts: source-type: git build-packages: - gcc + - libc6-dev - libxt-dev - libxtst-dev stage-packages: @@ -41,7 +48,7 @@ parts: # WORKAROUND: Snapcraft Go Plugin doesn't set buildtags for go-get GOPATH="$(realpath "${SNAPCRAFT_PART_SRC}/../go")" env --chdir="$GOPATH/src" GOPATH="$GOPATH" go get -t -d -tags 'portal x11' ./github.com/Unrud/remote-touchpad/... - # WORKAROUND: Point icon to the correct location + # WORKAROUND: Point icon directly to high resolution version otherwise snapcraft automatically chooses lowest resolution sed -e 's|Icon=com.github.unrud.RemoteTouchpad|Icon=/usr/share/icons/hicolor/512x512/apps/com.github.unrud.RemoteTouchpad.png|' -i desktop/com.github.unrud.RemoteTouchpad.desktop override-build: | snapcraftctl build @@ -51,6 +58,4 @@ parts: for s in 64 128 256 512; do install -Dm0644 desktop/remote-touchpad_${s}.png "${SNAPCRAFT_PART_INSTALL}/usr/share/icons/hicolor/${s}x${s}/apps/com.github.unrud.RemoteTouchpad.png" done - # WORKAROUND: Version is not extracted from AppStream - snapcraftctl set-version "$(${SNAPCRAFT_PART_INSTALL}/bin/remote-touchpad --version)" parse-info: [usr/share/metainfo/com.github.unrud.RemoteTouchpad.appdata.xml] From 9ad8590517c79ca3322f5d2d01a9b55eda73b8bf Mon Sep 17 00:00:00 2001 From: Unrud Date: Wed, 26 Aug 2020 03:30:20 +0200 Subject: [PATCH 002/203] Cosmetics --- backend.go | 4 +- backend_portal.go | 5 +- backend_portal_disabled.go | 4 +- backend_windows.go | 4 +- backend_windows_disabled.go | 4 +- backend_x11.go | 4 +- backend_x11_disabled.go | 4 +- flatpak/com.github.unrud.RemoteTouchpad.yaml | 3 +- host.go | 4 +- keysyms.generator.go | 4 +- keysyms.go | 29 ++++++----- main.go | 4 +- qr.go | 4 +- terminal.go | 4 +- terminal_posix.go | 4 +- terminal_windows.go | 4 +- webdata/fn.js | 55 +++++++++----------- 17 files changed, 70 insertions(+), 74 deletions(-) diff --git a/backend.go b/backend.go index 98f7682..4efea54 100644 --- a/backend.go +++ b/backend.go @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/backend_portal.go b/backend_portal.go index 1f1bc6f..3de18ef 100644 --- a/backend_portal.go +++ b/backend_portal.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main @@ -35,6 +35,7 @@ const ( btnReleased uint32 = 0 btnPressed uint32 = 1 + // linux/input-event-codes.h btnLeft int32 = 0x110 btnRight int32 = 0x111 btnMiddle int32 = 0x112 diff --git a/backend_portal_disabled.go b/backend_portal_disabled.go index 499d5f5..05ca72f 100644 --- a/backend_portal_disabled.go +++ b/backend_portal_disabled.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/backend_windows.go b/backend_windows.go index 2b25cc7..78574e0 100644 --- a/backend_windows.go +++ b/backend_windows.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/backend_windows_disabled.go b/backend_windows_disabled.go index 5d902ea..b0051b0 100644 --- a/backend_windows_disabled.go +++ b/backend_windows_disabled.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/backend_x11.go b/backend_x11.go index 6749408..ad3445b 100644 --- a/backend_x11.go +++ b/backend_x11.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/backend_x11_disabled.go b/backend_x11_disabled.go index 8a68e22..11a8234 100644 --- a/backend_x11_disabled.go +++ b/backend_x11_disabled.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/flatpak/com.github.unrud.RemoteTouchpad.yaml b/flatpak/com.github.unrud.RemoteTouchpad.yaml index 9839211..ad9276c 100644 --- a/flatpak/com.github.unrud.RemoteTouchpad.yaml +++ b/flatpak/com.github.unrud.RemoteTouchpad.yaml @@ -34,8 +34,7 @@ modules: dest: src/github.com/unrud/remote-touchpad buildsystem: simple build-commands: - - . /usr/lib/sdk/golang/enable.sh; env GOPATH="$(pwd)" go build -tags 'portal x11' - github.com/unrud/remote-touchpad + - . /usr/lib/sdk/golang/enable.sh; env GOPATH="$(pwd)" go build -tags 'portal x11' github.com/unrud/remote-touchpad - install -Dm0755 -t /app/bin remote-touchpad - install -Dm0755 -t /app/bin src/github.com/unrud/remote-touchpad/desktop/remote-touchpad-wait-on-error - install -Dm0644 -t /app/share/metainfo src/github.com/unrud/remote-touchpad/desktop/com.github.unrud.RemoteTouchpad.appdata.xml diff --git a/host.go b/host.go index 2e622a8..14ed821 100644 --- a/host.go +++ b/host.go @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/keysyms.generator.go b/keysyms.generator.go index 17340be..74d479d 100644 --- a/keysyms.generator.go +++ b/keysyms.generator.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/keysyms.go b/keysyms.go index a81dfd9..dbafa70 100644 --- a/keysyms.go +++ b/keysyms.go @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main @@ -26,12 +26,13 @@ import "errors" type Keysym int32 const ( - xf86AudioLowerVolume Keysym = 0x1008ff11 - xf86AudioMute Keysym = 0x1008ff12 - xf86AudioRaiseVolume Keysym = 0x1008ff13 - xf86AudioPlay Keysym = 0x1008ff14 - xf86AudioPrev Keysym = 0x1008ff16 - xf86AudioNext Keysym = 0x1008ff17 + // X11/XF86keysym.h + xf86xkAudioLowerVolume Keysym = 0x1008ff11 + xf86xkAudioMute Keysym = 0x1008ff12 + xf86xkAudioRaiseVolume Keysym = 0x1008ff13 + xf86xkAudioPlay Keysym = 0x1008ff14 + xf86xkAudioPrev Keysym = 0x1008ff16 + xf86xkAudioNext Keysym = 0x1008ff17 ) func RuneToKeysym(runeValue rune) (Keysym, error) { @@ -51,22 +52,22 @@ func RuneToKeysym(runeValue rune) (Keysym, error) { func KeyToKeysym(key Key) (Keysym, error) { if key == KeyVolumeMute { - return xf86AudioMute, nil + return xf86xkAudioMute, nil } if key == KeyVolumeDown { - return xf86AudioLowerVolume, nil + return xf86xkAudioLowerVolume, nil } if key == KeyVolumeUp { - return xf86AudioRaiseVolume, nil + return xf86xkAudioRaiseVolume, nil } if key == KeyMediaPlayPause { - return xf86AudioPlay, nil + return xf86xkAudioPlay, nil } if key == KeyMediaPrevTrack { - return xf86AudioPrev, nil + return xf86xkAudioPrev, nil } if key == KeyMediaNextTrack { - return xf86AudioNext, nil + return xf86xkAudioNext, nil } return 0, errors.New("key not mapped to keysym") } diff --git a/main.go b/main.go index 5475122..4b9d967 100644 --- a/main.go +++ b/main.go @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/qr.go b/qr.go index 3c94b84..aae21db 100644 --- a/qr.go +++ b/qr.go @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/terminal.go b/terminal.go index 86e559c..91de022 100644 --- a/terminal.go +++ b/terminal.go @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/terminal_posix.go b/terminal_posix.go index 1e5ad90..e79ea61 100644 --- a/terminal_posix.go +++ b/terminal_posix.go @@ -15,8 +15,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/terminal_windows.go b/terminal_windows.go index 22c0c3e..5637a7d 100644 --- a/terminal_windows.go +++ b/terminal_windows.go @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ package main diff --git a/webdata/fn.js b/webdata/fn.js index 8c4fa6d..9a018b2 100644 --- a/webdata/fn.js +++ b/webdata/fn.js @@ -13,14 +13,15 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with Remote-Touchpad. If not, see . + * You should have received a copy of the GNU General Public License + * along with Remote-Touchpad. If not, see . */ -// [1 Touch, 2 Touches, 3 Touches] +// [1 Touch, 2 Touches, 3 Touches] (as pixel) const TOUCH_MOVE_THRESHOLD = [10, 15, 15]; +// Max time between consecutive touches for clicking or dragging (as milliseconds) const TOUCH_TIMEOUT = 250; -// [[px/s, mult], ...] +// [[pixel/second, multiplicator], ...] const POINTER_ACCELERATION = [ [0, 0], [87, 1], @@ -311,7 +312,7 @@ window.addEventListener("load", function() { let text = document.getElementById("text"); function showScene(scene) { - [opening, closed, pad, keys, keyboard].forEach(function (e) { + [opening, closed, pad, keys, keyboard].forEach(function(e) { e.classList.toggle("hidden", e != scene); }); } @@ -336,13 +337,10 @@ window.addEventListener("load", function() { text.value = ""; showScene(opening); - let wsProtocol = "wss:"; - if (location.protocol == "http:") { - wsProtocol = "ws:"; - } - ws = new WebSocket(wsProtocol + "//" + location.hostname + - (location.port ? ":" + location.port : "") + - "/ws"); + ws = new WebSocket( + (location.protocol == "http:" ? "ws:" : "wss:") + "//" + location.hostname + + (location.port ? ":" + location.port : "") + "/ws" + ); ws.onmessage = function(evt) { if (authenticated) { @@ -383,23 +381,21 @@ window.addEventListener("load", function() { {id: "volumedownbutton", key: KEY_VOLUME_DOWN}, {id: "volumemutebutton", key: KEY_VOLUME_MUTE}, {id: "volumeupbutton", key: KEY_VOLUME_UP}].forEach(function(o) { - document.getElementById(o.id).addEventListener("click", - function() { - ws.send("k" + o.key); - }); - }); - document.getElementById("sendbutton").addEventListener("click", - function() { - if (text.value != "") { - ws.send("t" + text.value); - text.value = ""; - } - window.history.back(); + document.getElementById(o.id).addEventListener("click", function() { + ws.send("k" + o.key); }); + }); + document.getElementById("sendbutton").addEventListener("click", function() { + if (text.value != "") { + ws.send("t" + text.value); + text.value = ""; + } + window.history.back(); + }); window.onpopstate = function() { if (!pad.classList.contains("hidden") || - !keyboard.classList.contains("hidden") || - !keys.classList.contains("hidden")) { + !keyboard.classList.contains("hidden") || + !keys.classList.contains("hidden")) { if (history.state == "keys") { showKeys(); } else if (history.state == "keyboard") { @@ -409,10 +405,9 @@ window.addEventListener("load", function() { } } }; - document.getElementById("reloadbutton").addEventListener("click", - function() { - location.reload(); - }); + document.getElementById("reloadbutton").addEventListener("click", function() { + location.reload(); + }); pad.addEventListener("touchstart", handleStart); pad.addEventListener("touchend", handleEnd); pad.addEventListener("touchcancel", handleEnd); From 1f410b5a18bbc9ac10364cd1605a04dc693afc52 Mon Sep 17 00:00:00 2001 From: Unrud Date: Wed, 26 Aug 2020 03:30:21 +0200 Subject: [PATCH 003/203] Only exit fullscreen when in fullscreen mode --- webdata/fn.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/webdata/fn.js b/webdata/fn.js index 9a018b2..627b748 100644 --- a/webdata/fn.js +++ b/webdata/fn.js @@ -318,7 +318,9 @@ window.addEventListener("load", function() { } function showKeys() { - exitFullscreen(); + if (fullscreenElement()) { + exitFullscreen(); + } showScene(keys); if (history.state != "keys") { history.pushState("keys", ""); @@ -326,7 +328,9 @@ window.addEventListener("load", function() { } function showKeyboard() { - exitFullscreen(); + if (fullscreenElement()) { + exitFullscreen(); + } showScene(keyboard); text.focus(); if (history.state != "keyboard") { @@ -359,7 +363,9 @@ window.addEventListener("load", function() { }; ws.onclose = function() { - exitFullscreen(); + if (fullscreenElement()) { + exitFullscreen(); + } showScene(closed); }; From 585a3c0dccf739073791dbaae8f069c19cf3ab5c Mon Sep 17 00:00:00 2001 From: Unrud Date: Wed, 26 Aug 2020 03:30:21 +0200 Subject: [PATCH 004/203] Reduce minimum size of textarea --- webdata/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webdata/index.html b/webdata/index.html index f7aed29..fc3fd96 100644 --- a/webdata/index.html +++ b/webdata/index.html @@ -29,7 +29,7 @@