feat(ags): add method to decide x pos of popup windows
This commit is contained in:
parent
6805c0f521
commit
71d69c88ec
4 changed files with 36 additions and 4 deletions
|
@ -12,7 +12,12 @@ const SPACING = 4;
|
|||
export default () => EventBox({
|
||||
className: 'toggle-off',
|
||||
|
||||
onPrimaryClickRelease: () => App.toggleWindow('notification-center'),
|
||||
onPrimaryClickRelease: (self) => {
|
||||
App.getWindow('notification-center')
|
||||
.setXPos(self.get_allocation(), 'right');
|
||||
|
||||
App.toggleWindow('notification-center');
|
||||
},
|
||||
|
||||
connections: [[App, (self, windowName, visible) => {
|
||||
if (windowName === 'notification-center') {
|
||||
|
|
|
@ -19,7 +19,12 @@ export default () => EventBox({
|
|||
|
||||
onHoverLost: () => { /**/ },
|
||||
|
||||
onPrimaryClickRelease: () => App.toggleWindow('quick-settings'),
|
||||
onPrimaryClickRelease: (self) => {
|
||||
App.getWindow('notification-center')
|
||||
.setXPos(self.get_allocation(), 'right');
|
||||
|
||||
App.toggleWindow('quick-settings');
|
||||
},
|
||||
|
||||
connections: [[App, (self, windowName, visible) => {
|
||||
if (windowName === 'quick-settings') {
|
||||
|
|
|
@ -78,6 +78,29 @@ export default ({
|
|||
}),
|
||||
});
|
||||
|
||||
window.setXPos = (
|
||||
alloc,
|
||||
side = 'right',
|
||||
) => {
|
||||
const width = window.get_display()
|
||||
.get_monitor_at_point(alloc.x, alloc.y)
|
||||
.get_geometry().width;
|
||||
|
||||
window.margins = [
|
||||
window.margins[0],
|
||||
|
||||
side === 'right' ?
|
||||
(width - alloc.x - alloc.width) :
|
||||
window.margins[1],
|
||||
|
||||
window.margins[2],
|
||||
|
||||
side === 'right' ?
|
||||
window.margins[3] :
|
||||
(alloc.x - alloc.width),
|
||||
];
|
||||
};
|
||||
|
||||
// Make getting the original child passed in this
|
||||
// function easier when making more code for the widget
|
||||
window.getChild = () => window.child.children[0].child;
|
||||
|
|
|
@ -15,12 +15,11 @@ export const NotifPopups = () => PopupWindow({
|
|||
|
||||
|
||||
const TOP_MARGIN = 6;
|
||||
const RIGHT_MARGIN = 60;
|
||||
|
||||
export const NotifCenter = () => PopupWindow({
|
||||
name: 'notification-center',
|
||||
anchor: ['top', 'right'],
|
||||
margins: [TOP_MARGIN, RIGHT_MARGIN, 0, 0],
|
||||
margins: [TOP_MARGIN, 0, 0, 0],
|
||||
|
||||
child: NotifCenterWidget(),
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue