Initial fullscreen support
This commit is contained in:
parent
c3e0fbdb8f
commit
b04a9a248d
|
@ -13,6 +13,7 @@ struct roots_wl_shell_surface {
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
struct wl_listener request_set_maximized;
|
struct wl_listener request_set_maximized;
|
||||||
|
struct wl_listener request_set_fullscreen;
|
||||||
struct wl_listener set_state;
|
struct wl_listener set_state;
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
struct wl_listener surface_commit;
|
||||||
|
@ -26,6 +27,7 @@ struct roots_xdg_surface_v6 {
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
struct wl_listener request_maximize;
|
struct wl_listener request_maximize;
|
||||||
|
struct wl_listener request_fullscreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct roots_xwayland_surface {
|
struct roots_xwayland_surface {
|
||||||
|
@ -54,6 +56,7 @@ struct roots_view {
|
||||||
float rotation;
|
float rotation;
|
||||||
|
|
||||||
bool maximized;
|
bool maximized;
|
||||||
|
struct wlr_output *fullscreen_output;
|
||||||
struct {
|
struct {
|
||||||
double x, y;
|
double x, y;
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
|
@ -93,6 +96,7 @@ struct roots_view {
|
||||||
void (*move_resize)(struct roots_view *view, double x, double y,
|
void (*move_resize)(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
void (*maximize)(struct roots_view *view, bool maximized);
|
void (*maximize)(struct roots_view *view, bool maximized);
|
||||||
|
void (*set_fullscreen)(struct roots_view *view, bool fullscreen);
|
||||||
void (*close)(struct roots_view *view);
|
void (*close)(struct roots_view *view);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,6 +107,8 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
|
||||||
void view_move_resize(struct roots_view *view, double x, double y,
|
void view_move_resize(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
void view_maximize(struct roots_view *view, bool maximized);
|
void view_maximize(struct roots_view *view, bool maximized);
|
||||||
|
void view_set_fullscreen(struct roots_view *view, bool fullscreen,
|
||||||
|
struct wlr_output *output);
|
||||||
void view_close(struct roots_view *view);
|
void view_close(struct roots_view *view);
|
||||||
bool view_center(struct roots_view *view);
|
bool view_center(struct roots_view *view);
|
||||||
void view_setup(struct roots_view *view);
|
void view_setup(struct roots_view *view);
|
||||||
|
|
|
@ -64,6 +64,10 @@ struct wlr_output {
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
|
struct wlr_surface *fullscreen_surface;
|
||||||
|
struct wl_listener fullscreen_surface_commit;
|
||||||
|
struct wl_listener fullscreen_surface_destroy;
|
||||||
|
|
||||||
struct wl_list cursors; // wlr_output_cursor::link
|
struct wl_list cursors; // wlr_output_cursor::link
|
||||||
struct wlr_output_cursor *hardware_cursor;
|
struct wlr_output_cursor *hardware_cursor;
|
||||||
|
|
||||||
|
@ -89,6 +93,8 @@ void wlr_output_swap_buffers(struct wlr_output *output);
|
||||||
void wlr_output_set_gamma(struct wlr_output *output,
|
void wlr_output_set_gamma(struct wlr_output *output,
|
||||||
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
|
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
|
||||||
uint32_t wlr_output_get_gamma_size(struct wlr_output *output);
|
uint32_t wlr_output_get_gamma_size(struct wlr_output *output);
|
||||||
|
void wlr_output_set_fullscreen_surface(struct wlr_output *output,
|
||||||
|
struct wlr_surface *surface);
|
||||||
|
|
||||||
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output);
|
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output);
|
||||||
bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
|
bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
|
||||||
|
|
|
@ -152,6 +152,13 @@ struct wlr_xdg_toplevel_v6_resize_event {
|
||||||
uint32_t edges;
|
uint32_t edges;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wlr_xdg_toplevel_v6_set_fullscreen_event {
|
||||||
|
struct wl_client *client;
|
||||||
|
struct wlr_xdg_surface_v6 *surface;
|
||||||
|
bool fullscreen;
|
||||||
|
struct wlr_output *output;
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_xdg_toplevel_v6_show_window_menu_event {
|
struct wlr_xdg_toplevel_v6_show_window_menu_event {
|
||||||
struct wl_client *client;
|
struct wl_client *client;
|
||||||
struct wlr_xdg_surface_v6 *surface;
|
struct wlr_xdg_surface_v6 *surface;
|
||||||
|
|
|
@ -89,6 +89,19 @@ void view_move_resize(struct roots_view *view, double x, double y,
|
||||||
view_resize(view, width, height);
|
view_resize(view, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct wlr_output *view_get_output(struct roots_view *view) {
|
||||||
|
struct wlr_box view_box;
|
||||||
|
view_get_box(view, &view_box);
|
||||||
|
|
||||||
|
double output_x, output_y;
|
||||||
|
wlr_output_layout_closest_point(view->desktop->layout, NULL,
|
||||||
|
view->x + (double)view_box.width/2,
|
||||||
|
view->y + (double)view_box.height/2,
|
||||||
|
&output_x, &output_y);
|
||||||
|
return wlr_output_layout_output_at(view->desktop->layout, output_x,
|
||||||
|
output_y);
|
||||||
|
}
|
||||||
|
|
||||||
void view_maximize(struct roots_view *view, bool maximized) {
|
void view_maximize(struct roots_view *view, bool maximized) {
|
||||||
if (view->maximized == maximized) {
|
if (view->maximized == maximized) {
|
||||||
return;
|
return;
|
||||||
|
@ -109,13 +122,7 @@ void view_maximize(struct roots_view *view, bool maximized) {
|
||||||
view->saved.width = view_box.width;
|
view->saved.width = view_box.width;
|
||||||
view->saved.height = view_box.height;
|
view->saved.height = view_box.height;
|
||||||
|
|
||||||
double output_x, output_y;
|
struct wlr_output *output = view_get_output(view);
|
||||||
wlr_output_layout_closest_point(view->desktop->layout, NULL,
|
|
||||||
view->x + (double)view_box.width/2,
|
|
||||||
view->y + (double)view_box.height/2,
|
|
||||||
&output_x, &output_y);
|
|
||||||
struct wlr_output *output = wlr_output_layout_output_at(
|
|
||||||
view->desktop->layout, output_x, output_y);
|
|
||||||
struct wlr_box *output_box =
|
struct wlr_box *output_box =
|
||||||
wlr_output_layout_get_box(view->desktop->layout, output);
|
wlr_output_layout_get_box(view->desktop->layout, output);
|
||||||
|
|
||||||
|
@ -133,6 +140,54 @@ void view_maximize(struct roots_view *view, bool maximized) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void view_set_fullscreen(struct roots_view *view, bool fullscreen,
|
||||||
|
struct wlr_output *output) {
|
||||||
|
bool was_fullscreen = view->fullscreen_output != NULL;
|
||||||
|
if (was_fullscreen == fullscreen) {
|
||||||
|
// TODO: support changing the output?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: check if client is focused?
|
||||||
|
|
||||||
|
if (view->set_fullscreen) {
|
||||||
|
view->set_fullscreen(view, fullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!was_fullscreen && fullscreen) {
|
||||||
|
if (output == NULL) {
|
||||||
|
output = view_get_output(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_box view_box;
|
||||||
|
view_get_box(view, &view_box);
|
||||||
|
|
||||||
|
view->saved.x = view->x;
|
||||||
|
view->saved.y = view->y;
|
||||||
|
view->saved.rotation = view->rotation;
|
||||||
|
view->saved.width = view_box.width;
|
||||||
|
view->saved.height = view_box.height;
|
||||||
|
|
||||||
|
struct wlr_box *output_box =
|
||||||
|
wlr_output_layout_get_box(view->desktop->layout, output);
|
||||||
|
view_move_resize(view, output_box->x, output_box->y, output_box->width,
|
||||||
|
output_box->height);
|
||||||
|
view->rotation = 0;
|
||||||
|
|
||||||
|
wlr_output_set_fullscreen_surface(output, view->wlr_surface);
|
||||||
|
view->fullscreen_output = output;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (was_fullscreen && !fullscreen) {
|
||||||
|
view_move_resize(view, view->saved.x, view->saved.y, view->saved.width,
|
||||||
|
view->saved.height);
|
||||||
|
view->rotation = view->saved.rotation;
|
||||||
|
|
||||||
|
wlr_output_set_fullscreen_surface(view->fullscreen_output, NULL);
|
||||||
|
view->fullscreen_output = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void view_close(struct roots_view *view) {
|
void view_close(struct roots_view *view) {
|
||||||
if (view->close) {
|
if (view->close) {
|
||||||
view->close(view);
|
view->close(view);
|
||||||
|
|
|
@ -186,6 +186,13 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_output_make_current(wlr_output);
|
wlr_output_make_current(wlr_output);
|
||||||
wlr_renderer_begin(server->renderer, wlr_output);
|
wlr_renderer_begin(server->renderer, wlr_output);
|
||||||
|
|
||||||
|
if (wlr_output->fullscreen_surface != NULL) {
|
||||||
|
wlr_renderer_end(server->renderer);
|
||||||
|
wlr_output_swap_buffers(wlr_output);
|
||||||
|
output->last_frame = desktop->last_frame = now;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct roots_view *view;
|
struct roots_view *view;
|
||||||
wl_list_for_each_reverse(view, &desktop->views, link) {
|
wl_list_for_each_reverse(view, &desktop->views, link) {
|
||||||
render_view(view, desktop, wlr_output, &now);
|
render_view(view, desktop, wlr_output, &now);
|
||||||
|
|
|
@ -59,6 +59,17 @@ static void handle_request_set_maximized(struct wl_listener *listener,
|
||||||
view_maximize(view, true);
|
view_maximize(view, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_set_fullscreen(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, request_set_fullscreen);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
struct wlr_wl_shell_surface_set_fullscreen_event *e = data;
|
||||||
|
|
||||||
|
// TODO: support e->method, e->framerate
|
||||||
|
view_set_fullscreen(view, true, e->output);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_set_state(struct wl_listener *listener, void *data) {
|
static void handle_set_state(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, set_state);
|
wl_container_of(listener, roots_surface, set_state);
|
||||||
|
@ -68,6 +79,10 @@ static void handle_set_state(struct wl_listener *listener, void *data) {
|
||||||
surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) {
|
surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) {
|
||||||
view_maximize(view, false);
|
view_maximize(view, false);
|
||||||
}
|
}
|
||||||
|
if (view->fullscreen_output != NULL &&
|
||||||
|
surface->state != WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN) {
|
||||||
|
view_set_fullscreen(view, false, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
|
@ -81,6 +96,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&roots_surface->request_move.link);
|
wl_list_remove(&roots_surface->request_move.link);
|
||||||
wl_list_remove(&roots_surface->request_resize.link);
|
wl_list_remove(&roots_surface->request_resize.link);
|
||||||
wl_list_remove(&roots_surface->request_set_maximized.link);
|
wl_list_remove(&roots_surface->request_set_maximized.link);
|
||||||
|
wl_list_remove(&roots_surface->request_set_fullscreen.link);
|
||||||
wl_list_remove(&roots_surface->set_state.link);
|
wl_list_remove(&roots_surface->set_state.link);
|
||||||
wl_list_remove(&roots_surface->surface_commit.link);
|
wl_list_remove(&roots_surface->surface_commit.link);
|
||||||
view_destroy(roots_surface->view);
|
view_destroy(roots_surface->view);
|
||||||
|
@ -111,6 +127,10 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->request_set_maximized.notify = handle_request_set_maximized;
|
roots_surface->request_set_maximized.notify = handle_request_set_maximized;
|
||||||
wl_signal_add(&surface->events.request_set_maximized,
|
wl_signal_add(&surface->events.request_set_maximized,
|
||||||
&roots_surface->request_set_maximized);
|
&roots_surface->request_set_maximized);
|
||||||
|
roots_surface->request_set_fullscreen.notify =
|
||||||
|
handle_request_set_fullscreen;
|
||||||
|
wl_signal_add(&surface->events.request_set_fullscreen,
|
||||||
|
&roots_surface->request_set_fullscreen);
|
||||||
roots_surface->set_state.notify = handle_set_state;
|
roots_surface->set_state.notify = handle_set_state;
|
||||||
wl_signal_add(&surface->events.set_state, &roots_surface->set_state);
|
wl_signal_add(&surface->events.set_state, &roots_surface->set_state);
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
|
|
|
@ -100,6 +100,16 @@ static void maximize(struct roots_view *view, bool maximized) {
|
||||||
wlr_xdg_toplevel_v6_set_maximized(surface, maximized);
|
wlr_xdg_toplevel_v6_set_maximized(surface, maximized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
||||||
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
|
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_xdg_toplevel_v6_set_fullscreen(surface, fullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
static void close(struct roots_view *view) {
|
static void close(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
||||||
|
@ -150,6 +160,21 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
view_maximize(view, surface->toplevel_state->next.maximized);
|
view_maximize(view, surface->toplevel_state->next.maximized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_fullscreen(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
|
wl_container_of(listener, roots_xdg_surface, request_fullscreen);
|
||||||
|
struct roots_view *view = roots_xdg_surface->view;
|
||||||
|
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data;
|
||||||
|
|
||||||
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view_set_fullscreen(view, e->fullscreen, e->output);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_commit(struct wl_listener *listener, void *data) {
|
static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
//struct roots_xdg_surface_v6 *roots_xdg_surface =
|
//struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
// wl_container_of(listener, roots_xdg_surface, commit);
|
// wl_container_of(listener, roots_xdg_surface, commit);
|
||||||
|
@ -202,6 +227,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->request_maximize.notify = handle_request_maximize;
|
roots_surface->request_maximize.notify = handle_request_maximize;
|
||||||
wl_signal_add(&surface->events.request_maximize,
|
wl_signal_add(&surface->events.request_maximize,
|
||||||
&roots_surface->request_maximize);
|
&roots_surface->request_maximize);
|
||||||
|
roots_surface->request_fullscreen.notify = handle_request_fullscreen;
|
||||||
|
wl_signal_add(&surface->events.request_fullscreen,
|
||||||
|
&roots_surface->request_fullscreen);
|
||||||
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
if (!view) {
|
if (!view) {
|
||||||
|
@ -217,6 +245,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move_resize = move_resize;
|
view->move_resize = move_resize;
|
||||||
view->maximize = maximize;
|
view->maximize = maximize;
|
||||||
|
view->set_fullscreen = set_fullscreen;
|
||||||
view->close = close;
|
view->close = close;
|
||||||
roots_surface->view = view;
|
roots_surface->view = view;
|
||||||
view_init(view, desktop);
|
view_init(view, desktop);
|
||||||
|
|
|
@ -252,6 +252,24 @@ void wlr_output_make_current(struct wlr_output *output) {
|
||||||
output->impl->make_current(output);
|
output->impl->make_current(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void output_fullscreen_surface_render(struct wlr_output *output,
|
||||||
|
struct wlr_surface *surface) {
|
||||||
|
int x = (output->width - surface->current->width) / 2;
|
||||||
|
int y = (output->height - surface->current->height) / 2;
|
||||||
|
|
||||||
|
glViewport(0, 0, output->width, output->height);
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
|
||||||
|
if (!wlr_surface_has_buffer(surface)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float matrix[16];
|
||||||
|
wlr_texture_get_matrix(surface->texture, &matrix, &output->transform_matrix,
|
||||||
|
x, y);
|
||||||
|
wlr_render_with_matrix(surface->renderer, surface->texture, &matrix);
|
||||||
|
}
|
||||||
|
|
||||||
static void output_cursor_get_box(struct wlr_output_cursor *cursor,
|
static void output_cursor_get_box(struct wlr_output_cursor *cursor,
|
||||||
struct wlr_box *box) {
|
struct wlr_box *box) {
|
||||||
box->x = cursor->x - cursor->hotspot_x;
|
box->x = cursor->x - cursor->hotspot_x;
|
||||||
|
@ -308,6 +326,10 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) {
|
||||||
void wlr_output_swap_buffers(struct wlr_output *output) {
|
void wlr_output_swap_buffers(struct wlr_output *output) {
|
||||||
wl_signal_emit(&output->events.swap_buffers, &output);
|
wl_signal_emit(&output->events.swap_buffers, &output);
|
||||||
|
|
||||||
|
if (output->fullscreen_surface != NULL) {
|
||||||
|
output_fullscreen_surface_render(output, output->fullscreen_surface);
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_output_cursor *cursor;
|
struct wlr_output_cursor *cursor;
|
||||||
wl_list_for_each(cursor, &output->cursors, link) {
|
wl_list_for_each(cursor, &output->cursors, link) {
|
||||||
if (!cursor->enabled || output->hardware_cursor == cursor) {
|
if (!cursor->enabled || output->hardware_cursor == cursor) {
|
||||||
|
@ -334,6 +356,51 @@ uint32_t wlr_output_get_gamma_size(struct wlr_output *output) {
|
||||||
return output->impl->get_gamma_size(output);
|
return output->impl->get_gamma_size(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void output_fullscreen_surface_reset(struct wlr_output *output) {
|
||||||
|
if (output->fullscreen_surface != NULL) {
|
||||||
|
wl_list_remove(&output->fullscreen_surface_commit.link);
|
||||||
|
wl_list_remove(&output->fullscreen_surface_destroy.link);
|
||||||
|
output->fullscreen_surface = NULL;
|
||||||
|
output->needs_swap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void output_fullscreen_surface_handle_commit(
|
||||||
|
struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_output *output = wl_container_of(listener, output,
|
||||||
|
fullscreen_surface_destroy);
|
||||||
|
output->needs_swap = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void output_fullscreen_surface_handle_destroy(
|
||||||
|
struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_output *output = wl_container_of(listener, output,
|
||||||
|
fullscreen_surface_destroy);
|
||||||
|
output_fullscreen_surface_reset(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_output_set_fullscreen_surface(struct wlr_output *output,
|
||||||
|
struct wlr_surface *surface) {
|
||||||
|
// TODO: hardware fullscreen
|
||||||
|
output_fullscreen_surface_reset(output);
|
||||||
|
|
||||||
|
output->fullscreen_surface = surface;
|
||||||
|
output->needs_swap = true;
|
||||||
|
|
||||||
|
if (surface == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
output->fullscreen_surface_commit.notify =
|
||||||
|
output_fullscreen_surface_handle_commit;
|
||||||
|
wl_signal_add(&surface->events.commit, &output->fullscreen_surface_commit);
|
||||||
|
output->fullscreen_surface_destroy.notify =
|
||||||
|
output_fullscreen_surface_handle_destroy;
|
||||||
|
wl_signal_add(&surface->events.destroy,
|
||||||
|
&output->fullscreen_surface_destroy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void output_cursor_reset(struct wlr_output_cursor *cursor) {
|
static void output_cursor_reset(struct wlr_output_cursor *cursor) {
|
||||||
if (cursor->output->hardware_cursor != cursor) {
|
if (cursor->output->hardware_cursor != cursor) {
|
||||||
cursor->output->needs_swap = true;
|
cursor->output->needs_swap = true;
|
||||||
|
|
|
@ -597,21 +597,14 @@ static void xdg_toplevel_protocol_move(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_xdg_toplevel_v6_move_event *event =
|
struct wlr_xdg_toplevel_v6_move_event event = {
|
||||||
calloc(1, sizeof(struct wlr_xdg_toplevel_v6_move_event));
|
.client = client,
|
||||||
if (event == NULL) {
|
.surface = surface,
|
||||||
wl_client_post_no_memory(client);
|
.seat = seat,
|
||||||
return;
|
.serial = serial,
|
||||||
}
|
};
|
||||||
|
|
||||||
event->client = client;
|
wl_signal_emit(&surface->events.request_move, &event);
|
||||||
event->surface = surface;
|
|
||||||
event->seat = seat;
|
|
||||||
event->serial = serial;
|
|
||||||
|
|
||||||
wl_signal_emit(&surface->events.request_move, event);
|
|
||||||
|
|
||||||
free(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
||||||
|
@ -628,22 +621,15 @@ static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_xdg_toplevel_v6_resize_event *event =
|
struct wlr_xdg_toplevel_v6_resize_event event = {
|
||||||
calloc(1, sizeof(struct wlr_xdg_toplevel_v6_resize_event));
|
.client = client,
|
||||||
if (event == NULL) {
|
.surface = surface,
|
||||||
wl_client_post_no_memory(client);
|
.seat = seat,
|
||||||
return;
|
.serial = serial,
|
||||||
}
|
.edges = edges,
|
||||||
|
};
|
||||||
|
|
||||||
event->client = client;
|
wl_signal_emit(&surface->events.request_resize, &event);
|
||||||
event->surface = surface;
|
|
||||||
event->seat = seat;
|
|
||||||
event->serial = serial;
|
|
||||||
event->edges = edges;
|
|
||||||
|
|
||||||
wl_signal_emit(&surface->events.request_resize, event);
|
|
||||||
|
|
||||||
free(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_set_max_size(struct wl_client *client,
|
static void xdg_toplevel_protocol_set_max_size(struct wl_client *client,
|
||||||
|
@ -677,15 +663,38 @@ static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
||||||
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
||||||
struct wl_resource *resource, struct wl_resource *output_resource) {
|
struct wl_resource *resource, struct wl_resource *output_resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
|
|
||||||
|
struct wlr_output *output = NULL;
|
||||||
|
if (output_resource != NULL) {
|
||||||
|
output = wl_resource_get_user_data(output_resource);
|
||||||
|
}
|
||||||
|
|
||||||
surface->toplevel_state->next.fullscreen = true;
|
surface->toplevel_state->next.fullscreen = true;
|
||||||
wl_signal_emit(&surface->events.request_fullscreen, surface);
|
|
||||||
|
struct wlr_xdg_toplevel_v6_set_fullscreen_event event = {
|
||||||
|
.client = client,
|
||||||
|
.surface = surface,
|
||||||
|
.fullscreen = true,
|
||||||
|
.output = output,
|
||||||
|
};
|
||||||
|
|
||||||
|
wl_signal_emit(&surface->events.request_fullscreen, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
|
|
||||||
surface->toplevel_state->next.fullscreen = false;
|
surface->toplevel_state->next.fullscreen = false;
|
||||||
wl_signal_emit(&surface->events.request_fullscreen, surface);
|
|
||||||
|
struct wlr_xdg_toplevel_v6_set_fullscreen_event event = {
|
||||||
|
.client = client,
|
||||||
|
.surface = surface,
|
||||||
|
.fullscreen = false,
|
||||||
|
.output = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
wl_signal_emit(&surface->events.request_fullscreen, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
||||||
|
|
Loading…
Reference in New Issue