Skip to content
  • Xaver Hugl's avatar
    8fa7eedf
    window: snap sizes to the pixel grid and double buffer decoration state · 8fa7eedf
    Xaver Hugl authored
    
    
    This ensures that the decoration (as well as other KWin code) gets a logical size that fits
    perfectly on the pixel grid. In other words, multiplying it with the scale factor results in
    an integer, so there are no gaps or overlaps when using the floating point value in geometry
    calculations or painting code.
    
    For example, before, if you had a screen with 200% scale, and a window on it that's 49u wide
    with 1px wide decoration borders, the border size in integer logical units would be
        round(1px / 200%) = 1u
    and the resulting size
        1u + 49u + 1u = 51u => 51 * 200% = 102px
    but the actual pixel size is
        1px + 49u * 200% + 1px = 100px
    
    with this change, the floating point numbers are taken into account, the decoration border is
        1px / 200% = 0.5u
    wide and thus the logical window size is
        0.5u + 49u + 0.5u = 50u => 100px
    which matches the actual pixel size perfectly.
    
    Similar issues were observable with the window size at non-integer scale factors, which also
    get fixed by this commit.
    
    Co-authored-by: default avatarVlad Zahorodnii <vlad.zahorodnii@kde.org>
    
    BUG: 483338
    BUG: 452438
    BUG: 492052
    8fa7eedf
    window: snap sizes to the pixel grid and double buffer decoration state
    Xaver Hugl authored
    
    
    This ensures that the decoration (as well as other KWin code) gets a logical size that fits
    perfectly on the pixel grid. In other words, multiplying it with the scale factor results in
    an integer, so there are no gaps or overlaps when using the floating point value in geometry
    calculations or painting code.
    
    For example, before, if you had a screen with 200% scale, and a window on it that's 49u wide
    with 1px wide decoration borders, the border size in integer logical units would be
        round(1px / 200%) = 1u
    and the resulting size
        1u + 49u + 1u = 51u => 51 * 200% = 102px
    but the actual pixel size is
        1px + 49u * 200% + 1px = 100px
    
    with this change, the floating point numbers are taken into account, the decoration border is
        1px / 200% = 0.5u
    wide and thus the logical window size is
        0.5u + 49u + 0.5u = 50u => 100px
    which matches the actual pixel size perfectly.
    
    Similar issues were observable with the window size at non-integer scale factors, which also
    get fixed by this commit.
    
    Co-authored-by: default avatarVlad Zahorodnii <vlad.zahorodnii@kde.org>
    
    BUG: 483338
    BUG: 452438
    BUG: 492052
Loading