SortScreens - bakkeby/dusk GitHub Wiki

Doing a multi-head setup using other means than Xinerama may lead to XineramaQueryScreens() returning the screens in an order that does not actually represent the actual screen layout.

This in turn may result in dwm using the "wrong" monitor in monitor related functions like focusmon, tagmon and similar functionality.

This change sorts the list of unique screens by their origin to alleviate this problem.

It should be noted that typically the primary screen is the first one returned by XineramaQueryScreens() and will have the monitor index 0 and the left and right monitor ending up with 1 and 2 respectively. Under normal circumstances it should be possible to address this by controlling what is being set by xrandr.

If this functionality is used then the leftmost monitor will be monitor number 0, the middle monitor will be monitor 1 and the rightmost monitor will be number 2. Take this into account when setting up client rules.

It should be noted that the mechanism for this orders monitors based on the y-axis by default and it expects that all monitors have the same y-axis in order to sort the screens by the x-axis.

This is defined by a macro in lib/sortscreens.c:

#define RIGHTOF(a,b) (a.y_org > b.y_org) || ((a.y_org == b.y_org) && (a.x_org > b.x_org))

It is possible to overwrite this by adding your own definition in your config.h file, e.g. to always sort the screens using the x-axis from left to right one could add:

#define RIGHTOF(a,b) ((a.x_org > b.x_org))

or, if it is desirable to sort the screens from right to left then one could add:

#define RIGHTOF(a,b) ((a.x_org < b.x_org))

This functionality is not enabled by default, but can be enabled by uncommenting the SortScreens settings in config.h.

/* See util.h for options */
static uint64_t functionality = 0
...
//  |SortScreens // only applies on startup
...

Note that this will affect bar configuration and workspace rules as monitor 0 will now be the leftmost monitor rather than your primary monitor.


NB: if this functionality is enabled during runtime then this can potentially cause undefined behaviour when new screens are added and removed.


Back to Functionality.

⚠️ **GitHub.com Fallback** ⚠️