Skip to content

Commit

Permalink
Move PlatformSpecificWindowBuilderAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Jan 17, 2024
1 parent aec608f commit ef164ea
Show file tree
Hide file tree
Showing 22 changed files with 145 additions and 156 deletions.
13 changes: 7 additions & 6 deletions src/platform/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,38 +217,39 @@ pub trait WindowBuilderExtIOS {
impl WindowBuilderExtIOS for WindowBuilder {
#[inline]
fn with_scale_factor(mut self, scale_factor: f64) -> Self {
self.platform_specific.scale_factor = Some(scale_factor);
self.window.platform_specific.scale_factor = Some(scale_factor);
self
}

#[inline]
fn with_valid_orientations(mut self, valid_orientations: ValidOrientations) -> Self {
self.platform_specific.valid_orientations = valid_orientations;
self.window.platform_specific.valid_orientations = valid_orientations;
self
}

#[inline]
fn with_prefers_home_indicator_hidden(mut self, hidden: bool) -> Self {
self.platform_specific.prefers_home_indicator_hidden = hidden;
self.window.platform_specific.prefers_home_indicator_hidden = hidden;
self
}

#[inline]
fn with_preferred_screen_edges_deferring_system_gestures(mut self, edges: ScreenEdge) -> Self {
self.platform_specific
self.window
.platform_specific
.preferred_screen_edges_deferring_system_gestures = edges;
self
}

#[inline]
fn with_prefers_status_bar_hidden(mut self, hidden: bool) -> Self {
self.platform_specific.prefers_status_bar_hidden = hidden;
self.window.platform_specific.prefers_status_bar_hidden = hidden;
self
}

#[inline]
fn with_preferred_status_bar_style(mut self, status_bar_style: StatusBarStyle) -> Self {
self.platform_specific.preferred_status_bar_style = status_bar_style;
self.window.platform_specific.preferred_status_bar_style = status_bar_style;
self
}
}
Expand Down
23 changes: 12 additions & 11 deletions src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,69 +212,70 @@ pub trait WindowBuilderExtMacOS {
impl WindowBuilderExtMacOS for WindowBuilder {
#[inline]
fn with_movable_by_window_background(mut self, movable_by_window_background: bool) -> Self {
self.platform_specific.movable_by_window_background = movable_by_window_background;
self.window.platform_specific.movable_by_window_background = movable_by_window_background;
self
}

#[inline]
fn with_titlebar_transparent(mut self, titlebar_transparent: bool) -> Self {
self.platform_specific.titlebar_transparent = titlebar_transparent;
self.window.platform_specific.titlebar_transparent = titlebar_transparent;
self
}

#[inline]
fn with_titlebar_hidden(mut self, titlebar_hidden: bool) -> Self {
self.platform_specific.titlebar_hidden = titlebar_hidden;
self.window.platform_specific.titlebar_hidden = titlebar_hidden;
self
}

#[inline]
fn with_titlebar_buttons_hidden(mut self, titlebar_buttons_hidden: bool) -> Self {
self.platform_specific.titlebar_buttons_hidden = titlebar_buttons_hidden;
self.window.platform_specific.titlebar_buttons_hidden = titlebar_buttons_hidden;
self
}

#[inline]
fn with_title_hidden(mut self, title_hidden: bool) -> Self {
self.platform_specific.title_hidden = title_hidden;
self.window.platform_specific.title_hidden = title_hidden;
self
}

#[inline]
fn with_fullsize_content_view(mut self, fullsize_content_view: bool) -> Self {
self.platform_specific.fullsize_content_view = fullsize_content_view;
self.window.platform_specific.fullsize_content_view = fullsize_content_view;
self
}

#[inline]
fn with_disallow_hidpi(mut self, disallow_hidpi: bool) -> Self {
self.platform_specific.disallow_hidpi = disallow_hidpi;
self.window.platform_specific.disallow_hidpi = disallow_hidpi;
self
}

#[inline]
fn with_has_shadow(mut self, has_shadow: bool) -> Self {
self.platform_specific.has_shadow = has_shadow;
self.window.platform_specific.has_shadow = has_shadow;
self
}

#[inline]
fn with_accepts_first_mouse(mut self, accepts_first_mouse: bool) -> Self {
self.platform_specific.accepts_first_mouse = accepts_first_mouse;
self.window.platform_specific.accepts_first_mouse = accepts_first_mouse;
self
}

#[inline]
fn with_tabbing_identifier(mut self, tabbing_identifier: &str) -> Self {
self.platform_specific
self.window
.platform_specific
.tabbing_identifier
.replace(tabbing_identifier.to_string());
self
}

#[inline]
fn with_option_as_alt(mut self, option_as_alt: OptionAsAlt) -> Self {
self.platform_specific.option_as_alt = option_as_alt;
self.window.platform_specific.option_as_alt = option_as_alt;
self
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/startup_notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl WindowExtStartupNotify for Window {

impl WindowBuilderExtStartupNotify for WindowBuilder {
fn with_activation_token(mut self, token: ActivationToken) -> Self {
self.platform_specific.activation_token = Some(token);
self.window.platform_specific.activation_token = Some(token);
self
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub trait WindowBuilderExtWayland {
impl WindowBuilderExtWayland for WindowBuilder {
#[inline]
fn with_name(mut self, general: impl Into<String>, instance: impl Into<String>) -> Self {
self.platform_specific.name = Some(crate::platform_impl::ApplicationName::new(
self.window.platform_specific.name = Some(crate::platform_impl::ApplicationName::new(
general.into(),
instance.into(),
));
Expand Down
8 changes: 4 additions & 4 deletions src/platform/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,22 @@ pub trait WindowBuilderExtWebSys {

impl WindowBuilderExtWebSys for WindowBuilder {
fn with_canvas(mut self, canvas: Option<HtmlCanvasElement>) -> Self {
self.platform_specific.set_canvas(canvas);
self.window.platform_specific.set_canvas(canvas);
self
}

fn with_prevent_default(mut self, prevent_default: bool) -> Self {
self.platform_specific.prevent_default = prevent_default;
self.window.platform_specific.prevent_default = prevent_default;
self
}

fn with_focusable(mut self, focusable: bool) -> Self {
self.platform_specific.focusable = focusable;
self.window.platform_specific.focusable = focusable;
self
}

fn with_append(mut self, append: bool) -> Self {
self.platform_specific.append = append;
self.window.platform_specific.append = append;
self
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,49 +222,49 @@ pub trait WindowBuilderExtWindows {
impl WindowBuilderExtWindows for WindowBuilder {
#[inline]
fn with_owner_window(mut self, parent: HWND) -> Self {
self.platform_specific.owner = Some(parent);
self.window.platform_specific.owner = Some(parent);
self
}

#[inline]
fn with_menu(mut self, menu: HMENU) -> Self {
self.platform_specific.menu = Some(menu);
self.window.platform_specific.menu = Some(menu);
self
}

#[inline]
fn with_taskbar_icon(mut self, taskbar_icon: Option<Icon>) -> Self {
self.platform_specific.taskbar_icon = taskbar_icon;
self.window.platform_specific.taskbar_icon = taskbar_icon;
self
}

#[inline]
fn with_no_redirection_bitmap(mut self, flag: bool) -> Self {
self.platform_specific.no_redirection_bitmap = flag;
self.window.platform_specific.no_redirection_bitmap = flag;
self
}

#[inline]
fn with_drag_and_drop(mut self, flag: bool) -> Self {
self.platform_specific.drag_and_drop = flag;
self.window.platform_specific.drag_and_drop = flag;
self
}

#[inline]
fn with_skip_taskbar(mut self, skip: bool) -> Self {
self.platform_specific.skip_taskbar = skip;
self.window.platform_specific.skip_taskbar = skip;
self
}

#[inline]
fn with_class_name<S: Into<String>>(mut self, class_name: S) -> Self {
self.platform_specific.class_name = class_name.into();
self.window.platform_specific.class_name = class_name.into();
self
}

#[inline]
fn with_undecorated_shadow(mut self, shadow: bool) -> Self {
self.platform_specific.decoration_shadow = shadow;
self.window.platform_specific.decoration_shadow = shadow;
self
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/platform/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,19 @@ pub trait WindowBuilderExtX11 {
impl WindowBuilderExtX11 for WindowBuilder {
#[inline]
fn with_x11_visual(mut self, visual_id: XVisualID) -> Self {
self.platform_specific.x11.visual_id = Some(visual_id);
self.window.platform_specific.x11.visual_id = Some(visual_id);
self
}

#[inline]
fn with_x11_screen(mut self, screen_id: i32) -> Self {
self.platform_specific.x11.screen_id = Some(screen_id);
self.window.platform_specific.x11.screen_id = Some(screen_id);
self
}

#[inline]
fn with_name(mut self, general: impl Into<String>, instance: impl Into<String>) -> Self {
self.platform_specific.name = Some(crate::platform_impl::ApplicationName::new(
self.window.platform_specific.name = Some(crate::platform_impl::ApplicationName::new(
general.into(),
instance.into(),
));
Expand All @@ -211,25 +211,25 @@ impl WindowBuilderExtX11 for WindowBuilder {

#[inline]
fn with_override_redirect(mut self, override_redirect: bool) -> Self {
self.platform_specific.x11.override_redirect = override_redirect;
self.window.platform_specific.x11.override_redirect = override_redirect;
self
}

#[inline]
fn with_x11_window_type(mut self, x11_window_types: Vec<WindowType>) -> Self {
self.platform_specific.x11.x11_window_types = x11_window_types;
self.window.platform_specific.x11.x11_window_types = x11_window_types;
self
}

#[inline]
fn with_base_size<S: Into<Size>>(mut self, base_size: S) -> Self {
self.platform_specific.x11.base_size = Some(base_size.into());
self.window.platform_specific.x11.base_size = Some(base_size.into());
self
}

#[inline]
fn with_embed_parent_window(mut self, parent_window_id: XWindow) -> Self {
self.platform_specific.x11.embed_window = Some(parent_window_id);
self.window.platform_specific.x11.embed_window = Some(parent_window_id);
self
}
}
Expand Down
1 change: 0 additions & 1 deletion src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ impl Window {
pub(crate) fn new(
el: &EventLoopWindowTarget,
_window_attrs: window::WindowAttributes,
_: PlatformSpecificWindowBuilderAttributes,
) -> Result<Self, error::OsError> {
// FIXME this ignores requested window attributes

Expand Down
35 changes: 23 additions & 12 deletions src/platform_impl/ios/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::{
platform::ios::ValidOrientations,
platform_impl::platform::{
ffi::{UIRectEdge, UIUserInterfaceIdiom},
window::PlatformSpecificWindowBuilderAttributes,
Fullscreen, DEVICE_ID,
},
window::{WindowAttributes, WindowId as RootWindowId},
Expand Down Expand Up @@ -264,8 +263,7 @@ extern_methods!(
impl WinitView {
pub(crate) fn new(
_mtm: MainThreadMarker,
_window_attributes: &WindowAttributes,
platform_attributes: &PlatformSpecificWindowBuilderAttributes,
window_attributes: &WindowAttributes,
frame: CGRect,
) -> Id<Self> {
let this = Self::alloc().set_ivars(WinitViewState {
Expand All @@ -277,7 +275,7 @@ impl WinitView {

this.setMultipleTouchEnabled(true);

if let Some(scale_factor) = platform_attributes.scale_factor {
if let Some(scale_factor) = window_attributes.platform_specific.scale_factor {
this.setContentScaleFactor(scale_factor as _);
}

Expand Down Expand Up @@ -515,8 +513,7 @@ impl WinitViewController {

pub(crate) fn new(
mtm: MainThreadMarker,
_window_attributes: &WindowAttributes,
platform_attributes: &PlatformSpecificWindowBuilderAttributes,
window_attributes: &WindowAttributes,
view: &UIView,
) -> Id<Self> {
// These are set properly below, we just to set them to something in the meantime.
Expand All @@ -529,18 +526,33 @@ impl WinitViewController {
});
let this: Id<Self> = unsafe { msg_send_id![super(this), init] };

this.set_prefers_status_bar_hidden(platform_attributes.prefers_status_bar_hidden);
this.set_prefers_status_bar_hidden(
window_attributes
.platform_specific
.prefers_status_bar_hidden,
);

this.set_preferred_status_bar_style(platform_attributes.preferred_status_bar_style.into());
this.set_preferred_status_bar_style(
window_attributes
.platform_specific
.preferred_status_bar_style
.into(),
);

this.set_supported_interface_orientations(mtm, platform_attributes.valid_orientations);
this.set_supported_interface_orientations(
mtm,
window_attributes.platform_specific.valid_orientations,
);

this.set_prefers_home_indicator_auto_hidden(
platform_attributes.prefers_home_indicator_hidden,
window_attributes
.platform_specific
.prefers_home_indicator_hidden,
);

this.set_preferred_screen_edges_deferring_system_gestures(
platform_attributes
window_attributes
.platform_specific
.preferred_screen_edges_deferring_system_gestures
.into(),
);
Expand Down Expand Up @@ -597,7 +609,6 @@ impl WinitUIWindow {
pub(crate) fn new(
mtm: MainThreadMarker,
window_attributes: &WindowAttributes,
_platform_attributes: &PlatformSpecificWindowBuilderAttributes,
frame: CGRect,
view_controller: &UIViewController,
) -> Id<Self> {
Expand Down
Loading

0 comments on commit ef164ea

Please sign in to comment.