The following shows the diffstat and patchsets between c4d4ed4..eacaa8b^ ---------------------------------------------------------------- commit eacaa8bfcfac0a87a28ed19e6e27d6dad36dd25a Author: Thomas Adam <tho...@fvwm.org> Date: Sat Nov 1 19:46:29 2014 +0000
TODO: Add item about monitor API --- TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO b/TODO index ab5506d..2b818bd 100644 --- a/TODO +++ b/TODO @@ -89,6 +89,8 @@ Here's a very brief list of things on my immediate radar. -- Thomas Adam functionality. * Modules: + - monitor API in libs/FScreen.c to be flattened to use an enum to look for + monitor-specific information instead, rather than lots of small functions? - The module interface (FVWM <-> Module) is a mess; consider DBUS? Or imsg? - Use libevent to replace the hand-rolled (and often broken) select/poll commit 7045161a33352585226dba02fd6f8148281dd227 Author: Thomas Adam <tho...@fvwm.org> Date: Sat Nov 1 19:44:27 2014 +0000 Introduce monitor_by_number() Rather than internal APIs relying on the name of monitors when looking up various things about them, instead assign each monitor an ID which can be used internally. This will also make things easier in the longer-term when trying to streamline how RandR is going to be used, but for now this will make more sense in terms of communicating monitor information with modules. --- libs/FScreen.c | 23 +++++++++++++++++++++++ libs/FScreen.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/libs/FScreen.c b/libs/FScreen.c index 8ede234..e5b7413 100644 --- a/libs/FScreen.c +++ b/libs/FScreen.c @@ -126,6 +126,27 @@ monitor_by_name(const char *name) } struct monitor * +monitor_by_number(int number) +{ + struct monitor *m = NULL; + + TAILQ_FOREACH(m, &monitor_q, entry) { + if (m->number == number) + return (m); + } + + /* If 'm' is still NULL here, and the monitor number is -1, return + * the global monitor instead. This check can only succeed if we've + * requested the global screen whilst XRandR is in use, since the global + * monitor isn't stored in the monitor list directly. + */ + if (m == NULL && number == -1) + return (global_monitor); + + return (NULL); +} + +struct monitor * monitor_by_xy(int x, int y) { struct monitor *m; @@ -170,6 +191,7 @@ void FScreenInit(Display *dpy) global_monitor->coord.w = DisplayWidth(disp, DefaultScreen(disp)); global_monitor->coord.h = DisplayHeight(disp, DefaultScreen(disp)); global_monitor->name = mvwm_strdup("global"); + global_monitor->number = -1; if (!is_randr_present) { /* TA: 2014-09-16: We maintain a list of all monitors. If @@ -203,6 +225,7 @@ void FScreenInit(Display *dpy) m->coord.w = crtc->width; m->coord.h = crtc->height; m->name = mvwm_strdup(oinfo->name); + m->number = i; init_monitor_contents(m); diff --git a/libs/FScreen.h b/libs/FScreen.h index 1902554..fd1024e 100644 --- a/libs/FScreen.h +++ b/libs/FScreen.h @@ -29,6 +29,7 @@ typedef enum struct monitor { char *name; + int number; struct { int x; int y; @@ -69,6 +70,7 @@ struct monitor *global_monitor; struct monitor *monitor_get_current(void); struct monitor *monitor_by_name(const char *); struct monitor *monitor_by_xy(int, int); +struct monitor *monitor_by_number(int); #define FSCREEN_MANGLE_USPOS_HINTS_MAGIC ((short)-32109) ---------------------------------------------------------------- Diffstat: ---------------------------------------------------------------- TODO | 2 ++ libs/FScreen.c | 23 +++++++++++++++++++++++ libs/FScreen.h | 2 ++ 3 files changed, 27 insertions(+) ----------------------------------------------------------------