summaryrefslogtreecommitdiff
path: root/desktop-shell
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2022-07-16 00:22:00 +0300
committerMarius Vlad <marius.vlad@collabora.com>2022-08-09 13:36:43 +0300
commit5bcbe92d51c627093e5669c20ae0ee78ff50abe0 (patch)
treea3ca039c24407fa4516bf0fe88ada4672d91118b /desktop-shell
parent37a3025d893def991dec59587d17672aa3bf967a (diff)
downloadweston-5bcbe92d51c627093e5669c20ae0ee78ff50abe0.tar.gz
desktops-shell: Add tiled orientation support using key-bindings
Patch adds KEY_UP/KEY_DOWN for tiled top and bottom positioning, KEY_LEFT/KEY_RIGHT correspondingly, for left and right positioning. It also modifies the man page to include these new bindings, But also with commit 'compositor: Remove desktop zoom' we no longer have zoom effects so removed them. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Diffstat (limited to 'desktop-shell')
-rw-r--r--desktop-shell/shell.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 0e746b05..0c6b769a 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2897,6 +2897,83 @@ fullscreen_binding(struct weston_keyboard *keyboard,
}
static void
+set_tiled_orientation(struct weston_surface *focus,
+ enum weston_top_level_tiled_orientation orientation)
+{
+ struct weston_surface *surface;
+ struct shell_surface *shsurf;
+ int width, height;
+ pixman_rectangle32_t area;
+ struct weston_geometry geom;
+ int x, y;
+
+ surface = weston_surface_get_main_surface(focus);
+ if (surface == NULL)
+ return;
+
+ shsurf = get_shell_surface(surface);
+ if (shsurf == NULL)
+ return;
+
+ get_maximized_size(shsurf, &width, &height);
+ get_output_work_area(shsurf->shell, shsurf->output, &area);
+ geom = weston_desktop_surface_get_geometry(shsurf->desktop_surface);
+
+ if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT ||
+ orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT)
+ width /= 2;
+ else if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP ||
+ orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM)
+ height /= 2;
+
+ x = area.x - geom.x;
+ y = area.y - geom.y;
+
+ if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT)
+ x += width;
+ else if (orientation & WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM)
+ y += height;
+
+ weston_view_set_position(shsurf->view, x, y);
+ weston_desktop_surface_set_size(shsurf->desktop_surface, width, height);
+ weston_desktop_surface_set_orientation(shsurf->desktop_surface, orientation);
+ weston_compositor_schedule_repaint(surface->compositor);
+}
+
+static void
+set_tiled_orientation_left(struct weston_keyboard *keyboard,
+ const struct timespec *time,
+ uint32_t button, void *data)
+{
+ set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT);
+
+}
+
+static void
+set_tiled_orientation_right(struct weston_keyboard *keyboard,
+ const struct timespec *time,
+ uint32_t button, void *data)
+{
+ set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT);
+}
+
+static void
+set_tiled_orientation_up(struct weston_keyboard *keyboard,
+ const struct timespec *time,
+ uint32_t button, void *data)
+{
+ set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP);
+}
+
+static void
+set_tiled_orientation_down(struct weston_keyboard *keyboard,
+ const struct timespec *time,
+ uint32_t button, void *data)
+{
+ set_tiled_orientation(keyboard->focus, WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM);
+}
+
+static void
touch_move_binding(struct weston_touch *touch, const struct timespec *time, void *data)
{
struct weston_surface *focus;
@@ -4492,6 +4569,15 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
mod | MODIFIER_SHIFT,
resize_binding, shell);
+ weston_compositor_add_key_binding(ec, KEY_LEFT, mod | MODIFIER_SHIFT,
+ set_tiled_orientation_left, NULL);
+ weston_compositor_add_key_binding(ec, KEY_RIGHT, mod | MODIFIER_SHIFT,
+ set_tiled_orientation_right, NULL);
+ weston_compositor_add_key_binding(ec, KEY_UP, mod | MODIFIER_SHIFT,
+ set_tiled_orientation_up, NULL);
+ weston_compositor_add_key_binding(ec, KEY_DOWN, mod | MODIFIER_SHIFT,
+ set_tiled_orientation_down, NULL);
+
if (ec->capabilities & WESTON_CAP_ROTATION_ANY)
weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod,
rotate_binding, NULL);