-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcitx5_hidpi.patch
More file actions
65 lines (64 loc) · 2.35 KB
/
fcitx5_hidpi.patch
File metadata and controls
65 lines (64 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
diff --git a/src/ui/classic/classicui.h b/src/ui/classic/classicui.h
index e184689d..2955b77c 100644
--- a/src/ui/classic/classicui.h
+++ b/src/ui/classic/classicui.h
@@ -177,6 +177,15 @@ FCITX_CONFIGURATION(
{},
{},
{_("This option will be always disabled on XWayland.")}};
+ OptionWithAnnotation<bool, ToolTipAnnotation> xwaylandScaleMode{
+ this,
+ "XWaylandScaleMode",
+ _("Enable To Use Maximum DPI Scale, Disable To Use Minimum DPI Scale "
+ "on X11"),
+ false,
+ {},
+ {},
+ {_("This option will be always disabled on Xwayland.")}};
Option<int, IntConstrain, DefaultMarshaller<int>, ToolTipAnnotation>
forceWaylandDPI{
this,
diff --git a/src/ui/classic/xcbui.cpp b/src/ui/classic/xcbui.cpp
index 51c03f6c..e9a3d4f9 100644
--- a/src/ui/classic/xcbui.cpp
+++ b/src/ui/classic/xcbui.cpp
@@ -730,19 +730,32 @@ int XCBUI::dpiByPosition(int x, int y) {
}
int XCBUI::scaledDPI(int dpi) {
- if (!*parent_->config().perScreenDPI ||
- parent_->xcb()->call<IXCBModule::isXWayland>(displayName_)) {
+ bool is_xwayland =
+ parent_->xcb()->call<IXCBModule::isXWayland>(displayName_);
+ if (!*parent_->config().perScreenDPI || is_xwayland) {
// CLASSICUI_DEBUG() << "Use font option dpi: " << fontOption_.dpi;
+
if (fontOption_.dpi > 0) {
return fontOption_.dpi;
}
- if (screenDpi_ >= 96) {
- // Nowadays their should not be tiny dpi screen I assume.
- // In ancient days, there used to be invalid DPI value that make
- // font extremely tiny.
- return screenDpi_;
+
+ if (is_xwayland && *parent_->config().xwaylandScaleMode) {
+ int scale = std::ceil((double)dpi / screenDpi_);
+ int scaledDpi = screenDpi_ * scale;
+ if (scaledDpi >= 96) {
+ return scaledDpi;
+ }
+ return -1;
+ } else {
+
+ if (screenDpi_ >= 96) {
+ // Nowadays their should not be tiny dpi screen I assume.
+ // In ancient days, there used to be invalid DPI value that make
+ // font extremely tiny.
+ return screenDpi_;
+ }
+ return -1;
}
- return -1;
}
if (dpi < 0) {
return fontOption_.dpi;