From c779a161b36a7e6562380ff8bf2ea8a6e0eb3566 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 25 Nov 2024 22:06:02 -0500 Subject: [PATCH] feat(ags osk): don't drag when a button is pressed --- .../config/widgets/on-screen-keyboard/_index.scss | 5 +++-- .../config/widgets/on-screen-keyboard/gesture.ts | 15 ++++++++++++--- .../config/widgets/on-screen-keyboard/keys.tsx | 6 ++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss b/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss index e36fa32f..479a3948 100644 --- a/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss +++ b/nixosModules/ags/config/widgets/on-screen-keyboard/_index.scss @@ -39,11 +39,12 @@ transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out; box-shadow: 2px 1px 2px gray; - margin: 4px 10px 4px 10px; + + margin: 4px 4px 4px 4px; &.active { box-shadow: 0 0 0 white; - margin: 6px 10px 2px 10px; + margin: 6px 4px 2px 4px; background-color: color.adjust(colors.$window_bg_color, $lightness: -3%); } diff --git a/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts b/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts index 51b50094..7ba638f1 100644 --- a/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts +++ b/nixosModules/ags/config/widgets/on-screen-keyboard/gesture.ts @@ -5,17 +5,18 @@ import Tablet from '../../services/tablet'; import { hyprMessage } from '../../lib'; import OskWindow from './osk-window'; +import { Keys } from './keys'; const KEY_N = 249; -const KEYCODES = Array.from(Array(KEY_N).keys()); +const KEYCODES = Array.from(Array(KEY_N).keys()).map((keycode) => `${keycode}:0`); const ANIM_DURATION = 700; const releaseAllKeys = () => { execAsync([ 'ydotool', 'key', - ...KEYCODES.map((keycode) => `${keycode}:0`), + ...KEYCODES, ]).catch(print); }; @@ -136,6 +137,8 @@ export default (window: OskWindow) => { margin-bottom: -${calculatedHeight}px; `; } + + window.startY = null; }); }), ); @@ -148,7 +151,11 @@ export default (window: OskWindow) => { signals.push( gesture.connect('drag-begin', () => { hyprMessage('j/cursorpos').then((out) => { - window.startY = JSON.parse(out).y; + const hasActiveKey = Keys.get().map((v) => v.get()).includes(true); + + if (!hasActiveKey) { + window.startY = JSON.parse(out).y; + } }); }), ); @@ -205,6 +212,8 @@ export default (window: OskWindow) => { margin-bottom: 0px; `; } + + window.startY = null; }); }), ); diff --git a/nixosModules/ags/config/widgets/on-screen-keyboard/keys.tsx b/nixosModules/ags/config/widgets/on-screen-keyboard/keys.tsx index ba89de1f..d2581b4e 100644 --- a/nixosModules/ags/config/widgets/on-screen-keyboard/keys.tsx +++ b/nixosModules/ags/config/widgets/on-screen-keyboard/keys.tsx @@ -25,6 +25,8 @@ const LSHIFT_CODE = 42; const LALT_CODE = 56; const LCTRL_CODE = 29; +export const Keys = Variable[]>([]); + // Keep track of modifier statuses const Super = Variable(false); const LAlt = Variable(false); @@ -84,6 +86,8 @@ const ModKey = (key: Key) => { Mod = RCtrl; } + Keys.set([...Keys.get(), Mod!]); + const label = (