Removed debugging, added in proper gap resets for config reloads

This commit is contained in:
Luminarys 2015-08-18 21:05:58 -05:00
parent ab5805ca6e
commit f718556a85
3 changed files with 21 additions and 14 deletions

View file

@ -8,6 +8,7 @@
#include "log.h" #include "log.h"
#include "commands.h" #include "commands.h"
#include "config.h" #include "config.h"
#include "layout.h"
struct sway_config *config; struct sway_config *config;
@ -227,6 +228,8 @@ _continue:
if (is_active) { if (is_active) {
temp_config->reloading = false; temp_config->reloading = false;
container_map(&root_container, reset_gaps, NULL);
arrange_windows(&root_container, -1, -1);
} }
config = temp_config; config = temp_config;

View file

@ -341,3 +341,12 @@ void set_view_visibility(swayc_t *view, void *data) {
} }
view->visible = (*p == 2); view->visible = (*p == 2);
} }
void reset_gaps(swayc_t *view, void *data) {
if (view->type == C_OUTPUT) {
view->gaps = config->gaps_outer;
}
if (view->type == C_VIEW) {
view->gaps = config->gaps_inner;
}
}

View file

@ -19,7 +19,9 @@ uint32_t keys_pressed[32];
static struct wlc_origin mouse_origin; static struct wlc_origin mouse_origin;
static bool m1_held = false; static bool m1_held = false;
static bool dragging = false;
static bool m2_held = false; static bool m2_held = false;
static bool resizing = false;
static bool pointer_test(swayc_t *view, void *_origin) { static bool pointer_test(swayc_t *view, void *_origin) {
const struct wlc_origin *origin = _origin; const struct wlc_origin *origin = _origin;
@ -338,14 +340,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
// Do checks to determine if proper keys are being held // Do checks to determine if proper keys are being held
swayc_t *view = active_workspace->focused; swayc_t *view = active_workspace->focused;
uint32_t edge = 0; uint32_t edge = 0;
if (m1_held && view) { if (dragging && view) {
if (view->is_floating) { if (view->is_floating) {
while (keys_pressed[i++]) { while (keys_pressed[i++]) {
if (keys_pressed[i] == config->floating_mod) { if (keys_pressed[i] == config->floating_mod) {
int dx = mouse_origin.x - prev_pos.x; int dx = mouse_origin.x - prev_pos.x;
int dy = mouse_origin.y - prev_pos.y; int dy = mouse_origin.y - prev_pos.y;
sway_log(L_DEBUG, "Moving from px: %d to cx: %d and from py: %d to cy: %d", prev_pos.x, mouse_origin.x, prev_pos.y, mouse_origin.y);
view->x += dx; view->x += dx;
view->y += dy; view->y += dy;
changed_floating = true; changed_floating = true;
@ -353,13 +353,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
} }
} }
} }
} else if (m2_held && view) { } else if (resizing && view) {
if (view->is_floating) { if (view->is_floating) {
while (keys_pressed[i++]) { while (keys_pressed[i++]) {
if (keys_pressed[i] == config->floating_mod) { if (keys_pressed[i] == config->floating_mod) {
int dx = mouse_origin.x - prev_pos.x; int dx = mouse_origin.x - prev_pos.x;
int dy = mouse_origin.y - prev_pos.y; int dy = mouse_origin.y - prev_pos.y;
sway_log(L_DEBUG, "Moving from px: %d to cx: %d and from py: %d to cy: %d", prev_pos.x, mouse_origin.x, prev_pos.y, mouse_origin.y);
// Move and resize the view based on the dx/dy and mouse position // Move and resize the view based on the dx/dy and mouse position
int midway_x = view->x + view->width/2; int midway_x = view->x + view->width/2;
@ -369,11 +368,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
if (dx < 0) { if (dx < 0) {
changed_floating = true; changed_floating = true;
if (mouse_origin.x > midway_x) { if (mouse_origin.x > midway_x) {
sway_log(L_INFO, "Downsizing view to the left");
view->width += dx; view->width += dx;
edge += WLC_RESIZE_EDGE_RIGHT; edge += WLC_RESIZE_EDGE_RIGHT;
} else { } else {
sway_log(L_INFO, "Upsizing view to the left");
view->x += dx; view->x += dx;
view->width -= dx; view->width -= dx;
edge += WLC_RESIZE_EDGE_LEFT; edge += WLC_RESIZE_EDGE_LEFT;
@ -381,11 +378,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
} else if (dx > 0){ } else if (dx > 0){
changed_floating = true; changed_floating = true;
if (mouse_origin.x > midway_x) { if (mouse_origin.x > midway_x) {
sway_log(L_INFO, "Upsizing to the right");
view->width += dx; view->width += dx;
edge += WLC_RESIZE_EDGE_RIGHT; edge += WLC_RESIZE_EDGE_RIGHT;
} else { } else {
sway_log(L_INFO, "Downsizing to the right");
view->x += dx; view->x += dx;
view->width -= dx; view->width -= dx;
edge += WLC_RESIZE_EDGE_LEFT; edge += WLC_RESIZE_EDGE_LEFT;
@ -395,11 +390,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
if (dy < 0) { if (dy < 0) {
changed_floating = true; changed_floating = true;
if (mouse_origin.y > midway_y) { if (mouse_origin.y > midway_y) {
sway_log(L_INFO, "Downsizing view to the top");
view->height += dy; view->height += dy;
edge += WLC_RESIZE_EDGE_BOTTOM; edge += WLC_RESIZE_EDGE_BOTTOM;
} else { } else {
sway_log(L_INFO, "Upsizing the view to the top");
view->y += dy; view->y += dy;
view->height -= dy; view->height -= dy;
edge += WLC_RESIZE_EDGE_TOP; edge += WLC_RESIZE_EDGE_TOP;
@ -407,12 +400,10 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
} else if (dy > 0) { } else if (dy > 0) {
changed_floating = true; changed_floating = true;
if (mouse_origin.y > midway_y) { if (mouse_origin.y > midway_y) {
sway_log(L_INFO, "Upsizing to the bottom");
view->height += dy; view->height += dy;
edge += WLC_RESIZE_EDGE_BOTTOM; edge += WLC_RESIZE_EDGE_BOTTOM;
} else { } else {
edge = WLC_RESIZE_EDGE_BOTTOM; edge = WLC_RESIZE_EDGE_BOTTOM;
sway_log(L_INFO, "Downsizing to the bottom");
view->y += dy; view->y += dy;
view->height -= dy; view->height -= dy;
edge += WLC_RESIZE_EDGE_TOP; edge += WLC_RESIZE_EDGE_TOP;
@ -426,7 +417,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
if (config->focus_follows_mouse && prev_handle != handle) { if (config->focus_follows_mouse && prev_handle != handle) {
//Dont change focus if fullscreen //Dont change focus if fullscreen
swayc_t *focused = get_focused_view(view); swayc_t *focused = get_focused_view(view);
if (!(focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) { if (!(focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) && !(m1_held || m2_held)) {
set_focused_container(container_under_pointer()); set_focused_container(container_under_pointer());
} }
} }
@ -476,15 +467,19 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
} }
} }
arrange_windows(pointer->parent, -1, -1); arrange_windows(pointer->parent, -1, -1);
dragging = m1_held;
resizing = m2_held;
} }
return (pointer && pointer != focused); return (pointer && pointer != focused);
} else { } else {
sway_log(L_DEBUG, "Mouse button %u released", button); sway_log(L_DEBUG, "Mouse button %u released", button);
if (button == 272) { if (button == 272) {
m1_held = false; m1_held = false;
dragging = false;
} }
if (button == 273) { if (button == 273) {
m2_held = false; m2_held = false;
resizing = false;
} }
} }
return false; return false;