Add back some window events for workspace

Co-Authored-By: Antonio <me@as-cii.com>
This commit is contained in:
Conrad Irwin 2023-11-02 10:03:03 -06:00
parent 0bab1a92df
commit 634aba89d2
4 changed files with 231 additions and 219 deletions

View file

@ -4,11 +4,11 @@ use crate::{
Entity, EntityId, EventEmitter, FileDropEvent, FocusEvent, FontId, GlobalElementId, GlyphId,
Hsla, ImageData, InputEvent, IsZero, KeyListener, KeyMatch, KeyMatcher, Keystroke, LayoutId,
Model, ModelContext, Modifiers, MonochromeSprite, MouseButton, MouseDownEvent, MouseMoveEvent,
MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformWindow, Point, PolychromeSprite,
PromptLevel, Quad, Render, RenderGlyphParams, RenderImageParams, RenderSvgParams, ScaledPixels,
SceneBuilder, Shadow, SharedString, Size, Style, SubscriberSet, Subscription,
TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext, WeakView,
WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,
MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformDisplay, PlatformWindow, Point,
PolychromeSprite, PromptLevel, Quad, Render, RenderGlyphParams, RenderImageParams,
RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size, Style, SubscriberSet,
Subscription, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext,
WeakView, WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,
};
use anyhow::{anyhow, Result};
use collections::HashMap;
@ -25,6 +25,7 @@ use std::{
hash::{Hash, Hasher},
marker::PhantomData,
mem,
rc::Rc,
sync::{
atomic::{AtomicUsize, Ordering::SeqCst},
Arc,
@ -570,6 +571,17 @@ impl<'a> WindowContext<'a> {
self.window.bounds
}
pub fn is_window_active(&self) -> bool {
self.window.active
}
pub fn display(&self) -> Option<Rc<dyn PlatformDisplay>> {
self.platform
.displays()
.into_iter()
.find(|display| display.id() == self.window.display_id)
}
/// The scale factor of the display associated with the window. For example, it could
/// return 2.0 for a "retina" display, indicating that each logical pixel should actually
/// be rendered as two pixels on screen.