Skip to content

Commit

Permalink
Force enable fractional-scale-v1 experimental option
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Nov 21, 2023
1 parent 0f9d83f commit 4696f73
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
22 changes: 22 additions & 0 deletions Telegram/SourceFiles/core/sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ For license and copyright information please follow this link:
#include "core/local_url_handlers.h"
#include "core/update_checker.h"
#include "core/deadlock_detector.h"
#include "base/options.h"
#include "base/timer.h"
#include "base/concurrent_timer.h"
#include "base/invoke_queued.h"
Expand All @@ -37,6 +38,22 @@ For license and copyright information please follow this link:
namespace Core {
namespace {

base::options::toggle OptionForceWaylandFractionalScaling({
.id = kOptionForceWaylandFractionalScaling,
.name = "Force enable fractional-scale-v1",
.description = "Enable fractional-scale-v1 on Wayland without "
"precise High DPI scaling. "
"Requires Qt with Desktop App Toolkit patches.",
.scope = [] {
#ifdef DESKTOP_APP_QT_PATCHED
return Platform::IsWayland();
#else // DESKTOP_APP_QT_PATCHED
return false;
#endif // !DESKTOP_APP_QT_PATCHED
},
.restartRequired = true,
});

QChar _toHex(ushort v) {
v = v & 0x000F;
return QChar::fromLatin1((v >= 10) ? ('a' + (v - 10)) : ('0' + v));
Expand Down Expand Up @@ -77,12 +94,17 @@ QString _escapeFrom7bit(const QString &str) {

} // namespace

const char kOptionForceWaylandFractionalScaling[] = "force-wayland-fractional-scaling";

bool Sandbox::QuitOnStartRequested = false;

Sandbox::Sandbox(int &argc, char **argv)
: QApplication(argc, argv)
, _mainThreadId(QThread::currentThreadId()) {
setQuitOnLastWindowClosed(false);
if (OptionForceWaylandFractionalScaling.value()) {
setProperty("_q_force_wayland_fractional_scale", true);
}
}

int Sandbox::start() {
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/core/sandbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class QLockFile;

namespace Core {

extern const char kOptionForceWaylandFractionalScaling[];

class UpdateChecker;
class Application;

Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/settings/settings_experimental.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ For license and copyright information please follow this link:
#include "ui/chat/chat_style_radius.h"
#include "base/options.h"
#include "core/application.h"
#include "core/sandbox.h"
#include "core/launcher.h"
#include "chat_helpers/tabbed_panel.h"
#include "dialogs/dialogs_widget.h"
Expand Down Expand Up @@ -142,6 +143,7 @@ void SetupExperimental(
addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick);
addToggle(Dialogs::kOptionForumHideChatsList);
addToggle(Core::kOptionFractionalScalingEnabled);
addToggle(Core::kOptionForceWaylandFractionalScaling);
addToggle(Window::kOptionViewProfileInChatsListContextMenu);
addToggle(Info::Profile::kOptionShowPeerIdBelowAbout);
addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL);
Expand Down
5 changes: 2 additions & 3 deletions Telegram/build/docker/centos_env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ FROM builder AS patches
RUN git init patches \
&& cd patches \
&& git remote add origin {{ GIT }}/desktop-app/patches.git \
&& git fetch --depth=1 origin c80c0d530200e3f27a9a39b4f230919529e73bd2 \
&& git fetch --depth=1 origin 90a7f1b55da69c99699e6b6776268184c20387f8 \
&& git reset --hard FETCH_HEAD \
&& rm -rf .git

Expand Down Expand Up @@ -758,8 +758,7 @@ RUN git clone -b {{ QT_TAG }} --depth=1 {{ GIT }}/qt/qt5.git qt_{{ QT }} \
&& cd qtbase \
&& find ../../patches/qtbase_{{ QT }} -type f -print0 | sort -z | xargs -r0 git apply \
&& cd ../qtwayland \
&& git fetch origin aae65c885d8e38d8abc2959cded7b5e9e5fc88b3 \
&& git cherry-pick -n FETCH_HEAD \
&& find ../../patches/qtwayland_{{ QT }} -type f -print0 | sort -z | xargs -r0 git apply \
&& cd .. \
&& ./configure -prefix "{{ QT_PREFIX }}" \
CMAKE_BUILD_TYPE=None \
Expand Down
3 changes: 1 addition & 2 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ parts:
git fetch origin v6.5.3
git checkout FETCH_HEAD
cd ../qtwayland
git fetch origin aae65c885d8e38d8abc2959cded7b5e9e5fc88b3
git cherry-pick -n FETCH_HEAD
find $CRAFT_STAGE/patches/qtwayland_${QT} -type f -print0 | sort -z | xargs -r0 git apply
sed -i 's/qMin(version, 8)/qMin(version, 7)/' src/client/qwaylandinputdevice.cpp
cd ..
override-build: |
Expand Down

0 comments on commit 4696f73

Please sign in to comment.