Guest User

awesome: prefere 16px icons - patch

a guest
Feb 5th, 2014
516
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- ewmh.c_a    2014-01-20 17:39:11.238913114 +0400
  2. +++ ewmh.c  2014-01-20 22:49:51.560952817 +0400
  3. @@ -620,6 +620,8 @@
  4.  ewmh_window_icon_from_reply(xcb_get_property_reply_t *r)
  5.  {
  6.      uint32_t *data;
  7. +    uint64_t move;
  8. +    uint32_t *selected_data;
  9.      uint64_t len;
  10.  
  11.      if(!r || r->type != XCB_ATOM_CARDINAL || r->format != 32 || r->length < 2)
  12. @@ -633,11 +635,26 @@
  13.       * overflow. <uint32_t> times <another uint32_t casted to uint64_t> always
  14.       * fits into an uint64_t and thus this multiplication cannot overflow.
  15.       */
  16. -    len = data[0] * (uint64_t) data[1];
  17. -    if (!data[0] || !data[1] || len > r->length - 2)
  18. -        return 0;
  19. +    selected_data = 0;
  20. +    move = 0;
  21. +
  22. +    do {
  23. +        len = data[0] * (uint64_t) data[1];
  24. +        if (!data[0] || !data[1] || len+move+2 > r->length) {
  25. +            if(!selected_data) return 0;
  26. +            else break;
  27. +        }
  28. +        if (data[0] == 16) {
  29. +            selected_data = data;
  30. +            break;
  31. +        }
  32. +        if (!selected_data)
  33. +            selected_data = data;
  34. +        move += len + 2;
  35. +        data += move;
  36. +    } while(move+2 < r->length);
  37.  
  38. -    return draw_surface_from_data(data[0], data[1], data + 2);
  39. +    return draw_surface_from_data(selected_data[0], selected_data[1], selected_data + 2);
  40.  }
  41.  
  42.  /** Get NET_WM_ICON.
RAW Paste Data