mirror of
https://github.com/systemd/systemd
synced 2024-09-06 08:46:19 +00:00
terminal: allow user-context to be retrieved/stored
Add "userdata" storage to a bunch of external objects, namely displays and sessions. Furthermore, add some property retrieval helpers. This is required if we want external API users to not duplicate our own object hashtables, but retrieve context from the objects themselves.
This commit is contained in:
parent
5d301b8aec
commit
f2a15d86cc
|
@ -94,6 +94,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_tile*, grdev_tile_free);
|
|||
struct grdev_display {
|
||||
grdev_session *session;
|
||||
char *name;
|
||||
void *userdata;
|
||||
|
||||
size_t n_leafs;
|
||||
grdev_tile *tile;
|
||||
|
|
|
@ -282,6 +282,24 @@ grdev_display *grdev_display_free(grdev_display *display) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void grdev_display_set_userdata(grdev_display *display, void *userdata) {
|
||||
assert(display);
|
||||
|
||||
display->userdata = userdata;
|
||||
}
|
||||
|
||||
void *grdev_display_get_userdata(grdev_display *display) {
|
||||
assert_return(display, NULL);
|
||||
|
||||
return display->userdata;
|
||||
}
|
||||
|
||||
const char *grdev_display_get_name(grdev_display *display) {
|
||||
assert_return(display, NULL);
|
||||
|
||||
return display->name;
|
||||
}
|
||||
|
||||
bool grdev_display_is_enabled(grdev_display *display) {
|
||||
return display && display->enabled;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,11 @@ struct grdev_display_target {
|
|||
const grdev_fb *fb;
|
||||
};
|
||||
|
||||
void grdev_display_set_userdata(grdev_display *display, void *userdata);
|
||||
void *grdev_display_get_userdata(grdev_display *display);
|
||||
|
||||
const char *grdev_display_get_name(grdev_display *display);
|
||||
|
||||
bool grdev_display_is_enabled(grdev_display *display);
|
||||
void grdev_display_enable(grdev_display *display);
|
||||
void grdev_display_disable(grdev_display *display);
|
||||
|
|
|
@ -64,6 +64,7 @@ struct sysview_session {
|
|||
sysview_seat *seat;
|
||||
char *name;
|
||||
char *path;
|
||||
void *userdata;
|
||||
|
||||
sd_bus_slot *slot_take_control;
|
||||
|
||||
|
|
|
@ -104,6 +104,12 @@ sysview_device *sysview_device_free(sysview_device *device) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char *sysview_device_get_name(sysview_device *device) {
|
||||
assert_return(device, NULL);
|
||||
|
||||
return device->name;
|
||||
}
|
||||
|
||||
unsigned int sysview_device_get_type(sysview_device *device) {
|
||||
assert_return(device, (unsigned)-1);
|
||||
|
||||
|
@ -243,6 +249,18 @@ sysview_session *sysview_session_free(sysview_session *session) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void sysview_session_set_userdata(sysview_session *session, void *userdata) {
|
||||
assert(session);
|
||||
|
||||
session->userdata = userdata;
|
||||
}
|
||||
|
||||
void *sysview_session_get_userdata(sysview_session *session) {
|
||||
assert_return(session, NULL);
|
||||
|
||||
return session->userdata;
|
||||
}
|
||||
|
||||
const char *sysview_session_get_name(sysview_session *session) {
|
||||
assert_return(session, NULL);
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ enum {
|
|||
SYSVIEW_DEVICE_CNT
|
||||
};
|
||||
|
||||
const char *sysview_device_get_name(sysview_device *device);
|
||||
unsigned int sysview_device_get_type(sysview_device *device);
|
||||
struct udev_device *sysview_device_get_ud(sysview_device *device);
|
||||
|
||||
|
@ -123,6 +124,9 @@ struct udev_device *sysview_device_get_ud(sysview_device *device);
|
|||
* Sessions
|
||||
*/
|
||||
|
||||
void sysview_session_set_userdata(sysview_session *session, void *userdata);
|
||||
void *sysview_session_get_userdata(sysview_session *session);
|
||||
|
||||
const char *sysview_session_get_name(sysview_session *session);
|
||||
|
||||
int sysview_session_take_control(sysview_session *session);
|
||||
|
|
Loading…
Reference in a new issue