Skip to content

Commit

Permalink
koekeishiya#644 extend *SPACE_SEL* and *DISPLAY_SEL* to include selec…
Browse files Browse the repository at this point in the history
…tor *mouse*
  • Loading branch information
koekeishiya authored and unrevre committed Aug 26, 2020
1 parent d74a886 commit fb3145b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Border windows should not have shadows [#617](https://github.com/koekeishiya/yabai/issues/617)
- *external_bar* should not have to be set before regular padding [#615](https://github.com/koekeishiya/yabai/issues/615)
- Adjust reported mouse location to use when synthesizing events for ffm autofocus [#637](https://github.com/koekeishiya/yabai/issues/637)
- Extend *SPACE_SEL* and *DISPLAY_SEL* to include the option *mouse* [#644](https://github.com/koekeishiya/yabai/issues/644)

## [3.2.1] - 2020-06-17
### Changed
Expand Down
8 changes: 4 additions & 4 deletions doc/yabai.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: yabai
.\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.10
.\" Date: 2020-08-25
.\" Date: 2020-08-26
.\" Manual: Yabai Manual
.\" Source: Yabai
.\" Language: English
.\"
.TH "YABAI" "1" "2020-08-25" "Yabai" "Yabai Manual"
.TH "YABAI" "1" "2020-08-26" "Yabai" "Yabai Manual"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
Expand Down Expand Up @@ -104,9 +104,9 @@ DIR_SEL := north | east | south | west | above | below

WINDOW_SEL := prev | next | first | last | recent | mouse | largest | smallest | DIR_SEL | <window id>

DISPLAY_SEL := prev | next | first | last | recent | DIR_SEL | <arrangement index (1\-based)>
DISPLAY_SEL := prev | next | first | last | recent | mouse | DIR_SEL | <arrangement index (1\-based)>

SPACE_SEL := prev | next | first | last | recent | <mission\-control index (1\-based)> | LABEL
SPACE_SEL := prev | next | first | last | recent | mouse | <mission\-control index (1\-based)> | LABEL
.fi
.if n .RE
.SH "DOMAINS"
Expand Down
4 changes: 2 additions & 2 deletions doc/yabai.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ DIR_SEL := north | east | south | west | above | below
WINDOW_SEL := prev | next | first | last | recent | mouse | largest | smallest | DIR_SEL | <window id>
DISPLAY_SEL := prev | next | first | last | recent | DIR_SEL | <arrangement index (1-based)>
DISPLAY_SEL := prev | next | first | last | recent | mouse | DIR_SEL | <arrangement index (1-based)>
SPACE_SEL := prev | next | first | last | recent | <mission-control index (1-based)> | LABEL
SPACE_SEL := prev | next | first | last | recent | mouse | <mission-control index (1-based)> | LABEL
----

Domains
Expand Down
7 changes: 7 additions & 0 deletions src/display_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ uint32_t display_manager_arrangement_display_id(int arrangement)
return result;
}

uint32_t display_manager_cursor_display_id(void)
{
CGPoint cursor;
SLSGetCurrentCursorLocation(g_connection, &cursor);
return display_manager_point_display_id(cursor);
}

uint32_t display_manager_prev_display_id(uint32_t did)
{
int arrangement = display_arrangement(did);
Expand Down
1 change: 1 addition & 0 deletions src/display_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CFStringRef display_manager_dock_display_uuid(void);
uint32_t display_manager_dock_display_id(void);
CFStringRef display_manager_point_display_uuid(CGPoint point);
uint32_t display_manager_point_display_id(CGPoint point);
uint32_t display_manager_cursor_display_id(void);
CFStringRef display_manager_arrangement_display_uuid(int arrangement);
uint32_t display_manager_arrangement_display_id(int arrangement);
uint32_t display_manager_prev_display_id(uint32_t did);
Expand Down
15 changes: 15 additions & 0 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ extern bool g_verbose;
#define ARGUMENT_COMMON_SEL_EAST "east"
#define ARGUMENT_COMMON_SEL_SOUTH "south"
#define ARGUMENT_COMMON_SEL_WEST "west"
#define ARGUMENT_COMMON_SEL_MOUSE "mouse"
/* ----------------------------------------------------------------------------- */

static bool token_equals(struct token token, char *match)
Expand Down Expand Up @@ -963,6 +964,13 @@ static struct selector parse_display_selector(FILE *rsp, char **message, uint32_
}
} else if (token_equals(result.token, ARGUMENT_COMMON_SEL_RECENT)) {
result.did = g_display_manager.last_display_id;
} else if (token_equals(result.token, ARGUMENT_COMMON_SEL_MOUSE)) {
uint32_t did = display_manager_cursor_display_id();
if (did) {
result.did = did;
} else {
daemon_fail(rsp, "could not locate display containing cursor.\n");
}
} else if (token_is_valid(result.token)) {
int arrangement_index = 0;
if (token_to_int(result.token, &arrangement_index)) {
Expand Down Expand Up @@ -1033,6 +1041,13 @@ static struct selector parse_space_selector(FILE *rsp, char **message, uint64_t
}
} else if (token_equals(result.token, ARGUMENT_COMMON_SEL_RECENT)) {
result.sid = g_space_manager.last_space_id;
} else if (token_equals(result.token, ARGUMENT_COMMON_SEL_MOUSE)) {
uint64_t sid = space_manager_cursor_space();
if (sid) {
result.sid = sid;
} else {
daemon_fail(rsp, "could not locate space containing cursor.\n");
}
} else if (token_is_valid(result.token)) {
int mci = 0;
if (token_to_int(result.token, &mci)) {
Expand Down
6 changes: 6 additions & 0 deletions src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ uint64_t space_manager_mission_control_space(int desktop_id)
return result;
}

uint64_t space_manager_cursor_space(void)
{
uint32_t did = display_manager_cursor_display_id();
return display_space_id(did);
}

uint64_t space_manager_prev_space(uint64_t sid)
{
uint64_t p_sid = 0;
Expand Down
1 change: 1 addition & 0 deletions src/space_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ bool space_manager_balance_space(struct space_manager *sm, uint64_t sid);
void space_manager_toggle_window_split(struct space_manager *sm, struct window *window);
int space_manager_mission_control_index(uint64_t sid);
uint64_t space_manager_mission_control_space(int desktop_id);
uint64_t space_manager_cursor_space(void);
uint64_t space_manager_prev_space(uint64_t sid);
uint64_t space_manager_next_space(uint64_t sid);
uint64_t space_manager_first_space(void);
Expand Down

0 comments on commit fb3145b

Please sign in to comment.