Add keyboard/rebindOnMappingNotify option
authorMikael Magnusson <mikachu@gmail.com>
Sat, 22 Feb 2014 20:37:29 +0000 (21:37 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Sat, 22 Feb 2014 20:37:29 +0000 (21:37 +0100)
I have to switch to a qwerty layout to play steam games, and every time
I switch back and forth, we lose some random bindings so I also had to
reconfigure Openbox every time, now I don't.

openbox/config.c
openbox/config.h
openbox/event.c

index a1b9f96..492781d 100644 (file)
@@ -83,8 +83,9 @@ guint           config_dock_show_delay;
 guint           config_dock_app_move_button;
 guint           config_dock_app_move_modifiers;
 
 guint           config_dock_app_move_button;
 guint           config_dock_app_move_modifiers;
 
-guint config_keyboard_reset_keycode;
-guint config_keyboard_reset_state;
+guint    config_keyboard_reset_keycode;
+guint    config_keyboard_reset_state;
+gboolean config_keyboard_rebind_on_mapping_notify;
 
 gint     config_mouse_threshold;
 gint     config_mouse_dclicktime;
 
 gint     config_mouse_threshold;
 gint     config_mouse_dclicktime;
@@ -510,6 +511,9 @@ static void parse_keyboard(xmlNodePtr node, gpointer d)
             parse_key(n, NULL);
             n = obt_xml_find_node(n->next, "keybind");
         }
             parse_key(n, NULL);
             n = obt_xml_find_node(n->next, "keybind");
         }
+
+    if ((n = obt_xml_find_node(node->children, "rebindOnMappingNotify")))
+        config_keyboard_rebind_on_mapping_notify = obt_xml_node_bool(n);
 }
 
 /*
 }
 
 /*
@@ -1149,6 +1153,7 @@ void config_startup(ObtXmlInst *i)
 
     translate_key("C-g", &config_keyboard_reset_state,
                   &config_keyboard_reset_keycode);
 
     translate_key("C-g", &config_keyboard_reset_state,
                   &config_keyboard_reset_keycode);
+    config_keyboard_rebind_on_mapping_notify = TRUE;
 
     bind_default_keyboard();
 
 
     bind_default_keyboard();
 
index 26bd2b2..f778f84 100644 (file)
@@ -180,6 +180,8 @@ extern guint config_desktop_popup_time;
 extern guint config_keyboard_reset_keycode;
 /*! The modifiers of the key combo which resets the keybaord chains */
 extern guint config_keyboard_reset_state;
 extern guint config_keyboard_reset_keycode;
 /*! The modifiers of the key combo which resets the keybaord chains */
 extern guint config_keyboard_reset_state;
+/*! Reload the keyboard bindings when the mapping changes */
+extern gboolean config_keyboard_rebind_on_mapping_notify;
 
 /*! Number of pixels a drag must go before being considered a drag */
 extern gint config_mouse_threshold;
 
 /*! Number of pixels a drag must go before being considered a drag */
 extern gint config_mouse_threshold;
index ecbdb90..9300fa5 100644 (file)
@@ -638,11 +638,13 @@ static void event_process(const XEvent *ec, gpointer data)
     else if (e->type == MappingNotify) {
         /* keyboard layout changes for modifier mapping changes. reload the
            modifier map, and rebind all the key bindings as appropriate */
     else if (e->type == MappingNotify) {
         /* keyboard layout changes for modifier mapping changes. reload the
            modifier map, and rebind all the key bindings as appropriate */
-        ob_debug("Keyboard map changed. Reloading keyboard bindings.");
-        ob_set_state(OB_STATE_RECONFIGURING);
-        obt_keyboard_reload();
-        keyboard_rebind();
-        ob_set_state(OB_STATE_RUNNING);
+        if (config_keyboard_rebind_on_mapping_notify) {
+            ob_debug("Keyboard map changed. Reloading keyboard bindings.");
+            ob_set_state(OB_STATE_RECONFIGURING);
+            obt_keyboard_reload();
+            keyboard_rebind();
+            ob_set_state(OB_STATE_RUNNING);
+        }
     }
     else if (e->type == ClientMessage) {
         /* This is for _NET_WM_REQUEST_FRAME_EXTENTS messages. They come for
     }
     else if (e->type == ClientMessage) {
         /* This is for _NET_WM_REQUEST_FRAME_EXTENTS messages. They come for