Implement missing SetForeground api function. Fixes #2

This commit is contained in:
meehl committed 2025-10-28 23:12:09 +01:00
1 parent f2387804c1
commit 38e3a39782
4 files changed
+19 -2

No files matched your search

+5 -1
View File
@@ -2,6 +2,10 @@
## [Unreleased] - ReleaseDate
### Fixed
- Fix crash caused by missing `SetForeground` api function
## [0.2.0] - 2025-10-28
### Added
@@ -46,8 +50,8 @@
- First release
<!-- next-url -->
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/meehl/rusty-path-of-building/compare/v0.1.2...v0.2.0
[0.1.2]: https://github.com/meehl/rusty-path-of-building/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/meehl/rusty-path-of-building/compare/v0.1.0...v0.1.1
+2 -1
View File
@@ -13,7 +13,7 @@ use crate::{
},
rendering::PoBString,
search_handle::new_search_handle,
window::{get_screen_scale, get_screen_size, set_window_title},
window::{get_screen_scale, get_screen_size, set_foreground, set_window_title},
},
lua::ContextSocket,
};
@@ -84,6 +84,7 @@ pub fn register_globals(lua: &Lua) -> LuaResult<()> {
globals.set("GetScreenSize", lua.create_function(get_screen_size)?)?;
globals.set("GetScreenScale", lua.create_function(get_screen_scale)?)?;
globals.set("SetWindowTitle", lua.create_function(set_window_title)?)?;
globals.set("SetForeground", lua.create_function(set_foreground)?)?;
// lua
globals.set("PCall", lua.create_function(protected_call)?)?;
+6
View File
@@ -26,3 +26,9 @@ pub fn set_window_title(l: &Lua, title: String) -> LuaResult<()> {
socket.window().set_window_title(&title);
Ok(())
}
pub fn set_foreground(l: &Lua, _: ()) -> LuaResult<()> {
let socket = l.app_data_ref::<&'static ContextSocket>().unwrap();
socket.window().focus();
Ok(())
}
+6
View File
@@ -42,4 +42,10 @@ impl WindowState {
pub fn logical_size(&self) -> LogicalSize<u32> {
self.size.to_logical(self.scale_factor)
}
pub fn focus(&self) {
if let Some(ref window) = self.window {
window.focus_window();
}
}
}