x11: Call ApplicationHandler directly
Instead of going through the Event enum.
This commit is contained in:
parent
f290619dce
commit
f9912baf09
3 changed files with 225 additions and 391 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -24,7 +24,7 @@ use x11rb::xcb_ffi::ReplyOrIdError;
|
||||||
|
|
||||||
use crate::application::ApplicationHandler;
|
use crate::application::ApplicationHandler;
|
||||||
use crate::error::{EventLoopError, RequestError};
|
use crate::error::{EventLoopError, RequestError};
|
||||||
use crate::event::{DeviceId, Event, StartCause, WindowEvent};
|
use crate::event::{DeviceId, StartCause, WindowEvent};
|
||||||
use crate::event_loop::{
|
use crate::event_loop::{
|
||||||
ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents,
|
ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents,
|
||||||
EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider,
|
EventLoopProxy as CoreEventLoopProxy, EventLoopProxyProvider,
|
||||||
|
|
@ -574,22 +574,7 @@ impl EventLoop {
|
||||||
|
|
||||||
while unsafe { self.event_processor.poll_one_event(xev.as_mut_ptr()) } {
|
while unsafe { self.event_processor.poll_one_event(xev.as_mut_ptr()) } {
|
||||||
let mut xev = unsafe { xev.assume_init() };
|
let mut xev = unsafe { xev.assume_init() };
|
||||||
self.event_processor.process_event(&mut xev, |window_target, event: Event| {
|
self.event_processor.process_event(&mut xev, app);
|
||||||
if let Event::WindowEvent { window_id, event: WindowEvent::RedrawRequested } = event
|
|
||||||
{
|
|
||||||
window_target.redraw_sender.send(window_id);
|
|
||||||
} else {
|
|
||||||
match event {
|
|
||||||
Event::WindowEvent { window_id, event } => {
|
|
||||||
app.window_event(window_target, window_id, event)
|
|
||||||
},
|
|
||||||
Event::DeviceEvent { device_id, event } => {
|
|
||||||
app.device_event(window_target, device_id, event)
|
|
||||||
},
|
|
||||||
_ => unreachable!("event which is neither device nor window event."),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,11 @@ use super::util::{self, SelectedCursor};
|
||||||
use super::{
|
use super::{
|
||||||
ffi, ActiveEventLoop, CookieResultExt, ImeRequest, ImeSender, VoidCookie, XConnection,
|
ffi, ActiveEventLoop, CookieResultExt, ImeRequest, ImeSender, VoidCookie, XConnection,
|
||||||
};
|
};
|
||||||
|
use crate::application::ApplicationHandler;
|
||||||
use crate::cursor::{Cursor, CustomCursor as RootCustomCursor};
|
use crate::cursor::{Cursor, CustomCursor as RootCustomCursor};
|
||||||
use crate::dpi::{PhysicalInsets, PhysicalPosition, PhysicalSize, Position, Size};
|
use crate::dpi::{PhysicalInsets, PhysicalPosition, PhysicalSize, Position, Size};
|
||||||
use crate::error::{NotSupportedError, RequestError};
|
use crate::error::{NotSupportedError, RequestError};
|
||||||
use crate::event::{Event, SurfaceSizeWriter, WindowEvent};
|
use crate::event::{SurfaceSizeWriter, WindowEvent};
|
||||||
use crate::event_loop::AsyncRequestSerial;
|
use crate::event_loop::AsyncRequestSerial;
|
||||||
use crate::platform::x11::WindowType;
|
use crate::platform::x11::WindowType;
|
||||||
use crate::platform_impl::x11::atoms::*;
|
use crate::platform_impl::x11::atoms::*;
|
||||||
|
|
@ -1211,7 +1212,8 @@ impl UnownedWindow {
|
||||||
&self,
|
&self,
|
||||||
new_monitor: &X11MonitorHandle,
|
new_monitor: &X11MonitorHandle,
|
||||||
maybe_prev_scale_factor: Option<f64>,
|
maybe_prev_scale_factor: Option<f64>,
|
||||||
mut callback: impl FnMut(Event),
|
app: &mut dyn ApplicationHandler,
|
||||||
|
event_loop: &ActiveEventLoop,
|
||||||
) {
|
) {
|
||||||
// Check if the self is on this monitor
|
// Check if the self is on this monitor
|
||||||
let monitor = self.shared_state_lock().last_monitor.clone();
|
let monitor = self.shared_state_lock().last_monitor.clone();
|
||||||
|
|
@ -1231,12 +1233,9 @@ impl UnownedWindow {
|
||||||
|
|
||||||
let old_surface_size = PhysicalSize::new(width, height);
|
let old_surface_size = PhysicalSize::new(width, height);
|
||||||
let surface_size = Arc::new(Mutex::new(PhysicalSize::new(new_width, new_height)));
|
let surface_size = Arc::new(Mutex::new(PhysicalSize::new(new_width, new_height)));
|
||||||
callback(Event::WindowEvent {
|
app.window_event(event_loop, self.id(), WindowEvent::ScaleFactorChanged {
|
||||||
window_id: self.id(),
|
scale_factor: new_monitor.scale_factor,
|
||||||
event: WindowEvent::ScaleFactorChanged {
|
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&surface_size)),
|
||||||
scale_factor: new_monitor.scale_factor,
|
|
||||||
surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade(&surface_size)),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let new_surface_size = *surface_size.lock().unwrap();
|
let new_surface_size = *surface_size.lock().unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue