Skip to content

Commit e9b1ed2

Browse files
committed
POC: Wayland fractional scale support
1 parent b4f7c0f commit e9b1ed2

155 files changed

Lines changed: 1112 additions & 704 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Telegram/SourceFiles/api/api_chat_invite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void ConfirmSubscriptionBox(
154154
creditsIconSize,
155155
1.5);
156156
state->frame = QImage(
157-
Size(photoSize * style::DevicePixelRatio()),
157+
Size(style::DevicePixels(photoSize)),
158158
QImage::Format_ARGB32_Premultiplied);
159159
state->frame.setDevicePixelRatio(style::DevicePixelRatio());
160160
const auto options = Images::Option::RoundCircle;

Telegram/SourceFiles/boxes/background_box.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ void BackgroundBox::Inner::validatePaperThumbnail(
657657
} else if (!paper.data.backgroundColors().empty()) {
658658
paper.thumbnail = Ui::PixmapFromImage(
659659
Ui::GenerateBackgroundImage(
660-
st::backgroundSize * style::DevicePixelRatio(),
660+
style::DevicePixels(st::backgroundSize),
661661
paper.data.backgroundColors(),
662662
paper.data.gradientRotation()));
663663
paper.thumbnail.setDevicePixelRatio(style::DevicePixelRatio());

Telegram/SourceFiles/boxes/background_preview_box.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ constexpr auto kMaxWallPaperSlugLength = 255;
121121
const auto takeHeight = (width > height)
122122
? size
123123
: (height * size / width);
124-
const auto ratio = style::DevicePixelRatio();
125-
return Images::Prepare(image, QSize(takeWidth, takeHeight) * ratio, {
124+
return Images::Prepare(image, QSize(
125+
style::DevicePixels(takeWidth),
126+
style::DevicePixels(takeHeight)), {
126127
.options = Images::Option::TransparentBackground | blur,
127128
.outer = { size, size },
128129
});
@@ -725,7 +726,7 @@ void BackgroundPreviewBox::applyForPeer() {
725726
} else if (_forBothOverlay) {
726727
return;
727728
}
728-
const auto size = this->size() * style::DevicePixelRatio();
729+
const auto size = style::DevicePixels(this->size());
729730
const auto bg = Images::DitherImage(
730731
Images::BlurLargeImage(
731732
Ui::GrabWidgetToImage(this).scaled(

Telegram/SourceFiles/boxes/filters/edit_filter_links.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ PaintRoundImageCallback ChatRow::generatePaintUserpicCallback(
359359
int outerWidth,
360360
int size) mutable {
361361
const auto wide = size + style::ConvertScale(3);
362-
const auto full = QSize(wide, wide) * style::DevicePixelRatio();
362+
const auto full = QSize(
363+
style::DevicePixels(wide),
364+
style::DevicePixels(wide));
363365
auto repaint = false;
364366
if (_disabledFrame.size() != full) {
365367
repaint = true;
@@ -967,7 +969,7 @@ void LinksController::rowPaintIcon(
967969
auto &icon = _icons[int(color)];
968970
if (icon.isNull()) {
969971
icon = QImage(
970-
QSize(inner, inner) * style::DevicePixelRatio(),
972+
style::DevicePixels(QSize(inner, inner)),
971973
QImage::Format_ARGB32_Premultiplied);
972974
icon.fill(Qt::transparent);
973975
icon.setDevicePixelRatio(style::DevicePixelRatio());

Telegram/SourceFiles/boxes/gift_premium_box.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,12 @@ using SpinnerState = Data::GiftUpgradeSpinner::State;
416416
return;
417417
}
418418
}
419-
const auto ratio = style::DevicePixelRatio();
420419
const auto h = raw->height();
421-
if (state->fading.height() != h * ratio) {
422-
state->fading = QImage(
423-
QSize(1, h) * ratio,
420+
const auto pixelHeight = style::DevicePixels(h);
421+
if (state->fading.height() != pixelHeight) {
422+
state->fading = QImage(style::DevicePixels(QSize(1, h)),
424423
QImage::Format_ARGB32_Premultiplied);
425-
state->fading.setDevicePixelRatio(ratio);
424+
state->fading.setDevicePixelRatio(style::DevicePixelRatio());
426425
state->fading.fill(Qt::transparent);
427426
auto q = QPainter(&state->fading);
428427
auto brush = QLinearGradient(0, 0, 0, margin.top());
@@ -439,7 +438,7 @@ using SpinnerState = Data::GiftUpgradeSpinner::State;
439438
auto &now = state->rows[state->nowIndex];
440439
const auto validate = [&](Row &row) {
441440
const auto size = row.widget->size();
442-
if (row.frame.size() != size * ratio) {
441+
if (row.frame.size() != style::DevicePixels(size)) {
443442
row.frame = Ui::GrabWidgetToImage(row.widget.get());
444443
}
445444
};

Telegram/SourceFiles/boxes/peer_list_box.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ PaintRoundImageCallback ForceRoundUserpicCallback(not_null<PeerData*> peer) {
6767
auto userpic = Ui::PeerUserpicView();
6868
auto cache = std::make_shared<QImage>();
6969
return [=](Painter &p, int x, int y, int outerWidth, int size) mutable {
70-
const auto ratio = style::DevicePixelRatio();
71-
const auto cacheSize = QSize(size, size) * ratio;
70+
const auto cacheSize = QSize(
71+
style::DevicePixels(size),
72+
style::DevicePixels(size));
7273
if (cache->size() != cacheSize) {
7374
*cache = QImage(cacheSize, QImage::Format_ARGB32_Premultiplied);
74-
cache->setDevicePixelRatio(ratio);
75+
cache->setDevicePixelRatio(style::DevicePixelRatio());
7576
}
7677
auto q = Painter(cache.get());
7778
peer->paintUserpicLeft(q, userpic, 0, 0, outerWidth, size);

Telegram/SourceFiles/boxes/peers/add_participants_box.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ PaintRoundImageCallback ForbiddenRow::generatePaintUserpicCallback(
337337
int outerWidth,
338338
int size) mutable {
339339
const auto wide = size + style::ConvertScale(3);
340-
const auto full = QSize(wide, wide) * style::DevicePixelRatio();
340+
const auto full = style::DevicePixels(QSize(wide, wide));
341341
auto repaint = false;
342342
if (_disabledFrame.size() != full) {
343343
repaint = true;

Telegram/SourceFiles/boxes/peers/edit_peer_color_box.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,9 +2906,9 @@ void CheckBoostLevel(
29062906
ButtonWithEmoji ButtonStyleWithRightEmoji(
29072907
not_null<Ui::RpWidget*> parent,
29082908
const QString &noneString,
2909-
const style::SettingsButton &parentSt) {
2909+
const style::SettingsButton &parentSt) {
29102910
const auto ratio = style::DevicePixelRatio();
2911-
const auto emojiWidth = Data::FrameSizeFromTag({}) / ratio;
2911+
const auto emojiWidth = qRound(Data::FrameSizeFromTag({}) / ratio);
29122912

29132913
const auto noneWidth = st::normalFont->width(noneString);
29142914

Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ void LinksController::rowPaintIcon(
708708
auto &icon = _icons[int(color)];
709709
if (icon.isNull()) {
710710
icon = QImage(
711-
QSize(inner, inner) * style::DevicePixelRatio(),
711+
style::DevicePixels(QSize(inner, inner)),
712712
QImage::Format_ARGB32_Premultiplied);
713713
icon.fill(Qt::transparent);
714714
icon.setDevicePixelRatio(style::DevicePixelRatio());

Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ PeerShortInfoCover::PeerShortInfoCover(
151151

152152
refreshLabelsGeometry();
153153

154-
_roundedTopImage = QImage(
155-
QSize(_st.size, _st.radius) * style::DevicePixelRatio(),
154+
_roundedTopImage = QImage(style::DevicePixels(QSize(_st.size, _st.radius)),
156155
QImage::Format_ARGB32_Premultiplied);
157156
_roundedTopImage.setDevicePixelRatio(style::DevicePixelRatio());
158157
_roundedTopImage.fill(Qt::transparent);
@@ -196,7 +195,7 @@ void PeerShortInfoCover::paint(QPainter &p) {
196195
RectPart::TopLeft | RectPart::TopRight);
197196
} else if (_userpicImage.isNull()) {
198197
auto image = QImage(
199-
_widget->size() * style::DevicePixelRatio(),
198+
style::DevicePixels(_widget->size()),
200199
QImage::Format_ARGB32_Premultiplied);
201200
image.fill(Qt::black);
202201
_userpicImage = Images::Round(
@@ -602,9 +601,10 @@ void PeerShortInfoCover::refreshBarImages() {
602601
_largeWidth = _smallWidth + 1;
603602
const auto makeBar = [&](int size) {
604603
const auto radius = _st.line / 2.;
605-
auto result = QImage(
606-
QSize(size, _st.line) * style::DevicePixelRatio(),
607-
QImage::Format_ARGB32_Premultiplied);
604+
const auto resultSize = QSize(
605+
style::DevicePixels(size),
606+
style::DevicePixels(_st.line));
607+
auto result = QImage(resultSize, QImage::Format_ARGB32_Premultiplied);
608608
result.setDevicePixelRatio(style::DevicePixelRatio());
609609
result.fill(Qt::transparent);
610610
auto p = QPainter(&result);
@@ -733,7 +733,7 @@ void PeerShortInfoBox::prepare() {
733733
}, _topRoundBackground->lifetime());
734734

735735
_roundedTop = QImage(
736-
_topRoundBackground->size() * style::DevicePixelRatio(),
736+
style::DevicePixels(_topRoundBackground->size()),
737737
QImage::Format_ARGB32_Premultiplied);
738738
_roundedTop.setDevicePixelRatio(style::DevicePixelRatio());
739739
refreshRoundedTopImage(getDelegate()->style().bg->c);

0 commit comments

Comments
 (0)