Skip to content

Commit

Permalink
Do not check hostname for WM_CLASS match
Browse files Browse the repository at this point in the history
Addresses #6
  • Loading branch information
mkropat committed Jan 17, 2015
1 parent 4e2f395 commit d8b7260
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
28 changes: 11 additions & 17 deletions jumpapp
Original file line number Diff line number Diff line change
Expand Up @@ -82,36 +82,30 @@ needs_passthrough() {

list_matching_windowids() {
list_windows |
select_local_windows "$(get_hostname)" |
select_windowid_by_class_or_pid "$@" |
select_normal_windows # spawns `xprop` process per-id, so do it last
}

select_local_windows() {
local windowid hostname rest
while read -r windowid hostname rest; do
if [[ "$hostname" == "$1" ]]; then
printf '%s\n' "$windowid $rest"
fi
done
}

select_windowid_by_class_or_pid() {
local target_class=$1
shift

local local_hostname=$(get_hostname)

local windowid pid desktop class
while read -r windowid pid desktop class; do
while read -r windowid hostname pid desktop class; do
if equals_case_insensitive "$class" "$target_class"; then
printf '%s\n' "$windowid"
continue
fi
for target_pid in "$@"; do
if (( pid == target_pid )); then
printf '%s\n' "$windowid"
continue 2
fi
done
if equals_case_insensitive "$hostname" "$local_hostname"; then
for target_pid in "$@"; do
if (( pid == target_pid )); then
printf '%s\n' "$windowid"
continue 2
fi
done
fi
done
}

Expand Down
11 changes: 10 additions & 1 deletion t/test_jumpapp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ it_calls_activate_window_when_window_found_by_pid() {
assertNull 'fork_command() not called' "$fork_command_called"
}

it_calls_activate_window_only_on_local_windows() {
it_calls_activate_window_only_on_local_windows_when_window_found_by_pid() {
list_pids_for_command_output='123'
list_windows_output='456 otherhost 123 -1 some-class
567 somehost 123 -1 some-class'
Expand Down Expand Up @@ -112,6 +112,15 @@ it_calls_activate_window_when_window_found_by_class() {
assertNull 'fork_command() not called' "$fork_command_called"
}

it_calls_activate_window_when_window_found_by_class_and_hostname_is_not_set() {
list_windows_output='456 N/A 123 -1 someapp'

main someapp

assertNotNull 'activate_window() called' "$activate_window_called"
assertNull 'fork_command() not called' "$fork_command_called"
}

it_calls_activate_window_when_window_class_matches_with_different_case() {
list_windows_output='456 somehost 123 -1 SomeAPP'

Expand Down

0 comments on commit d8b7260

Please sign in to comment.