mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
Merge remote-tracking branch 'upstream/master' into atomic
This commit is contained in:
commit
e396af853b
|
@ -32,6 +32,7 @@ struct sway_view_impl {
|
||||||
uint32_t (*configure)(struct sway_view *view, double lx, double ly,
|
uint32_t (*configure)(struct sway_view *view, double lx, double ly,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
void (*set_activated)(struct sway_view *view, bool activated);
|
void (*set_activated)(struct sway_view *view, bool activated);
|
||||||
|
void (*set_tiled)(struct sway_view *view, bool tiled);
|
||||||
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
|
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
|
||||||
bool (*wants_floating)(struct sway_view *view);
|
bool (*wants_floating)(struct sway_view *view);
|
||||||
void (*for_each_surface)(struct sway_view *view,
|
void (*for_each_surface)(struct sway_view *view,
|
||||||
|
@ -223,6 +224,8 @@ void view_autoconfigure(struct sway_view *view);
|
||||||
|
|
||||||
void view_set_activated(struct sway_view *view, bool activated);
|
void view_set_activated(struct sway_view *view, bool activated);
|
||||||
|
|
||||||
|
void view_set_tiled(struct sway_view *view, bool tiled);
|
||||||
|
|
||||||
void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen);
|
void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen);
|
||||||
|
|
||||||
void view_set_fullscreen(struct sway_view *view, bool fullscreen);
|
void view_set_fullscreen(struct sway_view *view, bool fullscreen);
|
||||||
|
|
|
@ -870,7 +870,7 @@ static void render_floating_container(struct sway_output *soutput,
|
||||||
render_titlebar(soutput, damage, con, con->current.swayc_x,
|
render_titlebar(soutput, damage, con, con->current.swayc_x,
|
||||||
con->current.swayc_y, con->current.swayc_width, colors,
|
con->current.swayc_y, con->current.swayc_width, colors,
|
||||||
title_texture, marks_texture);
|
title_texture, marks_texture);
|
||||||
} else {
|
} else if (con->current.border != B_NONE) {
|
||||||
render_top_border(soutput, damage, con, colors);
|
render_top_border(soutput, damage, con, colors);
|
||||||
}
|
}
|
||||||
render_view(soutput, damage, con, colors);
|
render_view(soutput, damage, con, colors);
|
||||||
|
|
|
@ -108,6 +108,19 @@ static void set_activated(struct sway_view *view, bool activated) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_tiled(struct sway_view *view, bool tiled) {
|
||||||
|
if (xdg_shell_view_from_view(view) == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
|
||||||
|
enum wlr_edges edges = WLR_EDGE_NONE;
|
||||||
|
if (tiled) {
|
||||||
|
edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP |
|
||||||
|
WLR_EDGE_BOTTOM;
|
||||||
|
}
|
||||||
|
wlr_xdg_toplevel_set_tiled(surface, edges);
|
||||||
|
}
|
||||||
|
|
||||||
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
|
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
|
||||||
if (xdg_shell_view_from_view(view) == NULL) {
|
if (xdg_shell_view_from_view(view) == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -157,6 +170,7 @@ static const struct sway_view_impl view_impl = {
|
||||||
.get_string_prop = get_string_prop,
|
.get_string_prop = get_string_prop,
|
||||||
.configure = configure,
|
.configure = configure,
|
||||||
.set_activated = set_activated,
|
.set_activated = set_activated,
|
||||||
|
.set_tiled = set_tiled,
|
||||||
.set_fullscreen = set_fullscreen,
|
.set_fullscreen = set_fullscreen,
|
||||||
.wants_floating = wants_floating,
|
.wants_floating = wants_floating,
|
||||||
.for_each_surface = for_each_surface,
|
.for_each_surface = for_each_surface,
|
||||||
|
@ -288,8 +302,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
|
wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
|
||||||
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
||||||
wlr_xdg_surface_ping(xdg_surface);
|
wlr_xdg_surface_ping(xdg_surface);
|
||||||
wlr_xdg_toplevel_set_tiled(xdg_surface, WLR_EDGE_LEFT | WLR_EDGE_RIGHT |
|
|
||||||
WLR_EDGE_TOP | WLR_EDGE_BOTTOM);
|
|
||||||
|
|
||||||
struct sway_xdg_shell_view *xdg_shell_view =
|
struct sway_xdg_shell_view *xdg_shell_view =
|
||||||
calloc(1, sizeof(struct sway_xdg_shell_view));
|
calloc(1, sizeof(struct sway_xdg_shell_view));
|
||||||
|
|
|
@ -108,6 +108,14 @@ static void set_activated(struct sway_view *view, bool activated) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_tiled(struct sway_view *view, bool tiled) {
|
||||||
|
if (xdg_shell_v6_view_from_view(view) == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wlr_xdg_surface_v6 *surface = view->wlr_xdg_surface_v6;
|
||||||
|
wlr_xdg_toplevel_v6_set_maximized(surface, tiled);
|
||||||
|
}
|
||||||
|
|
||||||
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
|
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
|
||||||
if (xdg_shell_v6_view_from_view(view) == NULL) {
|
if (xdg_shell_v6_view_from_view(view) == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -158,6 +166,7 @@ static const struct sway_view_impl view_impl = {
|
||||||
.get_string_prop = get_string_prop,
|
.get_string_prop = get_string_prop,
|
||||||
.configure = configure,
|
.configure = configure,
|
||||||
.set_activated = set_activated,
|
.set_activated = set_activated,
|
||||||
|
.set_tiled = set_tiled,
|
||||||
.set_fullscreen = set_fullscreen,
|
.set_fullscreen = set_fullscreen,
|
||||||
.wants_floating = wants_floating,
|
.wants_floating = wants_floating,
|
||||||
.for_each_surface = for_each_surface,
|
.for_each_surface = for_each_surface,
|
||||||
|
@ -284,7 +293,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
wlr_log(L_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
|
wlr_log(L_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
|
||||||
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
||||||
wlr_xdg_surface_v6_ping(xdg_surface);
|
wlr_xdg_surface_v6_ping(xdg_surface);
|
||||||
wlr_xdg_toplevel_v6_set_maximized(xdg_surface, true);
|
|
||||||
|
|
||||||
struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
|
struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
|
||||||
calloc(1, sizeof(struct sway_xdg_shell_v6_view));
|
calloc(1, sizeof(struct sway_xdg_shell_v6_view));
|
||||||
|
|
|
@ -200,6 +200,14 @@ static void set_activated(struct sway_view *view, bool activated) {
|
||||||
wlr_xwayland_surface_activate(surface, activated);
|
wlr_xwayland_surface_activate(surface, activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_tiled(struct sway_view *view, bool tiled) {
|
||||||
|
if (xwayland_view_from_view(view) == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
|
||||||
|
wlr_xwayland_surface_set_maximized(surface, tiled);
|
||||||
|
}
|
||||||
|
|
||||||
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
|
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
|
||||||
if (xwayland_view_from_view(view) == NULL) {
|
if (xwayland_view_from_view(view) == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -258,6 +266,7 @@ static const struct sway_view_impl view_impl = {
|
||||||
.get_int_prop = get_int_prop,
|
.get_int_prop = get_int_prop,
|
||||||
.configure = configure,
|
.configure = configure,
|
||||||
.set_activated = set_activated,
|
.set_activated = set_activated,
|
||||||
|
.set_tiled = set_tiled,
|
||||||
.set_fullscreen = set_fullscreen,
|
.set_fullscreen = set_fullscreen,
|
||||||
.wants_floating = wants_floating,
|
.wants_floating = wants_floating,
|
||||||
.close = _close,
|
.close = _close,
|
||||||
|
@ -307,7 +316,6 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
xwayland_view->commit.notify = handle_commit;
|
xwayland_view->commit.notify = handle_commit;
|
||||||
|
|
||||||
// Put it back into the tree
|
// Put it back into the tree
|
||||||
wlr_xwayland_surface_set_maximized(xsurface, true);
|
|
||||||
view_map(view, xsurface->surface);
|
view_map(view, xsurface->surface);
|
||||||
|
|
||||||
if (xsurface->fullscreen) {
|
if (xsurface->fullscreen) {
|
||||||
|
|
|
@ -522,21 +522,11 @@ static struct sway_container *container_at_view(struct sway_container *swayc,
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
break;
|
break;
|
||||||
case SWAY_VIEW_XDG_SHELL_V6:
|
case SWAY_VIEW_XDG_SHELL_V6:
|
||||||
// the top left corner of the sway container is the
|
|
||||||
// coordinate of the top left corner of the window geometry
|
|
||||||
view_sx += sview->wlr_xdg_surface_v6->geometry.x;
|
|
||||||
view_sy += sview->wlr_xdg_surface_v6->geometry.y;
|
|
||||||
|
|
||||||
_surface = wlr_xdg_surface_v6_surface_at(
|
_surface = wlr_xdg_surface_v6_surface_at(
|
||||||
sview->wlr_xdg_surface_v6,
|
sview->wlr_xdg_surface_v6,
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
break;
|
break;
|
||||||
case SWAY_VIEW_XDG_SHELL:
|
case SWAY_VIEW_XDG_SHELL:
|
||||||
// the top left corner of the sway container is the
|
|
||||||
// coordinate of the top left corner of the window geometry
|
|
||||||
view_sx += sview->wlr_xdg_surface->geometry.x;
|
|
||||||
view_sy += sview->wlr_xdg_surface->geometry.y;
|
|
||||||
|
|
||||||
_surface = wlr_xdg_surface_surface_at(
|
_surface = wlr_xdg_surface_surface_at(
|
||||||
sview->wlr_xdg_surface,
|
sview->wlr_xdg_surface,
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
|
@ -954,6 +944,9 @@ void container_set_floating(struct sway_container *container, bool enable) {
|
||||||
container_add_child(workspace, container);
|
container_add_child(workspace, container);
|
||||||
container->width = container->parent->width;
|
container->width = container->parent->width;
|
||||||
container->height = container->parent->height;
|
container->height = container->parent->height;
|
||||||
|
if (container->type == C_VIEW) {
|
||||||
|
view_set_tiled(container->sway_view, true);
|
||||||
|
}
|
||||||
container->is_sticky = false;
|
container->is_sticky = false;
|
||||||
container_reap_empty_recursive(workspace->sway_workspace->floating);
|
container_reap_empty_recursive(workspace->sway_workspace->floating);
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,9 @@ void view_init_floating(struct sway_view *view) {
|
||||||
view->border_left = view->border_right = true;
|
view->border_left = view->border_right = true;
|
||||||
|
|
||||||
container_set_geometry_from_floating_view(view->swayc);
|
container_set_geometry_from_floating_view(view->swayc);
|
||||||
|
|
||||||
|
// Don't maximize floating windows
|
||||||
|
view_set_tiled(view, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_autoconfigure(struct sway_view *view) {
|
void view_autoconfigure(struct sway_view *view) {
|
||||||
|
@ -275,6 +278,7 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
view->y = y;
|
view->y = y;
|
||||||
view->width = width;
|
view->width = width;
|
||||||
view->height = height;
|
view->height = height;
|
||||||
|
view_set_tiled(view, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_set_activated(struct sway_view *view, bool activated) {
|
void view_set_activated(struct sway_view *view, bool activated) {
|
||||||
|
@ -283,6 +287,13 @@ void view_set_activated(struct sway_view *view, bool activated) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void view_set_tiled(struct sway_view *view, bool tiled) {
|
||||||
|
view->border = tiled ? config->border : B_NONE;
|
||||||
|
if (view->impl->set_tiled) {
|
||||||
|
view->impl->set_tiled(view, tiled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
|
void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
|
||||||
if (view->is_fullscreen == fullscreen) {
|
if (view->is_fullscreen == fullscreen) {
|
||||||
return;
|
return;
|
||||||
|
@ -948,7 +959,7 @@ bool view_is_visible(struct sway_view *view) {
|
||||||
// Check view isn't in a tabbed or stacked container on an inactive tab
|
// Check view isn't in a tabbed or stacked container on an inactive tab
|
||||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
struct sway_container *container = view->swayc;
|
struct sway_container *container = view->swayc;
|
||||||
while (container->type != C_WORKSPACE) {
|
while (container->type != C_WORKSPACE && container->layout != L_FLOATING) {
|
||||||
if (container->parent->layout == L_TABBED ||
|
if (container->parent->layout == L_TABBED ||
|
||||||
container->parent->layout == L_STACKED) {
|
container->parent->layout == L_STACKED) {
|
||||||
if (seat_get_active_child(seat, container->parent) != container) {
|
if (seat_get_active_child(seat, container->parent) != container) {
|
||||||
|
|
|
@ -19,30 +19,40 @@ void sway_terminate(int exit_code) {
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool success_object(json_object *result) {
|
||||||
|
json_object *success;
|
||||||
|
|
||||||
|
if (!json_object_object_get_ex(result, "success", &success)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_object_get_boolean(success);
|
||||||
|
}
|
||||||
|
|
||||||
// Iterate results array and return false if any of them failed
|
// Iterate results array and return false if any of them failed
|
||||||
static bool success(json_object *r, bool fallback) {
|
static bool success(json_object *r, bool fallback) {
|
||||||
if (!json_object_is_type(r, json_type_array)) {
|
if (!json_object_is_type(r, json_type_array)) {
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t results_len = json_object_array_length(r);
|
size_t results_len = json_object_array_length(r);
|
||||||
if (!results_len) {
|
if (!results_len) {
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < results_len; ++i) {
|
for (size_t i = 0; i < results_len; ++i) {
|
||||||
json_object *result = json_object_array_get_idx(r, i);
|
json_object *result = json_object_array_get_idx(r, i);
|
||||||
json_object *success;
|
|
||||||
if (!json_object_object_get_ex(result, "success", &success)) {
|
if (!success_object(result)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!json_object_get_boolean(success)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pretty_print_cmd(json_object *r) {
|
static void pretty_print_cmd(json_object *r) {
|
||||||
if (!success(r, true)) {
|
if (!success_object(r)) {
|
||||||
json_object *error;
|
json_object *error;
|
||||||
if (!json_object_object_get_ex(r, "error", &error)) {
|
if (!json_object_object_get_ex(r, "error", &error)) {
|
||||||
printf("An unknkown error occurred");
|
printf("An unknkown error occurred");
|
||||||
|
@ -402,6 +412,7 @@ int main(int argc, char **argv) {
|
||||||
} else {
|
} else {
|
||||||
sway_abort("Unknown message type %s", cmdtype);
|
sway_abort("Unknown message type %s", cmdtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(cmdtype);
|
free(cmdtype);
|
||||||
|
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
|
|
Loading…
Reference in a new issue