shell: Always go to original mode when focused window not fullscreen
Right now we only switch mode on activating a fullscreened window. This has several problems: * Once you're in fullscreen its hard to switch to a non-fullscreened window with alt-tab as you stay in the small resolution. * If you switch from a fullscreened window to a non-fullscreened window and the fullscreened window is destroyed we will not restore the original mode (since the window is not shell_surface_is_top_fullscreen() * Its hard to reach a different output on the right with the mouse when the mode is smaller that the original, as there is a "gap" between the two outputs. So, if you alt-tab to another window you can not always reach it. This is somewhat of a sledge hammer, as it means you can't e.g. focus a non-fullscreen on one output and have a window fullscreened on another output. However, trying to restore only the outputs the new window is on is problematic: * It may later change output * We want to see all windows anyway during alt-tab * Can't reach the other windows with the mouse anyway So, this seems like an ok solution.
This commit is contained in:
committed by
Kristian Høgsberg
parent
355748e3b5
commit
f82b6cac5e
+29
-9
@@ -1495,6 +1495,25 @@ get_default_output(struct weston_compositor *compositor)
|
|||||||
struct weston_output, link);
|
struct weston_output, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
restore_output_mode(struct weston_output *output)
|
||||||
|
{
|
||||||
|
if (output->current != output->origin ||
|
||||||
|
(int32_t)output->scale != output->origin_scale)
|
||||||
|
weston_output_switch_mode(output,
|
||||||
|
output->origin,
|
||||||
|
output->origin_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
restore_all_output_modes(struct weston_compositor *compositor)
|
||||||
|
{
|
||||||
|
struct weston_output *output;
|
||||||
|
|
||||||
|
wl_list_for_each(output, &compositor->output_list, link)
|
||||||
|
restore_output_mode(output);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shell_unset_fullscreen(struct shell_surface *shsurf)
|
shell_unset_fullscreen(struct shell_surface *shsurf)
|
||||||
{
|
{
|
||||||
@@ -1502,9 +1521,7 @@ shell_unset_fullscreen(struct shell_surface *shsurf)
|
|||||||
/* undo all fullscreen things here */
|
/* undo all fullscreen things here */
|
||||||
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
|
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
|
||||||
shell_surface_is_top_fullscreen(shsurf)) {
|
shell_surface_is_top_fullscreen(shsurf)) {
|
||||||
weston_output_switch_mode(shsurf->fullscreen_output,
|
restore_output_mode(shsurf->fullscreen_output);
|
||||||
shsurf->fullscreen_output->origin,
|
|
||||||
shsurf->fullscreen_output->origin_scale);
|
|
||||||
}
|
}
|
||||||
shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT;
|
shsurf->fullscreen.type = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT;
|
||||||
shsurf->fullscreen.framerate = 0;
|
shsurf->fullscreen.framerate = 0;
|
||||||
@@ -1742,6 +1759,9 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
|
|||||||
float scale, output_aspect, surface_aspect, x, y;
|
float scale, output_aspect, surface_aspect, x, y;
|
||||||
int32_t surf_x, surf_y, surf_width, surf_height;
|
int32_t surf_x, surf_y, surf_width, surf_height;
|
||||||
|
|
||||||
|
if (shsurf->fullscreen.type != WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER)
|
||||||
|
restore_output_mode(output);
|
||||||
|
|
||||||
if (!shsurf->fullscreen.black_surface)
|
if (!shsurf->fullscreen.black_surface)
|
||||||
shsurf->fullscreen.black_surface =
|
shsurf->fullscreen.black_surface =
|
||||||
create_black_surface(surface->compositor,
|
create_black_surface(surface->compositor,
|
||||||
@@ -1809,7 +1829,8 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
|
|||||||
output->width,
|
output->width,
|
||||||
output->height);
|
output->height);
|
||||||
break;
|
break;
|
||||||
}
|
} else
|
||||||
|
restore_output_mode(output);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_FILL:
|
case WL_SHELL_SURFACE_FULLSCREEN_METHOD_FILL:
|
||||||
@@ -2147,11 +2168,8 @@ destroy_shell_surface(struct shell_surface *shsurf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
|
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
|
||||||
shell_surface_is_top_fullscreen(shsurf)) {
|
shell_surface_is_top_fullscreen(shsurf))
|
||||||
weston_output_switch_mode(shsurf->fullscreen_output,
|
restore_output_mode (shsurf->fullscreen_output);
|
||||||
shsurf->fullscreen_output->origin,
|
|
||||||
shsurf->fullscreen_output->origin_scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shsurf->fullscreen.black_surface)
|
if (shsurf->fullscreen.black_surface)
|
||||||
weston_surface_destroy(shsurf->fullscreen.black_surface);
|
weston_surface_destroy(shsurf->fullscreen.black_surface);
|
||||||
@@ -2921,6 +2939,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
|
|||||||
shell_configure_fullscreen(get_shell_surface(main_surface));
|
shell_configure_fullscreen(get_shell_surface(main_surface));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
restore_all_output_modes(shell->compositor);
|
||||||
ws = get_current_workspace(shell);
|
ws = get_current_workspace(shell);
|
||||||
weston_surface_restack(main_surface, &ws->layer.surface_list);
|
weston_surface_restack(main_surface, &ws->layer.surface_list);
|
||||||
break;
|
break;
|
||||||
@@ -4011,6 +4030,7 @@ switcher_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
|
|||||||
switcher->listener.notify = switcher_handle_surface_destroy;
|
switcher->listener.notify = switcher_handle_surface_destroy;
|
||||||
wl_list_init(&switcher->listener.link);
|
wl_list_init(&switcher->listener.link);
|
||||||
|
|
||||||
|
restore_all_output_modes(shell->compositor);
|
||||||
lower_fullscreen_layer(switcher->shell);
|
lower_fullscreen_layer(switcher->shell);
|
||||||
switcher->grab.interface = &switcher_grab;
|
switcher->grab.interface = &switcher_grab;
|
||||||
weston_keyboard_start_grab(seat->keyboard, &switcher->grab);
|
weston_keyboard_start_grab(seat->keyboard, &switcher->grab);
|
||||||
|
|||||||
Reference in New Issue
Block a user