Skip to content

Commit a8473ff

Browse files
author
Sergey Trotsyuk
committed
examples/i3-focus/history-server.py: Remove window id from history on close
1 parent 8ee7493 commit a8473ff

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

examples/i3-focus/history-server.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
class FocusWatcher:
1919
def __init__(self):
2020
self.i3 = i3ipc.Connection()
21-
self.i3.on('window::focus', self._on_window_focus)
21+
self.i3.on(i3ipc.Event.WINDOW_FOCUS, self._on_window_focus)
22+
self.i3.on(i3ipc.Event.WINDOW_CLOSE, self._on_window_close)
2223
self.listening_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
2324
if os.path.exists(args.socket_file):
2425
os.remove(args.socket_file)
@@ -42,10 +43,18 @@ def _on_window_focus(self, i3conn, event):
4243
with self.window_list_lock:
4344
if window_id in self.window_list:
4445
self.window_list.remove(window_id)
46+
4547
self.window_list.insert(0, window_id)
48+
4649
if len(self.window_list) > MAX_WIN_HISTORY:
4750
del self.window_list[MAX_WIN_HISTORY:]
4851

52+
def _on_window_close(self, i3conn, event):
53+
window_id = event.container.id
54+
with self.window_list_lock:
55+
if window_id in self.window_list:
56+
self.window_list.remove(window_id)
57+
4958
def _launch_i3(self):
5059
self.i3.main()
5160

0 commit comments

Comments
 (0)