aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c18
-rw-r--r--sway/handlers.c28
2 files changed, 30 insertions, 16 deletions
diff --git a/sway/commands.c b/sway/commands.c
index cc51717b..aafa51f3 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -240,7 +240,23 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv)
if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) {
return false;
}
- config->floating_mod = xkb_keysym_from_name(argv[0], XKB_KEYSYM_CASE_INSENSITIVE);
+ int i, j;
+ list_t *split = split_string(argv[0], "+");
+ config->floating_mod = 0;
+
+ //set modifer keys
+ for (i = 0; i < split->length; ++i) {
+ for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) {
+ if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
+ config->floating_mod |= modifiers[j].mod;
+ }
+ }
+ }
+ list_free(split);
+ if (!config->floating_mod) {
+ sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]);
+ return false;
+ }
return true;
}
diff --git a/sway/handlers.c b/sway/handlers.c
index 00f10a0c..5e8e05b8 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -15,8 +15,10 @@
#include "focus.h"
uint32_t keys_pressed[32];
+uint32_t key_modifiers;
int keys_pressed_length = 0;
+
static struct wlc_origin mouse_origin;
static bool m1_held = false;
@@ -293,6 +295,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
return false;
}
bool cmd_success = false;
+ key_modifiers = modifiers->mods;
struct sway_mode *mode = config->current_mode;
// Lowercase if necessary
@@ -385,15 +388,13 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
int midway_x = view->x + view->width/2;
int midway_y = view->y + view->height/2;
if (dx < 0) {
- if (mouse_origin.x > midway_x && !lock_right) {
+ if (!lock_right) {
if (view->width > min_sane_w) {
- lock_left = true;
changed_floating = true;
view->width += dx;
edge += WLC_RESIZE_EDGE_RIGHT;
}
} else if (mouse_origin.x < midway_x && !lock_left) {
- lock_right = true;
changed_floating = true;
view->x += dx;
view->width -= dx;
@@ -401,16 +402,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
} else if (dx > 0){
if (mouse_origin.x > midway_x && !lock_right) {
- lock_left = true;
changed_floating = true;
view->width += dx;
edge += WLC_RESIZE_EDGE_RIGHT;
+ } else if (!lock_left) {
if (view->width > min_sane_w) {
- lock_left = false;
- }
- } else if (mouse_origin.x < midway_x && !lock_left) {
- if (view->width > min_sane_w) {
- lock_right = true;
changed_floating = true;
view->x += dx;
view->width -= dx;
@@ -420,15 +416,13 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
if (dy < 0) {
- if (mouse_origin.y > midway_y && !lock_bottom) {
+ if (!lock_bottom) {
if (view->height > min_sane_h) {
- lock_top = true;
changed_floating = true;
view->height += dy;
edge += WLC_RESIZE_EDGE_BOTTOM;
}
} else if (mouse_origin.y < midway_y && !lock_top) {
- lock_bottom = true;
changed_floating = true;
view->y += dy;
view->height -= dy;
@@ -436,13 +430,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
} else if (dy > 0) {
if (mouse_origin.y > midway_y && !lock_bottom) {
- lock_top = true;
changed_floating = true;
view->height += dy;
edge += WLC_RESIZE_EDGE_BOTTOM;
- } else if (mouse_origin.y < midway_y && !lock_top) {
+ } else if (!lock_top) {
if (view->height > min_sane_h) {
- lock_bottom = true;
changed_floating = true;
view->y += dy;
view->height -= dy;
@@ -508,6 +500,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
if (floating_mod_pressed()) {
dragging = m1_held;
resizing = m2_held;
+ int midway_x = pointer->x + pointer->width/2;
+ int midway_y = pointer->y + pointer->height/2;
+ lock_bottom = origin->y < midway_y;
+ lock_top = !lock_bottom;
+ lock_right = origin->x < midway_x;
+ lock_left = !lock_right;
}
//Dont want pointer sent to window while dragging or resizing
return (dragging || resizing);