Skip to content

Commit

Permalink
#565 hide border from native-fullscreen mode; speed up border resize …
Browse files Browse the repository at this point in the history
…handling
  • Loading branch information
koekeishiya committed Jun 11, 2020
1 parent 714485b commit c537efb
Show file tree
Hide file tree
Showing 8 changed files with 2,585 additions and 2,524 deletions.
17 changes: 12 additions & 5 deletions src/border.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ void border_create(struct window *window)
window->border.frame = window_ax_frame(window);
if (window->border.region) CFRelease(window->border.region);
CGSNewRegionWithRect(&window->border.frame, &window->border.region);
window->border.frame.origin.x = 0;
window->border.frame.origin.y = 0;
window->border.frame.origin = (CGPoint) { 0, 0 };

window->border.path = CGPathCreateMutable();
CGPathAddRoundedRect(window->border.path, NULL, window->border.frame, 0, 0);

uint64_t tags[2] = { kCGSIgnoreForEventsTagBit, 0 };
SLSNewWindow(g_connection, 2, 0, 0, window->border.region, &window->border.id);
Expand All @@ -71,17 +73,22 @@ void border_create(struct window *window)
g_window_manager.normal_border_color.b,
g_window_manager.normal_border_color.a);
window_manager_add_to_window_group(window->border.id, window->id);

border_redraw(window);
}

void border_resize(struct window *window)
{
if (!window->border.id) return;

window->border.frame = window_ax_frame(window);
CGRect frame = window_ax_frame(window);
if ((frame.size.width == window->border.frame.size.width) &&
(frame.size.height == window->border.frame.size.height)) return;

window->border.frame = frame;
if (window->border.region) CFRelease(window->border.region);
CGSNewRegionWithRect(&window->border.frame, &window->border.region);
window->border.frame.origin.x = 0;
window->border.frame.origin.y = 0;
window->border.frame.origin = (CGPoint) { 0, 0 };

if (window->border.path) CGPathRelease(window->border.path);
window->border.path = CGPathCreateMutable();
Expand Down
12 changes: 10 additions & 2 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,15 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED)
}

debug("%s: %s %d\n", __FUNCTION__, window->application->name, window->id);
border_resize(window);

bool was_fullscreen = window->is_fullscreen;
bool is_fullscreen = window_is_fullscreen(window);
window->is_fullscreen = is_fullscreen;

if (!was_fullscreen && is_fullscreen) {
if (window->border.id) {
window_manager_remove_from_window_group(window->border.id, window->id);
border_hide(window);
}
struct view *view = window_manager_find_managed_window(&g_window_manager, window);
if (view) {
space_manager_untile_window(&g_space_manager, view, window);
Expand All @@ -533,10 +535,16 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED)
window_manager_add_managed_window(&g_window_manager, window, view);
}
window_manager_make_floating(&g_window_manager, window, window->is_floating);
if (window->border.id) {
border_show(window);
window_manager_add_to_window_group(window->border.id, window->id);
}
} else if (was_fullscreen == is_fullscreen) {
if (g_mouse_state.current_action == MOUSE_MODE_MOVE && g_mouse_state.window == window) {
g_mouse_state.window_frame.size = window_ax_frame(g_mouse_state.window).size;
}

border_resize(window);
}

return EVENT_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion src/osax/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SA_COMMON_H
#define SA_COMMON_H

#define OSAX_VERSION "1.0.13"
#define OSAX_VERSION "1.0.14"

#define OSAX_PAYLOAD_SUCCESS 0
#define OSAX_PAYLOAD_NOT_FOUND 1
Expand Down
18 changes: 18 additions & 0 deletions src/osax/payload.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
extern CGError CGSGetWindowTransform(int cid, uint32_t wid, CGAffineTransform *t);
extern CGError CGSSetWindowTransform(int cid, uint32_t wid, CGAffineTransform t);
extern CGError CGSAddWindowToWindowMovementGroup(int cid, uint32_t parent_wid, uint32_t child_wid);
extern CGError CGSRemoveWindowFromWindowMovementGroup(int cid, uint32_t parent_wid, uint32_t child_wid);
extern CGError CGSAddWindowToWindowOrderingGroup(int cid, uint32_t parent_wid, uint32_t child_wid, int order);
extern CGError CGSRemoveFromOrderingGroup(int cid, uint32_t wid);
extern void CGSManagedDisplaySetCurrentSpace(int cid, CFStringRef display_ref, uint64_t spid);
extern uint64_t CGSManagedDisplayGetCurrentSpace(int cid, CFStringRef display_ref);
extern CFArrayRef CGSCopyManagedDisplaySpaces(const int cid);
Expand Down Expand Up @@ -829,6 +831,20 @@ static void do_window_group_add(const char *message)
CGSAddWindowToWindowOrderingGroup(_connection, parent, child, 1);
}

static void do_window_group_remove(const char *message)
{
Token parent_token = get_token(&message);
uint32_t parent = token_to_uint32t(parent_token);
if (!parent) return;

Token child_token = get_token(&message);
uint32_t child = token_to_uint32t(child_token);
if (!child) return;

CGSRemoveWindowFromWindowMovementGroup(_connection, parent, child);
CGSRemoveFromOrderingGroup(_connection, child);
}

static inline bool can_focus_space()
{
return dock_spaces != nil;
Expand Down Expand Up @@ -920,6 +936,8 @@ static void handle_message(int sockfd, const char *message)
do_window_shadow(message);
} else if (token_equals(token, "window_group_add")) {
do_window_group_add(message);
} else if (token_equals(token, "window_group_remove")) {
do_window_group_remove(message);
}
}

Expand Down
Loading

0 comments on commit c537efb

Please sign in to comment.