aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-12-05 11:02:31 -0500
committerTony Crisci <tony@dubstepdish.com>2017-12-05 11:02:31 -0500
commit8bdf3b1b0275d53cee8538777f12461603b0a751 (patch)
tree7f93aba35ba5c022d3d825bd6720aa4916adba49 /sway
parent83b4c0648d75932c693b8636242202ea728035da (diff)
view set position
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/wl_shell.c9
-rw-r--r--sway/desktop/xdg_shell_v6.c9
-rw-r--r--sway/desktop/xwayland.c33
-rw-r--r--sway/tree/container.c5
-rw-r--r--sway/tree/layout.c6
5 files changed, 57 insertions, 5 deletions
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index 9641b911..b2e026ef 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -37,6 +37,14 @@ static void set_size(struct sway_view *view, int width, int height) {
wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height);
}
+static void set_position(struct sway_view *view, double ox, double oy) {
+ if (!assert_wl_shell(view)) {
+ return;
+ }
+ view->swayc->x = ox;
+ view->swayc->y = oy;
+}
+
static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_wl_shell_surface *sway_surface =
wl_container_of(listener, sway_surface, commit);
@@ -87,6 +95,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
sway_view->type = SWAY_WL_SHELL_VIEW;
sway_view->iface.get_prop = get_prop;
sway_view->iface.set_size = set_size;
+ sway_view->iface.set_position = set_position;
sway_view->wlr_wl_shell_surface = shell_surface;
sway_view->sway_wl_shell_surface = sway_surface;
sway_view->surface = shell_surface->surface;
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 2545d1a6..37e39f37 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -37,6 +37,14 @@ static void set_size(struct sway_view *view, int width, int height) {
wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
}
+static void set_position(struct sway_view *view, double ox, double oy) {
+ if (!assert_xdg(view)) {
+ return;
+ }
+ view->swayc->x = ox;
+ view->swayc->y = oy;
+}
+
static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_xdg_surface_v6 *sway_surface =
wl_container_of(listener, sway_surface, commit);
@@ -87,6 +95,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
sway_view->type = SWAY_XDG_SHELL_V6_VIEW;
sway_view->iface.get_prop = get_prop;
sway_view->iface.set_size = set_size;
+ sway_view->iface.set_position = set_position;
sway_view->wlr_xdg_surface_v6 = xdg_surface;
sway_view->sway_xdg_surface_v6 = sway_surface;
sway_view->surface = xdg_surface->surface;
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 04ec118d..266a5869 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -3,14 +3,17 @@
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/xwayland.h>
+#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_output.h>
#include "sway/container.h"
#include "sway/layout.h"
#include "sway/server.h"
#include "sway/view.h"
+#include "sway/output.h"
#include "log.h"
static bool assert_xwayland(struct sway_view *view) {
- return sway_assert(view->type == SWAY_XWAYLAND_VIEW,
+ return sway_assert(view->type == SWAY_XWAYLAND_VIEW && view->wlr_xwayland_surface,
"Expected xwayland view!");
}
@@ -40,6 +43,33 @@ static void set_size(struct sway_view *view, int width, int height) {
width, height);
}
+static void set_position(struct sway_view *view, double ox, double oy) {
+ if (!assert_xwayland(view)) {
+ return;
+ }
+ swayc_t *output = swayc_parent_by_type(view->swayc, C_OUTPUT);
+ if (!sway_assert(output, "view must be within tree to set position")) {
+ return;
+ }
+ swayc_t *root = swayc_parent_by_type(output, C_ROOT);
+ if (!sway_assert(root, "output must be within tree to set position")) {
+ return;
+ }
+ struct wlr_output_layout *layout = root->output_layout;
+ struct wlr_output_layout_output *loutput =
+ wlr_output_layout_get(layout, output->sway_output->wlr_output);
+ if (!sway_assert(loutput, "output must be within layout to set position")) {
+ return;
+ }
+
+ view->swayc->x = ox;
+ view->swayc->y = oy;
+
+ wlr_xwayland_surface_configure(view->wlr_xwayland_surface,
+ ox + loutput->x, oy + loutput->y,
+ view->width, view->height);
+}
+
static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_xwayland_surface *sway_surface =
wl_container_of(listener, sway_surface, commit);
@@ -102,6 +132,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
sway_view->type = SWAY_XWAYLAND_VIEW;
sway_view->iface.get_prop = get_prop;
sway_view->iface.set_size = set_size;
+ sway_view->iface.set_position = set_position;
sway_view->wlr_xwayland_surface = xsurface;
sway_view->sway_xwayland_surface = sway_surface;
// TODO remove from the tree when the surface goes away (unmapped)
diff --git a/sway/tree/container.c b/sway/tree/container.c
index c7bce38a..e205fbcf 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <wlr/types/wlr_output_layout.h>
#include "sway/container.h"
#include "sway/layout.h"
#include "sway/output.h"
@@ -53,6 +54,10 @@ swayc_t *new_output(struct sway_output *sway_output) {
output->width = size.width;
output->height = size.width;
+ // TODO configure output layout position
+ wlr_output_layout_add_auto(root_container.output_layout,
+ sway_output->wlr_output);
+
add_child(&root_container, output);
// Create workspace
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 2d442f2a..cb39a361 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -215,8 +215,7 @@ static void apply_horiz_layout(swayc_t *container,
sway_log(L_DEBUG,
"Calculating arrangement for %p:%d (will scale %f by %f)",
child, child->type, width, scale);
- child->x = child_x;
- child->y = y;
+ child->sway_view->iface.set_position(child->sway_view, child_x, y);
if (i == end - 1) {
double remaining_width = x + width - child_x;
@@ -266,8 +265,7 @@ void apply_vert_layout(swayc_t *container,
sway_log(L_DEBUG,
"Calculating arrangement for %p:%d (will scale %f by %f)",
child, child->type, height, scale);
- child->x = x;
- child->y = child_y;
+ child->sway_view->iface.set_position(child->sway_view, x, child_y);
if (i == end - 1) {
double remaining_height = y + height - child_y;