diff options
-rw-r--r-- | common/util.c | 2 | ||||
-rw-r--r-- | config | 47 | ||||
-rw-r--r-- | include/border.h | 1 | ||||
-rw-r--r-- | sway/border.c | 6 | ||||
-rw-r--r-- | sway/commands.c | 11 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/focus.c | 23 | ||||
-rw-r--r-- | sway/handlers.c | 2 | ||||
-rw-r--r-- | sway/input_state.c | 2 | ||||
-rw-r--r-- | sway/ipc-json.c | 5 | ||||
-rw-r--r-- | sway/ipc-server.c | 10 |
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) { sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color); return 0xFFFFFFFF; } - uint32_t res = (uint32_t)strtol(color + 1, NULL, 16); + uint32_t res = (uint32_t)strtoul(color + 1, NULL, 16); if (strlen(color) == 7) { res = (res << 8) | 0xFF; } @@ -8,6 +8,11 @@ # # Logo key. Use Mod1 for Alt. set $mod Mod4 +# Home row direction keys, like vim +set $left h +set $down j +set $up k +set $right l # Your preferred terminal emulator set $term urxvt # Your preferred application launcher @@ -52,11 +57,11 @@ output * bg /usr/share/sway/Sway_Wallpaper_Blue_1920x1080.png fill # # Moving around: # - # Move your focus around with $mod+[h|j|k|l], like vim - bindsym $mod+h focus left - bindsym $mod+j focus down - bindsym $mod+k focus up - bindsym $mod+l focus right + # Move your focus around + bindsym $mod+$left focus left + bindsym $mod+$down focus down + bindsym $mod+$up focus up + bindsym $mod+$right focus right # or use $mod+[up|down|left|right] bindsym $mod+Left focus left bindsym $mod+Down focus down @@ -64,10 +69,10 @@ output * bg /usr/share/sway/Sway_Wallpaper_Blue_1920x1080.png fill bindsym $mod+Right focus right # _move_ the focused window with the same, but add Shift - bindsym $mod+Shift+h move left - bindsym $mod+Shift+j move down - bindsym $mod+Shift+k move up - bindsym $mod+Shift+l move right + bindsym $mod+Shift+$left move left + bindsym $mod+Shift+$down move down + bindsym $mod+Shift+$up move up + bindsym $mod+Shift+$right move right # ditto, with arrow keys bindsym $mod+Shift+Left move left bindsym $mod+Shift+Down move down @@ -137,6 +142,30 @@ output * bg /usr/share/sway/Sway_Wallpaper_Blue_1920x1080.png fill # Show the next scratchpad window or hide the focused scratchpad window. # If there are multiple scratchpad windows, this command cycles through them. bindsym $mod+minus scratchpad show +# +# Resizing containers: +# +mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + bindsym $left resize shrink width 10 px or 10 ppt + bindsym $down resize grow height 10 px or 10 ppt + bindsym $up resize shrink height 10 px or 10 ppt + bindsym $right resize grow width 10 px or 10 ppt + + # ditto, with arrow keys + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # return to default mode + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" # # 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); void update_container_border(swayc_t *container); void render_view_borders(wlc_handle view); -void map_update_view_border(swayc_t *view, void *data); int get_font_text_height(const char *font); bool should_hide_top_border(swayc_t *con, double y); 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) { } } -void map_update_view_border(swayc_t *view, void *data) { - if (view->type == C_VIEW) { - update_view_border(view); - } -} - void render_view_borders(wlc_handle view) { swayc_t *c = swayc_by_handle(view); 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) { } else if (strcasecmp(argv[0], "prev_on_output") == 0) { ws = workspace_output_prev(); } else if (strcasecmp(argv[0], "back_and_forth") == 0) { - if (prev_workspace_name) { - if (!(ws = workspace_by_name(prev_workspace_name))) { - ws = workspace_create(prev_workspace_name); - } + // if auto_back_and_forth is enabled, workspace_switch will swap + // the workspaces. If we created prev_workspace here, workspace_switch + // would put us back on original workspace. + if (config->auto_back_and_forth) { + ws = swayc_active_workspace(); + } else if (prev_workspace_name && !(ws = workspace_by_name(prev_workspace_name))) { + ws = workspace_create(prev_workspace_name); } } else { 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) { bar->font = NULL; bar->height = -1; bar->workspace_buttons = true; + bar->wrap_scroll = false; bar->separator_symbol = NULL; bar->strip_workspace_numbers = false; 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) { // Case where output changes case C_OUTPUT: - // update borders for views in prev - container_map(prev, map_update_view_border, NULL); wlc_output_focus(c->handle); break; @@ -54,8 +52,6 @@ static void update_focus(swayc_t *c) { default: case C_VIEW: case C_CONTAINER: - // TODO whatever to do when container changes - // for example, stacked and tabbing change stuff. break; } } @@ -110,18 +106,17 @@ bool set_focused_container(swayc_t *c) { active_ws_child_count = active_ws->children->length + active_ws->floating->length; } - swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle); - - // Get workspace for c, get that workspaces current focused container. swayc_t *workspace = swayc_active_workspace_for(c); - swayc_t *focused = get_focused_container(workspace); + swayc_t *focused = get_focused_container(&root_container); - if (swayc_is_fullscreen(focused) && focused != c) { + if (swayc_is_fullscreen(get_focused_container(workspace))) { // if switching to a workspace with a fullscreen view, // focus on the fullscreen view - c = focused; + c = get_focused_container(workspace); } + swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle); + if (c->type == C_VIEW) { // dispatch a window event ipc_event_window(c, "focus"); @@ -139,7 +134,7 @@ bool set_focused_container(swayc_t *c) { } // get new focused view and set focus to it. - if (c->type == C_CONTAINER || (c->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP))) { + if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { // unactivate previous focus if (focused->type == C_VIEW) { wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); @@ -149,7 +144,7 @@ bool set_focused_container(swayc_t *c) { if (c->type == C_VIEW) { wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true); } - // set focus if view_focus is unlocked + // set focus wlc_view_focus(c->handle); if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) { update_container_border(c); @@ -161,10 +156,6 @@ bool set_focused_container(swayc_t *c) { arrange_backgrounds(); arrange_windows(parent, -1, -1); } - } else if (c->type == C_WORKSPACE) { - // remove previous focus if view_focus is unlocked - update_container_border(c); - wlc_view_focus(0); } 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) { } wlc_view_set_mask(handle, VISIBLE); - if (return_to_workspace && current_ws) { + if (return_to_workspace && current_ws != swayc_active_workspace()) { // we were on one workspace, switched to another to add this view, // now let's return to where we were 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) { update_geometry(initial.ptr); // Set focus back to initial view set_focused_container(initial.ptr); + // Arrange the windows + arrange_windows(&root_container, -1, -1); } break; 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) { c->is_floating ? "auto_on" : "auto_off")); // we can't state the cause json_object_object_add(object, "app_id", c->app_id ? json_object_new_string(c->app_id) : NULL); - // we do not include children, floating etc. as views have none + json_object_object_add(object, "nodes", json_object_new_array()); + json_object_object_add(object, "floating_nodes", json_object_new_array()); } json_object *ipc_json_describe_container(swayc_t *c) { @@ -214,7 +215,7 @@ json_object *ipc_json_describe_container(swayc_t *c) { json_object *object = json_object_new_object(); - json_object_object_add(object, "id", json_object_new_int((intptr_t)&c)); + json_object_object_add(object, "id", json_object_new_int((uintptr_t)&c)); json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL); json_object_object_add(object, "rect", ipc_json_create_rect(c)); 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) { } void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) { + sway_log(L_DEBUG, "Sending workspace::%s event", change); json_object *obj = json_object_new_object(); json_object_object_add(obj, "change", json_object_new_string(change)); if (strcmp("focus", change) == 0) { if (old) { - json_object_object_add(obj, "old", ipc_json_describe_container(old)); + json_object_object_add(obj, "old", ipc_json_describe_container_recursive(old)); } else { json_object_object_add(obj, "old", NULL); } } if (new) { - json_object_object_add(obj, "current", ipc_json_describe_container(new)); + json_object_object_add(obj, "current", ipc_json_describe_container_recursive(new)); } else { json_object_object_add(obj, "current", NULL); } @@ -562,6 +563,7 @@ void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change) { } void ipc_event_window(swayc_t *window, const char *change) { + sway_log(L_DEBUG, "Sending window::%s event", change); json_object *obj = json_object_new_object(); json_object_object_add(obj, "change", json_object_new_string(change)); if (strcmp(change, "close") == 0 || !window) { @@ -577,6 +579,7 @@ void ipc_event_window(swayc_t *window, const char *change) { } void ipc_event_barconfig_update(struct bar_config *bar) { + sway_log(L_DEBUG, "Sending barconfig_update event"); json_object *json = ipc_json_describe_bar_config(bar); const char *json_string = json_object_to_json_string(json); ipc_send_event(json_string, IPC_EVENT_BARCONFIG_UPDATE); @@ -585,6 +588,7 @@ void ipc_event_barconfig_update(struct bar_config *bar) { } void ipc_event_mode(const char *mode) { + sway_log(L_DEBUG, "Sending mode::%s event", mode); json_object *obj = json_object_new_object(); json_object_object_add(obj, "change", json_object_new_string(mode)); @@ -595,6 +599,7 @@ void ipc_event_mode(const char *mode) { } void ipc_event_modifier(uint32_t modifier, const char *state) { + sway_log(L_DEBUG, "Sending modifier::%s event", state); json_object *obj = json_object_new_object(); json_object_object_add(obj, "change", json_object_new_string(state)); @@ -609,6 +614,7 @@ void ipc_event_modifier(uint32_t modifier, const char *state) { #if SWAY_BINDING_EVENT static void ipc_event_binding(json_object *sb_obj) { + sway_log(L_DEBUG, "Sending binding::run event"); json_object *obj = json_object_new_object(); json_object_object_add(obj, "change", json_object_new_string("run")); json_object_object_add(obj, "binding", sb_obj); |