From 89ff6549a57c72ad342601c5f9821e537d1a0626 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sat, 21 Oct 2023 16:44:07 +0100 Subject: [PATCH] edgethickness: stash value so it's monitor-aware Rather than having a global value to represent the state of edgethickness, make this a part of the monitor struct, so it can be changed per-monitor. --- doc/fvwm3_manpage_source.adoc | 16 +++++++--- fvwm/events.c | 2 +- fvwm/virtual.c | 59 +++++++++++++++++++++++++++-------- fvwm/virtual.h | 2 +- libs/FScreen.c | 3 ++ libs/FScreen.h | 4 +++ 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/doc/fvwm3_manpage_source.adoc b/doc/fvwm3_manpage_source.adoc index d22814849..1e8eeb079 100644 --- a/doc/fvwm3_manpage_source.adoc +++ b/doc/fvwm3_manpage_source.adoc @@ -7390,9 +7390,13 @@ Style * EdgeMoveResistance moving screen-scrolling + Fvwm does this substitution automatically and prints a warning. -*EdgeScroll* _horizontal_[p] _vertical_[p] [wrap | wrapx | wrapy]:: +*EdgeScroll* [_screen RANDRNAME_] _horizontal_[p] _vertical_[p] [wrap | wrapx | wrapy]:: Specifies the percentage of a page to scroll when the cursor hits the - edge of a page. A trailing '_p_' changes the interpretation to mean + edge of a page. + The optional '_screen RANDRNAME_' specifies the RandR monitor which + this setting should apply to, ignoring all other monitors. Without + this option, it applies the value to all monitors. + A trailing '_p_' changes the interpretation to mean pixels. If you do not want any paging or scrolling when you hit the edge of a page include + @@ -7426,11 +7430,15 @@ EdgeScroll 100000 100000 is used fvwm scrolls by whole pages, wrapping around at the edge of the desktop. -*EdgeThickness* 0 | 1 | 2:: +*EdgeThickness* [_screen RANDRNAME_] 0 | 1 | 2:: This is the width or height of the invisible window that fvwm creates on the edges of the screen that are used for the edge scrolling feature. + +The optional '_screen RANDRNAME_' specifies the RandR monitor which +this setting should apply to, ignoring all other monitors. Without +this option, it applies the value to all monitors. ++ In order to enable page scrolling via the mouse, four windows called the "pan frames" are placed at the very edge of the screen. This is how fvwm detects the mouse's presence at the window edge. Because of @@ -9355,4 +9363,4 @@ refer to the COPYING file that came with fvwm for details. Bug reports can be sent to the fvwm-workers mailing list at -The official fvwm homepage is _http://fvwm.org/_. +The official fvwm homepage is _http://fvwm.org/_. \ No newline at end of file diff --git a/fvwm/events.c b/fvwm/events.c index 101eb27ca..c637ead3c 100644 --- a/fvwm/events.c +++ b/fvwm/events.c @@ -4186,7 +4186,7 @@ void dispatch_event(XEvent *e) XRRUpdateConfiguration(e); monitor_update_ewmh(); monitor_emit_broadcast(); - initPanFrames(); + initPanFrames(NULL); break; } } diff --git a/fvwm/virtual.c b/fvwm/virtual.c index 370539af9..74c116a1a 100644 --- a/fvwm/virtual.c +++ b/fvwm/virtual.c @@ -114,10 +114,6 @@ * * 2 is the default. */ -static int edge_thickness = 2; -static int last_edge_thickness = 2; -static bool pan_frames_mapped = false; - static void store_desktop_cmd(int, char *); static int number_of_desktops(struct monitor *); static void init_one_panframe(PanFrame *, int, int, int, int, int); @@ -735,6 +731,7 @@ int HandlePaging( static Bool is_last_position_valid = False; struct monitor *m = monitor_get_current(); int mwidth, mheight; + int edge_thickness = m->virtual_scr.edge_thickness; mwidth = monitor_get_all_widths(); mheight = monitor_get_all_heights(); @@ -1049,10 +1046,14 @@ void checkPanFrames(struct monitor *m) int x = m->si->x; int y = m->si->y; + int edge_thickness = m->virtual_scr.edge_thickness; + int last_edge_thickness = m->virtual_scr.last_edge_thickness; if (!Scr.flags.are_windows_captured) return; + fvwm_debug(__func__, "CONSIDERING PANFRAME: %s", m->si->name); + /* thickness of 0 means remove the pan frames */ if (edge_thickness == 0) { @@ -1294,14 +1295,20 @@ init_one_panframe(PanFrame *pf, int x, int y, int w, int h, int cursor) * Creates the windows for edge-scrolling * */ -void initPanFrames(void) +void initPanFrames(struct monitor *ref) { int saved_thickness; - struct monitor *m; + int edge_thickness; + struct monitor *m = NULL; - if (pan_frames_mapped) + if (ref == NULL) return; + if (ref->pan_frames_mapped) + return; + + edge_thickness = ref->virtual_scr.edge_thickness; + /* Not creating the frames disables all subsequent behavior */ /* TKP. This is bad, it will cause an XMap request on a null window * later*/ @@ -1315,6 +1322,9 @@ void initPanFrames(void) /* Free panframes here for all monitors. */ fvwm_debug(__func__, "freeing panframes"); TAILQ_FOREACH(m, &monitor_q, entry) { + if (ref != NULL && m != ref) + continue; + fvwm_debug(__func__, "CONSIDERING FREEING: %s", m->si->name); if (m->PanFrameLeft.isMapped) { XUnmapWindow(dpy, m->PanFrameLeft.win); @@ -1338,6 +1348,9 @@ void initPanFrames(void) } TAILQ_FOREACH(m, &monitor_q, entry) { + if (ref != NULL && m != ref) + continue; + fvwm_debug(__func__, "CONSIDERING ADDING: %s", m->si->name); init_one_panframe(&m->PanFrameTop, m->si->x, m->si->y, m->si->w, edge_thickness, CRS_TOP_EDGE); init_one_panframe(&m->PanFrameLeft, m->si->x, m->si->y, @@ -1353,8 +1366,8 @@ void initPanFrames(void) m->PanFrameRight.isMapped= m->PanFrameBottom.isMapped=false; checkPanFrames(m); } - edge_thickness = saved_thickness; - pan_frames_mapped = true; + ref->virtual_scr.edge_thickness = saved_thickness; + ref->pan_frames_mapped = true; fvwm_debug(__func__, "finished setting up per-monitor panframes"); } @@ -2049,7 +2062,7 @@ void parse_edge_leave_command(char *action, int type) if ((option = PeekToken(action, NULL)) != NULL) command = action; - initPanFrames(); + initPanFrames(NULL); TAILQ_FOREACH(m_loop, &monitor_q, entry) { char **target; @@ -2114,6 +2127,23 @@ void CMD_EdgeLeaveCommand(F_CMD_ARGS) void CMD_EdgeThickness(F_CMD_ARGS) { int val, n; + char *option; + struct monitor *m = NULL, *m_loop = NULL; + + option = PeekToken(action, NULL); + if (StrEquals(option, "screen")) { + /* Skip literal 'screen' */ + option = PeekToken(action, &action); + /* Actually get the screen value. */ + option = PeekToken(action, &action); + + if ((m = monitor_resolve_name(option)) == NULL) { + fvwm_debug(__func__, "Invalid screen: %s", option); + return; + } + + fvwm_debug(__func__, "Only setting for %s", m->si->name); + } n = GetIntegerArguments(action, NULL, &val, 1); if (n != 1) @@ -2131,8 +2161,11 @@ void CMD_EdgeThickness(F_CMD_ARGS) " found %d",val); return; } - edge_thickness = val; - initPanFrames(); + + TAILQ_FOREACH(m_loop, &monitor_q, entry) + m_loop->virtual_scr.edge_thickness = val; + + initPanFrames(m); return; } @@ -2457,7 +2490,7 @@ void CMD_DesktopConfiguration(F_CMD_ARGS) return; update: - initPanFrames(); + initPanFrames(NULL); raisePanFrames(); ewmh_SetWorkArea(m); diff --git a/fvwm/virtual.h b/fvwm/virtual.h index 1fed0b020..82a0e9caf 100644 --- a/fvwm/virtual.h +++ b/fvwm/virtual.h @@ -11,7 +11,7 @@ int HandlePaging( XEvent *pev, position warp_size, position *p, position *delta, Bool Grab, Bool fLoop, Bool do_continue_previous, int delay); void raisePanFrames(void); -void initPanFrames(void); +void initPanFrames(struct monitor *); Bool is_pan_frame(Window w); void MoveViewport(struct monitor *, int newx, int newy,Bool); void goto_desk(int desk, struct monitor *); diff --git a/libs/FScreen.c b/libs/FScreen.c index 77c695279..ce85c7117 100644 --- a/libs/FScreen.c +++ b/libs/FScreen.c @@ -470,7 +470,10 @@ scan_screens(Display *dpy) m->flags |= MONITOR_NEW; m->si = screen_info_new(); m->si->name = strdup(name); + memset(&m->virtual_scr, 0, sizeof(m->virtual_scr)); + m->virtual_scr.edge_thickness = 2; + m->virtual_scr.last_edge_thickness = 2; TAILQ_INSERT_TAIL(&screen_info_q, m->si, entry); TAILQ_INSERT_TAIL(&monitor_q, m, entry); diff --git a/libs/FScreen.h b/libs/FScreen.h index 833e9cc2e..a0f3996ee 100644 --- a/libs/FScreen.h +++ b/libs/FScreen.h @@ -117,6 +117,9 @@ struct monitor { int Vx; int Vy; + int edge_thickness; + int last_edge_thickness; + int EdgeScrollX; int EdgeScrollY; @@ -135,6 +138,7 @@ struct monitor { PanFrame PanFrameLeft; PanFrame PanFrameRight; PanFrame PanFrameBottom; + bool pan_frames_mapped; TAILQ_ENTRY(monitor) entry; };