winit-core: move window
Create `WindowAttributes` for respective platform specific window attributes in `winit` due to move of `WindowAttributes`.
This commit is contained in:
parent
c8b9a86885
commit
b4c5b76155
48 changed files with 843 additions and 808 deletions
|
|
@ -18,6 +18,7 @@ use sctk::reexports::client::{globals, Connection, QueueHandle};
|
|||
use tracing::warn;
|
||||
|
||||
use crate::application::ApplicationHandler;
|
||||
use crate::cursor::{CustomCursor as CoreCustomCursor, CustomCursorSource};
|
||||
use crate::dpi::LogicalSize;
|
||||
use crate::error::{EventLoopError, NotSupportedError, OsError, RequestError};
|
||||
use crate::event::{DeviceEvent, StartCause, SurfaceSizeWriter, WindowEvent};
|
||||
|
|
@ -29,7 +30,7 @@ use crate::monitor::MonitorHandle as CoreMonitorHandle;
|
|||
use crate::platform::pump_events::PumpStatus;
|
||||
use crate::platform_impl::platform::min_timeout;
|
||||
use crate::platform_impl::wayland::types::cursor::WaylandCustomCursor;
|
||||
use crate::window::{CustomCursor as CoreCustomCursor, CustomCursorSource, Theme};
|
||||
use crate::window::Theme;
|
||||
|
||||
mod proxy;
|
||||
pub mod sink;
|
||||
|
|
|
|||
|
|
@ -163,9 +163,9 @@ pub trait ZwpTextInputV3Ext {
|
|||
impl ZwpTextInputV3Ext for ZwpTextInputV3 {
|
||||
fn set_content_type_by_purpose(&self, purpose: ImePurpose) {
|
||||
let (hint, purpose) = match purpose {
|
||||
ImePurpose::Normal => (ContentHint::None, ContentPurpose::Normal),
|
||||
ImePurpose::Password => (ContentHint::SensitiveData, ContentPurpose::Password),
|
||||
ImePurpose::Terminal => (ContentHint::None, ContentPurpose::Terminal),
|
||||
_ => (ContentHint::None, ContentPurpose::Normal),
|
||||
};
|
||||
self.set_content_type(hint, purpose);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ use super::output::MonitorHandle;
|
|||
use super::state::WinitState;
|
||||
use super::types::xdg_activation::XdgActivationTokenData;
|
||||
use super::ActiveEventLoop;
|
||||
use crate::cursor::Cursor;
|
||||
use crate::dpi::{LogicalSize, PhysicalInsets, PhysicalPosition, PhysicalSize, Position, Size};
|
||||
use crate::error::{NotSupportedError, RequestError};
|
||||
use crate::event::{Ime, WindowEvent};
|
||||
use crate::event_loop::AsyncRequestSerial;
|
||||
use crate::monitor::{Fullscreen, MonitorHandle as CoreMonitorHandle};
|
||||
use crate::platform::wayland::WindowAttributesWayland;
|
||||
use crate::platform_impl::wayland::output;
|
||||
use crate::window::{
|
||||
Cursor, CursorGrabMode, ImePurpose, ResizeDirection, Theme, UserAttentionType,
|
||||
Window as CoreWindow, WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
||||
CursorGrabMode, ImePurpose, ResizeDirection, Theme, UserAttentionType, Window as CoreWindow,
|
||||
WindowAttributes, WindowButtons, WindowId, WindowLevel,
|
||||
};
|
||||
|
||||
pub(crate) mod state;
|
||||
|
|
@ -78,7 +80,7 @@ pub struct Window {
|
|||
impl Window {
|
||||
pub(crate) fn new(
|
||||
event_loop_window_target: &ActiveEventLoop,
|
||||
attributes: WindowAttributes,
|
||||
mut attributes: WindowAttributes,
|
||||
) -> Result<Self, RequestError> {
|
||||
let queue_handle = event_loop_window_target.queue_handle.clone();
|
||||
let mut state = event_loop_window_target.state.borrow_mut();
|
||||
|
|
@ -121,8 +123,15 @@ impl Window {
|
|||
// Set the decorations hint.
|
||||
window_state.set_decorate(attributes.decorations);
|
||||
|
||||
let (app_name, activation_token) =
|
||||
match attributes.platform.take().and_then(|p| p.cast::<WindowAttributesWayland>().ok())
|
||||
{
|
||||
Some(attrs) => (attrs.name, attrs.activation_token),
|
||||
None => (None, None),
|
||||
};
|
||||
|
||||
// Set the app_id.
|
||||
if let Some(name) = attributes.platform_specific.name.map(|name| name.general) {
|
||||
if let Some(name) = app_name.map(|name| name.general) {
|
||||
window.set_app_id(name);
|
||||
}
|
||||
|
||||
|
|
@ -162,10 +171,8 @@ impl Window {
|
|||
}
|
||||
|
||||
// Activate the window when the token is passed.
|
||||
if let (Some(xdg_activation), Some(token)) =
|
||||
(xdg_activation.as_ref(), attributes.platform_specific.activation_token)
|
||||
{
|
||||
xdg_activation.activate(token.token, &surface);
|
||||
if let (Some(xdg_activation), Some(token)) = (xdg_activation.as_ref(), activation_token) {
|
||||
xdg_activation.activate(token.into_raw(), &surface);
|
||||
}
|
||||
|
||||
// XXX Do initial commit.
|
||||
|
|
@ -497,7 +504,7 @@ impl CoreWindow for Window {
|
|||
|
||||
fn set_window_level(&self, _level: WindowLevel) {}
|
||||
|
||||
fn set_window_icon(&self, _window_icon: Option<crate::window::Icon>) {}
|
||||
fn set_window_icon(&self, _window_icon: Option<crate::icon::Icon>) {}
|
||||
|
||||
#[inline]
|
||||
fn set_ime_cursor_area(&self, position: Position, size: Size) {
|
||||
|
|
@ -678,23 +685,3 @@ impl WindowRequests {
|
|||
self.redraw_requested.swap(false, Ordering::Relaxed)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for Theme {
|
||||
type Error = ();
|
||||
|
||||
/// ```
|
||||
/// use winit::window::Theme;
|
||||
///
|
||||
/// assert_eq!("dark".try_into(), Ok(Theme::Dark));
|
||||
/// assert_eq!("lIghT".try_into(), Ok(Theme::Light));
|
||||
/// ```
|
||||
fn try_from(theme: &str) -> Result<Self, Self::Error> {
|
||||
if theme.eq_ignore_ascii_case("dark") {
|
||||
Ok(Self::Dark)
|
||||
} else if theme.eq_ignore_ascii_case("light") {
|
||||
Ok(Self::Light)
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use sctk::subcompositor::SubcompositorState;
|
|||
use tracing::{info, warn};
|
||||
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
|
||||
|
||||
use crate::cursor::CustomCursor as CoreCustomCursor;
|
||||
use crate::cursor::{CursorIcon, CustomCursor as CoreCustomCursor};
|
||||
use crate::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Size};
|
||||
use crate::error::{NotSupportedError, RequestError};
|
||||
use crate::platform_impl::wayland::event_loop::OwnedDisplayHandle;
|
||||
|
|
@ -41,7 +41,7 @@ use crate::platform_impl::wayland::types::cursor::{
|
|||
CustomCursor, SelectedCursor, WaylandCustomCursor,
|
||||
};
|
||||
use crate::platform_impl::wayland::types::kwin_blur::KWinBlurManager;
|
||||
use crate::window::{CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme, WindowId};
|
||||
use crate::window::{CursorGrabMode, ImePurpose, ResizeDirection, Theme, WindowId};
|
||||
|
||||
#[cfg(feature = "sctk-adwaita")]
|
||||
pub type WinitFrame = sctk_adwaita::AdwaitaFrame<WinitState>;
|
||||
|
|
@ -398,7 +398,7 @@ impl WindowState {
|
|||
self.apply_on_pointer(|_, data| {
|
||||
let serial = data.latest_button_serial();
|
||||
let seat = data.seat();
|
||||
xdg_toplevel.resize(seat, serial, direction.into());
|
||||
xdg_toplevel.resize(seat, serial, resize_direction_to_xdg(direction));
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
|
@ -1148,18 +1148,16 @@ pub enum FrameCallbackState {
|
|||
Received,
|
||||
}
|
||||
|
||||
impl From<ResizeDirection> for XdgResizeEdge {
|
||||
fn from(value: ResizeDirection) -> Self {
|
||||
match value {
|
||||
ResizeDirection::North => XdgResizeEdge::Top,
|
||||
ResizeDirection::West => XdgResizeEdge::Left,
|
||||
ResizeDirection::NorthWest => XdgResizeEdge::TopLeft,
|
||||
ResizeDirection::NorthEast => XdgResizeEdge::TopRight,
|
||||
ResizeDirection::East => XdgResizeEdge::Right,
|
||||
ResizeDirection::SouthWest => XdgResizeEdge::BottomLeft,
|
||||
ResizeDirection::SouthEast => XdgResizeEdge::BottomRight,
|
||||
ResizeDirection::South => XdgResizeEdge::Bottom,
|
||||
}
|
||||
fn resize_direction_to_xdg(direction: ResizeDirection) -> XdgResizeEdge {
|
||||
match direction {
|
||||
ResizeDirection::North => XdgResizeEdge::Top,
|
||||
ResizeDirection::West => XdgResizeEdge::Left,
|
||||
ResizeDirection::NorthWest => XdgResizeEdge::TopLeft,
|
||||
ResizeDirection::NorthEast => XdgResizeEdge::TopRight,
|
||||
ResizeDirection::East => XdgResizeEdge::Right,
|
||||
ResizeDirection::SouthWest => XdgResizeEdge::BottomLeft,
|
||||
ResizeDirection::SouthEast => XdgResizeEdge::BottomRight,
|
||||
ResizeDirection::South => XdgResizeEdge::Bottom,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue