Rename internal structs for consistency (#2149)

Proxy -> EventLoopProxy
Id -> WindowId or DeviceId
WindowTarget -> EventLoopWindowTarget
Handle -> MonitorHandle
Mode -> VideoMode
PlatformSpecificBuilderAttributes -> PlatformSpecificWindowBuilderAttributes
SuperWindowId -> RootWindowId
This commit is contained in:
Mads Marquart 2022-03-18 14:09:39 +01:00 committed by GitHub
parent 85baf79d17
commit a438091266
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 134 additions and 135 deletions

View file

@ -226,8 +226,8 @@ impl<T> EventLoop<T> {
exit_code
}
pub fn create_proxy(&self) -> Proxy<T> {
Proxy::new(self.window_target.p.sender.clone())
pub fn create_proxy(&self) -> EventLoopProxy<T> {
EventLoopProxy::new(self.window_target.p.sender.clone())
}
}
@ -281,14 +281,14 @@ pub fn stop_app_on_panic<F: FnOnce() -> R + UnwindSafe, R>(
}
}
pub struct Proxy<T> {
pub struct EventLoopProxy<T> {
sender: mpsc::Sender<T>,
source: CFRunLoopSourceRef,
}
unsafe impl<T: Send> Send for Proxy<T> {}
unsafe impl<T: Send> Send for EventLoopProxy<T> {}
impl<T> Drop for Proxy<T> {
impl<T> Drop for EventLoopProxy<T> {
fn drop(&mut self) {
unsafe {
CFRelease(self.source as _);
@ -296,13 +296,13 @@ impl<T> Drop for Proxy<T> {
}
}
impl<T> Clone for Proxy<T> {
impl<T> Clone for EventLoopProxy<T> {
fn clone(&self) -> Self {
Proxy::new(self.sender.clone())
EventLoopProxy::new(self.sender.clone())
}
}
impl<T> Proxy<T> {
impl<T> EventLoopProxy<T> {
fn new(sender: mpsc::Sender<T>) -> Self {
unsafe {
// just wake up the eventloop
@ -318,7 +318,7 @@ impl<T> Proxy<T> {
CFRunLoopAddSource(rl, source, kCFRunLoopCommonModes);
CFRunLoopWakeUp(rl);
Proxy { sender, source }
EventLoopProxy { sender, source }
}
}

View file

@ -21,11 +21,10 @@ use std::{fmt, ops::Deref, sync::Arc};
pub(crate) use self::{
app_delegate::get_aux_state_mut,
event_loop::{
EventLoop, EventLoopWindowTarget, PlatformSpecificEventLoopAttributes,
Proxy as EventLoopProxy,
EventLoop, EventLoopProxy, EventLoopWindowTarget, PlatformSpecificEventLoopAttributes,
},
monitor::{MonitorHandle, VideoMode},
window::{Id as WindowId, PlatformSpecificWindowBuilderAttributes, UnownedWindow},
window::{PlatformSpecificWindowBuilderAttributes, UnownedWindow, WindowId},
};
use crate::{
error::OsError as RootOsError, event::DeviceId as RootDeviceId, window::WindowAttributes,

View file

@ -49,18 +49,18 @@ use objc::{
};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Id(pub usize);
pub struct WindowId(pub usize);
impl Id {
impl WindowId {
pub const unsafe fn dummy() -> Self {
Id(0)
Self(0)
}
}
// Convert the `cocoa::base::id` associated with a window to a usize to use as a unique identifier
// for the window.
pub fn get_window_id(window_cocoa_id: id) -> Id {
Id(window_cocoa_id as *const Object as _)
pub fn get_window_id(window_cocoa_id: id) -> WindowId {
WindowId(window_cocoa_id as *const Object as _)
}
#[derive(Clone)]
@ -485,7 +485,7 @@ impl UnownedWindow {
unsafe { util::set_style_mask_sync(*self.ns_window, *self.ns_view, mask) };
}
pub fn id(&self) -> Id {
pub fn id(&self) -> WindowId {
get_window_id(*self.ns_window)
}