Add fullscreen command, fix view_at with fullscreen views
This commit is contained in:
parent
9e29621ec3
commit
9a6f799d8f
|
@ -60,11 +60,13 @@ struct roots_server;
|
||||||
struct roots_desktop *desktop_create(struct roots_server *server,
|
struct roots_desktop *desktop_create(struct roots_server *server,
|
||||||
struct roots_config *config);
|
struct roots_config *config);
|
||||||
void desktop_destroy(struct roots_desktop *desktop);
|
void desktop_destroy(struct roots_desktop *desktop);
|
||||||
|
struct roots_output *desktop_output_from_wlr_output(
|
||||||
|
struct roots_desktop *desktop, struct wlr_output *output);
|
||||||
|
struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
|
||||||
|
double ly, struct wlr_surface **surface, double *sx, double *sy);
|
||||||
|
|
||||||
void view_init(struct roots_view *view, struct roots_desktop *desktop);
|
void view_init(struct roots_view *view, struct roots_desktop *desktop);
|
||||||
void view_destroy(struct roots_view *view);
|
void view_destroy(struct roots_view *view);
|
||||||
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
|
||||||
struct wlr_surface **surface, double *sx, double *sy);
|
|
||||||
void view_activate(struct roots_view *view, bool activate);
|
void view_activate(struct roots_view *view, bool activate);
|
||||||
|
|
||||||
void output_add_notify(struct wl_listener *listener, void *data);
|
void output_add_notify(struct wl_listener *listener, void *data);
|
||||||
|
|
|
@ -37,7 +37,7 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
switch (cursor->mode) {
|
switch (cursor->mode) {
|
||||||
case ROOTS_CURSOR_PASSTHROUGH:
|
case ROOTS_CURSOR_PASSTHROUGH:
|
||||||
view = view_at(desktop, cursor->cursor->x, cursor->cursor->y,
|
view = desktop_view_at(desktop, cursor->cursor->x, cursor->cursor->y,
|
||||||
&surface, &sx, &sy);
|
&surface, &sx, &sy);
|
||||||
bool set_compositor_cursor = !view && cursor->cursor_client;
|
bool set_compositor_cursor = !view && cursor->cursor_client;
|
||||||
if (view) {
|
if (view) {
|
||||||
|
@ -137,7 +137,8 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
|
||||||
|
|
||||||
struct wlr_surface *surface;
|
struct wlr_surface *surface;
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
struct roots_view *view = view_at(desktop, lx, ly, &surface, &sx, &sy);
|
struct roots_view *view =
|
||||||
|
desktop_view_at(desktop, lx, ly, &surface, &sx, &sy);
|
||||||
|
|
||||||
if (state == WLR_BUTTON_PRESSED &&
|
if (state == WLR_BUTTON_PRESSED &&
|
||||||
view &&
|
view &&
|
||||||
|
@ -237,7 +238,7 @@ void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
view_at(desktop, lx, ly, &surface, &sx, &sy);
|
desktop_view_at(desktop, lx, ly, &surface, &sx, &sy);
|
||||||
|
|
||||||
uint32_t serial = 0;
|
uint32_t serial = 0;
|
||||||
if (surface) {
|
if (surface) {
|
||||||
|
@ -291,7 +292,7 @@ void roots_cursor_handle_touch_motion(struct roots_cursor *cursor,
|
||||||
}
|
}
|
||||||
|
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
view_at(desktop, lx, ly, &surface, &sx, &sy);
|
desktop_view_at(desktop, lx, ly, &surface, &sx, &sy);
|
||||||
|
|
||||||
if (surface) {
|
if (surface) {
|
||||||
wlr_seat_touch_point_focus(cursor->seat->seat, surface,
|
wlr_seat_touch_point_focus(cursor->seat->seat, surface,
|
||||||
|
|
|
@ -163,6 +163,11 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen,
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
output = view_get_output(view);
|
output = view_get_output(view);
|
||||||
}
|
}
|
||||||
|
struct roots_output *roots_output =
|
||||||
|
desktop_output_from_wlr_output(view->desktop, output);
|
||||||
|
if (roots_output == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_box view_box;
|
struct wlr_box view_box;
|
||||||
view_get_box(view, &view_box);
|
view_get_box(view, &view_box);
|
||||||
|
@ -179,14 +184,8 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen,
|
||||||
output_box->height);
|
output_box->height);
|
||||||
view->rotation = 0;
|
view->rotation = 0;
|
||||||
|
|
||||||
struct roots_output *roots_output;
|
|
||||||
wl_list_for_each(roots_output, &view->desktop->outputs, link) {
|
|
||||||
if (roots_output->wlr_output == output) {
|
|
||||||
roots_output->fullscreen_view = view;
|
roots_output->fullscreen_view = view;
|
||||||
view->fullscreen_output = roots_output;
|
view->fullscreen_output = roots_output;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (was_fullscreen && !fullscreen) {
|
if (was_fullscreen && !fullscreen) {
|
||||||
|
@ -273,14 +272,11 @@ void view_setup(struct roots_view *view) {
|
||||||
view_update_output(view, &before);
|
view_update_output(view, &before);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
static bool view_at(struct roots_view *view, double lx, double ly,
|
||||||
struct wlr_surface **surface, double *sx, double *sy) {
|
struct wlr_surface **surface, double *sx, double *sy) {
|
||||||
struct roots_view *view;
|
|
||||||
wl_list_for_each(view, &desktop->views, link) {
|
|
||||||
if (view->type == ROOTS_WL_SHELL_VIEW &&
|
if (view->type == ROOTS_WL_SHELL_VIEW &&
|
||||||
view->wl_shell_surface->state ==
|
view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
|
||||||
WLR_WL_SHELL_SURFACE_STATE_POPUP) {
|
return false;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double view_sx = lx - view->x;
|
double view_sx = lx - view->x;
|
||||||
|
@ -314,7 +310,7 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
||||||
*sx = view_sx - popup_sx;
|
*sx = view_sx - popup_sx;
|
||||||
*sy = view_sy - popup_sy;
|
*sy = view_sy - popup_sy;
|
||||||
*surface = popup->surface;
|
*surface = popup->surface;
|
||||||
return view;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +324,7 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
||||||
*sx = view_sx - popup_sx;
|
*sx = view_sx - popup_sx;
|
||||||
*sy = view_sy - popup_sy;
|
*sy = view_sy - popup_sy;
|
||||||
*surface = popup->surface;
|
*surface = popup->surface;
|
||||||
return view;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,16 +336,40 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
||||||
*sx = view_sx - sub_x;
|
*sx = view_sx - sub_x;
|
||||||
*sy = view_sy - sub_y;
|
*sy = view_sy - sub_y;
|
||||||
*surface = subsurface->surface;
|
*surface = subsurface->surface;
|
||||||
return view;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wlr_box_contains_point(&box, view_sx, view_sy) &&
|
if (wlr_box_contains_point(&box, view_sx, view_sy) &&
|
||||||
pixman_region32_contains_point(
|
pixman_region32_contains_point(&view->wlr_surface->current->input,
|
||||||
&view->wlr_surface->current->input,
|
|
||||||
view_sx, view_sy, NULL)) {
|
view_sx, view_sy, NULL)) {
|
||||||
*sx = view_sx;
|
*sx = view_sx;
|
||||||
*sy = view_sy;
|
*sy = view_sy;
|
||||||
*surface = view->wlr_surface;
|
*surface = view->wlr_surface;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
|
||||||
|
double ly, struct wlr_surface **surface, double *sx, double *sy) {
|
||||||
|
struct wlr_output *wlr_output =
|
||||||
|
wlr_output_layout_output_at(desktop->layout, lx, ly);
|
||||||
|
if (wlr_output != NULL) {
|
||||||
|
struct roots_output *output =
|
||||||
|
desktop_output_from_wlr_output(desktop, wlr_output);
|
||||||
|
if (output != NULL && output->fullscreen_view != NULL) {
|
||||||
|
if (view_at(output->fullscreen_view, lx, ly, surface, sx, sy)) {
|
||||||
|
return output->fullscreen_view;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct roots_view *view;
|
||||||
|
wl_list_for_each(view, &desktop->views, link) {
|
||||||
|
if (view_at(view, lx, ly, surface, sx, sy)) {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -445,3 +465,14 @@ struct roots_desktop *desktop_create(struct roots_server *server,
|
||||||
void desktop_destroy(struct roots_desktop *desktop) {
|
void desktop_destroy(struct roots_desktop *desktop) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct roots_output *desktop_output_from_wlr_output(
|
||||||
|
struct roots_desktop *desktop, struct wlr_output *output) {
|
||||||
|
struct roots_output *roots_output;
|
||||||
|
wl_list_for_each(roots_output, &desktop->outputs, link) {
|
||||||
|
if (roots_output->wlr_output == output) {
|
||||||
|
return roots_output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -95,6 +95,12 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
||||||
if (focus != NULL) {
|
if (focus != NULL) {
|
||||||
view_close(focus);
|
view_close(focus);
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(command, "fullscreen") == 0) {
|
||||||
|
struct roots_view *focus = roots_seat_get_focus(seat);
|
||||||
|
if (focus != NULL) {
|
||||||
|
bool is_fullscreen = focus->fullscreen_output != NULL;
|
||||||
|
view_set_fullscreen(focus, !is_fullscreen, NULL);
|
||||||
|
}
|
||||||
} else if (strcmp(command, "next_window") == 0) {
|
} else if (strcmp(command, "next_window") == 0) {
|
||||||
roots_seat_cycle_focus(seat);
|
roots_seat_cycle_focus(seat);
|
||||||
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
|
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
|
||||||
|
|
Loading…
Reference in New Issue