mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Move output_size to utils
This commit is contained in:
+1
-1
@@ -43,8 +43,8 @@ use smithay::{
|
||||
delegate_text_input_manager, delegate_virtual_keyboard_manager,
|
||||
};
|
||||
|
||||
use crate::layout::output_size;
|
||||
use crate::niri::State;
|
||||
use crate::utils::output_size;
|
||||
|
||||
impl SeatHandler for State {
|
||||
type KeyboardFocus = WlSurface;
|
||||
|
||||
+1
-10
@@ -57,6 +57,7 @@ use smithay::wayland::shell::xdg::SurfaceCachedState;
|
||||
|
||||
use crate::animation::Animation;
|
||||
use crate::config::{self, Color, Config, PresetWidth, SizeChange, Struts};
|
||||
use crate::utils::output_size;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct OutputId(String);
|
||||
@@ -3264,16 +3265,6 @@ impl<W: LayoutElement> Column<W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn output_size(output: &Output) -> Size<i32, Logical> {
|
||||
let output_scale = output.current_scale().integer_scale();
|
||||
let output_transform = output.current_transform();
|
||||
let output_mode = output.current_mode().unwrap();
|
||||
|
||||
output_transform
|
||||
.transform_size(output_mode.size)
|
||||
.to_logical(output_scale)
|
||||
}
|
||||
|
||||
fn compute_working_area(output: &Output, struts: Struts) -> Rectangle<i32, Logical> {
|
||||
// Start with the layer-shell non-exclusive zone.
|
||||
let mut working_area = layer_map_for_output(output).non_exclusive_zone();
|
||||
|
||||
+4
-2
@@ -90,10 +90,12 @@ use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri};
|
||||
use crate::frame_clock::FrameClock;
|
||||
use crate::handlers::configure_lock_surface;
|
||||
use crate::input::TabletData;
|
||||
use crate::layout::{output_size, Layout, MonitorRenderElement};
|
||||
use crate::layout::{Layout, MonitorRenderElement};
|
||||
use crate::pw_utils::{Cast, PipeWire};
|
||||
use crate::screenshot_ui::{ScreenshotUi, ScreenshotUiRenderElement};
|
||||
use crate::utils::{center, get_monotonic_time, make_screenshot_path, write_png_rgba8};
|
||||
use crate::utils::{
|
||||
center, get_monotonic_time, make_screenshot_path, output_size, write_png_rgba8,
|
||||
};
|
||||
|
||||
const CLEAR_COLOR: [f32; 4] = [0.2, 0.2, 0.2, 1.];
|
||||
const CLEAR_COLOR_LOCKED: [f32; 4] = [0.3, 0.1, 0.1, 1.];
|
||||
|
||||
+12
-1
@@ -11,8 +11,9 @@ use std::time::Duration;
|
||||
|
||||
use anyhow::{ensure, Context};
|
||||
use directories::UserDirs;
|
||||
use smithay::output::Output;
|
||||
use smithay::reexports::rustix::time::{clock_gettime, ClockId};
|
||||
use smithay::utils::{Logical, Point, Rectangle};
|
||||
use smithay::utils::{Logical, Point, Rectangle, Size};
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
@@ -25,6 +26,16 @@ pub fn center(rect: Rectangle<i32, Logical>) -> Point<i32, Logical> {
|
||||
rect.loc + rect.size.downscale(2).to_point()
|
||||
}
|
||||
|
||||
pub fn output_size(output: &Output) -> Size<i32, Logical> {
|
||||
let output_scale = output.current_scale().integer_scale();
|
||||
let output_transform = output.current_transform();
|
||||
let output_mode = output.current_mode().unwrap();
|
||||
|
||||
output_transform
|
||||
.transform_size(output_mode.size)
|
||||
.to_logical(output_scale)
|
||||
}
|
||||
|
||||
pub fn make_screenshot_path(config: &Config) -> anyhow::Result<Option<PathBuf>> {
|
||||
let Some(path) = &config.screenshot_path else {
|
||||
return Ok(None);
|
||||
|
||||
Reference in New Issue
Block a user