Iced master merge (again)

This commit is contained in:
Bingus 2023-02-17 11:50:52 -08:00
parent 744cef5608
commit 2d427455ce
No known key found for this signature in database
GPG key ID: 5F84D2AA40A9F170
5 changed files with 34 additions and 12 deletions

View file

@ -441,7 +441,7 @@ impl Pane {
fn new(id: usize, axis: pane_grid::Axis) -> Self {
Self {
id,
scrollable_id: scrollable::Id::new(format!("{:?}", id)),
scrollable_id: scrollable::Id::unique(),
axis,
is_pinned: false,
is_moving: false,
@ -495,7 +495,7 @@ fn view_content<'a>(
controls,
]
.width(Length::Fill)
.height(Length::Units(800))
.height(800)
.spacing(10)
.align_items(Alignment::Center);

View file

@ -25,16 +25,15 @@ use glutin::surface::{GlSurface, SwapInterval};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use crate::application::gl_surface;
use iced_native::window::Action;
use iced_winit::multi_window::Event;
use std::collections::HashMap;
use std::ffi::CString;
use std::mem::ManuallyDrop;
use std::num::NonZeroU32;
use iced_native::widget::operation;
#[cfg(feature = "tracing")]
use tracing::{info_span, instrument::Instrument};
use iced_native::widget::operation;
#[allow(unsafe_code)]
const ONE: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(1) };
@ -937,16 +936,27 @@ pub fn run_command<A, E>(
let window = windows.get(&id).expect("No window found!");
window.set_decorations(!window.is_decorated());
}
Action::RequestUserAttention(attention_type) => {
window::Action::RequestUserAttention(attention_type) => {
let window = windows.get(&id).expect("No window found!");
window.request_user_attention(
attention_type.map(conversion::user_attention),
);
}
Action::GainFocus => {
window::Action::GainFocus => {
let window = windows.get(&id).expect("No window found!");
window.focus_window();
}
window::Action::ChangeAlwaysOnTop(on_top) => {
let window = windows.get(&id).expect("No window found!");
window.set_always_on_top(on_top);
}
window::Action::FetchId(tag) => {
let window = windows.get(&id).expect("No window found!");
proxy
.send_event(Event::Application(tag(window.id().into())))
.expect("Send message to event loop.")
}
},
command::Action::System(action) => match action {
system::Action::QueryInformation(_tag) => {

View file

@ -148,6 +148,7 @@ pub trait Application: Sized {
/// while a scale factor of `0.5` will shrink them to half their size.
///
/// By default, it returns `1.0`.
#[allow(unused_variables)]
fn scale_factor(&self, window: window::Id) -> f64 {
1.0
}

View file

@ -4,12 +4,12 @@ mod state;
pub use state::State;
use crate::clipboard::{self, Clipboard};
use crate::conversion;
use crate::mouse;
use crate::renderer;
use crate::settings;
use crate::widget::operation;
use crate::window;
use crate::conversion;
use crate::{
Command, Debug, Element, Error, Executor, Proxy, Renderer, Runtime,
Settings, Size, Subscription,
@ -22,7 +22,6 @@ use iced_native::user_interface::{self, UserInterface};
pub use iced_native::application::{Appearance, StyleSheet};
use iced_native::window::Action;
use std::collections::HashMap;
use std::mem::ManuallyDrop;
use std::time::Instant;
@ -147,6 +146,7 @@ where
/// while a scale factor of `0.5` will shrink them to half their size.
///
/// By default, it returns `1.0`.
#[allow(unused_variables)]
fn scale_factor(&self, window: window::Id) -> f64 {
1.0
}
@ -470,7 +470,7 @@ async fn run_instance<A, E, C>(
user_interface::State::Outdated,
)
{
let user_interfaces: HashMap<_, _> =
let cached_interfaces: HashMap<_, _> =
ManuallyDrop::into_inner(interfaces)
.drain()
.map(
@ -510,7 +510,7 @@ async fn run_instance<A, E, C>(
&mut renderer,
&mut debug,
&states,
user_interfaces,
cached_interfaces,
));
if application.should_exit() {
@ -1057,10 +1057,21 @@ pub fn run_command<A, E>(
attention_type.map(conversion::user_attention),
);
}
Action::GainFocus => {
window::Action::GainFocus => {
let window = windows.get(&id).expect("No window found!");
window.focus_window();
}
window::Action::ChangeAlwaysOnTop(on_top) => {
let window = windows.get(&id).expect("No window found!");
window.set_always_on_top(on_top);
}
window::Action::FetchId(tag) => {
let window = windows.get(&id).expect("No window found!");
proxy
.send_event(Event::Application(tag(window.id().into())))
.expect("Send message to event loop.")
}
},
command::Action::System(action) => match action {
system::Action::QueryInformation(_tag) => {

View file

@ -122,7 +122,7 @@ pub fn fetch_id<Message>(
id: window::Id,
f: impl FnOnce(u64) -> Message + 'static,
) -> Command<Message> {
Command::single(command::Action::Window(id: window::Id, window::Action::FetchId(Box::new(
Command::single(command::Action::Window(id, window::Action::FetchId(Box::new(
f,
))))
}