feat(ags): add swipe gesture to open quick-settings
This commit is contained in:
parent
c66909efed
commit
7d45c18843
2 changed files with 73 additions and 38 deletions
32
config/ags/js/bar/gesture.js
Normal file
32
config/ags/js/bar/gesture.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
const { Window, CenterBox, EventBox, Button } = ags.Widget;
|
||||||
|
const { openWindow } = ags.App;
|
||||||
|
const { Gtk, Gdk } = imports.gi;
|
||||||
|
const display = Gdk.Display.get_default();
|
||||||
|
|
||||||
|
export const Gesture = ({
|
||||||
|
child,
|
||||||
|
...params
|
||||||
|
}) => {
|
||||||
|
let w = EventBox({
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
|
let gesture = Gtk.GestureSwipe.new(w);
|
||||||
|
|
||||||
|
w.child = CenterBox({
|
||||||
|
children: [
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
connections: [
|
||||||
|
|
||||||
|
[gesture, box => {
|
||||||
|
const velocity = gesture.get_velocity()[1];
|
||||||
|
if (velocity < -50)
|
||||||
|
openWindow('quick-settings');
|
||||||
|
}, 'update'],
|
||||||
|
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
return w;
|
||||||
|
};
|
|
@ -12,6 +12,7 @@ import { SysTray } from './systray.js';
|
||||||
import { BatteryIndicator } from './battery.js';
|
import { BatteryIndicator } from './battery.js';
|
||||||
import { Brightness } from './brightness.js';
|
import { Brightness } from './brightness.js';
|
||||||
import { AudioIndicator } from './audio.js';
|
import { AudioIndicator } from './audio.js';
|
||||||
|
import { Gesture } from './gesture.js';
|
||||||
|
|
||||||
export const Bar = Window({
|
export const Bar = Window({
|
||||||
name: 'bar',
|
name: 'bar',
|
||||||
|
@ -19,6 +20,7 @@ export const Bar = Window({
|
||||||
anchor: 'top left right',
|
anchor: 'top left right',
|
||||||
exclusive: true,
|
exclusive: true,
|
||||||
|
|
||||||
|
child: Gesture({
|
||||||
child: CenterBox({
|
child: CenterBox({
|
||||||
className: 'transparent',
|
className: 'transparent',
|
||||||
halign: 'fill',
|
halign: 'fill',
|
||||||
|
@ -75,4 +77,5 @@ export const Bar = Window({
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue