|
21 | 21 | import com.jfoenix.controls.JFXCheckBox; |
22 | 22 | import com.jfoenix.controls.JFXComboBox; |
23 | 23 | import com.jfoenix.controls.JFXListView; |
24 | | -import com.sun.jna.Pointer; |
25 | 24 | import javafx.application.Platform; |
26 | 25 | import javafx.beans.InvalidationListener; |
27 | 26 | import javafx.beans.binding.Bindings; |
28 | 27 | import javafx.beans.property.*; |
29 | 28 | import javafx.collections.FXCollections; |
30 | 29 | import javafx.collections.ObservableList; |
31 | 30 | import javafx.css.PseudoClass; |
32 | | -import javafx.event.EventHandler; |
33 | 31 | import javafx.geometry.Insets; |
34 | 32 | import javafx.geometry.Pos; |
35 | 33 | import javafx.scene.Scene; |
|
38 | 36 | import javafx.scene.input.MouseButton; |
39 | 37 | import javafx.scene.layout.*; |
40 | 38 | import javafx.stage.Stage; |
41 | | -import javafx.stage.WindowEvent; |
42 | 39 | import org.jackhuang.hmcl.game.GameDumpGenerator; |
43 | 40 | import org.jackhuang.hmcl.game.Log; |
44 | 41 | import org.jackhuang.hmcl.setting.StyleSheets; |
|
48 | 45 | import org.jackhuang.hmcl.ui.construct.SpinnerPane; |
49 | 46 | import org.jackhuang.hmcl.util.*; |
50 | 47 | import org.jackhuang.hmcl.util.platform.*; |
51 | | -import org.jackhuang.hmcl.util.platform.windows.Dwmapi; |
52 | | -import org.jackhuang.hmcl.util.platform.windows.WinConstants; |
53 | | -import org.jackhuang.hmcl.util.platform.windows.WinTypes; |
54 | 48 |
|
55 | 49 | import java.io.IOException; |
56 | 50 | import java.nio.file.Files; |
@@ -87,41 +81,13 @@ public final class LogWindow extends Stage { |
87 | 81 | private final LogWindowImpl impl; |
88 | 82 | private final ManagedProcess gameProcess; |
89 | 83 |
|
90 | | - @SuppressWarnings("unused") |
91 | | - private Object windowsDarkModeListenerHolder; |
92 | | - |
93 | | - { |
94 | | - if (OperatingSystem.SYSTEM_VERSION.isAtLeast(OSVersion.WINDOWS_11) && NativeUtils.USE_JNA && Dwmapi.INSTANCE != null) { |
95 | | - this.addEventFilter(WindowEvent.WINDOW_SHOWN, new EventHandler<>() { |
96 | | - @Override |
97 | | - public void handle(WindowEvent event) { |
98 | | - LogWindow.this.removeEventFilter(WindowEvent.WINDOW_SHOWN, this); |
99 | | - |
100 | | - windowsDarkModeListenerHolder = FXUtils.onWeakChangeAndOperate(Themes.darkModeProperty(), darkMode -> { |
101 | | - if (LogWindow.this.isShowing()) { |
102 | | - WindowsNativeUtils.getWindowHandle(LogWindow.this).ifPresent(handle -> { |
103 | | - if (handle == WinTypes.HANDLE.INVALID_VALUE) |
104 | | - return; |
105 | | - |
106 | | - Dwmapi.INSTANCE.DwmSetWindowAttribute( |
107 | | - new WinTypes.HANDLE(Pointer.createConstant(handle)), |
108 | | - WinConstants.DWMWA_USE_IMMERSIVE_DARK_MODE, |
109 | | - new WinTypes.BOOLByReference(new WinTypes.BOOL(darkMode)), |
110 | | - WinTypes.BOOL.SIZE |
111 | | - ); |
112 | | - }); |
113 | | - } |
114 | | - }); |
115 | | - } |
116 | | - }); |
117 | | - } |
118 | | - } |
119 | | - |
120 | 84 | public LogWindow(ManagedProcess gameProcess) { |
121 | 85 | this(gameProcess, new CircularArrayList<>()); |
122 | 86 | } |
123 | 87 |
|
124 | 88 | public LogWindow(ManagedProcess gameProcess, CircularArrayList<Log> logs) { |
| 89 | + Themes.applyNativeDarkMode(this); |
| 90 | + |
125 | 91 | this.logs = logs; |
126 | 92 | this.impl = new LogWindowImpl(); |
127 | 93 | setScene(new Scene(impl, 800, 480)); |
|
0 commit comments