Skip to content

Commit

Permalink
libweston-desktop: Add listener and API to drop the idle inhibitor
Browse files Browse the repository at this point in the history
Listen for the drop_idle_inhibitor signal from libweston, and propagate
the call to a corresponding libweston-desktop API.
  • Loading branch information
bryceharrington committed Aug 30, 2016
1 parent ca5b624 commit e7069bc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libweston-desktop/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ void
weston_desktop_api_surface_removed(struct weston_desktop *desktop,
struct weston_desktop_surface *surface);
void
weston_desktop_api_surface_drop_idle_inhibitor(struct weston_desktop *desktop,
struct weston_desktop_surface *surface);
void
weston_desktop_api_committed(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
int32_t sx, int32_t sy);
Expand Down
8 changes: 8 additions & 0 deletions libweston-desktop/libweston-desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ weston_desktop_create(struct weston_compositor *compositor,

assert(api->surface_added);
assert(api->surface_removed);
/* assert(api->surface_drop_idle_inhibitor); -- optional, for now */

desktop = zalloc(sizeof(struct weston_desktop));
desktop->compositor = compositor;
Expand Down Expand Up @@ -165,6 +166,13 @@ weston_desktop_api_surface_removed(struct weston_desktop *desktop,
desktop->api.surface_removed(surface, desktop->user_data);
}

void
weston_desktop_api_surface_drop_idle_inhibitor(struct weston_desktop *desktop,
struct weston_desktop_surface *surface)
{
desktop->api.surface_drop_idle_inhibitor(surface, desktop->user_data);
}

void
weston_desktop_api_committed(struct weston_desktop *desktop,
struct weston_desktop_surface *surface,
Expand Down
2 changes: 2 additions & 0 deletions libweston-desktop/libweston-desktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ struct weston_desktop_api {
void *user_data);
void (*surface_removed)(struct weston_desktop_surface *surface,
void *user_data);
void (*surface_drop_idle_inhibitor)(struct weston_desktop_surface *surface,
void *user_data);
void (*committed)(struct weston_desktop_surface *surface,
int32_t sx, int32_t sy, void *user_data);
void (*show_window_menu)(struct weston_desktop_surface *surface,
Expand Down
20 changes: 20 additions & 0 deletions libweston-desktop/surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct weston_desktop_surface {
struct weston_position buffer_move;
struct wl_listener surface_commit_listener;
struct wl_listener surface_destroy_listener;
struct wl_listener surface_drop_idle_inhibitor_listener;
struct wl_listener client_destroy_listener;
struct wl_list children_list;

Expand Down Expand Up @@ -130,6 +131,7 @@ weston_desktop_surface_destroy(struct weston_desktop_surface *surface)

wl_list_remove(&surface->surface_commit_listener.link);
wl_list_remove(&surface->surface_destroy_listener.link);
wl_list_remove(&surface->surface_drop_idle_inhibitor_listener.link);
wl_list_remove(&surface->client_destroy_listener.link);

if (!wl_list_empty(&surface->resource_list)) {
Expand Down Expand Up @@ -217,6 +219,20 @@ weston_desktop_surface_resource_destroy(struct wl_resource *resource)
weston_desktop_surface_destroy(surface);
}

static void
weston_desktop_surface_drop_idle_inhibitor(struct wl_listener *listener,
void *data)
{
struct weston_desktop_surface *surface =
wl_container_of(listener, surface, surface_drop_idle_inhibitor_listener);
struct weston_desktop *desktop = surface->desktop;

printf("weston_desktop_surface_drop_idle_inhibitor\n");
weston_desktop_api_surface_drop_idle_inhibitor(desktop, surface);
// TODO: Need to call shell.c's desktop_surface_drop_idle_inhibitor
//shell_desktop_api.surface_drop_idle_inhibitor(surface, NULL /*data?*/);
}

static void
weston_desktop_surface_committed(struct weston_surface *wsurface,
int32_t sx, int32_t sy)
Expand Down Expand Up @@ -277,6 +293,10 @@ weston_desktop_surface_create(struct weston_desktop *desktop,
weston_desktop_surface_surface_destroyed;
wl_signal_add(&surface->surface->destroy_signal,
&surface->surface_destroy_listener);
surface->surface_drop_idle_inhibitor_listener.notify =
weston_desktop_surface_drop_idle_inhibitor;
wl_signal_add(&surface->surface->drop_idle_inhibitor_signal,
&surface->surface_drop_idle_inhibitor_listener);

wl_list_init(&surface->client_link);
wl_list_init(&surface->resource_list);
Expand Down

0 comments on commit e7069bc

Please sign in to comment.