labwc/src/view.c

101 lines
2.1 KiB
C
Raw Normal View History

2019-12-26 21:37:31 +00:00
#include "labwc.h"
#include <stdio.h>
void
2020-12-22 20:35:06 +00:00
view_move_resize(struct view *view, struct wlr_box geo)
{
2020-12-22 20:35:06 +00:00
view->impl->configure(view, geo);
}
2020-12-23 18:52:46 +00:00
void
view_move(struct view *view, double x, double y)
{
view->impl->move(view, x, y);
}
void
view_minimize(struct view *view)
2020-09-08 20:51:33 +01:00
{
if (view->minimized == true) {
2020-09-08 20:51:33 +01:00
return;
}
2020-09-08 20:51:33 +01:00
view->minimized = true;
view->impl->unmap(view);
}
void
view_unminimize(struct view *view)
2020-09-08 20:51:33 +01:00
{
if (view->minimized == false) {
2020-09-08 20:51:33 +01:00
return;
}
2020-09-08 20:51:33 +01:00
view->minimized = false;
view->impl->map(view);
}
2020-09-29 20:48:50 +01:00
void
view_maximize(struct view *view, bool maximize)
{
2021-03-12 21:27:17 +00:00
if (view->maximized == maximize) {
return;
}
view->impl->maximize(view, maximize);
if (maximize) {
struct wlr_output_layout *layout = view->server->output_layout;
struct wlr_output* output = wlr_output_layout_output_at(
layout, view->x + view->w / 2, view->y + view->h / 2);
if (!output) {
return;
}
struct wlr_output_layout_output* ol_output =
wlr_output_layout_get(layout, output);
2021-02-28 18:12:10 +00:00
view->unmaximized_geometry.x = view->x;
view->unmaximized_geometry.y = view->y;
view->unmaximized_geometry.width = view->w;
view->unmaximized_geometry.height = view->h;
struct wlr_box box = {
2021-03-01 18:15:02 +00:00
.x = ol_output->x,
.y = ol_output->y,
.width = output->width,
.height = output->height,
};
2021-03-01 18:15:02 +00:00
if (view->server_side_deco) {
struct border border = deco_thickness(view);
box.x += border.left;
box.y += border.top;
box.width -= border.right + border.left;
box.height -= border.top + border.bottom;
}
scale_box(&box, output->scale);
view_move_resize(view, box);
2021-03-01 18:15:02 +00:00
view_move(view, box.x, box.y);
view->maximized = true;
2021-02-28 18:12:10 +00:00
} else {
/* unmaximize */
view_move_resize(view, view->unmaximized_geometry);
view->maximized = false;
}
}
2020-09-29 20:48:50 +01:00
void
view_for_each_surface(struct view *view, wlr_surface_iterator_func_t iterator,
void *user_data)
{
view->impl->for_each_surface(view, iterator, user_data);
}
2021-01-09 22:51:20 +00:00
void
view_for_each_popup(struct view *view, wlr_surface_iterator_func_t iterator,
void *data)
{
if (!view->impl->for_each_popup) {
return;
}
view->impl->for_each_popup(view, iterator, data);
}