%token TOK_OPEN "open"
%token TOK_NEXT "next"
%token TOK_PREV "prev"
+%token TOK_SCRATCHPAD "scratchpad"
+%token TOK_SHOW "show"
%token TOK_SPLIT "split"
%token TOK_HORIZONTAL "horizontal"
%token TOK_VERTICAL "vertical"
| mark
| resize
| nop
+ | scratchpad
| mode
;
focus:
TOK_FOCUS
{
+ if (focused &&
+ focused->type != CT_WORKSPACE &&
+ focused->fullscreen_mode != CF_NONE) {
+ LOG("Cannot change focus while in fullscreen mode.\n");
+ break;
+ }
+
owindow *current;
if (match_is_empty(¤t_match)) {
}
| TOK_FOCUS direction
{
+ if (focused &&
+ focused->type != CT_WORKSPACE &&
+ focused->fullscreen_mode != CF_NONE) {
+ LOG("Cannot change focus while in fullscreen mode.\n");
+ break;
+ }
+
int direction = $2;
switch (direction) {
case TOK_LEFT:
}
| TOK_FOCUS window_mode
{
+ if (focused &&
+ focused->type != CT_WORKSPACE &&
+ focused->fullscreen_mode != CF_NONE) {
+ LOG("Cannot change focus while in fullscreen mode.\n");
+ break;
+ }
+
printf("should focus: ");
if ($2 == TOK_TILING)
}
| TOK_FOCUS level
{
+ if (focused &&
+ focused->type != CT_WORKSPACE &&
+ focused->fullscreen_mode != CF_NONE) {
+ LOG("Cannot change focus while in fullscreen mode.\n");
+ break;
+ }
+
if ($2 == TOK_PARENT)
level_up();
else level_down();
}
| TOK_WORKSPACE STR
{
+ if (strncasecmp($2, "__i3_", strlen("__i3_")) == 0) {
+ printf("You cannot switch to the i3 internal workspaces.\n");
+ break;
+ }
+
printf("should switch to workspace %s\n", $2);
Con *ws = con_get_workspace(focused);
printf("moving in direction %d\n", direction);
if (con_is_floating(focused)) {
printf("floating move with %d pixels\n", px);
+ Rect newrect = focused->parent->rect;
if (direction == TOK_LEFT) {
- focused->parent->rect.x -= px;
+ newrect.x -= px;
} else if (direction == TOK_RIGHT) {
- focused->parent->rect.x += px;
+ newrect.x += px;
} else if (direction == TOK_UP) {
- focused->parent->rect.y -= px;
+ newrect.y -= px;
} else if (direction == TOK_DOWN) {
- focused->parent->rect.y += px;
+ newrect.y += px;
}
+ floating_reposition(focused->parent, newrect);
} else {
tree_move(direction);
+ tree_render();
}
-
- tree_render();
}
| TOK_MOVE TOK_WORKSPACE STR
{
+ if (strncasecmp($3, "__i3_", strlen("__i3_")) == 0) {
+ printf("You cannot switch to the i3 internal workspaces.\n");
+ break;
+ }
+
owindow *current;
/* Error out early to not create a non-existing workspace (in
{
owindow *current;
- printf("should move window to output %s", $3);
+ printf("should move window to output %s\n", $3);
HANDLE_EMPTY_MATCH;
output = get_output_by_name($3);
free($3);
- if (!output)
+ if (!output) {
+ printf("No such output found.\n");
break;
+ }
/* get visible workspace on output */
Con *ws = NULL;
tree_render();
}
+ | TOK_MOVE TOK_SCRATCHPAD
+ {
+ printf("should move window to scratchpad\n");
+ owindow *current;
+
+ HANDLE_EMPTY_MATCH;
+
+ TAILQ_FOREACH(current, &owindows, owindows) {
+ printf("matching: %p / %s\n", current->con, current->con->name);
+ scratchpad_move(current->con);
+ }
+
+ tree_render();
+ }
;
append_layout:
mark:
TOK_MARK STR
{
+ printf("Clearing all windows which have that mark first\n");
+
+ Con *con;
+ TAILQ_FOREACH(con, &all_cons, all_cons) {
+ if (con->mark && strcmp(con->mark, $2) == 0)
+ FREE(con->mark);
+ }
+
printf("marking window with str %s\n", $2);
owindow *current;
TAILQ_FOREACH(current, &owindows, owindows) {
printf("matching: %p / %s\n", current->con, current->con->name);
- current->con->mark = sstrdup($2);
+ current->con->mark = $2;
}
- free($<string>2);
-
tree_render();
}
;
}
;
+scratchpad:
+ TOK_SCRATCHPAD TOK_SHOW
+ {
+ printf("should show scratchpad window\n");
+ owindow *current;
+
+ if (match_is_empty(¤t_match)) {
+ scratchpad_show(NULL);
+ } else {
+ TAILQ_FOREACH(current, &owindows, owindows) {
+ printf("matching: %p / %s\n", current->con, current->con->name);
+ scratchpad_show(current->con);
+ }
+ }
+
+ tree_render();
+ }
+ ;
+
+
resize:
TOK_RESIZE resize_way direction resize_px resize_tiling
{
ppt *= -1;
}
- if (con_is_floating(focused)) {
+ Con *floating_con;
+ if ((floating_con = con_inside_floating(focused))) {
printf("floating resize\n");
if (direction == TOK_UP) {
- focused->parent->rect.y -= px;
- focused->parent->rect.height += px;
+ floating_con->rect.y -= px;
+ floating_con->rect.height += px;
} else if (direction == TOK_DOWN) {
- focused->parent->rect.height += px;
+ floating_con->rect.height += px;
} else if (direction == TOK_LEFT) {
- focused->parent->rect.x -= px;
- focused->parent->rect.width += px;
+ floating_con->rect.x -= px;
+ floating_con->rect.width += px;
} else {
- focused->parent->rect.width += px;
+ floating_con->rect.width += px;
}
} else {
LOG("tiling resize\n");
while (current->parent->layout == L_STACKED ||
current->parent->layout == L_TABBED)
current = current->parent;
+
+ /* Then further go up until we find one with the matching orientation. */
+ orientation_t search_orientation =
+ (direction == TOK_LEFT || direction == TOK_RIGHT ? HORIZ : VERT);
+
+ while (current->type != CT_WORKSPACE &&
+ current->type != CT_FLOATING_CON &&
+ current->parent->orientation != search_orientation)
+ current = current->parent;
+
/* get the default percentage */
int children = con_num_children(current->parent);
Con *other;