Feedback for fullscreen.

This commit is contained in:
Ryan Dwyer 2018-04-17 08:11:50 +10:00
parent 52420cc24d
commit bfd5834f4c
7 changed files with 13 additions and 41 deletions

View File

@ -72,7 +72,6 @@ struct sway_container {
// For C_OUTPUT, this is the output position in layout coordinates
// For other types, this is the position in output-local coordinates
double x, y;
double saved_x, saved_y;
// does not include borders or gaps.
double width, height;

View File

@ -42,7 +42,6 @@ struct sway_view {
struct sway_container *swayc; // NULL for unmanaged views
struct wlr_surface *surface; // NULL for unmapped views
int width, height;
int saved_width, saved_height;
bool is_fullscreen;
union {

View File

@ -8,12 +8,6 @@
// fullscreen toggle|enable|disable
struct cmd_results *cmd_fullscreen(int argc, char **argv) {
struct cmd_results *error = NULL;
if (config->reading) return cmd_results_new(CMD_FAILURE, "fullscreen", "Can't be used in config file.");
if (!config->active) return cmd_results_new(CMD_FAILURE, "fullscreen", "Can only be used when sway is running.");
if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_LEAST, 1))) {
return error;
}
struct sway_container *container =
config->handler_context.current_container;
if (container->type != C_VIEW) {
@ -23,15 +17,15 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
struct sway_view *view = container->sway_view;
bool wants_fullscreen;
if (strcmp(argv[0], "enable") == 0) {
if (argc == 0 || strcmp(argv[0], "toggle") == 0) {
wants_fullscreen = !view->is_fullscreen;
} else if (strcmp(argv[0], "enable") == 0) {
wants_fullscreen = true;
} else if (strcmp(argv[0], "disable") == 0) {
wants_fullscreen = false;
} else if (strcmp(argv[0], "toggle") == 0) {
wants_fullscreen = !view->is_fullscreen;
} else {
return cmd_results_new(CMD_INVALID, "fullscreen",
"Expected 'fullscreen <enable|disable|toggle>'");
"Expected 'fullscreen' or fullscreen <enable|disable|toggle>'");
}
view_set_fullscreen(view, wants_fullscreen);

View File

@ -287,11 +287,9 @@ static void render_output(struct sway_output *output, struct timespec *when,
render_container(output, workspace);
render_unmanaged(output, &root_container.sway_root->xwayland_unmanaged);
render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
render_layer(output,
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
}
render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
renderer_end:
if (root_container.sway_root->debug_tree) {

View File

@ -25,15 +25,6 @@ static void unmanaged_handle_request_configure(struct wl_listener *listener,
ev->width, ev->height);
}
static void unmanaged_handle_request_fullscreen(struct wl_listener *listener,
void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, request_fullscreen);
struct sway_view *view = &xwayland_view->view;
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
view_set_fullscreen(view, xsurface->fullscreen);
}
static void unmanaged_handle_commit(struct wl_listener *listener, void *data) {
struct sway_xwayland_unmanaged *surface =
wl_container_of(listener, surface, commit);
@ -115,9 +106,6 @@ static struct sway_xwayland_unmanaged *create_unmanaged(
wl_signal_add(&xsurface->events.request_configure,
&surface->request_configure);
surface->request_configure.notify = unmanaged_handle_request_configure;
wl_signal_add(&xsurface->events.request_fullscreen,
&surface->request_fullscreen);
surface->request_fullscreen.notify = unmanaged_handle_request_fullscreen;
wl_signal_add(&xsurface->events.map, &surface->map);
surface->map.notify = unmanaged_handle_map;
wl_signal_add(&xsurface->events.unmap, &surface->unmap);

View File

@ -138,7 +138,7 @@ void container_move_to(struct sway_container *container,
return;
}
if (container->sway_view->is_fullscreen) {
if (container->type == C_VIEW && container->sway_view->is_fullscreen) {
struct sway_container *old_workspace = container;
if (old_workspace->type != C_WORKSPACE) {
old_workspace = container_parent(old_workspace, C_WORKSPACE);

View File

@ -79,32 +79,26 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
return;
}
struct sway_container *container = container_parent(view->swayc, C_OUTPUT);
struct sway_output *output = container->sway_output;
struct sway_container *workspace = container_parent(view->swayc, C_WORKSPACE);
struct sway_container *container = container_parent(workspace, C_OUTPUT);
struct sway_output *output = container->sway_output;
if (view->impl->set_fullscreen) {
view->impl->set_fullscreen(view, fullscreen);
}
view->is_fullscreen = fullscreen;
if (fullscreen) {
view->swayc->saved_x = view->swayc->x;
view->swayc->saved_y = view->swayc->y;
view->saved_width = view->width;
view->saved_height = view->height;
view_configure(view, 0, 0, output->wlr_output->width, output->wlr_output->height);
workspace->fullscreen = view;
view_configure(view, 0, 0, output->wlr_output->width, output->wlr_output->height);
} else {
view_configure(view, view->swayc->saved_x, view->swayc->saved_y,
view->saved_width, view->saved_height);
workspace->fullscreen = NULL;
arrange_windows(workspace, -1, -1);
}
view->is_fullscreen = fullscreen;
output_damage_whole(output);
arrange_windows(workspace, -1, -1);
ipc_event_window(view->swayc, "fullscreen_mode");
}