Ticket #4720: wallpaper-fix.diff

File wallpaper-fix.diff, 2.2 KB (added by engleek, 14 years ago)

Replacement for previous fix, with ratio comparing and obeying 80 chars style rule.

  • src/preferences/backgrounds/BackgroundImage.cpp

     
    299299            // else fall thru
    300300        case kScaledToFit:
    301301            if (fIsDesktop) {
    302                 destinationBitmapBounds = viewBounds;
     302                if ((destinationBitmapBounds.Width()
     303                     / destinationBitmapBounds.Height())
     304                    >= (viewBounds.Height() / viewBounds.Width())) {
     305                    float overlap =
     306                                (((viewBounds.Height()
     307                                / destinationBitmapBounds.Height())
     308                            * destinationBitmapBounds.Width())
     309                        - viewBounds.Height()) / 2;
     310                    destinationBitmapBounds.Set(-overlap, 0,
     311                        viewBounds.Height() + overlap, viewBounds.Height());
     312                } else {
     313                    float overlap =
     314                                (((viewBounds.Width()
     315                                / destinationBitmapBounds.Width())
     316                            * destinationBitmapBounds.Height())
     317                        - viewBounds.Width()) / 2;
     318                    destinationBitmapBounds.Set(0, -overlap, viewBounds.Width(),
     319                        viewBounds.Height() + overlap);
     320                }
    303321                followFlags = B_FOLLOW_ALL;
    304322                break;
    305323            }
  • src/kits/tracker/BackgroundImage.cpp

     
    199199            // else fall thru
    200200        case kScaledToFit:
    201201            if (fIsDesktop) {
    202                 destinationBitmapBounds = viewBounds;
     202                if ((destinationBitmapBounds.Width()
     203                     / destinationBitmapBounds.Height())
     204                    >= (viewBounds.Height() / viewBounds.Width())) {
     205                    float overlap =
     206                                (((viewBounds.Height()
     207                                / destinationBitmapBounds.Height())
     208                            * destinationBitmapBounds.Width())
     209                        - viewBounds.Height()) / 2;
     210                    destinationBitmapBounds.Set(-overlap, 0,
     211                        viewBounds.Height() + overlap, viewBounds.Height());
     212                } else {
     213                    float overlap =
     214                                (((viewBounds.Width()
     215                                / destinationBitmapBounds.Width())
     216                            * destinationBitmapBounds.Height())
     217                        - viewBounds.Width()) / 2;
     218                    destinationBitmapBounds.Set(0, -overlap, viewBounds.Width(),
     219                        viewBounds.Height() + overlap);
     220                }
    203221                followFlags = B_FOLLOW_ALL;
    204222                break;
    205223            }