Merge branch 'master' into next

This commit is contained in:
Michael Stapelberg
2014-01-13 23:36:47 +01:00
5 changed files with 133 additions and 38 deletions

View File

@ -1022,3 +1022,37 @@ int ipc_create_socket(const char *filename) {
current_socketpath = resolved;
return sockfd;
}
/*
* For the workspace "focus" event we send, along the usual "change" field,
* also the current and previous workspace, in "current" and "old"
* respectively.
*/
void ipc_send_workspace_focus_event(Con *current, Con *old) {
setlocale(LC_NUMERIC, "C");
yajl_gen gen = ygenalloc();
y(map_open);
ystr("change");
ystr("focus");
ystr("current");
dump_node(gen, current, false);
ystr("old");
if (old == NULL)
y(null);
else
dump_node(gen, old, false);
y(map_close);
const unsigned char *payload;
ylength length;
y(get_buf, &payload, &length);
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
y(free);
setlocale(LC_NUMERIC, "");
}

View File

@ -99,6 +99,7 @@ static void attach_to_workspace(Con *con, Con *ws, direction_t direction) {
*
*/
static void move_to_output_directed(Con *con, direction_t direction) {
Con *old_ws = con_get_workspace(con);
Con *current_output_con = con_get_output(con);
Output *current_output = get_output_by_name(current_output_con->name);
Output *output = get_output_next(direction, current_output, CLOSEST_OUTPUT);
@ -117,6 +118,16 @@ static void move_to_output_directed(Con *con, direction_t direction) {
}
attach_to_workspace(con, ws, direction);
/* fix the focus stack */
con_focus(con);
/* force re-painting the indicators */
FREE(con->deco_render_params);
tree_flatten(croot);
ipc_send_workspace_focus_event(ws, old_ws);
}
/*
@ -141,7 +152,7 @@ void tree_move(int direction) {
if (con->parent->type == CT_WORKSPACE && con_num_children(con->parent) == 1) {
/* This is the only con on this workspace */
move_to_output_directed(con, direction);
goto end;
return;
}
orientation_t o = (direction == D_LEFT || direction == D_RIGHT ? HORIZ : VERT);
@ -201,7 +212,7 @@ void tree_move(int direction) {
/* If we couldn't find a place to move it on this workspace,
* try to move it to a workspace on a different output */
move_to_output_directed(con, direction);
goto end;
return;
}
/* If there was no con with which we could swap the current one,

View File

@ -11,9 +11,6 @@
*
*/
#include "all.h"
#include "yajl_utils.h"
#include <yajl/yajl_gen.h>
/* Stores a copy of the name of the last used workspace for the workspace
* back-and-forth switching. */
@ -335,39 +332,6 @@ static void workspace_defer_update_urgent_hint_cb(EV_P_ ev_timer *w, int revents
FREE(con->urgency_timer);
}
/*
* For the "focus" event we send, along the usual "change" field, also the
* current and previous workspace, in "current" and "old" respectively.
*/
static void ipc_send_workspace_focus_event(Con *current, Con *old) {
setlocale(LC_NUMERIC, "C");
yajl_gen gen = ygenalloc();
y(map_open);
ystr("change");
ystr("focus");
ystr("current");
dump_node(gen, current, false);
ystr("old");
if (old == NULL)
y(null);
else
dump_node(gen, old, false);
y(map_close);
const unsigned char *payload;
ylength length;
y(get_buf, &payload, &length);
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
y(free);
setlocale(LC_NUMERIC, "");
}
static void _workspace_show(Con *workspace) {
Con *current, *old = NULL;