diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-09-20 09:43:16 +0200 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2014-09-20 11:46:49 +0200 |
commit | 965f7a3f9bf7afb85be62198fabc70ffa033d8b1 (patch) | |
tree | 2dce26fa0db13f0aa9b4e9e046723a874431b7fb /src | |
parent | 3e7f6cf9565e007545112f245e69b2bf45866258 (diff) |
terminal: forward DEVICE_CHANGE events via sysview
Whe need to react to "change" events on devices, but we want to avoid
duplicating udev-monitors everywhere. Therefore, make sysview forward
change events to the sysview controllers, which can then properly react
to it.
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-terminal/sysview.c | 14 | ||||
-rw-r--r-- | src/libsystemd-terminal/sysview.h | 7 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c index 6c1a9543b9..23d564d6a0 100644 --- a/src/libsystemd-terminal/sysview.c +++ b/src/libsystemd-terminal/sysview.c @@ -517,6 +517,18 @@ static int context_raise_session_detach(sysview_context *c, sysview_session *ses return context_raise(c, &event, 0); } +static int context_raise_device_change(sysview_context *c, sysview_device *device, struct udev_device *ud) { + sysview_event event = { + .type = SYSVIEW_EVENT_DEVICE_CHANGE, + .device_change = { + .device = device, + .ud = ud, + } + }; + + return context_raise(c, &event, 0); +} + static int context_add_device(sysview_context *c, sysview_device *device) { sysview_session *session; int r, error = 0; @@ -872,7 +884,7 @@ static int context_ud_hotplug(sysview_context *c, struct udev_device *d) { if (!device) return 0; - /* TODO: send REFRESH event */ + return context_raise_device_change(c, device, d); } else if (!action || streq_ptr(action, "add")) { struct udev_device *p; unsigned int type, t; diff --git a/src/libsystemd-terminal/sysview.h b/src/libsystemd-terminal/sysview.h index de6ff371db..b9452fab89 100644 --- a/src/libsystemd-terminal/sysview.h +++ b/src/libsystemd-terminal/sysview.h @@ -64,6 +64,8 @@ enum { SYSVIEW_EVENT_SESSION_ATTACH, SYSVIEW_EVENT_SESSION_DETACH, SYSVIEW_EVENT_SESSION_CONTROL, + + SYSVIEW_EVENT_DEVICE_CHANGE, }; struct sysview_event { @@ -94,6 +96,11 @@ struct sysview_event { sysview_session *session; int error; } session_control; + + struct { + sysview_device *device; + struct udev_device *ud; + } device_change; }; }; |