mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-23 22:10:03 +01:00
Remove KBD backlight
This commit is contained in:
parent
f82b7b501b
commit
8606d67c7d
6 changed files with 74 additions and 36 deletions
|
|
@ -33,6 +33,7 @@
|
||||||
#include "up-backend.h"
|
#include "up-backend.h"
|
||||||
#include "up-daemon.h"
|
#include "up-daemon.h"
|
||||||
#include "up-device.h"
|
#include "up-device.h"
|
||||||
|
#include "up-device-kbd-backlight.h"
|
||||||
|
|
||||||
#include "up-enumerator-udev.h"
|
#include "up-enumerator-udev.h"
|
||||||
|
|
||||||
|
|
@ -419,12 +420,19 @@ up_device_disconnected_cb (GObject *gobject,
|
||||||
"native-path", &path,
|
"native-path", &path,
|
||||||
"disconnected", &disconnected,
|
"disconnected", &disconnected,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
g_warning ("Disconnect signal received %s", path);
|
||||||
if (disconnected) {
|
if (disconnected) {
|
||||||
g_debug("Device %s became disconnected, hiding device", path);
|
g_debug("Device %s became disconnected, hiding device", path);
|
||||||
|
if (UP_IS_DEVICE (gobject)) {
|
||||||
if (up_device_is_registered (UP_DEVICE (gobject))) {
|
if (up_device_is_registered (UP_DEVICE (gobject))) {
|
||||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, gobject);
|
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, gobject);
|
||||||
up_device_unregister (UP_DEVICE (gobject));
|
up_device_unregister (UP_DEVICE (gobject));
|
||||||
}
|
}
|
||||||
|
} else if (UP_IS_DEVICE_KBD_BACKLIGHT (gobject)){
|
||||||
|
g_warning ("Unregister LED");
|
||||||
|
up_device_kbd_backlight_unregister (UP_DEVICE_KBD_BACKLIGHT (gobject));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
g_debug ("Device %s became connected, showing device", path);
|
g_debug ("Device %s became connected, showing device", path);
|
||||||
if (up_device_register (UP_DEVICE (gobject)))
|
if (up_device_register (UP_DEVICE (gobject)))
|
||||||
|
|
@ -441,16 +449,20 @@ udev_device_added_cb (UpBackend *backend, GObject *device)
|
||||||
if (UP_IS_DEVICE (device)) {
|
if (UP_IS_DEVICE (device)) {
|
||||||
if (update_added_duplicate_device (backend, UP_DEVICE (device)))
|
if (update_added_duplicate_device (backend, UP_DEVICE (device)))
|
||||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, device);
|
g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, device);
|
||||||
} else {
|
} else if (UP_IS_DEVICE_KBD_BACKLIGHT (device)){
|
||||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, device);
|
g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, device);
|
||||||
|
} else {
|
||||||
|
g_warning ("Unknown device type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
udev_device_removed_cb (UpBackend *backend, UpDevice *device)
|
udev_device_removed_cb (UpBackend *backend, GObject *device)
|
||||||
{
|
{
|
||||||
g_debug ("Removing device from udev enumerator: %p", device);
|
g_debug ("Removing device from udev enumerator: %p", device);
|
||||||
update_removed_duplicate_device (backend, device);
|
|
||||||
|
if (UP_IS_DEVICE (device))
|
||||||
|
update_removed_duplicate_device (backend, UP_DEVICE (device));
|
||||||
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, device);
|
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -785,7 +797,7 @@ up_backend_class_init (UpBackendClass *klass)
|
||||||
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
|
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (UpBackendClass, device_removed),
|
G_STRUCT_OFFSET (UpBackendClass, device_removed),
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 1, UP_TYPE_DEVICE);
|
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,12 @@ uevent_signal_handler_cb (UpEnumeratorUdev *self,
|
||||||
|
|
||||||
g_debug ("removing device for path %s", g_udev_device_get_sysfs_path (device));
|
g_debug ("removing device for path %s", g_udev_device_get_sysfs_path (device));
|
||||||
|
|
||||||
|
if (is_kbd_backlight) {
|
||||||
|
g_debug ("uevent KDB backlight remove.");
|
||||||
|
g_signal_emit_by_name (self, "device-removed", obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
parent_id = g_object_get_data (obj, "udev-parent-id");
|
parent_id = g_object_get_data (obj, "udev-parent-id");
|
||||||
|
|
||||||
/* Remove from siblings table. */
|
/* Remove from siblings table. */
|
||||||
|
|
|
||||||
|
|
@ -233,9 +233,10 @@ up_kbd_backlight_finalize (GObject *object)
|
||||||
/* close file */
|
/* close file */
|
||||||
if (kbd_backlight->priv->fd >= 0)
|
if (kbd_backlight->priv->fd >= 0)
|
||||||
close (kbd_backlight->priv->fd);
|
close (kbd_backlight->priv->fd);
|
||||||
|
#endif
|
||||||
|
|
||||||
G_OBJECT_CLASS (up_kbd_backlight_parent_class)->finalize (object);
|
G_OBJECT_CLASS (up_kbd_backlight_parent_class)->finalize (object);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -255,7 +256,6 @@ up_kbd_backlight_class_init (UpKbdBacklightClass *klass)
|
||||||
dev_kbd_klass->set_brightness = up_kbd_backlight_set_brightness;
|
dev_kbd_klass->set_brightness = up_kbd_backlight_set_brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* up_kbd_backlight_init:
|
* up_kbd_backlight_init:
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
|
|
@ -1075,16 +1075,24 @@ up_daemon_device_removed_cb (UpBackend *backend, UpDevice *device, UpDaemon *dae
|
||||||
const gchar *object_path;
|
const gchar *object_path;
|
||||||
UpDaemonPrivate *priv = daemon->priv;
|
UpDaemonPrivate *priv = daemon->priv;
|
||||||
|
|
||||||
|
|
||||||
g_return_if_fail (UP_IS_DAEMON (daemon));
|
g_return_if_fail (UP_IS_DAEMON (daemon));
|
||||||
g_return_if_fail (UP_IS_DEVICE (device));
|
g_return_if_fail (UP_IS_DEVICE (device) || UP_IS_DEVICE_KBD_BACKLIGHT (device));
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_data (device, daemon);
|
g_signal_handlers_disconnect_by_data (device, daemon);
|
||||||
|
|
||||||
|
/* emit */
|
||||||
|
if (UP_IS_DEVICE (device)) {
|
||||||
/* remove from list (device remains valid during the function call) */
|
/* remove from list (device remains valid during the function call) */
|
||||||
up_device_list_remove (priv->power_devices, device);
|
up_device_list_remove (priv->power_devices, device);
|
||||||
|
|
||||||
/* emit */
|
|
||||||
object_path = up_device_get_object_path (device);
|
object_path = up_device_get_object_path (device);
|
||||||
|
} else if (UP_IS_DEVICE_KBD_BACKLIGHT (device)) {
|
||||||
|
/* remove from list (device remains valid during the function call) */
|
||||||
|
up_device_list_remove (priv->kbd_backlight_devices, device);
|
||||||
|
object_path = up_device_kbd_backlight_get_object_path (UP_DEVICE_KBD_BACKLIGHT (device));
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* don't crash the session */
|
/* don't crash the session */
|
||||||
if (object_path == NULL) {
|
if (object_path == NULL) {
|
||||||
|
|
@ -1095,6 +1103,10 @@ up_daemon_device_removed_cb (UpBackend *backend, UpDevice *device, UpDaemon *dae
|
||||||
g_debug ("emitting device-removed: %s", object_path);
|
g_debug ("emitting device-removed: %s", object_path);
|
||||||
up_exported_daemon_emit_device_removed (UP_EXPORTED_DAEMON (daemon), object_path);
|
up_exported_daemon_emit_device_removed (UP_EXPORTED_DAEMON (daemon), object_path);
|
||||||
|
|
||||||
|
/* Unregister keyboard backlight dbus path */
|
||||||
|
if (UP_IS_DEVICE_KBD_BACKLIGHT (device))
|
||||||
|
up_device_kbd_backlight_unregister (UP_DEVICE_KBD_BACKLIGHT (device));
|
||||||
|
|
||||||
/* In case a battery was removed */
|
/* In case a battery was removed */
|
||||||
up_daemon_refresh_battery_devices (daemon);
|
up_daemon_refresh_battery_devices (daemon);
|
||||||
up_daemon_update_warning_level (daemon);
|
up_daemon_update_warning_level (daemon);
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ enum {
|
||||||
#define UP_DEVICES_KBD_BACKLIGHT_DBUS_PATH "/org/freedesktop/UPower/KbdBacklight"
|
#define UP_DEVICES_KBD_BACKLIGHT_DBUS_PATH "/org/freedesktop/UPower/KbdBacklight"
|
||||||
static GParamSpec *properties[N_PROPS];
|
static GParamSpec *properties[N_PROPS];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* up_kbd_backlight_emit_change:
|
* up_kbd_backlight_emit_change:
|
||||||
**/
|
**/
|
||||||
|
|
@ -140,6 +139,8 @@ up_kbd_backlight_get_max_brightness (UpExportedKbdBacklight *skeleton,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* up_kbd_backlight_set_brightness:
|
* up_kbd_backlight_set_brightness:
|
||||||
|
*
|
||||||
|
* Sets the kbd backlight LED brightness.
|
||||||
**/
|
**/
|
||||||
static gboolean
|
static gboolean
|
||||||
up_kbd_backlight_set_brightness (UpExportedKbdBacklight *skeleton,
|
up_kbd_backlight_set_brightness (UpExportedKbdBacklight *skeleton,
|
||||||
|
|
@ -186,8 +187,8 @@ static gchar *
|
||||||
up_device_kbd_backlight_compute_object_path (UpDeviceKbdBacklight *device)
|
up_device_kbd_backlight_compute_object_path (UpDeviceKbdBacklight *device)
|
||||||
{
|
{
|
||||||
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
||||||
gchar *basename;
|
g_autofree gchar *basename = NULL;
|
||||||
gchar *id;
|
g_autofree gchar *id = NULL;
|
||||||
gchar *object_path;
|
gchar *object_path;
|
||||||
const gchar *native_path;
|
const gchar *native_path;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
@ -213,13 +214,9 @@ up_device_kbd_backlight_compute_object_path (UpDeviceKbdBacklight *device)
|
||||||
}
|
}
|
||||||
object_path = g_build_filename (UP_DEVICES_KBD_BACKLIGHT_DBUS_PATH, id, NULL);
|
object_path = g_build_filename (UP_DEVICES_KBD_BACKLIGHT_DBUS_PATH, id, NULL);
|
||||||
|
|
||||||
g_free (basename);
|
|
||||||
g_free (id);
|
|
||||||
|
|
||||||
return object_path;
|
return object_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
up_device_kbd_backlight_export_skeleton (UpDeviceKbdBacklight *device,
|
up_device_kbd_backlight_export_skeleton (UpDeviceKbdBacklight *device,
|
||||||
const gchar *object_path)
|
const gchar *object_path)
|
||||||
|
|
@ -238,7 +235,6 @@ up_device_kbd_backlight_export_skeleton (UpDeviceKbdBacklight *device,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
up_device_kbd_backlight_register (UpDeviceKbdBacklight *device)
|
up_device_kbd_backlight_register (UpDeviceKbdBacklight *device)
|
||||||
{
|
{
|
||||||
|
|
@ -252,6 +248,19 @@ up_device_kbd_backlight_register (UpDeviceKbdBacklight *device)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
up_device_kbd_backlight_unregister (UpDeviceKbdBacklight *device)
|
||||||
|
{
|
||||||
|
g_autofree char *object_path = NULL;
|
||||||
|
|
||||||
|
object_path = g_strdup (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (device)));
|
||||||
|
if (object_path != NULL) {
|
||||||
|
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (device));
|
||||||
|
g_debug ("Unexported UpDeviceKbdBacklight with path %s", object_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
up_device_kbd_backlight_get_object_path (UpDeviceKbdBacklight *device)
|
up_device_kbd_backlight_get_object_path (UpDeviceKbdBacklight *device)
|
||||||
{
|
{
|
||||||
|
|
@ -268,8 +277,6 @@ up_device_kbd_backlight_set_property (GObject *object,
|
||||||
UpDeviceKbdBacklight *device = UP_DEVICE_KBD_BACKLIGHT (object);
|
UpDeviceKbdBacklight *device = UP_DEVICE_KBD_BACKLIGHT (object);
|
||||||
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
||||||
|
|
||||||
g_debug ("kbd property set");
|
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_DAEMON:
|
case PROP_DAEMON:
|
||||||
|
|
@ -277,7 +284,6 @@ up_device_kbd_backlight_set_property (GObject *object,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_NATIVE:
|
case PROP_NATIVE:
|
||||||
g_debug ("Set kbd native");
|
|
||||||
priv->native = g_value_dup_object (value);
|
priv->native = g_value_dup_object (value);
|
||||||
if (priv->native == NULL)
|
if (priv->native == NULL)
|
||||||
g_warning ("KBD native is NULL");
|
g_warning ("KBD native is NULL");
|
||||||
|
|
@ -297,8 +303,6 @@ up_device_kbd_backlight_get_property (GObject *object,
|
||||||
UpDeviceKbdBacklight *device = UP_DEVICE_KBD_BACKLIGHT (object);
|
UpDeviceKbdBacklight *device = UP_DEVICE_KBD_BACKLIGHT (object);
|
||||||
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
|
@ -315,7 +319,7 @@ up_device_kbd_backlight_initable_init (GInitable *initable,
|
||||||
|
|
||||||
UpDeviceKbdBacklight *device = UP_DEVICE_KBD_BACKLIGHT (initable);
|
UpDeviceKbdBacklight *device = UP_DEVICE_KBD_BACKLIGHT (initable);
|
||||||
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
UpDeviceKbdBacklightPrivate *priv = up_device_kbd_backlight_get_instance_private (device);
|
||||||
const gchar *native_path = "KbdDevice";
|
const gchar *native_path = NULL;
|
||||||
UpDeviceKbdBacklightClass *klass = UP_DEVICE_KBD_BACKLIGHT_GET_CLASS (device);
|
UpDeviceKbdBacklightClass *klass = UP_DEVICE_KBD_BACKLIGHT_GET_CLASS (device);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
@ -380,6 +384,9 @@ up_device_kbd_backlight_finalize (GObject *object)
|
||||||
g_return_if_fail (UP_IS_DEVICE_KBD_BACKLIGHT (object));
|
g_return_if_fail (UP_IS_DEVICE_KBD_BACKLIGHT (object));
|
||||||
|
|
||||||
kbd_backlight = UP_DEVICE_KBD_BACKLIGHT (object);
|
kbd_backlight = UP_DEVICE_KBD_BACKLIGHT (object);
|
||||||
|
|
||||||
|
g_warning ("KBD LED Finalize");
|
||||||
|
|
||||||
//kbd_backlight->priv = up_device_kbd_backlight_get_instance_private (kbd_backlight);
|
//kbd_backlight->priv = up_device_kbd_backlight_get_instance_private (kbd_backlight);
|
||||||
|
|
||||||
//if (kbd_backlight->priv->channel_hw_changed) {
|
//if (kbd_backlight->priv->channel_hw_changed) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ GObject * up_device_kbd_backlight_get_native (UpDeviceKbdBacklight *device);
|
||||||
UpDeviceKbdBacklight *up_device_kbd_backlight_new (UpDaemon *daemon,
|
UpDeviceKbdBacklight *up_device_kbd_backlight_new (UpDaemon *daemon,
|
||||||
GObject *native);
|
GObject *native);
|
||||||
gboolean up_device_kbd_backlight_register (UpDeviceKbdBacklight *device);
|
gboolean up_device_kbd_backlight_register (UpDeviceKbdBacklight *device);
|
||||||
|
void up_device_kbd_backlight_unregister (UpDeviceKbdBacklight *device);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
|
|
@ -67,7 +68,7 @@ void up_device_sibling_discovered (UpDevice *device,
|
||||||
GObject *sibling);
|
GObject *sibling);
|
||||||
gboolean up_device_refresh_internal (UpDevice *device,
|
gboolean up_device_refresh_internal (UpDevice *device,
|
||||||
UpRefreshReason reason);
|
UpRefreshReason reason);
|
||||||
void up_device_unregister (UpDevice *device);
|
|
||||||
|
|
||||||
gboolean up_device_is_registered (UpDevice *device);
|
gboolean up_device_is_registered (UpDevice *device);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue