Sort RandR outputs too

This commit is contained in:
LemonBoy 2014-02-17 14:46:26 +00:00
parent 81ef4a8eb7
commit a66f6bb097

8
bar.c
View File

@ -402,12 +402,13 @@ rect_sort_cb (const void *p1, const void *p2)
void void
get_randr_outputs(void) get_randr_outputs(void)
{ {
int i, j, num, cnt = 0;
xcb_generic_error_t *err; xcb_generic_error_t *err;
xcb_randr_get_screen_resources_current_cookie_t rres_query; xcb_randr_get_screen_resources_current_cookie_t rres_query;
xcb_randr_get_screen_resources_current_reply_t *rres_reply; xcb_randr_get_screen_resources_current_reply_t *rres_reply;
xcb_randr_output_t *outputs; xcb_randr_output_t *outputs;
xcb_timestamp_t config_timestamp; xcb_timestamp_t config_timestamp;
int i, j, num, cnt = 0;
int width = cfg.width;
rres_query = xcb_randr_get_screen_resources_current(c, scr->root); rres_query = xcb_randr_get_screen_resources_current(c, scr->root);
rres_reply = xcb_randr_get_screen_resources_current_reply(c, rres_query, &err); rres_reply = xcb_randr_get_screen_resources_current_reply(c, rres_query, &err);
@ -483,7 +484,8 @@ get_randr_outputs(void)
return; return;
} }
int width = cfg.width; /* Sort by X */
qsort(rects, cnt, sizeof(xcb_rectangle_t), rect_sort_cb);
for (i = j = 0; i < num && j < cnt; i++) { for (i = j = 0; i < num && j < cnt; i++) {
if (rects[i].width) { if (rects[i].width) {
@ -532,7 +534,7 @@ get_xinerama_screens (void)
screens = i; screens = i;
/* Sort by X */ /* Sort by X */
qsort(rects, i, sizeof(xcb_rectangle_t), rect_sort_cb); qsort(rects, screens, sizeof(xcb_rectangle_t), rect_sort_cb);
/* The width is consumed across all the screens */ /* The width is consumed across all the screens */
for (i = 0; i < screens; i++) { for (i = 0; i < screens; i++) {