Adding sortscreens patch

This commit is contained in:
bakkeby 2019-10-07 22:56:53 +02:00
parent fc28c6a7b2
commit 2612060419
7 changed files with 46 additions and 0 deletions

View File

@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2019-10-07 - Added sortscreens patch
2019-10-06 - Added statuscolors and statusallmons patches, fixed minor cross-compatibility issues for killunsel, fullscreen, noborder, tagintostack patches
2019-10-05 - Added killunsel, taggrid, hidevacanttags and cmdcustomize patches
@ -192,6 +194,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [setborderpx](https://dwm.suckless.org/patches/statuspadding/)
- this patch allows border pixels to be changed during runtime
- [sortscreens](https://www.mail-archive.com/hackers@suckless.org/msg09400.html)
- this patch aims to address some inconsistencies when it comes to focusmon, tagmon and similar functionality by explicitly sorting screens left to right (or top to bottom in a vertical layout)
- [statusallmons](https://dwm.suckless.org/patches/statuspadding/)
- this patch draws and updates the statusbar on all monitors

3
dwm.c
View File

@ -3104,6 +3104,9 @@ updategeom(void)
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
XFree(info);
nn = j;
#if SORTSCREENS_PATCH
sortscreens(unique, nn);
#endif // SORTSCREENS_PATCH
if (n <= nn) { /* new monitors available */
for (i = 0; i < (nn - n); i++) {
for (m = mons; m && m->next; m = m->next);

View File

@ -94,6 +94,12 @@
#include "setborderpx.c"
#endif
#ifdef XINERAMA
#if SORTSCREENS_PATCH
#include "sortscreens.c"
#endif
#endif
#if STICKY_PATCH
#include "sticky.c"
#endif

View File

@ -94,6 +94,12 @@
#include "setborderpx.h"
#endif
#ifdef XINERAMA
#if SORTSCREENS_PATCH
#include "sortscreens.h"
#endif
#endif
#if STICKY_PATCH
#include "sticky.h"
#endif

15
patch/sortscreens.c Normal file
View File

@ -0,0 +1,15 @@
void
sortscreens(XineramaScreenInfo *screens, int n)
{
int i, j;
XineramaScreenInfo *screen = ecalloc(1, sizeof(XineramaScreenInfo));
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
if (RIGHTOF(screens[i], screens[j])) {
memcpy(&screen[0], &screens[i], sizeof(XineramaScreenInfo));
memcpy(&screens[i], &screens[j], sizeof(XineramaScreenInfo));
memcpy(&screens[j], &screen[0], sizeof(XineramaScreenInfo));
}
XFree(screen);
}

3
patch/sortscreens.h Normal file
View File

@ -0,0 +1,3 @@
#define RIGHTOF(a,b) (a.y_org > b.y_org) || ((a.y_org == b.y_org) && (a.x_org > b.x_org))
static void sortscreens(XineramaScreenInfo *screens, int n);

View File

@ -298,6 +298,14 @@
*/
#define SETBORDERPX_PATCH 0
/* In a multi-head setup monitor 0 is by default the primary screen, with the left and right
* screen being monitor 1 and 2 respectively. This patch sorts screens left to right (or
* top to bottom in a vertical layout) which aims to address some inconsistencies when it
* comes to focusmon, tagmon and similar functionality.
* https://www.mail-archive.com/hackers@suckless.org/msg09400.html
*/
#define SORTSCREENS_PATCH 0
/* This patch draws and updates the statusbar on all monitors.
* https://dwm.suckless.org/patches/statusallmons/
*/