diff options
author | raveit65 <[email protected]> | 2017-04-02 08:32:38 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-04-04 17:58:54 +0200 |
commit | 2f12b7ca7d63e8eef0943a99179f31abde1d3282 (patch) | |
tree | 192dbe8bb141315d93722624d6b680af2c5e556f | |
parent | 0c6d56e56978500d0491f2b809e2e31287eeb98d (diff) | |
download | libmatekbd-2f12b7ca7d63e8eef0943a99179f31abde1d3282.tar.bz2 libmatekbd-2f12b7ca7d63e8eef0943a99179f31abde1d3282.tar.xz |
matekbd-keyboard-drawing: Handle XkbGetKeyboard() failing
XkbGetKeyboard() might fail but we might still be able to work with a
XkbGetKeyboardByName() later in gkbd_keyboard_drawing_set_keyboard()
so don't abort the initialization if it fails.
taken from:
https://git.gnome.org/browse/libgnomekbd/commit/?id=5f260b2
-rw-r--r-- | libmatekbd/matekbd-keyboard-drawing.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libmatekbd/matekbd-keyboard-drawing.c b/libmatekbd/matekbd-keyboard-drawing.c index 83c91ea..3343362 100644 --- a/libmatekbd/matekbd-keyboard-drawing.c +++ b/libmatekbd/matekbd-keyboard-drawing.c @@ -1913,6 +1913,9 @@ free_cdik ( /*colors doodads indicators keys */ static void alloc_cdik (MatekbdKeyboardDrawing * drawing) { + if (!drawing->xkb) + return; + drawing->physical_indicators_size = drawing->xkb->indicators->phys_indicators + 1; drawing->physical_indicators = @@ -2101,13 +2104,14 @@ matekbd_keyboard_drawing_init (MatekbdKeyboardDrawing * drawing) XkbGBN_SymbolsMask | XkbGBN_IndicatorMapMask, XkbUseCoreKbd); - if (drawing->xkb == NULL) { - g_critical - ("XkbGetKeyboard failed to get keyboard from the server!"); - return; + if (drawing->xkb) { + XkbGetNames (drawing->display, XkbAllNamesMask, drawing->xkb); + XkbSelectEventDetails (drawing->display, XkbUseCoreKbd, + XkbIndicatorStateNotify, + drawing->xkb->indicators->phys_indicators, + drawing->xkb->indicators->phys_indicators); } - XkbGetNames (drawing->display, XkbAllNamesMask, drawing->xkb); drawing->l3mod = XkbKeysymToModifiers (drawing->display, GDK_KEY_ISO_Level3_Shift); @@ -2115,11 +2119,6 @@ matekbd_keyboard_drawing_init (MatekbdKeyboardDrawing * drawing) alloc_cdik (drawing); - XkbSelectEventDetails (drawing->display, XkbUseCoreKbd, - XkbIndicatorStateNotify, - drawing->xkb->indicators->phys_indicators, - drawing->xkb->indicators->phys_indicators); - mask = (XkbStateNotifyMask | XkbNamesNotifyMask | XkbControlsNotifyMask | XkbIndicatorMapNotifyMask | @@ -2328,8 +2327,12 @@ matekbd_keyboard_drawing_set_keyboard (MatekbdKeyboardDrawing * drawing, drawing->xkbOnDisplay = TRUE; } - if (drawing->xkb == NULL) - return FALSE; + if (drawing->xkb) { + XkbSelectEventDetails (drawing->display, XkbUseCoreKbd, + XkbIndicatorStateNotify, + drawing->xkb->indicators->phys_indicators, + drawing->xkb->indicators->phys_indicators); + } alloc_cdik (drawing); |