Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions winit-appkit/src/window_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,8 +1279,9 @@ impl WindowDelegate {
#[inline]
pub fn drag_window(&self) -> Result<(), RequestError> {
let mtm = MainThreadMarker::from(self);
let event =
NSApplication::sharedApplication(mtm).currentEvent().ok_or(RequestError::Ignored)?;
let event = NSApplication::sharedApplication(mtm)
.currentEvent()
.ok_or(NotSupportedError::new("event no longer current"))?;
self.window().performWindowDragWithEvent(&event);
Ok(())
}
Expand Down
12 changes: 9 additions & 3 deletions winit-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ impl From<NotSupportedError> for EventLoopError {
pub enum RequestError {
/// The request is not supported.
NotSupported(NotSupportedError),
/// The request was ignored by the operating system.
Ignored,
/// Got unspecified OS specific error during the request.
Os(OsError),
}
Expand All @@ -67,7 +65,6 @@ impl Display for RequestError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotSupported(err) => err.fmt(f),
Self::Ignored => write!(f, "The request was ignored"),
Self::Os(err) => err.fmt(f),
}
}
Expand All @@ -90,6 +87,15 @@ impl From<OsError> for RequestError {
}
}

impl From<RequestError> for EventLoopError {
fn from(value: RequestError) -> Self {
match value {
RequestError::NotSupported(err) => EventLoopError::NotSupported(err),
RequestError::Os(err) => EventLoopError::Os(err),
}
}
}

/// The requested operation is not supported.
#[derive(Debug)]
pub struct NotSupportedError {
Expand Down
6 changes: 3 additions & 3 deletions winit-core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
use smol_str::SmolStr;

use crate::Instant;
use crate::error::RequestError;
use crate::error::{NotSupportedError, RequestError};
use crate::event_loop::AsyncRequestSerial;
use crate::keyboard::{self, ModifiersKeyState, ModifiersKeys, ModifiersState};
#[cfg(doc)]
Expand Down Expand Up @@ -1498,7 +1498,7 @@ impl SurfaceSizeWriter {
*inner.lock().unwrap() = new_surface_size;
Ok(())
} else {
Err(RequestError::Ignored)
Err(NotSupportedError::new("request closed").into())
}
}

Expand All @@ -1507,7 +1507,7 @@ impl SurfaceSizeWriter {
if let Some(inner) = self.new_surface_size.upgrade() {
Ok(*inner.lock().unwrap())
} else {
Err(RequestError::Ignored)
Err(NotSupportedError::new("request closed").into())
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions winit-x11/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1978,11 +1978,11 @@ impl UnownedWindow {
})
}
let region = RegionWrapper::create_region(self.xconn.xcb_connection(), &rectangles)
.map_err(|_e| RequestError::Ignored)?;
.map_err(|err| os_error!(X11Error::from(err)))?;
self.xconn
.xcb_connection()
.xfixes_set_window_shape_region(self.xwindow, SK::INPUT, 0, 0, region.region())
.map_err(|_e| RequestError::Ignored)?;
.map_err(|err| os_error!(X11Error::from(err)))?;
self.shared_state_lock().cursor_hittest = Some(hittest);
Ok(())
}
Expand Down