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

Ensure a window's monitor is defined when placing it. #1101

Merged
merged 1 commit into from
Nov 7, 2024
Merged
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
27 changes: 14 additions & 13 deletions fvwm/placement.c
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,13 @@ static int _place_window(
reason->screen.screen = "current";
}

/* JS: Now that StartsOnScren has been processed, ensure a monitor
* is set here to avoid a possible crash with broadcasting the new
* window and to avoid checking the monitor is defined below.
*/
if (fw->m == NULL)
fw->m = monitor_get_current();

if (SPLACEMENT_MODE(&pstyle->flags) != PLACE_MINOVERLAPPERCENT &&
SPLACEMENT_MODE(&pstyle->flags) != PLACE_MINOVERLAP &&
SPLACEMENT_MODE(&pstyle->flags) != PLACE_POSITION)
Expand All @@ -1822,8 +1829,7 @@ static int _place_window(
/* Don't alter the existing desk location during Capture/Recapture. */
if (!win_opts->flags.do_override_ppos)
{
struct monitor *m = fw->m ? fw->m : monitor_get_current();
fw->Desk = m->virtual_scr.CurrentDesk;
fw->Desk = fw->m->virtual_scr.CurrentDesk;
reason->desk.reason = PR_DESK_CURRENT;
}
else
Expand All @@ -1832,8 +1838,7 @@ static int _place_window(
}
if (S_IS_STICKY_ACROSS_DESKS(SFC(pstyle->flags)))
{
struct monitor *m = fw->m ? fw->m : monitor_get_current();
fw->Desk = m->virtual_scr.CurrentDesk;
fw->Desk = fw->m->virtual_scr.CurrentDesk;
reason->desk.reason = PR_DESK_STICKY;
}
else if (SUSE_START_ON_DESK(&pstyle->flags) && start_style.desk &&
Expand Down Expand Up @@ -1930,13 +1935,11 @@ static int _place_window(
/* RBW - 11/02/1998 -- I dont. */
if (!is_tracking_shared && !win_opts->flags.do_override_ppos && !DO_NOT_SHOW_ON_MAP(fw))
{
struct monitor *m = fw->m ? fw->m : monitor_get_current();

if (m->virtual_scr.CurrentDesk != fw->Desk)
if (fw->m->virtual_scr.CurrentDesk != fw->Desk)
{
reason->desk.do_switch_desk = 1;
}
goto_desk(fw->Desk, m);
goto_desk(fw->Desk, fw->m);
}
/* Don't move viewport if SkipMapping, or if recapturing the window,
* adjust the coordinates later. Otherwise, just switch to the target
Expand All @@ -1949,8 +1952,6 @@ static int _place_window(
{
if (start_style.page_x != 0 && start_style.page_y != 0)
{
struct monitor *m = (fw && fw->m) ? fw->m :
monitor_get_current();
px = start_style.page_x - 1;
py = start_style.page_y - 1;
reason->page.reason = PR_PAGE_STYLE;
Expand All @@ -1959,14 +1960,14 @@ static int _place_window(
if (!win_opts->flags.do_override_ppos &&
!DO_NOT_SHOW_ON_MAP(fw))
{
MoveViewport(m, px,py,True);
MoveViewport(fw->m, px, py, True);
reason->page.do_switch_page = 1;
}
else if (flags.do_honor_starts_on_page)
{
/* Save the delta from current page */
pdeltax = m->virtual_scr.Vx - px;
pdeltay = m->virtual_scr.Vy - py;
pdeltax = fw->m->virtual_scr.Vx - px;
pdeltay = fw->m->virtual_scr.Vy - py;
reason->page.do_honor_starts_on_page = 1;
}
}
Expand Down
Loading