Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
c52e8155
Commit
c52e8155
authored
Dec 15, 2020
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed getting dpi scale in Linux.
parent
07c14932
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
3 deletions
+80
-3
.gitignore
.gitignore
+1
-0
drawlayer.cc
skiko/src/jvmMain/cpp/linux/drawlayer.cc
+44
-0
HardwareLayer.kt
...o/src/jvmMain/kotlin/org/jetbrains/skiko/HardwareLayer.kt
+1
-1
PlatformOperations.kt
.../jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
+34
-2
No files found.
.gitignore
View file @
c52e8155
...
@@ -5,3 +5,4 @@ local.properties
...
@@ -5,3 +5,4 @@ local.properties
run.sh
run.sh
.idea
.idea
deploy.sh
deploy.sh
skiko/src/jvmMain/java/
skiko/src/jvmMain/cpp/linux/drawlayer.cc
View file @
c52e8155
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
#include <GL/glx.h>
#include <GL/glx.h>
#include <X11/X.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <cstdlib>
#include <unistd.h>
#include <unistd.h>
#include <stdio.h>
#include <stdio.h>
#include <set>
#include <set>
...
@@ -230,4 +232,46 @@ extern "C"
...
@@ -230,4 +232,46 @@ extern "C"
return
(
jlong
)
window
;
return
(
jlong
)
window
;
}
}
double
getDpiScaleByDisplay
(
Display
*
display
)
{
char
*
resourceManager
=
XResourceManagerString
(
display
);
if
(
resourceManager
!=
nullptr
)
{
XrmDatabase
db
=
XrmGetStringDatabase
(
resourceManager
);
if
(
db
!=
nullptr
)
{
XrmValue
value
;
char
*
type
;
XrmGetResource
(
db
,
"Xft.dpi"
,
"Xft.dpi"
,
&
type
,
&
value
);
if
(
value
.
addr
!=
nullptr
)
{
return
atof
(
value
.
addr
)
/
96.0
;
}
}
}
return
1
;
}
double
getDpiScale
()
{
Display
*
display
=
XOpenDisplay
(
nullptr
);
if
(
display
!=
nullptr
)
{
double
result
=
getDpiScaleByDisplay
(
display
);
XCloseDisplay
(
display
);
return
result
;
}
else
{
return
1
;
}
}
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_PlatformOperationsKt_linuxGetDpiScaleNative
(
JNIEnv
*
env
,
jobject
properties
)
{
return
(
float
)
getDpiScale
();
}
}
// extern "C"
}
// extern "C"
\ No newline at end of file
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/HardwareLayer.kt
View file @
c52e8155
...
@@ -34,7 +34,7 @@ abstract class HardwareLayer : Canvas(), Drawable {
...
@@ -34,7 +34,7 @@ abstract class HardwareLayer : Canvas(), Drawable {
external
get
external
get
override
val
contentScale
:
Float
override
val
contentScale
:
Float
get
()
=
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
(
)
get
()
=
platformOperations
.
getDpiScale
(
this
)
val
absoluteX
:
Int
val
absoluteX
:
Int
get
()
=
convertPoint
(
this
,
x
,
y
,
getRootPane
(
this
)).
x
get
()
=
convertPoint
(
this
,
x
,
y
,
getRootPane
(
this
)).
x
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/PlatformOperations.kt
View file @
c52e8155
...
@@ -7,6 +7,7 @@ import javax.swing.SwingUtilities
...
@@ -7,6 +7,7 @@ import javax.swing.SwingUtilities
internal
interface
PlatformOperations
{
internal
interface
PlatformOperations
{
fun
isFullscreen
(
component
:
Component
):
Boolean
fun
isFullscreen
(
component
:
Component
):
Boolean
fun
setFullscreen
(
component
:
Component
,
value
:
Boolean
)
fun
setFullscreen
(
component
:
Component
,
value
:
Boolean
)
fun
getDpiScale
(
component
:
Component
):
Float
}
}
internal
val
platformOperations
:
PlatformOperations
by
lazy
{
internal
val
platformOperations
:
PlatformOperations
by
lazy
{
...
@@ -19,8 +20,12 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -19,8 +20,12 @@ internal val platformOperations: PlatformOperations by lazy {
override
fun
setFullscreen
(
component
:
Component
,
value
:
Boolean
)
{
override
fun
setFullscreen
(
component
:
Component
,
value
:
Boolean
)
{
osxSetFullscreenNative
(
component
,
value
)
osxSetFullscreenNative
(
component
,
value
)
}
}
override
fun
getDpiScale
(
component
:
Component
):
Float
{
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
}
}
}
else
->
{
OS
.
Windows
->
{
object
:
PlatformOperations
{
object
:
PlatformOperations
{
override
fun
isFullscreen
(
component
:
Component
):
Boolean
{
override
fun
isFullscreen
(
component
:
Component
):
Boolean
{
val
window
=
SwingUtilities
.
getRoot
(
component
)
as
Window
val
window
=
SwingUtilities
.
getRoot
(
component
)
as
Window
...
@@ -33,10 +38,37 @@ internal val platformOperations: PlatformOperations by lazy {
...
@@ -33,10 +38,37 @@ internal val platformOperations: PlatformOperations by lazy {
val
device
=
window
.
graphicsConfiguration
.
device
val
device
=
window
.
graphicsConfiguration
.
device
device
.
setFullScreenWindow
(
if
(
value
)
window
else
null
)
device
.
setFullScreenWindow
(
if
(
value
)
window
else
null
)
}
}
override
fun
getDpiScale
(
component
:
Component
):
Float
{
return
component
.
graphicsConfiguration
.
defaultTransform
.
scaleX
.
toFloat
()
}
}
}
OS
.
Linux
->
{
object
:
PlatformOperations
{
override
fun
isFullscreen
(
component
:
Component
):
Boolean
{
val
window
=
SwingUtilities
.
getRoot
(
component
)
as
Window
val
device
=
window
.
graphicsConfiguration
.
device
return
device
.
getFullScreenWindow
()
==
window
}
override
fun
setFullscreen
(
component
:
Component
,
value
:
Boolean
)
{
val
window
=
SwingUtilities
.
getRoot
(
component
)
as
Window
val
device
=
window
.
graphicsConfiguration
.
device
device
.
setFullScreenWindow
(
if
(
value
)
window
else
null
)
}
override
fun
getDpiScale
(
component
:
Component
):
Float
{
return
linuxGetDpiScaleNative
()
}
}
}
}
}
}
}
}
}
// OSX
external
private
fun
osxIsFullscreenNative
(
component
:
Component
):
Boolean
external
private
fun
osxIsFullscreenNative
(
component
:
Component
):
Boolean
external
private
fun
osxSetFullscreenNative
(
component
:
Component
,
value
:
Boolean
)
external
private
fun
osxSetFullscreenNative
(
component
:
Component
,
value
:
Boolean
)
// Linux
external
private
fun
linuxGetDpiScaleNative
():
Float
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment