Skip to content

Commit

Permalink
#487 make new feedback windows work well with mission-control
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Apr 25, 2020
1 parent 318444c commit cad6590
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extern struct space_manager g_space_manager;
extern struct window_manager g_window_manager;
extern struct mouse_state g_mouse_state;
extern bool g_mission_control_active;
extern uint32_t *g_insert_feedback_windows;
extern int g_connection;

static void event_signal_populate_args(void *context, enum event_type type, struct signal_args *args)
Expand Down Expand Up @@ -1216,6 +1217,11 @@ static EVENT_CALLBACK(EVENT_HANDLER_MISSION_CONTROL_ENTER)
debug("%s:\n", __FUNCTION__);
g_mission_control_active = true;

for (int i = 0; i < buf_len(g_insert_feedback_windows); ++i) {
uint32_t feedback_wid = g_insert_feedback_windows[i];
SLSOrderWindow(g_connection, feedback_wid, 0, 0);
}

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
struct event *event = event_create(&g_event_loop, MISSION_CONTROL_CHECK_FOR_EXIT, NULL);
event_loop_post(&g_event_loop, event);
Expand Down Expand Up @@ -1275,6 +1281,11 @@ static EVENT_CALLBACK(EVENT_HANDLER_MISSION_CONTROL_EXIT)
debug("%s:\n", __FUNCTION__);
g_mission_control_active = false;

for (int i = 0; i < buf_len(g_insert_feedback_windows); ++i) {
uint32_t feedback_wid = g_insert_feedback_windows[i];
SLSOrderWindow(g_connection, feedback_wid, 1, 0);
}

space_manager_mark_spaces_invalid(&g_space_manager);

if (space_is_user(g_space_manager.current_space_id)) {
Expand Down
12 changes: 11 additions & 1 deletion src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern int g_connection;
extern struct display_manager g_display_manager;
extern struct space_manager g_space_manager;
extern struct window_manager g_window_manager;
extern uint32_t *g_insert_feedback_windows;

void insert_feedback_show(struct window_node *node)
{
Expand All @@ -24,6 +25,7 @@ void insert_feedback_show(struct window_node *node)
g_window_manager.insert_feedback_color.g,
g_window_manager.insert_feedback_color.b,
g_window_manager.insert_feedback_color.a);
buf_push(g_insert_feedback_windows, node->feedback_window.id);
}

frame.origin.x = 0; frame.origin.y = 0;
Expand Down Expand Up @@ -78,6 +80,13 @@ void insert_feedback_show(struct window_node *node)
void insert_feedback_destroy(struct window_node *node)
{
if (node->feedback_window.id) {
for (int i = 0; i < buf_len(g_insert_feedback_windows); ++i) {
if (g_insert_feedback_windows[i] == node->feedback_window.id) {
buf_del(g_insert_feedback_windows, i);
break;
}
}

CGContextRelease(node->feedback_window.context);
SLSReleaseWindow(g_connection, node->feedback_window.id);
memset(&node->feedback_window, 0, sizeof(struct feedback_window));
Expand Down Expand Up @@ -257,8 +266,8 @@ static void window_node_destroy(struct window_node *node)
{
if (node->left) window_node_destroy(node->left);
if (node->right) window_node_destroy(node->right);

if (node->window_id) window_manager_remove_managed_window(&g_window_manager, node->window_id);
insert_feedback_destroy(node);
free(node);
}

Expand Down Expand Up @@ -648,6 +657,7 @@ void view_clear(struct view *view)
if (view->root) {
if (view->root->left) window_node_destroy(view->root->left);
if (view->root->right) window_node_destroy(view->root->right);
insert_feedback_destroy(view->root);
memset(view->root, 0, sizeof(struct window_node));
view_update(view);
}
Expand Down
1 change: 1 addition & 0 deletions src/yabai.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct window_manager g_window_manager;
struct mouse_state g_mouse_state;
struct event_tap g_event_tap;
struct daemon g_daemon;
uint32_t *g_insert_feedback_windows;
int g_connection;

struct signal *g_signal_event[EVENT_TYPE_COUNT];
Expand Down

0 comments on commit cad6590

Please sign in to comment.