+
Skip to content

Updates to FvwmPager scaling math to improve visual aspects due to rounding errors. #790

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

Merged
merged 2 commits into from
Jan 2, 2023
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
46 changes: 26 additions & 20 deletions modules/FvwmPager/x_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,31 +448,32 @@ fvwmrec_to_pager(rectangle *rec, bool is_icon)

int m_width = monitor_get_all_widths();
int m_height = monitor_get_all_heights();
int offset_x = 0, offset_y = 0;

if (monitor_to_track != NULL) {
offset_x = (m_width - mon->w) * (rec->x / m_width) + mon->x;
offset_y = (m_height - mon->h) * (rec->y / m_height) + mon->y;
/* Offset window location based on monitor location. */
rec->x -= (m_width - mon->w) * (rec->x / m_width) + mon->x;
rec->y -= (m_height - mon->h) * (rec->y / m_height) + mon->y;
m_width = mon->w;
m_height = mon->h;
}
m_width *= mon->virtual_scr.VxPages;
m_height *= mon->virtual_scr.VyPages;

int scale_w = desk_w, scale_h = desk_h;
if ( is_icon ) {
scale_w = icon.width;
scale_h = icon.height;
}

/* Due to rounding some windows may appear slightly off the page
* edges when they are not. Should add some cleanup/snapping
* code to help improve the visual effect.
/* To deal with rounding issues, first compute the right/bottom
* location of the window so the rounding is consistent for windows
* of different sizes at the same position.
*/
m_width = m_width * mon->virtual_scr.VxPages;
m_height = m_height * mon->virtual_scr.VyPages;
rec->width = (rec->width * scale_w) / m_width + 1;
rec->height = (rec->height * scale_h) / m_height + 1;
rec->x = ((rec->x - offset_x) * scale_w) / m_width;
rec->y = ((rec->y - offset_y) * scale_h) / m_height;
rec->width = ((rec->x + rec->width) * scale_w) / m_width;
rec->height = ((rec->y + rec->height) * scale_h) / m_height;
rec->x = (rec->x * scale_w) / m_width;
rec->y = (rec->y * scale_h) / m_height;
rec->width -= rec->x;
rec->height -= rec->y;
}
static void
pagerrec_to_fvwm(rectangle *rec, bool is_icon)
Expand Down Expand Up @@ -512,12 +513,16 @@ set_vp_size_and_loc(void)
rectangle vp;
struct fpmonitor *mon = fpmonitor_this();

vp.width = desk_w / mon->virtual_scr.VxPages;
vp.height = desk_h / mon->virtual_scr.VyPages;
vp.x = (mon->virtual_scr.Vx * vp.width) /
mon->virtual_scr.MyDisplayWidth;
vp.y = (mon->virtual_scr.Vy * vp.height) /
mon->virtual_scr.MyDisplayHeight;
vp.x = (mon->virtual_scr.Vx * desk_w) /
mon->virtual_scr.VWidth;
vp.y = (mon->virtual_scr.Vy * desk_h) /
mon->virtual_scr.VHeight;
vp.width = ((mon->virtual_scr.Vx + mon->virtual_scr.VWidth /
mon->virtual_scr.VxPages) * desk_w) /
mon->virtual_scr.VWidth - vp.x;
vp.height = ((mon->virtual_scr.Vy + mon->virtual_scr.VHeight /
mon->virtual_scr.VyPages) * desk_h) /
mon->virtual_scr.VHeight - vp.y;
return vp;
}

Expand Down Expand Up @@ -1586,7 +1591,8 @@ void MovePage(Bool is_new_desk)
{
if(i == mon->virtual_scr.CurrentDesk - desk1)
{
XMoveWindow(dpy, Desks[i].CPagerWin, vp.x, vp.y);
XMoveResizeWindow(
dpy, Desks[i].CPagerWin, vp.x, vp.y, vp.width, vp.height);
XLowerWindow(dpy,Desks[i].CPagerWin);
if (CSET_IS_TRANSPARENT(Desks[i].highcolorset))
{
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载