aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-30 22:46:25 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-30 22:46:25 +1000
commite396af853b01438f7e5ef34bfa6fd2507d11ce5a (patch)
tree323739dc80680dd774acfdcf43eb76cfe93aa64c
parentFix compile error (diff)
parentMerge pull request #2179 from atomnuker/master (diff)
downloadsway-e396af853b01438f7e5ef34bfa6fd2507d11ce5a.tar.gz
sway-e396af853b01438f7e5ef34bfa6fd2507d11ce5a.tar.zst
sway-e396af853b01438f7e5ef34bfa6fd2507d11ce5a.zip
Merge remote-tracking branch 'upstream/master' into atomic
-rw-r--r--include/sway/tree/view.h3
-rw-r--r--sway/desktop/output.c2
-rw-r--r--sway/desktop/xdg_shell.c16
-rw-r--r--sway/desktop/xdg_shell_v6.c10
-rw-r--r--sway/desktop/xwayland.c10
-rw-r--r--sway/tree/container.c13
-rw-r--r--sway/tree/view.c13
-rw-r--r--swaymsg/main.c23
8 files changed, 68 insertions, 22 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 1bcb0582..b99044d3 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -32,6 +32,7 @@ struct sway_view_impl {
32 uint32_t (*configure)(struct sway_view *view, double lx, double ly, 32 uint32_t (*configure)(struct sway_view *view, double lx, double ly,
33 int width, int height); 33 int width, int height);
34 void (*set_activated)(struct sway_view *view, bool activated); 34 void (*set_activated)(struct sway_view *view, bool activated);
35 void (*set_tiled)(struct sway_view *view, bool tiled);
35 void (*set_fullscreen)(struct sway_view *view, bool fullscreen); 36 void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
36 bool (*wants_floating)(struct sway_view *view); 37 bool (*wants_floating)(struct sway_view *view);
37 void (*for_each_surface)(struct sway_view *view, 38 void (*for_each_surface)(struct sway_view *view,
@@ -223,6 +224,8 @@ void view_autoconfigure(struct sway_view *view);
223 224
224void view_set_activated(struct sway_view *view, bool activated); 225void view_set_activated(struct sway_view *view, bool activated);
225 226
227void view_set_tiled(struct sway_view *view, bool tiled);
228
226void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); 229void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen);
227 230
228void view_set_fullscreen(struct sway_view *view, bool fullscreen); 231void view_set_fullscreen(struct sway_view *view, bool fullscreen);
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index b55a3962..541d765d 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -870,7 +870,7 @@ static void render_floating_container(struct sway_output *soutput,
870 render_titlebar(soutput, damage, con, con->current.swayc_x, 870 render_titlebar(soutput, damage, con, con->current.swayc_x,
871 con->current.swayc_y, con->current.swayc_width, colors, 871 con->current.swayc_y, con->current.swayc_width, colors,
872 title_texture, marks_texture); 872 title_texture, marks_texture);
873 } else { 873 } else if (con->current.border != B_NONE) {
874 render_top_border(soutput, damage, con, colors); 874 render_top_border(soutput, damage, con, colors);
875 } 875 }
876 render_view(soutput, damage, con, colors); 876 render_view(soutput, damage, con, colors);
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 0f45399d..da3a1cdd 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -108,6 +108,19 @@ static void set_activated(struct sway_view *view, bool activated) {
108 } 108 }
109} 109}
110 110
111static void set_tiled(struct sway_view *view, bool tiled) {
112 if (xdg_shell_view_from_view(view) == NULL) {
113 return;
114 }
115 struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
116 enum wlr_edges edges = WLR_EDGE_NONE;
117 if (tiled) {
118 edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP |
119 WLR_EDGE_BOTTOM;
120 }
121 wlr_xdg_toplevel_set_tiled(surface, edges);
122}
123
111static void set_fullscreen(struct sway_view *view, bool fullscreen) { 124static void set_fullscreen(struct sway_view *view, bool fullscreen) {
112 if (xdg_shell_view_from_view(view) == NULL) { 125 if (xdg_shell_view_from_view(view) == NULL) {
113 return; 126 return;
@@ -157,6 +170,7 @@ static const struct sway_view_impl view_impl = {
157 .get_string_prop = get_string_prop, 170 .get_string_prop = get_string_prop,
158 .configure = configure, 171 .configure = configure,
159 .set_activated = set_activated, 172 .set_activated = set_activated,
173 .set_tiled = set_tiled,
160 .set_fullscreen = set_fullscreen, 174 .set_fullscreen = set_fullscreen,
161 .wants_floating = wants_floating, 175 .wants_floating = wants_floating,
162 .for_each_surface = for_each_surface, 176 .for_each_surface = for_each_surface,
@@ -288,8 +302,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
288 wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'", 302 wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
289 xdg_surface->toplevel->title, xdg_surface->toplevel->app_id); 303 xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
290 wlr_xdg_surface_ping(xdg_surface); 304 wlr_xdg_surface_ping(xdg_surface);
291 wlr_xdg_toplevel_set_tiled(xdg_surface, WLR_EDGE_LEFT | WLR_EDGE_RIGHT |
292 WLR_EDGE_TOP | WLR_EDGE_BOTTOM);
293 305
294 struct sway_xdg_shell_view *xdg_shell_view = 306 struct sway_xdg_shell_view *xdg_shell_view =
295 calloc(1, sizeof(struct sway_xdg_shell_view)); 307 calloc(1, sizeof(struct sway_xdg_shell_view));
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index b296f1a8..69819280 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -108,6 +108,14 @@ static void set_activated(struct sway_view *view, bool activated) {
108 } 108 }
109} 109}
110 110
111static void set_tiled(struct sway_view *view, bool tiled) {
112 if (xdg_shell_v6_view_from_view(view) == NULL) {
113 return;
114 }
115 struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6;
116 wlr_xdg_toplevel_v6_set_maximized(surface, tiled);
117}
118
111static void set_fullscreen(struct sway_view *view, bool fullscreen) { 119static void set_fullscreen(struct sway_view *view, bool fullscreen) {
112 if (xdg_shell_v6_view_from_view(view) == NULL) { 120 if (xdg_shell_v6_view_from_view(view) == NULL) {
113 return; 121 return;
@@ -158,6 +166,7 @@ static const struct sway_view_impl view_impl = {
158 .get_string_prop = get_string_prop, 166 .get_string_prop = get_string_prop,
159 .configure = configure, 167 .configure = configure,
160 .set_activated = set_activated, 168 .set_activated = set_activated,
169 .set_tiled = set_tiled,
161 .set_fullscreen = set_fullscreen, 170 .set_fullscreen = set_fullscreen,
162 .wants_floating = wants_floating, 171 .wants_floating = wants_floating,
163 .for_each_surface = for_each_surface, 172 .for_each_surface = for_each_surface,
@@ -284,7 +293,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
284 wlr_log(L_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'", 293 wlr_log(L_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
285 xdg_surface->toplevel->title, xdg_surface->toplevel->app_id); 294 xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
286 wlr_xdg_surface_v6_ping(xdg_surface); 295 wlr_xdg_surface_v6_ping(xdg_surface);
287 wlr_xdg_toplevel_v6_set_maximized(xdg_surface, true);
288 296
289 struct sway_xdg_shell_v6_view *xdg_shell_v6_view = 297 struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
290 calloc(1, sizeof(struct sway_xdg_shell_v6_view)); 298 calloc(1, sizeof(struct sway_xdg_shell_v6_view));
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index ad893248..6e63c505 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -200,6 +200,14 @@ static void set_activated(struct sway_view *view, bool activated) {
200 wlr_xwayland_surface_activate(surface, activated); 200 wlr_xwayland_surface_activate(surface, activated);
201} 201}
202 202
203static void set_tiled(struct sway_view *view, bool tiled) {
204 if (xwayland_view_from_view(view) == NULL) {
205 return;
206 }
207 struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
208 wlr_xwayland_surface_set_maximized(surface, tiled);
209}
210
203static void set_fullscreen(struct sway_view *view, bool fullscreen) { 211static void set_fullscreen(struct sway_view *view, bool fullscreen) {
204 if (xwayland_view_from_view(view) == NULL) { 212 if (xwayland_view_from_view(view) == NULL) {
205 return; 213 return;
@@ -258,6 +266,7 @@ static const struct sway_view_impl view_impl = {
258 .get_int_prop = get_int_prop, 266 .get_int_prop = get_int_prop,
259 .configure = configure, 267 .configure = configure,
260 .set_activated = set_activated, 268 .set_activated = set_activated,
269 .set_tiled = set_tiled,
261 .set_fullscreen = set_fullscreen, 270 .set_fullscreen = set_fullscreen,
262 .wants_floating = wants_floating, 271 .wants_floating = wants_floating,
263 .close = _close, 272 .close = _close,
@@ -307,7 +316,6 @@ static void handle_map(struct wl_listener *listener, void *data) {
307 xwayland_view->commit.notify = handle_commit; 316 xwayland_view->commit.notify = handle_commit;
308 317
309 // Put it back into the tree 318 // Put it back into the tree
310 wlr_xwayland_surface_set_maximized(xsurface, true);
311 view_map(view, xsurface->surface); 319 view_map(view, xsurface->surface);
312 320
313 if (xsurface->fullscreen) { 321 if (xsurface->fullscreen) {
diff --git a/sway/tree/container.c b/sway/tree/container.c
index ab3d9dbd..6f6137c4 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -522,21 +522,11 @@ static struct sway_container *container_at_view(struct sway_container *swayc,
522 view_sx, view_sy, &_sx, &_sy); 522 view_sx, view_sy, &_sx, &_sy);
523 break; 523 break;
524 case SWAY_VIEW_XDG_SHELL_V6: 524 case SWAY_VIEW_XDG_SHELL_V6:
525 // the top left corner of the sway container is the
526 // coordinate of the top left corner of the window geometry
527 view_sx += sview->wlr_xdg_surface_v6->geometry.x;
528 view_sy += sview->wlr_xdg_surface_v6->geometry.y;
529
530 _surface = wlr_xdg_surface_v6_surface_at( 525 _surface = wlr_xdg_surface_v6_surface_at(
531 sview->wlr_xdg_surface_v6, 526 sview->wlr_xdg_surface_v6,
532 view_sx, view_sy, &_sx, &_sy); 527 view_sx, view_sy, &_sx, &_sy);
533 break; 528 break;
534 case SWAY_VIEW_XDG_SHELL: 529 case SWAY_VIEW_XDG_SHELL:
535 // the top left corner of the sway container is the
536 // coordinate of the top left corner of the window geometry
537 view_sx += sview->wlr_xdg_surface->geometry.x;
538 view_sy += sview->wlr_xdg_surface->geometry.y;
539
540 _surface = wlr_xdg_surface_surface_at( 530 _surface = wlr_xdg_surface_surface_at(
541 sview->wlr_xdg_surface, 531 sview->wlr_xdg_surface,
542 view_sx, view_sy, &_sx, &_sy); 532 view_sx, view_sy, &_sx, &_sy);
@@ -954,6 +944,9 @@ void container_set_floating(struct sway_container *container, bool enable) {
954 container_add_child(workspace, container); 944 container_add_child(workspace, container);
955 container->width = container->parent->width; 945 container->width = container->parent->width;
956 container->height = container->parent->height; 946 container->height = container->parent->height;
947 if (container->type == C_VIEW) {
948 view_set_tiled(container->sway_view, true);
949 }
957 container->is_sticky = false; 950 container->is_sticky = false;
958 container_reap_empty_recursive(workspace->sway_workspace->floating); 951 container_reap_empty_recursive(workspace->sway_workspace->floating);
959 } 952 }
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 9f85bac0..6263bfb0 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -164,6 +164,9 @@ void view_init_floating(struct sway_view *view) {
164 view->border_left = view->border_right = true; 164 view->border_left = view->border_right = true;
165 165
166 container_set_geometry_from_floating_view(view->swayc); 166 container_set_geometry_from_floating_view(view->swayc);
167
168 // Don't maximize floating windows
169 view_set_tiled(view, false);
167} 170}
168 171
169void view_autoconfigure(struct sway_view *view) { 172void view_autoconfigure(struct sway_view *view) {
@@ -275,6 +278,7 @@ void view_autoconfigure(struct sway_view *view) {
275 view->y = y; 278 view->y = y;
276 view->width = width; 279 view->width = width;
277 view->height = height; 280 view->height = height;
281 view_set_tiled(view, true);
278} 282}
279 283
280void view_set_activated(struct sway_view *view, bool activated) { 284void view_set_activated(struct sway_view *view, bool activated) {
@@ -283,6 +287,13 @@ void view_set_activated(struct sway_view *view, bool activated) {
283 } 287 }
284} 288}
285 289
290void view_set_tiled(struct sway_view *view, bool tiled) {
291 view->border = tiled ? config->border : B_NONE;
292 if (view->impl->set_tiled) {
293 view->impl->set_tiled(view, tiled);
294 }
295}
296
286void view_set_fullscreen(struct sway_view *view, bool fullscreen) { 297void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
287 if (view->is_fullscreen == fullscreen) { 298 if (view->is_fullscreen == fullscreen) {
288 return; 299 return;
@@ -948,7 +959,7 @@ bool view_is_visible(struct sway_view *view) {
948 // Check view isn't in a tabbed or stacked container on an inactive tab 959 // Check view isn't in a tabbed or stacked container on an inactive tab
949 struct sway_seat *seat = input_manager_current_seat(input_manager); 960 struct sway_seat *seat = input_manager_current_seat(input_manager);
950 struct sway_container *container = view->swayc; 961 struct sway_container *container = view->swayc;
951 while (container->type != C_WORKSPACE) { 962 while (container->type != C_WORKSPACE && container->layout != L_FLOATING) {
952 if (container->parent->layout == L_TABBED || 963 if (container->parent->layout == L_TABBED ||
953 container->parent->layout == L_STACKED) { 964 container->parent->layout == L_STACKED) {
954 if (seat_get_active_child(seat, container->parent) != container) { 965 if (seat_get_active_child(seat, container->parent) != container) {
diff --git a/swaymsg/main.c b/swaymsg/main.c
index 29f2a907..4283bf00 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -19,30 +19,40 @@ void sway_terminate(int exit_code) {
19 exit(exit_code); 19 exit(exit_code);
20} 20}
21 21
22static bool success_object(json_object *result) {
23 json_object *success;
24
25 if (!json_object_object_get_ex(result, "success", &success)) {
26 return false;
27 }
28
29 return json_object_get_boolean(success);
30}
31
22// Iterate results array and return false if any of them failed 32// Iterate results array and return false if any of them failed
23static bool success(json_object *r, bool fallback) { 33static bool success(json_object *r, bool fallback) {
24 if (!json_object_is_type(r, json_type_array)) { 34 if (!json_object_is_type(r, json_type_array)) {
25 return fallback; 35 return fallback;
26 } 36 }
37
27 size_t results_len = json_object_array_length(r); 38 size_t results_len = json_object_array_length(r);
28 if (!results_len) { 39 if (!results_len) {
29 return fallback; 40 return fallback;
30 } 41 }
42
31 for (size_t i = 0; i < results_len; ++i) { 43 for (size_t i = 0; i < results_len; ++i) {
32 json_object *result = json_object_array_get_idx(r, i); 44 json_object *result = json_object_array_get_idx(r, i);
33 json_object *success; 45
34 if (!json_object_object_get_ex(result, "success", &success)) { 46 if (!success_object(result)) {
35 return false;
36 }
37 if (!json_object_get_boolean(success)) {
38 return false; 47 return false;
39 } 48 }
40 } 49 }
50
41 return true; 51 return true;
42} 52}
43 53
44static void pretty_print_cmd(json_object *r) { 54static void pretty_print_cmd(json_object *r) {
45 if (!success(r, true)) { 55 if (!success_object(r)) {
46 json_object *error; 56 json_object *error;
47 if (!json_object_object_get_ex(r, "error", &error)) { 57 if (!json_object_object_get_ex(r, "error", &error)) {
48 printf("An unknkown error occurred"); 58 printf("An unknkown error occurred");
@@ -402,6 +412,7 @@ int main(int argc, char **argv) {
402 } else { 412 } else {
403 sway_abort("Unknown message type %s", cmdtype); 413 sway_abort("Unknown message type %s", cmdtype);
404 } 414 }
415
405 free(cmdtype); 416 free(cmdtype);
406 417
407 char *command = NULL; 418 char *command = NULL;