diff options
author | Perberos <[email protected]> | 2011-12-08 14:09:44 -0300 |
---|---|---|
committer | Perberos <[email protected]> | 2011-12-08 14:09:44 -0300 |
commit | 283de05cf3b8bed9dcde9e80875b860520de392a (patch) | |
tree | 0447d2c7e271ed05493794670fac0d6f05d0d475 /plugins/keyboard/gsd-keyboard-manager.c | |
parent | 81ea15d1ce166e69e7fff11c88e16c42d8db190d (diff) | |
download | mate-settings-daemon-283de05cf3b8bed9dcde9e80875b860520de392a.tar.bz2 mate-settings-daemon-283de05cf3b8bed9dcde9e80875b860520de392a.tar.xz |
GDK_DISPLAY() is deprecated
Diffstat (limited to 'plugins/keyboard/gsd-keyboard-manager.c')
-rw-r--r-- | plugins/keyboard/gsd-keyboard-manager.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c index 343706d..24d6729 100644 --- a/plugins/keyboard/gsd-keyboard-manager.c +++ b/plugins/keyboard/gsd-keyboard-manager.c @@ -38,11 +38,12 @@ #include <gtk/gtk.h> #ifdef HAVE_X11_EXTENSIONS_XF86MISC_H -# include <X11/extensions/xf86misc.h> + #include <X11/extensions/xf86misc.h> #endif + #ifdef HAVE_X11_EXTENSIONS_XKB_H -#include <X11/XKBlib.h> -#include <X11/keysym.h> + #include <X11/XKBlib.h> + #include <X11/keysym.h> #endif #include "mate-settings-profile.h" @@ -51,10 +52,11 @@ #include "gsd-keyboard-xkb.h" #include "gsd-xmodmap.h" -#define GSD_KEYBOARD_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_KEYBOARD_MANAGER, GsdKeyboardManagerPrivate)) +#define GSD_KEYBOARD_MANAGER_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), GSD_TYPE_KEYBOARD_MANAGER, GsdKeyboardManagerPrivate)) #ifndef HOST_NAME_MAX -# define HOST_NAME_MAX 255 + #define HOST_NAME_MAX 255 #endif #define GSD_KEYBOARD_KEY "/desktop/mate/peripherals/keyboard" @@ -70,16 +72,15 @@ #define KEY_BELL_DURATION GSD_KEYBOARD_KEY "/bell_duration" #define KEY_BELL_MODE GSD_KEYBOARD_KEY "/bell_mode" -struct GsdKeyboardManagerPrivate -{ - gboolean have_xkb; - gint xkb_event_base; - guint notify; +struct GsdKeyboardManagerPrivate { + gboolean have_xkb; + gint xkb_event_base; + guint notify; }; -static void gsd_keyboard_manager_class_init (GsdKeyboardManagerClass *klass); -static void gsd_keyboard_manager_init (GsdKeyboardManager *keyboard_manager); -static void gsd_keyboard_manager_finalize (GObject *object); +static void gsd_keyboard_manager_class_init (GsdKeyboardManagerClass* klass); +static void gsd_keyboard_manager_init (GsdKeyboardManager* keyboard_manager); +static void gsd_keyboard_manager_finalize (GObject* object); G_DEFINE_TYPE (GsdKeyboardManager, gsd_keyboard_manager, G_TYPE_OBJECT) @@ -87,24 +88,23 @@ static gpointer manager_object = NULL; #ifdef HAVE_X11_EXTENSIONS_XF86MISC_H -static gboolean -xfree86_set_keyboard_autorepeat_rate (int delay, int rate) +static gboolean xfree86_set_keyboard_autorepeat_rate(int delay, int rate) { gboolean res = FALSE; int event_base_return; int error_base_return; - if (XF86MiscQueryExtension (GDK_DISPLAY (), + if (XF86MiscQueryExtension (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &event_base_return, &error_base_return) == True) { /* load the current settings */ XF86MiscKbdSettings kbdsettings; - XF86MiscGetKbdSettings (GDK_DISPLAY (), &kbdsettings); + XF86MiscGetKbdSettings (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &kbdsettings); /* assign the new values */ kbdsettings.delay = delay; kbdsettings.rate = rate; - XF86MiscSetKbdSettings (GDK_DISPLAY (), &kbdsettings); + XF86MiscSetKbdSettings (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &kbdsettings); res = TRUE; } @@ -113,21 +113,20 @@ xfree86_set_keyboard_autorepeat_rate (int delay, int rate) #endif /* HAVE_X11_EXTENSIONS_XF86MISC_H */ #ifdef HAVE_X11_EXTENSIONS_XKB_H -static gboolean -xkb_set_keyboard_autorepeat_rate (int delay, int rate) +static gboolean xkb_set_keyboard_autorepeat_rate(int delay, int rate) { - int interval = (rate <= 0) ? 1000000 : 1000/rate; - if (delay <= 0) - delay = 1; - return XkbSetAutoRepeatRate (GDK_DISPLAY (), - XkbUseCoreKbd, - delay, - interval); + int interval = (rate <= 0) ? 1000000 : 1000/rate; + + if (delay <= 0) + { + delay = 1; + } + + return XkbSetAutoRepeatRate(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XkbUseCoreKbd, delay, interval); } #endif -static char * -gsd_keyboard_get_hostname_key (const char *subkey) +static char* gsd_keyboard_get_hostname_key (const char *subkey) { char hostname[HOST_NAME_MAX + 1]; @@ -235,17 +234,17 @@ numlock_get_mateconf_state (MateConfClient *client) return curr_state; } -static void -numlock_set_mateconf_state (MateConfClient *client, - NumLockState new_state) +static void numlock_set_mateconf_state(MateConfClient *client, NumLockState new_state) { - char *key; + //printf("numlock_set_mateconf_state\n"); + char* key; if (new_state != NUMLOCK_STATE_ON && new_state != NUMLOCK_STATE_OFF) { return; } key = numlock_mateconf_state_key (); + if (key) { mateconf_client_set_bool (client, key, new_state, NULL); g_free (key); @@ -330,7 +329,7 @@ apply_settings (MateConfClient *client, if (repeat) { gboolean rate_set = FALSE; - XAutoRepeatOn (GDK_DISPLAY ()); + XAutoRepeatOn (GDK_DISPLAY_XDISPLAY(gdk_display_get_default())); /* Use XKB in preference */ #ifdef HAVE_X11_EXTENSIONS_XKB_H rate_set = xkb_set_keyboard_autorepeat_rate (delay, rate); @@ -343,7 +342,7 @@ apply_settings (MateConfClient *client, g_warning ("Neither XKeyboard not Xfree86's keyboard extensions are available,\n" "no way to support keyboard autorepeat rate settings"); } else { - XAutoRepeatOff (GDK_DISPLAY ()); + XAutoRepeatOff (GDK_DISPLAY_XDISPLAY(gdk_display_get_default())); } /* as percentage from 0..100 inclusive */ @@ -356,7 +355,7 @@ apply_settings (MateConfClient *client, kbdcontrol.bell_percent = bell_volume; kbdcontrol.bell_pitch = bell_pitch; kbdcontrol.bell_duration = bell_duration; - XChangeKeyboardControl (GDK_DISPLAY (), + XChangeKeyboardControl (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration, &kbdcontrol); @@ -366,7 +365,7 @@ apply_settings (MateConfClient *client, } #endif /* HAVE_X11_EXTENSIONS_XKB_H */ - XSync (GDK_DISPLAY (), FALSE); + XSync (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), FALSE); gdk_error_trap_pop (); } |