Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few FvwmPager fixes #980

Merged
merged 3 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions modules/FvwmPager/FvwmPager.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ char *BalloonFont = NULL;
char *BalloonBorderColor = NULL;
char *BalloonFormatString = NULL;
char *monitor_to_track = NULL;
char *preferred_monitor = NULL;
int BalloonBorderWidth = 1;
int BalloonYOffset = 3;
Window BalloonView = None;
Expand Down Expand Up @@ -177,6 +178,14 @@ void fpmonitor_disable(struct fpmonitor *fp)
for (int i = 0; i < ndesks; i++) {
XMoveWindow(dpy, fp->CPagerWin[i], -32768,-32768);
}

if (monitor_to_track != NULL &&
strcmp(monitor_to_track, fp->m->si->name) == 0)
{
free(monitor_to_track);
struct fpmonitor *tm = fpmonitor_this(NULL);
monitor_to_track = fxstrdup(tm->m->si->name);
}
}

struct fpmonitor *
Expand Down Expand Up @@ -1573,6 +1582,17 @@ void list_config_info(unsigned long *body)
fp->m->flags |= MONITOR_NEW;
}

/* This ensures that if monitor_to_track gets disconnected
* then reconnected, the pager can resume tracking it.
*/
if (preferred_monitor != NULL &&
strcmp(fp->m->si->name, preferred_monitor) == 0 &&
strcmp(preferred_monitor, monitor_to_track) != 0)
{
if (monitor_to_track != NULL)
free(monitor_to_track);
monitor_to_track = fxstrdup(preferred_monitor);
}
fp->disabled = false;
fp->scr_width = scr_width;
fp->scr_height = scr_height;
Expand Down Expand Up @@ -1935,6 +1955,9 @@ ImagePath = NULL;
}
fvwm_debug(__func__, "Assigning monitor: %s\n", m->m->si->name);
monitor_to_track = fxstrdup(m->m->si->name);
if (preferred_monitor != NULL)
free(preferred_monitor);
preferred_monitor = fxstrdup(monitor_to_track);
} else if(StrEquals(resource, "DeskLabels")) {
use_desk_label = True;
} else if(StrEquals(resource, "NoDeskLabels")) {
Expand Down Expand Up @@ -2492,5 +2515,7 @@ void ExitPager(void)
XSync(dpy,0);
}
XUngrabKeyboard(dpy, CurrentTime);
free(monitor_to_track);
free(preferred_monitor);
exit(0);
}
2 changes: 1 addition & 1 deletion modules/FvwmPager/x_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static struct fpmonitor *fpmonitor_from_xy(int x, int y)
static rectangle CalcGeom(PagerWindow *t, bool is_icon)
{
/* Place initial rectangle off screen. */
rectangle rec = {-32768, -32768, 0, 0};
rectangle rec = {-32768, -32768, MinSize, MinSize};
struct fpmonitor *fp = fpmonitor_this(NULL);

/* If the monitor we expect to find is disabled, then
Expand Down
Loading