Open SergeyKasmy opened 4 years ago
Did a bit of recon to figure out a bit about how things are done currently.
Screen offsets for new notifications are calculated here. The vertical position is calculated here, by adding up the heights of the notifications that are currently being displayed, which is why new notifications appear at the bottom of the stack. This sum is used here to set the position of the new notification, and also here, to be stored and used to sum up for the next notification that appears.
To implement newFirst
for popups, there are a few changes we'd have to make, but they all fall into two categories: Insertion and deletion:
On Insertion:
(fromIntegral distanceTop) + screenY
The vertical position for all existing notifs should be 'pushed down' by adding height + distanceBetween
to them. If we're willing to do a refactor for notification popups, and replace dNotiTop
with dPos :: Int32 * Int32
(length by height), you could do something like the following:
updatePos
:: MonadIO m
=> DisplayingNotificationPopup -- ^ notification to update
-> (Int32 -> Int32) -- ^ update function for horizontal position
-> (Int32 -> Int32) -- ^ update function for vertical position
-> m DisplayingNotificationPopup -- ^ updated notification
updatePos noti f g = do
let (posX, posY) = update $ dPos noti
where update (x, y) = (f x, g y)
windowMove (dMainWindow noti) posX posY
return noti { _dPos = (posX, posY) }
-- To move a notif 3 pixels down:
updatePos notif id (+3)
On Deletion:
let deletedHeight = snd $ dPos deletedNotif
notisBelow = filter (\n -> (snd $ dPos n) > deletedHeight) dispNotis
pushDown noti = updatePos noti id (+ deletedHeight)
in mapM pushDown notisBelow
The notification center itself is already able to show the newest notifications on the top, top to bottom. It would be awesome if the popups themselves also had a similar setting, so that the oldest popups where at the bottom and disappeared first, i.e. bottom to top
Example from Plasma