Skip to content

Commit

Permalink
fix empty timeout for WinWait/Close
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Jul 20, 2023
1 parent c0749d4 commit c22483c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cmd/x11/window/win-wait-close.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Cmd::X11::Window::WinWaitClose < Cmd::Base
def self.max_args; 5 end
def self.sets_error_level; true end
def run(thread, args)
seconds = args[2].to_f? || 0.5
seconds = args[2].to_f?
seconds = 0.5 if seconds == 0
match_conditions = args
match_conditions.delete_at(2)
is_gone = false
::Util::ExponentialBackOff.back_off(initial_interval: 20.milliseconds, factor: 1.15, max_interval: 0.8.seconds, timeout: seconds.seconds) do
::Util::ExponentialBackOff.back_off(initial_interval: 20.milliseconds, factor: 1.15, max_interval: 0.8.seconds, timeout: seconds ? seconds.seconds : nil) do
Util.match(thread, match_conditions, empty_is_last_found: true, a_is_active: false) do |win|
# Since LastFoundWindow is allowed, we might get that back even though it doesn't exist anymore,
# so we verify if the window is dead:
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/x11/window/win-wait.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class Cmd::X11::Window::WinWait < Cmd::Base
def self.max_args; 5 end
def self.sets_error_level; true end
def run(thread, args)
seconds = args[2].to_f? || 0.5
seconds = args[2].to_f?
seconds = 0.5 if seconds == 0
match_conditions = args
match_conditions.delete_at(2)
match = ::Util::ExponentialBackOff.back_off(initial_interval: 20.milliseconds, factor: 1.15, max_interval: 0.8.seconds, timeout: seconds.seconds) do
match = ::Util::ExponentialBackOff.back_off(initial_interval: 20.milliseconds, factor: 1.15, max_interval: 0.8.seconds, timeout: seconds ? seconds.seconds : nil) do
Util.match(thread, match_conditions, empty_is_last_found: false, a_is_active: false) do |win|
thread.settings.last_found_window = win
end
Expand Down

0 comments on commit c22483c

Please sign in to comment.