|
|
@ -67,36 +67,43 @@ void view_close(struct roots_view *view) {
|
|
|
|
bool view_center(struct roots_view *view) {
|
|
|
|
bool view_center(struct roots_view *view) {
|
|
|
|
struct wlr_box size;
|
|
|
|
struct wlr_box size;
|
|
|
|
view_get_size(view, &size);
|
|
|
|
view_get_size(view, &size);
|
|
|
|
if (size.width == 0 && size.height == 0) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct roots_desktop *desktop = view->desktop;
|
|
|
|
struct roots_desktop *desktop = view->desktop;
|
|
|
|
struct wlr_cursor *cursor = desktop->server->input->cursor;
|
|
|
|
struct wlr_cursor *cursor = desktop->server->input->cursor;
|
|
|
|
struct wlr_output *output = wlr_output_layout_output_at(desktop->layout,
|
|
|
|
|
|
|
|
cursor->x, cursor->y);
|
|
|
|
struct wlr_output *output =
|
|
|
|
const struct wlr_output_layout_output *output_layout =
|
|
|
|
wlr_output_layout_output_at(desktop->layout, cursor->x, cursor->y);
|
|
|
|
wlr_output_layout_get(desktop->layout, output);
|
|
|
|
|
|
|
|
|
|
|
|
if (!output) {
|
|
|
|
|
|
|
|
output = wlr_output_layout_get_center_output(desktop->layout);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!output) {
|
|
|
|
if (!output) {
|
|
|
|
|
|
|
|
// empty layout
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
view->x = (double)(output->width - size.width) / 2
|
|
|
|
const struct wlr_output_layout_output *l_output =
|
|
|
|
+ output_layout->x;
|
|
|
|
wlr_output_layout_get(desktop->layout, output);
|
|
|
|
view->y = (double)(output->height - size.height) / 2
|
|
|
|
|
|
|
|
+ output_layout->y;
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
wlr_output_effective_resolution(output, &width, &height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view->x = (double)(width - size.width) / 2
|
|
|
|
|
|
|
|
+ l_output->x;
|
|
|
|
|
|
|
|
view->y = (double)(height - size.height) / 2
|
|
|
|
|
|
|
|
+ l_output->y;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool view_initialize(struct roots_view *view) {
|
|
|
|
void view_initialize(struct roots_view *view) {
|
|
|
|
bool centered = view_center(view);
|
|
|
|
view_center(view);
|
|
|
|
if (centered) {
|
|
|
|
|
|
|
|
struct roots_input *input = view->desktop->server->input;
|
|
|
|
struct roots_input *input = view->desktop->server->input;
|
|
|
|
|
|
|
|
|
|
|
|
set_view_focus(input, view->desktop, view);
|
|
|
|
set_view_focus(input, view->desktop, view);
|
|
|
|
wlr_seat_keyboard_notify_enter(input->wl_seat, view->wlr_surface);
|
|
|
|
wlr_seat_keyboard_notify_enter(input->wl_seat, view->wlr_surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return centered;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
|
|
|
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
|
|
|
struct wlr_surface **surface, double *sx, double *sy) {
|
|
|
|
struct wlr_surface **surface, double *sx, double *sy) {
|
|
|
|