aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/util.c2
-rw-r--r--config47
-rw-r--r--include/border.h1
-rw-r--r--sway/border.c6
-rw-r--r--sway/commands.c11
-rw-r--r--sway/config.c1
-rw-r--r--sway/focus.c23
-rw-r--r--sway/handlers.c2
-rw-r--r--sway/input_state.c2
-rw-r--r--sway/ipc-json.c5
-rw-r--r--sway/ipc-server.c10
11 files changed, 68 insertions, 42 deletions
diff --git a/common/util.c b/common/util.c
index 86120769..f0b0fdf0 100644
--- a/common/util.c
+++ b/common/util.c
@@ -104,7 +104,7 @@ uint32_t parse_color(const char *color) {
104 sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); 104 sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
105 return 0xFFFFFFFF; 105 return 0xFFFFFFFF;
106 } 106 }
107 uint32_t res = (uint32_t)strtol(color + 1, NULL, 16); 107 uint32_t res = (uint32_t)strtoul(color + 1, NULL, 16);
108 if (strlen(color) == 7) { 108 if (strlen(color) == 7) {
109 res = (res << 8) | 0xFF; 109 res = (res << 8) | 0xFF;
110 } 110 }
diff --git a/config b/config
index e127207b..80765c29 100644
--- a/config
+++ b/config
@@ -8,6 +8,11 @@
8# 8#
9# Logo key. Use Mod1 for Alt. 9# Logo key. Use Mod1 for Alt.
10set $mod Mod4 10set $mod Mod4
11# Home row direction keys, like vim
12set $left h
13set $down j
14set $up k
15set $right l
11# Your preferred terminal emulator 16# Your preferred terminal emulator
12set $term urxvt 17set $term urxvt
13# Your preferred application launcher 18# Your preferred application launcher
@@ -52,11 +57,11 @@ output * bg /usr/share/sway/Sway_Wallpaper_Blue_1920x1080.png fill
52# 57#
53# Moving around: 58# Moving around:
54# 59#
55 # Move your focus around with $mod+[h|j|k|l], like vim 60 # Move your focus around
56 bindsym $mod+h focus left 61 bindsym $mod+$left focus left
57 bindsym $mod+j focus down 62 bindsym $mod+$down focus down
58 bindsym $mod+k focus up 63 bindsym $mod+$up focus up
59 bindsym $mod+l focus right 64 bindsym $mod+$right focus right
60 # or use $mod+[up|down|left|right] 65 # or use $mod+[up|down|left|right]
61 bindsym $mod+Left focus left 66 bindsym $mod+Left focus left
62 bindsym $mod+Down focus down 67 bindsym $mod+Down focus down
@@ -64,10 +69,10 @@ output * bg /usr/share/sway/Sway_Wallpaper_Blue_1920x1080.png fill
64 bindsym $mod+Right focus right 69 bindsym $mod+Right focus right
65 70
66 # _move_ the focused window with the same, but add Shift 71 # _move_ the focused window with the same, but add Shift
67 bindsym $mod+Shift+h move left 72 bindsym $mod+Shift+$left move left
68 bindsym $mod+Shift+j move down 73 bindsym $mod+Shift+$down move down
69 bindsym $mod+Shift+k move up 74 bindsym $mod+Shift+$up move up
70 bindsym $mod+Shift+l move right 75 bindsym $mod+Shift+$right move right
71 # ditto, with arrow keys 76 # ditto, with arrow keys
72 bindsym $mod+Shift+Left move left 77 bindsym $mod+Shift+Left move left
73 bindsym $mod+Shift+Down move down 78 bindsym $mod+Shift+Down move down
@@ -137,6 +142,30 @@ output * bg /usr/share/sway/Sway_Wallpaper_Blue_1920x1080.png fill
137 # Show the next scratchpad window or hide the focused scratchpad window. 142 # Show the next scratchpad window or hide the focused scratchpad window.
138 # If there are multiple scratchpad windows, this command cycles through them. 143 # If there are multiple scratchpad windows, this command cycles through them.
139 bindsym $mod+minus scratchpad show 144 bindsym $mod+minus scratchpad show
145#
146# Resizing containers:
147#
148mode "resize" {
149 # left will shrink the containers width
150 # right will grow the containers width
151 # up will shrink the containers height
152 # down will grow the containers height
153 bindsym $left resize shrink width 10 px or 10 ppt
154 bindsym $down resize grow height 10 px or 10 ppt
155 bindsym $up resize shrink height 10 px or 10 ppt
156 bindsym $right resize grow width 10 px or 10 ppt
157
158 # ditto, with arrow keys
159 bindsym Left resize shrink width 10 px or 10 ppt
160 bindsym Down resize grow height 10 px or 10 ppt
161 bindsym Up resize shrink height 10 px or 10 ppt
162 bindsym Right resize grow width 10 px or 10 ppt
163
164 # return to default mode
165 bindsym Return mode "default"
166 bindsym Escape mode "default"
167}
168bindsym $mod+r mode "resize"
140 169
141# 170#
142# Status Bar: 171# Status Bar:
diff --git a/include/border.h b/include/border.h
index b72dc5dc..c30c9da3 100644
--- a/include/border.h
+++ b/include/border.h
@@ -22,7 +22,6 @@ void border_clear(struct border *border);
22void update_container_border(swayc_t *container); 22void update_container_border(swayc_t *container);
23 23
24void render_view_borders(wlc_handle view); 24void render_view_borders(wlc_handle view);
25void map_update_view_border(swayc_t *view, void *data);
26int get_font_text_height(const char *font); 25int get_font_text_height(const char *font);
27bool should_hide_top_border(swayc_t *con, double y); 26bool should_hide_top_border(swayc_t *con, double y);
28 27
diff --git a/sway/border.c b/sway/border.c
index 46343d61..304f8b87 100644
--- a/sway/border.c
+++ b/sway/border.c
@@ -415,12 +415,6 @@ void update_container_border(swayc_t *container) {
415 } 415 }
416} 416}
417 417
418void map_update_view_border(swayc_t *view, void *data) {
419 if (view->type == C_VIEW) {
420 update_view_border(view);
421 }
422}
423
424void render_view_borders(wlc_handle view) { 418void render_view_borders(wlc_handle view) {
425 swayc_t *c = swayc_by_handle(view); 419 swayc_t *c = swayc_by_handle(view);
426 420
diff --git a/sway/commands.c b/sway/commands.c
index f73bd21c..172f9f34 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -2563,10 +2563,13 @@ static struct cmd_results *cmd_workspace(int argc, char **argv) {
2563 } else if (strcasecmp(argv[0], "prev_on_output") == 0) { 2563 } else if (strcasecmp(argv[0], "prev_on_output") == 0) {
2564 ws = workspace_output_prev(); 2564 ws = workspace_output_prev();
2565 } else if (strcasecmp(argv[0], "back_and_forth") == 0) { 2565 } else if (strcasecmp(argv[0], "back_and_forth") == 0) {
2566 if (prev_workspace_name) { 2566 // if auto_back_and_forth is enabled, workspace_switch will swap
2567 if (!(ws = workspace_by_name(prev_workspace_name))) { 2567 // the workspaces. If we created prev_workspace here, workspace_switch
2568 ws = workspace_create(prev_workspace_name); 2568 // would put us back on original workspace.
2569 } 2569 if (config->auto_back_and_forth) {
2570 ws = swayc_active_workspace();
2571 } else if (prev_workspace_name && !(ws = workspace_by_name(prev_workspace_name))) {
2572 ws = workspace_create(prev_workspace_name);
2570 } 2573 }
2571 } else { 2574 } else {
2572 if (!(ws = workspace_by_name(argv[0]))) { 2575 if (!(ws = workspace_by_name(argv[0]))) {
diff --git a/sway/config.c b/sway/config.c
index 25566213..a1f33dcf 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -1118,6 +1118,7 @@ struct bar_config *default_bar_config(void) {
1118 bar->font = NULL; 1118 bar->font = NULL;
1119 bar->height = -1; 1119 bar->height = -1;
1120 bar->workspace_buttons = true; 1120 bar->workspace_buttons = true;
1121 bar->wrap_scroll = false;
1121 bar->separator_symbol = NULL; 1122 bar->separator_symbol = NULL;
1122 bar->strip_workspace_numbers = false; 1123 bar->strip_workspace_numbers = false;
1123 bar->binding_mode_indicator = true; 1124 bar->binding_mode_indicator = true;
diff --git a/sway/focus.c b/sway/focus.c
index 6583f802..1ea88ad4 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -29,8 +29,6 @@ static void update_focus(swayc_t *c) {
29 29
30 // Case where output changes 30 // Case where output changes
31 case C_OUTPUT: 31 case C_OUTPUT:
32 // update borders for views in prev
33 container_map(prev, map_update_view_border, NULL);
34 wlc_output_focus(c->handle); 32 wlc_output_focus(c->handle);
35 break; 33 break;
36 34
@@ -54,8 +52,6 @@ static void update_focus(swayc_t *c) {
54 default: 52 default:
55 case C_VIEW: 53 case C_VIEW:
56 case C_CONTAINER: 54 case C_CONTAINER:
57 // TODO whatever to do when container changes
58 // for example, stacked and tabbing change stuff.
59 break; 55 break;
60 } 56 }
61 } 57 }
@@ -110,18 +106,17 @@ bool set_focused_container(swayc_t *c) {
110 active_ws_child_count = active_ws->children->length + active_ws->floating->length; 106 active_ws_child_count = active_ws->children->length + active_ws->floating->length;
111 } 107 }
112 108
113 swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle);
114
115 // Get workspace for c, get that workspaces current focused container.
116 swayc_t *workspace = swayc_active_workspace_for(c); 109 swayc_t *workspace = swayc_active_workspace_for(c);
117 swayc_t *focused = get_focused_container(workspace); 110 swayc_t *focused = get_focused_container(&root_container);
118 111
119 if (swayc_is_fullscreen(focused) && focused != c) { 112 if (swayc_is_fullscreen(get_focused_container(workspace))) {
120 // if switching to a workspace with a fullscreen view, 113 // if switching to a workspace with a fullscreen view,
121 // focus on the fullscreen view 114 // focus on the fullscreen view
122 c = focused; 115 c = get_focused_container(workspace);
123 } 116 }
124 117
118 swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle);
119
125 if (c->type == C_VIEW) { 120 if (c->type == C_VIEW) {
126 // dispatch a window event 121 // dispatch a window event
127 ipc_event_window(c, "focus"); 122 ipc_event_window(c, "focus");
@@ -139,7 +134,7 @@ bool set_focused_container(swayc_t *c) {
139 } 134 }
140 135
141 // get new focused view and set focus to it. 136 // get new focused view and set focus to it.
142 if (c->type == C_CONTAINER || (c->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP))) { 137 if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
143 // unactivate previous focus 138 // unactivate previous focus
144 if (focused->type == C_VIEW) { 139 if (focused->type == C_VIEW) {
145 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); 140 wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false);
@@ -149,7 +144,7 @@ bool set_focused_container(swayc_t *c) {
149 if (c->type == C_VIEW) { 144 if (c->type == C_VIEW) {
150 wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true); 145 wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true);
151 } 146 }
152 // set focus if view_focus is unlocked 147 // set focus
153 wlc_view_focus(c->handle); 148 wlc_view_focus(c->handle);
154 if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) { 149 if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) {
155 update_container_border(c); 150 update_container_border(c);
@@ -161,10 +156,6 @@ bool set_focused_container(swayc_t *c) {
161 arrange_backgrounds(); 156 arrange_backgrounds();
162 arrange_windows(parent, -1, -1); 157 arrange_windows(parent, -1, -1);
163 } 158 }
164 } else if (c->type == C_WORKSPACE) {
165 // remove previous focus if view_focus is unlocked
166 update_container_border(c);
167 wlc_view_focus(0);
168 } 159 }
169 160
170 if (active_ws != workspace) { 161 if (active_ws != workspace) {
diff --git a/sway/handlers.c b/sway/handlers.c
index 6d35f8a2..846d0005 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -410,7 +410,7 @@ static bool handle_view_created(wlc_handle handle) {
410 } 410 }
411 wlc_view_set_mask(handle, VISIBLE); 411 wlc_view_set_mask(handle, VISIBLE);
412 412
413 if (return_to_workspace && current_ws) { 413 if (return_to_workspace && current_ws != swayc_active_workspace()) {
414 // we were on one workspace, switched to another to add this view, 414 // we were on one workspace, switched to another to add this view,
415 // now let's return to where we were 415 // now let's return to where we were
416 workspace_switch(current_ws); 416 workspace_switch(current_ws);
diff --git a/sway/input_state.c b/sway/input_state.c
index 429b2f34..7e31d3d9 100644
--- a/sway/input_state.c
+++ b/sway/input_state.c
@@ -424,6 +424,8 @@ void pointer_mode_update(void) {
424 update_geometry(initial.ptr); 424 update_geometry(initial.ptr);
425 // Set focus back to initial view 425 // Set focus back to initial view
426 set_focused_container(initial.ptr); 426 set_focused_container(initial.ptr);
427 // Arrange the windows
428 arrange_windows(&root_container, -1, -1);
427 } 429 }
428 break; 430 break;
429 431
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 38aa7a8d..1debca7b 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -204,7 +204,8 @@ static void ipc_json_describe_view(swayc_t *c, json_object *object) {
204 c->is_floating ? "auto_on" : "auto_off")); // we can't state the cause 204 c->is_floating ? "auto_on" : "auto_off")); // we can't state the cause
205 205
206 json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL); 206 json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL);
207 // we do not include children, floating etc. as views have none 207 json_object_object_add(object, "nodes", json_object_new_array());
208 json_object_object_add(object, "floating_nodes", json_object_new_array());
208} 209}
209 210
210json_object *ipc_json_describe_container(swayc_t *c) { 211json_object *ipc_json_describe_container(swayc_t *c) {
@@ -214,7 +215,7 @@ json_object *ipc_json_describe_container(swayc_t *c) {
214 215
215 json_object *object = json_object_new_object(); 216 json_object *object = json_object_new_object();
216 217
217 json_object_object_add(object, "id", json_object_new_int((intptr_t)&c)); 218 json_object_object_add(object, "id", json_object_new_int((uintptr_t)&c));
218 json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL); 219 json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
219 json_object_object_add(object, "rect", ipc_json_create_rect(c)); 220 json_object_object_add(object, "rect", ipc_json_create_rect(c));
220 json_object_object_add(object, "visible", json_object_new_boolean(c->visible)); 221 json_object_object_add(object, "visible", json_object_new_boolean(c->visible));
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 326b309f..7039e348 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -539,18 +539,19 @@ void ipc_send_event(const char *json_string, enum ipc_command_type event) {
539} 539}
540 540
541void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) { 541void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) {
542 sway_log(L_DEBUG, "Sending workspace::%s event", change);
542 json_object *obj = json_object_new_object(); 543 json_object *obj = json_object_new_object();
543 json_object_object_add(obj, "change", json_object_new_string(change)); 544 json_object_object_add(obj, "change", json_object_new_string(change));
544 if (strcmp("focus", change) == 0) { 545 if (strcmp("focus", change) == 0) {
545 if (old) { 546 if (old) {
546 json_object_object_add(obj, "old", ipc_json_describe_container(old)); 547 json_object_object_add(obj, "old", ipc_json_describe_container_recursive(old));
547 } else { 548 } else {
548 json_object_object_add(obj, "old", NULL); 549 json_object_object_add(obj, "old", NULL);
549 } 550 }
550 } 551 }
551 552
552 if (new) { 553 if (new) {
553 json_object_object_add(obj, "current", ipc_json_describe_container(new)); 554 json_object_object_add(obj, "current", ipc_json_describe_container_recursive(new));
554 } else { 555 } else {
555 json_object_object_add(obj, "current", NULL); 556 json_object_object_add(obj, "current", NULL);
556 } 557 }
@@ -562,6 +563,7 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) {
562} 563}
563 564
564void ipc_event_window(swayc_t *window, const char *change) { 565void ipc_event_window(swayc_t *window, const char *change) {
566 sway_log(L_DEBUG, "Sending window::%s event", change);
565 json_object *obj = json_object_new_object(); 567 json_object *obj = json_object_new_object();
566 json_object_object_add(obj, "change", json_object_new_string(change)); 568 json_object_object_add(obj, "change", json_object_new_string(change));
567 if (strcmp(change, "close") == 0 || !window) { 569 if (strcmp(change, "close") == 0 || !window) {
@@ -577,6 +579,7 @@ void ipc_event_window(swayc_t *window, const char *change) {
577} 579}
578 580
579void ipc_event_barconfig_update(struct bar_config *bar) { 581void ipc_event_barconfig_update(struct bar_config *bar) {
582 sway_log(L_DEBUG, "Sending barconfig_update event");
580 json_object *json = ipc_json_describe_bar_config(bar); 583 json_object *json = ipc_json_describe_bar_config(bar);
581 const char *json_string = json_object_to_json_string(json); 584 const char *json_string = json_object_to_json_string(json);
582 ipc_send_event(json_string, IPC_EVENT_BARCONFIG_UPDATE); 585 ipc_send_event(json_string, IPC_EVENT_BARCONFIG_UPDATE);
@@ -585,6 +588,7 @@ void ipc_event_barconfig_update(struct bar_config *bar) {
585} 588}
586 589
587void ipc_event_mode(const char *mode) { 590void ipc_event_mode(const char *mode) {
591 sway_log(L_DEBUG, "Sending mode::%s event", mode);
588 json_object *obj = json_object_new_object(); 592 json_object *obj = json_object_new_object();
589 json_object_object_add(obj, "change", json_object_new_string(mode)); 593 json_object_object_add(obj, "change", json_object_new_string(mode));
590 594
@@ -595,6 +599,7 @@ void ipc_event_mode(const char *mode) {
595} 599}
596 600
597void ipc_event_modifier(uint32_t modifier, const char *state) { 601void ipc_event_modifier(uint32_t modifier, const char *state) {
602 sway_log(L_DEBUG, "Sending modifier::%s event", state);
598 json_object *obj = json_object_new_object(); 603 json_object *obj = json_object_new_object();
599 json_object_object_add(obj, "change", json_object_new_string(state)); 604 json_object_object_add(obj, "change", json_object_new_string(state));
600 605
@@ -609,6 +614,7 @@ void ipc_event_modifier(uint32_t modifier, const char *state) {
609 614
610#if SWAY_BINDING_EVENT 615#if SWAY_BINDING_EVENT
611static void ipc_event_binding(json_object *sb_obj) { 616static void ipc_event_binding(json_object *sb_obj) {
617 sway_log(L_DEBUG, "Sending binding::run event");
612 json_object *obj = json_object_new_object(); 618 json_object *obj = json_object_new_object();
613 json_object_object_add(obj, "change", json_object_new_string("run")); 619 json_object_object_add(obj, "change", json_object_new_string("run"));
614 json_object_object_add(obj, "binding", sb_obj); 620 json_object_object_add(obj, "binding", sb_obj);