mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Basic left right move command implemented.
This commit is contained in:
parent
f314d95103
commit
2a62c5c7fb
4 changed files with 71 additions and 4 deletions
|
@ -15,6 +15,7 @@ enum swayc_types{
|
||||||
C_TYPES,
|
C_TYPES,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum swayc_layouts{
|
enum swayc_layouts{
|
||||||
L_NONE,
|
L_NONE,
|
||||||
L_HORIZ,
|
L_HORIZ,
|
||||||
|
@ -75,6 +76,7 @@ swayc_t *destroy_view(swayc_t *view);
|
||||||
swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
|
swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
|
||||||
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
|
void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
|
||||||
|
|
||||||
|
|
||||||
// Mappings
|
// Mappings
|
||||||
void set_view_visibility(swayc_t *view, void *data);
|
void set_view_visibility(swayc_t *view, void *data);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
||||||
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
||||||
swayc_t *remove_child(swayc_t *child);
|
swayc_t *remove_child(swayc_t *child);
|
||||||
|
|
||||||
|
void move_container(swayc_t* container,swayc_t* root,int direction);
|
||||||
|
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
void arrange_windows(swayc_t *container, int width, int height);
|
void arrange_windows(swayc_t *container, int width, int height);
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,27 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char *
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cmd_move(struct sway_config *config, int argc, char **argv) {
|
static bool cmd_move(struct sway_config *config, int argc, char **argv) {
|
||||||
sway_log(L_DEBUG, "move cmd stub called");//Stubbed method until I get back.
|
if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
swayc_t *view = get_focused_container(&root_container);
|
||||||
|
|
||||||
|
if (strcasecmp(argv[0], "left") == 0) {
|
||||||
|
move_container(view,&root_container,MOVE_LEFT);
|
||||||
|
} else if (strcasecmp(argv[0], "right") == 0) {
|
||||||
|
move_container(view,&root_container,MOVE_RIGHT);
|
||||||
|
} else if (strcasecmp(argv[0], "up") == 0) {
|
||||||
|
move_container(view,&root_container,MOVE_UP);
|
||||||
|
} else if (strcasecmp(argv[0], "down") == 0) {
|
||||||
|
move_container(view,&root_container,MOVE_DOWN);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cmd_kill(struct sway_config *config, int argc, char **argv) {
|
static bool cmd_kill(struct sway_config *config, int argc, char **argv) {
|
||||||
|
@ -492,13 +511,13 @@ static struct cmd_handler handlers[] = {
|
||||||
{ "kill", cmd_kill },
|
{ "kill", cmd_kill },
|
||||||
{ "layout", cmd_layout },
|
{ "layout", cmd_layout },
|
||||||
{ "log_colors", cmd_log_colors },
|
{ "log_colors", cmd_log_colors },
|
||||||
|
{ "move",cmd_move},
|
||||||
{ "reload", cmd_reload },
|
{ "reload", cmd_reload },
|
||||||
{ "set", cmd_set },
|
{ "set", cmd_set },
|
||||||
{ "split", cmd_split },
|
{ "split", cmd_split },
|
||||||
{ "splith", cmd_splith },
|
{ "splith", cmd_splith },
|
||||||
{ "splitv", cmd_splitv },
|
{ "splitv", cmd_splitv },
|
||||||
{ "workspace", cmd_workspace },
|
{ "workspace", cmd_workspace }
|
||||||
{ "cmd_move",cmd_move}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static char **split_directive(char *line, int *argc) {
|
static char **split_directive(char *line, int *argc) {
|
||||||
|
|
|
@ -91,6 +91,50 @@ swayc_t *remove_child(swayc_t *child) {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void move_container(swayc_t *container,swayc_t* root,int direction){
|
||||||
|
sway_log(L_DEBUG, "Moved window");
|
||||||
|
swayc_t *temp;
|
||||||
|
int i;
|
||||||
|
uint clength = root->children->length;
|
||||||
|
//Rearrange
|
||||||
|
for (i = 0; i < clength; ++i) {
|
||||||
|
swayc_t *child = root->children->items[i];
|
||||||
|
if(child->handle == container->handle){
|
||||||
|
if(clength == 1){
|
||||||
|
//Only one container, meh.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Implement move to a different workspace.
|
||||||
|
if(direction == MOVE_LEFT && i > 0){
|
||||||
|
temp = root->children->items[i-1];
|
||||||
|
root->children->items[i] = temp;
|
||||||
|
root->children->items[i-1] = container;
|
||||||
|
arrange_windows(&root_container,-1,-1);
|
||||||
|
}
|
||||||
|
else if(direction == MOVE_RIGHT && i < clength-1){
|
||||||
|
temp = root->children->items[i+1];
|
||||||
|
root->children->items[i] = temp;
|
||||||
|
root->children->items[i+1] = container;
|
||||||
|
arrange_windows(&root_container,-1,-1);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(direction == MOVE_UP){
|
||||||
|
sway_log(L_INFO, "Moving up not implemented");
|
||||||
|
}
|
||||||
|
else if(direction == MOVE_DOWN){
|
||||||
|
sway_log(L_INFO, "Moving down not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(child->children != NULL){
|
||||||
|
move_container(container,child,direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void arrange_windows(swayc_t *container, int width, int height) {
|
void arrange_windows(swayc_t *container, int width, int height) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -282,4 +326,3 @@ swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) {
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue