From 9ed98a90e1917dadce6ac0acf95c07a7f8ceebc0 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sat, 14 Dec 2024 13:55:21 +0000 Subject: [PATCH 1/2] cursorbarrier: forward-declare functions Make sure we forward-declare the use of the cursor barrier function, so as to not rely on the order the functions have been declared. This will be relevant for subsequent changes. --- fvwm/cursor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fvwm/cursor.c b/fvwm/cursor.c index 4f70c2b86..593599642 100644 --- a/fvwm/cursor.c +++ b/fvwm/cursor.c @@ -41,6 +41,11 @@ #ifdef HAVE_XFIXES #include #define MAX_BARRIERS 16 +void create_barrier(int, int, int, int); +void destroy_barrier(int); +void destroy_all_barriers(void); +void destroy_barrier_n(int); + PointerBarrier barriers_l[MAX_BARRIERS]; PointerBarrier barriers_r[MAX_BARRIERS]; PointerBarrier barriers_t[MAX_BARRIERS]; @@ -110,6 +115,7 @@ void destroy_barrier_n(int n) #else #define create_barrier(a, b, c, d) +#define destroy_barrier(n); #define destroy_all_barriers() #define destroy_barrier_n(a) #endif From ff5cfd3924d914b70228a1ac57e154564011b47c Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sat, 14 Dec 2024 13:56:25 +0000 Subject: [PATCH 2/2] cursorbarrier: destroy barriers if MAX_BARRIERS is reached Make sure we destroy all the defined barriers if MAX_BARRIERS is reached. --- doc/fvwm3_manpage_source.adoc | 4 ++++ fvwm/cursor.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/fvwm3_manpage_source.adoc b/doc/fvwm3_manpage_source.adoc index cb6f8d94b..9a02bd2ff 100644 --- a/doc/fvwm3_manpage_source.adoc +++ b/doc/fvwm3_manpage_source.adoc @@ -4305,6 +4305,10 @@ Pick CursorBarrier coords $[w.x]p $[w.y]p \ CursorBarrier destroy .... + +Note that if the CURSOR_BARRIER limit is hit, _all_ defined CursorBarriers +are undefined. In pratice, this is unlikely to happen though. If it does, a +message is printed to fvwm3's debug logs. ++ _CursorBarrier_ only works if fvwm is complied with the XFixes extension. *CursorMove* _horizontal_[p] _vertical_[p]:: diff --git a/fvwm/cursor.c b/fvwm/cursor.c index 593599642..70059a48f 100644 --- a/fvwm/cursor.c +++ b/fvwm/cursor.c @@ -55,7 +55,8 @@ int num_barriers = 0; void create_barrier(int x1, int y1, int x2, int y2) { if (num_barriers >= MAX_BARRIERS) { - fvwm_debug(__func__, "Too many barriers. Aborting."); + fvwm_debug(__func__, "Too many barriers. Freeing previous..."); + destroy_all_barriers(); return; }