diff --git a/generated/GENERATED_command_call.h b/generated/GENERATED_command_call.h index 74c62fb2..5b7ac329 100644 --- a/generated/GENERATED_command_call.h +++ b/generated/GENERATED_command_call.h @@ -198,11 +198,7 @@ static void GENERATED_call(const int call_identifier, struct CommandResultIR *re break; case 29: result->next_state = INITIAL; -#ifndef TEST_PARSER - cmd_move_con_to_workspace_name(¤t_match, result, get_string("workspace"), get_string("no_auto_back_and_forth")); -#else fprintf(stderr, "cmd_move_con_to_workspace_name(%s, %s)\n", get_string("workspace"), get_string("no_auto_back_and_forth")); -#endif break; case 30: result->next_state = INITIAL; diff --git a/i3-msg/main.c b/i3-msg/main.c index dfde2beb..904bcc48 100644 --- a/i3-msg/main.c +++ b/i3-msg/main.c @@ -114,6 +114,6 @@ int main(int argc, char *argv[]) { err(EXIT_FAILURE, "IPC: read()"); exit(1); } - puts(reply); + printf("%s", reply); return 0; } diff --git a/include/commands.h b/include/commands.h index 807a19ec..f319a08b 100644 --- a/include/commands.h +++ b/include/commands.h @@ -56,7 +56,7 @@ void cmd_move_con_to_workspace_back_and_forth(I3_CMD); * Implementation of 'move [--no-auto-back-and-forth] [window|container] [to] workspace '. * */ -void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *no_auto_back_and_forth); +SCM guile_move_con_to_workspace_name(SCM g_name); /** * Implementation of 'move [--no-auto-back-and-forth] [window|container] [to] workspace number '. diff --git a/src/commands.c b/src/commands.c index 8bb5aa19..9471a606 100644 --- a/src/commands.c +++ b/src/commands.c @@ -259,7 +259,7 @@ void cmd_criteria_add(I3_CMD, const char *ctype, const char *cvalue) { static void move_matches_to_workspace(Con *ws) { owindow *current; TAILQ_FOREACH (current, &owindows, owindows) { - DLOG("matching: %p / %s\n", current->con, current->con->name); + printf("matching: %p / %s -> %s\n", current->con, current->con->name, ws); con_move_to_workspace(current->con, ws, true, false, false); } } @@ -300,7 +300,7 @@ static void move_matches_to_workspace(Con *ws) { SCM guile_move_con_to_workspace(SCM g_which) { const char * which = scm_to_locale_string(g_which); - DLOG("which=%s\n", which); + printf("which=%s\n", which); while (!TAILQ_EMPTY(&owindows)) { owindow *ow = TAILQ_FIRST(&owindows); @@ -348,7 +348,7 @@ SCM guile_move_con_to_workspace(SCM g_which) { else if (strcmp(which, "current") == 0) ws = con_get_workspace(focused); else { - /* yerror("BUG: called with which=%s", which); */ + printf("BUG: called with which=%s\n", which); return SCM_BOOL_F; } @@ -382,27 +382,58 @@ void cmd_move_con_to_workspace_back_and_forth(I3_CMD) { * Implementation of 'move [--no-auto-back-and-forth] [window|container] [to] workspace '. * */ -void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *no_auto_back_and_forth) { - if (strncasecmp(name, "__", strlen("__")) == 0) { - yerror("You cannot move containers to i3-internal workspaces (\"%s\").", name); - return; +SCM guile_move_con_to_workspace_name(SCM g_name) { + const char * name = scm_to_locale_string(g_name); + /* if (strncasecmp(name, "__", strlen("__")) == 0) { */ + /* yerror("You cannot move containers to i3-internal workspaces (\"%s\").", name); */ + /* return; */ + /* } */ + + while (!TAILQ_EMPTY(&owindows)) { + owindow *ow = TAILQ_FIRST(&owindows); + TAILQ_REMOVE(&owindows, ow, owindows); + free(ow); + } + owindow *ow = smalloc(sizeof(owindow)); + ow->con = focused; + TAILQ_INIT(&owindows); + TAILQ_INSERT_TAIL(&owindows, ow, owindows); + + + if (TAILQ_EMPTY(&owindows)) { + /* yerror("Nothing to move: specified criteria don't match any window"); */ + return SCM_BOOL_F; + } + bool found = false; + owindow *current = TAILQ_FIRST(&owindows); + while (current) { + owindow *next = TAILQ_NEXT(current, owindows); + + if (current->con->type == CT_WORKSPACE && !con_has_children(current->con)) { + TAILQ_REMOVE(&owindows, current, owindows); + } else { + found = true; } - CHECK_MOVE_CON_TO_WORKSPACE; + current = next; + } + if (!found) { + /* yerror("Nothing to move: workspace empty"); */ + return SCM_BOOL_F; + } - LOG("should move window to workspace %s\n", name); + LOG("should move window to workspace %s\n", name); /* get the workspace */ Con *ws = workspace_get(name, NULL); - if (no_auto_back_and_forth == NULL) { - ws = maybe_auto_back_and_forth_workspace(ws); - } + ws = maybe_auto_back_and_forth_workspace(ws); move_matches_to_workspace(ws); - cmd_output->needs_tree_render = true; + tree_render(); // XXX: default reply for now, make this a better reply - ysuccess(true); + /* ysuccess(true); */ + return SCM_BOOL_T; } /* diff --git a/src/con.c b/src/con.c index 645d1448..dd331d03 100644 --- a/src/con.c +++ b/src/con.c @@ -1422,7 +1422,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool Con *source_ws = con_get_workspace(con); if (workspace == source_ws) { - DLOG("Not moving, already there\n"); + puts("Not moving, already there"); return; } diff --git a/src/key_press.c b/src/key_press.c index fcf73558..3a59bf41 100644 --- a/src/key_press.c +++ b/src/key_press.c @@ -24,7 +24,8 @@ void handle_key_press(xcb_key_press_event_t *event) { /* printf("%s %d, state raw = 0x%x\n", (key_release ? "KeyRelease" : "KeyPress"), event->detail, event->state); */ - int col = (event->state & XCB_MOD_MASK_SHIFT); + /* int col = (event->state & XCB_MOD_MASK_SHIFT); */ + int col = (event->state & XCB_MOD_MASK_ANY); xcb_keysym_t sym = xcb_key_press_lookup_keysym(keysyms, event, col); if (sym == XKB_KEY_NoSymbol) { ELOG("Could not translate string to key symbol: \"%s\"\n", sym); @@ -34,7 +35,6 @@ void handle_key_press(xcb_key_press_event_t *event) { char buf[7]; xkb_keysym_to_utf8(sym, buf, 7); - // Let guile resolve the binding for us guile_hook("key-press-hook", scm_list_3(scm_from_int(event->response_type), diff --git a/src/main.c b/src/main.c index f5aa37a2..db61f5e9 100644 --- a/src/main.c +++ b/src/main.c @@ -321,7 +321,8 @@ register_functions (void* data) { scm_c_define_gsubr ("focus-direction", 1, 0, 0, &guile_focus_direction); scm_c_define_gsubr ("layout", 1, 0, 0, &guile_layout); scm_c_define_gsubr ("toggle-layout", 1, 0, 0, &guile_layout_toggle); - scm_c_define_gsubr ("move-to-workspace", 1, 0, 0, &guile_move_con_to_workspace); + /* scm_c_define_gsubr ("move-to-workspace", 1, 0, 0, &guile_move_con_to_workspace); */ + scm_c_define_gsubr ("move-to-workspace", 1, 0, 0, &guile_move_con_to_workspace_name); scm_c_define_gsubr ("rename-workspace", 2, 0, 0, &guile_rename_workspace);