diff options
author | 2015-08-10 23:47:14 -0400 | |
---|---|---|
committer | 2015-08-10 23:47:14 -0400 | |
commit | dd115cece3490a2d1791880cd45fae4b274a123a (patch) | |
tree | 43557d61373bbecf488e0940c1e55ef2abc50bee /sway | |
parent | Merge pull request #15 from taiyu-len/master (diff) | |
download | sway-dd115cece3490a2d1791880cd45fae4b274a123a.tar.gz sway-dd115cece3490a2d1791880cd45fae4b274a123a.tar.zst sway-dd115cece3490a2d1791880cd45fae4b274a123a.zip |
Prevent passing WM keys, improve multihead support
Diffstat (limited to 'sway')
-rw-r--r-- | sway/handlers.c | 35 | ||||
-rw-r--r-- | sway/layout.c | 21 | ||||
-rw-r--r-- | sway/workspace.c | 15 |
3 files changed, 49 insertions, 22 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index 938dc3fd..f183c418 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -57,24 +57,27 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers | |||
57 | // Lowercase if necessary | 57 | // Lowercase if necessary |
58 | sym = tolower(sym); | 58 | sym = tolower(sym); |
59 | 59 | ||
60 | if (state == WLC_KEY_STATE_PRESSED) { | 60 | int i; |
61 | int i; | 61 | for (i = 0; i < mode->bindings->length; ++i) { |
62 | for (i = 0; i < mode->bindings->length; ++i) { | 62 | struct sway_binding *binding = mode->bindings->items[i]; |
63 | struct sway_binding *binding = mode->bindings->items[i]; | 63 | |
64 | 64 | if ((modifiers->mods & binding->modifiers) == binding->modifiers) { | |
65 | if ((modifiers->mods & binding->modifiers) == binding->modifiers) { | 65 | bool match = true; |
66 | bool match = true; | 66 | int j; |
67 | int j; | 67 | for (j = 0; j < binding->keys->length; ++j) { |
68 | for (j = 0; j < binding->keys->length; ++j) { | 68 | xkb_keysym_t *k = binding->keys->items[j]; |
69 | xkb_keysym_t *k = binding->keys->items[j]; | 69 | if (sym != *k) { |
70 | if (sym != *k) { | 70 | match = false; |
71 | match = false; | 71 | break; |
72 | break; | ||
73 | } | ||
74 | } | 72 | } |
73 | } | ||
75 | 74 | ||
76 | if (match) { | 75 | if (match) { |
77 | cmd_success = handle_command(config, binding->command); | 76 | // TODO: --released |
77 | if (state == WLC_KEY_STATE_PRESSED) { | ||
78 | cmd_success = !handle_command(config, binding->command); | ||
79 | } else { | ||
80 | cmd_success = true; | ||
78 | } | 81 | } |
79 | } | 82 | } |
80 | } | 83 | } |
diff --git a/sway/layout.c b/sway/layout.c index 37f47673..08d1952c 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "list.h" | 4 | #include "list.h" |
5 | #include "log.h" | 5 | #include "log.h" |
6 | #include "layout.h" | 6 | #include "layout.h" |
7 | #include "container.h" | ||
7 | #include "workspace.h" | 8 | #include "workspace.h" |
8 | 9 | ||
9 | swayc_t root_container; | 10 | swayc_t root_container; |
@@ -35,10 +36,16 @@ void arrange_windows(swayc_t *container, int width, int height) { | |||
35 | height = container->height; | 36 | height = container->height; |
36 | } | 37 | } |
37 | 38 | ||
39 | int x = 0, y = 0; | ||
38 | switch (container->type) { | 40 | switch (container->type) { |
39 | case C_ROOT: | 41 | case C_ROOT: |
40 | for (i = 0; i < container->children->length; ++i) { | 42 | for (i = 0; i < container->children->length; ++i) { |
41 | arrange_windows(container->children->items[i], -1, -1); | 43 | swayc_t *child = container->children->items[i]; |
44 | sway_log(L_DEBUG, "Arranging output at %d", x); | ||
45 | child->x = x; | ||
46 | child->y = y; | ||
47 | arrange_windows(child, child->width, child->height); | ||
48 | x += child->width; | ||
42 | } | 49 | } |
43 | return; | 50 | return; |
44 | case C_VIEW: | 51 | case C_VIEW: |
@@ -85,7 +92,6 @@ void arrange_windows(swayc_t *container, int width, int height) { | |||
85 | total_weight += child->weight; | 92 | total_weight += child->weight; |
86 | } | 93 | } |
87 | 94 | ||
88 | int x = 0, y = 0; | ||
89 | switch (container->layout) { | 95 | switch (container->layout) { |
90 | case L_HORIZ: | 96 | case L_HORIZ: |
91 | default: | 97 | default: |
@@ -307,6 +313,13 @@ swayc_t *create_container(swayc_t *parent, wlc_handle handle) { | |||
307 | return c; | 313 | return c; |
308 | } | 314 | } |
309 | 315 | ||
316 | void add_output_widths(swayc_t *container, void *_width) { | ||
317 | int *width = _width; | ||
318 | if (container->type == C_OUTPUT) { | ||
319 | *width += container->width; | ||
320 | } | ||
321 | } | ||
322 | |||
310 | void add_output(wlc_handle output) { | 323 | void add_output(wlc_handle output) { |
311 | sway_log(L_DEBUG, "Adding output %d", output); | 324 | sway_log(L_DEBUG, "Adding output %d", output); |
312 | const struct wlc_size* size = wlc_output_get_resolution(output); | 325 | const struct wlc_size* size = wlc_output_get_resolution(output); |
@@ -317,6 +330,9 @@ void add_output(wlc_handle output) { | |||
317 | container->height = size->h; | 330 | container->height = size->h; |
318 | add_child(&root_container, container); | 331 | add_child(&root_container, container); |
319 | 332 | ||
333 | int total_width = 0; | ||
334 | container_map(&root_container, add_output_widths, &total_width); | ||
335 | |||
320 | swayc_t *workspace = create_container(container, -1); | 336 | swayc_t *workspace = create_container(container, -1); |
321 | workspace->type = C_WORKSPACE; | 337 | workspace->type = C_WORKSPACE; |
322 | workspace->name = workspace_next_name(); | 338 | workspace->name = workspace_next_name(); |
@@ -324,6 +340,7 @@ void add_output(wlc_handle output) { | |||
324 | workspace->height = size->h; | 340 | workspace->height = size->h; |
325 | workspace->layout = L_HORIZ; // TODO: Get default layout from config | 341 | workspace->layout = L_HORIZ; // TODO: Get default layout from config |
326 | add_child(container, workspace); | 342 | add_child(container, workspace); |
343 | sway_log(L_DEBUG, "Added workspace %s for output %d", workspace->name, output); | ||
327 | 344 | ||
328 | workspace_switch(workspace); | 345 | workspace_switch(workspace); |
329 | 346 | ||
diff --git a/sway/workspace.c b/sway/workspace.c index 01779723..53675c03 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -9,10 +9,18 @@ | |||
9 | 9 | ||
10 | swayc_t *active_workspace = NULL; | 10 | swayc_t *active_workspace = NULL; |
11 | 11 | ||
12 | int ws_num = 1; | ||
13 | |||
12 | char *workspace_next_name(void) { | 14 | char *workspace_next_name(void) { |
13 | //TODO change this i guess. seems pretty bad | 15 | int l = 1; |
14 | char *name = malloc(sizeof("1")); | 16 | if (ws_num >= 10) { |
15 | return strcpy(name, "1"); | 17 | l = 2; |
18 | } else if (ws_num >= 100) { | ||
19 | l = 3; | ||
20 | } | ||
21 | char *name = malloc(l + 1); | ||
22 | sprintf(name, "%d", ws_num++); | ||
23 | return name; | ||
16 | } | 24 | } |
17 | 25 | ||
18 | swayc_t *workspace_create(const char* name) { | 26 | swayc_t *workspace_create(const char* name) { |
@@ -45,7 +53,6 @@ bool workspace_destroy(swayc_t *workspace) { | |||
45 | sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name); | 53 | sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name); |
46 | free_swayc(workspace); | 54 | free_swayc(workspace); |
47 | return true; | 55 | return true; |
48 | |||
49 | } | 56 | } |
50 | 57 | ||
51 | void set_mask(swayc_t *view, void *data) { | 58 | void set_mask(swayc_t *view, void *data) { |