Updating branch refs/heads/master to b95f457e7418579d1e6ed89b648054a6012b76b2 (commit) from 7babb554123a624b4205b567f464911ed2e53b76 (commit)
commit b95f457e7418579d1e6ed89b648054a6012b76b2 Author: Jérôme Guelfucci <jero...@xfce.org> Date: Sat Oct 23 14:16:09 2010 +0200 Save and restore numlock state (Bug #3098). xfce4-settings-helper/keyboards.c | 41 +++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/xfce4-settings-helper/keyboards.c b/xfce4-settings-helper/keyboards.c index f1eb3eb..0880c88 100644 --- a/xfce4-settings-helper/keyboards.c +++ b/xfce4-settings-helper/keyboards.c @@ -51,6 +51,9 @@ static void xfce_keyboards_helper_channel_property_changed (XfconfChannel const gchar *property_name, const GValue *value, XfceKeyboardsHelper *helper); +static void xfce_keyboards_helper_restore_numlock_state (XfconfChannel *channel); +static void xfce_keyboards_helper_save_numlock_state (XfconfChannel *channel); + @@ -103,6 +106,7 @@ xfce_keyboards_helper_init (XfceKeyboardsHelper *helper) /* load settings */ xfce_keyboards_helper_set_auto_repeat_mode (helper); xfce_keyboards_helper_set_repeat_rate (helper); + xfce_keyboards_helper_restore_numlock_state (helper->channel); } else { @@ -118,6 +122,9 @@ xfce_keyboards_helper_finalize (GObject *object) { XfceKeyboardsHelper *helper = XFCE_KEYBOARDS_HELPER (object); + /* Save the numlock state */ + xfce_keyboards_helper_save_numlock_state (helper->channel); + /* release the channel */ if (G_LIKELY (helper->channel)) g_object_unref (G_OBJECT (helper->channel)); @@ -213,3 +220,37 @@ xfce_keyboards_helper_channel_property_changed (XfconfChannel *channel, xfce_keyboards_helper_set_repeat_rate (helper); } } + + + +static void +xfce_keyboards_helper_restore_numlock_state (XfconfChannel *channel) +{ + unsigned int numlock_mask; + Display *dpy; + gboolean state; + + dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + state = xfconf_channel_get_bool (channel, "/Default/Numlock", TRUE); + + numlock_mask = XkbKeysymToModifiers (dpy, XK_Num_Lock); + + XkbLockModifiers (dpy, XkbUseCoreKbd, numlock_mask, state ? numlock_mask : 0); +} + + + +static void +xfce_keyboards_helper_save_numlock_state (XfconfChannel *channel) +{ + Display *dpy; + Bool numlock_state; + Atom numlock; + + dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + numlock = XInternAtom(dpy, "Num Lock", False); + + XkbGetNamedIndicator (dpy, numlock, NULL, &numlock_state, NULL, NULL); + + xfconf_channel_set_bool (channel, "/Default/Numlock", numlock_state); +} _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits