Skip to content

Commit

Permalink
view: move MoveRelative code from action.c and restore natural geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph42oN authored and Consolatis committed Jul 23, 2023
1 parent c6e2f66 commit cb4afad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ void view_close(struct view *view);
void view_move_resize(struct view *view, struct wlr_box geo);
void view_resize_relative(struct view *view,
int left, int right, int top, int bottom);
void view_move_relative(struct view *view, int x, int y);
void view_move(struct view *view, int x, int y);
void view_moved(struct view *view);
void view_minimize(struct view *view, bool minimized);
Expand Down
5 changes: 2 additions & 3 deletions src/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,10 @@ actions_run(struct view *activator, struct server *server,
}
break;
case ACTION_TYPE_MOVE_RELATIVE:
if (view && !view->fullscreen) {
if (view) {
int x = get_arg_value_int(action, "x", 0);
int y = get_arg_value_int(action, "y", 0);
view_maximize(view, false, false);
view_move(view, view->pending.x + x, view->pending.y + y);
view_move_relative(view, x, y);
}
break;
case ACTION_TYPE_SEND_TO_DESKTOP:
Expand Down
17 changes: 16 additions & 1 deletion src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ view_move_resize(struct view *view, struct wlr_box geo)
void
view_resize_relative(struct view *view, int left, int right, int top, int bottom)
{
if (view->fullscreen || view->maximized)
if (view->fullscreen || view->maximized) {
return;
}
struct wlr_box newgeo = view->pending;
newgeo.x -= left;
newgeo.width += left + right;
Expand All @@ -217,6 +218,20 @@ view_resize_relative(struct view *view, int left, int right, int top, int bottom
view_set_untiled(view);
}

void
view_move_relative(struct view *view, int x, int y)
{
if (view->fullscreen) {
return;
}
view_maximize(view, false, /*store_natural_geometry*/ false);
if (view_is_tiled(view)) {
view_set_untiled(view);
view_restore_to(view, view->natural_geometry);
}
view_move(view, view->pending.x + x, view->pending.y + y);
}

void
view_adjust_size(struct view *view, int *w, int *h)
{
Expand Down

0 comments on commit cb4afad

Please sign in to comment.