feat(ags osk): add exclusive toggle
This commit is contained in:
parent
28570f7ac2
commit
2a64ff2a96
3 changed files with 57 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { Box, CenterBox } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Box, CenterBox, Label, ToggleButton } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import Separator from '../misc/separator.js';
|
import Separator from '../misc/separator.js';
|
||||||
|
|
||||||
import Key from './keys.js';
|
import Key from './keys.js';
|
||||||
|
@ -10,7 +10,7 @@ const keyboardJson = oskLayouts[keyboardLayout];
|
||||||
const L_KEY_PER_ROW = [8, 7, 6, 6, 6, 4];
|
const L_KEY_PER_ROW = [8, 7, 6, 6, 6, 4];
|
||||||
|
|
||||||
|
|
||||||
export default () => CenterBox({
|
export default window => CenterBox({
|
||||||
class_name: 'osk',
|
class_name: 'osk',
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
start_widget: Box({
|
start_widget: Box({
|
||||||
|
@ -33,6 +33,25 @@ export default () => CenterBox({
|
||||||
|
|
||||||
center_widget: Box({
|
center_widget: Box({
|
||||||
hpack: 'center',
|
hpack: 'center',
|
||||||
|
vpack: 'center',
|
||||||
|
children: [
|
||||||
|
Box({
|
||||||
|
class_name: 'settings',
|
||||||
|
children: [
|
||||||
|
ToggleButton({
|
||||||
|
cursor: 'pointer',
|
||||||
|
class_name: 'button',
|
||||||
|
active: true,
|
||||||
|
vpack: 'center',
|
||||||
|
connections: [['toggled', self => {
|
||||||
|
self.toggleClassName('toggled', self.get_active());
|
||||||
|
window.exclusivity = self.get_active() ? 'exclusive' : 'normal';
|
||||||
|
}]],
|
||||||
|
child: Label('Exclusive'),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
end_widget: Box({
|
end_widget: Box({
|
||||||
|
|
|
@ -10,20 +10,24 @@ execAsync('ydotoold').catch(print);
|
||||||
|
|
||||||
function releaseAllKeys() {
|
function releaseAllKeys() {
|
||||||
const keycodes = Array.from(Array(249).keys());
|
const keycodes = Array.from(Array(249).keys());
|
||||||
execAsync(['ydotool', 'key', ...keycodes.map(keycode => `${keycode}:0`)])
|
execAsync([
|
||||||
.then(console.log('Released all keys'))
|
'ydotool', 'key',
|
||||||
.catch(print);
|
...keycodes.map(keycode => `${keycode}:0`),
|
||||||
|
]).catch(print);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
export default () => Gesture(PopupWindow({
|
export default () => {
|
||||||
name: 'osk',
|
const window = PopupWindow({
|
||||||
exclusivity: 'exclusive',
|
name: 'osk',
|
||||||
anchor: ['left', 'bottom', 'right'],
|
anchor: ['left', 'bottom', 'right'],
|
||||||
onClose: releaseAllKeys,
|
onClose: releaseAllKeys,
|
||||||
closeOnUnfocus: 'none',
|
closeOnUnfocus: 'none',
|
||||||
connections: [[Tablet, self => {
|
connections: [[Tablet, self => {
|
||||||
self.visible = Tablet.oskState;
|
self.visible = Tablet.oskState;
|
||||||
}, 'osk-toggled']],
|
}, 'osk-toggled']],
|
||||||
child: Keyboard(),
|
});
|
||||||
}));
|
window.setChild(Keyboard(window));
|
||||||
|
|
||||||
|
return Gesture(window);
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
.osk {
|
.osk {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
|
|
||||||
|
.settings {
|
||||||
|
background-color: $bg;
|
||||||
|
border: 0.08rem solid $darkbg;
|
||||||
|
border-radius: 0.7rem;
|
||||||
|
padding: 0.6rem;
|
||||||
|
|
||||||
|
.button {
|
||||||
|
background-color: $bgfull;
|
||||||
|
border: 0.08rem solid $darkbg;
|
||||||
|
border-radius: 0.7rem;
|
||||||
|
padding: 0.5rem;
|
||||||
|
|
||||||
|
&.toggled {
|
||||||
|
background-color: $contrast-bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.side {
|
.side {
|
||||||
.key {
|
.key {
|
||||||
&:active label {
|
&:active label {
|
||||||
|
|
Loading…
Reference in a new issue