Skip to content

Commit

Permalink
#66 extend definition of WINDOW_SEL
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jun 24, 2019
1 parent 8938c9d commit 5371f81
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Hide power indicator from the status-bar if a battery could not be found [#60](https://github.com/koekeishiya/yabai/issues/60)
- Disable focus follows mouse while the *mouse_modifier* key is held down [#62](https://github.com/koekeishiya/yabai/issues/62)
- Silence meaningless warning reported by the scripting-bridge framework [#55](https://github.com/koekeishiya/yabai/issues/55)
- Extend definition of *WINDOW_SEL* to include *mouse*, targetting the window below the cursor [#66](https://github.com/koekeishiya/yabai/issues/66)

## [1.0.1] - 2019-06-23
### Added
Expand Down
2 changes: 1 addition & 1 deletion doc/yabai.1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Loads the scripting\-addition into Dock.app.
.nf
DIR_SEL := north | east | south | west

WINDOW_SEL := prev | next | last | DIR_SEL
WINDOW_SEL := prev | next | last | mouse | DIR_SEL

DISPLAY_SEL := prev | next | last | arrangement index (1\-based)

Expand Down
2 changes: 1 addition & 1 deletion doc/yabai.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Definitions
----
DIR_SEL := north | east | south | west
WINDOW_SEL := prev | next | last | DIR_SEL
WINDOW_SEL := prev | next | last | mouse | DIR_SEL
DISPLAY_SEL := prev | next | last | arrangement index (1-based)
Expand Down
14 changes: 11 additions & 3 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ static const char *bool_str[] = { "off", "on" };
#define COMMAND_WINDOW_DISPLAY "--display"
#define COMMAND_WINDOW_SPACE "--space"

#define ARGUMENT_WINDOW_SEL_PREV "prev"
#define ARGUMENT_WINDOW_SEL_NEXT "next"
#define ARGUMENT_WINDOW_SEL_LAST "last"
#define ARGUMENT_WINDOW_DIR_NORTH "north"
#define ARGUMENT_WINDOW_DIR_EAST "east"
#define ARGUMENT_WINDOW_DIR_SOUTH "south"
#define ARGUMENT_WINDOW_DIR_WEST "west"
#define ARGUMENT_WINDOW_SEL_MOUSE "mouse"
#define ARGUMENT_WINDOW_SEL_PREV "prev"
#define ARGUMENT_WINDOW_SEL_NEXT "next"
#define ARGUMENT_WINDOW_SEL_LAST "last"
#define ARGUMENT_WINDOW_GRID "%d:%d:%d:%d:%d:%d"
#define ARGUMENT_WINDOW_MOVE "%255[^:]:%f:%f"
#define ARGUMENT_WINDOW_RESIZE "%255[^:]:%f:%f"
Expand Down Expand Up @@ -946,6 +947,13 @@ static void handle_domain_window(FILE *rsp, struct token domain, char *message)
} else {
daemon_fail(rsp, "could not locate the selected window.\n");
}
} else if (token_equals(value, ARGUMENT_WINDOW_SEL_MOUSE)) {
struct ax_window *mouse_window = window_manager_find_window_below_cursor(&g_window_manager);
if (mouse_window) {
window_manager_focus_window_with_raise(mouse_window->id);
} else {
daemon_fail(rsp, "could not locate a window below the cursor.\n");
}
} else if (token_equals(value, ARGUMENT_WINDOW_SEL_PREV)) {
if (window) {
struct ax_window *prev_window = window_manager_find_prev_managed_window(&g_space_manager, &g_window_manager, window);
Expand Down
7 changes: 7 additions & 0 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ struct ax_window *window_manager_find_window_at_point(struct window_manager *wm,
return window_manager_find_window(wm, window_id);
}

struct ax_window *window_manager_find_window_below_cursor(struct window_manager *wm)
{
CGPoint cursor;
SLSGetCurrentCursorLocation(g_connection, &cursor);
return window_manager_find_window_at_point(wm, cursor);
}

static struct ax_window *window_manager_find_closest_window_for_direction_in_window_list(struct window_manager *wm, struct ax_window *source, int direction, uint32_t *window_list, int window_count)
{
CGRect source_frame = window_frame(source);
Expand Down
1 change: 1 addition & 0 deletions src/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct ax_window *window_manager_find_window_on_space_by_rank(struct window_mana
struct ax_window *window_manager_find_window_on_display_by_rank(struct window_manager *wm, uint32_t did, int rank);
struct ax_window *window_manager_find_window_at_point_filtering_window(struct window_manager *wm, CGPoint point, uint32_t filter_wid);
struct ax_window *window_manager_find_window_at_point(struct window_manager *wm, CGPoint point);
struct ax_window *window_manager_find_window_below_cursor(struct window_manager *wm);
struct ax_window *window_manager_find_closest_managed_window_in_direction(struct window_manager *wm, struct ax_window *window, int direction);
struct ax_window *window_manager_find_closest_window_in_direction(struct window_manager *wm, struct ax_window *window, int direction);
struct ax_window *window_manager_find_prev_managed_window(struct space_manager *sm, struct window_manager *wm, struct ax_window *window);
Expand Down

0 comments on commit 5371f81

Please sign in to comment.