Skip to content

Commit

Permalink
edgethickness: stash value so it's monitor-aware
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ThomasAdam committed Oct 22, 2023
1 parent a8a4a6c commit c55b45c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 26 deletions.
16 changes: 12 additions & 4 deletions doc/fvwm3_manpage_source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
+
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
<fvwm-workers@fvwm.org>

The official fvwm homepage is _http://fvwm.org/_.
The official fvwm homepage is _http://fvwm.org/_.
2 changes: 1 addition & 1 deletion fvwm/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -4186,7 +4186,7 @@ void dispatch_event(XEvent *e)
XRRUpdateConfiguration(e);
monitor_update_ewmh();
monitor_emit_broadcast();
initPanFrames();
initPanFrames(NULL);
break;
}
}
Expand Down
73 changes: 53 additions & 20 deletions fvwm/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1049,6 +1046,8 @@ 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;
Expand Down Expand Up @@ -1294,14 +1293,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*/
Expand All @@ -1315,6 +1320,8 @@ 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;
if (m->PanFrameLeft.isMapped)
{
XUnmapWindow(dpy, m->PanFrameLeft.win);
Expand All @@ -1338,6 +1345,8 @@ void initPanFrames(void)
}

TAILQ_FOREACH(m, &monitor_q, entry) {
if (ref != NULL && m != ref)
continue;
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,
Expand All @@ -1353,8 +1362,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");
}

Expand Down Expand Up @@ -2049,7 +2058,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;
Expand Down Expand Up @@ -2114,6 +2123,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)
Expand All @@ -2131,10 +2157,22 @@ void CMD_EdgeThickness(F_CMD_ARGS)
" found %d",val);
return;
}
edge_thickness = val;
initPanFrames();

return;
/* If we've only been asked to change this for one monitor, stop doing
* anything else after this point, so as not to overwrite any other
* per-monitor values.
*/
if (m != NULL) {
m->virtual_scr.edge_thickness = val;
initPanFrames(m);

return;
}

TAILQ_FOREACH(m_loop, &monitor_q, entry) {
m_loop->virtual_scr.edge_thickness = val;
initPanFrames(m_loop);
}
}

void CMD_EdgeScroll(F_CMD_ARGS)
Expand Down Expand Up @@ -2217,15 +2255,10 @@ void CMD_EdgeScroll(F_CMD_ARGS)
}

TAILQ_FOREACH(m_this, &monitor_q, entry) {
if (m != NULL && m == m_this)
continue;
m_this->virtual_scr.EdgeScrollX = val1 * val1_unit / 100;
m_this->virtual_scr.EdgeScrollY = val2 * val2_unit / 100;
checkPanFrames(m_this);
}


return;
}

void CMD_EdgeResistance(F_CMD_ARGS)
Expand Down Expand Up @@ -2457,7 +2490,7 @@ void CMD_DesktopConfiguration(F_CMD_ARGS)
return;

update:
initPanFrames();
initPanFrames(NULL);
raisePanFrames();
ewmh_SetWorkArea(m);

Expand Down Expand Up @@ -3120,4 +3153,4 @@ void CMD_DesktopName(F_CMD_ARGS)

TAILQ_FOREACH(m, &monitor_q, entry)
apply_desktops_monitor(m);
}
}
2 changes: 1 addition & 1 deletion fvwm/virtual.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
3 changes: 3 additions & 0 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions libs/FScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ struct monitor {
int Vx;
int Vy;

int edge_thickness;
int last_edge_thickness;

int EdgeScrollX;
int EdgeScrollY;

Expand All @@ -135,6 +138,7 @@ struct monitor {
PanFrame PanFrameLeft;
PanFrame PanFrameRight;
PanFrame PanFrameBottom;
bool pan_frames_mapped;

TAILQ_ENTRY(monitor) entry;
};
Expand Down

0 comments on commit c55b45c

Please sign in to comment.