A couple of patches for the parser branch: 0001: Some cleanup. 0002: The randr simulation patch from the other message. 0003: Fix function depth handling and an uninitialised function argument. (I.e. a crash)
Ciao Dominik ^_^ ^_^ -- Dominik Vogt
From 431a0709d2cbb82c18040957de33787572599702 Mon Sep 17 00:00:00 2001 From: Dominik Vogt <dominik.v...@gmx.de> Date: Wed, 17 Nov 2021 21:15:40 +0100 Subject: [PATCH 1/3] Cleanup. --- fvwm/cmdparser.h | 6 +++--- fvwm/cmdparser_hooks.h | 14 +++++++------- fvwm/cmdparser_old.h | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fvwm/cmdparser.h b/fvwm/cmdparser.h index 67e6ae36..53e1d2e6 100644 --- a/fvwm/cmdparser.h +++ b/fvwm/cmdparser.h @@ -1,7 +1,7 @@ /* -*-c-*- */ -#ifndef CMDPARSER_H -#define CMDPARSER_H +#ifndef FVWM_CMDPARSER_H +#define FVWM_CMDPARSER_H /* ---------------------------- included header files ---------------------- */ @@ -62,4 +62,4 @@ typedef struct char *pos_arg_tokens[CMDPARSER_NUM_POS_ARGS]; } cmdparser_context_t; -#endif /* CMDPARSER_H */ +#endif /* FVWM_CMDPARSER_H */ diff --git a/fvwm/cmdparser_hooks.h b/fvwm/cmdparser_hooks.h index f05c98d3..42330246 100644 --- a/fvwm/cmdparser_hooks.h +++ b/fvwm/cmdparser_hooks.h @@ -1,7 +1,7 @@ /* -*-c-*- */ -#ifndef CMDPARSER_HOOKS_H -#define CMDPARSER_HOOKS_H +#ifndef FVWM_CMDPARSER_HOOKS_H +#define FVWM_CMDPARSER_HOOKS_H /* ---------------------------- included header files ---------------------- */ @@ -46,7 +46,7 @@ typedef struct /* returns 1 if the stored command is a module configuration command * and 0 otherwise */ int (*is_module_config)(cmdparser_context_t *context); - /* expandeds the command line */ + /* expands the command line */ void (*expand_command_line)( cmdparser_context_t *context, int is_addto, void *func_rc, const void *exc); @@ -55,10 +55,10 @@ typedef struct void (*release_expanded_line)(cmdparser_context_t *context); /* Tries to find a builtin function, a complex function or a module * config line to execute and returns the type found or - * CP_EXECTYPE_UNKNOWN if none of the above was identified. For a - * builtin or a complex funtion the pointer to the description is + * CP_EXECTYPE_UNKNOWN if none of the above were identified. For a + * builtin or a complex function, the pointer to the description is * returned in *ret_builtin or *ret_complex_function. Consumes the - * the "Module" or the "Function" command form the input. Dos not + * the "Module" or the "Function" command from the input. Does not * consider builtin functions if *ret_builtin is != NULL when the * function is called. */ cmdparser_execute_type_t (*find_something_to_execute)( @@ -71,4 +71,4 @@ typedef struct void (*debug)(cmdparser_context_t *context, const char *msg); } cmdparser_hooks_t; -#endif /* CMDPARSER_HOOKS_H */ +#endif /* FVWM_CMDPARSER_HOOKS_H */ diff --git a/fvwm/cmdparser_old.h b/fvwm/cmdparser_old.h index 4ce61670..d2b11b47 100644 --- a/fvwm/cmdparser_old.h +++ b/fvwm/cmdparser_old.h @@ -1,11 +1,11 @@ /* -*-c-*- */ -#ifndef CMDPARSER_OLD_H -#define CMDPARSER_OLD_H +#ifndef FVWM_CMDPARSER_OLD_H +#define FVWM_CMDPARSER_OLD_H /* ---------------------------- interface functions ------------------------ */ /* return the hooks structure of the old parser */ const cmdparser_hooks_t *cmdparser_old_get_hooks(void); -#endif /* CMDPARSER_OLD_H */ +#endif /* FVWM_CMDPARSER_OLD_H */ -- 2.30.2
From c821293866fb8c56f00d8cee52b687097e5045a3 Mon Sep 17 00:00:00 2001 From: Dominik Vogt <dominik.v...@gmx.de> Date: Fri, 19 Nov 2021 02:09:28 +0100 Subject: [PATCH 2/3] Fake a global monitor when RandR is not available. --- libs/FScreen.c | 69 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/libs/FScreen.c b/libs/FScreen.c index 32ee78a7..e00af438 100644 --- a/libs/FScreen.c +++ b/libs/FScreen.c @@ -125,6 +125,13 @@ monitor_refresh_global(void) monitor_global = monitor_new(); monitor_global->si = screen_info_new(); monitor_global->si->name = fxstrdup(GLOBAL_SCREEN_NAME); + if (!is_randr_present) + { + TAILQ_INSERT_TAIL( + &screen_info_q, monitor_global->si, entry); + TAILQ_INSERT_TAIL( + &monitor_q, monitor_global, entry); + } } /* At this point, the global screen has been initialised. Refresh the @@ -342,8 +349,12 @@ monitor_assign_virtual(struct monitor *ref) void FScreenSelect(Display *dpy) { - XRRSelectInput(disp, DefaultRootWindow(disp), - RRScreenChangeNotifyMask | RROutputChangeNotifyMask); + if (is_randr_present) + { + XRRSelectInput( + disp, DefaultRootWindow(disp), + RRScreenChangeNotifyMask | RROutputChangeNotifyMask); + } } void @@ -352,6 +363,10 @@ monitor_output_change(Display *dpy, XRRScreenChangeNotifyEvent *e) XRRScreenResources *res; struct monitor *m = NULL; + if (!is_randr_present) + { + return; + } fvwm_debug(__func__, "%s: outputs have changed\n", __func__); if ((res = XRRGetScreenResources(dpy, e->root)) == NULL) { @@ -511,18 +526,19 @@ void FScreenInit(Display *dpy) if (!XRRQueryExtension(dpy, &randr_event, &err_base) || !XRRQueryVersion (dpy, &major, &minor)) { fvwm_debug(__func__, "RandR not present"); - goto randr_fail; + goto no_randr; } if (major == 1 && minor >= 5) + { is_randr_present = true; - - - if (!is_randr_present) { + } + else + { /* Something went wrong. */ fvwm_debug(__func__, "Couldn't initialise XRandR: %s\n", strerror(errno)); - goto randr_fail; + goto no_randr; } fvwm_debug(__func__, "Using RandR %d.%d\n", major, minor); @@ -533,13 +549,21 @@ void FScreenInit(Display *dpy) if (res == NULL || (res != NULL && res->noutput == 0)) { XRRFreeScreenResources(res); fvwm_debug(__func__, "RandR present, yet no outputs found."); - goto randr_fail; + is_randr_present = false; + goto no_randr; } XRRFreeScreenResources(res); scan_screens(dpy); + no_randr: is_tracking_shared = false; + if (!is_randr_present) + { + fprintf(stderr, "Unable to initialise RandR\n"); + monitor_refresh_global(); + } + TAILQ_FOREACH(m, &monitor_q, entry) { m->Desktops = fxcalloc(1, sizeof *m->Desktops); m->Desktops->name = NULL; @@ -552,10 +576,6 @@ void FScreenInit(Display *dpy) monitor_check_primary(); return; - -randr_fail: - fprintf(stderr, "Unable to initialise RandR\n"); - exit(101); } void @@ -620,6 +640,10 @@ monitor_get_count(void) struct monitor *m = NULL; int c = 0; + if (!is_randr_present) + { + return 1; + } TAILQ_FOREACH(m, &monitor_q, entry) { if (m->flags & MONITOR_DISABLED) continue; @@ -755,7 +779,18 @@ FScreenOfPointerXY(int x, int y) Bool FScreenGetScrRect(fscreen_scr_arg *arg, fscreen_scr_t screen, int *x, int *y, int *w, int *h) { - struct monitor *m = FindScreen(arg, screen); + struct monitor *m; + + if (is_randr_present) + { + m = FindScreen(arg, screen); + } + else + { + /* make sure a monitor exists */ + monitor_check_primary(); + m = monitor_global; + } if (m == NULL) { fvwm_debug(__func__, "%s: m is NULL\n", __func__); return (True); @@ -895,10 +930,10 @@ void FScreenGetResistanceRect( Bool FScreenIsRectangleOnScreen(fscreen_scr_arg *arg, fscreen_scr_t screen, rectangle *rec) { - int sx; - int sy; - int sw; - int sh; + int sx = 0; + int sy = 0; + int sw = 0; + int sh = 0; FScreenGetScrRect(arg, screen, &sx, &sy, &sw, &sh); -- 2.30.2
From f72aa4f1f6dd2bd64778820c8f931977613149eb Mon Sep 17 00:00:00 2001 From: Dominik Vogt <dominik.v...@gmx.de> Date: Fri, 19 Nov 2021 02:48:10 +0100 Subject: [PATCH 3/3] Fix function depth handling. --- fvwm/cmdparser_old.c | 5 +++-- fvwm/fvwm3.c | 2 +- fvwm/read.h | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fvwm/cmdparser_old.c b/fvwm/cmdparser_old.c index 6d01682d..876f5967 100644 --- a/fvwm/cmdparser_old.c +++ b/fvwm/cmdparser_old.c @@ -115,16 +115,17 @@ static int ocp_create_context( /*!!!should this be in handle_line_start instead???*/ if (caller_c != NULL) { - if (dest_c->call_depth > MAX_FUNCTION_DEPTH) + if (caller_c->call_depth >= MAX_FUNCTION_DEPTH) { fvwm_debug( __func__, "called with a depth of %i, " "stopping function execution!", - dest_c->call_depth); + caller_c->call_depth); return -1; } + dest_c->call_depth = caller_c->call_depth + 1; } else { diff --git a/fvwm/fvwm3.c b/fvwm/fvwm3.c index 031e5763..ff65ad75 100644 --- a/fvwm/fvwm3.c +++ b/fvwm/fvwm3.c @@ -2494,7 +2494,7 @@ int main(int argc, char **argv) xasprintf(&cfg_loc[++nl], "%s/default-config/config", FVWM_DATADIR); for (nl = 0; nl < upper; nl++) { - if (!run_command_file(cfg_loc[nl], exc)) { + if (!run_command_file(cfg_loc[nl], exc, NULL)) { fvwm_debug(__func__, "couldn't find/load [%d]: %s\n", nl, cfg_loc[nl]); tries++; diff --git a/fvwm/read.h b/fvwm/read.h index 0b7d2618..d42f9ca6 100644 --- a/fvwm/read.h +++ b/fvwm/read.h @@ -4,6 +4,7 @@ #include <stdio.h> #include "condrc.h" #include "execcontext.h" +#include "cmdparser.h" /** * Full pathname of file read in progress, or NULL. @@ -30,6 +31,7 @@ void run_command_stream( * fvwm_userdir (set in main()) or in FVWM_DATADIR. Return 1 * if the file was found and executed. **/ -int run_command_file(char *filename, const exec_context_t *exc); +int run_command_file( + char *filename, const exec_context_t *exc, cmdparser_context_t *pc); #endif -- 2.30.2