feat(ags): remove squeekboard dependency

This commit is contained in:
matt1432 2024-04-07 11:34:44 -04:00
parent 9766d98542
commit 4e7904775b
11 changed files with 54 additions and 155 deletions
modules/ags/config/ts

View file

@ -11,7 +11,7 @@ const HIDDEN_MARGIN = 340;
const ANIM_DURATION = 700;
// Types
import { BoxGeneric } from 'global-types';
import { OskWindow } from 'global-types';
const releaseAllKeys = () => {
@ -23,11 +23,10 @@ const releaseAllKeys = () => {
]).catch(print);
};
export default (window) => {
export default (window: OskWindow) => {
const gesture = Gtk.GestureDrag.new(window);
const child = window.child as BoxGeneric;
child.setCss(`margin-bottom: -${HIDDEN_MARGIN}px;`);
window.child.setCss(`margin-bottom: -${HIDDEN_MARGIN}px;`);
let signals = [] as Array<number>;
@ -39,14 +38,14 @@ export default (window) => {
window.visible = true;
window.attribute.setSlideDown();
child.setCss(`
window.child.setCss(`
transition: margin-bottom 0.7s
cubic-bezier(0.36, 0, 0.66, -0.56);
margin-bottom: 0px;
`);
}
else {
timeout(ANIM_DURATION + 10, () => {
timeout(ANIM_DURATION + 100 + 100, () => {
if (!Tablet.tabletMode) {
window.visible = false;
}
@ -54,7 +53,7 @@ export default (window) => {
releaseAllKeys();
window.attribute.setSlideUp();
child.setCss(`
window.child.setCss(`
transition: margin-bottom 0.7s
cubic-bezier(0.36, 0, 0.66, -0.56);
margin-bottom: -${HIDDEN_MARGIN}px;
@ -86,6 +85,10 @@ export default (window) => {
signals.push(
gesture.connect('drag-update', () => {
Hyprland.messageAsync('j/cursorpos').then((out) => {
if (!window.attribute.startY) {
return;
}
const currentY = JSON.parse(out).y;
const offset = window.attribute.startY - currentY;
@ -93,7 +96,7 @@ export default (window) => {
return;
}
(window.child as BoxGeneric).setCss(`
window.child.setCss(`
margin-bottom: ${offset - HIDDEN_MARGIN}px;
`);
});
@ -103,7 +106,7 @@ export default (window) => {
// End drag
signals.push(
gesture.connect('drag-end', () => {
(window.child as BoxGeneric).setCss(`
window.child.setCss(`
transition: margin-bottom 0.5s ease-in-out;
margin-bottom: -${HIDDEN_MARGIN}px;
`);
@ -127,6 +130,10 @@ export default (window) => {
signals.push(
gesture.connect('drag-update', () => {
Hyprland.messageAsync('j/cursorpos').then((out) => {
if (!window.attribute.startY) {
return;
}
const currentY = JSON.parse(out).y;
const offset = window.attribute.startY - currentY;
@ -134,7 +141,7 @@ export default (window) => {
return;
}
(window.child as BoxGeneric).setCss(`
window.child.setCss(`
margin-bottom: ${offset}px;
`);
});
@ -144,7 +151,7 @@ export default (window) => {
// End drag
signals.push(
gesture.connect('drag-end', () => {
(window.child as BoxGeneric).setCss(`
window.child.setCss(`
transition: margin-bottom 0.5s ease-in-out;
margin-bottom: 0px;
`);

View file

@ -16,10 +16,10 @@ const COLOR = 'rgba(0, 0, 0, 0.3)';
const SPACING = 4;
// Types
import { BoxGeneric, WindowGeneric } from 'global-types';
import { BoxGeneric, OskWindow } from 'global-types';
export default (window: WindowGeneric) => Box({
export default (window: OskWindow) => Box({
vertical: true,
children: [
CenterBox({

View file

@ -5,6 +5,8 @@ import Tablet from '../../services/tablet.ts';
import Gesture from './gesture.ts';
import Keyboard from './keyboard.ts';
/* Types */
import { OskWindow } from 'global-types';
// Start ydotool daemon
execAsync('ydotoold').catch(print);
@ -13,24 +15,16 @@ execAsync('ydotoold').catch(print);
export default () => {
const window = Window({
name: 'osk',
visible: false,
layer: 'overlay',
anchor: ['left', 'bottom', 'right'],
})
.hook(Tablet, (self: OskWindow, state) => {
self.attribute.setVisible(state);
}, 'osk-toggled')
setup: (self) => {
self
.hook(Tablet, (_, state) => {
// @ts-expect-error too lazy to do keyboard type
self.attribute.setVisible(state);
}, 'osk-toggled')
.hook(Tablet, () => {
if (!Tablet.tabletMode && !Tablet.oskState) {
window.visible = false;
}
}, 'mode-toggled');
},
});
.hook(Tablet, () => {
window.visible = !(!Tablet.tabletMode && !Tablet.oskState);
}, 'mode-toggled');
window.child = Keyboard(window);

View file

@ -1,4 +1,3 @@
const Hyprland = await Service.import('hyprland');
const Bluetooth = await Service.import('bluetooth');
import Brightness from '../services/brightness.ts';
@ -34,33 +33,17 @@ export default () => {
name: 'oskOn',
gesture: 'DU',
edge: 'B',
command: 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 ' +
'SetVisible b true',
command: () => {
Tablet.oskState = true;
},
});
TouchGestures.addGesture({
name: 'oskOff',
gesture: 'UD',
edge: 'B',
command: 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 ' +
'SetVisible b false',
});
TouchGestures.addGesture({
name: 'swipeSpotify1',
gesture: 'LR',
edge: 'L',
command: () => Hyprland.messageAsync(
'dispatch togglespecialworkspace spot',
),
});
TouchGestures.addGesture({
name: 'swipeSpotify2',
gesture: 'RL',
edge: 'L',
command: () => Hyprland.messageAsync(
'dispatch togglespecialworkspace spot',
),
command: () => {
Tablet.oskState = false;
},
});
};