[hackers] Refactoring in updategeom and friends

From: Devin J. Pohly <djpohly_AT_gmail.com>
Date: Mon, 27 Jan 2020 07:55:56 -0600

Hi all,

I've been trying to figure out how to simplify updategeom. So far I've
been able to cut down the number of times it iterates over the mons
list, and at the same time make the code a bit shorter:

 1 file changed, 33 insertions(+), 48 deletions(-)

I'd like some input on the next part. Handling monitor geometry
currently involves four separate pieces of code:

1. Non-Xinerama monitor setup/resizing
2. Adding monitors with Xinerama (also used for initial setup)
3. Removing monitors with Xinerama
4. Cleaning up monitors in cleanup()

This patch series combines #2 and #3, but the new code is general enough
to make a "resizemons" function that unifies all four cases:

1. resizemons(&(XineramaScreenInfo) {0, 0, 0, sw, sh}, 1)
2. resizemons(XineramaQueryScreens(dpy, &n), n)
3. resizemons(XineramaQueryScreens(dpy, &n), n)
4. resizemons(NULL, 0)

The sticking point is how to use XineramaScreenInfo even if XINERAMA is
not defined. I'd be interested on the devs' opinions on whether any of
the following options looks like a palatable starting point. (I'm
leaning toward the first one.)

/* Option A */
#include <X11/extensions/Xinerama.h>
// just the fields we need
typedef struct { short x_org, y_org, width, height; } XineramaScreenInfo;
int resizemons(XineramaScreenInfo *dims, int n);

/* Option B */
typedef struct { int x, y, w, h; } Dims;
int resizemons(Dims *dims, int n);
// finding unique geoms populates a Dims[]

/* Option C */
int resizemons(int (*dims)[4], int n);
// finding unique geoms populates an int[][4]

Received on Mon Jan 27 2020 - 14:55:56 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 28 2020 - 08:00:36 CET