mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-11 11:31:32 +11:00
Finally a visible window!
This commit is contained in:
parent
08028c1e54
commit
026be10b8b
|
@ -10,7 +10,7 @@ fn main() {
|
|||
//let mut carry;
|
||||
//let mut seed = 0xbeefu32;
|
||||
|
||||
//let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT];
|
||||
let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT];
|
||||
|
||||
let window = match macos::Window::new("Noise Test - Press ESC to exit",
|
||||
WIDTH,
|
||||
|
@ -25,6 +25,7 @@ fn main() {
|
|||
};
|
||||
|
||||
loop {
|
||||
window.update(&buffer);
|
||||
/*
|
||||
for i in buffer.iter_mut() {
|
||||
noise = seed;
|
||||
|
|
18
src/macos.rs
18
src/macos.rs
|
@ -59,6 +59,8 @@ impl WindowDelegate {
|
|||
let state: *mut libc::c_void = *this.get_ivar("glutinState");
|
||||
let state = &mut *(state as *mut DelegateState);
|
||||
|
||||
println!("did_resize");
|
||||
|
||||
//let _: () = msg_send![*state.context, update];
|
||||
|
||||
if let Some(handler) = state.resize_handler {
|
||||
|
@ -75,6 +77,7 @@ impl WindowDelegate {
|
|||
// TODO: center the cursor if the window had mouse grab when it
|
||||
// lost focus
|
||||
|
||||
println!("became key window");
|
||||
let state: *mut libc::c_void = *this.get_ivar("glutinState");
|
||||
let state = state as *mut DelegateState;
|
||||
//(*state).pending_events.lock().unwrap().push_back(Focused(true));
|
||||
|
@ -93,7 +96,7 @@ impl WindowDelegate {
|
|||
static INIT: Once = ONCE_INIT;
|
||||
|
||||
INIT.call_once(|| unsafe {
|
||||
// Create new NSWindowDelegate
|
||||
println!("Create new NSWindowDelegate");
|
||||
let superclass = Class::get("NSObject").unwrap();
|
||||
let mut decl = ClassDecl::new(superclass, "GlutinWindowDelegate").unwrap();
|
||||
|
||||
|
@ -167,8 +170,9 @@ impl Window {
|
|||
return Err("Unable to create NSView");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
app.activateIgnoringOtherApps_(YES);
|
||||
window.makeKeyAndOrderFront_(nil);
|
||||
|
||||
let ds = DelegateState {
|
||||
view: view.clone(),
|
||||
|
@ -202,6 +206,7 @@ impl Window {
|
|||
|
||||
window.non_nil().map(|window| {
|
||||
let title = IdRef::new(NSString::alloc(nil).init_str(name));
|
||||
window.setLevel_(NSMainMenuWindowLevel as i64 + 1);
|
||||
window.setTitle_(*title);
|
||||
window.center();
|
||||
window
|
||||
|
@ -216,7 +221,14 @@ impl Window {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn update(_: &[u32]) {
|
||||
pub fn update(&self, _: &[u32]) {
|
||||
unsafe {
|
||||
NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
|
||||
NSAnyEventMask.bits(),
|
||||
NSDate::distantPast(nil),
|
||||
NSDefaultRunLoopMode,
|
||||
YES);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_keys() -> Option<Vec<Key>> {
|
||||
|
|
Loading…
Reference in a new issue