Skip to content

Commit

Permalink
#565 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jun 11, 2020
1 parent 59c1397 commit b74fe2a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
34 changes: 29 additions & 5 deletions src/border.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#include "border.h"

extern int g_connection;
extern struct window_manager g_window_manager;

static void border_order_in(struct window *window)
{
SLSOrderWindow(g_connection, window->border.id, 1, window->id);
}

static void border_order_out(struct window *window)
{
SLSOrderWindow(g_connection, window->border.id, 0, window->id);
}

void border_redraw(struct window *window)
{
SLSDisableUpdate(g_connection);
Expand Down Expand Up @@ -36,23 +47,30 @@ void border_deactivate(struct window *window)
border_redraw(window);
}

void border_show(struct window *window)
void border_enter_fullscreen(struct window *window)
{
if (window->border.id) SLSOrderWindow(g_connection, window->border.id, 1, window->id);
if (!window->border.id) return;

window_manager_remove_from_window_group(window->border.id, window->id);
border_order_out(window);
}

void border_hide(struct window *window)
void border_exit_fullscreen(struct window *window)
{
if (window->border.id) SLSOrderWindow(g_connection, window->border.id, 0, window->id);
if (!window->border.id) return;

border_order_in(window);
window_manager_add_to_window_group(window->border.id, window->id);
}

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

if ((!window_is_standard(window)) && (!window_is_dialog(window))) return;

CGRect frame = window_ax_frame(window);
if (window->border.region) CFRelease(window->border.region);
CGSNewRegionWithRect(&frame, &window->border.region);
window->border.frame.size = frame.size;

Expand All @@ -75,6 +93,12 @@ void border_create(struct window *window)
window_manager_add_to_window_group(window->border.id, window->id);

border_redraw(window);

if ((!window->application->is_hidden) &&
(!window->is_minimized) &&
(!window->is_fullscreen)) {
border_order_in(window);
}
}

void border_resize(struct window *window)
Expand Down
4 changes: 2 additions & 2 deletions src/border.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct window;
void border_redraw(struct window *window);
void border_activate(struct window *window);
void border_deactivate(struct window *window);
void border_show(struct window *window);
void border_hide(struct window *window);
void border_enter_fullscreen(struct window *window);
void border_exit_fullscreen(struct window *window);
void border_create(struct window *window);
void border_resize(struct window *window);
void border_destroy(struct window *window);
Expand Down
10 changes: 2 additions & 8 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED)
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);
}
border_enter_fullscreen(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 @@ -535,10 +532,7 @@ 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);
}
border_exit_fullscreen(window);
} 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;
Expand Down
11 changes: 1 addition & 10 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,7 @@ struct window *window_create(struct application *application, AXUIElementRef win
window->id_ptr = malloc(sizeof(uint32_t *));
*window->id_ptr = &window->id;
window->has_shadow = true;

if ((window_is_standard(window)) || (window_is_dialog(window))) {
border_create(window);

if ((!window->application->is_hidden) &&
(!window->is_minimized) &&
(!window->is_fullscreen)) {
border_show(window);
}
}
border_create(window);

return window;
}
Expand Down
23 changes: 7 additions & 16 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,28 +201,19 @@ void window_manager_set_window_border_enabled(struct window_manager *wm, bool en
while (bucket) {
if (bucket->value) {
struct window *window = bucket->value;
if ((window_is_standard(window)) || (window_is_dialog(window))) {
if (enabled && !window->border.id) {
border_create(window);

if ((!window->application->is_hidden) &&
(!window->is_minimized) &&
(!window->is_fullscreen)) {
border_show(window);
}

if (window->id == wm->focused_window_id) {
border_activate(window);
}
} else if (!enabled) {
border_destroy(window);
}
if (enabled) {
border_create(window);
} else {
border_destroy(window);
}
}

bucket = bucket->next;
}
}

struct window *window = window_manager_focused_window(wm);
if (window) border_activate(window);
}

void window_manager_set_window_border_width(struct window_manager *wm, int width)
Expand Down

0 comments on commit b74fe2a

Please sign in to comment.