mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-26 02:36:32 +11:00
Finally a visible window!
This commit is contained in:
parent
08028c1e54
commit
026be10b8b
2 changed files with 17 additions and 4 deletions
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
//let mut carry;
|
//let mut carry;
|
||||||
//let mut seed = 0xbeefu32;
|
//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",
|
let window = match macos::Window::new("Noise Test - Press ESC to exit",
|
||||||
WIDTH,
|
WIDTH,
|
||||||
|
@ -25,6 +25,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
window.update(&buffer);
|
||||||
/*
|
/*
|
||||||
for i in buffer.iter_mut() {
|
for i in buffer.iter_mut() {
|
||||||
noise = seed;
|
noise = seed;
|
||||||
|
|
16
src/macos.rs
16
src/macos.rs
|
@ -59,6 +59,8 @@ impl WindowDelegate {
|
||||||
let state: *mut libc::c_void = *this.get_ivar("glutinState");
|
let state: *mut libc::c_void = *this.get_ivar("glutinState");
|
||||||
let state = &mut *(state as *mut DelegateState);
|
let state = &mut *(state as *mut DelegateState);
|
||||||
|
|
||||||
|
println!("did_resize");
|
||||||
|
|
||||||
//let _: () = msg_send![*state.context, update];
|
//let _: () = msg_send![*state.context, update];
|
||||||
|
|
||||||
if let Some(handler) = state.resize_handler {
|
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
|
// TODO: center the cursor if the window had mouse grab when it
|
||||||
// lost focus
|
// lost focus
|
||||||
|
|
||||||
|
println!("became key window");
|
||||||
let state: *mut libc::c_void = *this.get_ivar("glutinState");
|
let state: *mut libc::c_void = *this.get_ivar("glutinState");
|
||||||
let state = state as *mut DelegateState;
|
let state = state as *mut DelegateState;
|
||||||
//(*state).pending_events.lock().unwrap().push_back(Focused(true));
|
//(*state).pending_events.lock().unwrap().push_back(Focused(true));
|
||||||
|
@ -93,7 +96,7 @@ impl WindowDelegate {
|
||||||
static INIT: Once = ONCE_INIT;
|
static INIT: Once = ONCE_INIT;
|
||||||
|
|
||||||
INIT.call_once(|| unsafe {
|
INIT.call_once(|| unsafe {
|
||||||
// Create new NSWindowDelegate
|
println!("Create new NSWindowDelegate");
|
||||||
let superclass = Class::get("NSObject").unwrap();
|
let superclass = Class::get("NSObject").unwrap();
|
||||||
let mut decl = ClassDecl::new(superclass, "GlutinWindowDelegate").unwrap();
|
let mut decl = ClassDecl::new(superclass, "GlutinWindowDelegate").unwrap();
|
||||||
|
|
||||||
|
@ -169,6 +172,7 @@ impl Window {
|
||||||
};
|
};
|
||||||
|
|
||||||
app.activateIgnoringOtherApps_(YES);
|
app.activateIgnoringOtherApps_(YES);
|
||||||
|
window.makeKeyAndOrderFront_(nil);
|
||||||
|
|
||||||
let ds = DelegateState {
|
let ds = DelegateState {
|
||||||
view: view.clone(),
|
view: view.clone(),
|
||||||
|
@ -202,6 +206,7 @@ impl Window {
|
||||||
|
|
||||||
window.non_nil().map(|window| {
|
window.non_nil().map(|window| {
|
||||||
let title = IdRef::new(NSString::alloc(nil).init_str(name));
|
let title = IdRef::new(NSString::alloc(nil).init_str(name));
|
||||||
|
window.setLevel_(NSMainMenuWindowLevel as i64 + 1);
|
||||||
window.setTitle_(*title);
|
window.setTitle_(*title);
|
||||||
window.center();
|
window.center();
|
||||||
window
|
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>> {
|
pub fn get_keys() -> Option<Vec<Key>> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue