Allow o key to take effect in any chunk of OSC 99

This commit is contained in:
Kovid Goyal
2023-10-25 15:50:58 +05:30
parent 47b8b442dc
commit 0ce996120a
2 changed files with 6 additions and 2 deletions

View File

@@ -82,6 +82,7 @@ Detailed list of changes
- :doc:`desktop notification protocol </desktop-notifications>`: Allow applications sending notifications to specify that the notification should only be displayed if the window is currently unfocused (:iss:`6755`)
0.30.1 [2023-10-05]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -70,6 +70,7 @@ def notify_implementation(title: str, body: str, identifier: str) -> None:
class OnlyWhen(Enum):
unset = ''
always = 'always'
unfocused = 'unfocused'
invisible = 'invisible'
@@ -82,7 +83,7 @@ class NotificationCommand:
title: str = ''
body: str = ''
actions: str = ''
only_when: OnlyWhen = OnlyWhen.always
only_when: OnlyWhen = OnlyWhen.unset
def __repr__(self) -> str:
return f'NotificationCommand(identifier={self.identifier!r}, title={self.title!r}, body={self.body!r}, actions={self.actions!r}, done={self.done!r})'
@@ -165,6 +166,8 @@ def merge_osc_99(prev: NotificationCommand, cmd: NotificationCommand) -> Notific
cmd.actions = limit_size(f'{prev.actions},{cmd.actions}')
cmd.title = limit_size(prev.title + cmd.title)
cmd.body = limit_size(prev.body + cmd.body)
if cmd.only_when is OnlyWhen.unset:
cmd.only_when = prev.only_when
return cmd
@@ -222,7 +225,7 @@ def notify_with_command(cmd: NotificationCommand, window_id: int, notify_impleme
body = cmd.body if cmd.title else ''
if not title:
return
if cmd.only_when is not OnlyWhen.always:
if cmd.only_when is not OnlyWhen.always and cmd.only_when is not OnlyWhen.unset:
w = get_boss().window_id_map.get(window_id)
if w is None:
return