Skip to content

Commit

Permalink
Refactor update_fvwm_monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
somiaj committed Apr 6, 2024
1 parent 04bfb87 commit afca06e
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions fvwm/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,47 +665,48 @@ void apply_decor_change(FvwmWindow *fw)
Bool update_fvwm_monitor(FvwmWindow *fw)
{
rectangle g;
bool monitor_change = false;
struct monitor *mnew;

g = IS_MAXIMIZED(fw) ? fw->g.max : fw->g.normal;
mnew = FindScreenOfXY(g.x, g.y);

/* Avoid unnecessary updates. */
if (mnew != fw->m) {
fw->m_prev = fw->m;
fw->m = mnew;
monitor_change = true;
} else if (fw->UpdateDesk < 0) {
if (mnew == fw->m && fw->UpdateDesk < 0)
return False;

if (fw->UpdateDesk < 0) {
fw->Desk = mnew->virtual_scr.CurrentDesk;
goto out;
}

if (fw->UpdateDesk >= 0) {
int old_desk, new_desk;
old_desk = new_desk = mnew->virtual_scr.CurrentDesk;
if (monitor_change && fw->m_prev != NULL)
old_desk = fw->m_prev->virtual_scr.CurrentDesk;
int old_desk, new_desk;
old_desk = new_desk = mnew->virtual_scr.CurrentDesk;
if (fw->m != mnew)
old_desk = fw->m->virtual_scr.CurrentDesk;

/* Map/Unmap windows based on their final destination. */
if (fw->Desk == old_desk && fw->UpdateDesk != new_desk)
{
unmap_window(fw);
SET_FULLY_VISIBLE(fw, 0);
SET_PARTIALLY_VISIBLE(fw, 0);
}
else if (fw->Desk != old_desk && fw->UpdateDesk == new_desk)
/* Map/Unmap windows based on their final destination. */
if (fw->Desk == old_desk && fw->UpdateDesk != new_desk)
{
unmap_window(fw);
SET_FULLY_VISIBLE(fw, 0);
SET_PARTIALLY_VISIBLE(fw, 0);
}
else if (fw->Desk != old_desk && fw->UpdateDesk == new_desk)
{
/* If its an icon, auto-place it */
if (IS_ICONIFIED(fw))
{
/* If its an icon, auto-place it */
if (IS_ICONIFIED(fw))
{
AutoPlaceIcon(fw, NULL, True);
}
map_window(fw);
AutoPlaceIcon(fw, NULL, True);
}
fw->Desk = fw->UpdateDesk;
fw->UpdateDesk = -1;
} else {
fw->Desk = mnew->virtual_scr.CurrentDesk;
map_window(fw);
}
fw->Desk = fw->UpdateDesk;
fw->UpdateDesk = -1;

out:
if (fw->m != mnew) {
fw->m_prev = fw->m;
fw->m = mnew;
}
EWMH_SetCurrentDesktop(fw->m);
desk_add_fw(fw);
Expand Down

0 comments on commit afca06e

Please sign in to comment.