From ae1bfb516ba7d814c69546de01d649b1402bdb1c Mon Sep 17 00:00:00 2001 From: gintama91 Date: Fri, 30 Jun 2023 12:21:06 +0530 Subject: [PATCH] cleanup --- ext/wry_ruby/src/application/event_loop.rs | 10 +++++----- ext/wry_ruby/src/application/mod.rs | 2 +- ext/wry_ruby/src/application/window.rs | 13 ++++++------- test/test_wry_ruby.rb | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ext/wry_ruby/src/application/event_loop.rs b/ext/wry_ruby/src/application/event_loop.rs index 337da97..415e9c3 100644 --- a/ext/wry_ruby/src/application/event_loop.rs +++ b/ext/wry_ruby/src/application/event_loop.rs @@ -1,10 +1,10 @@ use magnus::{ - define_class, define_global_function, function, method, Error, Module, Object, Value, + function, Error, Object, }; -use std::cell::RefCell; + use std::marker::PhantomData; -use std::sync::atomic::{AtomicPtr, Ordering}; -use wry::application::dpi::LogicalSize; +use std::sync::atomic::{AtomicPtr}; + use wry::application::event_loop::{ EventLoop as EventLoopImpl, }; @@ -19,7 +19,7 @@ pub struct SafeWrapper { _marker: PhantomData<*mut T>, } -unsafe impl Send for SafeWrapper {} +unsafe impl Send for SafeWrapper {} impl EventLoop { pub fn new() -> Self { diff --git a/ext/wry_ruby/src/application/mod.rs b/ext/wry_ruby/src/application/mod.rs index dab16bb..3444e3d 100644 --- a/ext/wry_ruby/src/application/mod.rs +++ b/ext/wry_ruby/src/application/mod.rs @@ -10,7 +10,7 @@ mod event_loop; pub fn init() -> Result<(), Error> { tray_id::init()?; - // window::init()?; + window::init()?; clipboard::init()?; event_loop::init()?; Ok(()) diff --git a/ext/wry_ruby/src/application/window.rs b/ext/wry_ruby/src/application/window.rs index c969e61..5f670ef 100644 --- a/ext/wry_ruby/src/application/window.rs +++ b/ext/wry_ruby/src/application/window.rs @@ -1,21 +1,20 @@ -use magnus::{Error, define_global_function, function, define_class}; +use magnus::{Error, define_global_function, function}; use wry::application::dpi::LogicalSize; use wry::application::window::WindowBuilder; use wry::{ application::{ event::{Event, StartCause, WindowEvent}, - event_loop::{ControlFlow, EventLoop}, + event_loop::{ControlFlow}, }, - webview::WebViewBuilder, }; -pub fn WindoWnew(title: String, width: u32, height: u32) { +pub fn WindoWnew(title: String, width: u32, height: u32, resizable: bool) { let event_loop = wry::application::event_loop::EventLoop::new(); let mut window_builder = WindowBuilder::new(); window_builder = window_builder.with_title(title.clone()); window_builder = window_builder.with_inner_size(LogicalSize::new(width, height)); - window_builder = window_builder.with_resizable(false); + window_builder = window_builder.with_resizable(resizable); let window = window_builder.build(&event_loop).expect("Failed to create window"); @@ -45,8 +44,8 @@ pub fn WindoWnew(title: String, width: u32, height: u32) { pub fn init() -> Result<(), Error> { - - define_global_function("new_window", function!(WindoWnew, 3)); +println!("inside init"); + define_global_function("new_window", function!(WindoWnew, 4)); // define_global_function("hello_wry", function!(new, 3)); // application::init(); Ok(()) diff --git a/test/test_wry_ruby.rb b/test/test_wry_ruby.rb index f8fbf74..daccf72 100644 --- a/test/test_wry_ruby.rb +++ b/test/test_wry_ruby.rb @@ -6,6 +6,6 @@ class TestWryRuby < Minitest::Test # end def test_hello_wry - + new_window "Hello Wry",100,400,true # title, width, height, resizable end end