From e952989801783d09202b4fb6006633f17f10e5d3 Mon Sep 17 00:00:00 2001 From: Mika Valkealahti Date: Fri, 20 Mar 2026 00:38:44 +0200 Subject: [PATCH 1/2] Fix: focus-out-event shouldn't be trigger twice when screenshot is opened --- usr/lib/linuxmint/mintinstall/screenshot_window.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/usr/lib/linuxmint/mintinstall/screenshot_window.py b/usr/lib/linuxmint/mintinstall/screenshot_window.py index 223e26e3..795103a8 100644 --- a/usr/lib/linuxmint/mintinstall/screenshot_window.py +++ b/usr/lib/linuxmint/mintinstall/screenshot_window.py @@ -60,6 +60,7 @@ def __init__(self, parent, multiple_screenshots): self.swipe_handler.set_propagation_phase(Gtk.PropagationPhase.CAPTURE) self.swipe_handler.connect("swipe", self.swipe_or_button_release) self.connect("key-press-event", self.on_key_press_event) + self.previous_focus_out_event_time = 0 self.connect("focus-out-event", self.on_focus_out_event) self.scroll_handler = Gtk.EventControllerScroll.new(self, Gtk.EventControllerScrollFlags.VERTICAL) @@ -171,7 +172,12 @@ def on_scroll_event(self, controller, xd, yd, data=None): return Gdk.EVENT_PROPAGATE def on_focus_out_event(self, window, event, data=None): - GLib.timeout_add(200, lambda w: w.hide(), window) + # If System settings --> Keyboard --> Remember the last layout used for each window" is enabled + # It will cause multiple events which would trigger picture to close immediately after opening it + event_time = Gtk.get_current_event().get_time() + if event_time != self.previous_focus_out_event_time: + GLib.timeout_add(200, lambda w: w.hide(), window) + self.previous_focus_out_event_time = event_time return Gdk.EVENT_STOP def swipe_or_button_release(self, handler, vx, vy): From 5c70766530962c0b27e7e71e6f15d77de03b6e7f Mon Sep 17 00:00:00 2001 From: mikavlahti Date: Fri, 20 Mar 2026 00:38:44 +0200 Subject: [PATCH 2/2] Fix: focus-out-event shouldn't be trigger twice when screenshot is opened --- usr/lib/linuxmint/mintinstall/screenshot_window.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/usr/lib/linuxmint/mintinstall/screenshot_window.py b/usr/lib/linuxmint/mintinstall/screenshot_window.py index 223e26e3..795103a8 100644 --- a/usr/lib/linuxmint/mintinstall/screenshot_window.py +++ b/usr/lib/linuxmint/mintinstall/screenshot_window.py @@ -60,6 +60,7 @@ def __init__(self, parent, multiple_screenshots): self.swipe_handler.set_propagation_phase(Gtk.PropagationPhase.CAPTURE) self.swipe_handler.connect("swipe", self.swipe_or_button_release) self.connect("key-press-event", self.on_key_press_event) + self.previous_focus_out_event_time = 0 self.connect("focus-out-event", self.on_focus_out_event) self.scroll_handler = Gtk.EventControllerScroll.new(self, Gtk.EventControllerScrollFlags.VERTICAL) @@ -171,7 +172,12 @@ def on_scroll_event(self, controller, xd, yd, data=None): return Gdk.EVENT_PROPAGATE def on_focus_out_event(self, window, event, data=None): - GLib.timeout_add(200, lambda w: w.hide(), window) + # If System settings --> Keyboard --> Remember the last layout used for each window" is enabled + # It will cause multiple events which would trigger picture to close immediately after opening it + event_time = Gtk.get_current_event().get_time() + if event_time != self.previous_focus_out_event_time: + GLib.timeout_add(200, lambda w: w.hide(), window) + self.previous_focus_out_event_time = event_time return Gdk.EVENT_STOP def swipe_or_button_release(self, handler, vx, vy):