Skip to content

Commit 7600f1e

Browse files
committed
POC: Wayland fractional scale support
1 parent ca3eb7d commit 7600f1e

160 files changed

Lines changed: 1276 additions & 759 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.

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
url = https://github.com/desktop-app/codegen.git
2525
[submodule "Telegram/lib_ui"]
2626
path = Telegram/lib_ui
27-
url = https://github.com/desktop-app/lib_ui.git
27+
url = git@github.com:zvova7890/lib_ui.git
2828
[submodule "Telegram/lib_lottie"]
2929
path = Telegram/lib_lottie
30-
url = https://github.com/desktop-app/lib_lottie.git
30+
url = git@github.com:zvova7890/lib_lottie.git
3131
[submodule "Telegram/lib_tl"]
3232
path = Telegram/lib_tl
3333
url = https://github.com/desktop-app/lib_tl.git

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
@@ -2827,9 +2827,9 @@ void CheckBoostLevel(
28272827
ButtonWithEmoji ButtonStyleWithRightEmoji(
28282828
not_null<Ui::RpWidget*> parent,
28292829
const QString &noneString,
2830-
const style::SettingsButton &parentSt) {
2830+
const style::SettingsButton &parentSt) {
28312831
const auto ratio = style::DevicePixelRatio();
2832-
const auto emojiWidth = Data::FrameSizeFromTag({}) / ratio;
2832+
const auto emojiWidth = qRound(Data::FrameSizeFromTag({}) / ratio);
28332833

28342834
const auto noneWidth = st::normalFont->width(noneString);
28352835

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());

0 commit comments

Comments
 (0)