mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-09-06 09:56:14 +00:00
compositor: Move state tracking complexity into shell
Previously, when coming back from idle the compositor would try to track if the unlock signal needed to be sent, and the shell would change the compositor state in order to track when to display or hide the screensaver. This patch finishes moving this out of the compositor. With this, the compositor state should be changed only using the exported functions weston_compositor_wake() and weston_compositor_sleep(). The unlock signal will be sent if the compositor wasn't in the ACTIVE state previously. The lock signal is sent when the compositor becomes idle. The calls to weston_compositor_wake() in the shell where there to allow it to trigger the fade in only after the lock surface was configured. Now the shell has full control of the fade and does not needed to change the compositor state to do that, so those calls were replaced with shell_fade() calls.
This commit is contained in:
parent
859e885985
commit
87524b65cb
|
@ -1573,40 +1573,48 @@ static const struct wl_compositor_interface compositor_interface = {
|
|||
compositor_create_region
|
||||
};
|
||||
|
||||
WL_EXPORT void
|
||||
weston_compositor_wake(struct weston_compositor *compositor)
|
||||
{
|
||||
compositor->state = WESTON_COMPOSITOR_ACTIVE;
|
||||
|
||||
wl_event_source_timer_update(compositor->idle_source,
|
||||
compositor->idle_time * 1000);
|
||||
}
|
||||
|
||||
static void
|
||||
weston_compositor_dpms_on(struct weston_compositor *compositor)
|
||||
weston_compositor_dpms(struct weston_compositor *compositor,
|
||||
enum dpms_enum state)
|
||||
{
|
||||
struct weston_output *output;
|
||||
|
||||
wl_list_for_each(output, &compositor->output_list, link)
|
||||
if (output->set_dpms)
|
||||
output->set_dpms(output, WESTON_DPMS_ON);
|
||||
output->set_dpms(output, state);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_compositor_activity(struct weston_compositor *compositor)
|
||||
weston_compositor_wake(struct weston_compositor *compositor)
|
||||
{
|
||||
if (compositor->state == WESTON_COMPOSITOR_ACTIVE) {
|
||||
weston_compositor_wake(compositor);
|
||||
} else {
|
||||
weston_compositor_dpms_on(compositor);
|
||||
switch (compositor->state) {
|
||||
case WESTON_COMPOSITOR_SLEEPING:
|
||||
weston_compositor_dpms(compositor, WESTON_DPMS_ON);
|
||||
/* fall through */
|
||||
case WESTON_COMPOSITOR_IDLE:
|
||||
wl_signal_emit(&compositor->unlock_signal, compositor);
|
||||
/* fall through */
|
||||
default:
|
||||
compositor->state = WESTON_COMPOSITOR_ACTIVE;
|
||||
wl_event_source_timer_update(compositor->idle_source,
|
||||
compositor->idle_time * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_compositor_sleep(struct weston_compositor *compositor)
|
||||
{
|
||||
if (compositor->state == WESTON_COMPOSITOR_SLEEPING)
|
||||
return;
|
||||
|
||||
compositor->state = WESTON_COMPOSITOR_SLEEPING;
|
||||
weston_compositor_dpms(compositor, WESTON_DPMS_OFF);
|
||||
}
|
||||
|
||||
static void
|
||||
weston_compositor_idle_inhibit(struct weston_compositor *compositor)
|
||||
{
|
||||
weston_compositor_activity(compositor);
|
||||
weston_compositor_wake(compositor);
|
||||
compositor->idle_inhibit++;
|
||||
}
|
||||
|
||||
|
@ -1614,7 +1622,7 @@ static void
|
|||
weston_compositor_idle_release(struct weston_compositor *compositor)
|
||||
{
|
||||
compositor->idle_inhibit--;
|
||||
weston_compositor_activity(compositor);
|
||||
weston_compositor_wake(compositor);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1694,7 +1702,7 @@ notify_motion(struct weston_seat *seat, uint32_t time, wl_fixed_t x, wl_fixed_t
|
|||
struct wl_pointer *pointer = seat->seat.pointer;
|
||||
int32_t ix, iy;
|
||||
|
||||
weston_compositor_activity(ec);
|
||||
weston_compositor_wake(ec);
|
||||
|
||||
clip_pointer_motion(seat, &x, &y);
|
||||
|
||||
|
@ -1788,7 +1796,7 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
|
|||
if (compositor->ping_handler && focus)
|
||||
compositor->ping_handler(focus, serial);
|
||||
|
||||
weston_compositor_activity(compositor);
|
||||
weston_compositor_wake(compositor);
|
||||
|
||||
if (value)
|
||||
weston_compositor_run_axis_binding(compositor, seat,
|
||||
|
@ -3481,7 +3489,6 @@ int main(int argc, char *argv[])
|
|||
goto out;
|
||||
}
|
||||
|
||||
weston_compositor_dpms_on(ec);
|
||||
weston_compositor_wake(ec);
|
||||
|
||||
wl_display_run(display);
|
||||
|
|
|
@ -593,7 +593,7 @@ weston_compositor_unlock(struct weston_compositor *compositor);
|
|||
void
|
||||
weston_compositor_wake(struct weston_compositor *compositor);
|
||||
void
|
||||
weston_compositor_activity(struct weston_compositor *compositor);
|
||||
weston_compositor_sleep(struct weston_compositor *compositor);
|
||||
void
|
||||
weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);
|
||||
|
||||
|
|
15
src/shell.c
15
src/shell.c
|
@ -2292,7 +2292,7 @@ lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
|
|||
wl_list_insert(&shell->lock_layer.surface_list,
|
||||
&surface->layer_link);
|
||||
weston_surface_update_transform(surface);
|
||||
weston_compositor_wake(shell->compositor);
|
||||
shell_fade(shell, FADE_IN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2353,7 +2353,7 @@ resume_desktop(struct desktop_shell *shell)
|
|||
restore_focus_state(shell, get_current_workspace(shell));
|
||||
|
||||
shell->locked = false;
|
||||
weston_compositor_wake(shell->compositor);
|
||||
shell_fade(shell, FADE_IN);
|
||||
weston_compositor_damage_all(shell->compositor);
|
||||
}
|
||||
|
||||
|
@ -2780,14 +2780,10 @@ click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
|
|||
static void
|
||||
lock(struct desktop_shell *shell)
|
||||
{
|
||||
struct weston_output *output;
|
||||
struct workspace *ws = get_current_workspace(shell);
|
||||
|
||||
if (shell->locked) {
|
||||
wl_list_for_each(output, &shell->compositor->output_list, link)
|
||||
/* TODO: find a way to jump to other DPMS levels */
|
||||
if (output->set_dpms)
|
||||
output->set_dpms(output, WESTON_DPMS_STANDBY);
|
||||
weston_compositor_sleep(shell->compositor);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2816,7 +2812,7 @@ static void
|
|||
unlock(struct desktop_shell *shell)
|
||||
{
|
||||
if (!shell->locked || shell->lock_surface) {
|
||||
weston_compositor_wake(shell->compositor);
|
||||
shell_fade(shell, FADE_IN);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2846,7 +2842,6 @@ shell_fade_done(struct weston_surface_animation *animation, void *data)
|
|||
shell->fade.surface = NULL;
|
||||
break;
|
||||
case FADE_OUT:
|
||||
shell->compositor->state = WESTON_COMPOSITOR_SLEEPING;
|
||||
lock(shell);
|
||||
break;
|
||||
}
|
||||
|
@ -2914,7 +2909,6 @@ unlock_handler(struct wl_listener *listener, void *data)
|
|||
struct desktop_shell *shell =
|
||||
container_of(listener, struct desktop_shell, unlock_listener);
|
||||
|
||||
shell_fade(shell, FADE_IN);
|
||||
unlock(shell);
|
||||
}
|
||||
|
||||
|
@ -3322,7 +3316,6 @@ screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
|
|||
wl_event_source_timer_update(shell->screensaver.timer,
|
||||
shell->screensaver.duration);
|
||||
shell_fade(shell, FADE_IN);
|
||||
shell->compositor->state = WESTON_COMPOSITOR_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue