]> git.sur5r.net Git - i3/i3/blobdiff - src/bindings.c
Merge branch 'defect-1480' of https://github.com/Airblader/i3-original into Airblader...
[i3/i3] / src / bindings.c
index 0bda6019187f6f1916ac93e1b86d27aaa079384f..e7e424cc4b3a7ac89634686b6326033d0c226c7e 100644 (file)
@@ -49,10 +49,11 @@ static struct Mode *mode_from_name(const char *name) {
  *
  */
 Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code,
-                           const char *release, const char *command, const char *modename) {
+                           const char *release, const char *whole_window, const char *command, const char *modename) {
     Binding *new_binding = scalloc(sizeof(Binding));
     DLOG("bindtype %s, modifiers %s, input code %s, release %s\n", bindtype, modifiers, input_code, release);
     new_binding->release = (release != NULL ? B_UPON_KEYRELEASE : B_UPON_KEYPRESS);
+    new_binding->whole_window = (whole_window != NULL);
     if (strcmp(bindtype, "bindsym") == 0) {
         new_binding->input_type = (strncasecmp(input_code, "button", (sizeof("button") - 1)) == 0
                                        ? B_MOUSE
@@ -158,9 +159,10 @@ static Binding *get_binding(uint16_t modifiers, bool is_release, uint16_t input_
          * need to look in the array of translated keycodes for the event’s
          * keycode */
         if (input_type == B_KEYBOARD && bind->symbol != NULL) {
+            xcb_keycode_t input_keycode = (xcb_keycode_t)input_code;
             if (memmem(bind->translated_to,
                        bind->number_keycodes * sizeof(xcb_keycode_t),
-                       &input_code, sizeof(xcb_keycode_t)) == NULL)
+                       &input_keycode, sizeof(xcb_keycode_t)) == NULL)
                 continue;
         } else {
             /* This case is easier: The user specified a keycode */
@@ -386,10 +388,14 @@ void check_for_duplicate_bindings(struct context *context) {
 static Binding *binding_copy(Binding *bind) {
     Binding *ret = smalloc(sizeof(Binding));
     *ret = *bind;
-    ret->symbol = strdup(bind->symbol);
-    ret->command = strdup(bind->command);
-    ret->translated_to = smalloc(sizeof(xcb_keycode_t) * bind->number_keycodes);
-    memcpy(ret->translated_to, bind->translated_to, sizeof(xcb_keycode_t) * bind->number_keycodes);
+    if (bind->symbol != NULL)
+        ret->symbol = strdup(bind->symbol);
+    if (bind->command != NULL)
+        ret->command = strdup(bind->command);
+    if (bind->translated_to != NULL) {
+        ret->translated_to = smalloc(sizeof(xcb_keycode_t) * bind->number_keycodes);
+        memcpy(ret->translated_to, bind->translated_to, sizeof(xcb_keycode_t) * bind->number_keycodes);
+    }
     return ret;
 }