remove mspc channel (to be replaced by baseview-specific WindowHandle
This commit is contained in:
parent
c51aea5c12
commit
601a5d62a4
4 changed files with 4 additions and 24 deletions
|
@ -1,5 +1,3 @@
|
||||||
use std::sync::mpsc;
|
|
||||||
|
|
||||||
use baseview::{Event, Window, WindowHandler};
|
use baseview::{Event, Window, WindowHandler};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -10,11 +8,7 @@ fn main() {
|
||||||
parent: baseview::Parent::None,
|
parent: baseview::Parent::None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (_app_message_tx, app_message_rx) = mpsc::channel::<()>();
|
Window::open::<MyProgram>(window_open_options);
|
||||||
|
|
||||||
// Send _app_message_tx to a separate thread, then send messages to the GUI thread.
|
|
||||||
|
|
||||||
let _ = Window::open::<MyProgram>(window_open_options, app_message_rx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MyProgram {}
|
struct MyProgram {}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use std::sync::mpsc;
|
|
||||||
|
|
||||||
use cocoa::appkit::{
|
use cocoa::appkit::{
|
||||||
NSApp, NSApplication, NSApplicationActivateIgnoringOtherApps,
|
NSApp, NSApplication, NSApplicationActivateIgnoringOtherApps,
|
||||||
|
@ -19,10 +18,7 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn open<H: WindowHandler>(
|
pub fn open<H: WindowHandler>(options: WindowOpenOptions) {
|
||||||
options: WindowOpenOptions,
|
|
||||||
app_message_rx: mpsc::Receiver<H::Message>,
|
|
||||||
) {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let _pool = NSAutoreleasePool::new(nil);
|
let _pool = NSAutoreleasePool::new(nil);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ use std::cell::RefCell;
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc;
|
|
||||||
|
|
||||||
use raw_window_handle::{windows::WindowsHandle, HasRawWindowHandle, RawWindowHandle};
|
use raw_window_handle::{windows::WindowsHandle, HasRawWindowHandle, RawWindowHandle};
|
||||||
|
|
||||||
|
@ -137,10 +136,7 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn open<H: WindowHandler>(
|
pub fn open<H: WindowHandler>(options: WindowOpenOptions) {
|
||||||
options: WindowOpenOptions,
|
|
||||||
app_message_rx: mpsc::Receiver<H::Message>,
|
|
||||||
) {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let title = (options.title.to_owned() + "\0").as_ptr() as *const i8;
|
let title = (options.title.to_owned() + "\0").as_ptr() as *const i8;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::os::raw::{c_ulong, c_void};
|
use std::os::raw::{c_ulong, c_void};
|
||||||
use std::sync::mpsc;
|
|
||||||
|
|
||||||
use super::XcbConnection;
|
use super::XcbConnection;
|
||||||
use crate::{Event, MouseButtonID, MouseScroll, Parent, WindowHandler, WindowOpenOptions};
|
use crate::{Event, MouseButtonID, MouseScroll, Parent, WindowHandler, WindowOpenOptions};
|
||||||
|
@ -14,10 +13,7 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn open<H: WindowHandler>(
|
pub fn open<H: WindowHandler>(options: WindowOpenOptions) {
|
||||||
options: WindowOpenOptions,
|
|
||||||
app_message_rx: mpsc::Receiver<H::Message>,
|
|
||||||
) {
|
|
||||||
// Convert the parent to a X11 window ID if we're given one
|
// Convert the parent to a X11 window ID if we're given one
|
||||||
let parent = match options.parent {
|
let parent = match options.parent {
|
||||||
Parent::None => None,
|
Parent::None => None,
|
||||||
|
@ -122,8 +118,6 @@ unsafe impl HasRawWindowHandle for Window {
|
||||||
// Event loop
|
// Event loop
|
||||||
fn run_event_loop<H: WindowHandler>(window: &mut Window, handler: &mut H) {
|
fn run_event_loop<H: WindowHandler>(window: &mut Window, handler: &mut H) {
|
||||||
loop {
|
loop {
|
||||||
// somehow poll app_message_rx for messages at the same time
|
|
||||||
|
|
||||||
let ev = window.xcb_connection.conn.wait_for_event();
|
let ev = window.xcb_connection.conn.wait_for_event();
|
||||||
if let Some(event) = ev {
|
if let Some(event) = ev {
|
||||||
let event_type = event.response_type() & !0x80;
|
let event_type = event.response_type() & !0x80;
|
||||||
|
|
Loading…
Add table
Reference in a new issue