aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-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
8 files changed, 29 insertions, 31 deletions
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);