From b634c3029d5fa0b745b1002da89abecdc1aa14f2 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 2 Apr 2017 08:32:38 +0200 Subject: 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 --- libmatekbd/matekbd-keyboard-drawing.c | 27 +++++++++++++++------------ 1 file 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); -- cgit v1.2.1