Move PlatformSpecificWindowBuilderAttributes (#3318)
This commit is contained in:
parent
aec608f93c
commit
d7c7ba1d6c
22 changed files with 145 additions and 156 deletions
|
|
@ -71,7 +71,7 @@ impl ApplicationName {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PlatformSpecificWindowBuilderAttributes {
|
||||
pub name: Option<ApplicationName>,
|
||||
pub activation_token: Option<ActivationToken>,
|
||||
|
|
@ -79,7 +79,7 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
|||
pub x11: X11WindowBuilderAttributes,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg(x11_platform)]
|
||||
pub struct X11WindowBuilderAttributes {
|
||||
pub visual_id: Option<x11rb::protocol::xproto::Visualid>,
|
||||
|
|
@ -288,16 +288,15 @@ impl Window {
|
|||
pub(crate) fn new(
|
||||
window_target: &EventLoopWindowTarget,
|
||||
attribs: WindowAttributes,
|
||||
pl_attribs: PlatformSpecificWindowBuilderAttributes,
|
||||
) -> Result<Self, RootOsError> {
|
||||
match *window_target {
|
||||
#[cfg(wayland_platform)]
|
||||
EventLoopWindowTarget::Wayland(ref window_target) => {
|
||||
wayland::Window::new(window_target, attribs, pl_attribs).map(Window::Wayland)
|
||||
wayland::Window::new(window_target, attribs).map(Window::Wayland)
|
||||
}
|
||||
#[cfg(x11_platform)]
|
||||
EventLoopWindowTarget::X(ref window_target) => {
|
||||
x11::Window::new(window_target, attribs, pl_attribs).map(Window::X)
|
||||
x11::Window::new(window_target, attribs).map(Window::X)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use crate::event::{Ime, WindowEvent};
|
|||
use crate::event_loop::AsyncRequestSerial;
|
||||
use crate::platform_impl::{
|
||||
Fullscreen, MonitorHandle as PlatformMonitorHandle, OsError, PlatformIcon,
|
||||
PlatformSpecificWindowBuilderAttributes as PlatformAttributes,
|
||||
};
|
||||
use crate::window::{
|
||||
Cursor, CursorGrabMode, ImePurpose, ResizeDirection, Theme, UserAttentionType,
|
||||
|
|
@ -84,7 +83,6 @@ impl Window {
|
|||
pub(crate) fn new(
|
||||
event_loop_window_target: &EventLoopWindowTarget,
|
||||
attributes: WindowAttributes,
|
||||
platform_attributes: PlatformAttributes,
|
||||
) -> Result<Self, RootOsError> {
|
||||
let queue_handle = event_loop_window_target.queue_handle.clone();
|
||||
let mut state = event_loop_window_target.state.borrow_mut();
|
||||
|
|
@ -134,7 +132,7 @@ impl Window {
|
|||
window_state.set_decorate(attributes.decorations);
|
||||
|
||||
// Set the app_id.
|
||||
if let Some(name) = platform_attributes.name.map(|name| name.general) {
|
||||
if let Some(name) = attributes.platform_specific.name.map(|name| name.general) {
|
||||
window.set_app_id(name);
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +175,7 @@ impl Window {
|
|||
// Activate the window when the token is passed.
|
||||
if let (Some(xdg_activation), Some(token)) = (
|
||||
xdg_activation.as_ref(),
|
||||
platform_attributes.activation_token,
|
||||
attributes.platform_specific.activation_token,
|
||||
) {
|
||||
xdg_activation.activate(token._token, &surface);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,10 +72,7 @@ use crate::{
|
|||
event::{Event, StartCause, WindowEvent},
|
||||
event_loop::{DeviceEvents, EventLoopClosed, EventLoopWindowTarget as RootELW},
|
||||
platform::pump_events::PumpStatus,
|
||||
platform_impl::{
|
||||
platform::{min_timeout, WindowId},
|
||||
PlatformSpecificWindowBuilderAttributes,
|
||||
},
|
||||
platform_impl::platform::{min_timeout, WindowId},
|
||||
window::WindowAttributes,
|
||||
};
|
||||
|
||||
|
|
@ -843,9 +840,8 @@ impl Window {
|
|||
pub(crate) fn new(
|
||||
event_loop: &EventLoopWindowTarget,
|
||||
attribs: WindowAttributes,
|
||||
pl_attribs: PlatformSpecificWindowBuilderAttributes,
|
||||
) -> Result<Self, RootOsError> {
|
||||
let window = Arc::new(UnownedWindow::new(event_loop, attribs, pl_attribs)?);
|
||||
let window = Arc::new(UnownedWindow::new(event_loop, attribs)?);
|
||||
event_loop
|
||||
.windows
|
||||
.borrow_mut()
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ use crate::{
|
|||
X11Error,
|
||||
},
|
||||
Fullscreen, MonitorHandle as PlatformMonitorHandle, OsError, PlatformCustomCursor,
|
||||
PlatformIcon, PlatformSpecificWindowBuilderAttributes,
|
||||
VideoModeHandle as PlatformVideoModeHandle,
|
||||
PlatformIcon, VideoModeHandle as PlatformVideoModeHandle,
|
||||
},
|
||||
window::{
|
||||
CursorGrabMode, ImePurpose, ResizeDirection, Theme, UserAttentionType, WindowAttributes,
|
||||
|
|
@ -156,7 +155,6 @@ impl UnownedWindow {
|
|||
pub(crate) fn new(
|
||||
event_loop: &EventLoopWindowTarget,
|
||||
window_attrs: WindowAttributes,
|
||||
pl_attribs: PlatformSpecificWindowBuilderAttributes,
|
||||
) -> Result<UnownedWindow, RootOsError> {
|
||||
let xconn = &event_loop.xconn;
|
||||
let atoms = xconn.atoms();
|
||||
|
|
@ -229,7 +227,7 @@ impl UnownedWindow {
|
|||
dimensions
|
||||
};
|
||||
|
||||
let screen_id = match pl_attribs.x11.screen_id {
|
||||
let screen_id = match window_attrs.platform_specific.x11.screen_id {
|
||||
Some(id) => id,
|
||||
None => xconn.default_screen_index() as c_int,
|
||||
};
|
||||
|
|
@ -249,7 +247,11 @@ impl UnownedWindow {
|
|||
});
|
||||
|
||||
// creating
|
||||
let (visualtype, depth, require_colormap) = match pl_attribs.x11.visual_id {
|
||||
let (visualtype, depth, require_colormap) = match window_attrs
|
||||
.platform_specific
|
||||
.x11
|
||||
.visual_id
|
||||
{
|
||||
Some(vi) => {
|
||||
// Find this specific visual.
|
||||
let (visualtype, depth) = all_visuals
|
||||
|
|
@ -291,12 +293,12 @@ impl UnownedWindow {
|
|||
|
||||
aux = aux.event_mask(event_mask).border_pixel(0);
|
||||
|
||||
if pl_attribs.x11.override_redirect {
|
||||
if window_attrs.platform_specific.x11.override_redirect {
|
||||
aux = aux.override_redirect(true as u32);
|
||||
}
|
||||
|
||||
// Add a colormap if needed.
|
||||
let colormap_visual = match pl_attribs.x11.visual_id {
|
||||
let colormap_visual = match window_attrs.platform_specific.x11.visual_id {
|
||||
Some(vi) => Some(vi),
|
||||
None if require_colormap => Some(visual),
|
||||
_ => None,
|
||||
|
|
@ -319,7 +321,11 @@ impl UnownedWindow {
|
|||
};
|
||||
|
||||
// Figure out the window's parent.
|
||||
let parent = pl_attribs.x11.embed_window.unwrap_or(root);
|
||||
let parent = window_attrs
|
||||
.platform_specific
|
||||
.x11
|
||||
.embed_window
|
||||
.unwrap_or(root);
|
||||
|
||||
// finally creating the window
|
||||
let xwindow = {
|
||||
|
|
@ -381,7 +387,7 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
// Embed the window if needed.
|
||||
if pl_attribs.x11.embed_window.is_some() {
|
||||
if window_attrs.platform_specific.x11.embed_window.is_some() {
|
||||
window.embed_window()?;
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +408,7 @@ impl UnownedWindow {
|
|||
|
||||
// WM_CLASS must be set *before* mapping the window, as per ICCCM!
|
||||
{
|
||||
let (class, instance) = if let Some(name) = pl_attribs.name {
|
||||
let (class, instance) = if let Some(name) = window_attrs.platform_specific.name {
|
||||
(name.instance, name.general)
|
||||
} else {
|
||||
let class = env::args_os()
|
||||
|
|
@ -435,7 +441,8 @@ impl UnownedWindow {
|
|||
flusher.ignore_error()
|
||||
}
|
||||
|
||||
leap!(window.set_window_types(pl_attribs.x11.x11_window_types)).ignore_error();
|
||||
leap!(window.set_window_types(window_attrs.platform_specific.x11.x11_window_types))
|
||||
.ignore_error();
|
||||
|
||||
// Set size hints.
|
||||
let mut min_inner_size = window_attrs
|
||||
|
|
@ -458,7 +465,7 @@ impl UnownedWindow {
|
|||
shared_state.min_inner_size = min_inner_size.map(Into::into);
|
||||
shared_state.max_inner_size = max_inner_size.map(Into::into);
|
||||
shared_state.resize_increments = window_attrs.resize_increments;
|
||||
shared_state.base_size = pl_attribs.x11.base_size;
|
||||
shared_state.base_size = window_attrs.platform_specific.x11.base_size;
|
||||
|
||||
let normal_hints = WmSizeHints {
|
||||
position: position.map(|PhysicalPosition { x, y }| {
|
||||
|
|
@ -474,7 +481,8 @@ impl UnownedWindow {
|
|||
size_increment: window_attrs
|
||||
.resize_increments
|
||||
.map(|size| cast_size_to_hint(size, scale_factor)),
|
||||
base_size: pl_attribs
|
||||
base_size: window_attrs
|
||||
.platform_specific
|
||||
.x11
|
||||
.base_size
|
||||
.map(|size| cast_size_to_hint(size, scale_factor)),
|
||||
|
|
@ -580,7 +588,7 @@ impl UnownedWindow {
|
|||
window.set_cursor(window_attrs.cursor);
|
||||
|
||||
// Remove the startup notification if we have one.
|
||||
if let Some(startup) = pl_attribs.activation_token.as_ref() {
|
||||
if let Some(startup) = window_attrs.platform_specific.activation_token.as_ref() {
|
||||
leap!(xconn.remove_activation_token(xwindow, &startup._token));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue