seat: add helpers to schedule sessions from the outside
Two new helpers to schedule a specific session or a session given by a hint-number. These can be used by other subsystems to schedule their/others sessions. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
7b83d77463
commit
3c223d9bec
@ -830,6 +830,31 @@ struct conf_ctx *kmscon_seat_get_conf(struct kmscon_seat *seat)
|
||||
return seat->conf_ctx;
|
||||
}
|
||||
|
||||
void kmscon_seat_schedule(struct kmscon_seat *seat, unsigned int id)
|
||||
{
|
||||
struct shl_dlist *iter;
|
||||
struct kmscon_session *s, *next;
|
||||
|
||||
if (!seat)
|
||||
return;
|
||||
|
||||
next = seat->dummy_sess;
|
||||
shl_dlist_for_each(iter, &seat->sessions) {
|
||||
s = shl_dlist_entry(iter, struct kmscon_session, list);
|
||||
if (!s->enabled || seat->dummy_sess == s ||
|
||||
seat->current_sess == s)
|
||||
continue;
|
||||
|
||||
next = s;
|
||||
if (!id--)
|
||||
break;
|
||||
}
|
||||
|
||||
seat->scheduled_sess = next;
|
||||
if (seat_has_schedule(seat))
|
||||
seat_switch(seat);
|
||||
}
|
||||
|
||||
int kmscon_seat_register_session(struct kmscon_seat *seat,
|
||||
struct kmscon_session **out,
|
||||
kmscon_session_cb_t cb,
|
||||
@ -994,6 +1019,20 @@ int kmscon_session_set_background(struct kmscon_session *sess)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kmscon_session_schedule(struct kmscon_session *sess)
|
||||
{
|
||||
struct kmscon_seat *seat;
|
||||
|
||||
if (!sess || !sess->seat)
|
||||
return;
|
||||
|
||||
seat = sess->seat;
|
||||
seat->scheduled_sess = sess;
|
||||
seat_reschedule(seat);
|
||||
if (seat_has_schedule(seat))
|
||||
seat_switch(seat);
|
||||
}
|
||||
|
||||
void kmscon_session_enable(struct kmscon_session *sess)
|
||||
{
|
||||
if (!sess || sess->enabled)
|
||||
|
@ -90,6 +90,8 @@ struct uterm_input *kmscon_seat_get_input(struct kmscon_seat *seat);
|
||||
struct ev_eloop *kmscon_seat_get_eloop(struct kmscon_seat *seat);
|
||||
struct conf_ctx *kmscon_seat_get_conf(struct kmscon_seat *seat);
|
||||
|
||||
void kmscon_seat_schedule(struct kmscon_seat *seat, unsigned int id);
|
||||
|
||||
int kmscon_seat_register_session(struct kmscon_seat *seat,
|
||||
struct kmscon_session **out,
|
||||
kmscon_session_cb_t cb,
|
||||
@ -103,6 +105,7 @@ bool kmscon_session_is_registered(struct kmscon_session *sess);
|
||||
bool kmscon_session_is_active(struct kmscon_session *sess);
|
||||
int kmscon_session_set_foreground(struct kmscon_session *sess);
|
||||
int kmscon_session_set_background(struct kmscon_session *sess);
|
||||
void kmscon_session_schedule(struct kmscon_session *sess);
|
||||
|
||||
void kmscon_session_enable(struct kmscon_session *sess);
|
||||
void kmscon_session_disable(struct kmscon_session *sess);
|
||||
|
Loading…
x
Reference in New Issue
Block a user