You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce a new RTL Windows module to address layout issues in Compose Desktop apps on Windows in RTL mode. Updated dependencies and developer information across multiple modules. Adjusted versioning mechanism and included the new module in the project structure.
The **RTL Windows** module fixes a specific bug in Compose Desktop applications running on Windows in RTL mode, where window buttons (minimize, maximize, close) are incorrectly positioned. This module simply resolves this issue and does nothing if the application is not in RTL mode. It's essential for applications that need to support right-to-left languages like Arabic, Hebrew, or Persian.
712
+
713
+
### 🔧 Function: `setWindowsRtlLayout`
714
+
715
+
The `setWindowsRtlLayout` function applies RTL mirroring to a Window based on its component orientation:
716
+
717
+
```kotlin
718
+
fun Window.setWindowsRtlLayout()
719
+
```
720
+
721
+
This extension function:
722
+
- Checks if the operating system is Windows (returns early if not)
723
+
- Determines if RTL layout is needed based on the window's component orientation
724
+
- Applies the appropriate Windows-specific style flags to enable RTL layout
725
+
- Updates the window to reflect the new style
726
+
727
+
### 🔍 How It Works
728
+
729
+
- Uses JNA (Java Native Access) to interact with the Windows API
730
+
- Checks if the application is in RTL mode; if not, it does nothing
731
+
- When in RTL mode, applies the `WS_EX_LAYOUTRTL` and `WS_EX_RTLREADING` extended window styles to fix the window buttons positioning
732
+
- Only affects Windows OS; has no effect on other operating systems
733
+
734
+
### 🔧 Example Usage
735
+
736
+
Here is an example of using `setWindowsRtlLayout` in a Jetpack Compose for Desktop application:
737
+
738
+
```kotlin
739
+
Window(
740
+
title ="RTL Example",
741
+
state = rememberWindowState(width =800.dp, height =600.dp),
742
+
onCloseRequest = ::exitApplication,
743
+
) {
744
+
// Apply RTL layout if needed
745
+
window.setWindowsRtlLayout()
746
+
747
+
App()
748
+
}
749
+
```
750
+
751
+
### 📦 Installation
752
+
753
+
This library is available on Maven Central. To include this module in your project, add the following dependency to your `build.gradle.kts`:
@@ -722,5 +774,3 @@ Contributions are welcome! If you want to improve this library, please feel free
722
774
723
775
A demo is available in the `sample` module, showcasing the main features of all the modules included in this library.
724
776
Additionally, a demo application with an integrated updater using this library is available [here](https://github.com/kdroidFilter/AppwithAutoUpdater).
0 commit comments