|
|
@ -62,55 +62,10 @@ const char *view_get_instance(struct sway_view *view) {
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void view_update_outputs(struct sway_view *view,
|
|
|
|
void view_configure(struct sway_view *view, double ox, double oy, int width,
|
|
|
|
const struct wlr_box *before) {
|
|
|
|
int height) {
|
|
|
|
struct wlr_output_layout *output_layout =
|
|
|
|
if (view->impl->configure) {
|
|
|
|
root_container.sway_root->output_layout;
|
|
|
|
view->impl->configure(view, ox, oy, width, height);
|
|
|
|
struct wlr_box box = {
|
|
|
|
|
|
|
|
.x = view->swayc->x,
|
|
|
|
|
|
|
|
.y = view->swayc->y,
|
|
|
|
|
|
|
|
.width = view->width,
|
|
|
|
|
|
|
|
.height = view->height,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_output_layout_output *layout_output;
|
|
|
|
|
|
|
|
wl_list_for_each(layout_output, &output_layout->outputs, link) {
|
|
|
|
|
|
|
|
bool intersected = before != NULL && wlr_output_layout_intersects(
|
|
|
|
|
|
|
|
output_layout, layout_output->output, before);
|
|
|
|
|
|
|
|
bool intersects = wlr_output_layout_intersects(output_layout,
|
|
|
|
|
|
|
|
layout_output->output, &box);
|
|
|
|
|
|
|
|
if (intersected && !intersects) {
|
|
|
|
|
|
|
|
wlr_surface_send_leave(view->surface, layout_output->output);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!intersected && intersects) {
|
|
|
|
|
|
|
|
wlr_surface_send_enter(view->surface, layout_output->output);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void view_set_size(struct sway_view *view, int width, int height) {
|
|
|
|
|
|
|
|
if (view->impl->set_size) {
|
|
|
|
|
|
|
|
struct wlr_box box = {
|
|
|
|
|
|
|
|
.x = view->swayc->x,
|
|
|
|
|
|
|
|
.y = view->swayc->y,
|
|
|
|
|
|
|
|
.width = view->width,
|
|
|
|
|
|
|
|
.height = view->height,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
view->impl->set_size(view, width, height);
|
|
|
|
|
|
|
|
view_update_outputs(view, &box);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO make view coordinates in layout coordinates
|
|
|
|
|
|
|
|
void view_set_position(struct sway_view *view, double ox, double oy) {
|
|
|
|
|
|
|
|
if (view->impl->set_position) {
|
|
|
|
|
|
|
|
struct wlr_box box = {
|
|
|
|
|
|
|
|
.x = view->swayc->x,
|
|
|
|
|
|
|
|
.y = view->swayc->y,
|
|
|
|
|
|
|
|
.width = view->width,
|
|
|
|
|
|
|
|
.height = view->height,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
view->impl->set_position(view, ox, oy);
|
|
|
|
|
|
|
|
view_update_outputs(view, &box);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -136,6 +91,56 @@ struct sway_container *container_view_destroy(struct sway_container *view) {
|
|
|
|
return parent;
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void view_damage_whole(struct sway_view *view) {
|
|
|
|
|
|
|
|
for (int i = 0; i < root_container.children->length; ++i) {
|
|
|
|
|
|
|
|
struct sway_container *cont = root_container.children->items[i];
|
|
|
|
|
|
|
|
if (cont->type == C_OUTPUT) {
|
|
|
|
|
|
|
|
output_damage_whole_view(cont->sway_output, view);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void view_damage_from(struct sway_view *view) {
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
view_damage_whole(view);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) {
|
|
|
|
|
|
|
|
struct sway_container *cont = container_parent(view->swayc, C_OUTPUT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_output_layout *output_layout =
|
|
|
|
|
|
|
|
root_container.sway_root->output_layout;
|
|
|
|
|
|
|
|
struct wlr_box *output_box = wlr_output_layout_get_box(output_layout,
|
|
|
|
|
|
|
|
cont->sway_output->wlr_output);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
box->x = output_box->x + view->swayc->x;
|
|
|
|
|
|
|
|
box->y = output_box->y + view->swayc->y;
|
|
|
|
|
|
|
|
box->width = view->width;
|
|
|
|
|
|
|
|
box->height = view->height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void view_update_outputs(struct sway_view *view,
|
|
|
|
|
|
|
|
const struct wlr_box *before) {
|
|
|
|
|
|
|
|
struct wlr_box box;
|
|
|
|
|
|
|
|
view_get_layout_box(view, &box);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_output_layout *output_layout =
|
|
|
|
|
|
|
|
root_container.sway_root->output_layout;
|
|
|
|
|
|
|
|
struct wlr_output_layout_output *layout_output;
|
|
|
|
|
|
|
|
wl_list_for_each(layout_output, &output_layout->outputs, link) {
|
|
|
|
|
|
|
|
bool intersected = before != NULL && wlr_output_layout_intersects(
|
|
|
|
|
|
|
|
output_layout, layout_output->output, before);
|
|
|
|
|
|
|
|
bool intersects = wlr_output_layout_intersects(output_layout,
|
|
|
|
|
|
|
|
layout_output->output, &box);
|
|
|
|
|
|
|
|
if (intersected && !intersects) {
|
|
|
|
|
|
|
|
wlr_surface_send_leave(view->surface, layout_output->output);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!intersected && intersects) {
|
|
|
|
|
|
|
|
wlr_surface_send_enter(view->surface, layout_output->output);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
|
|
|
|
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
|
|
|
|
if (!sway_assert(view->surface == NULL, "cannot map mapped view")) {
|
|
|
|
if (!sway_assert(view->surface == NULL, "cannot map mapped view")) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -153,6 +158,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
|
|
|
|
sway_input_manager_set_focus(input_manager, cont);
|
|
|
|
sway_input_manager_set_focus(input_manager, cont);
|
|
|
|
|
|
|
|
|
|
|
|
view_damage_whole(view);
|
|
|
|
view_damage_whole(view);
|
|
|
|
|
|
|
|
view_update_outputs(view, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void view_map_unmanaged(struct sway_view *view,
|
|
|
|
void view_map_unmanaged(struct sway_view *view,
|
|
|
@ -168,6 +174,8 @@ void view_map_unmanaged(struct sway_view *view,
|
|
|
|
&view->unmanaged_view_link);
|
|
|
|
&view->unmanaged_view_link);
|
|
|
|
|
|
|
|
|
|
|
|
view_damage_whole(view);
|
|
|
|
view_damage_whole(view);
|
|
|
|
|
|
|
|
// TODO: make this work for unmanaged views
|
|
|
|
|
|
|
|
//view_update_outputs(view, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void view_unmap(struct sway_view *view) {
|
|
|
|
void view_unmap(struct sway_view *view) {
|
|
|
@ -186,17 +194,30 @@ void view_unmap(struct sway_view *view) {
|
|
|
|
view->surface = NULL;
|
|
|
|
view->surface = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void view_damage_whole(struct sway_view *view) {
|
|
|
|
void view_update_position(struct sway_view *view, double ox, double oy) {
|
|
|
|
struct sway_container *cont = NULL;
|
|
|
|
if (view->swayc->x == ox && view->swayc->y == oy) {
|
|
|
|
for (int i = 0; i < root_container.children->length; ++i) {
|
|
|
|
return;
|
|
|
|
cont = root_container.children->items[i];
|
|
|
|
|
|
|
|
if (cont->type == C_OUTPUT) {
|
|
|
|
|
|
|
|
output_damage_whole_view(cont->sway_output, view);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_box box;
|
|
|
|
|
|
|
|
view_get_layout_box(view, &box);
|
|
|
|
|
|
|
|
view_damage_whole(view);
|
|
|
|
|
|
|
|
view->swayc->x = ox;
|
|
|
|
|
|
|
|
view->swayc->y = oy;
|
|
|
|
|
|
|
|
view_update_outputs(view, &box);
|
|
|
|
|
|
|
|
view_damage_whole(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void view_update_size(struct sway_view *view, int width, int height) {
|
|
|
|
|
|
|
|
if (view->width == width && view->height == height) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void view_damage_from(struct sway_view *view) {
|
|
|
|
struct wlr_box box;
|
|
|
|
// TODO
|
|
|
|
view_get_layout_box(view, &box);
|
|
|
|
|
|
|
|
view_damage_whole(view);
|
|
|
|
|
|
|
|
view->width = width;
|
|
|
|
|
|
|
|
view->height = height;
|
|
|
|
|
|
|
|
view_update_outputs(view, &box);
|
|
|
|
view_damage_whole(view);
|
|
|
|
view_damage_whole(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|