aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-02 10:57:45 -0400
committerLibravatar emersion <contact@emersion.fr>2018-04-02 10:57:45 -0400
commit61fabede14bb3a8fe9ee5a249352cd405fd1b9bf (patch)
treede0cc1378f2edba5cc194c8dcebe4d5fdaeda647 /sway/desktop
parentAdd sway_view_impl (diff)
downloadsway-61fabede14bb3a8fe9ee5a249352cd405fd1b9bf.tar.gz
sway-61fabede14bb3a8fe9ee5a249352cd405fd1b9bf.tar.zst
sway-61fabede14bb3a8fe9ee5a249352cd405fd1b9bf.zip
Address review comments
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/wl_shell.c23
-rw-r--r--sway/desktop/xdg_shell_v6.c24
-rw-r--r--sway/desktop/xwayland.c31
3 files changed, 27 insertions, 51 deletions
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index e0909a03..6528a397 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -30,24 +30,18 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
30 } 30 }
31} 31}
32 32
33static void set_size(struct sway_view *view, int width, int height) { 33static void configure(struct sway_view *view, double ox, double oy, int width,
34 int height) {
34 if (!assert_wl_shell(view)) { 35 if (!assert_wl_shell(view)) {
35 return; 36 return;
36 } 37 }
38 view_update_position(view, ox, oy);
37 view->sway_wl_shell_surface->pending_width = width; 39 view->sway_wl_shell_surface->pending_width = width;
38 view->sway_wl_shell_surface->pending_height = height; 40 view->sway_wl_shell_surface->pending_height = height;
39 wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height); 41 wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height);
40} 42}
41 43
42static void set_position(struct sway_view *view, double ox, double oy) { 44static void _close(struct sway_view *view) {
43 if (!assert_wl_shell(view)) {
44 return;
45 }
46 view->swayc->x = ox;
47 view->swayc->y = oy;
48}
49
50static void close(struct sway_view *view) {
51 if (!assert_wl_shell(view)) { 45 if (!assert_wl_shell(view)) {
52 return; 46 return;
53 } 47 }
@@ -57,9 +51,8 @@ static void close(struct sway_view *view) {
57 51
58static const struct sway_view_impl view_impl = { 52static const struct sway_view_impl view_impl = {
59 .get_prop = get_prop, 53 .get_prop = get_prop,
60 .set_size = set_size, 54 .configure = configure,
61 .set_position = set_position, 55 .close = _close,
62 .close = close,
63}; 56};
64 57
65static void handle_commit(struct wl_listener *listener, void *data) { 58static void handle_commit(struct wl_listener *listener, void *data) {
@@ -68,8 +61,8 @@ static void handle_commit(struct wl_listener *listener, void *data) {
68 struct sway_view *view = sway_surface->view; 61 struct sway_view *view = sway_surface->view;
69 // NOTE: We intentionally discard the view's desired width here 62 // NOTE: We intentionally discard the view's desired width here
70 // TODO: Let floating views do whatever 63 // TODO: Let floating views do whatever
71 view->width = sway_surface->pending_width; 64 view_update_size(view, sway_surface->pending_width,
72 view->height = sway_surface->pending_height; 65 sway_surface->pending_height);
73 view_damage_from(view); 66 view_damage_from(view);
74} 67}
75 68
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index c1adc7fe..49305b39 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -30,23 +30,18 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
30 } 30 }
31} 31}
32 32
33static void set_size(struct sway_view *view, int width, int height) { 33static void configure(struct sway_view *view, double ox, double oy, int width,
34 int height) {
34 if (!assert_xdg(view)) { 35 if (!assert_xdg(view)) {
35 return; 36 return;
36 } 37 }
38
39 view_update_position(view, ox, oy);
37 view->sway_xdg_surface_v6->pending_width = width; 40 view->sway_xdg_surface_v6->pending_width = width;
38 view->sway_xdg_surface_v6->pending_height = height; 41 view->sway_xdg_surface_v6->pending_height = height;
39 wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); 42 wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
40} 43}
41 44
42static void set_position(struct sway_view *view, double ox, double oy) {
43 if (!assert_xdg(view)) {
44 return;
45 }
46 view->swayc->x = ox;
47 view->swayc->y = oy;
48}
49
50static void set_activated(struct sway_view *view, bool activated) { 45static void set_activated(struct sway_view *view, bool activated) {
51 if (!assert_xdg(view)) { 46 if (!assert_xdg(view)) {
52 return; 47 return;
@@ -57,7 +52,7 @@ static void set_activated(struct sway_view *view, bool activated) {
57 } 52 }
58} 53}
59 54
60static void close(struct sway_view *view) { 55static void _close(struct sway_view *view) {
61 if (!assert_xdg(view)) { 56 if (!assert_xdg(view)) {
62 return; 57 return;
63 } 58 }
@@ -69,10 +64,9 @@ static void close(struct sway_view *view) {
69 64
70static const struct sway_view_impl view_impl = { 65static const struct sway_view_impl view_impl = {
71 .get_prop = get_prop, 66 .get_prop = get_prop,
72 .set_size = set_size, 67 .configure = configure,
73 .set_position = set_position,
74 .set_activated = set_activated, 68 .set_activated = set_activated,
75 .close = close, 69 .close = _close,
76}; 70};
77 71
78static void handle_commit(struct wl_listener *listener, void *data) { 72static void handle_commit(struct wl_listener *listener, void *data) {
@@ -82,8 +76,8 @@ static void handle_commit(struct wl_listener *listener, void *data) {
82 // NOTE: We intentionally discard the view's desired width here 76 // NOTE: We intentionally discard the view's desired width here
83 // TODO: Store this for restoration when moving to floating plane 77 // TODO: Store this for restoration when moving to floating plane
84 // TODO: Let floating views do whatever 78 // TODO: Let floating views do whatever
85 view->width = sway_surface->pending_width; 79 view_update_size(view, sway_surface->pending_width,
86 view->height = sway_surface->pending_height; 80 sway_surface->pending_height);
87 view_damage_from(view); 81 view_damage_from(view);
88} 82}
89 83
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 93c78228..39076fab 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -33,22 +33,13 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
33 } 33 }
34} 34}
35 35
36static void set_size(struct sway_view *view, int width, int height) { 36static void configure(struct sway_view *view, double ox, double oy, int width,
37 int height) {
37 if (!assert_xwayland(view)) { 38 if (!assert_xwayland(view)) {
38 return; 39 return;
39 } 40 }
40 view->sway_xwayland_surface->pending_width = width;
41 view->sway_xwayland_surface->pending_height = height;
42
43 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; 41 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
44 wlr_xwayland_surface_configure(xsurface, xsurface->x, xsurface->y,
45 width, height);
46}
47 42
48static void set_position(struct sway_view *view, double ox, double oy) {
49 if (!assert_xwayland(view)) {
50 return;
51 }
52 struct sway_container *output = container_parent(view->swayc, C_OUTPUT); 43 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
53 if (!sway_assert(output, "view must be within tree to set position")) { 44 if (!sway_assert(output, "view must be within tree to set position")) {
54 return; 45 return;
@@ -64,13 +55,12 @@ static void set_position(struct sway_view *view, double ox, double oy) {
64 return; 55 return;
65 } 56 }
66 57
67 view->swayc->x = ox; 58 view_update_position(view, ox, oy);
68 view->swayc->y = oy;
69 59
70 wlr_xwayland_surface_configure(view->wlr_xwayland_surface, 60 view->sway_xwayland_surface->pending_width = width;
71 ox + loutput->x, oy + loutput->y, 61 view->sway_xwayland_surface->pending_height = height;
72 view->wlr_xwayland_surface->width, 62 wlr_xwayland_surface_configure(xsurface, ox + loutput->x, oy + loutput->y,
73 view->wlr_xwayland_surface->height); 63 width, height);
74} 64}
75 65
76static void set_activated(struct sway_view *view, bool activated) { 66static void set_activated(struct sway_view *view, bool activated) {
@@ -90,8 +80,7 @@ static void _close(struct sway_view *view) {
90 80
91static const struct sway_view_impl view_impl = { 81static const struct sway_view_impl view_impl = {
92 .get_prop = get_prop, 82 .get_prop = get_prop,
93 .set_size = set_size, 83 .configure = configure,
94 .set_position = set_position,
95 .set_activated = set_activated, 84 .set_activated = set_activated,
96 .close = _close, 85 .close = _close,
97}; 86};
@@ -102,8 +91,8 @@ static void handle_commit(struct wl_listener *listener, void *data) {
102 struct sway_view *view = sway_surface->view; 91 struct sway_view *view = sway_surface->view;
103 // NOTE: We intentionally discard the view's desired width here 92 // NOTE: We intentionally discard the view's desired width here
104 // TODO: Let floating views do whatever 93 // TODO: Let floating views do whatever
105 view->width = sway_surface->pending_width; 94 view_update_size(view, sway_surface->pending_width,
106 view->height = sway_surface->pending_height; 95 sway_surface->pending_height);
107 view_damage_from(view); 96 view_damage_from(view);
108} 97}
109 98