sortscreens.c (612B)
1 void 2 sortscreens(XineramaScreenInfo *screens, int n) 3 { 4 int i, j; 5 XineramaScreenInfo *screen = ecalloc(1, sizeof(XineramaScreenInfo)); 6 7 for (i = 0; i < n; i++) 8 for (j = i + 1; j < n; j++) 9 if (RIGHTOF(screens[i], screens[j])) { 10 memcpy(&screen[0], &screens[i], sizeof(XineramaScreenInfo)); 11 memcpy(&screens[i], &screens[j], sizeof(XineramaScreenInfo)); 12 memcpy(&screens[j], &screen[0], sizeof(XineramaScreenInfo)); 13 } 14 XFree(screen); 15 } 16