Skip to content

Commit

Permalink
Fix searching windows by ahk_class
Browse files Browse the repository at this point in the history
sometimes, when `class` and `class_name` differ, the value of `WinGetClass` and the used value for searching `ahk_class` were different. Now only the non-name `class` value is handled.

Fixes #60
  • Loading branch information
phil294 committed Oct 21, 2023
1 parent 83cf9b5 commit 1673aac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cmd/x11/window/win-get-class.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Cmd::X11::Window::WinGetClass < Cmd::Base
match_conditions = args[1..]? || [] of ::String
out_var = args[0]
Util.match(thread, match_conditions, empty_is_last_found: true, a_is_active: true) do |win|
# We seem to actually get class here, not class_name
thread.runner.set_user_var(out_var, win.class_name || "")
return
end
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/x11/window/win-util.cr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Cmd::X11::Window::Util
end
if title.starts_with?("ahk_class ")
# TODO: these/name etc should all be case sensitive. Maybe double filter below? How performant is querying for .name etc?
window_class_name title[10..] # TODO: is this regex? how to make partial matches like ahk?
window_class title[10..] # TODO: is this regex? how to make partial matches like ahk?
else
title = ".*" if title.empty?
window_name title # todo same as above / seems to be partial match but only at *start* of string
Expand Down

0 comments on commit 1673aac

Please sign in to comment.