backend: Use g_signal_emit instead of g_signal_emit_by_name

No functional changes, just a minor cleanup.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2017-03-29 14:30:10 +08:00
parent 6c8b103a7b
commit 6791d1b8e2
3 changed files with 65 additions and 29 deletions

View File

@ -167,4 +167,9 @@ gboolean meta_is_stage_views_scaled (void);
MetaInputSettings *meta_backend_get_input_settings (MetaBackend *backend);
void meta_backend_notify_keymap_changed (MetaBackend *backend);
void meta_backend_notify_keymap_layout_group_changed (MetaBackend *backend,
unsigned int locked_group);
#endif /* META_BACKEND_PRIVATE_H */

View File

@ -44,6 +44,18 @@
#include "backends/meta-logical-monitor.h"
#include "backends/meta-monitor-manager-dummy.h"
enum
{
KEYMAP_CHANGED,
KEYMAP_LAYOUT_GROUP_CHANGED,
LAST_DEVICE_CHANGED,
EXPERIMENTAL_FEATURES_CHANGED,
N_SIGNALS
};
static guint signals[N_SIGNALS];
static MetaBackend *_backend;
/**
@ -472,7 +484,7 @@ mutter_settings_changed (GSettings *settings,
changed = update_experimental_features (backend);
if (changed)
g_signal_emit_by_name (backend, "experimental-features-changed");
g_signal_emit (backend, signals[EXPERIMENTAL_FEATURES_CHANGED], 0);
}
gboolean
@ -516,24 +528,28 @@ meta_backend_class_init (MetaBackendClass *klass)
klass->select_stage_events = meta_backend_real_select_stage_events;
klass->get_relative_motion_deltas = meta_backend_real_get_relative_motion_deltas;
signals[KEYMAP_CHANGED] =
g_signal_new ("keymap-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
signals[KEYMAP_LAYOUT_GROUP_CHANGED] =
g_signal_new ("keymap-layout-group-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_UINT);
signals[LAST_DEVICE_CHANGED] =
g_signal_new ("last-device-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 1, G_TYPE_INT);
signals[EXPERIMENTAL_FEATURES_CHANGED] =
g_signal_new ("experimental-features-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@ -757,7 +773,7 @@ update_last_device (MetaBackend *backend)
priv->current_device_id);
device_type = clutter_input_device_get_device_type (device);
g_signal_emit_by_name (backend, "last-device-changed",
g_signal_emit (backend, signals[LAST_DEVICE_CHANGED], 0,
priv->current_device_id);
switch (device_type)
@ -1012,3 +1028,17 @@ meta_backend_get_dnd (MetaBackend *backend)
return priv->dnd;
}
void
meta_backend_notify_keymap_changed (MetaBackend *backend)
{
g_signal_emit (backend, signals[KEYMAP_CHANGED], 0);
}
void
meta_backend_notify_keymap_layout_group_changed (MetaBackend *backend,
unsigned int locked_group)
{
g_signal_emit (backend, signals[KEYMAP_LAYOUT_GROUP_CHANGED], 0,
locked_group);
}

View File

@ -485,7 +485,7 @@ meta_backend_native_set_keymap (MetaBackend *backend,
clutter_evdev_set_keyboard_map (manager, keymap);
g_signal_emit_by_name (backend, "keymap-changed", 0);
meta_backend_notify_keymap_changed (backend);
xkb_keymap_unref (keymap);
}
@ -502,8 +502,9 @@ meta_backend_native_lock_layout_group (MetaBackend *backend,
guint idx)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
clutter_evdev_set_keyboard_layout_index (manager, idx);
g_signal_emit_by_name (backend, "keymap-layout-group-changed", idx, 0);
meta_backend_notify_keymap_layout_group_changed (backend, idx);
}
static void